BUG 8875 "Feature: New ExtJS based Login & Main ProcessMaker inter..." 3rd

- fixed compatibilities to user default redirection after login
-  user experience simplified compatibilities with uxmodern interface
This commit is contained in:
Erik Amaru Ortiz
2012-04-05 12:52:33 -04:00
parent 7dac53be11
commit 561832bb06
15 changed files with 336 additions and 518 deletions

View File

@@ -26,7 +26,6 @@ class Admin extends Controller
foreach ($skinsList['skins'] as $skin) {
$skins[] = array($skin['SKIN_FOLDER_ID'], $skin['SKIN_NAME']);
}
$skins[] = array('uxmodern', 'uxmodern');
foreach ($timeZonesList as $tz) {
$timeZones[] = array($tz, $tz);

View File

@@ -91,9 +91,16 @@ class adminProxy extends HttpProxyController
}
G::update_php_ini($envFile, $updatedConf);
if (substr($sysConf['default_skin'], 0, 2) == 'ux') {
$urlPart = '/main/login';
}
else {
$urlPart = '/login/login';
}
$this->success = true;
$this->restart = $restart;
$this->url = '/sys' . SYS_SYS . '/' . $sysConf['default_lang'] . '/' . $sysConf['default_skin'] . $urlPart;
$this->message = 'Saved Successfully';
}

View File

@@ -76,19 +76,29 @@ class Home extends Controller
return;
}
require_once 'classes/model/UsersProperties.php';
G::LoadClass('process');
G::LoadClass('case');
$userProperty = new UsersProperties();
$process = new Process();
$case = new Cases();
G::loadClass('system');
$sysConf = System::getSystemConfiguration(PATH_CONFIG . 'env.ini');
//Get ProcessStatistics Info
$start = 0;
$limit = '';
$proData = $process->getAllProcesses($start, $limit);
$processList = $case->getStartCasesPerType ( $_SESSION ['USER_LOGGED'], 'category');
$switchLink = '../classic/cases/main'; //'../' . $this->lastSkin . '/cases/main';
$processList = $case->getStartCasesPerType($_SESSION['USER_LOGGED'], 'category');
$switchLink = $userProperty->getUserLocation($_SESSION['USER_LOGGED']);
if (substr($sysConf['default_skin'], 0, 2) == 'ux') {
$_SESSION['_defaultUserLocation'] = $switchLink;
$switchLink = '/sys' . SYS_SYS . '/' . SYS_LANG . '/' . $sysConf['default_skin'] . '/main';
}
unset($processList[0]);

View File

@@ -27,6 +27,8 @@ class Main extends Controller
global $RBAC;
$RBAC->requirePermissions('PM_LOGIN');
$meta = new stdClass;
$showSystemInfo = $RBAC->userCanAccess('PM_SETUP') == 1;
// setting variables for template
$this->setVar('logo_company', $this->getCompanyLogo());
@@ -41,24 +43,33 @@ class Main extends Controller
// setting variables on javascript env.
$this->setJSVar('meta', array('menu'=>$this->getMenu()));
$this->setJSVar('activeTab', $this->getActiveTab());
$activeTab = 0;
if (isset($_SESSION['_defaultUserLocation'])) {
$activeTab = $this->resolveUrlToTabIndex($_SESSION['_defaultUserLocation']);
}
else if (isset($_GET['st'])) {
$activeTab = $this->getActiveTab($_GET['st']);
unset($_GET['st']);
}
$this->setJSVar('activeTab', $activeTab);
$this->setJSVar('urlAddGetParams', $this->getUrlGetParams());
$showSystemInfo = $RBAC->userCanAccess('PM_SETUP') == 1;
$this->setJSVar('showSystemInfo', $showSystemInfo);
$switchInterface = isset($_SESSION['user_experience']) && $_SESSION['user_experience'] == 'SWITCHABLE';
if (($flyNotify = $this->getFlyNotify()) !== false) {
$this->setJSVar('flyNotify', $flyNotify);
}
$this->setJSVar('switchInterface', $switchInterface);
$this->includeExtJSLib('ux/ux.menu');
$this->includeExtJS('main/index');
//$this->setView('main/index');
$this->setLayout('pm-modern');
$this->afterLoad($httpData);
$this->render();
}
@@ -337,304 +348,6 @@ class Main extends Controller
$this->render();
}
public function sysLoginVerify()
{
$this->setResponseType('json');
try {
if (!defined('SYS_SYS')) {
if (!isset($_POST)) {
throw new Exception('Bad Request!', ERROR_EXCEPTION);
}
if (!isset($_POST['workspace'])) {
throw new Exception('No workspace specified!', ERROR_EXCEPTION);
}
session_start();
$_SESSION['sysLogin'] = $_POST;
$url = '/sys' . $_POST['workspace'] . '/' . SYS_LANG . '/' . SYS_SKIN . '/main/sysLoginVerify';
$result->success = true;
$result->url = $url;
$result->message = G::LoadTranslation('LOGIN_VERIFY_MSG');
} else {
$_POST = $_SESSION['sysLogin'];
$result = $this->authentication();
if ($result->success) {
G::header ( 'location: ' . $result->url);
} else {
G::SendTemporalMessage($result->message, "error", 'string');
G::header('location: /sys' . $_POST['workspace'] . '/' . SYS_LANG . '/' . SYS_SKIN . '/main/login');
}
}
} catch ( Exception $e ) {
$result->success = false;
$result->message = $e->getMessage();
$result->errorCode = $e->getCode();
}
return $result;
}
public function authentication()
{
global $RBAC;
$this->setResponseType('json');
try {
if (!$RBAC->singleSignOn) {
if (!isset($_POST['user']) ) {
throw new Exception(G::LoadTranslation('ID_USER_HAVENT_RIGHTS_SYSTEM'));
}
$frm = $_POST;
$usr = '';
$pwd = '';
$lang = '';
if (isset($frm['user'])) {
$usr = strtolower(trim($frm['user']));
$pwd = $currentPwd = trim($frm['password']);
$lang = trim($frm['lang']) != '' ? $frm['lang'] : SYS_LANG;
}
$uid = $RBAC->VerifyLogin($usr , $pwd);
switch ($uid) {
//The user doesn't exist
case -1:
throw new Exception(G::LoadTranslation('ID_USER_NOT_REGISTERED'));
break;
//The password is incorrect
case -2:
throw new Exception(G::LoadTranslation('ID_WRONG_PASS'));
if(isset($_SESSION['__AUTH_ERROR__'])){
G::SendMessageText($_SESSION['__AUTH_ERROR__'], "warning");
unset($_SESSION['__AUTH_ERROR__']);
}
break;
//The user is inactive
case -3:
require_once 'classes/model/Users.php';
$user = new Users;
$aUser = $user->loadByUsernameInArray($usr);
switch($aUser['USR_STATUS']){
case 'VACATION':
throw new Exception(G::LoadTranslation('ID_USER_ONVACATION', WARNING_EXCEPTION));
break;
case 'INACTIVE':
throw new Exception(G::LoadTranslation('ID_USER_INACTIVE', WARNING_EXCEPTION));
break;
}
break;
//The Due date is finished
case -4:
throw new Exception(G::LoadTranslation('ID_USER_INACTIVE_BY_DATE', WARNING_EXCEPTION));
break;
case -5:
throw new Exception(G::LoadTranslation('ID_AUTHENTICATION_SOURCE_INVALID', WARNING_EXCEPTION));
break;
}
//to avoid empty string in user field. This will avoid a weird message "this row doesn't exist"
if ( !isset($uid) ) {
$uid = -1;
throw new Exception(G::LoadTranslation('ID_USER_NOT_REGISTERED', WARNING_EXCEPTION));
}
if ( !isset($uid) || $uid < 0 ) {
if(isset($_SESSION['FAILED_LOGINS']))
$_SESSION['FAILED_LOGINS']++;
if (!defined('PPP_FAILED_LOGINS')) {
define('PPP_FAILED_LOGINS', 0);
}
if (PPP_FAILED_LOGINS > 0) {
if ($_SESSION['FAILED_LOGINS'] >= PPP_FAILED_LOGINS) {
$oConnection = Propel::getConnection('rbac');
$oStatement = $oConnection->prepareStatement("SELECT USR_UID FROM USERS WHERE USR_USERNAME = '" . $usr . "'");
$oDataset = $oStatement->executeQuery();
if ($oDataset->next()) {
$sUserUID = $oDataset->getString('USR_UID');
$oConnection = Propel::getConnection('rbac');
$oStatement = $oConnection->prepareStatement("UPDATE USERS SET USR_STATUS = 0 WHERE USR_UID = '" . $sUserUID . "'");
$oStatement->executeQuery();
$oConnection = Propel::getConnection('workflow');
$oStatement = $oConnection->prepareStatement("UPDATE USERS SET USR_STATUS = 'INACTIVE' WHERE USR_UID = '" . $sUserUID . "'");
$oStatement->executeQuery();
unset($_SESSION['FAILED_LOGINS']);
G::SendMessageText(G::LoadTranslation('ID_ACCOUNT') . ' "' . $usr . '" ' . G::LoadTranslation('ID_ACCOUNT_DISABLED_CONTACT_ADMIN'), 'warning');
}
else {
//Nothing
}
}
}
//TODO complete this redirection
G::header ("location: login.html");
die;
}
//Execute the SSO Script from plugin
$oPluginRegistry =& PMPluginRegistry::getSingleton();
if ( $oPluginRegistry->existsTrigger ( PM_LOGIN ) ) {
$lSession="";
$loginInfo = new loginInfo ($usr, $pwd, $lSession );
$oPluginRegistry->executeTriggers ( PM_LOGIN , $loginInfo );
}
$_SESSION['USER_LOGGED'] = $uid;
$_SESSION['USR_USERNAME'] = $usr;
}
else {
$uid = $RBAC->userObj->fields['USR_UID'];
$usr = $RBAC->userObj->fields['USR_USERNAME'];
$_SESSION['USER_LOGGED'] = $uid;
$_SESSION['USR_USERNAME'] = $usr;
}
if (!isset($_SESSION['WORKSPACE'])) {
$_SESSION['WORKSPACE'] = SYS_SYS;
}
// Assign the uid of user to userloggedobj
$RBAC->loadUserRolePermission($RBAC->sSystem, $uid);
$res = $RBAC->userCanAccess('PM_LOGIN');
if ($res != 1 ) {
if ($res == -2)
throw new Exception(G::LoadTranslation('ID_USER_HAVENT_RIGHTS_SYSTEM', ERROR_EXCEPTION));
else
throw new Exception(G::LoadTranslation('ID_USER_HAVENT_RIGHTS_PAGE', ERROR_EXCEPTION));
die;
}
//using optimization with memcache, the user data will be in memcache 8 hours
$memKey = 'rbacSession' . session_id();
$this->memcache->set( $memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS );
$_SESSION['USR_FULLNAME'] = $RBAC->aUserInfo['USER_INFO']['USR_FIRSTNAME'] . ' ' . $RBAC->aUserInfo['USER_INFO']['USR_LASTNAME'];
unset($_SESSION['FAILED_LOGINS']);
//get the default language, language posted in form has preference
if ( isset($frm['USER_LANG']) && $frm['USER_LANG'] != '' ) {
$lang = $frm['USER_LANG'];
}
else {
$lang = (defined('SYS_LANG')) ? SYS_LANG : 'en';
}
/**log in table Login**/
require_once 'classes/model/LoginLog.php';
$weblog=new LoginLog();
$aLog['LOG_UID'] = G::generateUniqueID();
$aLog['LOG_STATUS'] = 'ACTIVE';
$aLog['LOG_IP'] = $_SERVER['REMOTE_ADDR'];
$aLog['LOG_SID'] = session_id();
$aLog['LOG_INIT_DATE'] = date('Y-m-d H:i:s');
$aLog['LOG_CLIENT_HOSTNAME'] = $_SERVER['HTTP_HOST'];
$aLog['USR_UID'] = $_SESSION['USER_LOGGED'];
$aLog['LOG_TYPE'] = (isset($RBAC->aUserInfo['USER_INFO']['USR_AUTH_TYPE']) ? ($RBAC->aUserInfo['USER_INFO']['USR_AUTH_TYPE'] != 'MYSQL' ? $RBAC->aUserInfo['USER_INFO']['USR_AUTH_TYPE'] : 'processmaker') : 'processmaker');
$aLog['LOG_SSO'] = (int) $RBAC->singleSignOn;
$weblog->create($aLog);
/**end log**/
// increment logins in heartbeat
G::LoadClass('serverConfiguration');
$oServerConf =& serverConf::getSingleton();
$oServerConf->sucessfulLogin();
// disabling this slow process, until revisit this issue
// //************** background processes, here we are putting some back office routines **********
// $oServerConf->setWsInfo(SYS_SYS,$oServerConf->getWorkspaceInfo(SYS_SYS) );
//
//
// //**** defining and saving server info, this file has the values of the global array $_SERVER ****
// //this file is useful for command line environment (no Browser), I mean for triggers, crons and other executed over command line
// $_CSERVER = $_SERVER;
// unset($_CSERVER['REQUEST_TIME']);
// unset($_CSERVER['REMOTE_PORT']);
// $cput = serialize($_CSERVER);
// if( !is_file(PATH_DATA_SITE . PATH_SEP . '.server_info') ){
// file_put_contents(PATH_DATA_SITE . PATH_SEP . '.server_info', $cput);
// }
// else {
// $c = file_get_contents(PATH_DATA_SITE . PATH_SEP . '.server_info');
// if(md5($c) != md5($cput)){
// file_put_contents(PATH_DATA_SITE . PATH_SEP . '.server_info', $cput);
// }
// }
//
/* Check password using policy - Start */
require_once 'classes/model/UsersProperties.php';
$oUserProperty = new UsersProperties();
if (!$RBAC->singleSignOn) {
$aUserProperty = $oUserProperty->loadOrCreateIfNotExists($_SESSION['USER_LOGGED'], array('USR_PASSWORD_HISTORY' => serialize(array(md5($currentPwd)))));
$aErrors = $oUserProperty->validatePassword($pwd, $aUserProperty['USR_LAST_UPDATE_DATE'], $aUserProperty['USR_LOGGED_NEXT_TIME']);
if (!empty($aErrors)) {
if (!defined('NO_DISPLAY_USERNAME')) {
define('NO_DISPLAY_USERNAME', 1);
}
$aFields = array();
$aFields['DESCRIPTION'] = '<span style="font-weight:normal;">';
$aFields['DESCRIPTION'] .= G::LoadTranslation('ID_POLICY_ALERT').':<br /><br />';
foreach ($aErrors as $sError) {
switch ($sError) {
case 'ID_PPP_MINIMUM_LENGTH':
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MINIMUM_LENGTH . '<br />';
$aFields[substr($sError, 3)] = PPP_MINIMUM_LENGTH;
break;
case 'ID_PPP_MAXIMUM_LENGTH':
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MAXIMUM_LENGTH . '<br />';
$aFields[substr($sError, 3)] = PPP_MAXIMUM_LENGTH;
break;
case 'ID_PPP_EXPIRATION_IN':
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).' ' . PPP_EXPIRATION_IN . ' ' . G::LoadTranslation('ID_DAYS') . '<br />';
$aFields[substr($sError, 3)] = PPP_EXPIRATION_IN;
break;
default:
$aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).'<br />';
$aFields[substr($sError, 3)] = 1;
break;
}
}
//TODO complete this policy section (need update)
$aFields['DESCRIPTION'] .= '<br />' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY') . '<br /><br /></span>';
//TODO need migrate to ExtJS
// $G_PUBLISH = new Publisher;
// $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePassword', '', $aFields, 'changePassword');
// G::RenderPage('publish');
//die;
}
}
$sLocation = $oUserProperty->redirectTo($_SESSION['USER_LOGGED'], $lang);
$result->success = true;
$result->message = 'Logged Successfully';
$result->url = $sLocation;
}
catch ( Exception $e ) {
$result->success = false;
$result->message = $e->getMessage();
$result->errorCode = $e->getCode();
}
return $result;
}
public function forgotPassword($httpData)
{
$this->setResponseType('json');
@@ -743,6 +456,22 @@ class Main extends Controller
return $menus;
}
private function resolveUrlToTabIndex($url)
{
if (strpos($url, 'cases/main') !== false)
$activeTab = 0;
else if (strpos($url, 'processes/main') !== false)
$activeTab = 1;
else if (strpos($url, 'dashboard/main') !== false)
$activeTab = 2;
else if (strpos($url, 'setup/main') !== false)
$activeTab = 3;
else
$activeTab = 0;
return $activeTab;
}
private function getCompanyLogo()
{
$sCompanyLogo = '/images/processmaker2.logo.png';
@@ -915,25 +644,20 @@ class Main extends Controller
}
}
private function getActiveTab()
{
$activeTab = '';
if (isset($_GET['st'])) {
$activeTab = $_GET['st'];
unset($_GET['st']);
if (!is_numeric($activeTab)) {
switch ($activeTab) {
case 'home' : $activeTab = 0; break;
case 'bpmn' : $activeTab = 1; break;
case 'designer': $activeTab = 2; break;
case 'admin' : $activeTab = 3; break;
default: $activeTab = 0;
}
}
else {
$activeTab = $activeTab > -1 && $activeTab < 3 ? (int) $activeTab : '';
private function getActiveTab($activeTab)
{
if (!is_numeric($activeTab)) {
switch ($activeTab) {
case 'home' : $activeTab = 0; break;
case 'designer' : $activeTab = 1; break;
case 'dashboard': $activeTab = 2; break;
case 'admin' : $activeTab = 3; break;
default: $activeTab = 0;
}
}
else {
$activeTab = $activeTab > -1 && $activeTab < 3 ? (int) $activeTab : '';
}
return $activeTab;
}