/** * @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'); } $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(); $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 ***/ /*** 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(); } }
public function configureorganisationAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $popConfigPermission = array(); $new_stateId = ''; if (sapp_Global::_checkprivileges(COUNTRIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'country'); } if (sapp_Global::_checkprivileges(STATES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'state'); } if (sapp_Global::_checkprivileges(CITIES, $loginuserGroup, $loginuserRole, 'add') == 'Yes') { array_push($popConfigPermission, 'city'); } $msgarray = array(); $new_stateId = ''; $new_cityId = ''; $id = $this->getRequest()->getParam('id'); $form = new Default_Form_Organisationinfo(); $orgInfoModel = new Default_Model_Organisationinfo(); $countriesModel = new Default_Model_Countries(); $statesmodel = new Default_Model_States(); $citiesmodel = new Default_Model_Cities(); $wizard_model = new Default_Model_Wizard(); $wizardData = $wizard_model->getWizardData(); $orginfodata = $orgInfoModel->getOrganisationInfo(); $allCountriesData = $countriesModel->fetchAll('isactive=1', 'country')->toArray(); $allStatesData = $statesmodel->fetchAll('isactive=1', 'state')->toArray(); $allCitiesData = $citiesmodel->fetchAll('isactive=1', 'city')->toArray(); $form->setAttrib('action', DOMAIN . 'wizard/configureorganisation'); $flag = 'true'; if (empty($allCountriesData)) { $msgarray['country'] = 'Countries are not configured yet.'; $flag = 'false'; } if (empty($allStatesData)) { $msgarray['state'] = 'States are not configured yet.'; $flag = 'false'; } if (empty($allCitiesData)) { $msgarray['city'] = 'Cities are not configured yet.'; $flag = 'false'; } if (!empty($orginfodata)) { try { $data = $orginfodata[0]; $data['org_startdate'] = sapp_Global::change_date($data['org_startdate'], 'view'); $form->populate($data); $countryId = $data['country']; $stateId = $data['state']; $cityId = $data['city']; $actionpage = 'edit'; if (count($_POST) > 0) { $countryId = isset($_POST['country']) ? $_POST['country'] : ""; $stateId = isset($_POST['state']) ? $_POST['state'] : ""; $cityId = isset($_POST['city']) ? $_POST['city'] : ""; } if ($countryId != '') { $statesData = $statesmodel->getBasicStatesList((int) $countryId); foreach ($statesData as $res) { if ($stateId == $res['state_id_org']) { $new_stateId = $res['state_id_org'] . '!@#' . utf8_encode($res['state']); } $form->state->addMultiOption($res['state_id_org'] . '!@#' . utf8_encode($res['state']), utf8_encode($res['state'])); } if (count($_POST) == 0) { $stateId = $new_stateId; } } if ($stateId != '') { $citiesData = $citiesmodel->getBasicCitiesList((int) $stateId); foreach ($citiesData as $res) { if ($cityId == $res['city_org_id']) { $new_cityId = $res['city_org_id'] . '!@#' . utf8_encode($res['city']); } $form->city->addMultiOption($res['city_org_id'] . '!@#' . utf8_encode($res['city']), utf8_encode($res['city'])); } if (count($_POST) == 0) { $cityId = $new_cityId; } } $form->setDefault('country', $countryId); $form->setDefault('state', $stateId); $form->setDefault('city', $cityId); $this->view->domainValue = $data['domain']; $this->view->org_image = $data['org_image']; $this->view->ermsg = ''; $this->view->datarr = $data; } catch (Exception $e) { $this->view->ermsg = 'nodata'; } } else { sapp_Global::buildlocations($form, $wizardData); } $this->view->form = $form; if (!empty($allCountriesData) && !empty($allStatesData) && !empty($allCitiesData)) { $this->view->configuremsg = ''; } else { $this->view->configuremsg = 'notconfigurable'; } $this->view->wizarddata = $wizardData; $this->view->msgarray = $msgarray; $this->view->popConfigPermission = $popConfigPermission; $this->view->messages = $this->_helper->flashMessenger->getMessages(); if ($this->getRequest()->getPost()) { $result = $this->saveorginfo($form, $loginUserId, $wizardData); $this->view->msgarray = $result; if (isset($this->msgarray['domain'])) { $this->view->msMsg = 'multiselecterror'; } } }
public function saverequesttypes() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $servicedeskrequestmodel = new Default_Model_Servicedeskrequest(); $msgarray = array(); $errorflag = 'true'; $service_desk_id = $this->_request->getParam('category_id'); $requesttype_arr = $this->_request->getParam('requesttype'); $description_arr = $this->_request->getParam('description'); if (!empty($requesttype_arr)) { $requestArr = array_count_values($requesttype_arr); for ($i = 0; $i < sizeof($requesttype_arr); $i++) { if ($requesttype_arr[$i] == '') { $msgarray['request_name'][$i] = 'Please enter request type.'; $errorflag = 'false'; } else { if (!preg_match('/^[a-zA-Z0-9.\\- ?]+$/', $requesttype_arr[$i])) { $msgarray['request_name'][$i] = 'Please enter valid request type.'; $errorflag = 'false'; } else { if ($i > 0 && $requestArr[$requesttype_arr[$i]] > 1) { $msgarray['request_name'][$i] = 'Please enter different request type.'; $errorflag = 'false'; } else { if ($service_desk_id) { $isduplicaterequest = $servicedeskrequestmodel->checkduplicaterequestname($service_desk_id, $requesttype_arr[$i]); if (!empty($isduplicaterequest)) { if ($isduplicaterequest[0]['count'] > 0) { $msgarray['request_name'][$i] = 'request type already exist.'; $errorflag = 'false'; } } } } } } } $msgarray['categorysize'] = sizeof($requesttype_arr); } if ($errorflag == 'true') { try { $menumodel = new Default_Model_Menu(); $actionflag = 1; $tableid = ''; $where = ''; $date = new Zend_Date(); for ($i = 0; $i < sizeof($requesttype_arr); $i++) { $data = array('service_desk_id' => $service_desk_id, 'service_request_name' => $requesttype_arr[$i], 'description' => $description_arr[$i] != '' ? $description_arr[$i] : NULL, 'createdby' => $loginUserId, 'createddate' => gmdate("Y-m-d H:i:s"), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s"), 'isactive' => 1); $Id = $servicedeskrequestmodel->SaveorUpdateServiceDeskRequestData($data, $where); $tableid = $Id; $menuID = SERVICEDESKREQUEST; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); } $wizard_model = new Default_Model_Wizard(); $wizardData = $wizard_model->getWizardData(); $wizardarray = array('servicerequest' => 2, 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($wizardData['site_config'] == 2 && $wizardData['org_details'] == 2 && $wizardData['departments'] == 2) { $wizardarray['iscomplete'] = 2; } $wizard_model->SaveorUpdateWizardData($wizardarray, ''); $this->_helper->getHelper("FlashMessenger")->addMessage("Categories added successfully."); $this->_redirect('wizard/configureservicerequest'); } catch (Exception $e) { $msgarray['category_id'] = "Something went wrong, please try again."; return $msgarray; } } else { return $msgarray; } }