Ejemplo n.º 1
0
 public function vote($id)
 {
     $datastore = new SurveyChoice();
     $choice = $datastore->get(["id" => $id])->First();
     $datastore = new UserSurveyChoice();
     $userChoice = $datastore->get(["surveyId" => $choice->getSurveyId(), "userId" => Session::instance()->Get("userId")])->First();
     if ($userChoice == null) {
         $choice->incrementCount();
         $choice->save();
         $userId = Session::instance()->Get("userId");
         $userChoice = new UserSurveyChoice();
         $userChoice->setChoiceId($choice->getId());
         $userChoice->setUserId($userId);
         $userChoice->setSurveyId($choice->getSurveyId());
         $userChoice->save();
     }
     return $this->redirectAction("~/Survey/Result/" . $choice->getSurveyId());
 }
Ejemplo n.º 2
0
 public static function logout()
 {
     \Framework\Http\Session::instance()->Remove("authenticated");
     \Framework\Http\Session::instance()->Remove("userId");
     \Framework\Http\Session::instance()->Remove("username");
 }