示例#1
0
 function getrecentcampaignsAction()
 {
     $offset = isset($this->params['offset']) ? $this->params['offset'] : 0;
     $status = isset($this->params['status']) ? $this->params['status'] : 'active';
     $grpmodel = new Default_Model_Groups();
     $campaignModel = new Default_Model_Campaigns();
     // If you find (time to think of) a better way to do this, be my guest.
     if ($status === 'forthcoming') {
         $recentcampaigns = $campaignModel->getRecentForthcomingFromOffset($offset, 10);
     } else {
         if ($status === 'ended') {
             $recentcampaigns = $campaignModel->getRecentEndedFromOffset($offset, 10);
         } else {
             $recentcampaigns = $campaignModel->getRecentFromOffset($offset, 10);
         }
     }
     $cmps_new = array();
     foreach ($recentcampaigns as $cmp) {
         $grp = $grpmodel->getGroupData($cmp['id_grp_cmp']);
         $cmp['group_name_grp'] = $grp['group_name_grp'];
         $cmps_new[] = $cmp;
     }
     $this->view->recentcampaigns = $cmps_new;
 }