You are here

function _photos_to_sub in Album Photos 6.2

Same name and namespace in other branches
  1. 7.3 inc/photos.edit.inc \_photos_to_sub()
1 string reference to '_photos_to_sub'
photos_edit_to_sub in inc/photos.edit.inc

File

inc/photos.edit.inc, line 428

Code

function _photos_to_sub(&$form_state, $fid) {
  $select_type = _photos_select_sub_album();
  if ($select_type[0]) {
    $form['title']['#value'] = '<h2>' . t('Please select sub-album: ') . '</h2>';
    $result = db_query('SELECT nid FROM {x_node} WHERE fid = %d', $fid);
    while ($sub = db_fetch_object($result)) {
      $select_sub[] = $sub->nid;
    }
    if (!$select_sub[0]) {
      $select_sub[0] = 0;
    }
    $result = pager_query('SELECT nid, title FROM {node} WHERE type IN (' . implode(',', $select_type) . ') AND nid NOT IN (' . implode(',', $select_sub) . ')', 50, 0);
    $form['sub']['#tree'] = true;
    $true = false;
    while ($node = db_fetch_object($result)) {
      $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']['#value'] = t('You do not have can be used to receive a subset of the album.');
    }
  }
  else {
    $form['help']['#value'] = t('Sub-album feature is not turned on.');
  }
  return $form;
}