Changeset 2146
- Timestamp:
- 03/30/10 02:37:23 (13 years ago)
- Location:
- plugins/pollsFactory
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/pollsFactory/_admin.php
r2139 r2146 33 33 $core->addBehavior('adminGalleryHeaders',array('adminPollsFactory','adminPostHeaders')); 34 34 35 $core->addBehavior('adminAfterPostCreate',array('adminPollsFactory','adminAfterPost Save'));36 $core->addBehavior('adminAfterPageCreate',array('adminPollsFactory','adminAfterPost Save'));37 $core->addBehavior('adminAfterGalleryCreate',array('adminPollsFactory','adminAfterPost Save'));38 39 $core->addBehavior('adminAfterPostUpdate',array('adminPollsFactory','adminAfterPost Save'));40 $core->addBehavior('adminAfterPageUpdate',array('adminPollsFactory','adminAfterPost Save'));41 $core->addBehavior('adminAfterGalleryUpdate',array('adminPollsFactory','adminAfterPost Save'));35 $core->addBehavior('adminAfterPostCreate',array('adminPollsFactory','adminAfterPostCreate')); 36 $core->addBehavior('adminAfterPageCreate',array('adminPollsFactory','adminAfterPostCreate')); 37 $core->addBehavior('adminAfterGalleryCreate',array('adminPollsFactory','adminAfterPostCreate')); 38 39 $core->addBehavior('adminAfterPostUpdate',array('adminPollsFactory','adminAfterPostUpdate')); 40 $core->addBehavior('adminAfterPageUpdate',array('adminPollsFactory','adminAfterPostUpdate')); 41 $core->addBehavior('adminAfterGalleryUpdate',array('adminPollsFactory','adminAfterPostUpdate')); 42 42 43 43 $core->addBehavior('adminPostsActionsCombo',array('adminPollsFactory','adminPostsActionsCombo')); … … 163 163 } 164 164 165 # On new post create polls/post relation 166 public static function adminAfterPostCreate($cur,$post_id) 167 { 168 if (empty($_POST['pollspostlist'])) return; 169 170 global $core; 171 $factory = new pollsFactory($core); 172 173 $cur = $factory->open(); 174 foreach($_POST['pollspostlist'] as $k => $poll_id) { 175 $cur->clean(); 176 $cur->option_type = 'pollspost'; 177 $cur->post_id = $post_id; 178 $cur->option_meta = $poll_id; 179 $factory->addOption($cur); 180 } 181 } 182 165 183 # If javascript is disabled, update polls/post relation 166 public static function adminAfterPost Save($cur,$post_id)184 public static function adminAfterPostUpdate($cur,$post_id) 167 185 { 168 186 if (empty($_POST['oldpollspostlist'])) return; … … 279 297 $rels_params['option_type'] = 'pollspost'; 280 298 $rels_params['post_id'] = $entries; 281 $rels_params['group'] = 'option_meta'; 299 $rels_params['sql'] = 'GROUP BY option_meta '; 300 $rels_params['order'] = 'option_meta ASC'; 282 301 $rels = $factory->getOptions($rels_params); 283 302 … … 309 328 $rels_params['option_type'] = 'pollspost'; 310 329 $rels_params['post_id'] = $entries; 311 $rels_params['group'] = 'option_meta'; 330 $rels_params['sql'] = 'GROUP BY option_meta '; 331 $rels_params['order'] = 'option_meta ASC'; 312 332 $rels = $factory->getOptions($rels_params); 313 333 … … 339 359 $rels_params['option_type'] = 'pollspost'; 340 360 $rels_params['post_id'] = $entries; 341 $rels_params['group'] = 'option_meta'; 361 $rels_params['sql'] = 'GROUP BY option_meta '; 362 $rels_params['order'] = 'option_meta ASC'; 342 363 $rels = $factory->getOptions($rels_params); 343 364 … … 369 390 $rels_params['option_type'] = 'pollspost'; 370 391 $rels_params['post_id'] = $entries; 371 $rels_params['group'] = 'option_meta'; 392 $rels_params['sql'] = 'GROUP BY option_meta '; 393 $rels_params['order'] = 'option_meta ASC'; 372 394 $rels = $factory->getOptions($rels_params); 373 395 … … 399 421 $rels_params['option_type'] = 'pollspost'; 400 422 $rels_params['post_id'] = $entries; 401 $rels_params['group'] = 'option_meta'; 423 $rels_params['sql'] = 'GROUP BY option_meta '; 424 $rels_params['order'] = 'option_meta ASC'; 402 425 $rels = $factory->getOptions($rels_params); 403 426 … … 429 452 $rels_params['option_type'] = 'pollspost'; 430 453 $rels_params['post_id'] = $entries; 431 $rels_params['group'] = 'option_meta'; 454 $rels_params['sql'] = 'GROUP BY option_meta '; 455 $rels_params['order'] = 'option_meta ASC'; 432 456 $rels = $factory->getOptions($rels_params); 433 457 … … 504 528 case 'addpolls': 505 529 while ($posts->fetch()) { 506 # Delete relations between post and polls507 $factory->delOption(null,'pollspost',$posts->post_id);508 530 509 531 # Add relations selected polls to entries 510 532 $cur = $factory->open(); 511 533 foreach($pollentries as $k => $id) { 534 535 # First delete relations between post and polls if exists 536 $factory->delOption(null,'pollspost',$posts->post_id,$id); 537 512 538 $cur->clean(); 513 539 $cur->option_type = 'pollspost'; -
plugins/pollsFactory/_define.php
r2139 r2146 17 17 /* Description*/ "Add polls to entries", 18 18 /* Author */ "JC Denis", 19 /* Version */ '1. 0',19 /* Version */ '1.1', 20 20 /* Permissions */ 'usage,contentadmin' 21 21 ); 22 /* date */ #201003 2822 /* date */ #20100330 23 23 ?> -
plugins/pollsFactory/_public.php
r2140 r2146 359 359 $queries_params['option_type'] = 'pollsquery'; 360 360 $queries_params['post_id'] = $poll->post_id; 361 $queries_params['order'] = 'option_position ASC'; 361 362 $queries = $factory->getOptions($queries_params); 362 363 # No query for this poll … … 370 371 $selections_params['post_id'] = $poll->post_id; 371 372 $selections_params['option_meta'] = $queries->option_id; 373 $selections_params['order'] = 'option_position ASC'; 372 374 $selections = $factory->getOptions($selections_params); 373 375 # No option for this query … … 466 468 $queries_params['option_type'] = 'pollsquery'; 467 469 $queries_params['post_id'] = $poll->post_id; 470 $queries_params['order'] = 'option_position ASC'; 468 471 $queries = $factory->getOptions($queries_params); 469 472 # No query for this poll -
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 -
plugins/pollsFactory/index.php
r2139 r2146 80 80 $default_tab = 'setting'; 81 81 } 82 require dirname(__FILE__).'/inc/index.'.$default_tab.'.php';82 include dirname(__FILE__).'/inc/index.'.$default_tab.'.php'; 83 83 84 84 ?> -
plugins/pollsFactory/release.txt
r2139 r2146 3 3 * Not fixed bug on image refresh 4 4 5 0.1 20100328 5 1.1 20100330 6 * Fixed order of queries and selections 7 * Fixed admin posts list actions 8 * Fixed adding polls from new post 9 * Fixed pgSQL bugs 10 11 1.0 20100328 6 12 * Rewrited plugin 7 13
Note: See TracChangeset
for help on using the changeset viewer.