From 9506a2cb819d240a403a0a10d9acd28428805e91 Mon Sep 17 00:00:00 2001 From: niekt0 Date: Sat, 1 Oct 2011 02:50:21 +0200 Subject: [PATCH] get_poll moved to backend (TODO: rewrite/remove) --- wwwroot/backend/mysql/backend.inc | 16 +++++++ .../smarty/node_methodz/function.get_poll.php | 44 +++++++++---------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/wwwroot/backend/mysql/backend.inc b/wwwroot/backend/mysql/backend.inc index deacb13..971bb10 100644 --- a/wwwroot/backend/mysql/backend.inc +++ b/wwwroot/backend/mysql/backend.inc @@ -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; +} + + } ?> diff --git a/wwwroot/inc/smarty/node_methodz/function.get_poll.php b/wwwroot/inc/smarty/node_methodz/function.get_poll.php index e19b77f..23f2c9e 100644 --- a/wwwroot/inc/smarty/node_methodz/function.get_poll.php +++ b/wwwroot/inc/smarty/node_methodz/function.get_poll.php @@ -1,31 +1,31 @@ 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); } ?> -- 2.30.2