Example #1
0
 public function sendRequestNotification($requestId)
 {
     $request = new Application_Model_Request();
     $request = $request->find($requestId);
     if (false === $request) {
         return false;
     }
     $departmentId = $request->getDepartmentId();
     $dept = new Application_Model_Department();
     $dept = $dept->find($departmentId);
     if ($dept === false) {
         return false;
     }
     $user = new Security_Model_User();
     $users = $user->fetchAll("department_id='{$departmentId}' and status='active' and id ='{$dept->getDepartmentHeadId()}'");
     if (count($users) == 0) {
         return false;
     }
     $emails = array();
     foreach ($users as $_user) {
         $emails[$_user->getFirstName() . " " . $_user->getLastName()] = $_user->getEmail();
     }
     if (count($emails) == 0) {
         return false;
     }
     $user = new Security_Model_User();
     $requestedBy = $user->find($request->getRequestedBy());
     $from_email = $this->settingValue('admin_email');
     $from_name = $this->settingLable('admin_email');
     /*---Template-----*/
     $template = $this->getEmailTemplate('request_notification_email');
     $htmlBody = $template['body'];
     $htmlBody = str_replace("__REQUESTER_NAME__", $requestedBy->getFirstName() . " " . $requestedBy->getLastName(), $htmlBody);
     $htmlBody = str_replace("__REQUESTER_EMAIL__", $requestedBy->getEmail(), $htmlBody);
     $htmlBody = str_replace("__REQUESTER_EMP_CODE__", $requestedBy->getEmployeeCode(), $htmlBody);
     $htmlBody = str_replace("__REQUEST__", $request->getRequest(), $htmlBody);
     /*---------------------*/
     $subject = $template['subject'];
     $this->setBodyHtml($htmlBody);
     $this->setFrom($from_email, $from_name);
     $this->addTo($emails);
     $this->setSubject($subject);
     $this->send();
 }
Example #2
0
 public function changePasswordAction()
 {
     $usersNs = new Zend_Session_Namespace("members");
     $user = new Security_Model_User();
     $model = $user->find($usersNs->userId);
     $request = $this->getRequest();
     $form = new Application_Form_ChangePassword();
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('Errors');
     }
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             $model->setPassword(md5($options['password']));
             $model->save();
             $this->_flashMessenger->addMessage(array('success' => 'Your password has been changed successfully!'));
             $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/admin/dashboard'));
         } else {
             $this->view->password_msg = array_pop($form->getMessages('password'));
             $this->view->cpassword_msg = array_pop($form->getMessages('confirmPassword'));
             $form->reset();
             $form->populate($options);
         }
     }
     // Assign the form to the view
     $this->view->form = $form;
 }
 public function changePasswordAction()
 {
     $request = $this->getRequest();
     $form = new Security_Form_User();
     $userM = new Security_Model_User();
     $arrUser = $userM->getAllUsers();
     $form->addElement('select', 'userId', array('label' => 'Username:'******'required' => true, 'validators' => array(array('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select username.')))), 'decorators' => array('ViewHelper', array('Errors', array('class' => 'input-notification-ul-li error png_bg')), array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array('Label', array('tag' => 'td')), array(array('row' => 'HtmlTag'), array('tag' => 'tr'))), 'filters' => array('StringTrim'), 'MultiOptions' => $arrUser));
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         //$element->removeDecorator('Errors');
         if ($element->getName() != "password" && $element->getName() != "confirmPassword" && $element->getName() != "userId" && $element->getName() != "submit") {
             $form->removeElement($element->getName());
         }
     }
     if ($request->isPost()) {
         $options = $request->getPost();
         if ($form->isValid($options)) {
             //        $usersNs = new Zend_Session_Namespace("members");
             $user = new Security_Model_User();
             $model = $user->find($options['userId']);
             $model->setPassword(md5($options['password']));
             $model->save();
             $this->_flashMessenger->addMessage(array('success' => 'Password has been changed successfully!'));
             $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/security/user/change-password'));
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     // Assign the form to the view
     $this->view->form = $form;
 }