exposing the dark side of adoption
Register Log in

Polls

public

0) { // For each category ID, generate an array of descendant category IDs to the right depth. $descendant_cids = array(); if ($depth === 'all' || $depth < 0) { $depth = NULL; } foreach ($cids as $index => $cid) { $category = category_get_category($cid); $cnid = $category->cnid ? $category->cnid : $cid; $tree = category_get_tree($cnid, $cid, -1, $depth, $distant); $descendant_cids[] = array_merge(array($cid), array_map('_category_get_cid_from_category', $tree)); } $group_by = 'n.nid, n.sticky, n.title, n.created'; if ($operator == 'or') { $str_cids = implode(',', call_user_func_array('array_merge', $descendant_cids)); $sql = 'SELECT DISTINCT(n.nid), n.sticky, n.title, n.created FROM {node} n INNER JOIN {category_node} cn ON n.nid = cn.nid WHERE cn.cid IN ('. $str_cids .') AND n.status = 1 GROUP BY '. $group_by .' ORDER BY '. $order; $sql_count = 'SELECT COUNT(DISTINCT(n.nid)) FROM {node} n INNER JOIN {category_node} cn ON n.nid = cn.nid WHERE cn.cid IN ('. $str_cids .') AND n.status = 1'; } else { $joins = ''; $wheres = ''; foreach ($descendant_cids as $index => $cids) { $joins .= ' INNER JOIN {category_node} cn'. $index .' ON n.nid = cn'. $index .'.nid'; $wheres .= ' AND cn'. $index .'.cid IN ('. implode(',', $cids) .')'; } $sql = 'SELECT n.nid, n.sticky, n.title, n.created FROM {node} n '. $joins .' WHERE n.status = 1 '. $wheres .' GROUP BY '. $group_by .' ORDER BY '. $order; $sql_count = 'SELECT COUNT(n.nid) FROM {node} n '. $joins .' WHERE n.status = 1 ' . $wheres; } $sql = db_rewrite_sql($sql); $sql_count = db_rewrite_sql($sql_count); if ($pager) { $result = pager_query($sql, variable_get('default_nodes_main', 5), 0, $sql_count); } else { $result = db_query($sql); } } return $result;} $nid = (int)arg(1); $cid = $_GET['cid']; if($cid != null){ $res = db_query(db_rewrite_sql('SELECT n.type FROM {node} n WHERE n.nid = %d AND n.status = 1'), $cid); $typerec = db_fetch_object($res); $type = $typerec->type; $cids = array(); if ($type == "theme_page"){ $result8 = db_query(db_rewrite_sql('SELECT cft.field_themes_nid FROM {content_field_themes } cft INNER JOIN {node} n ON cft.nid = n.nid AND cft.vid = n.vid INNER JOIN {node} n2 ON n2.nid = cft.field_themes_nid WHERE n.nid = %d AND n.status = 1'), $cid); $nids8 = array(); $nids8[] = $cid; while ($node8 = db_fetch_object($result8)) { $nids8[] = $node8->field_themes_nid; } while ($node8 = db_fetch_object($result8)) { $nids8[] = $node8->field_themes_nid; } $str_nids = implode(', ', $nids8); $result = db_query(db_rewrite_sql('SELECT cft.field_topics_nid FROM {content_field_topics } cft INNER JOIN {node} n ON cft.nid = n.nid AND cft.vid = n.vid WHERE n.status = 1 AND n.nid IN (' . $str_nids . ')' )); while ($cat = db_fetch_object($result)) { $cids[] = $cat->field_topics_nid; } } else if ($type == "category_cat"){ $cids[0] = $cid; } if ($cids[0] != null){ $result2 = category_select_polls($cids, 'or', -1, FALSE, FALSE, 'n.created DESC'); $nodes = array(); while ($node = db_fetch_object($result2)) { $nodes[] = $node->nid; } $sql2 = "SELECT n.nid, n.title, n.type, u.name, u.uid, n.created, nc.totalcount, ncs.last_comment_timestamp, ncs.comment_count, n.changed FROM {node} n INNER JOIN {users} u ON n.uid = u.uid INNER JOIN {node_counter} nc ON nc.nid = n.nid INNER JOIN {node_comment_statistics} ncs ON ncs.nid = n.nid WHERE n.status = 1 AND n.type = 'poll' AND n.nid IN (" . implode(', ', $nodes) . ")"; $header = array( array('data' => t('Title'), 'field' => 'n.title'), array('data' => t('Author'), 'field' => 'name'), array('data' => t('Reads'), 'field' => 'totalcount'), array('data' => t('Replies'), 'field' => 'comment_count'), array('data' => t('Latest Comment'), 'field' => 'last_comment_timestamp', 'sort' => 'desc'), ); $result3 = pager_query(db_rewrite_sql($sql2 . tablesort_sql($header)), 25, 0); while ($data = db_fetch_object($result3)) { $comments = intval($data->comment_count); if ($comments && $new = comment_num_new($data->nid)) { $comments .= '

'; $comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid", NULL, NULL, 'new'); } $rows[] = array( l($data->title, "node/$data->nid") . ' ' . theme('mark', node_mark($data->nid, $data->changed)), l($data->name, "user/$data->uid"), $data->totalcount, $comments, format_interval(time() - $data->last_comment_timestamp, 2), ); } print str_replace('

<>
by Admin on Monday, 02 June 2008