public function agregarAction() { $this->view->subtitle = $this->info->sitio->menus->agregar->titulo; $this->view->action = $this->info->sitio->menus->agregar->action; $this->view->buttonText = $this->info->sitio->menus->agregar->buttonText; $eMenu = new Menus(); if ($this->_request->isPost()) { $cleanData = $this->getCleanData(); $this->view->messages = $cleanData['messages']; if ($cleanData['secureData'] === TRUE) { $clean =& $cleanData['clean']; $data = array('nombre' => $clean['nombre'], 'descripcion' => $clean['descripcion'], 'posicion' => $clean['posicion'], 'privado' => $clean['privado'], 'estado' => $clean['estado'], 'id_sitio' => $this->session->sitio->id); $eMenu->insert($data); $this->_redirect('/admin/menus/'); return; } else { $this->setAsBadData(); $this->view->mensajeError = "Se encontraron errores en el formulario."; return; } } else { $this->setAsEmptyData(); } $this->render(); }
case true: if (!isset($_POST['token']) || !Token::isExist($_POST['token'])) { // VALIDATE ALL $alertred[] = TOKEN_NOT_EXIST; } if (!isset($_POST['name']) || $_POST['name'] == '') { $alertred[] = MENU_NAME_CANNOT_EMPTY; } if (!isset($_POST['type']) || $_POST['type'] == '') { $alertred[] = MENU_TYPE_CANNOT_EMPTY; } if (isset($alertred)) { $data['alertred'] = $alertred; } else { $vars = array('parent' => Typo::int($_POST['parent']), 'menuid' => Typo::strip($_POST['id']), 'name' => Typo::cleanX($_POST['name']), 'class' => Typo::cleanX($_POST['class']), 'type' => Typo::strip($_POST['type']), 'value' => Typo::cleanX($_POST[$_POST['type']])); Menus::insert($vars); $data['alertgreen'][] = 'Menu Item Added'; Token::remove($_POST['token']); } break; default: # code... break; } // ADD MENU ITEM END // CHANGE ORDER START if (isset($_POST['changeorder'])) { $submit = true; } else { $submit = false; }