Пример #1
0
 /**
  * Process revision submission steps.
  *
  * @return array Returns array in form of
  *	array(
  *		'error'				=> array(),
  *		'notice'			=> array(),
  *		'complete'			=> (bool),
  *		'allow_continue'	=> (bool),
  *	)
  */
 protected function process_steps()
 {
     $id = $this->request->variable('revision_id', 0);
     $steps = $this->contrib->type->upload_steps;
     if (!check_form_key('postform')) {
         return $this->get_result(array('error' => array($this->user->lang['FORM_INVALID'])), $steps, -1);
     }
     // If not id is provided, then we're just starting the submission process.
     if (!$id) {
         return $this->get_result($this->create(), $steps, -1);
     }
     $this->load_revision($id);
     // We use the validation_date field during the submission process
     // to store the current step in order to ensure that the user does not
     // skip any steps.
     $step_num = $this->revision->validation_date;
     if (empty($steps[$step_num])) {
         return $this->get_result(array(), $steps, $step_num);
     }
     $step = $steps[$step_num];
     if ($this->attachment) {
         if (!$this->package->get_source()) {
             $this->set_package_paths();
         }
     }
     $hash = $this->package->get_md5_hash();
     $result = $this->run_step($step['function']);
     $result = $this->get_result($result, $steps, $step_num);
     $this->package->cleanup();
     $new_hash = $this->package->get_md5_hash();
     if ($hash !== $new_hash) {
         $this->update_package_stats();
     }
     if (!$result['allow_continue']) {
         $this->cancel(false);
         return $result;
     }
     $this->revision->validation_date = $step_num + 1;
     $this->revision->submit();
     return $result;
 }
Пример #2
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);
    }
Пример #3
0
        if ($revision_status != $revision->revision_status && titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) {
            $revision->change_status($revision_status);
        }
        // Update the phpBB versions
        $revision->phpbb_versions = array();
        foreach ($revision_phpbb_versions as $revision_phpbb_version) {
            if (!isset($versions[(int) $revision_phpbb_version[0] . (int) $revision_phpbb_version[2] . substr($revision_phpbb_version, 4)])) {
                // Have we added some new phpBB version that does not exist?  We need to purge the cache then
                titania::$cache->destroy('_titania_phpbb_versions');
            }
            // Update the list of phpbb_versions for the revision to update
            $revision->phpbb_versions[] = array('phpbb_version_branch' => (int) $revision_phpbb_version[0] . (int) $revision_phpbb_version[2], 'phpbb_version_revision' => substr($revision_phpbb_version, 4));
        }
        // Submit the translations
        $translation->submit();
        $revision->submit();
        redirect(titania::$contrib->get_url());
    }
}
// Output the available license options
foreach (titania_types::$types[titania::$contrib->contrib_type]->license_options as $option) {
    phpbb::$template->assign_block_vars('license_options', array('NAME' => $option, 'VALUE' => $option));
}
// Display the list of phpBB versions available
foreach ($phpbb_versions as $version => $name) {
    $template->assign_block_vars('phpbb_versions', array('VERSION' => $name, 'S_SELECTED' => in_array($name, $revision_phpbb_versions) ? true : false));
}
// Display the status list
foreach ($status_list as $status => $row) {
    phpbb::$template->assign_block_vars('status_select', array('S_SELECTED' => $status == $revision_status ? true : false, 'VALUE' => $status, 'NAME' => phpbb::$user->lang[$row]));
}
Пример #4
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);
 }