function store_user($user, $newUser = true) { $username = stringsHelper::sanitize_string($this->input->post('username', true)); $password = $this->input->post('password', true); if ($password) { $user->setPassword($this->hashPassword($password)); } $user->setFullName($this->input->post('fullname', true)); $user->setUserName($username); $user->setAdmin($this->input->post('admin', true)); if ($newUser) { if (!$password) { $this->addMessage('Debe ingresar una clave.', 'error'); } if ($this->doctrine->em->getRepository('Entities\\User')->findOneBy(array('username' => $username))) { $this->addMessage('El nombre de usuario ya existe.', 'error'); } } if ($password != $this->input->post('password-confirm', true)) { $this->addMessage('La clave y su confirmación no son iguales.', 'error'); } if ($this->error) { $this->load_user_form($user, $newUser); } else { $this->doctrine->em->persist($user); $this->doctrine->em->flush(); redirect('backend/user'); } }
public function updatePagina($id) { $this->titulo = $this->input->post('titulo'); $this->amigable = url_title(stringsHelper::sanitize_string($this->input->post('titulo')), '-', TRUE); $this->subtitulo = $this->input->post('subtitulo'); $this->contenido = $this->input->post('contenido'); $this->db->update('pagina', $this, 'id = ' . $id); }
function store_page($page, $newPage = true) { $alias = stringsHelper::sanitize_string($this->input->post('alias', true)); if (!$alias) { $alias = stringsHelper::sanitize_string($this->input->post('title', true)); } $page->setTitle($this->input->post('title', true)); $page->setAlias($alias); $page->setRestricted($this->input->post('restricted'), true); $page->setContent($this->input->post('content')); if (!$page->getTitle()) { $this->addMessage('Debe ingresar un título para la página.'); } if ($this->error) { $this->load_page_form($page, $newPage); } else { $this->doctrine->em->persist($page); $this->doctrine->em->flush(); redirect('backend/page'); } }
function store_nav_item($nav, $navItem, $newNavItem = true) { $parentNavItem = $this->doctrine->em->find('Entities\\NavItem', $this->input->post('parentNavItem', true)); $page = $this->doctrine->em->find('Entities\\Page', $this->input->post('page_id', true)); $alias = stringsHelper::sanitize_string($this->input->post('alias', true)); if (!$alias) { $alias = stringsHelper::sanitize_string($this->input->post('title', true)); } $homepage = $this->input->post('homepage', true); if ($homepage) { $prevNavItemHome = $this->doctrine->em->getRepository('Entities\\NavItem')->findOneBy(array('homepage' => true))->setHomepage(false); if ($prevNavItemHome != $navItem) { $prevNavItemHome->setHomepage(false); $this->doctrine->em->persist($prevNavItemHome); } } $customurl = $this->input->post('customurl', true); if (!$customurl) { $navItem->setPage($page); $navItem->setCustomurl(null); } else { $navItem->setPage(null); $navItem->setCustomurl($customurl); } $navItem->setTitle($this->input->post('title', true)); $navItem->setAlias($alias); $navItem->setLayout($this->input->post('layout', true)); $navItem->setHomepage($homepage); $navItem->setOrdering($this->input->post('ordering', true)); if ($parentNavItem) { $navItem->setParent($parentNavItem); $navItem->setNav(null); } else { $navItem->setNav($nav); $navItem->setParent(null); } if (!$navItem->getTitle()) { $this->addMessage('Debe ingresar un título para el item.'); } if (!$navItem->getLayout() && $navItem->getPage()) { $this->addMessage('Debe seleccionar un layout para el menú cuando elige una pagina asociada.'); } if ($this->error) { $this->load_nav_item_form($nav, $navItem, $newNavItem); } else { $this->doctrine->em->persist($navItem); $this->doctrine->em->flush(); redirect('backend/nav/edit/' . $nav->getId()); } }