Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * 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();
 }
Esempio n. 3
0
 /**
  * Approve action.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function approve()
 {
     $public_notes = $this->request->variable('public_notes', '', true);
     if ($this->validate('approve')) {
         $this->queue->approve($public_notes);
         // Reload contribution with new data.
         $this->contrib->load();
         $this->contrib->type->approve($this->contrib, $this->queue, $this->request);
         $this->cache->destroy('sql', TITANIA_CONTRIBS_TABLE);
         redirect($this->queue->get_url());
     }
     if ($this->contrib->type->update_public) {
         $this->template->assign_vars(array('PUBLIC_MESSAGE' => $public_notes, 'S_PUBLIC_NOTES' => true));
         if ($this->request->is_set_post('preview')) {
             $this->template->assign_vars(array('PUBLIC_PREVIEW_SUBJECT' => 'Re: ' . $this->contrib->contrib_name, 'PUBLIC_PREVIEW_MESSAGE' => $this->get_public_notes_preview($public_notes)));
         }
     }
     return $this->helper->render('manage/queue_validate.html', $this->user->lang['APPROVE_QUEUE'] . ' - ' . $this->contrib->contrib_name);
 }
Esempio n. 4
0
	FROM ' . TITANIA_ATTACHMENTS_TABLE . "\n\tWHERE attachment_id = {$download_id}";
$result = phpbb::$db->sql_query_limit($sql, 1);
$attachment = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result);
if (!$attachment) {
    trigger_error('ERROR_NO_ATTACHMENT');
}
// Don't allow downloads of revisions for TITANIA_CONTRIB_DOWNLOAD_DISABLED items unless on the team or an author.
if ($attachment['object_type'] == TITANIA_CONTRIB) {
    $sql = 'SELECT contrib_id, revision_status FROM ' . TITANIA_REVISIONS_TABLE . '
			WHERE  attachment_id = ' . $attachment['attachment_id'];
    $result = phpbb::$db->sql_query($sql);
    $revision = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    $contrib = new titania_contribution();
    if (!$contrib->load((int) $revision['contrib_id'])) {
        trigger_error('NO_ATTACHMENT_SELECTED');
    }
    if (($revision['revision_status'] != TITANIA_REVISION_APPROVED && titania::$config->require_validation && titania_types::$types[$contrib->contrib_type]->require_validation || $contrib->contrib_status == TITANIA_CONTRIB_DOWNLOAD_DISABLED) && !$contrib->is_author && !$contrib->is_active_coauthor && !titania_types::$types[$contrib->contrib_type]->acl_get('view') && !titania_types::$types[$contrib->contrib_type]->acl_get('moderate')) {
        // Is it the MPV server requesting the file?  If so we allow non-approved file downloads
        $is_mpv_server = false;
        foreach (titania::$config->mpv_server_list as $data) {
            $dns_ipv4 = dns_get_record($data['host'], DNS_A);
            $dns_ipv6 = dns_get_record($data['host'], DNS_AAAA);
            if (isset($dns_ipv4[0]) && isset($dns_ipv4[0]['ip']) && phpbb::$user->ip == $dns_ipv4[0]['ip'] || isset($dns_ipv6[0]) && isset($dns_ipv6[0]['ip']) && phpbb::$user->ip == $dns_ipv6[0]['ip']) {
                $is_mpv_server = true;
                break;
            }
        }
        if (!$is_mpv_server) {
            trigger_error('NO_ATTACHMENT_SELECTED');
Esempio n. 5
0
    /**
     * 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);
    }
Esempio n. 6
0
         }
         $revision->revision_queue_id = 0;
         $revision->submit();
         // Delete the queue
         $queue->delete();
         redirect(titania_url::append_url($base_url));
     } else {
         titania::confirm_box(false, 'DELETE_QUEUE');
     }
     break;
 case 'approve':
 case 'deny':
     $queue = queue_overlord::get_queue_object($queue_id, true);
     // Load the contribution
     $contrib = new titania_contribution();
     $contrib->load((int) $queue->contrib_id);
     // Do not allow to approve your own contributions, except for founders...
     if (!titania::$config->allow_self_validation && phpbb::$user->data['user_type'] != USER_FOUNDER && $action == 'approve' && ($contrib->is_author || $contrib->is_active_coauthor || $contrib->is_coauthor)) {
         titania::needs_auth();
     }
     if (!titania_types::$types[$contrib->contrib_type]->acl_get('validate')) {
         titania::needs_auth();
     }
     // Load the message object for the validation reason
     $queue->message_fields_prefix = 'message_validation';
     $message_object = new titania_message($queue);
     $message_object->set_auth(array('bbcode' => phpbb::$auth->acl_get('u_titania_bbcode'), 'smilies' => phpbb::$auth->acl_get('u_titania_smilies')));
     $message_object->set_settings(array('display_subject' => false));
     $error = array();
     $public_notes = utf8_normalize_nfc(request_var('public_notes', '', true));
     if ($message_object->submit_check()) {
Esempio n. 7
0
             $messenger->template($email_template, users_overlord::get_user($post->post_user_id, 'user_lang'));
             $messenger->to(users_overlord::get_user($post->post_user_id, 'user_email'), users_overlord::get_user($post->post_user_id, '_username'));
             $messenger->assign_vars(array('USERNAME' => htmlspecialchars_decode(users_overlord::get_user($post->post_user_id, '_username')), 'POST_SUBJECT' => htmlspecialchars_decode(censor_text($post->post_subject)), 'TOPIC_TITLE' => htmlspecialchars_decode(censor_text($post->topic->topic_subject)), 'U_VIEW_TOPIC' => titania_url::append_url($post->topic->get_url()), 'U_VIEW_POST' => titania_url::append_url($post->get_url())));
             $messenger->send();
             phpbb::$user->set_custom_lang_path($lang_path);
         }
         redirect(titania_url::build_url(titania_url::$current_page));
     }
     users_overlord::load_users(array($post->post_user_id, $post->post_edit_user, $post->post_delete_user));
     users_overlord::assign_details($post->post_user_id, 'POSTER_', true);
     phpbb::$template->assign_vars(array('POST_SUBJECT' => censor_text($post->post_subject), 'POST_DATE' => phpbb::$user->format_date($post->post_time), 'POST_TEXT' => $post->generate_text_for_display(), 'EDITED_MESSAGE' => $post->post_edited ? sprintf(phpbb::$user->lang['EDITED_MESSAGE'], users_overlord::get_user($post->post_edit_user, '_full'), phpbb::$user->format_date($post->post_edited)) : '', 'DELETED_MESSAGE' => $post->post_deleted != 0 ? sprintf(phpbb::$user->lang['DELETED_MESSAGE'], users_overlord::get_user($post->post_delete_user, '_full'), phpbb::$user->format_date($post->post_deleted), $post->get_url('undelete')) : '', 'POST_EDIT_REASON' => censor_text($post->post_edit_reason), 'U_VIEW' => $post->get_url(), 'U_EDIT' => $post->get_url('edit'), 'SECTION_NAME' => '<a href="' . $post->get_url() . '">' . censor_text($post->post_subject) . '</a> - ' . phpbb::$user->lang['ATTENTION']));
     $title = censor_text($post->post_subject);
     break;
 case TITANIA_CONTRIB:
     $contrib = new titania_contribution();
     if (!$contrib->load((int) $object_id)) {
         $attention_object->delete();
         trigger_error('NO_CONTRIB');
     }
     // Close the report
     if ($close) {
         redirect(titania_url::build_url(titania_url::$current_page));
     }
     users_overlord::load_users(array($contrib->contrib_user_id));
     users_overlord::assign_details($contrib->contrib_user_id, 'POSTER_', true);
     phpbb::$template->assign_vars(array('POST_SUBJECT' => censor_text($contrib->contrib_name), 'POST_DATE' => phpbb::$user->format_date($contrib->contrib_last_update), 'POST_TEXT' => $contrib->generate_text_for_display(), 'U_VIEW' => $contrib->get_url(), 'U_EDIT' => $contrib->get_url('manage'), 'SECTION_NAME' => '<a href="' . $contrib->get_url() . '">' . censor_text($contrib->contrib_name) . '</a>  - ' . phpbb::$user->lang['ATTENTION']));
     $title = censor_text($contrib->contrib_name);
     break;
 default:
     trigger_error('NO_ATTENTION_TYPE');
     break;
Esempio n. 8
0
 /**
  * Undelete a topic
  *
  * @param int $topic_id
  */
 public function undelete_topic($topic_id)
 {
     titania::add_lang('posting');
     phpbb::$user->add_lang('mcp');
     // Load the stuff we need
     $topic_object = $this->load_topic($topic_id);
     // Auth check
     $is_authed = false;
     if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
         $is_authed = true;
     } else {
         if (phpbb::$auth->acl_get('u_titania_post_mod_own')) {
             if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic_object->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) {
                 $is_authed = true;
             } else {
                 if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic_object->parent_id) {
                     $contrib = new titania_contribution();
                     $contrib->load((int) $topic_object->parent_id);
                     if ($contrib->is_author || $contrib->is_active_coauthor) {
                         $is_authed = true;
                     }
                 }
             }
         }
     }
     // Check permissions
     if (!$is_authed) {
         titania::needs_auth();
     }
     if (titania::confirm_box(true)) {
         $topic_object->undelete();
         redirect($topic_object->get_url());
     } else {
         titania::confirm_box(false, 'UNDELETE_TOPIC');
     }
     redirect($topic_object->get_url());
 }
Esempio n. 9
0
    /**
     * 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;
    }
Esempio n. 10
0
if (!$attachment || $attachment['object_type'] != TITANIA_CONTRIB) {
    clr_error('ERROR_NO_ATTACHMENT');
}
if ((int) $attachment['object_type'] != TITANIA_CONTRIB || $attachment['is_orphan'] || $attachment['attachment_access'] < titania::$access_level) {
    clr_error('ERROR_NO_ATTACHMENT');
}
/**
* Get revision and contribution
*/
$sql = 'SELECT revision_id, contrib_id, revision_status, revision_clr_options FROM ' . TITANIA_REVISIONS_TABLE . '
    WHERE  attachment_id = ' . $attachment['attachment_id'];
$result = phpbb::$db->sql_query($sql);
$revision = phpbb::$db->sql_fetchrow($result);
phpbb::$db->sql_freeresult($result);
$contrib = new titania_contribution();
if (!$contrib->load((int) $revision['contrib_id']) || $revision['revision_status'] != TITANIA_REVISION_APPROVED) {
    clr_error('SORRY_AUTH_VIEW_ATTACH');
}
if (!$contrib->has_colorizeit()) {
    clr_error('CLR_ERROR_NOSAMPLE');
}
/**
* Get file options
*/
if (!strlen($revision['revision_clr_options'])) {
    $zip_file = titania::$config->upload_path . utf8_basename($attachment['attachment_directory']) . '/' . utf8_basename($attachment['physical_filename']);
    if (!@file_exists($zip_file)) {
        clr_error('ERROR_NO_ATTACHMENT');
    }
    $new_dir_name = md5(serialize($_SERVER)) . '_' . microtime();
    $contrib_tools = new titania_contrib_tools($zip_file, $new_dir_name);
Esempio n. 11
0
    /**
     * Display a single queue item
     *
     * @param int $queue_id
     * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic)
     */
    public static function display_queue_item($queue_id)
    {
        titania::add_lang('contributions');
        $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . '
				AND r.revision_id = q.revision_id
				AND t.topic_id = q.queue_topic_id');
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$row) {
            trigger_error('NO_QUEUE_ITEM');
        }
        self::$queue[$queue_id] = $row;
        // Load the contribution
        $contrib = new titania_contribution();
        $contrib->load((int) $row['contrib_id']);
        $contrib->get_download($row['revision_id']);
        $contrib->get_revisions();
        $contrib->get_screenshots();
        $contrib->assign_details();
        // Load the topic (with the already selected data)
        $topic = new titania_topic();
        $topic->__set_array($row);
        // Bit of a hack for the posting
        $_REQUEST['t'] = $topic->topic_id;
        // Some quick-actions
        $quick_actions = array();
        if ($row['queue_status'] > 0) {
            if ($row['queue_progress'] == phpbb::$user->data['user_id']) {
                $quick_actions['MARK_NO_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'no_progress')), 'class' => 'queue_progress');
            } else {
                if (!$row['queue_progress']) {
                    $quick_actions['MARK_IN_PROGRESS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'in_progress')), 'class' => 'queue_progress');
                }
            }
            $tags = titania::$cache->get_tags(TITANIA_QUEUE);
            unset($tags[$row['queue_status']]);
            $quick_actions['CHANGE_STATUS'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'move')), 'class' => 'change_status', 'tags' => $tags);
            if (titania_types::$types[$contrib->contrib_type]->acl_get('moderate')) {
                $quick_actions['REPACK'] = array('url' => titania_url::append_url($contrib->get_url('revision'), array('repack' => $row['revision_id'])), 'class' => 'repack');
            }
            // This allows you to alter the author submitted notes to the validation team, not really useful as the field's purpose was changed, so commenting out
            /*$quick_actions['ALTER_NOTES'] = array(
            			'url'		=> titania_url::append_url(titania_url::$current_page_url, array('action' => 'notes')),
            		);*/
            // Misc actions
            $subactions = array();
            if (titania_types::$types[$contrib->contrib_type]->mpv_test) {
                $subactions['RETEST_MPV'] = array('url' => titania_url::build_url('', array('action' => 'mpv', 'revision' => $row['revision_id'])));
            }
            if (titania_types::$types[$contrib->contrib_type]->automod_test) {
                $subactions['RETEST_AUTOMOD'] = array('url' => titania_url::build_url('', array('action' => 'automod', 'revision' => $row['revision_id'])));
            }
            $subactions['REBUILD_FIRST_POST'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'rebuild')));
            $quick_actions['CAT_MISC'] = array('subactions' => $subactions, 'class' => 'misc');
            // Validation
            if (titania_types::$types[$contrib->contrib_type]->acl_get('validate')) {
                $quick_actions['APPROVE'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'approve', 'start' => '*destroy*')), 'class' => 'approve');
                $quick_actions['DENY'] = array('url' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'deny', 'start' => '*destroy*')), 'class' => 'deny');
            }
        }
        foreach ($quick_actions as $lang_key => $data) {
            phpbb::$template->assign_block_vars('queue_actions', array('NAME' => isset(phpbb::$user->lang[$lang_key]) ? phpbb::$user->lang[$lang_key] : $lang_key, 'CLASS' => isset($data['class']) ? $data['class'] : '', 'U_VIEW' => isset($data['url']) ? $data['url'] : ''));
            if (isset($data['tags'])) {
                foreach ($data['tags'] as $tag_id => $tag_row) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => isset(phpbb::$user->lang[$tag_row['tag_field_name']]) ? phpbb::$user->lang[$tag_row['tag_field_name']] : $tag_row['tag_field_name'], 'U_ACTION' => titania_url::append_url($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions')))));
                }
            }
            if (isset($data['subactions'])) {
                foreach ($data['subactions'] as $sublang_key => $subdata) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => isset(phpbb::$user->lang[$sublang_key]) ? phpbb::$user->lang[$sublang_key] : $sublang_key, 'U_ACTION' => $subdata['url']));
                }
            }
        }
        if ($row['queue_status'] == -2) {
            $current_status = phpbb::$user->lang['REVISION_DENIED'];
        } else {
            if ($row['queue_status'] == -1) {
                $current_status = phpbb::$user->lang['REVISION_APPROVED'];
            } else {
                $current_status = titania_tags::get_tag_name($row['queue_status']);
            }
        }
        phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'reply', 't' => $topic->topic_id)), 'U_NEW_REVISION' => false));
        // Subscriptions
        titania_subscriptions::handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, titania_url::$current_page_url);
        return compact('row', 'contrib', 'topic');
    }
Esempio n. 12
0
      * Rerun the MPV or Automod test for the queue
      */
 /**
  * Rerun the MPV or Automod test for the queue
  */
 case 'mpv':
 case 'automod':
     $revision_id = request_var('revision', 0);
     titania::add_lang('contributions');
     // Get the revision, contribution, attachment, and queue
     $revision = new titania_revision(false, $revision_id);
     if (!$revision->load()) {
         trigger_error('NO_REVISION');
     }
     $contrib = new titania_contribution();
     if (!$contrib->load($revision->contrib_id)) {
         trigger_error('CONTRIB_NOT_FOUND');
     }
     $revision->contrib = $contrib;
     if (!titania_types::$types[$contrib->contrib_type]->acl_get('view')) {
         titania::needs_auth();
     }
     $revision_attachment = new titania_attachment(TITANIA_CONTRIB);
     $revision_attachment->attachment_id = $revision->attachment_id;
     if (!$revision_attachment->load()) {
         trigger_error('ERROR_NO_ATTACHMENT');
     }
     $queue = $revision->get_queue();
     $zip_file = titania::$config->upload_path . '/' . utf8_basename($revision_attachment->attachment_directory) . '/' . utf8_basename($revision_attachment->physical_filename);
     $download_package = titania_url::build_url('download', array('id' => $revision_attachment->attachment_id));
     if ($action == 'mpv') {
Esempio n. 13
0
    /**
     * Display a single queue item
     *
     * @param int $queue_id
     * @return array('row' => (sql selection), 'contrib' => $contrib, 'topic' => $topic)
     */
    public static function display_queue_item($queue_id)
    {
        phpbb::$user->add_lang_ext('phpbb/titania', 'contributions');
        $controller_helper = phpbb::$container->get('phpbb.titania.controller.helper');
        $path_helper = phpbb::$container->get('path_helper');
        $sql_ary = array('SELECT' => '*', 'FROM' => array(TITANIA_QUEUE_TABLE => 'q', TITANIA_REVISIONS_TABLE => 'r', TITANIA_TOPICS_TABLE => 't'), 'WHERE' => 'q.queue_id = ' . (int) $queue_id . '
				AND r.revision_id = q.revision_id
				AND t.topic_id = q.queue_topic_id');
        // Main SQL Query
        $sql = phpbb::$db->sql_build_query('SELECT', $sql_ary);
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if (!$row) {
            trigger_error('NO_QUEUE_ITEM');
        }
        self::$queue[$queue_id] = $row;
        $queue = self::get_queue_object($queue_id);
        // Load the contribution
        $contrib = new titania_contribution();
        $contrib->load((int) $row['contrib_id']);
        $contrib->get_download($row['revision_id']);
        $contrib->get_revisions();
        $contrib->get_screenshots();
        $contrib->assign_details();
        // Load the topic (with the already selected data)
        $topic = new titania_topic();
        $topic->__set_array($row);
        // Bit of a hack for the posting
        phpbb::$request->overwrite('t', $topic->topic_id);
        $is_moderator = $contrib->type->acl_get('moderate');
        $is_validator = $contrib->type->acl_get('validate');
        $hash = array('hash' => generate_link_hash('queue_tool'));
        // Misc actions
        $misc_actions = array(array('RETEST_PV', $queue->get_tool_url('mpv', $row['revision_id'], $hash), $contrib->type->mpv_test), array('RETEST_PV', $queue->get_tool_url('epv', $row['revision_id'], $hash), $contrib->type->epv_test), array('RETEST_AUTOMOD', $queue->get_tool_url('automod', $row['revision_id'], $hash), $contrib->type->automod_test));
        // Some quick-actions
        $quick_actions = array();
        $hash = array('hash' => generate_link_hash('queue_action'));
        if ($row['queue_status'] > 0) {
            $misc_actions = array_merge($misc_actions, array(array('REBUILD_FIRST_POST', $queue->get_url('rebuild', $hash), true), array('ALLOW_AUTHOR_REPACK', $queue->get_url('allow_author_repack'), $is_moderator && !$row['allow_author_repack']), array('MARK_TESTED', $queue->get_url('tested', $hash), !$row['queue_tested']), array('MARK_UNTESTED', $queue->get_url('not_tested', $hash), $row['queue_tested'])));
            $tags = titania::$cache->get_tags(TITANIA_QUEUE);
            unset($tags[$row['queue_status']]);
            $quick_actions = array(array('MARK_NO_PROGRESS', $queue->get_url('no_progress', $hash), $row['queue_progress'] == phpbb::$user->data['user_id'], 'queue_progress'), array('MARK_IN_PROGRESS', $queue->get_url('in_progress', $hash), !$row['queue_progress'], 'queue_progress'), array('CHANGE_STATUS', $queue->get_url('move'), true, 'change_status', $tags), array('REPACK', $contrib->get_url('revision', array('page' => 'repack', 'id' => $row['revision_id'])), $is_moderator, 'repack'), array('CAT_MISC', '', true, 'misc', '', $misc_actions), array('APPROVE', $queue->get_url('approve'), $is_validator, 'approve'), array('DENY', $queue->get_url('deny'), $is_validator, 'deny'));
        }
        if (empty($quick_actions) && !empty($misc_actions)) {
            $quick_actions = array(array('CAT_MISC', '', true, 'misc', '', $misc_actions));
        }
        foreach ($quick_actions as $data) {
            $properties = array('name', 'url', 'auth', 'class', 'tags', 'subactions');
            $data = array_pad($data, sizeof($properties), '');
            $data = array_combine($properties, $data);
            if (!$data['auth']) {
                continue;
            }
            phpbb::$template->assign_block_vars('queue_actions', array('NAME' => phpbb::$user->lang($data['name']), 'CLASS' => $data['class'], 'U_VIEW' => $data['url']));
            if ($data['tags']) {
                foreach ($data['tags'] as $tag_id => $tag_row) {
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('ID' => $tag_id, 'NAME' => phpbb::$user->lang($tag_row['tag_field_name']), 'U_ACTION' => $path_helper->append_url_params($data['url'], array('id' => $tag_id, 'hash' => generate_link_hash('quick_actions')))));
                }
            }
            if ($data['subactions']) {
                foreach ($data['subactions'] as $subdata) {
                    $subdata = array_pad($subdata, sizeof($properties), '');
                    $subdata = array_combine($properties, $subdata);
                    if (!$subdata['auth']) {
                        continue;
                    }
                    phpbb::$template->assign_block_vars('queue_actions.subactions', array('NAME' => phpbb::$user->lang($subdata['name']), 'U_ACTION' => $subdata['url']));
                }
            }
        }
        if ($row['queue_status'] == -3) {
            $current_status = phpbb::$user->lang('QUEUE_CLOSED');
        } else {
            if ($row['queue_status'] == -2) {
                $current_status = phpbb::$user->lang['REVISION_DENIED'];
            } else {
                if ($row['queue_status'] == -1) {
                    $current_status = phpbb::$user->lang['REVISION_APPROVED'];
                } else {
                    $current_status = phpbb::$container->get('phpbb.titania.tags')->get_tag_name($row['queue_status']);
                }
            }
        }
        phpbb::$template->assign_vars(array('CURRENT_STATUS' => $current_status, 'S_DISPLAY_CONTRIBUTION' => true, 'S_IN_QUEUE' => true, 'U_POST_REPLY' => $queue->get_url('reply'), 'U_NEW_REVISION' => false));
        // Subscriptions
        phpbb::$container->get('phpbb.titania.subscriptions')->handle_subscriptions(TITANIA_TOPIC, $topic->topic_id, $controller_helper->get_current_url(), 'SUBSCRIBE_TOPIC');
        return compact('row', 'contrib', 'topic');
    }
Esempio n. 14
0
 /**
  * Build the quick moderation actions for output for this topic
  *
  * @param mixed $topic
  */
 public static function build_quick_actions($topic)
 {
     // Auth check
     $is_authed = $is_moderator = false;
     if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
         $is_authed = $is_moderator = true;
     } else {
         if (phpbb::$auth->acl_get('u_titania_post_mod_own')) {
             if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) {
                 $is_authed = true;
             } else {
                 if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic->parent_id) {
                     $contrib = new titania_contribution();
                     $contrib->load((int) $topic->parent_id);
                     if ($contrib->is_author || $contrib->is_active_coauthor) {
                         $is_authed = true;
                     }
                 }
             }
         }
     }
     if (!$is_authed) {
         return;
     }
     $actions = array('MAKE_NORMAL' => $topic->topic_sticky ? $topic->get_url('unsticky_topic') : false, 'MAKE_STICKY' => !$topic->topic_sticky ? $topic->get_url('sticky_topic') : false, 'LOCK_TOPIC' => !$topic->topic_locked ? $topic->get_url('lock_topic') : false, 'UNLOCK_TOPIC' => $topic->topic_locked ? $topic->get_url('unlock_topic') : false, 'SPLIT_TOPIC' => $is_moderator && $topic->topic_type == TITANIA_SUPPORT ? $topic->get_url('split_topic') : false, 'MERGE_POSTS' => $is_moderator && $topic->topic_type == TITANIA_SUPPORT ? $topic->get_url('move_posts') : false, 'SOFT_DELETE_TOPIC' => $topic->get_url('delete_topic'), 'UNDELETE_TOPIC' => $topic->get_url('undelete_topic'));
     if (phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
         $actions = array_merge($actions, array('HARD_DELETE_TOPIC' => $topic->get_url('hard_delete_topic')));
     }
     foreach ($actions as $title => $link) {
         if (!$link) {
             continue;
         }
         phpbb::$template->assign_block_vars('quickmod', array('TITLE' => phpbb::$user->lang($title), 'LINK' => $link));
     }
 }
Esempio n. 15
0
/**
* Copy new posts for queue discussion, queue to the forum
*/
function phpbb_com_titania_queue_update_first_queue_post($hook, &$post_object, $queue_object)
{
    if ($queue_object->queue_status == TITANIA_QUEUE_HIDE || !$queue_object->queue_topic_id) {
        return;
    }
    // First we copy over the queue discussion topic if required
    $sql = 'SELECT topic_id, phpbb_topic_id, topic_category FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE parent_id = ' . $queue_object->contrib_id . '
			AND topic_type = ' . TITANIA_QUEUE_DISCUSSION;
    $result = phpbb::$db->sql_query($sql);
    $topic_row = phpbb::$db->sql_fetchrow($result);
    phpbb::$db->sql_freeresult($result);
    // Do we need to create the queue discussion topic or not?
    if ($topic_row['topic_id'] && !$topic_row['phpbb_topic_id']) {
        $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, TITANIA_QUEUE_DISCUSSION);
        $temp_post = new titania_post();
        // Go through any posts in the queue discussion topic and copy them
        $topic_id = false;
        $sql = 'SELECT * FROM ' . TITANIA_POSTS_TABLE . ' WHERE topic_id = ' . $topic_row['topic_id'];
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $temp_post->__set_array($row);
            $post_text = $row['post_text'];
            titania_decode_message($post_text, $row['post_text_uid']);
            $post_text .= "\n\n" . titania_url::remove_sid($temp_post->get_url());
            $options = array('poster_id' => $row['post_user_id'], 'forum_id' => $forum_id, 'topic_title' => $row['post_subject'], 'post_text' => $post_text);
            titania::_include('functions_posting', 'phpbb_posting');
            if ($topic_id) {
                $options = array_merge($options, array('topic_id' => $topic_id));
                phpbb_posting('reply', $options);
            } else {
                switch ($topic_row['topic_category']) {
                    case TITANIA_TYPE_MOD:
                        $options['poster_id'] = titania::$config->forum_mod_robot;
                        break;
                    case TITANIA_TYPE_STYLE:
                        $options['poster_id'] = titania::$config->forum_style_robot;
                        break;
                }
                $topic_id = phpbb_posting('post', $options);
            }
        }
        phpbb::$db->sql_freeresult($result);
        if ($topic_id) {
            $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
				SET phpbb_topic_id = ' . $topic_id . '
				WHERE topic_id = ' . $topic_row['topic_id'];
            phpbb::$db->sql_query($sql);
        }
        unset($temp_post);
    }
    // Does a queue topic already exist?  If so, don't repost.
    $sql = 'SELECT phpbb_topic_id FROM ' . TITANIA_TOPICS_TABLE . '
		WHERE topic_id = ' . $queue_object->queue_topic_id;
    phpbb::$db->sql_query($sql);
    $phpbb_topic_id = phpbb::$db->sql_fetchfield('phpbb_topic_id');
    phpbb::$db->sql_freeresult();
    if ($phpbb_topic_id) {
        return;
    }
    $forum_id = phpbb_com_forum_id($post_object->topic->topic_category, $post_object->topic->topic_type);
    if (!$forum_id) {
        return;
    }
    $post_object->submit();
    titania::_include('functions_posting', 'phpbb_posting');
    // Need some stuff
    titania::add_lang('contributions');
    $contrib = new titania_contribution();
    $contrib->load((int) $queue_object->contrib_id);
    $revision = $queue_object->get_revision();
    $contrib->get_download($revision->revision_id);
    switch ($post_object->topic->topic_category) {
        case TITANIA_TYPE_MOD:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_mod_robot;
            $lang_var = 'MOD_QUEUE_TOPIC';
            break;
        case TITANIA_TYPE_STYLE:
            $post_object->topic->topic_first_post_user_id = titania::$config->forum_style_robot;
            $lang_var = 'STYLE_QUEUE_TOPIC';
            break;
        default:
            return;
            break;
    }
    $description = $contrib->contrib_desc;
    titania_decode_message($description, $contrib->contrib_desc_uid);
    $post_text = sprintf(phpbb::$user->lang[$lang_var], $contrib->contrib_name, $contrib->author->get_url(), users_overlord::get_user($contrib->author->user_id, '_username'), $description, $revision->revision_version, titania_url::build_url('download', array('id' => $revision->attachment_id)), $contrib->download['real_filename'], $contrib->download['filesize']);
    $post_text .= "\n\n" . $post_object->post_text;
    titania_decode_message($post_text, $post_object->post_text_uid);
    $post_text .= "\n\n" . titania_url::remove_sid($post_object->get_url());
    $options = array('poster_id' => $post_object->topic->topic_first_post_user_id, 'forum_id' => $forum_id, 'topic_title' => $post_object->topic->topic_subject, 'post_text' => $post_text);
    $topic_id = phpbb_posting('post', $options);
    $post_object->topic->phpbb_topic_id = $topic_id;
    $sql = 'UPDATE ' . TITANIA_TOPICS_TABLE . '
		SET phpbb_topic_id = ' . (int) $topic_id . '
		WHERE topic_id = ' . $post_object->topic->topic_id;
    phpbb::$db->sql_query($sql);
}
Esempio n. 16
0
 /**
  * Get contribution.
  *
  * @param int $contrib_id
  * @return \titania_contribution
  */
 protected function get_contrib($contrib_id)
 {
     $contrib = $this->contrib;
     // Load the contrib parent if not loaded.
     if (!is_object($contrib) || !$contrib->contrib_id == $contrib_id && $contrib_id) {
         $contrib = new \titania_contribution();
         $contrib->load((int) $contrib_id);
     }
     return $contrib;
 }
Esempio n. 17
0
 /**
  * Build the quick moderation actions for output for this topic
  *
  * @param mixed $topic
  */
 public static function build_quick_actions($topic)
 {
     // Auth check
     $is_authed = false;
     if (phpbb::$auth->acl_get('u_titania_mod_post_mod')) {
         $is_authed = true;
     } else {
         if (phpbb::$auth->acl_get('u_titania_post_mod_own')) {
             if (is_object(titania::$contrib) && titania::$contrib->contrib_id == $topic->parent_id && titania::$contrib->is_author || titania::$contrib->is_active_coauthor) {
                 $is_authed = true;
             } else {
                 if (!is_object(titania::$contrib) || !titania::$contrib->contrib_id == $topic->parent_id) {
                     $contrib = new titania_contribution();
                     $contrib->load((int) $topic->parent_id);
                     if ($contrib->is_author || $contrib->is_active_coauthor) {
                         $is_authed = true;
                     }
                 }
             }
         }
     }
     if (!$is_authed) {
         return;
     }
     $actions = array('MAKE_NORMAL' => $topic->topic_sticky ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'unsticky_topic')) : false, 'MAKE_STICKY' => !$topic->topic_sticky ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'sticky_topic')) : false, 'LOCK_TOPIC' => !$topic->topic_locked ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'lock_topic')) : false, 'UNLOCK_TOPIC' => $topic->topic_locked ? titania_url::append_url(titania_url::$current_page_url, array('action' => 'unlock_topic')) : false, 'SOFT_DELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'delete_topic')), 'UNDELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'undelete_topic')));
     if (phpbb::$auth->acl_get('u_titania_post_hard_delete')) {
         $actions = array_merge($actions, array('HARD_DELETE_TOPIC' => titania_url::append_url(titania_url::$current_page_url, array('action' => 'hard_delete_topic'))));
     }
     phpbb::$template->assign_var('TOPIC_QUICK_ACTIONS', titania::build_quick_actions($actions));
 }