get_poll moved to backend (TODO: rewrite/remove)
authorniekt0 <niekt0@kyberia.cz>
Sat, 1 Oct 2011 00:50:21 +0000 (02:50 +0200)
committerniekt0 <niekt0@kyberia.cz>
Sat, 1 Oct 2011 00:50:21 +0000 (02:50 +0200)
wwwroot/backend/mysql/backend.inc
wwwroot/inc/smarty/node_methodz/function.get_poll.php

index deacb13a808a0d367d1a47ff158b26fbddb6ee3f..971bb104bd3a7aba4f2f97bbfcd87c67b6789d00 100644 (file)
@@ -683,6 +683,22 @@ public static function getThreadedChildren($node_id,$node_vector,$offset,$limit,
        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;
+}
+
+
 }
 
 ?>
index e19b77f99eeb5b070b9d56bab7bb825747594411..23f2c9e58929af36c84b3a5315c79a2e43a712d7 100644 (file)
@@ -1,31 +1,31 @@
 <?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);
 
 }
 ?>
This page took 0.107813 seconds and 4 git commands to generate.