public function locationsAction() { $locationsModel = new Locations(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if (@$data['method'] == 'create') { //CREATE NEW Location unset($data['method']); if ($data['name'] == '') { $this->view->error = "Please Provide a Name for the New Location."; $this->view->data = $data; } else { $locationsModel->insert($data); $this->view->success = "New Location Created."; } } if (@$data['method'] == 'update') { //UPDATE Location unset($data['method']); $locationsModel->updateRecord($data['id'], $data); $this->view->success = "User Record Updated."; } if (@$data['method'] == 'delete') { //DELETE Location $where = "id=" . $data['id']; $locationsModel->delete($where); } } $locations = $locationsModel->getAll(); $page = $this->_getParam('page', 1); $paginator = Zend_Paginator::factory($locations); $paginator->setItemCountPerPage(20); $paginator->setCurrentPageNumber($page); $this->view->locations = $paginator; }
$context['page_title'] = i18n::s('Delete a location'); // not found if (!isset($item['id'])) { include '../error.php'; // permission denied } elseif (!$permitted) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // deletion is confirmed } elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') { // touch the related anchor before actual deletion, since the location has to be accessible at that time if (is_object($anchor)) { $anchor->touch('location:delete', $item['id']); } // if no error, back to the anchor or to the index page if (Locations::delete($item['id'])) { Locations::clear($item); if (is_object($anchor)) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url()); } else { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/'); } } // deletion has to be confirmed } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('The action has not been confirmed.')); // ask for confirmation } else { // commands $menu = array();
<?php echo gettext("Yes"); ?> </a> <a href="locations.php"><?php echo gettext("No"); ?> </a> </p> <?php exit; } $db = new ossim_db(); $conn = $db->connect(); Locations::delete($conn, $id); Util::memcacheFlush(); $db->close(); ?> <p><?php echo gettext("Location deleted"); ?> </p> <script type="text/javascript"> document.location.href="locations.php"; </script> </body> </html>