function scald_update_author in Scald: Media Management made easy 6
Updates an Author's details.
Parameters
$aid: The Author ID of the Author whose information is being updated.
$data: A keyed array with the same elements as the $data parameter from scald_register_author(). Any elements not present will not be updated.
Return value
A boolean indicating success or failure
1 call to scald_update_author()
- scald_user in ./
scald.module - Implementation of hook_user().
File
- ./
scald.module, line 1730
Code
function scald_update_author($aid, $data = array()) {
// Validate arguments
if (empty($aid) || !is_numeric($aid) || empty($data)) {
return FALSE;
}
$sets = array();
$sql_data = array();
foreach ($data as $field => $value) {
switch ($field) {
case 'name':
$sets[] = 'name = \'%s\'';
$sql_data[] = $value;
break;
// end 'name'
case 'uid':
$sets[] = 'uid = %d';
$sql_data[] = $value;
if (!isset($data['url'])) {
$sets[] = 'url = \'' . url('user') . '/%d\'';
$sql_data[] = $value;
}
break;
// end 'uid'
case 'url':
$sets[] = 'url = \'%s\'';
$sql_data[] = $value;
break;
// end 'url'
default:
continue;
}
}
$sql_data[] = $aid;
if (!db_query("\n UPDATE\n {scald_authors}\n SET " . implode(', ', $sets) . "\n WHERE\n aid = %d\n ", $sql_data)) {
return FALSE;
}
}