<?php /** * Remove a pad * * Subpages are not deleted but are moved up a level in the tree * * @package ElggPad */ $guid = get_input('guid'); $page = new ElggPad($guid); if ($page) { if ($page->canEdit()) { $container = get_entity($page->container_guid); // Bring all child elements forward $parent = $page->parent_guid; $children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID())); if ($children) { foreach ($children as $child) { $child->parent_guid = $parent; } } if ($page->delete()) { system_message(elgg_echo('etherpad:delete:success')); if ($parent) { if ($parent = get_entity($parent)) { forward($parent->getURL()); } } //Forward to pages only if pages integration enabled. Otherwise forward to pads. $handler = elgg_get_plugin_setting('integrate_in_pages', 'etherpad') == 'yes' ? 'pages' : 'etherpad';
if ($type == 'tags') { $input[$name] = string_to_tag_array($input[$name]); } } // Get guids $page_guid = (int) get_input('page_guid'); $container_guid = (int) get_input('container_guid'); $parent_guid = (int) get_input('parent_guid'); elgg_make_sticky_form('etherpad'); if (!$input['title']) { register_error(elgg_echo('pages:error:no_title')); forward(REFERER); } if ($page_guid) { $page = new ElggPad($page_guid); if (!$page || !$page->canEdit()) { register_error(elgg_echo('pages:error:no_save')); forward(REFERER); } $new_page = false; } else { $page = new ElggPad(); if ($parent_guid) { $page->subtype = 'subpad'; } $new_page = true; } if (sizeof($input) > 0) { foreach ($input as $name => $value) { $page->{$name} = $value; }