/** * Create queue item * * @param bool $allow_repack Whether author has allowed repacking. * @param string $test_account Test account details. * @return null */ protected function create_queue_item($allow_repack, $test_account) { // Create the queue $this->revision->update_queue(); $this->queue = $this->revision->get_queue(); // Load the message object $this->get_message(); $this->queue->queue_allow_repack = $allow_repack; if ($test_account) { $this->queue->queue_notes .= "\n\n[b]" . $this->user->lang('TEST_ACCOUNT') . "[/b]\n" . $test_account; } $this->queue->submit(); }
/** * 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); }
/** * 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); }
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))); } // Subscriptions $queue = $revision->get_queue(); if ($queue) { $email_vars = array('NAME' => phpbb::$user->lang['VALIDATION'] . ' - ' . titania::$contrib->contrib_name . ' - ' . $revision->revision_version, 'U_VIEW' => titania_url::build_url('manage/queue', array('q' => $queue->queue_id))); titania_subscriptions::send_notifications(TITANIA_QUEUE, titania::$contrib->contrib_type, 'subscribe_notify_forum.txt', $email_vars, phpbb::$user->data['user_id']); } redirect(titania::$contrib->get_url()); break; } } while ($try_again); phpbb::$template->assign_vars(array('ERROR_MSG' => sizeof($error) ? implode('<br />', $error) : '', 'NEXT_STEP' => $next_step, 'REVISION_ID' => $revision_id, 'AGREEMENT_NOTICE' => titania_types::$types[titania::$contrib->contrib_type]->upload_agreement ? isset(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) ? nl2br(phpbb::$user->lang[titania_types::$types[titania::$contrib->contrib_type]->upload_agreement]) : nl2br(titania_types::$types[titania::$contrib->contrib_type]->upload_agreement) : false, 'QUEUE_ALLOW_REPACK' => true, 'S_POST_ACTION' => $repack ? titania_url::append_url(titania::$contrib->get_url('revision'), array('repack' => $repack)) : titania::$contrib->get_url('revision'))); // 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 /*$allowed_branches = get_allowed_phpbb_branches();
/** * Load revision's corresponding queue item. * * @return null */ protected function load_queue() { $this->queue = $this->revision->get_queue(); }