コード例 #1
0
ファイル: faq.php プロジェクト: Sajaki/customisation-db
 /**
  * Common handler for edit/create action.
  *
  * @return bool|JsonResponse Returns true if item was submitted.
  */
 protected function common_post()
 {
     // Load the message object
     $this->message->set_parent($this->faq)->set_auth(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies'), 'attachments' => true));
     // Submit check...handles running $this->faq->post_data() if required
     $submit = $this->message->submit_check();
     $error = $this->message->error;
     if ($this->message->is_plupload_request()) {
         return new JsonResponse($this->message->get_plupload_response_data());
     }
     if ($submit) {
         $error = array_merge($error, $this->faq->validate());
         if (($validate_form_key = $this->message->validate_form_key()) !== false) {
             $error[] = $validate_form_key;
         }
         if (empty($error)) {
             $this->faq->submit();
             $this->message->submit($this->id);
             return true;
         }
     }
     $this->template->assign_vars(array('S_EDIT' => true, 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false));
     $this->message->display();
     return false;
 }
コード例 #2
0
 /**
  * Common handler for add/edit action.
  *
  * @param \titania_category	Category object.
  * @param bool|array			Old settings
  * @return bool Returns true if category was submitted.
  */
 protected function common_post($category, $old_settings = false)
 {
     $this->message->set_parent($category)->set_auth(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies')))->set_settings(array('display_error' => false, 'display_subject' => false));
     $category->post_data($this->message);
     $error = array();
     if ($this->request->is_set_post('submit')) {
         $category = $this->set_submitted_settings($category);
         if (!empty($old_settings) && $category->category_name == $old_settings['name_lang']) {
             $category->category_name = $old_settings['name'];
         }
         $error = $category->validate();
         if (($form_error = $this->message->validate_form_key()) !== false) {
             $error[] = $form_error;
         }
         if (empty($error)) {
             $error = $this->submit($category, $old_settings);
             if (empty($error)) {
                 return true;
             }
         }
     }
     // Generate data for category type dropdown box
     $this->display->generate_type_select($category->category_type);
     $this->message->display();
     $this->template->assign_vars(array('ERROR_MSG' => !empty($error) ? implode('<br />', $error) : '', 'CATEGORY' => $category->category_id, 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_NAME_CLEAN' => $category->category_name_clean, 'CATEGORY_VISIBLE' => $category->category_visible, 'S_MOVE_CATEGORY_OPTIONS' => $this->display->generate_category_select($category->parent_id, true, false)));
     foreach ($category->available_options as $option => $flag) {
         if ($category->is_option_set($option)) {
             $this->template->assign_var(strtoupper("s_{$option}"), 'checked="checked"');
         }
     }
     return false;
 }
コード例 #3
0
ファイル: manage.php プロジェクト: Elsensee/customisation-db
 /**
  * Assign template variables.
  *
  * @param array $error		Array containing any errors found.
  * @return null
  */
 protected function assign_vars($error)
 {
     // ColorizeIt
     if ($this->use_colorizeit) {
         $this->assign_colorizeit_vars();
     }
     foreach ($this->status_list as $status => $lang) {
         $this->template->assign_block_vars('status_select', array('NAME' => $this->user->lang($lang), 'VALUE' => $status, 'S_SELECTED' => $status == $this->contrib->contrib_status));
     }
     $this->display->generate_custom_fields($this->contrib->type->contribution_fields, $this->settings['custom'], $this->contrib->type->id);
     foreach ($this->settings['demo'] as $branch => $demo_url) {
         $this->template->assign_block_vars('demo', array('BRANCH' => $branch, 'URL' => $demo_url, 'NAME' => $this->ext_config->phpbb_versions[$branch]['name'], 'U_INSTALL' => $this->contrib->get_url('manage_demo', array('action' => 'install', 'branch' => $branch, 'hash' => generate_link_hash('manage_demo')))));
     }
     $coauthors = $this->get_coauthor_usernames();
     $this->template->assign_vars(array('S_CONTRIB_APPROVED' => $this->contrib->contrib_status == TITANIA_CONTRIB_APPROVED, 'S_POST_ACTION' => $this->contrib->get_url('manage'), 'S_EDIT_SUBJECT' => $this->is_moderator || $this->contrib->is_author(), 'S_DELETE_CONTRIBUTION' => $this->check_auth('delete'), 'S_IS_OWNER' => $this->contrib->is_author, 'S_IS_MODERATOR' => $this->is_moderator, 'S_CAN_EDIT_DEMO' => $this->can_edit_demo, 'S_CAN_EDIT_CONTRIB' => $this->auth->acl_get('u_titania_contrib_submit'), 'S_LIMITED_SUPPORT' => $this->settings['limited_support'], 'CONTRIB_PERMALINK' => $this->settings['permalink'], 'CONTRIB_TYPE' => $this->contrib->contrib_type, 'SCREENSHOT_UPLOADER' => $this->auth->acl_get('u_titania_contrib_submit') ? $this->screenshots->parse_uploader('posting/attachments/simple.html', true) : false, 'ERROR_MSG' => !empty($error) ? implode('<br />', $error) : false, 'ACTIVE_COAUTHORS' => implode("\n", $coauthors['active']), 'NONACTIVE_COAUTHORS' => implode("\n", $coauthors['nonactive'])));
     $this->display->generate_category_select($this->settings['categories'], false, true, $this->contrib->type->id);
     $this->message->display();
     $this->contrib->assign_details();
     $this->display->assign_global_vars();
     $this->generate_navigation('manage');
     $this->generate_breadcrumbs();
 }
コード例 #4
0
ファイル: posting.php プロジェクト: Sajaki/customisation-db
 /**
  * Set up message.
  *
  * @param \titania_post $post
  * @param array $auth
  * @param array $settings
  */
 protected function setup_message(\titania_post $post, array $auth = array(), array $settings = array())
 {
     $this->message->set_parent($post)->set_auth(array_merge(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies'), 'attachments' => $this->auth->acl_get('u_titania_post_attach')), $auth))->set_settings($settings);
 }
コード例 #5
0
ファイル: queue.php プロジェクト: Sajaki/customisation-db
    /**
     * Send the approve/deny notification
     */
    private function send_approve_deny_notification($approve = true)
    {
        $this->user->add_lang_ext('phpbb/titania', 'manage');
        phpbb::_include('functions_privmsgs', 'submit_pm');
        // Need some stuff
        $contrib = new titania_contribution();
        $contrib->load((int) $this->contrib_id);
        $revision = new titania_revision($contrib, $this->revision_id);
        $revision->load();
        // Generate the authors list to send it to
        $authors = array($contrib->contrib_user_id => 'to');
        $sql = 'SELECT user_id FROM ' . TITANIA_CONTRIB_COAUTHORS_TABLE . '
			WHERE contrib_id = ' . (int) $this->contrib_id . '
				AND active = 1';
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $authors[$row['user_id']] = 'to';
        }
        phpbb::$db->sql_freeresult($result);
        // Subject
        $subject = sprintf(phpbb::$user->lang[$contrib->type->validation_subject], $contrib->contrib_name, $revision->revision_version);
        // Message
        $notes = $this->validation_notes;
        message::decode($notes, $this->validation_notes_uid);
        if ($approve) {
            $message = $contrib->type->validation_message_approve;
        } else {
            $message = $contrib->type->validation_message_deny;
        }
        $message = sprintf(phpbb::$user->lang[$message], $notes);
        // Replace empty quotes if there are no notes
        if (!$notes) {
            $message = str_replace('[quote][/quote]', phpbb::$user->lang['NO_NOTES'], $message);
        }
        // Parse the message
        $message_uid = $message_bitfield = $message_options = false;
        generate_text_for_storage($message, $message_uid, $message_bitfield, $message_options, true, true, true);
        $data = array('address_list' => array('u' => $authors), 'from_user_id' => phpbb::$user->data['user_id'], 'from_username' => phpbb::$user->data['username'], 'icon_id' => 0, 'from_user_ip' => phpbb::$user->ip, 'enable_bbcode' => true, 'enable_smilies' => true, 'enable_urls' => true, 'enable_sig' => true, 'message' => $message, 'bbcode_bitfield' => $message_bitfield, 'bbcode_uid' => $message_uid);
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $data, $this);
        // Submit Plz
        submit_pm('post', $subject, $data, true);
    }
コード例 #6
0
 /**
  * Get queue message object.
  *
  * @return \phpbb\titania\message\message
  */
 protected function get_message()
 {
     $this->message->set_parent($this->queue)->set_auth(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies')))->set_settings(array('display_error' => false, 'display_subject' => false));
     $this->queue->post_data($this->message);
     return $this->message;
 }
コード例 #7
0
ファイル: item.php プロジェクト: Sajaki/customisation-db
 /**
  * Get message object.
  *
  * @param mixed $object		Parent object receiving the message.
  * @return \phpbb\titania\message\message
  */
 protected function get_message($object)
 {
     $this->message->set_parent($object)->set_auth(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies')))->set_settings(array('display_subject' => false));
     return $this->message;
 }
コード例 #8
0
ファイル: post.php プロジェクト: Sajaki/customisation-db
 /**
  * {@inheritDoc}
  */
 public function post_data(message $message)
 {
     $post_data = $message->request_data();
     $this->topic->__set_array(array('topic_sticky' => $message->auth['sticky_topic'] ? $post_data['sticky_topic'] : $this->topic->topic_sticky, 'topic_locked' => $message->auth['lock_topic'] ? $post_data['lock_topic'] : $this->topic->topic_locked));
     parent::post_data($message);
 }
コード例 #9
0
ファイル: author.php プロジェクト: Sajaki/customisation-db
 /**
  * Set up message object for contribution description.
  *
  * @param \titania_contribution
  * @return \phpbb\titania\message\message
  */
 protected function setup_message($contrib)
 {
     $this->message->set_parent($contrib)->set_auth(array('bbcode' => $this->auth->acl_get('u_titania_bbcode'), 'smilies' => $this->auth->acl_get('u_titania_smilies')))->set_settings(array('display_error' => false, 'display_subject' => false, 'subject_name' => 'name'));
     return $this->message;
 }
コード例 #10
0
 /**
  * Update the release topic for this contribution
  */
 public function update_release_topic()
 {
     if ($this->type->forum_robot && $this->type->forum_database && $this->type->create_public) {
         titania::_include('functions_posting', 'phpbb_posting');
         // Get the latest download
         $this->get_download();
         // If there is not a download do not update.
         if (!$this->download) {
             return;
         }
         // Get the latest revision
         $this->get_revisions();
         // If there is not a revision do not update.
         if (!$this->revisions) {
             return;
         }
         $contrib_description = $this->contrib_desc;
         message::decode($contrib_description, $this->contrib_desc_uid);
         foreach ($this->download as $download) {
             $phpbb_version = $this->revisions[$download['revision_id']]['phpbb_versions'][0];
             $branch = (int) $phpbb_version['phpbb_version_branch'];
             if (empty($this->type->forum_database[$branch])) {
                 continue;
             }
             $u_download = $this->controller_helper->route('phpbb.titania.download', array('id' => $download['attachment_id']));
             // Global body and options
             $body = phpbb::$user->lang($this->type->create_public, $this->contrib_name, $this->path_helper->strip_url_params($this->author->get_url(), 'sid'), users_overlord::get_user($this->author->user_id, '_username'), $contrib_description, $download['revision_version'], $this->path_helper->strip_url_params($u_download, 'sid'), $download['real_filename'], get_formatted_filesize($download['filesize']), $this->path_helper->strip_url_params($this->get_url(), 'sid'), $this->path_helper->strip_url_params($this->get_url('support'), 'sid'), $phpbb_version['phpbb_version_branch'][0] . '.' . $phpbb_version['phpbb_version_branch'][1] . '.' . $phpbb_version['phpbb_version_revision']);
             $options = array('poster_id' => $this->type->forum_robot, 'forum_id' => $this->type->forum_database[$branch]);
             $release_topic_id = (int) $this->get_release_topic_id($branch);
             if ($release_topic_id) {
                 // We edit the first post of contrib release topic
                 $options_edit = array('topic_id' => $release_topic_id, 'topic_title' => $this->contrib_name, 'post_text' => $body);
                 $options_edit = array_merge($options_edit, $options);
                 phpbb_posting('edit_first_post', $options_edit);
             } else {
                 // We create a new topic in database
                 $options_post = array('topic_title' => $this->contrib_name, 'post_text' => $body);
                 $options_post = array_merge($options_post, $options);
                 $release_topic_id = phpbb_posting('post', $options_post);
                 $this->set_release_topic_id($branch, $release_topic_id);
             }
         }
     }
 }
コード例 #11
0
function phpbb_com_titania_post_edit($hook, &$post_object)
{
    if (defined('IN_TITANIA_CONVERT') || !$post_object->phpbb_post_id) {
        return;
    }
    $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->post_type);
    if (!$forum_id) {
        return;
    }
    titania::_include('functions_posting', 'phpbb_posting');
    $path_helper = phpbb::$container->get('path_helper');
    $post_text = $post_object->post_text;
    phpbb_com_handle_attachments($post_object, $post_text);
    message::decode($post_text, $post_object->post_text_uid);
    $post_text .= "\n\n" . $path_helper->strip_url_params($post_object->get_url(), 'sid');
    $options = array('post_id' => $post_object->phpbb_post_id, 'topic_title' => $post_object->post_subject, 'post_text' => $post_text);
    phpbb_posting('edit', $options);
}
コード例 #12
0
ファイル: posts.php プロジェクト: Sajaki/customisation-db
    /**
     * Display topic section for support/tracker/etc
     *
     * @param object $topic The topic object
     * @param \phpbb\titania\sort $sort The sort object
     */
    public static function display_topic($topic, $sort = false)
    {
        $tracking = phpbb::$container->get('phpbb.titania.tracking');
        if ($sort === false) {
            // Setup the sort tool
            $sort = self::build_sort();
        }
        $sort->request();
        $total_posts = $topic->get_postcount();
        // Make sure the start parameter falls within the post count limit
        if ($total_posts <= $sort->start) {
            $sort->start = (ceil($total_posts / $sort->limit) - 1) * $sort->limit;
        }
        $sql_ary = array('SELECT' => 'p.*', 'FROM' => array(TITANIA_POSTS_TABLE => 'p'), 'WHERE' => 'p.topic_id = ' . (int) $topic->topic_id . self::sql_permissions('p.'), 'ORDER_BY' => $sort->get_order_by());
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        // Handle pagination
        if (!$sort->sql_count($sql_ary, 'p.post_id')) {
            // No results...no need to query more...
            return;
        }
        $topic_action = isset($sort->url_parameters['action']) ? $sort->url_parameters['action'] : false;
        unset($sort->url_parameters['action']);
        $sort->build_pagination($topic->get_url($topic_action));
        // Get the data
        $post_ids = $user_ids = array();
        $last_post_time = 0;
        // tracking
        $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            self::$posts[$row['post_id']] = $row;
            self::$posts[$row['post_id']]['attachments'] = array();
            $post_ids[] = $row['post_id'];
            $user_ids[] = $row['post_user_id'];
            $user_ids[] = $row['post_edit_user'];
            $user_ids[] = $row['post_delete_user'];
            $last_post_time = $row['post_time'];
            // to set tracking
        }
        phpbb::$db->sql_freeresult($result);
        // Grab the tracking data
        $last_mark_time = $tracking->get_track(TITANIA_TOPIC, $topic->topic_id);
        // Store tracking data
        $tracking->track(TITANIA_TOPIC, $topic->topic_id, $last_post_time);
        // load the user data
        users_overlord::load($user_ids);
        $cp = phpbb::$container->get('profilefields.manager');
        $post = new titania_post($topic->topic_type, $topic);
        $attachments = phpbb::$container->get('phpbb.titania.attachment.operator');
        // Grab all attachments
        $attachments_set = $attachments->configure($topic->topic_type, false)->load_attachments_set($post_ids);
        // Loop de loop
        $prev_post_time = 0;
        foreach ($post_ids as $post_id) {
            $post->__set_array(self::$posts[$post_id]);
            $attachments->clear_all();
            if (isset($attachments_set[$post_id])) {
                $attachments->store($attachments_set[$post_id]);
            }
            // Parse attachments before outputting the message
            $message = $post->generate_text_for_display();
            $parsed_attachments = $attachments->parse_attachments($message);
            // Prepare message text for use in javascript
            $message_decoded = censor_text($post->post_text);
            message::decode($message_decoded, $post->post_text_uid);
            $message_decoded = bbcode_nl2br($message_decoded);
            // Build CP Fields
            $cp_row = array();
            if (isset(users_overlord::$cp_fields[$post->post_user_id])) {
                $cp_row = $cp->generate_profile_fields_template_data(users_overlord::$cp_fields[$post->post_user_id]);
            }
            $cp_row['row'] = isset($cp_row['row']) && sizeof($cp_row['row']) ? $cp_row['row'] : array();
            // Display edit info
            $display_username = get_username_string('full', $post->post_user_id, users_overlord::get_user($post->post_user_id, 'username'), users_overlord::get_user($post->post_user_id, 'user_colour'), false, phpbb::append_sid('memberlist', 'mode=viewprofile'));
            $l_edited_by = $post->post_edit_time ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], $display_username, phpbb::$user->format_date($post->post_edit_time)) : '';
            phpbb::$template->assign_block_vars('posts', array_merge($post->assign_details(false), users_overlord::assign_details($post->post_user_id), $cp_row['row'], array('POST_TEXT' => $message, 'POST_TEXT_DECODED' => $message_decoded, 'EDITED_MESSAGE' => $l_edited_by, 'U_MINI_POST' => $topic->get_url(false, array('p' => $post_id, '#' => 'p' . $post_id)), 'MINI_POST_IMG' => $post->post_time > $last_mark_time ? phpbb::$user->img('icon_post_target_unread', 'NEW_POST') : phpbb::$user->img('icon_post_target', 'POST'), 'S_FIRST_UNREAD' => $post->post_time > $last_mark_time && $prev_post_time <= $last_mark_time ? true : false)));
            $contact_fields = array(array('ID' => 'pm', 'NAME' => phpbb::$user->lang['SEND_PRIVATE_MESSAGE'], 'U_CONTACT' => users_overlord::get_user($post->post_user_id, '_u_pm')), array('ID' => 'email', 'NAME' => phpbb::$user->lang['SEND_EMAIL'], 'U_CONTACT' => users_overlord::get_user($post->post_user_id, '_u_email')), array('ID' => 'jabber', 'NAME' => phpbb::$user->lang['JABBER'], 'U_CONTACT' => users_overlord::get_user($post->post_user_id, '_jabber')));
            foreach ($contact_fields as $field) {
                if ($field['U_CONTACT']) {
                    phpbb::$template->assign_block_vars('posts.contact', $field);
                }
            }
            // Output CP Fields
            if (!empty($cp_row['blockrow'])) {
                foreach ($cp_row['blockrow'] as $field_data) {
                    phpbb::$template->assign_block_vars('posts.custom_fields', $field_data);
                    if ($field_data['S_PROFILE_CONTACT']) {
                        phpbb::$template->assign_block_vars('posts.contact', array('ID' => $field_data['PROFILE_FIELD_IDENT'], 'NAME' => $field_data['PROFILE_FIELD_NAME'], 'U_CONTACT' => $field_data['PROFILE_FIELD_CONTACT']));
                    }
                }
            }
            //S_IGNORE_POST
            //POST_ICON_IMG
            //MINI_POST_IMG
            foreach ($parsed_attachments as $attachment) {
                phpbb::$template->assign_block_vars('posts.attachment', array('DISPLAY_ATTACHMENT' => $attachment));
            }
            $prev_post_time = $post->post_time;
        }
        unset($post, $attachments);
        // Increment the topic view count
        $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
			SET topic_views = topic_views + 1
			WHERE topic_id = ' . (int) $topic->topic_id;
        phpbb::$db->sql_query($sql);
    }
コード例 #13
0
 /**
  * Parse text for edit
  *
  * @return array of the items to be used in the message parser class
  */
 public function generate_text_for_edit()
 {
     // Add the object type and object id
     $for_edit = array('object_type' => is_string($this->object_type) && isset($this->{$this->object_type}) ? $this->{$this->object_type} : $this->object_type, 'object_id' => $this->{$this->sql_id_field});
     $message = $message_uid = $message_bitfield = $message_options = false;
     $this->get_message_fields($message, $message_uid, $message_bitfield, $message_options);
     message::decode($message, $message_uid);
     $for_edit = array_merge($for_edit, array('allow_bbcode' => $message_options & OPTION_FLAG_BBCODE ? 1 : 0, 'allow_smilies' => $message_options & OPTION_FLAG_SMILIES ? 1 : 0, 'allow_urls' => $message_options & OPTION_FLAG_LINKS ? 1 : 0, 'text' => $message, 'message' => $message));
     // Add any of the marked fields to the array
     foreach ($this->object_config as $field => $options) {
         if (isset($options['message_field'])) {
             $for_edit[$options['message_field']] = $this->{$field};
         }
     }
     return $for_edit;
 }
コード例 #14
0
ファイル: contribs.php プロジェクト: Sajaki/customisation-db
    /**
     * Display contributions
     *
     * @param string $mode The mode (category, author)
     * @param int $id The parent id (only show contributions under this category, author, etc)
     * @param int|bool $branch	Branch to limit results to: 20|30|31. Defaults to false.
     * @param \phpbb\titania\sort|bool $sort
     * @param string $blockname The name of the template block to use (contribs by default)
     *
     * @return array
     */
    public static function display_contribs($mode, $id, $branch = false, $sort = false, $blockname = 'contribs')
    {
        phpbb::$user->add_lang_ext('phpbb/titania', 'contributions');
        $tracking = phpbb::$container->get('phpbb.titania.tracking');
        $types = phpbb::$container->get('phpbb.titania.contribution.type.collection');
        // Setup the sort tool if not sent, then request
        if ($sort === false) {
            $sort = self::build_sort();
        }
        $sort->request();
        $branch = $branch ? (int) $branch : null;
        $select = 'DISTINCT(c.contrib_id), c.contrib_name, c.contrib_name_clean,
			c.contrib_status, c.contrib_downloads, c.contrib_views, c.contrib_rating,
			c.contrib_rating_count, c.contrib_type, c.contrib_last_update, c.contrib_user_id,
			c.contrib_limited_support, c.contrib_categories, c.contrib_desc, c.contrib_desc_uid';
        switch ($mode) {
            case 'author':
                // Get the contrib_ids this user is an author in (includes as a co-author)
                $contrib_ids = titania::$cache->get_author_contribs($id, $types, phpbb::$user);
                if (!sizeof($contrib_ids)) {
                    return compact('sort');
                }
                $sql_ary = array('SELECT' => $select . ', a.attachment_id, a.thumbnail', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_ATTACHMENTS_TABLE => 'a'), 'ON' => 'c.contrib_id = a.object_id
								AND a.object_type = ' . TITANIA_SCREENSHOT . '
								AND a.is_orphan = 0
								AND a.is_preview = 1')), 'WHERE' => phpbb::$db->sql_in_set('c.contrib_id', $contrib_ids) . '
						AND c.contrib_visible = 1', 'ORDER_BY' => $sort->get_order_by());
                break;
            case 'category':
                $sql_ary = array('SELECT' => $select . ', a.attachment_id, a.thumbnail', 'FROM' => array(TITANIA_CONTRIB_IN_CATEGORIES_TABLE => 'cic'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'ON' => 'cic.contrib_id = c.contrib_id'), array('FROM' => array(TITANIA_REVISIONS_PHPBB_TABLE => 'rp'), 'ON' => 'cic.contrib_id = rp.contrib_id'), array('FROM' => array(TITANIA_ATTACHMENTS_TABLE => 'a'), 'ON' => 'c.contrib_id = a.object_id
								AND a.object_type = ' . TITANIA_SCREENSHOT . '
								AND a.is_orphan = 0
								AND a.is_preview = 1')), 'WHERE' => (is_array($id) && sizeof($id) ? phpbb::$db->sql_in_set('cic.category_id', array_map('intval', $id)) : 'cic.category_id = ' . (int) $id) . '
						AND c.contrib_visible = 1' . ($branch ? " AND rp.phpbb_version_branch = {$branch}" : ''), 'ORDER_BY' => $sort->get_order_by());
                break;
            case 'all':
                $sql_ary = array('SELECT' => $select . ', a.attachment_id, a.thumbnail', 'FROM' => array(TITANIA_CONTRIBS_TABLE => 'c'), 'LEFT_JOIN' => array(array('FROM' => array(TITANIA_REVISIONS_PHPBB_TABLE => 'rp'), 'ON' => 'c.contrib_id = rp.contrib_id'), array('FROM' => array(TITANIA_ATTACHMENTS_TABLE => 'a'), 'ON' => 'c.contrib_id = a.object_id
								AND a.object_type = ' . TITANIA_SCREENSHOT . '
								AND a.is_orphan = 0
								AND a.is_preview = 1')), 'WHERE' => 'c.contrib_visible = 1' . ($branch ? " AND rp.phpbb_version_branch = {$branch}" : ''), 'ORDER_BY' => $sort->get_order_by());
                break;
        }
        $tracking->get_track_sql($sql_ary, TITANIA_CONTRIB, 'c.contrib_id');
        $mod_contrib_mod = (bool) phpbb::$auth->acl_get('u_titania_mod_contrib_mod');
        // Permissions
        if (!$mod_contrib_mod) {
            $sql_ary['SELECT'] .= ', cc.user_id AS coauthor';
            $sql_ary['LEFT_JOIN'][] = array('FROM' => array(TITANIA_CONTRIB_COAUTHORS_TABLE => 'cc'), 'ON' => 'cc.contrib_id = c.contrib_id AND cc.user_id = ' . phpbb::$user->data['user_id']);
            $view_unapproved = array();
            if ($types->find_authed('moderate')) {
                $view_unapproved = array_merge($view_unapproved, $types->find_authed('moderate'));
            }
            if ($types->find_authed('view')) {
                $view_unapproved = array_merge($view_unapproved, $types->find_authed('view'));
            }
            $view_unapproved = array_unique($view_unapproved);
            $sql_ary['WHERE'] .= ' AND (' . phpbb::$db->sql_in_set('c.contrib_status', array(TITANIA_CONTRIB_APPROVED, TITANIA_CONTRIB_DOWNLOAD_DISABLED)) . (sizeof($view_unapproved) ? ' OR ' . phpbb::$db->sql_in_set('c.contrib_type', array_map('intval', $view_unapproved)) : '') . '
				OR c.contrib_user_id = ' . phpbb::$user->data['user_id'] . '
				OR cc.active = 1)';
        }
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        // Handle pagination
        if (!$sort->sql_count($sql_ary, 'DISTINCT(c.contrib_id)')) {
            // No results...no need to query more...
            return compact('sort');
        }
        $controller_helper = phpbb::$container->get('controller.helper');
        $path_helper = phpbb::$container->get('path_helper');
        $access = phpbb::$container->get('phpbb.titania.access');
        $url = $path_helper->get_url_parts($controller_helper->get_current_url());
        $sort->build_pagination($url['base']);
        $result = phpbb::$db->sql_query_limit($sql, $sort->limit, $sort->start);
        $contrib_ids = $user_ids = array();
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            //Check to see if user has permission
            if (!$mod_contrib_mod && $row['contrib_user_id'] != phpbb::$user->data['user_id'] && $row['coauthor'] != phpbb::$user->data['user_id'] && !$access->is_team()) {
                //If the contribution has a status that is not accessible by the current user let's not add it
                if (in_array($row['contrib_status'], array(TITANIA_CONTRIB_NEW, TITANIA_CONTRIB_CLEANED, TITANIA_CONTRIB_HIDDEN, TITANIA_CONTRIB_DISABLED))) {
                    continue;
                }
            }
            $user_ids[] = $row['contrib_user_id'];
            $contrib_ids[] = $row['contrib_id'];
            self::$contribs[$row['contrib_id']] = $row;
        }
        phpbb::$db->sql_freeresult($result);
        // Get user data
        users_overlord::load_users($user_ids);
        // Get phpBB versions
        if (sizeof($contrib_ids)) {
            $validation_free = $types->find_validation_free();
            if (sizeof($validation_free) && titania::$config->require_validation) {
                $sql = 'SELECT rp.contrib_id, rp.phpbb_version_branch, rp.phpbb_version_revision
					FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . ' rp, ' . TITANIA_CONTRIBS_TABLE . ' c
					WHERE ' . phpbb::$db->sql_in_set('rp.contrib_id', array_map('intval', $contrib_ids)) . '
					AND c.contrib_id = rp.contrib_id
					AND (rp.revision_validated = 1
						OR ' . phpbb::$db->sql_in_set('c.contrib_type', $validation_free) . ')
					ORDER BY rp.row_id DESC';
            } else {
                $sql = 'SELECT contrib_id, phpbb_version_branch, phpbb_version_revision FROM ' . TITANIA_REVISIONS_PHPBB_TABLE . '
					WHERE ' . phpbb::$db->sql_in_set('contrib_id', array_map('intval', $contrib_ids)) . (titania::$config->require_validation ? ' AND revision_validated = 1' : '') . '
					ORDER BY row_id DESC';
            }
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                self::$contribs[$row['contrib_id']]['phpbb_versions'][] = $row;
            }
            phpbb::$db->sql_freeresult($result);
        }
        // Setup some objects we'll use for temps
        $contrib = new titania_contribution();
        $contrib->author = new titania_author();
        $versions = titania::$cache->get_phpbb_versions();
        $author_contribs = titania::$cache->get_author_contribs(phpbb::$user->data['user_id'], $types, phpbb::$user, true);
        // Get the mark all tracking
        $tracking->get_track(TITANIA_CONTRIB, 0);
        foreach ($contrib_ids as $contrib_id) {
            $row = self::$contribs[$contrib_id];
            $contrib->__set_array($row);
            $contrib->set_type($row['contrib_type']);
            $contrib->author->user_id = $contrib->contrib_user_id;
            $contrib->author->__set_array($row);
            $contrib->fill_categories();
            // Author contrib variables
            $contrib->is_author = $contrib->contrib_user_id == phpbb::$user->data['user_id'] ? true : false;
            $contrib->is_active_coauthor = in_array($contrib->contrib_id, $author_contribs) ? true : false;
            $rating = new \titania_rating('contrib', $contrib);
            $rating->cannot_rate = true;
            $contrib->rating = $rating;
            // Store the tracking info we grabbed from the DB
            $tracking->store_from_db($row);
            // Get the folder image
            $folder_img = $folder_alt = '';
            $last_read_mark = $tracking->get_track(TITANIA_CONTRIB, $contrib->contrib_id, true);
            $last_complete_mark = $tracking->get_track(TITANIA_CONTRIB, 0, true);
            $is_unread = $contrib->contrib_last_update > $last_read_mark && $contrib->contrib_last_update > $last_complete_mark ? true : false;
            phpbb::$container->get('phpbb.titania.display')->topic_folder_img($folder_img, $folder_alt, 0, $is_unread);
            // Only get unique phpBB versions supported
            if (isset($row['phpbb_versions'])) {
                $ordered_phpbb_versions = versions::order_phpbb_version_list_from_db(titania::$cache, $row['phpbb_versions'], $contrib->options['all_versions']);
            }
            $preview_params = array();
            $stripped_desc = message::generate_clean_excerpt($contrib->contrib_desc, $contrib->contrib_desc_uid, 255, '&hellip;');
            if (!empty($row['attachment_id'])) {
                $preview_params['id'] = $row['attachment_id'];
                if ($row['thumbnail']) {
                    $preview_params['thumb'] = 1;
                }
            }
            phpbb::$template->assign_block_vars($blockname, array_merge($contrib->assign_details(true, true), array('FOLDER_STYLE' => $folder_img, 'FOLDER_IMG' => phpbb::$user->img($folder_img, $folder_alt), 'FOLDER_IMG_SRC' => phpbb::$user->img($folder_img, $folder_alt, false, '', 'src'), 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_ALT' => phpbb::$user->lang[$folder_alt], 'FOLDER_IMG_WIDTH' => phpbb::$user->img($folder_img, '', false, '', 'width'), 'FOLDER_IMG_HEIGHT' => phpbb::$user->img($folder_img, '', false, '', 'height'), 'PHPBB_VERSION' => isset($row['phpbb_versions']) && sizeof($ordered_phpbb_versions) == 1 ? $ordered_phpbb_versions[0] : '', 'DESC_SNIPPET' => $stripped_desc, 'PREVIEW' => $preview_params ? $controller_helper->route('phpbb.titania.download', $preview_params) : '')));
            if (isset($row['phpbb_versions'])) {
                $prev_branch = '';
                foreach ($ordered_phpbb_versions as $version_row) {
                    phpbb::$template->assign_block_vars($blockname . '.phpbb_versions', array('NAME' => $version_row));
                    $branch = versions::get_branch_from_string($version_row);
                    if ($prev_branch != $branch) {
                        phpbb::$template->assign_block_vars($blockname . '.branches', array('NAME' => $version_row));
                    }
                    $prev_branch = $branch;
                }
            }
            $contrib_type = $row['contrib_type'];
        }
        unset($contrib);
        return compact('sort');
    }
コード例 #15
0
ファイル: revision.php プロジェクト: Sajaki/customisation-db
    /**
     * Repack a revision
     *
     * @param titania_revision $old_revision titania_revision object
     * @param titania_queue $old_queue Old queue object
     */
    public function repack($old_revision, $old_queue)
    {
        if (!$this->revision_id) {
            throw new exception('Submit the revision before repacking');
        }
        $this->user->add_lang_ext('phpbb/titania', 'manage');
        // Get the old and new queue objects
        $queue = $this->get_queue();
        if ($old_queue === false) {
            throw new exception('Old queue missing. Revision ID: ' . $old_revision->revision_id);
        }
        // Reply to the queue topic to say that it's been repacked and have the old mpv/automod results listed in it as well
        $repack_message = phpbb::$user->lang['REVISION_REPACKED'] . "\n\n";
        // Add the MPV results
        if ($queue->mpv_results) {
            message::decode($queue->mpv_results, $queue->mpv_results_uid);
            $repack_message .= '[quote=&quot;' . $this->user->lang['VALIDATION_PV'] . '&quot;]' . $queue->mpv_results . "[/quote]\n";
        }
        // Add the Automod results
        if ($queue->automod_results) {
            $repack_message .= '[quote=&quot;' . phpbb::$user->lang['VALIDATION_AUTOMOD'] . '&quot;]' . $queue->automod_results . "[/quote]\n";
        }
        // Reply
        $old_queue->topic_reply($repack_message);
        // Update the old queue with the new results
        $old_queue->revision_id = $queue->revision_id;
        $old_queue->submit();
        // Delete the new queue we made for this revision
        $queue->delete();
        // Unlink the old queue_id from the old revision and set it to repacked
        $old_revision->change_status(TITANIA_REVISION_REPACKED);
        $old_revision->revision_queue_id = 0;
        $old_revision->submit();
        // Update the queue_id for this revision to point to the old queue_id
        $this->revision_queue_id = $old_queue->queue_id;
        $this->submit();
        // Move any translations
        $sql = 'UPDATE ' . TITANIA_ATTACHMENTS_TABLE . '
			SET object_id = ' . $this->revision_id . '
			WHERE object_type = ' . TITANIA_TRANSLATION . '
				AND object_id = ' . $old_revision->revision_id;
        phpbb::$db->sql_query($sql);
        // Hooks
        titania::$hook->call_hook_ref(array(__CLASS__, __FUNCTION__), $this);
    }