예제 #1
0
 /**
  * Creates the commment renderer.
  * @param Text $text The website text object.
  * @param Comment[] $comments List of comments.
  * @param boolean $viewedOutOfContext Whether there should be a link to the article.
  * @param User|null $viewer The user viewing the comments, null if logged out.
  */
 public function __construct(Text $text, $comments, $viewedOutOfContext, User $viewer = null)
 {
     parent::__construct($text);
     $this->comments = $comments;
     $this->viewedByStaff = $viewer === null ? false : $viewer->hasRank(Authentication::RANK_MODERATOR);
     $this->viewedOutOfContext = $viewedOutOfContext;
     $this->viewerId = $viewer ? $viewer->getId() : 0;
 }
예제 #2
0
 /**
  * Save that user object in the session. Doesn't modify the login cookie.
  * Null values are not permitted. Use log_out to log the current user out.
  * @param User $user The user to login
  * @return boolean Whether the user object was set. Returns false when the
  * account is banned or deleted.
  */
 public function setCurrentUser(User $user)
 {
     if (!$user->canLogIn()) {
         // User is banned or something
         return false;
     }
     $_SESSION['user_id'] = $user->getId();
     if ($user->hasRank(self::RANK_MODERATOR)) {
         // This session vars are purely used for CKEditor.
         // In rCMS there are much better, easier and safer ways to check this.
         $_SESSION['moderator'] = true;
     } else {
         $_SESSION['moderator'] = false;
     }
     $this->currentUser = $user;
     return true;
 }