Guest User

Untitled

a guest
May 29th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2.  
  3.     protected function _update() {
  4.         if (isset($this->_modifiedFields['password']) &&
  5.             $this->_modifiedFields['password'] &&
  6.             strlen($this->_data['password'])
  7.         ){
  8.             $this->_data['password'] =  sha1($this->_modifiedFields['password'].$this->_data['salt']);
  9.         }
  10.     }
  11.   public function editAction() {
  12.         // action body
  13.         $this->view->title = "Edit User";
  14.         $this->view->headTitle($this->view->title, 'PREPEND');
  15.         $form = new Application_Form_Admin();
  16.         $form->submit->setLabel('Save');
  17.         $this->view->form = $form;
  18.         if ($this->getRequest()->isPost()) {
  19.             $formData = $this->getRequest()->getPost();
  20.             if ($form->isValid($formData)) {
  21.                 $id = (int) $form->getValue('id');
  22.                 $username = $form->getValue('username');
  23.                 $password = $form->getValue('password');
  24.                 $real_name = $form->getValue('real_name');
  25.                 $admin = $form->getValue('admin');
  26.                 $users = new Application_Model_DbTable_Users();
  27.                 $user = $users->getUser($id);
  28.                 $user->setFromArray($data);
  29.                 $user->save();
  30.                 $this->_helper->redirector('index');
  31.             } else {
  32.                 $form->populate($formData);
  33.             }
  34.         } else {
  35.             $id = $this->_getParam('id', 0);
  36.             if ($id > 0) {
  37.                 $users = new Application_Model_DbTable_Users();
  38.                 $form->populate($users->getUser($id)->toArray());
  39.             }
  40.         }
  41.     }
  42.  
  43. ?>
Add Comment
Please, Sign In to add comment