示例#1
0
 /**
  * EditAction for Users
  *
  * @return void
  */
 public function editAction()
 {
     $this->view->title = "Edit Users";
     $form = new User_Form_User();
     $form->submit->setLabel('Save');
     $form->removeElement('password');
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $model = new User_Model_Users();
             $id = $this->getRequest()->getPost('id');
             $model->update($form->getValues(), 'id = ' . (int) $id);
             return $this->_helper->redirector('index');
         } else {
             $form->populate($this->getRequest()->getPost());
         }
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $model = new User_Model_Users();
             $form->populate($model->fetchEntry($id));
         }
     }
     $this->view->form = $form;
 }
 public function editAction()
 {
     if ($this->_hasParam("id")) {
         $id = $this->_getParam("id");
         //$update = $this->_isUserAllowed(User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE);
         $update = Agana_Acl_Service::isAllowed(Zend_Auth::getInstance()->getIdentity()->acl_role_id, User_Module_Acl::ACL_RESOURCE_USER, User_Module_Acl::ACL_RESOURCE_USER_PRIVILEGE_UPDATE);
         $isMe = $id == Zend_Auth::getInstance()->getIdentity()->id;
         if ($update || $isMe) {
             $request = $this->getRequest();
             $userDomain = new User_Domain_User(null);
             $user = $userDomain->getById($id);
             $form = new User_Form_User(User_Form_User::ACTION_EDIT, $user);
             if ($request->isPost()) {
                 $data = $request->getPost();
                 if (isset($data['save'])) {
                     if ($form->isValid($data)) {
                         try {
                             /**
                              * Before save test if the user has permission to change
                              * GROUP and STATUS
                              * It only can update this fields if has update privilege
                              * not only being the profile owner
                              * We do not want that the users change it's own group
                              * to another one like Administrator
                              */
                             if (!$update) {
                                 $data['acl_role_id'] = $user->getAcl_role_id();
                                 $data['status'] = $user->getStatus();
                             }
                             $this->_update($data);
                             $msg = 'User updated';
                             $this->_helper->flashMessenger->addMessage(array('success' => $msg));
                             $this->_helper->redirector('index', 'profile', 'user', array('id' => $id));
                         } catch (Exception $e) {
                             $this->_addSavingExceptionMessage($e);
                         }
                     } else {
                         $this->_addValidationMessage();
                     }
                 } else {
                     if (isset($data['cancel'])) {
                         $lru = new Agana_Controller_Action_Helper_LastRequestUri();
                         $lru->setNamespace('edituserprofile');
                         $lru->redirect('user/admin/list');
                         //$this->_helper->redirector(array('action' => 'list', 'controller' => 'admin', 'module' => 'user'));
                     }
                 }
             }
             $this->view->form = $form;
         }
     } else {
         $this->_helper->flashMessenger->addMessage(array('error' => 'Param id missing'));
         $this->_forward('list');
         return;
     }
 }
示例#3
0
 public function edituserdetailAction()
 {
     //calling the form
     $addForm = new User_Form_User();
     $this->view->form = $addForm;
     //listing designation
     $designation = $this->view->adm->viewRecord("ourbank_master_designation", "id", "DESC");
     foreach ($designation as $designation) {
         $addForm->designation->addMultiOption($designation['id'], $designation['name']);
     }
     //;isting institution
     $bankname = $this->view->adm->viewRecord("ourbank_office", "id", "DESC");
     foreach ($bankname as $bankname) {
         $addForm->bank_id->addMultiOption($bankname['id'], $bankname['name']);
     }
     $department = $this->view->adm->viewRecord("ourbank_master_department", "id", "DESC");
     foreach ($department as $department) {
         $addForm->department->addMultiOption($department['id'], $department['name']);
     }
     //listing grants
     $grant = $this->view->adm->viewRecord("ourbank_grant", "id", "DESC");
     foreach ($grant as $grant) {
         $addForm->grant_id->addMultiOption($grant['id'], $grant['name']);
     }
     //listing gender
     $gender = $this->view->adm->viewRecord("ourbank_master_gender", "id", "DESC");
     foreach ($gender as $gender) {
         $addForm->gender->addMultiOption($gender['id'], $gender['name']);
     }
     $this->view->title = "Edit User";
     //Acl
     //         $access = new App_Model_Access();
     //         $checkaccess = $access->accessRights('User',$this->view->globalvalue[0]['name'],'edituserdetail');
     //        	if (($checkaccess != NULL)) {
     //getting the id
     $id = $this->_getParam('id');
     $this->view->id = $id;
     //displaying datas to be edited
     $userdetails = $this->view->adm->editRecord("ourbank_user", $id);
     $addForm->populate($userdetails[0]);
     //submit action
     if ($this->_request->isPost() && $this->_request->getPost('Update')) {
         $id = $this->_getParam('id');
         $formData = $this->_request->getPost();
         if ($addForm->isValid($formData)) {
             //editing record
             $previousdata = $this->view->adm->editRecord("ourbank_user", $id);
             //echo  "<pre>"; print_r($previousdata);
             $this->view->adm->updateLog("ourbank_user_log", $previousdata[0], $id);
             $this->view->adm->updateRecord("ourbank_user", $id, $addForm->getValues());
             $this->_redirect('user');
         }
         // } else {
         //            $this->_redirect('index/index');
     }
 }
示例#4
0
 /**
  * EditAction for Users
  *
  * @return void
  */
 public function editownuserAction()
 {
     $this->view->title = "Edit Users";
     $form = new User_Form_User();
     $form->submit->setLabel('Save');
     $form->removeElement('password');
     $form->removeElement('company_id');
     $id = $_SESSION["gpms"]["storage"]->id;
     $this->gpms = new Zend_Session_Namespace('gpms');
     //TODO pasar el role implementador y administrador sin hardcode
     //si es un usuario sin permiso solo puede editar su usuario y no su role_id
     $form->removeElement('role_id');
     $id = $this->gpms->storage->id;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $model = new User_Model_Users();
             $id = $this->getRequest()->getPost('id');
             $model->update($form->getValues(), 'id = ' . (int) $id);
             $this->_helper->redirector('index', 'company', 'company');
         } else {
             $form->populate($this->getRequest()->getPost());
         }
     } else {
         if ($id > 0) {
             $model = new User_Model_Users();
             $data = $model->fetchEntry($id);
             if ($model->haveContact($id)) {
                 $form->removeElement('add_contact');
             }
             $form->populate($data);
         }
     }
     $this->view->form = $form;
 }