function _photos_block_album in Album Photos 6.2
Same name and namespace in other branches
- 7.3 photos.module \_photos_block_album()
1 call to _photos_block_album()
File
- ./
photos.module, line 788
Code
function _photos_block_album($type, $limit, $url = 0, $uid = 0, $sort = ' n.nid DESC') {
switch ($type) {
case 'user':
$where = ' WHERE n.uid = ' . $uid;
break;
case 'rand':
$sort = ' RAND()';
}
$result = db_query_range(db_rewrite_sql('SELECT n.nid, n.title, p.count, p.fid, u.uid, u.name FROM {x_album} p INNER JOIN {node} n ON p.pid = n.nid INNER JOIN {users} u ON n.uid = u.uid' . $where . ' ORDER BY' . $sort), $limit);
$i = 0;
while ($node = db_fetch_object($result)) {
if ($node->fid) {
$view = photos_get_info($node->fid, 0, array(
'href' => 'photos/album/' . $node->nid,
'filename' => $node->title,
));
}
else {
$image = db_fetch_array(db_query_range('SELECT f.fid, f.filepath, f.filename FROM {files} f INNER JOIN {x_image} p ON f.fid = p.fid WHERE p.pid = %d ORDER BY f.fid DESC', $node->nid, 0, 1));
if ($image['fid']) {
$view = photos_get_info(0, $image, array(
'href' => 'photos/album/' . $node->nid,
'filename' => $node->title,
));
}
}
$album[] = array(
'node' => $node,
'view' => $view,
);
++$i;
}
if ($i) {
$content = theme('photos_block', $album, 'album');
if ($url && $i >= $limit) {
$content .= theme('more_link', url($url), t('View more'));
}
if ($type == 'user') {
return array(
$content,
$album[0]['node']->name,
);
}
else {
return $content;
}
}
}