Changeset 2146 for plugins/pollsFactory/inc
- Timestamp:
- 03/30/10 02:37:23 (13 years ago)
- Location:
- plugins/pollsFactory/inc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pollsFactory/inc/class.pollsfactory.php
r2139 r2146 47 47 if($ident > 0) 48 48 { 49 $params['option_type'] = 'pollsresponse'; 50 $params['post_id'] = $poll_id; 51 $params['option_title'] = $this->con->escape(http::realIP()); 52 53 $rs = $this->getOptions($params); 49 $rs = $this->con->select( 50 'SELECT option_id '. 51 'FROM '.$this->table.' '. 52 'WHERE post_id = '.$poll_id.' '. 53 "AND option_title = '".$this->con->escape(http::realIP())."' ". 54 "AND option_type = 'pollsresponse' ". 55 $this->con->limit(1) 56 ); 54 57 55 58 if (!$rs->isEmpty()) $chk = true; … … 76 79 "AND option_type = 'pollsresponse' ". 77 80 'GROUP BY option_title, post_id '. 78 'ORDER BY option_ upddtDESC '.81 'ORDER BY option_title DESC '. 79 82 $q 80 83 ); … … 84 87 public function countVotes($poll_id) 85 88 { 86 $params['option_type'] = 'pollsresponse'; 87 $params['post_id'] = (integer) $poll_id; 88 $params['group'] = 'option_title'; 89 $poll_id = (integer) $poll_id; 89 90 90 $rs = $this->getOptions($params); 91 92 return $rs->count(); 91 return $this->con->select( 92 'SELECT option_title '. 93 'FROM '.$this->table.' '. 94 'WHERE post_id = '.$poll_id.' '. 95 "AND option_type = 'pollsresponse' ". 96 'GROUP BY option_title ' 97 )->count(); 93 98 } 94 99 -
plugins/pollsFactory/inc/class.postoption.php
r2139 r2146 110 110 public function getOptions($params=array(),$count_only=false) 111 111 { 112 // This limit field to only one and group results on this field.113 $group = array();114 if (!empty($params['group'])) {115 if (is_array($params['group'])) {116 foreach($params['group'] as $k => $v) {117 $group[] = $this->con->escape($v);118 }119 }120 else {121 $group[] = $this->con->escape($params['group']);122 }123 }124 125 112 if ($count_only) { 126 if (!empty($group)) { 127 $q = 'SELECT count('.$group[0].') '; 128 } 129 else { 130 $q = 'SELECT count(O.option_id) '; 131 } 113 $q = 'SELECT count(O.option_id) '; 132 114 } 133 115 else { 134 if (!empty($group)) { 135 $q = 'SELECT '.implode(', ',$group).' '; 136 } 137 else { 138 $q = 'SELECT O.option_id, O.post_id, O.option_meta, '; 139 140 if (!empty($params['columns']) && is_array($params['columns'])) { 141 $q .= implode(', ',$params['columns']).', '; 142 } 143 $q .= 144 'O.option_creadt, O.option_upddt, O.option_type, O.option_format, '. 145 'O.option_title, O.option_content, O.option_content_xhtml, '. 146 'O.option_selected, O.option_position, '. 147 'P.blog_id, P.post_type, P.post_title '; 148 } 116 $q = 'SELECT O.option_id, O.post_id, O.option_meta, '; 117 118 if (!empty($params['columns']) && is_array($params['columns'])) { 119 $q .= implode(', ',$params['columns']).', '; 120 } 121 $q .= 122 'O.option_creadt, O.option_upddt, O.option_type, O.option_format, '. 123 'O.option_title, O.option_content, O.option_content_xhtml, '. 124 'O.option_selected, O.option_position, '. 125 'P.blog_id, P.post_type, P.post_title '; 149 126 } 150 127 … … 212 189 $q .= $params['sql'].' '; 213 190 } 214 # group215 if (!empty($group)) {216 if (!$count_only) {217 $q .= 'GROUP BY '.implode(', ',$group).' ';218 }219 else {220 $q .= 'GROUP BY '.$group[0].' ';221 }222 }223 191 # order 224 192 if (!$count_only) { -
plugins/pollsFactory/inc/index.polls.php
r2139 r2146 451 451 ); 452 452 453 echo dcPage::helpBlock('pollsFactory').$footer.'</body></html>'; 453 dcPage::helpBlock('pollsFactory'); 454 echo $footer.'</body></html>'; 454 455 ?> -
plugins/pollsFactory/inc/index.result.php
r2140 r2146 199 199 $queries_params['option_type'] = 'pollsquery'; 200 200 $queries_params['post_id'] = $poll_id; 201 $queries_params['order'] = 'option_position ASC'; 201 202 $queries = $factory->getOptions($queries_params); 202 203 if (!$queries->isEmpty()) { … … 307 308 $queries_params['option_type'] = 'pollsquery'; 308 309 $queries_params['post_id'] = $poll_id; 310 $queries_params['order'] = 'option_position ASC'; 309 311 $queries = $factory->getOptions($queries_params); 310 312
Note: See TracChangeset
for help on using the changeset viewer.