Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
     // Do some simple error checking on the versions
     if (empty($revision_phpbb_versions)) {
         $error[] = phpbb::$user->lang['MUST_SELECT_ONE_VERSION'];
     } else {
         foreach ($revision_phpbb_versions as $revision_phpbb_version) {
             if (!$revision_phpbb_version || strlen($revision_phpbb_version) < 5 || $revision_phpbb_version[1] != '.' || $revision_phpbb_version[3] != '.') {
                 $error[] = sprintf(phpbb::$user->lang['BAD_VERSION_SELECTED'], $revision_phpbb_version);
             }
         }
     }
 }
 // If no errors, submit
 if (!sizeof($error)) {
     // Update the status
     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());