/** * Form to edit a user * User login must be set in parameter * @return void */ public function edit() { if (!$this->hasRequestParameter('uri')) { throw new Exception('Please set the user uri in request parameter'); } $user = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('uri'))); $this->checkUser($user->getUri()); $types = $user->getTypes(); $myFormContainer = new tao_actions_form_Users(reset($types), $user); $myForm = $myFormContainer->getForm(); if ($myForm->isSubmited()) { if ($myForm->isValid()) { $values = $myForm->getValues(); if (!empty($values['password2']) && !empty($values['password3'])) { $values[PROPERTY_USER_PASSWORD] = core_kernel_users_Service::getPasswordHash()->encrypt($values['password2']); } unset($values['password2']); unset($values['password3']); if (!preg_match("/[A-Z]{2,4}\$/", trim($values[PROPERTY_USER_UILG]))) { unset($values[PROPERTY_USER_UILG]); } if (!preg_match("/[A-Z]{2,4}\$/", trim($values[PROPERTY_USER_DEFLG]))) { unset($values[PROPERTY_USER_DEFLG]); } $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($user); if ($binder->bind($values)) { $this->getEventManager()->trigger(new UserUpdatedEvent($user, $values)); $this->setData('message', __('User saved')); } } } $this->setData('formTitle', __('Edit a user')); $this->setData('myForm', $myForm->render()); $this->setView('user/form.tpl'); }
/** * Short description of method initElements * * @access public * @author Jerome Bogaerts, <*****@*****.**> * @return void */ public function initElements() { parent::initElements(); $this->form->removeElement(\tao_helpers_Uri::encode(PROPERTY_USER_DEFLG)); $this->form->removeElement(\tao_helpers_Uri::encode(PROPERTY_USER_ROLES)); }