/** * The default action * * Displays the admin dashboard * * @return void */ public function indexAction() { $notes = new Model_Note(); $this->view->notes = $notes->getUsersNotes(); $content = new Model_Page(); $this->view->pages = $content->getCurrentUsersPages('create_date DESC', 5); $user = new Model_User(); $identity = $user->getCurrentUser(); $form = new Admin_Form_User(); $form->onlyIndexIndexActionElements(); $form->setAction($this->baseUrl . '/admin/user/update-my-account'); $firstName = $form->getElement('first_name'); $firstName->setValue($identity->first_name); $lastName = $form->getElement('last_name'); $lastName->setValue($identity->last_name); $email = $form->getElement('email'); $email->setValue($identity->email); $submit = $form->getElement('submitAdminUserForm'); $submit->setLabel($this->view->getTranslation('Update My Account')); $displayGroup = $form->getDisplayGroup('adminUserGroup'); $displayGroup->setLegend($this->view->getTranslation('My Account'))->setAttrib('class', 'formColumn'); $this->view->form = $form; }
/** * Add action * * Add a new user * * @return void */ public function createAction() { $form = new Admin_Form_User(); $elmUserName = $form->getElement('name'); $elmUserName->addValidators(array(array('UsernameExistsNot', true))); $form->onlyCreateActionElements(); $u = new Model_User(); $form->setModel($u); if ($form->validatePost()) { $password = $form->getValue('password'); $userName = $form->getValue('name'); $result = $form->create(array('password' => md5($password))); if ($result) { $this->_redirect('admin/user/open/username/' . $userName); } } $this->view->breadcrumbs['Create User'] = $this->baseUrl . '/admin/user/create'; $form->setAction($this->baseUrl . '/admin/user/create'); $this->view->form = $form; $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark/url/admin_user_create'; }