function photos_edit_sort_subalbums_save in Album Photos 7.3
Save weight for array of image id's in sub-album.
1 call to photos_edit_sort_subalbums_save()
- _photos_ajax_helper in ./
photos.module - Ajax helper, perform different ajax requests.
File
- inc/
photos.edit.inc, line 422 - Handles uploading and editing images.
Code
function photos_edit_sort_subalbums_save($order = array(), $nid = 0) {
if ($nid) {
$access = FALSE;
if ($nid) {
$node = node_load($nid);
// Check for node_accss.
$access = _photos_access('editAlbum', $node);
}
if ($access) {
$weight = 0;
// Update weight for all images in array / album.
foreach ($order as $image_id) {
$fid = str_replace('photos_', '', $image_id);
db_query("UPDATE {photos_node} SET wid = :wid WHERE fid = :fid AND nid = :nid", array(
':wid' => $weight,
':fid' => $fid,
':nid' => $nid,
));
$weight++;
}
if ($weight > 0) {
$message = t('Image order saved!');
return $message;
}
}
}
}