/** * Set user's access level. * * @return null */ protected function set_access_level() { if ($this->access->is_public() && $this->user->data['is_registered'] && !$this->user->data['is_bot']) { if ($this->is_author) { $this->access->set_level(access::AUTHOR_LEVEL); } } }
/** * Load author object and set access level. * * @param string|int $author Author username or user id. * @throws \Exception Throws exception if user is not found. * @return null */ protected function load_author($author) { $this->author = new \titania_author(false); if (!$this->author->load($author)) { throw new \Exception($this->user->lang['AUTHOR_NOT_FOUND']); } $this->is_owner = $this->user->data['user_id'] == $this->author->user_id; // Check to see if the currently accessing user is the author if ($this->access->is_public() && $this->is_owner) { $this->access->set_level(access::AUTHOR_LEVEL); } }
/** * Create select with Titania's accesses * * @param int|bool $default Default access level. False for none. * @param int $min_access Minimum access level to display * @return string */ protected function get_access_select($default = false, $min_access = access::PUBLIC_LEVEL) { if ($this->access->is_public()) { return ''; } $access_types = array(access::TEAM_LEVEL => 'ACCESS_TEAMS', access::AUTHOR_LEVEL => 'ACCESS_AUTHORS', access::PUBLIC_LEVEL => 'ACCESS_PUBLIC'); if ($default === false) { $default = access::PUBLIC_LEVEL; } $s_options = ''; foreach ($access_types as $type => $lang_key) { if ($this->access->get_level() > $type || $min_access < $type) { continue; } $selected = $default == $type ? ' selected="selected"' : ''; $s_options .= '<option value="' . $type . '"' . $selected . '>' . $this->user->lang($lang_key) . '</option>'; } return $s_options; }