Example #1
0
 public function deleteUserById($userId)
 {
     $userModel = new User_Model_DbTable_User();
     $userModel->deleteUser($userId);
     $profileModel = new User_Model_DbTable_Profile();
     $profileModel->deleteProfile($userId);
     $wepModel = new Model_Wep();
     $wepModel->deleteRow('user_permission', 'user_id', $userId);
     $wepModel->deleteRow('Privilege', 'owner_id', $userId);
 }
Example #2
0
 public function changeusernameAction()
 {
     $user_id = $this->getRequest()->getParam('user_id');
     $auth = Zend_Auth::getInstance()->getIdentity();
     if ($user_id != $auth->user_id) {
         $this->_helper->FlashMessenger->addMessage(array('error' => 'Access denied.'));
         $this->_redirect('/user/user/myaccount');
     }
     $userModel = new User_Model_DbTable_User();
     $user = $userModel->getUserById($user_id);
     $form = new User_Form_User_Changeusername();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formdata = $this->getRequest()->getPost();
         if ($form->isValid($formdata)) {
             try {
                 if ($auth->role == 'admin') {
                     $old_account_identifier = strstr($user->user_name, '_', TRUE);
                     $account_identifier = $this->_getParam('account_identifier');
                     $userModel->changeAdminUsername($old_account_identifier, $account_identifier, $auth->account_id);
                     $auth->user_name = $account_identifier . '_admin';
                 } elseif ($auth->role == 'groupadmin') {
                     $old_group_identifier = strstr($user->user_name, '_', TRUE);
                     $group_identifier = $this->_getParam('group_identifier');
                     $userModel->changeGroupadminUsername($old_group_identifier, $group_identifier, $auth->user_id);
                     $auth->user_name = $group_identifier . '_group';
                 }
                 $this->_helper->FlashMessenger->addMessage(array('message' => 'Username changed successfully. Please use the new username next time you log in.'));
                 $this->_redirect('user/user/myaccount');
             } catch (Exception $e) {
                 print 'Cannot update username. Error Occured.';
             }
             //end of try catch*/
         }
     }
     $this->view->user = $user;
     $this->_helper->layout()->setLayout('layout_wep');
     $this->view->blockManager()->enable('partial/dashboard.phtml');
 }
 private function checkUserExist($value)
 {
     return User_Model_DbTable_User::getInstance()->checkExist($value) ? true : false;
 }
Example #4
0
 public function editGroupAction()
 {
     $groupId = $this->_getParam('group_id');
     if (!isset($groupId)) {
         $this->_helper->FlashMessenger->addMessage(array('error' => "No Group Id Provided."));
         $this->_redirect('/admin/group-organisations');
     }
     $userModel = new User_Model_DbTable_User();
     $profileModel = new User_Model_DbTable_Profile();
     $userGroupModel = new User_Model_DbTable_UserGroup();
     $groupModel = new User_Model_DbTable_Group();
     $row = $userGroupModel->getRowByGroupId($groupId);
     if (!$row) {
         $this->_helper->FlashMessenger->addMessage(array('error' => "Invalid Group Id."));
         $this->_redirect('/admin/group-organisations');
     }
     $userId = $row['user_id'];
     $row1 = $userModel->getUserById($userId);
     $row2 = $profileModel->getProfileByUserId($userId);
     $row1 = $row1->toArray();
     $row2 = $row2->toArray();
     $row3['group_organisations'] = $groupModel->getOrganisationIdByGroupId($groupId);
     $row['group_identifier'] = $row['username'];
     $row['group_name'] = $row['name'];
     $form = new Form_Admin_EditOrganisationGroup(array('user_id' => $userId));
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $data = $this->getRequest()->getPost();
         if ($form->isValid($data)) {
             $user['user_name'] = $data['group_identifier'] . '_group';
             $user['email'] = $data['email'];
             $value = $userModel->updateUser($user, $userId);
             $information['first_name'] = $data['first_name'];
             $information['middle_name'] = $data['middle_name'];
             $information['last_name'] = $data['last_name'];
             $profileModel->updateProfile($information, $userId);
             $group['name'] = $data['group_name'];
             $group['username'] = $data['group_identifier'];
             $userGroupModel->updateUserGroup($group, $groupId);
             $accountIds = $data['group_organisations'];
             $groupModel->deleteGroup($groupId);
             foreach ($accountIds as $accountId) {
                 $groupModel->insertGroupWithAccountId($accountId, $groupId);
             }
             $this->_helper->FlashMessenger->addMessage(array('message' => "Organisation Group successfully updated."));
             $this->_redirect('/admin/group-organisations');
         } else {
             $form->populate($data);
         }
     } else {
         $form->populate($row);
         $form->populate($row1);
         $form->populate($row2);
         $form->populate($row3);
     }
 }