/** * Cancel submission process. * * @param bool $redirect Whether to redirect back to contrib details. * @return null */ protected function cancel($redirect = true) { if ($this->revision->revision_id) { $this->revision->delete(); } $this->id = 0; if ($redirect) { redirect($this->contrib->get_url()); } }
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 if (isset($_POST['delete']) && !sizeof($error)) { $revision->delete(); redirect(titania::$contrib->get_url()); } // 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)) {
/** * 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(); }