function node_gallery_handler_field_gid::pre_render in Node Gallery 6.2
File
- includes/
node_gallery_handler_field_gid.inc, line 40 - node_gallery_handler_field_gid.inc
Class
Code
function pre_render(&$values) {
foreach ($values as $value) {
//$fids[$this->field_alias] = $value->{$value->{$this->aliases[$this->additional_fields['fid']]}};
$gids[] = $value->{$this->field_alias};
}
if (!empty($gids)) {
$result = db_query(db_rewrite_sql("SELECT n.nid, ng.*, f.filepath, n.title FROM {node} n INNER JOIN {node_galleries} ng ON\n n.nid = ng.gid INNER JOIN {files} f ON ng.fid = f.fid\n WHERE ng.gid IN (" . db_placeholders($gids) . ") AND is_cover > 0"), $gids);
while ($r = db_fetch_array($result)) {
$items[$r['gid']] = $r;
}
// If nga is active, then fetch the access type and password from the db and merge it for use later in render()
if (module_exists('node_gallery_access')) {
$nids = array_keys($items);
$result = db_query("SELECT n.uid, n.nid, nga.access_type, nga.password FROM {node} n INNER JOIN {node_gallery_access} nga ON n.nid = nga.nid WHERE n.nid IN (" . db_placeholders($nids) . ")", $nids);
while ($r = db_fetch_array($result)) {
$items[$r['nid']] = array_merge((array) $items[$r['nid']], $r);
}
}
foreach ($values as $value) {
$new = array_merge((array) $value, $items[$value->{$this->field_alias}]);
$new_items[] = (object) $new;
}
$values = $new_items;
}
}