Пример #1
0
 /**
  * Load revision
  *
  * @param int $id		Revision id.
  * @throws \Exception	Throws exception if revision or its attachment
  *	cannot be loaded.
  * @return null
  */
 protected function load_revision($id)
 {
     $this->id = (int) $id;
     if (!$this->id || !$this->revision->load($this->id) || $this->revision->contrib_id != $this->contrib->contrib_id || $this->revision->attachment_id && !$this->load_attachment($this->revision->attachment_id)) {
         throw new \Exception($this->user->lang['NO_REVISION']);
     }
 }
Пример #2
0
    /**
     * Get the revision object for this queue
     */
    public function get_revision()
    {
        $sql = 'SELECT * FROM ' . TITANIA_REVISIONS_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id . '
				AND revision_id = ' . $this->revision_id;
        $result = phpbb::$db->sql_query($sql);
        $row = phpbb::$db->sql_fetchrow($result);
        phpbb::$db->sql_freeresult($result);
        if ($row) {
            $revision = new titania_revision(contribs_overlord::get_contrib_object($this->contrib_id, true), $this->revision_id);
            $revision->__set_array($row);
            return $revision;
        }
        return false;
    }
Пример #3
0
    /**
     * Repack a revision
     *
     * @param titania_revision $old_revision titania_revision object
     */
    public function repack($old_revision)
    {
        if (!$this->revision_id) {
            throw new exception('Submit the revision before repacking');
        }
        titania::add_lang('manage');
        // Get the old and new queue objects
        $old_queue = $old_revision->get_queue();
        $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 ($old_queue->mpv_results) {
            $mpv_results = $old_queue->mpv_results;
            titania_decode_message($mpv_results, $old_queue->mpv_results_uid);
            $repack_message .= '[quote="' . phpbb::$user->lang['OLD_VALIDATION_MPV'] . '"]' . $mpv_results . "[/quote]\n";
        }
        // Add the Automod results
        if ($old_queue->automod_results) {
            $repack_message .= '[quote="' . phpbb::$user->lang['OLD_VALIDATION_AUTOMOD'] . '"]' . $old_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->mpv_results = $queue->mpv_results;
        $old_queue->mpv_results_bitfield = $queue->mpv_results_bitfield;
        $old_queue->mpv_results_uid = $queue->mpv_results_uid;
        $old_queue->automod_results = $queue->automod_results;
        $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);
    }
Пример #4
0
 /**
  * Install contribution demo.
  *
  * @param int $branch
  * @return array
  */
 protected function install_demo($branch)
 {
     $this->contrib->get_download();
     $demo_url = '';
     if (!empty($this->contrib->download[$branch])) {
         $revision = new \titania_revision($this->contrib);
         $revision->__set_array($this->contrib->download[$branch]);
         $demo_url = $this->contrib->type->install_demo($this->contrib, $revision);
     }
     return array('url' => $demo_url);
 }
Пример #5
0
* @ignore
*/
if (!defined('IN_TITANIA')) {
    exit;
}
load_contrib();
// Editing a revision can only be done by moderators
if (!titania::$contrib->is_author && !titania::$contrib->is_active_coauthor && !titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) {
    titania::needs_auth();
}
// Setup some variables
$revision_id = request_var('revision', 0);
$error = $revision_phpbb_versions = array();
$phpbb_versions = titania::$cache->get_phpbb_versions();
// Load the revision
$revision = new titania_revision(titania::$contrib, $revision_id);
if (!$revision->load()) {
    trigger_error('NO_REVISION');
}
// Translations
$translation = new titania_attachment(TITANIA_TRANSLATION, $revision_id);
$translation->load_attachments();
$translation->upload();
$error = array_merge($error, $translation->error);
// Revision phpBB versions
$revision->load_phpbb_versions();
foreach ($revision->phpbb_versions as $row) {
    $revision_phpbb_versions[] = $phpbb_versions[$row['phpbb_version_branch'] . $row['phpbb_version_revision']];
}
// Revision Status
$revision_status = request_var('revision_status', (int) $revision->revision_status);
Пример #6
0
				WHERE revision_id = ' . $revision->revision_id;
            $result = phpbb::$db->sql_query($sql);
            while ($row = phpbb::$db->sql_fetchrow($result)) {
                $version_string = $row['phpbb_version_branch'][0] . '.' . $row['phpbb_version_branch'][1] . '.' . $row['phpbb_version_revision'];
                $reference_filepath = $validation_tools->automod_phpbb_files($version_string);
                // path to files against which we will validate the package
            }
            $errors = $validation_tools->check_package($reference_filepath);
            if (!empty($errors)) {
                trigger_error(implode('<br /><br />', $errors));
            }
            $validation_tools->remove_temp_files();
            phpbb::$template->assign_var('S_PASSED_TRANSLATION_VALIDATION', true);
            break;
        case 5:
            $revision = new titania_revision(titania::$contrib, $revision_id);
            if (!$revision->load()) {
                trigger_error('NO_REVISION');
            }
            // Repack if that's what we want
            if ($repack) {
                $revision->repack($old_revision);
            }
            // Update the revision to be submitted, which unhides the queue topic and updates the contrib_last_update time
            $revision->revision_submitted = true;
            $revision->submit();
            // Update the queue (make visible)
            $revision->update_queue();
            if ($repack && titania::$config->use_queue && titania_types::$types[titania::$contrib->contrib_type]->use_queue) {
                redirect(titania_url::build_url('manage/queue', array('q' => $revision->revision_queue_id)));
            }
Пример #7
0
    /**
     * Delete this contribution
     */
    public function delete()
    {
        // Delete Revisions
        $revision = new titania_revision($this);
        $sql = 'SELECT * FROM ' . TITANIA_REVISIONS_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $revision->__set_array($row);
            $revision->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Delete Support/Discussion/Queue Discussion Topics
        $topic = new titania_topic();
        $sql = 'SELECT * FROM ' . TITANIA_TOPICS_TABLE . '
			WHERE ' . phpbb::$db->sql_in_set('topic_type', array(TITANIA_SUPPORT, TITANIA_QUEUE_DISCUSSION)) . '
				AND parent_id = ' . $this->contrib_id;
        $result = phpbb::$db->sql_query($sql);
        while ($row = phpbb::$db->sql_fetchrow($result)) {
            $topic->__set_array($row);
            $topic->delete();
        }
        phpbb::$db->sql_freeresult($result);
        // Change the status to new (handles resetting counts)
        $this->change_status(TITANIA_CONTRIB_NEW);
        // Remove any attention items
        $sql = 'DELETE FROM ' . TITANIA_ATTENTION_TABLE . '
			WHERE attention_object_type = ' . TITANIA_CONTRIB . '
				AND attention_object_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        // Delete the release topic
        if ($this->contrib_release_topic_id) {
            phpbb::_include('functions_admin', 'delete_topics');
            delete_topics('topic_id', $this->contrib_release_topic_id);
        }
        // Delete from categories
        $this->update_category_count('-');
        $sql = ' DELETE FROM ' . TITANIA_CONTRIB_IN_CATEGORIES_TABLE . '
			WHERE contrib_id = ' . $this->contrib_id;
        phpbb::$db->sql_query($sql);
        repository::trigger_cron($this->config);
        // Self delete
        parent::delete();
    }
Пример #8
0
 /**
  * @{inheritDoc}
  */
 public function install_demo(\titania_contribution $contrib, \titania_revision $revision)
 {
     $revision->load_phpbb_versions();
     $attachment = $revision->get_attachment();
     $branch = $revision->phpbb_versions[0]['phpbb_version_branch'];
     $package = new package();
     $package->set_source($attachment->get_filepath())->set_temp_path($this->ext_config->__get('contrib_temp_path'), true);
     $demo_url = '';
     if ($this->demo_manager->configure($branch, $contrib, $package)) {
         $result = $this->demo_manager->install();
         if (empty($result['error'])) {
             $demo_url = $this->demo_manager->get_demo_url($branch, $result['id']);
             $contrib->set_demo_url($branch, $demo_url);
             $contrib->submit();
         }
     }
     $package->cleanup();
     return $demo_url;
 }
Пример #9
0
     } else {
         trigger_error('BAD_RATING');
     }
     break;
     /**
      * 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');
Пример #10
0
 /**
  * AutoMOD Test.
  *
  * @param \titania_contribution $contrib
  * @param \titania_revision $revision
  * @param attachment $attachment
  * @param string $download_package
  * @param package $package
  * @param template $template
  * @return array
  */
 public function automod_test(\titania_contribution $contrib, \titania_revision $revision, attachment $attachment, $download_package, package $package, template $template)
 {
     $package->ensure_extracted();
     $prevalidator = $this->get_prevalidator();
     // Automod testing time
     $details = '';
     $error = $html_results = $bbcode_results = array();
     if (!$revision->phpbb_versions) {
         $revision->load_phpbb_versions();
     }
     foreach ($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) {
             $error = array_merge($error, $prevalidator->get_helper()->get_errors());
             continue;
         }
         $template->assign_vars(array('PHPBB_VERSION' => $version_string, 'TEST_ID' => $row['row_id']));
         $html_result = $bbcode_result = '';
         $installed = $prevalidator->run_automod_test($package, $phpbb_path, $details, $html_result, $bbcode_result);
         $html_results[] = $html_result;
         $bbcode_results[] = $bbcode_result;
     }
     if (is_array($details)) {
         $revision->install_time = $details['INSTALLATION_TIME'];
         switch ($details['INSTALLATION_LEVEL']) {
             case 'easy':
                 $revision->install_level = 1;
                 break;
             case 'intermediate':
                 $revision->install_level = 2;
                 break;
             case 'advanced':
                 $revision->install_level = 3;
                 break;
         }
         $revision->submit();
     }
     $html_results = implode('<br /><br />', $html_results);
     $bbcode_results = implode("\n\n", $bbcode_results);
     // Update the queue with the results
     $queue = $revision->get_queue();
     $queue->automod_results = $bbcode_results;
     $queue->submit();
     $template->assign_var('AUTOMOD_RESULTS', $html_results);
     return array('error' => $error);
 }
Пример #11
0
 /**
  * Load revision's corresponding queue item.
  *
  * @return null
  */
 protected function load_queue()
 {
     $this->queue = $this->revision->get_queue();
 }
Пример #12
0
        }
        $error = array_merge($error, $contrib_tools->error);
        if (!sizeof($error)) {
            phpbb::$template->assign_var('S_NEW_REVISION_SUBMITTED', true);
            // Replace the uploaded zip package with the new one
            $contrib_tools->replace_zip();
            if (titania_types::$types[titania::$contrib->contrib_type]->mpv_test && titania::$config->use_queue && titania_types::$types[titania::$contrib->contrib_type]->use_queue) {
                phpbb::$template->assign_var('MPV_TEST_WARNING', true);
            }
        }
        // Remove our temp files
        $contrib_tools->remove_temp_files();
    }
} else {
    if ($step > 1) {
        $revision = new titania_revision(titania::$contrib, $revision_id);
        if (!$revision->load()) {
            trigger_error('NO_REVISION');
        }
        $revision_attachment = new titania_attachment(TITANIA_CONTRIB);
        $revision_attachment->attachment_id = $revision->attachment_id;
        if (!$revision_attachment->load()) {
            trigger_error('ERROR_NO_ATTACHMENT');
        }
        // Start up the machine
        $zip_file = titania::$config->upload_path . '/' . utf8_basename($revision_attachment->attachment_directory) . '/' . utf8_basename($revision_attachment->physical_filename);
        $contrib_tools = new titania_contrib_tools($zip_file);
        $download_package = titania_url::build_url('download', array('id' => $revision_attachment->attachment_id));
        // Now go through any special steps for this type
        $steps = titania_types::$types[titania::$contrib->contrib_type]->upload_steps;
        $step_cnt = 2;
Пример #13
0
 /**
  * Translation validation.
  *
  * @param \titania_contribution $contrib
  * @param \titania_revision $revision
  * @param attachment $attachment
  * @param $download_package
  * @param package $package
  * @param template $template
  * @return array Returns array containing any errors found.
  */
 public function translation_validate(\titania_contribution $contrib, \titania_revision $revision, attachment $attachment, $download_package, package $package, template $template)
 {
     if (empty($revision->phpbb_versions)) {
         $revision->load_phpbb_versions();
     }
     $version = $revision->phpbb_versions[0];
     if ($version['phpbb_version_branch'] != 30) {
         return array();
     }
     $version_string = $version['phpbb_version_branch'][0] . '.' . $version['phpbb_version_branch'][1] . '.' . $version['phpbb_version_revision'];
     $prevalidator = $this->get_prevalidator();
     $reference_filepath = $prevalidator->get_helper()->prepare_phpbb_test_directory($version_string);
     // path to files against which we will validate the package
     $errors = $prevalidator->get_helper()->get_errors();
     if (!empty($errors)) {
         return array('error' => implode('<br /><br />', $errors));
     }
     $errors = $prevalidator->check_package($package, $reference_filepath);
     if (!empty($errors)) {
         return array('error' => $errors);
     }
     $template->assign_var('S_PASSED_TRANSLATION_VALIDATION', true);
     return array();
 }