Exemplo n.º 1
0
 /**
  * Run AutoMOD Tests.
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function automod()
 {
     if (!$this->contrib->type->automod_test) {
         return $this->helper->error('INVALID_TOOl');
     }
     $this->package->ensure_extracted();
     // Start up the machine
     $prevalidator = $this->contrib->type->get_prevalidator();
     // Automod testing time
     $details = '';
     $html_results = $bbcode_results = array();
     $this->revision->load_phpbb_versions();
     foreach ($this->revision->phpbb_versions as $row) {
         $version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' . $row['phpbb_version_revision'];
         $phpbb_path = $prevalidator->get_helper()->prepare_phpbb_test_directory($version_string);
         if ($phpbb_path === false) {
             continue;
         }
         $this->template->assign_vars(array('PHPBB_VERSION' => $version_string, 'TEST_ID' => $row['row_id']));
         $html_result = $bbcode_result = '';
         $prevalidator->run_automod_test($this->package, $phpbb_path, $details, $html_result, $bbcode_result);
         $bbcode_results[] = $bbcode_result;
     }
     $bbcode_results = $this->get_result_post('VALIDATION_AUTOMOD', implode("\n\n", $bbcode_results));
     // Update the queue with the results
     $post = $this->queue->topic_reply($bbcode_results);
     $this->package->cleanup();
     redirect($post->get_url());
 }
Exemplo n.º 2
0
 /**
  * Allow author to repack revision action.
  *
  * @return null
  */
 protected function allow_author_repack()
 {
     $topic = $this->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 = $this->get_message($post);
     // Submit check...handles running $post->post_data() if required
     $submit = $message_object->submit_check();
     if ($submit) {
         $this->queue->allow_author_repack = true;
         $repack_url = $this->contrib->get_url('revision', array('page' => 'repack', 'id' => $this->queue->revision_id));
         $for_edit = $post->generate_text_for_edit();
         $post->post_text = $for_edit['message'] . "\n\n\n\t\t\t\t[url=" . $repack_url . ']' . $this->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();
         $this->queue->submit();
         $this->queue->topic_reply('QUEUE_REPLY_ALLOW_REPACK');
         $this->queue->submit();
         redirect($this->queue->get_url());
     }
     $message_object->display();
     // Common stuff
     $this->template->assign_vars(array('S_POST_ACTION' => $this->helper->get_current_url(), 'L_POST_A' => $this->user->lang['DISCUSSION_REPLY_MESSAGE']));
     return $this->helper->render('manage/queue_post.html', 'DISCUSSION_REPLY_MESSAGE');
 }
Exemplo n.º 3
0
    /**
     * 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="' . $this->user->lang['VALIDATION_PV'] . '"]' . $queue->mpv_results . "[/quote]\n";
        }
        // Add the Automod results
        if ($queue->automod_results) {
            $repack_message .= '[quote="' . phpbb::$user->lang['VALIDATION_AUTOMOD'] . '"]' . $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);
    }