/** * Displays an article delete confirmation view. * * Note, that the article for non-index mode operation is automatically determined in the can_handle * phase. * * If create privileges apply, we relocate to the index creation article * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_article = new midcom_db_article($args[0]); // Relocate to delete the link instead of the article itself if ($this->_article->topic !== $this->_content_topic->id) { return new midcom_response_relocate("delete/link/{$args[0]}/"); } $this->_article->require_do('midgard:delete'); $this->_load_datamanager(); if (array_key_exists('net_nehmer_blog_deleteok', $_REQUEST)) { $title = $this->_article->title; // Deletion confirmed. if (!$this->_article->delete()) { throw new midcom_error("Failed to delete article {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string()); } // Delete all the links pointing to the article $qb = net_nehmer_blog_link_dba::new_query_builder(); $qb->add_constraint('article', '=', $this->_article->id); $links = $qb->execute_unchecked(); midcom::get('auth')->request_sudo('net.nehmer.blog'); foreach ($links as $link) { $link->delete(); } midcom::get('auth')->drop_sudo(); // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_article->guid); // Show user interface message midcom::get('uimessages')->add($this->_l10n->get('net.nehmer.blog'), sprintf($this->_l10n->get('article %s deleted'), $title)); // Delete ok, relocating to welcome. return new midcom_response_relocate(''); } if (array_key_exists('net_nehmer_blog_deletecancel', $_REQUEST)) { midcom::get('uimessages')->add($this->_l10n->get('net.nehmer.blog'), $this->_l10n->get('delete cancelled')); // Redirect to view page. if ($this->_config->get('view_in_url')) { return new midcom_response_relocate("view/{$this->_article->name}/"); } else { return new midcom_response_relocate("{$this->_article->name}/"); } } $this->_prepare_request_data(); midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid); $this->_view_toolbar->bind_to($this->_article); midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}"); $this->_update_breadcrumb_line($handler_id); }
/** * Displays an article delete confirmation view. * * Note, that the article for non-index mode operation is automatically determined in the can_handle * phase. * * If create privileges apply, we relocate to the index creation article * * @param mixed $handler_id The ID of the handler. * @param Array $args The argument list. * @param Array &$data The local request data. */ public function _handler_delete($handler_id, array $args, array &$data) { $this->_article = new midcom_db_article($args[0]); // Relocate to delete the link instead of the article itself if ($this->_article->topic !== $this->_content_topic->id) { return new midcom_response_relocate("delete/link/{$args[0]}/"); } $this->_article->require_do('midgard:delete'); $this->_load_datamanager(); if (array_key_exists('net_nehmer_static_deleteok', $_REQUEST)) { // Deletion confirmed. if (!$this->_article->delete()) { throw new midcom_error("Failed to delete article {$args[0]}, last Midgard error was: " . midcom_connection::get_error_string()); } // Delete all the links pointing to the article $qb = net_nehmer_static_link_dba::new_query_builder(); $qb->add_constraint('article', '=', $this->_article->id); $links = $qb->execute_unchecked(); midcom::get('auth')->request_sudo('net.nehmer.static'); foreach ($links as $link) { $link->delete(); } midcom::get('auth')->drop_sudo(); // Update the index $indexer = midcom::get('indexer'); $indexer->delete($this->_article->guid); // Delete ok, relocating to welcome. return new midcom_response_relocate(''); } if (array_key_exists('net_nehmer_static_deletecancel', $_REQUEST)) { // Redirect to view page. return new midcom_response_relocate("{$this->_article->name}/"); } $this->_prepare_request_data(); $this->bind_view_to_object($this->_article, $this->_datamanager->schema->name); midcom::get('style')->append_substyle('admin'); midcom::get('metadata')->set_request_metadata($this->_article->metadata->revised, $this->_article->guid); midcom::get('head')->set_pagetitle("{$this->_topic->extra}: {$this->_article->title}"); $this->set_active_leaf($this->_article->id); $this->_update_breadcrumb_line($handler_id); }