Dotclear


Ignore:
Timestamp:
03/30/10 02:37:23 (13 years ago)
Author:
JcDenis
Message:

pollsFactory 1.1:

  • Fixed order of queries and selections
  • Fixed admin posts list actions
  • Fixed adding polls from new post
  • Fixed pgSQL bugs
Location:
plugins/pollsFactory/inc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/pollsFactory/inc/class.pollsfactory.php

    r2139 r2146  
    4747          if($ident > 0) 
    4848          { 
    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               ); 
    5457 
    5558               if (!$rs->isEmpty()) $chk = true; 
     
    7679               "AND option_type = 'pollsresponse' ". 
    7780               'GROUP BY option_title, post_id '. 
    78                'ORDER BY option_upddt DESC '. 
     81               'ORDER BY option_title DESC '. 
    7982               $q 
    8083          ); 
     
    8487     public function countVotes($poll_id) 
    8588     { 
    86           $params['option_type'] = 'pollsresponse'; 
    87           $params['post_id'] = (integer) $poll_id; 
    88           $params['group'] = 'option_title'; 
     89          $poll_id = (integer) $poll_id; 
    8990 
    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(); 
    9398     } 
    9499 
  • plugins/pollsFactory/inc/class.postoption.php

    r2139 r2146  
    110110     public function getOptions($params=array(),$count_only=false) 
    111111     { 
    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  
    125112          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) '; 
    132114          } 
    133115          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 '; 
    149126          } 
    150127 
     
    212189               $q .= $params['sql'].' '; 
    213190          } 
    214           # group 
    215           if (!empty($group)) { 
    216                if (!$count_only) { 
    217                     $q .= 'GROUP BY '.implode(', ',$group).' '; 
    218                } 
    219                else { 
    220                     $q .= 'GROUP BY '.$group[0].' '; 
    221                } 
    222           } 
    223191          # order 
    224192          if (!$count_only) { 
  • plugins/pollsFactory/inc/index.polls.php

    r2139 r2146  
    451451); 
    452452 
    453 echo dcPage::helpBlock('pollsFactory').$footer.'</body></html>'; 
     453dcPage::helpBlock('pollsFactory'); 
     454echo $footer.'</body></html>'; 
    454455?> 
  • plugins/pollsFactory/inc/index.result.php

    r2140 r2146  
    199199          $queries_params['option_type'] = 'pollsquery'; 
    200200          $queries_params['post_id'] = $poll_id; 
     201          $queries_params['order'] = 'option_position ASC'; 
    201202          $queries = $factory->getOptions($queries_params); 
    202203          if (!$queries->isEmpty()) { 
     
    307308     $queries_params['option_type'] = 'pollsquery'; 
    308309     $queries_params['post_id'] = $poll_id; 
     310     $queries_params['order'] = 'option_position ASC'; 
    309311     $queries = $factory->getOptions($queries_params); 
    310312 
Note: See TracChangeset for help on using the changeset viewer.

Sites map