/** * Load contribution. * * @param string $contrib_type Contrib type URL identifier. * @param string $contrib Contrib name clean. * @throws \Exception Throws exception if contrib is not found. * @return null */ protected function load_contrib($contrib_type, $contrib) { $type = $contrib_type ? $this->types->type_from_url($contrib_type) : false; $this->contrib = new \titania_contribution(); if (!$this->contrib->load($contrib, $type) || !$this->contrib->is_visible()) { throw new \Exception($this->user->lang['CONTRIB_NOT_FOUND']); } $this->is_author = $this->contrib->is_active_coauthor || $this->contrib->is_author; $this->set_access_level(); }
/** * Get type id from url string identifier * * @param string $type Contribution type's string identifier * @return int|bool Returns the type's id or false if no type matches. */ protected function get_type_id($type) { return $type == 'all' ? self::ALL_SUPPORT : $this->types->type_from_url($type); }
/** * Set the contribution type to generate stats for. * * @param string $type Contribution type URL value. * @return null */ protected function set_type($type) { $type = $this->types->type_from_url($type); $this->type = $type ? $this->types->get($type) : false; }