You are here

function _photos_edit_page_albums in Album Photos 7.3

Get albums for album re-arrange page.

1 call to _photos_edit_page_albums()
photos_edit_sort_album_page in inc/photos.edit.inc
Grid drag and drop album sorting.

File

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

Code

function _photos_edit_page_albums($uid) {
  $albums = array();
  $query = db_select('node', 'n');
  $query
    ->join('photos_album', 'p', 'p.pid = n.nid');
  $query
    ->fields('n', array(
    'nid',
    'title',
  ));
  $query
    ->fields('p', array(
    'wid',
    'fid',
    'count',
  ));
  $query
    ->condition('n.uid', $uid);
  $query
    ->orderBy('p.wid', 'ASC');
  $query
    ->orderBy('n.nid', 'DESC');
  $result = $query
    ->execute();
  foreach ($result as $data) {
    if (isset($data->fid) && $data->fid != 0) {
      $cover_fid = $data->fid;
    }
    else {
      $cover_fid = db_query("SELECT fid FROM {photos_image} WHERE pid = :pid", array(
        ':pid' => $data->nid,
      ))
        ->fetchField();
      if (empty($cover_fid)) {

        // Skip albums with no images.
        continue;
      }
    }
    $albums[] = array(
      'wid' => $data->wid,
      'nid' => $data->nid,
      'fid' => $cover_fid,
      'count' => $data->count,
      'title' => $data->title,
    );
  }
  return $albums;
}