Ejemplo n.º 1
0
 function toggle_like()
 {
     Auth::checkLoggedIn();
     $answer = QuestionAnswer::fromId(Input::get('answerid'));
     if (!$answer->canView(Auth::getUser())) {
         throw new Exception('You are not allowed to like this answer.');
     }
     $answer->toggleLike(Auth::getUser());
     View::renderJson($answer->getContext(Auth::getUser()));
 }
Ejemplo n.º 2
0
 /**
  * Determines whether or not a given user can edit the question.
  * @param User $user The user to check.
  * @return boolean
  */
 public function canEdit(User $user)
 {
     // See if they are a professor for the course
     $entry = Entry::fromId($this->getEntryId());
     if ($entry->canEdit($user)) {
         return true;
     }
     // See if they asked the question
     $firstAnswer = QuestionAnswer::fromId($this->getFirstAnswerId());
     if ($firstAnswer->getUserId() == $user->getUserId()) {
         return true;
     }
     // They cannot edit
     return false;
 }