diff --git a/gulliver/system/class.controller.php b/gulliver/system/class.controller.php index 4577edb76..494e6b91e 100755 --- a/gulliver/system/class.controller.php +++ b/gulliver/system/class.controller.php @@ -31,6 +31,11 @@ class Controller * @var string - response type var. possibles values: json|plain */ private $responseType = ''; + + /** + * @var string - layout to pass skinEngine + */ + private $layout = ''; /** * Magic setter method diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index b84caa367..f99d95c47 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -666,23 +666,17 @@ class G $G_CONTENT = $objContent; $G_TEMPLATE = $strTemplate; $G_SKIN = $strSkin; - //echo 'x'; g::dump($G_PUBLISH); die; try { - ///////G::LoadSkin( $strSkin ); - //G::skinEngine($strSkin); - $file = G::ExpandPath( "skinEngine" ) . "skinEngine.php"; include $file; $skinEngine = new SkinEngine($G_TEMPLATE, $G_SKIN, $G_CONTENT); $skinEngine->setLayout($layout); $skinEngine->dispatch(); - } catch ( Exception $e ) { - echo $aMessage['MESSAGE'] = $e->getMessage(); - die; + $aMessage['MESSAGE'] = $e->getMessage(); global $G_PUBLISH; global $G_MAIN_MENU; global $G_SUB_MENU; @@ -706,18 +700,6 @@ class G die; } } - - function skinEngine($strSkin){ - // $file = G::ExpandPath( "skinEngine" ) . "skinEngine.php"; - // require_once( $file ); - - $file = G::ExpandPath( "skinEngine" ) . "class.skinEngine.php"; - //die($file); - include $file; - $skinEngine = new SkinEngine(); - $skinEngine->dispatch(); - - } /** * Load a skin @@ -994,18 +976,8 @@ class G while ( count ( $URI_VARS ) > 0 && $exit == 0) { $SYS_TARGET .= '/' . array_shift($URI_VARS); } - - // if ($SYS_TARGET == 'login') { - // if (isset($config['default_lang']) && !empty($config['default_lang'])) { - // $SYS_LANG = $config['default_lang']; - // } - - // if (isset($config['default_skin']) && !empty($config['default_skin'])) { - // $SYS_SKIN = $config['default_skin']; - // } - // } - - /* Fix to prevent use uxs skin outside siplified interface, because that skin is not compatible with others interfaces*/ + /* Fix to prevent use uxs skin outside siplified interface, + because that skin is not compatible with others interfaces*/ if ($SYS_SKIN == 'uxs' && $SYS_COLLECTION !== 'home') { $SYS_SKIN = 'classic'; } diff --git a/workflow/engine/classes/class.system.php b/workflow/engine/classes/class.system.php index ee43d6b42..d909f402e 100755 --- a/workflow/engine/classes/class.system.php +++ b/workflow/engine/classes/class.system.php @@ -933,15 +933,25 @@ class System { //Get Skin Config files $skinListArray = array(); $customSkins = glob(PATH_CUSTOM_SKINS . "*/config.xml"); - $configurationFile = G::ExpandPath("skinEngine") . 'base' . PATH_SEP . 'config.xml'; - array_unshift($customSkins, $configurationFile); + + // getting al base skins + $baseSkins = glob(G::ExpandPath("skinEngine") . '*/config.xml'); + + // filtering no public skins (uxs, simplified) + foreach ($baseSkins as $i => $skinName) { + if (strpos($skinName, 'simplified') !== false || strpos($skinName, 'uxs') !== false) { + unset($baseSkins[$i]); + } + } + + $customSkins = array_merge($baseSkins, $customSkins); //Read and parse each Configuration File foreach ($customSkins as $key => $configInformation) { - $folderId = str_replace(G::ExpandPath("skinEngine") . 'base', "", str_replace(PATH_CUSTOM_SKINS, "", str_replace("/config.xml", "", $configInformation))); + $folderId = basename(dirname($configInformation)); - if ($folderId == "") { - $folderId = "classic"; + if ($folderId == 'base') { + $folderId = 'classic'; } $xmlConfiguration = file_get_contents($configInformation); diff --git a/workflow/engine/classes/model/UsersProperties.php b/workflow/engine/classes/model/UsersProperties.php index 31e782cad..343baf8ec 100755 --- a/workflow/engine/classes/model/UsersProperties.php +++ b/workflow/engine/classes/model/UsersProperties.php @@ -18,40 +18,38 @@ require_once 'classes/model/om/BaseUsersProperties.php'; */ class UsersProperties extends BaseUsersProperties { - var $fields = null; + public $fields = null; + public $usrID = ''; + public $lang = 'en'; + + function __construct() + { + $this->lang = defined('SYS_LANG') ? SYS_LANG : 'en'; + } - function UserPropertyExists($sUserUID) { - try { - $oUserProperty = UsersPropertiesPeer::retrieveByPk($sUserUID); - if (!is_null($oUserProperty) && is_object($oUserProperty) && get_class($oUserProperty) == 'UsersProperties') { - $this->fields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($this->fields, BasePeer::TYPE_FIELDNAME); - return true; - } - else { - return false; - } + function UserPropertyExists($sUserUID) + { + $oUserProperty = UsersPropertiesPeer::retrieveByPk($sUserUID); + if (!is_null($oUserProperty) && is_object($oUserProperty) && get_class($oUserProperty) == 'UsersProperties') { + $this->fields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME); + $this->fromArray($this->fields, BasePeer::TYPE_FIELDNAME); + return true; } - catch (Exception $oError) { - throw($oError); + else { + return false; } } public function load($sUserUID) - { - try { - $oUserProperty = UsersPropertiesPeer::retrieveByPK($sUserUID); - if (!is_null($oUserProperty)) { - $aFields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME); - $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); - return $aFields; - } - else { - throw(new Exception('This row doesn\'t exist!')); - } + { + $oUserProperty = UsersPropertiesPeer::retrieveByPK($sUserUID); + if (!is_null($oUserProperty)) { + $aFields = $oUserProperty->toArray(BasePeer::TYPE_FIELDNAME); + $this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); + return $aFields; } - catch (Exception $oError) { - throw($oError); + else { + throw new Exception("User with $sUserUID does not exist!"); } } @@ -129,6 +127,7 @@ class UsersProperties extends BaseUsersProperties else { $aUserProperty = $this->fields; } + return $aUserProperty; } @@ -199,12 +198,84 @@ class UsersProperties extends BaseUsersProperties return $aErrors; } - public function redirectTo($sUserUID, $sLanguage = 'en') + + /** + * get user location + * defined by precedence plugin->ux->default + */ + public function redirectTo($usrID, $lang='') + { + $this->usrID = $usrID; + $this->lang = empty($lang) ? $this->lang : $lang; + + $url = $this->_getPluginLocation(); + + if (empty($url)) { + $url = $this->_getUXLocation(); + } + + $urlUx = $this->_getUXSkinVariant(); + if (empty($url) && !empty($urlUx)) { + $_SESSION['_defaultUserLocation'] = $url; + $url = $urlUx; + } + + if (empty($url)) { + $url = $this->_getDefaultLocation(); + } + + return $url; + } + + /** + * get user location + * defined by precedence plugin->default + * note that is getting location without User Inbox Simplified varification + */ + public function getUserLocation($usrID, $lang = 'en') + { + $this->usrID = $usrID; + $this->lang = empty($lang) ? $this->lang : $lang; + + $url = $this->_getPluginLocation(); + + if (empty($url)) { + $url = $this->_getDefaultLocation(); + } + + $urlUx = $this->_getUXSkinVariant(); + if (!empty($urlUx)) { + $_SESSION['_defaultUserLocation'] = $url; + $url = $urlUx; + } + + return $url; + } + + /** + * to verify if the user is using some "ux..." skin variant + * if that is the case, the redirection will change to 'main' controller + */ + public function _getUXSkinVariant() + { + $url = ''; + + if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') { + $url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/main'; + } + + return $url; + } + + /** + * get the plugins, and check if there is redirectLogins + * if yes, then redirect goes according his Role + */ + public function _getPluginLocation() { global $RBAC; - - //get the plugins, and check if there is redirectLogins - //if yes, then redirect goes according his Role + $url = ''; + if ( class_exists('redirectDetail')) { //to do: complete the validation if(isset($RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'])) @@ -215,24 +286,25 @@ class UsersProperties extends BaseUsersProperties if (isset($aRedirectLogin) && is_array($aRedirectLogin) ) { foreach ($aRedirectLogin as $key=>$detail) { if (isset($detail->sPathMethod) && $detail->sRoleCode == $userRole ) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . $detail->sPathMethod; + $url = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/' . $detail->sPathMethod; } } } } - //end plugin - if (substr(SYS_SKIN, 0, 2) === 'ux' && SYS_SKIN != 'uxs') { - return '../main'; - } + return $url; + } - - /** - * New feature - User Experience Redirector - * @author Erik Amaru Ortiz - */ + /** + * New feature - User Experience Redirector + * @author Erik Amaru Ortiz + */ + public function _getUXLocation() + { require_once 'classes/model/Users.php'; - $u = UsersPeer::retrieveByPK($sUserUID); + $u = UsersPeer::retrieveByPK($this->usrID); + $url = ''; + $uxType = $u->getUsrUx(); $_SESSION['user_experience'] = 'NORMAL'; @@ -240,7 +312,7 @@ class UsersProperties extends BaseUsersProperties if ($uxType == '' || $uxType == 'NORMAL') { require_once 'classes/model/GroupUser.php'; $gu = new GroupUser(); - $ugList = $gu->getAllUserGroups($sUserUID); + $ugList = $gu->getAllUserGroups($this->usrID); foreach ($ugList as $row) { if ($row['GRP_UX'] != 'NORMAL' && $row['GRP_UX'] != '') { @@ -256,69 +328,85 @@ class UsersProperties extends BaseUsersProperties case 'SINGLE': $_SESSION['user_experience'] = $uxType; $_SESSION['user_last_skin'] = SYS_SKIN; - return '/sys' . SYS_SYS . '/' . $sLanguage . '/uxs/' . 'home'; + $url = '/sys' . SYS_SYS . '/' . $this->lang . '/uxs/' . 'home'; break; } - // end user experience redirection - // get user preferences for default redirect - // verifying if it has any preferences on configurations table + return $url; + } + + /** + * get user preferences for default redirect + * verifying if it has any preferences on configurations table + */ + public function _getDefaultLocation() + { + global $RBAC; G::loadClass('configuration'); $oConf = new Configurations; $oConf->loadConfig($x, 'USER_PREFERENCES','','',$_SESSION['USER_LOGGED'],''); + $baseUrl = '/sys' . SYS_SYS . '/' . $this->lang . '/' . SYS_SKIN . '/'; + $url = ''; + if( sizeof($oConf->aConfig) > 0) { // this user has a configuration record - // backward compatibility, because now, we don't have user and dashboard menu. - if ( $oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP'; - if ( $oConf->aConfig['DEFAULT_MENU'] == 'PM_DASHBOARD') $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP'; - + // backward compatibility, because now, we don't have user and dashboard menu. + if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_USERS') + $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP'; + + if ($oConf->aConfig['DEFAULT_MENU'] == 'PM_DASHBOARD') + $oConf->aConfig['DEFAULT_MENU'] = 'PM_SETUP'; + switch($oConf->aConfig['DEFAULT_MENU']) { case 'PM_SETUP': if ($RBAC->userCanAccess('PM_SETUP') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'setup/main'; + $url = 'setup/main'; } break; case 'PM_FACTORY': if ($RBAC->userCanAccess('PM_FACTORY') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'processes/main'; + $url = 'processes/main'; } break; case 'PM_CASES': if ($RBAC->userCanAccess('PM_CASES') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'cases/main'; + $url = 'cases/main'; } break; case 'PM_USERS': if ($RBAC->userCanAccess('PM_USERS') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'setup/main'; + $url = 'setup/main'; } break; case 'PM_DASHBOARD': if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'dashboard/dashboard'; + $url = 'dashboard/dashboard'; } break; } } - if ($RBAC->userCanAccess('PM_FACTORY') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'processes/main'; + if (empty($url)) { + if ($RBAC->userCanAccess('PM_FACTORY') == 1) { + $url = 'processes/main'; + } + else if ($RBAC->userCanAccess('PM_SETUP') == 1) { + $url = 'setup/main'; + } + else if ($RBAC->userCanAccess('PM_CASES') == 1) { + $url = 'cases/main'; + } + else if ($RBAC->userCanAccess('PM_USERS') == 1) { + $url = 'setup/main'; + } + else if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) { + $url = 'dashboard/dashboard'; + } + else { + $url = 'users/myInfo'; + } } - if ($RBAC->userCanAccess('PM_SETUP') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'setup/main'; - } - if ($RBAC->userCanAccess('PM_CASES') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'cases/main'; - } - if ($RBAC->userCanAccess('PM_USERS') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'setup/main'; - } - if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'dashboard/dashboard'; - } - if ($RBAC->userCanAccess('PM_REPORTS') == 1) { - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'reports/reportsList'; - } - return '/sys' . SYS_SYS . '/' . $sLanguage . '/' . SYS_SKIN . '/' . 'users/myInfo'; + + return $baseUrl . $url; } } // UsersProperties diff --git a/workflow/engine/controllers/admin.php b/workflow/engine/controllers/admin.php index 7bd2dbff4..5c3fbd2a3 100644 --- a/workflow/engine/controllers/admin.php +++ b/workflow/engine/controllers/admin.php @@ -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); diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index f4063eb53..5c00b17a0 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -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'; } diff --git a/workflow/engine/controllers/home.php b/workflow/engine/controllers/home.php index f54697d46..b37589cbd 100644 --- a/workflow/engine/controllers/home.php +++ b/workflow/engine/controllers/home.php @@ -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]); diff --git a/workflow/engine/controllers/main.php b/workflow/engine/controllers/main.php index a63b6e57c..681f58ae3 100644 --- a/workflow/engine/controllers/main.php +++ b/workflow/engine/controllers/main.php @@ -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'] = ''; - $aFields['DESCRIPTION'] .= G::LoadTranslation('ID_POLICY_ALERT').':

'; - foreach ($aErrors as $sError) { - switch ($sError) { - case 'ID_PPP_MINIMUM_LENGTH': - $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MINIMUM_LENGTH . '
'; - $aFields[substr($sError, 3)] = PPP_MINIMUM_LENGTH; - break; - case 'ID_PPP_MAXIMUM_LENGTH': - $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MAXIMUM_LENGTH . '
'; - $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') . '
'; - $aFields[substr($sError, 3)] = PPP_EXPIRATION_IN; - break; - default: - $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).'
'; - $aFields[substr($sError, 3)] = 1; - break; - } - } - - //TODO complete this policy section (need update) - $aFields['DESCRIPTION'] .= '
' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY') . '

'; - //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; } diff --git a/workflow/engine/methods/login/authentication.php b/workflow/engine/methods/login/authentication.php index 67953a60f..1c560cbf6 100755 --- a/workflow/engine/methods/login/authentication.php +++ b/workflow/engine/methods/login/authentication.php @@ -26,7 +26,6 @@ try { if (!$RBAC->singleSignOn) { - if (!isset($_POST['form']) ) { G::SendTemporalMessage ('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error'); G::header('Location: login'); @@ -43,9 +42,7 @@ try { } $uid = $RBAC->VerifyLogin($usr , $pwd); - $RBAC->cleanSessionFiles(72); //cleaning session files older than 72 hours - $sPwd = 'currentPwd'; switch ($uid) { //The user does doesn't exist @@ -85,8 +82,6 @@ try { break; } - $$sPwd = $pwd; - //to avoid empty string in user field. This will avoid a weird message "this row doesn't exist" if ( !isset($uid) ) { $uid = -1; @@ -141,9 +136,9 @@ try { //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 ); + $lSession=""; + $loginInfo = new loginInfo ($usr, $pwd, $lSession ); + $oPluginRegistry->executeTriggers ( PM_LOGIN , $loginInfo ); } $_SESSION['USER_LOGGED'] = $uid; $_SESSION['USR_USERNAME'] = $usr; @@ -225,88 +220,76 @@ try { $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($_POST['form']['USR_PASSWORD'], $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'] = ''; - $aFields['DESCRIPTION'] .= G::LoadTranslation('ID_POLICY_ALERT').':

'; - foreach ($aErrors as $sError) { - switch ($sError) { - case 'ID_PPP_MINIMUM_LENGTH': - $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MINIMUM_LENGTH . '
'; - $aFields[substr($sError, 3)] = PPP_MINIMUM_LENGTH; - break; - case 'ID_PPP_MAXIMUM_LENGTH': - $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MAXIMUM_LENGTH . '
'; - $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') . '
'; - $aFields[substr($sError, 3)] = PPP_EXPIRATION_IN; - break; - default: - $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).'
'; - $aFields[substr($sError, 3)] = 1; - break; - } - } - $aFields['DESCRIPTION'] .= '
' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY') . '

'; - $G_PUBLISH = new Publisher; - $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePassword', '', $aFields, 'changePassword'); - G::RenderPage('publish'); - die; - } - - if (isset($_REQUEST['form']['URL']) && $_REQUEST['form']['URL'] != '') { - $sLocation = $_REQUEST['form']['URL']; - } - else { - if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') { - $sLocation = $_REQUEST['u']; - } - else { - $sLocation = $oUserProperty->redirectTo($_SESSION['USER_LOGGED'], $lang); - } - } + // getting default user location + if (isset($_REQUEST['form']['URL']) && $_REQUEST['form']['URL'] != '') { + $sLocation = $_REQUEST['form']['URL']; } else { - if (isset($_REQUEST['form']['URL']) && $_REQUEST['form']['URL'] != '') { - $sLocation = $_REQUEST['form']['URL']; + if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') { + $sLocation = $_REQUEST['u']; } else { - if (isset($_REQUEST['u']) && $_REQUEST['u'] != '') { - $sLocation = $_REQUEST['u']; - } - else { - $sLocation = $oUserProperty->redirectTo($_SESSION['USER_LOGGED'], $lang); - } + $sLocation = $oUserProperty->redirectTo($_SESSION['USER_LOGGED'], $lang); } + } + + if ($RBAC->singleSignOn) { G::header('Location: ' . $sLocation); die(); } + + $aUserProperty = $oUserProperty->loadOrCreateIfNotExists($_SESSION['USER_LOGGED'], array('USR_PASSWORD_HISTORY' => serialize(array(md5($pwd))))); + $aErrors = $oUserProperty->validatePassword($_POST['form']['USR_PASSWORD'], $aUserProperty['USR_LAST_UPDATE_DATE'], $aUserProperty['USR_LOGGED_NEXT_TIME']); - $oHeadPublisher =& headPublisher::getSingleton(); + if (!empty($aErrors)) { + if (!defined('NO_DISPLAY_USERNAME')) { + define('NO_DISPLAY_USERNAME', 1); + } + $aFields = array(); + $aFields['DESCRIPTION'] = ''; + $aFields['DESCRIPTION'] .= G::LoadTranslation('ID_POLICY_ALERT').':

'; + foreach ($aErrors as $sError) { + switch ($sError) { + case 'ID_PPP_MINIMUM_LENGTH': + $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MINIMUM_LENGTH . '
'; + $aFields[substr($sError, 3)] = PPP_MINIMUM_LENGTH; + break; + case 'ID_PPP_MAXIMUM_LENGTH': + $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).': ' . PPP_MAXIMUM_LENGTH . '
'; + $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') . '
'; + $aFields[substr($sError, 3)] = PPP_EXPIRATION_IN; + break; + default: + $aFields['DESCRIPTION'] .= ' - ' . G::LoadTranslation($sError).'
'; + $aFields[substr($sError, 3)] = 1; + break; + } + } + $aFields['DESCRIPTION'] .= '
' . G::LoadTranslation('ID_PLEASE_CHANGE_PASSWORD_POLICY') . '

'; + $G_PUBLISH = new Publisher; + $G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/changePassword', '', $aFields, 'changePassword'); + G::RenderPage('publish'); + die; + } + + $oHeadPublisher = &headPublisher::getSingleton(); $oHeadPublisher->extJsInit = true; $oHeadPublisher->addExtJsScript('login/init', false); //adding a javascript file .js $oHeadPublisher->assign('uriReq', $sLocation); G::RenderPage('publish', 'extJs'); //G::header('Location: ' . $sLocation); - die; - } catch ( Exception $e ) { $aMessage['MESSAGE'] = $e->getMessage(); diff --git a/workflow/engine/skinEngine/skinEngine.php b/workflow/engine/skinEngine/skinEngine.php index 148be4411..6b3b9eac6 100644 --- a/workflow/engine/skinEngine/skinEngine.php +++ b/workflow/engine/skinEngine/skinEngine.php @@ -456,8 +456,8 @@ class SkinEngine $viewFile = isset($contentFiles[0]) ? $contentFiles[0] : ''; if (empty($this->layout)) { - $smarty->template_dir = PATH_TPL; - $tpl = $viewFile; + $smarty->template_dir = PATH_TPL; + $tpl = $viewFile . '.html'; } else { $smarty->template_dir = $this->layoutFile['dirname']; diff --git a/workflow/engine/skinEngine/uxmodern/config.xml b/workflow/engine/skinEngine/uxmodern/config.xml index 0c5ccfe87..70fce06c2 100644 --- a/workflow/engine/skinEngine/uxmodern/config.xml +++ b/workflow/engine/skinEngine/uxmodern/config.xml @@ -1,13 +1,13 @@ - 00000000000000000000000000000001 - Classic - Classic/default skin + 00000000000000000000000000000002 + UxModern + UxModern skin ProcessMaker Team 1.0 - 2011-02-27 - 2011-02-28 + 2012-04-05 + 2012-04-05 diff --git a/workflow/engine/templates/admin/system.js b/workflow/engine/templates/admin/system.js index 012cafd30..267e24321 100644 --- a/workflow/engine/templates/admin/system.js +++ b/workflow/engine/templates/admin/system.js @@ -2,6 +2,7 @@ Ext.onReady(function(){ var cmbSkins = new Ext.form.ComboBox({ fieldLabel : _('ID_DEFAULT_SKIN'), + id : 'default_skin', hiddenName : 'default_skin', store : new Ext.data.ArrayStore({ fields: ['ID', 'NAME'], @@ -31,6 +32,7 @@ Ext.onReady(function(){ var cmbLang = new Ext.form.ComboBox({ fieldLabel : _('ID_DEFAULT_LANGUAGE'), + id : 'default_lang', hiddenName : 'default_lang', store : new Ext.data.ArrayStore({ fields: ['ID', 'NAME'], @@ -161,13 +163,12 @@ function saveSettings() if(response.restart) { PMExt.confirm(_('ID_CONFIRM'), _('ID_SYSTEM_REDIRECT_CONFIRM'), function(){ - if (typeof window.parent.parent != 'undefined') - window.parent.parent.location.href = '/'; + window.parent.parent.location.href = response.url; if (typeof window.parent != 'undefined') - window.parent.location.href = '/'; + window.parent.location.href = response.url; else - window.location.href = '/'; + window.location.href = response.url; }); } else diff --git a/workflow/engine/templates/main/index.js b/workflow/engine/templates/main/index.js index 8468d5f17..51aeeca24 100644 --- a/workflow/engine/templates/main/index.js +++ b/workflow/engine/templates/main/index.js @@ -98,6 +98,24 @@ Main.configureComponents = function() this.configuration.userMenu = {} this.configuration.userMenu.items = new Array(); + + if (switchInterface) { + this.configuration.userMenu.items.push({ + text : _("ID_SWITCH_INTERFACE"), + iconCls: 'ss_sprite ss_arrow_switch', + handler: function() { + var url = '../uxs/home'; + + if (typeof parent != 'undefined') { + parent.location.href = url; + } + else { + location.href = url; + } + } + }); + } + this.configuration.userMenu.items.push({ text : _("ID_VIEW_EDIT_PROFILE"), icon: '/images/profile-picture.png', diff --git a/workflow/engine/templates/main/login.js b/workflow/engine/templates/main/login.js index 5a8a81331..df38b5b18 100644 --- a/workflow/engine/templates/main/login.js +++ b/workflow/engine/templates/main/login.js @@ -419,6 +419,7 @@ Login.submit = function() Login.submiting = true; + document.getElementById('language').value = Ext.getCmp('language').getValue(); document.forms[0].action = '../login/authentication'; document.forms[0].submit(); return; diff --git a/workflow/engine/templates/main/sysLogin.js b/workflow/engine/templates/main/sysLogin.js index 82725c692..c62c89073 100644 --- a/workflow/engine/templates/main/sysLogin.js +++ b/workflow/engine/templates/main/sysLogin.js @@ -196,10 +196,10 @@ Login.initComponents = function() data : languages }), listeners : { - afterrender : function(){ + afterrender : function() { var store = languagesCmb.getStore(); var i = store.findExact('id', defaultLang, 0); - if (i > -1){ + if (i > -1) { Ext.getCmp('language').setValue(store.getAt(i).data.id); Ext.getCmp('language').setRawValue(store.getAt(i).data.name); } @@ -275,12 +275,12 @@ Login.submit = function() } Login.submiting = true; - + + document.getElementById('language').value = Ext.getCmp('language').getValue(); document.forms[0].action = '../login/sysLoginVerify'; document.forms[0].submit(); return; - Login.form.getForm().submit({ method: 'POST', //waitTitle: '',