コード例 #1
0
ファイル: tools.php プロジェクト: Sajaki/customisation-db
 /**
  * Load revision's parent contribution.
  *
  * @throws \Exception Throws exception if no contrib found.
  * @return null
  */
 protected function load_contrib()
 {
     $this->contrib = new \titania_contribution();
     if (!$this->contrib->load($this->revision->contrib_id) || !$this->contrib->is_visible()) {
         throw new \Exception($this->user->lang['CONTRIB_NOT_FOUND']);
     }
     $this->revision->contrib = $this->contrib;
 }
コード例 #2
0
ファイル: base.php プロジェクト: Sajaki/customisation-db
 /**
  * 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();
 }
コード例 #3
0
ファイル: queue.php プロジェクト: Sajaki/customisation-db
 /**
  * Approve this revision
  *
  * @param mixed $public_notes
  */
 public function approve($public_notes)
 {
     $this->user->add_lang_ext('phpbb/titania', array('manage', 'contributions'));
     $revision = $this->get_revision();
     $contrib = new titania_contribution();
     if (!$contrib->load($this->contrib_id) || !$contrib->is_visible()) {
         return false;
     }
     $revision->contrib = $contrib;
     $revision->load_phpbb_versions();
     $branch = (int) $revision->phpbb_versions[0]['phpbb_version_branch'];
     $contrib_release_topic_id = $contrib->get_release_topic_id($branch);
     $notes = $this->validation_notes;
     message::decode($notes, $this->validation_notes_uid);
     $message = sprintf(phpbb::$user->lang['QUEUE_REPLY_APPROVED'], $revision->revision_version, $notes);
     // Replace empty quotes if there are no notes
     if (!$notes) {
         $message = str_replace('[quote][/quote]', '', $message);
     }
     $this->topic_reply($message, false);
     $this->discussion_reply($message);
     // Update the revisions
     $revision->change_status(TITANIA_REVISION_APPROVED);
     $revision->submit();
     // Reply to the release topic
     if ($contrib_release_topic_id && $contrib->type->update_public) {
         // Replying to an already existing topic, use the update message
         $public_notes = sprintf(phpbb::$user->lang[$contrib->type->update_public], $revision->revision_version) . ($public_notes ? sprintf(phpbb::$user->lang[$contrib->type->update_public . '_NOTES'], $public_notes) : '');
         $contrib->reply_release_topic($branch, $public_notes);
     } elseif (!$contrib_release_topic_id && $contrib->type->reply_public) {
         // Replying to a topic that was just made, use the reply message
         $public_notes = phpbb::$user->lang[$contrib->type->reply_public] . ($public_notes ? sprintf(phpbb::$user->lang[$contrib->type->reply_public . '_NOTES'], $public_notes) : '');
         $contrib->reply_release_topic($branch, $public_notes);
     }
     // Self-updating
     $this->queue_status = TITANIA_QUEUE_APPROVED;
     $this->queue_close_time = titania::$time;
     $this->queue_close_user = phpbb::$user->data['user_id'];
     $this->submit(false);
     // Send notification message
     $this->send_approve_deny_notification(true);
     // Subscriptions
     $email_vars = array('NAME' => $contrib->contrib_name, 'U_VIEW' => $contrib->get_url());
     $this->subscriptions->send_notifications(TITANIA_CONTRIB, $this->contrib_id, 'subscribe_notify', $email_vars);
     // Hooks
     titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
 }
コード例 #4
0
ファイル: download.php プロジェクト: Sajaki/customisation-db
    /**
     * Check if user can download the requested revision.
     *
     * @return int Returns HTTP status code.
     */
    protected function check_revision_auth()
    {
        $sql = 'SELECT contrib_id, revision_status
			FROM ' . TITANIA_REVISIONS_TABLE . '
			WHERE attachment_id = ' . (int) $this->id;
        $result = $this->db->sql_query($sql);
        $revision = $this->db->sql_fetchrow($result);
        $this->db->sql_freeresult($result);
        $contrib = new \titania_contribution();
        if (!$revision || !$contrib->load((int) $revision['contrib_id']) || !$contrib->is_visible(true)) {
            return self::NOT_FOUND;
        }
        if ($this->type == 'composer' && !$contrib->type->create_composer_packages) {
            return self::NOT_FOUND;
        }
        $is_author = $contrib->is_author || $contrib->is_active_coauthor;
        $can_download_hidden = $is_author || $contrib->type->acl_get('view') || $contrib->type->acl_get('moderate');
        $use_queue = $this->ext_config->require_validation && $contrib->type->require_validation;
        $is_unvalidated = $revision['revision_status'] != TITANIA_REVISION_APPROVED && $use_queue;
        $is_disabled = $contrib->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED;
        if (!$can_download_hidden && !$this->is_auto_validator() && ($is_unvalidated || $is_disabled)) {
            return self::NOT_FOUND;
        }
        // Set access Level
        if ($is_author) {
            $this->access->set_level(access::AUTHOR_LEVEL);
        }
        return self::OK;
    }