예제 #1
0
 /**
  * @name loginAction
  *
  * This method is used to display the login data errors
  *
  * @author Mainak
  * @version 1.0
  *
  * values used in this method
  * ==========================
  * @param username => Email given in Login Form
  * @param password => Password given in Login Form
  */
 public function loginpopupsaveAction()
 {
     $emailParam = $this->getRequest()->getParam('username');
     $opt = array('custom' => array('timeout' => $this->_options['auth']['timeout']));
     $options = array();
     $options['username'] = $this->getRequest()->getParam('username');
     $options['user_password'] = $this->getRequest()->getParam('password');
     $usersModel = new Default_Model_Users();
     $userData = $usersModel->isActiveUser($options['username']);
     $check = 0;
     foreach ($userData as $user) {
         $check = $user['count'] == 1 ? 1 : 0;
     }
     if (!$check) {
         $userStatusArr = $usersModel->getActiveStatus($options['username']);
         if (!empty($userStatusArr)) {
             $userStatus = $userStatusArr[0]['status'];
             $islockaccount = $userStatusArr[0]['isaccountlock'];
             if ($userStatus == 0) {
                 $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Employee has been inactivated from the organization.");
             } else {
                 if ($userStatus == 2) {
                     $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Employee has resigned from the organization.");
                 } else {
                     if ($userStatus == 3) {
                         $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Employee has left the organization.");
                     } else {
                         if ($userStatus == 4) {
                             $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Employee has been suspended from the organization.");
                         } else {
                             if ($userStatus == 5) {
                                 $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Employee deleted.");
                             } else {
                                 if ($islockaccount == 1) {
                                     $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Employee has been locked.");
                                 } else {
                                     $this->_helper->getHelper("FlashMessenger")->addMessage("Login failed. Not a valid employee.");
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage("The username or password you entered is incorrect.");
         }
         $this->_redirect('index');
     }
     /**
      * 	Start - To check if employee date of joining is greater than current date.
      */
     $userDateOfJoining = $usersModel->getUserDateOfJoining($options['username']);
     if (!empty($userDateOfJoining)) {
         if (!$userDateOfJoining[0]['doj']) {
             $this->_helper->getHelper("FlashMessenger")->addMessage("You will be able to login on or after " . sapp_Global::change_date($userDateOfJoining[0]['date_of_joining'], 'view'));
             $this->_redirect('index');
         }
     }
     /**
      * End
      */
     $auth = Zend_Auth::getInstance();
     try {
         $db = $this->getInvokeArg('bootstrap')->getResource('db');
         $user = new Default_Model_Users($db);
         if ($user->isLdapUser(sapp_Global::escapeString($options['username']))) {
             $options['ldap'] = $this->_options['ldap'];
             $authAdapter = Login_Auth::_getAdapter('ldap', $options);
         } else {
             $options['db'] = $db;
             $options['salt'] = $this->_options['auth']['salt'];
             if ($isemail = filter_var($options['username'], FILTER_VALIDATE_EMAIL)) {
                 $authAdapter = Login_Auth::_getAdapter('email', $options);
             } else {
                 $authAdapter = Login_Auth::_getAdapter('db', $options);
             }
         }
         $result = $auth->authenticate($authAdapter);
         if ($result->isValid()) {
             $admin_data = $user->getUserObject($options['username']);
             $auth->getStorage()->write($admin_data);
             $storage = $auth->getStorage()->read();
             /***
             				Start - Session for time management role.
             			**/
             $tmRole = $usersModel->getUserTimemanagementRole($storage->id);
             $timeManagementRole = new Zend_Session_Namespace('tm_role');
             if (empty($timeManagementRole->tmrole)) {
                 $timeManagementRole->tmrole = $tmRole;
             }
             /***
             				End - Session for time management role.
             			**/
             $dataTmp = array();
             $dataTmp['userid'] = $storage->id ? $storage->id : 0;
             $dataTmp['emprole'] = $storage->emprole ? $storage->emprole : 0;
             $dataTmp['group_id'] = $storage->group_id ? $storage->group_id : 0;
             $dataTmp['employeeId'] = $storage->employeeId ? $storage->employeeId : 0;
             $dataTmp['emailaddress'] = $storage->emailaddress ? $storage->emailaddress : '';
             $dataTmp['userfullname'] = $storage->userfullname ? $storage->userfullname : '';
             $dataTmp['logindatetime'] = gmdate("Y-m-d H:i:s");
             if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && $_SERVER['HTTP_X_FORWARDED_FOR'] != '') {
                 $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR'];
             } else {
                 $ip_address = $_SERVER['REMOTE_ADDR'];
             }
             if ($ip_address == '::1') {
                 $ip_address = '127.0.0.1';
             }
             $dataTmp['empipaddress'] = $ip_address;
             $dataTmp['profileimg'] = $storage->profileimg ? $storage->profileimg : '';
             $lastRecordId = $usersModel->addUserLoginLogManager($dataTmp);
             $orgImg = $usersModel->getOrganizationImg();
             $organizationImg = new Zend_Session_Namespace('organizationinfo');
             if (empty($organizationImg->orgimg)) {
                 $organizationImg->orgimg = $orgImg;
             }
             if (!isset($organizationImg->hideshowmainmenu)) {
                 $organizationImg->hideshowmainmenu = 1;
             }
             /*** Redirect to wizard if not complete - start ***/
             if ($storage->emprole == SUPERADMINROLE) {
                 $wizard_model = new Default_Model_Wizard();
                 $wizardData = $wizard_model->getWizardData();
                 if (!empty($wizardData)) {
                     if ($wizardData['iscomplete'] == 1) {
                         $this->_redirect('wizard');
                     }
                 }
             }
             /*** Redirect to wizard if not complete - end ***/
             /*** Redirect to wizard if not complete - start ***/
             if ($storage->group_id == HR_GROUP) {
                 $hrWizardModel = new Default_Model_Hrwizard();
                 $hrwizardData = $hrWizardModel->getHrwizardData();
                 if (!empty($hrwizardData)) {
                     if ($hrwizardData['iscomplete'] == 1) {
                         $this->_redirect('hrwizard');
                     }
                 }
             }
             /*** Redirect to wizard if not complete - end ***/
             /*** Previous URL redirection after login - start ***/
             $prevUrl = new Zend_Session_Namespace('prevUrl');
             if (isset($prevUrl->prevUrlObject) && $prevUrl->prevUrlObject[0] != '/index/logout') {
                 header('Location:' . $prevUrl->prevUrlObject[0]);
                 Zend_Session::namespaceUnset('prevUrl');
                 exit;
                 /*** Previous URL redirection after login - end ***/
             } else {
                 $this->_redirect('/index/welcome');
             }
         } else {
             $this->_helper->getHelper("FlashMessenger")->addMessage("The username or password you entered is incorrect.");
             $this->_redirect('index');
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
예제 #2
0
 public function updatewizardcompletionAction()
 {
     $this->_helper->layout->disableLayout();
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $result['result'] = '';
     $hrWizardModel = new Default_Model_Hrwizard();
     $db = Zend_Db_Table::getDefaultAdapter();
     $db->beginTransaction();
     try {
         $Completion_data = array('iscomplete' => 0, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"));
         $CompleteId = $hrWizardModel->SaveorUpdateHrWizardData($Completion_data, '');
         $db->commit();
         $result['result'] = 'success';
     } catch (Exception $e) {
         $db->rollBack();
         $result['result'] = 'fail';
     }
     $this->_helper->json($result);
 }