Пример #1
0
 public function viewAction($goalID = -1)
 {
     $goal = Goals::findFirstByGoalID($goalID);
     if ($goal) {
         //check if user owns it
         $auth = $this->session->get('auth');
         $userID = $auth['userID'];
         $owned = false;
         if ($userID == $goal->seekerID) {
             $owned = true;
         }
         //get seeker info
         $seeker = Users::findFirstByUserID($goal->seekerID);
         //grab every milestone for goal
         $milestones = Milestones::findAllByGoalID($goal->goalID);
         //get completed/total number of milestones
         $totalMS = 1;
         $completedMS = 0;
         foreach ($milestones as $ms) {
             if ($ms->number > $totalMS) {
                 $totalMS = $ms->number;
             }
             if ($ms->isComplete == 1) {
                 $completedMS++;
             }
         }
         //pass data
         $this->view->setVar('goal', $goal);
         $this->view->setVar('userID', $userID);
         $this->view->setVar('milestones', $milestones);
         //$this->view->setVar('gifts', $gifts);
         $this->view->setVar('owned', $owned);
         $this->view->setVar('totalMS', $totalMS);
         $this->view->setVar('completedMS', $completedMS);
         $this->view->setVar('seeker', $seeker);
     } else {
         $this->flashSession->error("Error: Invalid Goal");
         $this->response->redirect("index");
         $this->view->disable();
     }
 }