You are here

function _photos_to_sub in Album Photos 7.3

Same name and namespace in other branches
  1. 6.2 inc/photos.edit.inc \_photos_to_sub()

Move to sub album form.

1 string reference to '_photos_to_sub'
photos_edit_to_sub in inc/photos.edit.inc
Move image to sub album.

File

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

Code

function _photos_to_sub($form, &$form_state, $fid) {
  $select_type = _photos_select_sub_album();
  if ($select_type[0]) {
    $form['title']['#markup'] = '<h2>' . t('Please select sub-album') . ': ' . '</h2>';
    $query = db_select('photos_node', 'p')
      ->fields('p', array(
      'nid',
    ))
      ->condition('fid', $fid);
    $result = $query
      ->execute();
    $select_sub = array();
    foreach ($result as $sub) {
      $select_sub[] = $sub->nid;
    }
    if (!isset($select_sub[0])) {
      $select_sub[] = 0;
    }
    $query = db_select('node', 'n')
      ->extend('PagerDefault');
    $query
      ->fields('n', array(
      'nid',
      'title',
    ))
      ->condition('n.type', $select_type, 'IN')
      ->condition('n.nid', $select_sub, 'NOT IN')
      ->limit(50);
    $result = $query
      ->execute();
    $form['sub']['#tree'] = TRUE;
    $true = FALSE;
    foreach ($result as $node) {
      $form['sub'][$node->nid] = array(
        '#type' => 'checkbox',
        '#title' => l($node->title, 'node/' . $node->nid, array(
          'attributes' => array(
            'target' => '_blank',
          ),
        )),
      );
      $true = TRUE;
    }
    if ($true) {
      $form['fid'] = array(
        '#type' => 'value',
        '#value' => $fid,
      );
      $form['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Send confirmation'),
        '#submit' => array(
          '_photos_to_sub_submit',
        ),
      );
    }
    else {
      $form['help']['#markup'] = t('There are no additional sub albums available.');
    }
  }
  else {
    $form['help']['#markup'] = t('Sub-album feature is not turned on.');
  }
  return $form;
}