예제 #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
 /**
  * List the contributions for the category and its children
  *
  * @param array $categories The id's of the categories from which to select.
  * @param string $sort_url The base url from which to sort.
  *
  * @return \phpbb\titania\sort
  */
 protected function list_contributions($categories, $sort_url)
 {
     $mode = $this->id ? 'category' : 'all';
     $sort = \contribs_overlord::build_sort();
     $sort->set_defaults(25);
     $branch = (int) str_replace('.', '', $this->branch);
     $data = \contribs_overlord::display_contribs($mode, $categories, $branch, $sort);
     // Canonical URL
     $data['sort']->set_url($sort_url);
     $this->template->assign_var('U_CANONICAL', $data['sort']->build_canonical());
     return $data['sort'];
 }
예제 #3
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;
 }
예제 #4
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();
        }
    }
예제 #5
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;
예제 #6
0
 /**
  * Display author contributions page.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function contributions()
 {
     // Setup the sort tool to sort by contribution support status and name ascending
     $sort = \contribs_overlord::build_sort();
     $sort->set_url($this->author->get_url('contributions'));
     $sort->set_sort_keys(array('sc' => array('SORT_CONTRIB_NAME', 'c.contrib_limited_support, c.contrib_name', true)));
     $sort->set_defaults(24, 'sc', 'a');
     \contribs_overlord::display_contribs('author', $this->author->user_id, false, $sort);
     $this->template->assign_vars(array('S_AUTHOR_LIST' => true, 'U_CANONICAL' => $sort->build_canonical()));
     return $this->helper->render('authors/author_contributions.html', $this->get_title('AUTHOR_CONTRIBS'));
 }
예제 #7
0
<?php

/**
 *
 * @package titania
 * @version $Id$
 * @copyright (c) 2008 phpBB Customisation Database Team
 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
 *
 */
/**
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
// Setup the sort tool to sort by contribution name ascending
$sort = contribs_overlord::build_sort();
$sort->set_url(titania::$author->get_url('contributions'));
$sort->set_defaults(false, 'c', 'a');
contribs_overlord::display_contribs('author', titania::$author->user_id, $sort);
phpbb::$template->assign_vars(array('S_AUTHOR_LIST' => true, 'U_CANONICAL' => $sort->build_canonical()));
titania::page_header(titania::$author->get_username_string('username') . ' - ' . phpbb::$user->lang['AUTHOR_CONTRIBS']);
titania::page_footer(true, 'authors/author_contributions.html');
예제 #8
0
            }
            // Include the current category in the ones selected
            $child_categories[] = $category_id;
            $data = contribs_overlord::display_contribs('category', $child_categories, $sort);
            // Canonical URL
            $data['sort']->set_url($category_object->get_url());
            phpbb::$template->assign_var('U_CANONICAL', $data['sort']->build_canonical());
        } else {
            // Mark all contribs read
            if (request_var('mark', '') == 'contribs') {
                titania_tracking::track(TITANIA_CONTRIB, 0);
            }
            phpbb::$template->assign_vars(array('CATEGORY_ID' => 0, 'U_MARK_FORUMS' => titania_url::append_url(titania_url::$current_page_url, array('mark' => 'contribs')), 'L_MARK_FORUMS_READ' => phpbb::$user->lang['MARK_CONTRIBS_READ'], 'S_DISPLAY_SEARCHBOX' => true, 'S_SEARCHBOX_ACTION' => titania_url::build_url('find-contribution')));
            // Setup the sort tool to only display the 10 most recent
            $sort = contribs_overlord::build_sort();
            $sort->set_defaults(10);
            $data = contribs_overlord::display_contribs('all', 0, $sort);
            // Canonical URL
            $data['sort']->set_url('');
            phpbb::$template->assign_var('U_CANONICAL', $data['sort']->build_canonical());
        }
        phpbb::$template->assign_vars(array('U_CREATE_CONTRIBUTION' => phpbb::$auth->acl_get('u_titania_contrib_submit') ? titania_url::build_url('author/' . htmlspecialchars_decode(phpbb::$user->data['username_clean']) . '/create') : '', 'S_HAS_CONTRIBS' => $categories_ary && $categories_ary[$category_id]['category_type'] ? true : false));
        if ($category_id != 0) {
            $category_name = isset(phpbb::$user->lang[$category_object->category_name]) ? phpbb::$user->lang[$category_object->category_name] : $category_object->category_name;
            titania::page_header($category_name . ' - ' . phpbb::$user->lang['CUSTOMISATION_DATABASE']);
            titania::page_footer(true, 'index_body.html');
        }
        break;
}
titania::page_header('CUSTOMISATION_DATABASE');
titania::page_footer(true, 'index_body.html');
예제 #9
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;
    }