public function create($aPostData) { $aData = $aPostData['page']; $aMenuData = $aPostData['menu']; $content = trim(stripslashes($aData['content'])); if (isset($aData['id'])) { $this->id = $aData['id']; $this->edited = new Doctrine_Expression("now()"); if ($this->content != $content) { $this->backupPage(); } } else { $this->created = new Doctrine_Expression("now()"); $this->edited = new Doctrine_Expression("now()"); } $this->pname = $aData['pname']; $this->link = Webbers_Normalize::Link($aData['pname']); $this->hd_title = $aData['hd_title']; $this->hd_keywords = $aData['hd_keywords']; $this->content = $content; $this->active = $aData['active']; $this->owner = Zend_Auth::getInstance()->getIdentity()->username; $this->template = isset($aData['template']) ? $aData['template'] : null; $this->save(); if ($aData['menuitem'] == '0') { if (is_array($aMenuData) and $aMenuData['mname'] != '0') { $aMenuData['mname'] = $this->pname; $aMenuData['active'] = $aData['active']; $aMenuData['Pages_id'] = $this->id; $aMenuData['link'] = '/pages/' . $this->link; $menu = new Menu(); $menu->updateMenu($aMenuData); } } else { $menu = Menu::getById($aData['menuitem']); if ($menu->Pages_id > 0) { $oldMenu = Menu::getMenusByPageId($this->id); if ($oldMenu) { $oldMenu->Pages_id = $menu->Pages_id; $oldMenu->save(); } } $menu->mname = $this->pname; $menu->active = $aData['active']; $menu->Pages_id = $this->id; $menu->link = '/pages/' . $this->link; $menu->save(); } return $this->id; }
public function updateQuickEdit() { $arrReturn = ['status' => 'error']; $id = (int) Input::get('pk'); $name = (string) Input::get('name'); $value = Input::get('value'); try { $page = Page::findorFail($id); if ($name == 'active') { $page->active = (int) $value; $page = Menu::updateMenu($page, 'add'); } else { if ($name == 'on_menu') { $type = $value ? 'add' : 'delete'; $page = Menu::updateMenu($page, $type); } else { $page->{$name} = $value; } } } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { return App::abort(404); } $pass = $page->valid(); if ($pass->passes()) { $page->save(); $arrReturn = ['status' => 'ok']; $arrReturn['message'] = $page->name . ' has been saved'; } else { $arrReturn['message'] = ''; $arrErr = $pass->messages()->all(); foreach ($arrErr as $value) { $arrReturn['message'] .= "{$value}\n"; } } $response = Response::json($arrReturn); $response->header('Content-Type', 'application/json'); return $response; }
$url = ADMIN_URL . "/menu_manager/edit.php"; $general->redirectUrl($url, $num); exit; } else { if ($_REQUEST['order'] == "") { $_SESSION['msg'] = 'Please enter order.'; $num = 'danger'; $num .= '&id=' . $_REQUEST['id']; $url = ADMIN_URL . "/menu_manager/edit.php"; $general->redirectUrl($url, $num); exit; } } $cond = array("id" => $_REQUEST['id']); $fieldvalues = array('name' => $_REQUEST['name'], 'order_index' => $_REQUEST['order'], 'is_dashboard_icon' => $_REQUEST['dashboard']); $updated = $Menu->updateMenu($fieldvalues, $cond); if ($updated) { $general->addLogAction($_SESSION['adm_user_id'], 'Edited', $_REQUEST['id'], 'Menu Management', $_SESSION['adm_status']); $error = 'success'; $_SESSION['msg'] = 'Record updated successfully.'; } else { $error = 'danger'; $_SESSION['msg'] = 'Error updating record.'; } $url = ADMIN_URL . "/menu_manager/index.php"; $general->redirectUrl($url, $error); exit; } /*************************************************************************************/ if (isset($_REQUEST['FLAG']) && $_REQUEST['FLAG'] == 'DELETE') { $id = $_REQUEST['id'];
public function menuaddAction() { $form = $this->formPages('menuadd'); $error = false; if (!$this->getRequest()->isPost()) { $this->_flash('/admin/pages', 'Błędne odowołanie siŧ do strony!'); return; } if (!$_POST or !$form->isValid($_POST)) { $this->view->message = $form->getMessages(); $error = true; } else { $menu = new Menu(); try { $menu->updateMenu($_POST); } catch (Exception $e) { $error = true; $this->view->message = $e->getMessage(); } } if ($error) { $this->_flash('/admin/pages', $this->view->message); return; } $this->_flash('/admin/pages', 'Poprawnie dodano element menu!'); }
<?php session_start(); require_once '../classes/connection.class.php'; require_once '../classes/menu.class.php'; require_once '../classes/locate.class.php'; if (isset($_POST['submit'])) { $menu_id = $_POST['menu_id']; $menu_category = $_POST['menu_category']; $menu_title = $_POST['menu_title']; $menu_price = $_POST['menu_price']; //$category_title=$_POST['category_title']; } $updateMenuObj = new Menu(); $updateMenuObj->setMenuID($menu_id); $updateMenuObj->setMenuCategory($menu_category); $updateMenuObj->setMenuTitle($menu_title); $updateMenuObj->setMenuPrice($menu_price); //$updateMenuObj->setCategoryTitle($category_title); $flag = $updateMenuObj->updateMenu(); /*echo '<pre>'; print_r($flag); echo '</pre>'; exit;*/ if ($flag) { $_SESSION['update_menu'] = "The menu successfully updated"; new Locate('../index.php?page=menu&action=view'); } else { $_SESSION['update_not_menu'] = "The menu couldn't be updated"; new Locate('../index.php?page=menu&action=view'); }
<?php //Get from textbox $name = $_POST['menu_name']; $desc = $_POST['menu_description']; $price = $_POST['menu_price']; $id = $_POST['menu_id']; //Instances of Classes include '../classes/class.menu.php'; //assigning of values from Instance $p = new Menu(); $p->menu_id = $id; $p->menu_name = $name; $p->menu_description = $desc; $p->menu_price = $price; //calling of method Save if ($p->updateMenu()) { header('Location:../public/menu_2.php'); } else { echo Database::$conn->error; }