Exemple #1
0
 /**
  * Send notification for forgot password.
  */
 public function sendResetNotifications($user, $resetUrl)
 {
     $email = $user->email;
     $profileModel = new User_Model_DbTable_Profile();
     $profile = $profileModel->getProfileByUserId($user->user_id);
     $name = $profile->first_name;
     if ($profile->middle_name) {
         $name .= " " . $profile->middle_name;
     }
     $name .= " " . $profile->last_name;
     $mailParams['subject'] = 'Password reset for ' . $email;
     $mailParams['name'] = $name;
     $mailParams['username'] = $user->user_name;
     $mailParams['reset_url'] = $resetUrl;
     $template = 'forgot_password.phtml';
     $this->sendemail($mailParams, $template, array($email => ''));
 }
Exemple #2
0
 public function editAction()
 {
     $user_id = $this->getRequest()->getParam('user_id');
     $auth = Zend_Auth::getInstance()->getIdentity();
     $roleName = $auth->role;
     $uploadDir = Zend_Registry::get('config')->upload_dir . "/image/";
     //$uploadDir = APPLICATION_PATH.'/../public/uploads/image/';
     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();
     $row = $userModel->getUserById($user_id);
     $profileModel = new User_Model_DbTable_Profile();
     $row1 = $profileModel->getProfileByUserId($user_id);
     $accountObj = new User_Model_DbTable_Account();
     //$userName = strtok($row['user_name'], '_');
     $names = explode('_', $row['user_name']);
     $last = array_pop($names);
     $userName = implode('_', $names);
     $account = $accountObj->getAccountRowByUserName('account', 'username', $userName);
     $form = new User_Form_User_Edit();
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $data['name'] = $form->getValue('name');
             $data['address'] = $form->getValue('address');
             $data['telephone'] = $form->getValue('telephone');
             $data['twitter'] = !$form->getValue('twitter') ? $form->getValue('twitter') : '@' . preg_replace("/@/", "", $form->getValue('twitter'), 1);
             $data['first_name'] = $form->getValue('first_name');
             $data['middle_name'] = $form->getValue('middle_name');
             $data['last_name'] = $form->getValue('last_name');
             $data['email'] = $form->getValue('email');
             $data['url'] = $form->getValue('url');
             $data['disqus_comments'] = $form->getValue('disqus_comments');
             $accountObj->updateAccount($data, $userName);
             $value = $userModel->updateUser($data, $user_id);
             $profileModel->updateProfile($data, $user_id);
             if ($roleName != 'user') {
                 $upload = new Zend_File_Transfer_Adapter_Http();
                 $upload->setDestination($uploadDir);
                 $upload->addFilter(new App_Filter_File_Resize(array('width' => 150, 'height' => 100, 'keepRatio' => true)));
                 $source = $upload->getFileName();
                 if (is_string($source)) {
                     $data['file_name'] = basename($source);
                 }
                 try {
                     $upload->receive();
                     $accountObj->insertFileNameOrUpdate($data, $userName);
                 } catch (Zend_File_Transfer_Exception $e) {
                     $e->getMessage();
                 }
             }
             $this->_helper->FlashMessenger->addMessage(array('message' => 'Profile saved successfully.'));
             $this->_redirect('user/user/myaccount/user_id/' . $row->user_id);
         } else {
             $form->populate($formData);
         }
     } else {
         $form->populate($row->toArray());
         $form->populate($row1->toArray());
         if ($roleName != 'superadmin' && $roleName != 'groupadmin') {
             $form->populate($account->toArray());
         }
     }
     $this->view->form = $form;
     $identity = Zend_Auth::getInstance()->getIdentity();
     $this->_helper->layout()->setLayout('layout_wep');
     if ($identity->role == 'user') {
         $model = new Model_Wep();
         $userPermission = $model->getUserPermission($identity->user_id);
         $permission = $userPermission->hasPermission(Iati_WEP_PermissionConts::VIEW_ACTIVITIES);
         if ($permission == '0') {
             $this->view->blockManager()->disable('partial/primarymenu.phtml');
         }
         $permission = $userPermission->hasPermission(Iati_WEP_PermissionConts::ADD_ACTIVITY);
         if ($permission == '0') {
             $this->view->blockManager()->disable('partial/add-activity-menu.phtml');
         }
     }
     $this->view->blockManager()->enable('partial/dashboard.phtml');
     if ($identity->role == 'user' || $identity->role == 'admin') {
         $this->view->blockManager()->enable('partial/primarymenu.phtml');
         $this->view->blockManager()->enable('partial/add-activity-menu.phtml');
         $this->view->blockManager()->enable('partial/published-list.phtml');
         $this->view->blockManager()->enable('partial/organisation-data.phtml');
         $this->view->blockManager()->enable('partial/download-my-data.phtml');
         $this->view->blockManager()->enable('partial/usermgmtmenu.phtml');
         $this->view->blockManager()->enable('partial/uploaded-docs.phtml');
         // for role user check if the user has permission to add, publish ,if not disable menu.
         if ($identity->role == 'user') {
             $model = new Model_Wep();
             $userPermission = $model->getUserPermission($identity->user_id);
             $permission = $userPermission->hasPermission(Iati_WEP_PermissionConts::ADD_ACTIVITY);
             $publishPermission = $userPermission->hasPermission(Iati_WEP_PermissionConts::PUBLISH);
             if (!$permission) {
                 $this->view->blockManager()->disable('partial/add-activity-menu.phtml');
             }
             if (!$publishPermission) {
                 $this->view->blockManager()->disable('partial/published-list.phtml');
             }
         }
     } elseif ($identity->role == 'groupadmin') {
         $this->view->blockManager()->enable('partial/groupadmin-menu.phtml');
     } else {
         $this->view->blockManager()->enable('partial/superadmin-menu.phtml');
     }
 }
Exemple #3
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);
     }
 }