~primes2h/ubuntu-qa-website/bug_726645

« back to all changes in this revision

Viewing changes to code/modules/qapoll/models/choicelist.php

  • Committer: Nicolas Deschildre
  • Date: 2008-08-04 19:21:05 UTC
  • mto: This revision was merged to the branch mainline in revision 127.
  • Revision ID: ndeschildre@gmail.com-20080804192105-1zfu28xw9u8dzbbm
[QAPoll] Create the problem/solution SQL schema, implement the solution view in the idea listings.
- Also added pre-update-db.sh, which will enable the PL/pgsql language on the qawebsite database, before running update-db.sh.

Show diffs side-by-side

added added

removed removed

Lines of Context:
130
130
         * and was not read by the user, set the item_comment_unread_flag col to true.
131
131
         * include_item_edition_unread_flag: Specify if we should also compute the "unread" flag: When an was edited less than one week ago,
132
132
         * and was not read by the user, set the include_item_edition_unread_flag col to true.
 
133
         * include_choice_solutions: Specify if we should also fetch the choice solution (separate subquery).
133
134
         */
134
135
        var $_include_minimal_data = false;
135
136
        var $_include_user_vote = true;
141
142
        var $_include_user_extra_data = true;
142
143
        var $_include_item_comment_unread_flag = false;
143
144
        var $_include_item_edition_unread_flag = false;
 
145
        var $_include_choice_solutions_flag = true;
144
146
 
145
147
        /**
146
148
         * The data filter array currently in use.
185
187
                while ($choice = db_fetch_object($choices))
186
188
                        $choicelist[] = $choice;
187
189
 
188
 
                //Get the user infos, if revelant (e.g. listing the items of a user)
189
 
                if($this->_userid != -1)
190
 
                        $user = user_load(array("uid" => $this->_userid));
 
190
                //For each choice, fetch the corresponding solution list
 
191
                if($this->_include_choice_solutions_flag == true)
 
192
                {
 
193
                        foreach($choicelist as $choice)
 
194
                        {
 
195
                                $choicesolutionlist = new ChoiceSolutionListModel();
 
196
                                $choicesolutionlist->setFilterParameters(array("choice_id" => $choice->id));
 
197
                                $choice->solutions = $choicesolutionlist->getData();
 
198
                        }
 
199
                }
191
200
 
192
201
                $poll = $this->_pollModel->getData();
193
202
 
197
206
                $data->page = $this->_page;
198
207
                $data->numberRowsPerPage = $this->_numberRowsPerPage;
199
208
                $data->rowCount = $this->_getRowCount();
200
 
                if($user != null)
201
 
                        $data->_userinfos = $user;
202
209
                //Use the entry point title as the title
203
210
                $data->title = $entrypoint->getData()->title;
204
211
 
568
575
                switch($this->_ordering)
569
576
                {
570
577
                        case "mosthype-day":
571
 
                                $orderby = "ideavotes/EXTRACT(EPOCH FROM (NOW() - qapoll_choice.date)) DESC ";
 
578
                                $orderby = "totalvotes/EXTRACT(EPOCH FROM (NOW() - qapoll_choice.date)) DESC ";
572
579
                        break;
573
580
 
574
581
                        //To prevent young ideas to appear always on top, give an minimum age of one day to each item.
821
828
                        $this->_include_user_extra_data = false;
822
829
                        $this->_include_item_comment_unread_flag = false;
823
830
                        $this->_include_item_edition_unread_flag = false;
 
831
                        $this->_include_choice_solutions_flag = false;
824
832
                }
825
833
                else
826
834
                {
843
851
                                $this->_include_item_comment_unread_flag = $filter_array['include_item_comment_unread_flag'];
844
852
                        if($filter_array['include_item_edition_unread_flag'] != null && is_numeric($filter_array['include_item_edition_unread_flag']))
845
853
                                $this->_include_item_edition_unread_flag = $filter_array['include_item_edition_unread_flag'];
 
854
                        if($filter_array['include_choice_solutions_flag'] != null && is_numeric($filter_array['include_choice_solutions_flag']))
 
855
                                $this->_include_choice_solutions_flag = $filter_array['include_choice_solutions_flag'];
 
856
 
846
857
                }
847
858
 
848
859
        }