/** * * @param type $user Objeto GUser (nivel superior en la jerarquía de usuarios) */ public function getSubUser($user) { $subUser = UserFactory::getUser($user->tipo); $subTable = $subUser->getTableIO($this->adapter); $subUserObject = $subTable->getUser($user->uid); return $subUserObject; }
public function myaccountAction() { if ($this->isUserLogued()) { // Verifico que hayan iniciado sesion $user = $this->getUserTable()->getUserFromUserName($this->getUserLogued()); $userObject = UserFactory::getUser($user->tipo); // Contruyo menu de usuario $container = $this->getUserMenu($userObject); // $this->getServiceLocator()->setService('usernav', $container); // $config = null; //echo get_class($config); $router = $this->getServiceLocator()->get('router'); NavigationUtils::injectRouter($container, $router); $view = new ViewModel(array('container' => $container)); return $view; } else { // si no se inicio sesion redirijo al home return $this->redirect()->toRoute('home'); } }
public function editAction() { $uid = (int) $this->params()->fromRoute('uid', 0); if (!$uid) { return $this->redirect()->toRoute('user'); } $user = $this->getUserTable()->getUser($uid); $subUserObject = UserFactory::getUser($user->tipo); $subUser = $subUserObject::getTableIO($this->getServiceLocator()->get('Zend\\Db\\Adapter\\Adapter'))->getUser($user->uid); $userData = $user->getFullData(); $form = new UserForm(); // Creo subForm y seteo los valores $subform = $subUser->getForm(); $subform->setName('subForm'); $subUserData = $subUser->getFullData(); $subform->setData($subUserData); $form->add($subform); ///////// $form->setData($userData); $form->get('submit')->setAttribute('value', 'Editar'); ////// $request = $this->getRequest(); if ($request->isPost()) { // PERFORM EDIT //$form->setInputFilter($user->getInputFilter()); $form->setData($request->getPost()); if ($form->isValid()) { $user->exchangeArray($form->getData()); // Hash password $this->hashUserPassword($user); $subUser->exchangeArray($request->getPost('subForm')); $this->startTransactionAddUser($user, $subUser, false); //$this->getUserTable()->saveUser($user); // Redirect to list of user $this->addInfoMessage(GeneralMessages::EDIT_OK); return $this->redirect()->toRoute('user'); } else { $this->addErrorMessage(GeneralMessages::EDIT_ERROR); $this->addErrorMessage($form->isValid()); return $this->redirect()->toRoute('user'); } } return array('uid' => $uid, 'form' => $form); }