Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- protected function _update() {
- if (isset($this->_modifiedFields['password']) &&
- $this->_modifiedFields['password'] &&
- strlen($this->_data['password'])
- ){
- $this->_data['password'] = sha1($this->_modifiedFields['password'].$this->_data['salt']);
- }
- }
- public function editAction() {
- // action body
- $this->view->title = "Edit User";
- $this->view->headTitle($this->view->title, 'PREPEND');
- $form = new Application_Form_Admin();
- $form->submit->setLabel('Save');
- $this->view->form = $form;
- if ($this->getRequest()->isPost()) {
- $formData = $this->getRequest()->getPost();
- if ($form->isValid($formData)) {
- $id = (int) $form->getValue('id');
- $data = array(
- 'username' => $form->getValue('username'),
- 'real_name' => $form->getValue('real_name'),
- 'admin' => $form->getValue('admin')
- );
- $password = $form->getValue('password');
- if (!empty($password)) {
- $data['password'] = $password;
- }
- $users = new Application_Model_DbTable_Users();
- $user = $users->getUser($id);
- $user->setFromArray($data);
- $user->save();
- $this->_helper->redirector('index');
- } else {
- $form->populate($formData);
- }
- } else {
- $id = $this->_getParam('id', 0);
- if ($id > 0) {
- $users = new Application_Model_DbTable_Users();
- $form->populate($users->getUser($id)->toArray());
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment