예제 #1
0
    /**
     * Get the queue discussion topic or create one if needed
     *
     * @param bool $check_only Return false if topic does not exist instead of creating it
     *
     * @return titania_topic object
     */
    public function get_queue_discussion_topic($check_only = false)
    {
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE parent_id = ' . $this->contrib_id . '
				AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if ($row) {
            $topic = new titania_topic();
            $topic->__set_array($row);
            $this->queue_discussion_topic_id = $topic->topic_id;
            return $topic;
        } else {
            if ($check_only) {
                return false;
            }
        }
        // No queue discussion topic...so we must create one
        $this->user->add_lang_ext('phpbb/titania', 'posting');
        $contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
        $post = new titania_post(TITANIA_QUEUE_DISCUSSION);
        $post->topic->__set_array(array('parent_id' => $this->contrib_id, 'topic_category' => $contrib->contrib_type, 'topic_url' => serialize(array('contrib_type' => $contrib->type->url, 'contrib' => $contrib->contrib_name_clean)), 'topic_sticky' => true));
        $post->__set_array(array('post_access' => access::AUTHOR_LEVEL, 'post_subject' => sprintf(phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_TITLE'], $contrib->contrib_name), 'post_text' => phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_MESSAGE']));
        $post->generate_text_for_storage(true, true, true);
        $post->submit();
        $this->queue_discussion_topic_id = $post->topic->topic_id;
        return $post->topic;
    }
예제 #2
0
    /**
     * Change the status of this revision
     *
     * @param int $new_status
     */
    public function change_status($new_status)
    {
        $new_status = (int) $new_status;
        $old_status = $this->revision_status;
        if ($old_status == $new_status) {
            return;
        }
        $this->revision_status = $new_status;
        $sql_ary = array('revision_status' => $this->revision_status);
        switch ($old_status) {
            case TITANIA_REVISION_APPROVED:
                // If there are no approved revisions left we will need to reset the contribution status
                $sql = 'SELECT COUNT(revision_id) AS cnt FROM ' . TITANIA_REVISIONS_TABLE . '
					WHERE revision_status = ' . TITANIA_REVISION_APPROVED . '
						AND contrib_id = ' . $this->contrib_id . '
						AND revision_id <> ' . $this->revision_id;
                phpbb::$db->sql_query($sql);
                $cnt = phpbb::$db->sql_fetchfield('cnt');
                if (!$cnt) {
                    if (!$this->contrib) {
                        $this->contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
                    }
                    if (in_array($this->contrib->contrib_status, array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED))) {
                        $this->contrib->change_status(TITANIA_CONTRIB_NEW);
                    }
                }
                break;
        }
        switch ($new_status) {
            case TITANIA_REVISION_APPROVED:
                // If approving this revision and the contribution is set to new, approve the contribution
                if (!$this->contrib) {
                    $this->contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
                }
                if (in_array($this->contrib->contrib_status, array(TITANIA_CONTRIB_NEW))) {
                    $this->contrib->change_status(TITANIA_CONTRIB_APPROVED);
                }
                // Update the revisions phpbb version table
                $sql = 'UPDATE ' . TITANIA_REVISIONS_PHPBB_TABLE . '
					SET revision_validated = 1
					WHERE revision_id = ' . (int) $this->revision_id;
                phpbb::$db->sql_query($sql);
                $sql_ary['validation_date'] = titania::$time;
                // Update the contributions table if this is the newest validated revision
                $sql = 'SELECT revision_id FROM ' . $this->sql_table . '
					WHERE revision_status = ' . TITANIA_REVISION_APPROVED . '
					AND contrib_id = ' . $this->contrib_id . '
					ORDER BY revision_id DESC';
                phpbb::$db->sql_query_limit($sql, 1);
                $newest_revision_id = phpbb::$db->sql_fetchfield('revision_id');
                phpbb::$db->sql_freeresult();
                if ($newest_revision_id && (int) $newest_revision_id < $this->revision_id) {
                    $sql = 'UPDATE ' . TITANIA_CONTRIBS_TABLE . '
						SET contrib_last_update = ' . titania::$time . '
						WHERE contrib_id = ' . (int) $this->contrib_id;
                    phpbb::$db->sql_query($sql);
                }
                break;
            default:
                // Update the revisions phpbb version table
                $sql = 'UPDATE ' . TITANIA_REVISIONS_PHPBB_TABLE . '
					SET revision_validated = 0
					WHERE revision_id = ' . (int) $this->revision_id;
                phpbb::$db->sql_query($sql);
                $sql_ary['validation_date'] = 0;
                break;
        }
        $sql = 'UPDATE ' . $this->sql_table . '
			SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . '
			WHERE revision_id = ' . $this->revision_id;
        phpbb::$db->sql_query($sql);
        // Update the release topic
        if ($this->revision_status == TITANIA_REVISION_APPROVED) {
            $this->contrib->update_release_topic();
        }
    }
예제 #3
0
     redirect(titania_url::append_url($base_url, array('q' => $queue->queue_id)));
     break;
 case 'allow_author_repack':
     $queue = queue_overlord::get_queue_object($queue_id, true);
     $topic = $queue->get_queue_discussion_topic();
     $post = new titania_post(TITANIA_QUEUE_DISCUSSION, $topic);
     $post->__set_array(array('post_subject' => 'Re: ' . $post->topic->topic_subject));
     // Load the message object
     $message_object = new titania_message($post);
     $message_object->set_auth(array('bbcode' => true, 'smilies' => true));
     $message_object->set_settings(array('display_subject' => false));
     // Submit check...handles running $post->post_data() if required
     $submit = $message_object->submit_check();
     if ($submit) {
         $queue->allow_author_repack = true;
         $contrib = contribs_overlord::get_contrib_object($queue->contrib_id, true);
         $for_edit = $post->generate_text_for_edit();
         $post->post_text = $for_edit['message'] . "\n\n[url=" . titania_url::append_url($contrib->get_url('revision'), array('repack' => $queue->revision_id)) . ']' . phpbb::$user->lang['AUTHOR_REPACK_LINK'] . '[/url]';
         $post->generate_text_for_storage($for_edit['allow_bbcode'], $for_edit['allow_smilies'], $for_edit['allow_urls']);
         $post->submit();
         $queue->submit();
         $queue->topic_reply('QUEUE_REPLY_ALLOW_REPACK');
         $queue->submit();
         redirect(titania_url::append_url($base_url, array('q' => $queue->queue_id)));
     }
     $message_object->display();
     // Common stuff
     phpbb::$template->assign_vars(array('S_POST_ACTION' => titania_url::$current_page_url, 'L_POST_A' => phpbb::$user->lang['DISCUSSION_REPLY_MESSAGE']));
     titania::page_header('DISCUSSION_REPLY_MESSAGE');
     titania::page_footer(true, 'manage/queue_post.html');
     break;
예제 #4
0
 /**
  * Load queue item.
  *
  * @param int $id		Queue item id.
  * @throws \Exception	Throws exception if no item found.
  * @return null
  */
 protected function load_item($id)
 {
     $this->id = (int) $id;
     $this->queue = \queue_overlord::get_queue_object($this->id, true);
     if (!$this->queue) {
         throw new \Exception($this->user->lang['NO_QUEUE_ITEM']);
     }
     $this->contrib = \contribs_overlord::get_contrib_object($this->queue->contrib_id, true);
     $this->revision = $this->queue->get_revision();
     $this->is_author = $this->contrib->is_author || $this->contrib->is_active_coauthor || $this->contrib->is_coauthor;
 }
예제 #5
0
    /**
     * Get the queue discussion topic or create one if needed
     *
     * @return titania_topic object
     */
    public function get_queue_discussion_topic()
    {
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE parent_id = ' . $this->contrib_id . '
				AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if ($row) {
            $topic = new titania_topic();
            $topic->__set_array($row);
            return $topic;
        }
        // No queue discussion topic...so we must create one
        titania::add_lang('posting');
        $contrib = contribs_overlord::get_contrib_object($this->contrib_id, true);
        $post = new titania_post(TITANIA_QUEUE_DISCUSSION);
        $post->topic->__set_array(array('parent_id' => $this->contrib_id, 'topic_category' => $contrib->contrib_type, 'topic_url' => titania_types::$types[$contrib->contrib_type]->url . '/' . $contrib->contrib_name_clean . '/support/', 'topic_sticky' => true));
        $post->__set_array(array('post_access' => TITANIA_ACCESS_AUTHORS, 'post_subject' => sprintf(phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_TITLE'], $contrib->contrib_name), 'post_text' => phpbb::$user->lang['QUEUE_DISCUSSION_TOPIC_MESSAGE']));
        $post->generate_text_for_storage(true, true, true);
        $post->submit();
        return $post->topic;
    }