function _photos_useralbum_option in Album Photos 7.3
Same name and namespace in other branches
- 6.2 photos.module \_photos_useralbum_option()
User albums.
3 calls to _photos_useralbum_option()
- photos_admin_import in inc/
photos.admin.inc - Upload to album form.
- photos_editlist_form in inc/
photos.edit.inc - Edit list form.
- photos_upload_form in inc/
photos.edit.inc - Upload form.
File
- ./
photos.module, line 1609 - Implementation of photos.module.
Code
function _photos_useralbum_option($uid = 0, $current = 0) {
if (!$uid) {
$uid = $GLOBALS['user']->uid;
}
$output = array();
if (arg(1) == 'quote' && $_GET['type'] != 'upload') {
$choice = new stdClass();
$choice->option = array(
t('All albums'),
);
$output[] = $choice;
}
// @todo cleanup and test.
$result = db_query('SELECT n.nid, n.title FROM {node} n INNER JOIN {photos_album} a ON a.pid = n.nid WHERE n.uid = :uid ORDER BY n.nid DESC', array(
':uid' => $uid,
));
$query = db_select('node', 'n');
$query
->join('photos_album', 'a', 'a.pid = n.nid');
$query
->fields('n', array(
'nid',
'title',
));
$query
->condition('n.uid', $uid);
$query
->orderBy('n.nid', 'DESC');
$result = $query
->execute();
$true = FALSE;
foreach ($result as $a) {
$choice = new stdClass();
$choice->option = array(
$a->nid => $a->title,
);
$output[] = $choice;
$true = TRUE;
}
if ($current) {
$choice = new stdClass();
$choice->option = array(
$current[0] => $current[1],
);
$output[] = $choice;
}
if (!$true) {
$output = array(
t('You do not have an album yet.'),
);
}
return $output;
}