function gallery_assist_public_status_updater in Gallery Assist 6
Update the public status fron all existing galleries from an assignment.
Parameters
$type: A string with the node type.
$status: A integer with the selected status id.
1 call to gallery_assist_public_status_updater()
- gallery_assist_settings_submit in ./
gallery_assist.module - Update the settings of gallery_assist or of assignments.
File
- ./
gallery_assist.module, line 5844 - Drupal content type with gallery functionality.
Code
function gallery_assist_public_status_updater($type, $status) {
if (empty($type)) {
return;
}
$names = array(
0 => t('public'),
1 => t('privat'),
2 => t('public for all'),
);
$q = "SELECT g.gid, g.nid, n.type FROM {gallery_assist} g, {node} n WHERE g.nid = n.nid AND n.type = '%s'";
$result = db_rewrite_sql(db_query($q, $type));
$i = 0;
while ($r = db_fetch_object($result)) {
++$i;
db_query("UPDATE {gallery_assist} SET ga_public_status = %d WHERE gid = %d", $status, $r->gid);
db_query("DELETE FROM {cache_gallery_assist_data} WHERE cid = %d", $r->nid);
}
if ($i == 1) {
$message = 'One gallery was updated with public status = @status.';
}
elseif ($i > 1) {
$message = '@num galleries were updated with public status = @status.';
}
else {
return;
}
drupal_set_message($message);
}