/** * Create revision. * * @param array $settings * @return null */ protected function create_revision($settings) { $this->revision->__set_array(array('attachment_id' => $this->attachment ? $this->attachment->get_id() : 0, 'revision_name' => $settings['name'], 'revision_version' => $settings['version'], 'revision_status' => TITANIA_REVISION_NEW, 'queue_allow_repack' => $settings['allow_repack'], 'revision_license' => $settings['license'])); $this->revision->set_custom_fields($settings['custom']); $this->revision->phpbb_versions = $settings['vendor_versions']; $this->revision->submit(); $this->id = $this->revision->revision_id; }
/** * 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; }
/** * 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); }
// 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 if (isset($_POST['submit'])) { if (!check_form_key('postform')) { $error[] = phpbb::$user->lang['FORM_INVALID']; } if (sizeof(titania_types::$types[titania::$contrib->contrib_type]->license_options) && !titania_types::$types[titania::$contrib->contrib_type]->license_allow_custom && !in_array($revision->revision_license, titania_types::$types[titania::$contrib->contrib_type]->license_options)) { $error[] = phpbb::$user->lang['INVALID_LICENSE']; } if (titania_types::$types[titania::$contrib->contrib_type]->acl_get('moderate')) { // Delete the revision if that is what we want
$selected_branches = $allowed_branches; } else { $selected_branches = request_var('phpbb_branch', array(0)); $selected_branches = array_intersect($selected_branches, $allowed_branches); if (!sizeof($selected_branches)) { $error[] = phpbb::$user->lang['NO_PHPBB_BRANCH']; } } // Send the file to the type class so it can do custom error checks if ($revision_attachment->uploaded) { $error = array_merge($error, titania_types::$types[titania::$contrib->contrib_type]->upload_check($revision_attachment)); } if (!sizeof($error)) { // Success, create a new revision to start $revision = new titania_revision(titania::$contrib); $revision->__set_array(array('attachment_id' => $revision_attachment->attachment_id, 'revision_name' => utf8_normalize_nfc(request_var('revision_name', '', true)), 'revision_version' => $revision_version, 'queue_allow_repack' => $queue_allow_repack, 'revision_license' => $revision_license != phpbb::$user->lang['CUSTOM_LICENSE'] || !titania_types::$types[titania::$contrib->contrib_type]->license_allow_custom ? $revision_license : utf8_normalize_nfc(request_var('revision_custom_license', '', true)))); $revision->phpbb_versions = $selected_branches; /*$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), );
/** * 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(); }