/** * 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()); }
/** * 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']); } $this->revision->load_phpbb_versions(); }
/** * Determine which active revisions in the queue should not be marked as * repacked upon submitting the new revision to the queue. * * @return array Returns array of revision id's */ protected function get_repack_exclusions() { $exclude_from_repack = array(); $in_queue = $this->revisions_in_queue; if (empty($this->revision->phpbb_versions)) { $this->revision->load_phpbb_versions(); } foreach ($this->revision->phpbb_versions as $version) { $branch = (int) is_array($version) ? $version['phpbb_version_branch'] : $version; if (in_array($branch, $this->repackable_branches) || isset($in_queue[$branch]) && $in_queue[$branch]['queue_status'] == TITANIA_QUEUE_NEW) { unset($in_queue[$branch]); } } foreach ($in_queue as $info) { $exclude_from_repack[] = (int) $info['revision_id']; } return $exclude_from_repack; }
// 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); $status_list = array(TITANIA_REVISION_NEW => 'REVISION_NEW', TITANIA_REVISION_APPROVED => 'REVISION_APPROVED', TITANIA_REVISION_DENIED => 'REVISION_DENIED', TITANIA_REVISION_PULLED_SECURITY => 'REVISION_PULLED_FOR_SECURITY', TITANIA_REVISION_PULLED_OTHER => 'REVISION_PULLED_FOR_OTHER', TITANIA_REVISION_REPACKED => 'REVISION_REPACKED', TITANIA_REVISION_RESUBMITTED => 'REVISION_RESUBMITTED'); if ($translation->uploaded || isset($_POST['submit'])) { $revision_license = utf8_normalize_nfc(request_var('revision_license', '', true)); $revision->__set_array(array('revision_name' => utf8_normalize_nfc(request_var('revision_name', $revision->revision_name, true)), 'revision_license' => $revision_license != phpbb::$user->lang['CUSTOM_LICENSE'] ? $revision_license : utf8_normalize_nfc(request_var('revision_custom_license', '', true)))); // Stuff that can be done by moderators only if (titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) { $revision_phpbb_versions = request_var('revision_phpbb_versions', array('')); } } // Submit the revision
/** * @{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; }
/** * 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); }
/** * 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(); }