/** * checks if the action is allowed for this session * @param string $type permission type to check for * @param int $forum a forum id * @param int $message a message id * @access public * @return bool */ public function doesHavePermission($type, $forum = false, $message = false) { switch ($type) { case 'open': return true; break; case 'Edit My Post': if (false === is_numeric($message)) { return false; } $user_id = bl_User::getInstance()->getUserId(); return $this->isMessageOwner($user_id, $message) && bl_ActionsLevels::isAllowed($type); break; } return bl_ActionsLevels::isAllowed($type); }
/** * sets the message user id * @param int $id a user id. if not set will attempt to fetch it independantly * @access public * @return $this */ public function setUserId($id = false) { if ($this->getUserId() != self::DEFAULT_USER_ID) { throw new LogicException('cannot change user'); } if (false === $id) { $id = bl_User::getInstance()->getUserId(); } if ($this->_dba->count($this->user_table, array('id' => $id)) === 0) { throw new InvalidArgumentException('user_id'); } $this->user['id'] = $id; return $this; }