You are here

function photos_edit_sort_save in Album Photos 7.3

Save weight for array of image id's.

1 call to photos_edit_sort_save()
_photos_ajax_helper in ./photos.module
Ajax helper, perform different ajax requests.

File

inc/photos.edit.inc, line 394
Handles uploading and editing images.

Code

function photos_edit_sort_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_image} SET wid = :wid WHERE fid = :fid AND pid = :pid", array(
          ':wid' => $weight,
          ':fid' => $fid,
          ':pid' => $nid,
        ));
        $weight++;
      }
      if ($weight > 0) {
        $message = t('Image order saved!');
        return $message;
      }
    }
  }
}