Ejemplo n.º 1
0
 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();
     }
 }