コード例 #1
0
ファイル: ProfileController.php プロジェクト: freesaga/getit
 public function indexAction()
 {
     //get session info
     $auth = $this->session->get('auth');
     $userID = $auth['userID'];
     $username = $auth['username'];
     //get other user information from db
     $user = Users::findFirstByUserID($userID);
     if ($user) {
         //user found, get rest of info
         $this->view->setVar("firstname", $user->firstname);
         $this->view->setVar("lastname", $user->lastname);
         $this->view->setVar("email", $user->email);
         $this->view->setVar("location", $user->location);
         $this->view->setVar("username", $user->username);
         $goals = Goals::findAllBySeekerID($userID);
         $this->view->setVar("goals", $goals);
         $gifts = Gifts::findAllByMotivatorID($userID);
         $goalIDs = array();
         $exists = false;
         if ($gifts) {
             foreach ($gifts as $gift) {
                 $milestone = Milestones::findFirstByMilestoneID($gift->milestoneID);
                 if ($milestone) {
                     for ($i = 0; i < array_count_values($goalIDs) && $exists == false; $i++) {
                         if ($goalIDs[$i] == $milestone->goalID) {
                             $exists = true;
                         }
                     }
                     if ($exists == false) {
                         array_push($goalIDs, $milestone->goalID);
                     }
                 }
             }
         }
     } else {
         //error, go to login
         $this->flashSession->error("Error: Unable to access user information");
         $this->response->redirect("index");
         $this->view->disable();
     }
 }
コード例 #2
0
ファイル: Goals.php プロジェクト: freesaga/getit
 public static function findAll()
 {
     return Goals::find();
 }
コード例 #3
0
ファイル: GoalController.php プロジェクト: freesaga/getit
 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();
     }
 }