return $get_children_array;
}
+// XXX
+
+public static function getPoll($user_id,$poll_id) {
+ global $db;
+
+ $set=$db->query("select nodes.*,node_access.node_permission from nodes
+ left join node_access on (nodes.node_id=node_access.node_id and node_access.user_id='$user_id')
+ where node_parent='$poll_id' and template_id='1549834' order by node_id desc limit 1");
+
+ $set->next();
+ $array=$set->getRecord();
+
+ return $array;
+}
+
+
}
?>
<?php
// bugfix. Opravuje zobrazovanie ankiet v nadparentoch kde nemaju byt.
-function smarty_function_get_poll($params,&$smarty) {
-global $db,$node;
-$user_id=$_SESSION['user_id'];
-$node_vector=$node['node_vector'];
-if (!is_numeric($params['poll_id'])) $poll_id=$node['node_id'];
-else $poll_id=$params['poll_id'];
-
-if (is_array($params['poll'])) {
-$array=$params['poll'];
-$voted='yes';
-}
+// XXX Wotta fokka, rewrite completly.
-else {
-$set=$db->query("select nodes.*,node_access.node_permission from nodes left join node_access on (nodes.node_id=node_access.node_id and node_access.user_id='$user_id') where node_parent='$poll_id' and template_id='1549834' order by node_id desc limit 1");
+function smarty_function_get_poll($params,&$smarty) {
+ global $node;
+ $user_id=$_SESSION['user_id'];
+ $node_vector=$node['node_vector'];
+ if (isset($params['poll_id']) && is_numeric($params['poll_id'])) {
+ $poll_id=$params['poll_id'];
+ } else {
+ $poll_id=$node['node_id'];
+ }
-$set->next();
-$array=$set->getRecord();
-if ($array['node_permission']=='ban') $voted='yes';
-else $voted='no';
-}
+ if (isset($params['poll']) && is_array($params['poll'])) {
+ $array=$params['poll'];
+ $voted='yes';
+ } else {
+ $array=nodes::getPoll($user_id,$poll_id);
+ if ($array['node_permission']=='ban') $voted='yes';
+ else $voted='no';
+ }
-$option_array=unserialize($array['node_content']);
-$permission=$array['node_permission'];
+ $option_array=unserialize($array['node_content']);
+ $permission=$array['node_permission']; // XXX WTF? sec. hole?
-$poll=Array("voted"=>$voted,"node_id"=>$array['node_id'],"question"=>$array['node_name'],"total"=>$array['node_views'],"options"=>$option_array);
-$smarty->assign('get_poll',$poll);
+ $poll=Array("voted"=>$voted,"node_id"=>$array['node_id'],"question"=>$array['node_name'],"total"=>$array['node_views'],"options"=>$option_array);
+ $smarty->assign('get_poll',$poll);
}
?>