/** * Move To Trash * Hide special pages * */ function MoveToTrash($cmd) { global $gp_titles, $gp_index, $langmessage, $gp_menu; includeFile('admin/admin_trash.php'); admin_trash::PrepFolder(); $this->CacheSettings(); $_POST += array('index' => ''); $indexes = explode(',', $_POST['index']); foreach ($indexes as $index) { $title = common::IndexToTitle($index); // Create file in trash if ($title) { if (!admin_trash::MoveToTrash_File($title, $index, $trash_data)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } } // Remove from menu if (isset($gp_menu[$index])) { if (count($gp_menu) == 1) { continue; } if (!$this->RmFromMenu($index, false)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } } unset($gp_titles[$index]); unset($gp_index[$title]); } $this->ResetHomepage(); if (!admin_trash::ModTrashData($trash_data, null)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } if (!admin_tools::SaveAllConfig()) { $this->RestoreSettings(); return false; } if ($cmd == 'trash_page') { $link = common::GetUrl('Admin_Trash'); message(sprintf($langmessage['MOVED_TO_TRASH'], $link)); } //finally, delete the files in /_pages foreach ($indexes as $index) { $title = common::IndexToTitle($index); if (!$title) { continue; } $file = gpFiles::PageFile($title); if (gpFiles::Exists($file)) { unlink($file); } } return true; }
/** * Move To Trash * Hide special pages * */ function MoveToTrash($cmd) { global $gp_titles, $gp_index, $langmessage, $gp_menu; if ($_SERVER['REQUEST_METHOD'] != 'POST') { message($langmessage['OOPS'] . ' (Invalid Request)'); return; } includeFile('admin/admin_trash.php'); admin_trash::PrepFolder(); $this->CacheSettings(); $index =& $_POST['index']; $title = common::IndexToTitle($index); if (!$title) { message($langmessage['OOPS'] . ' (Invalid Index)'); return; } $index = $gp_index[$title]; if (isset($gp_menu[$index])) { if (count($gp_menu) == 1) { message($langmessage['OOPS'] . ' (The main menu cannot be empty)'); return; } if (!$this->RmFromMenu($index, false)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } } if (!admin_trash::MoveToTrash_File($title, $index, $trash_data)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } unset($gp_titles[$index]); unset($gp_index[$title]); if (!admin_trash::ModTrashData($trash_data, null)) { message($langmessage['OOPS']); $this->RestoreSettings(); return false; } if (!admin_tools::SavePagesPHP()) { $this->RestoreSettings(); return false; } if ($cmd == 'trash_page') { $link = common::GetUrl('Admin_Trash'); message(sprintf($langmessage['MOVED_TO_TRASH'], $link)); } //delete the file in /_pages $file = gpFiles::PageFile($title); if (file_exists($file)) { unlink($file); } return true; }
/** * Move To Trash * Hide special pages * */ function MoveToTrash($cmd) { global $gp_titles, $gp_index, $langmessage, $gp_menu, $config, $dataDir; includeFile('admin/admin_trash.php'); $this->CacheSettings(); $_POST += array('index' => ''); $indexes = explode(',', $_POST['index']); $trash_data = array(); $delete_files = array(); foreach ($indexes as $index) { $title = common::IndexToTitle($index); // Create file in trash if ($title) { if (!admin_trash::MoveToTrash_File($title, $index, $trash_data)) { msg($langmessage['OOPS'] . ' (Not Moved)'); $this->RestoreSettings(); return false; } } // Remove from menu if (isset($gp_menu[$index])) { if (count($gp_menu) == 1) { continue; } if (!$this->RmFromMenu($index, false)) { msg($langmessage['OOPS']); $this->RestoreSettings(); return false; } } unset($gp_titles[$index]); unset($gp_index[$title]); } $this->ResetHomepage(); if (!admin_tools::SaveAllConfig()) { $this->RestoreSettings(); return false; } $link = common::GetUrl('Admin_Trash'); msg(sprintf($langmessage['MOVED_TO_TRASH'], $link)); gpPlugin::Action('MenuPageTrashed', array($indexes)); return true; }