diff --git a/workflow/engine/controllers/main.php b/workflow/engine/controllers/main.php index 5b2fe3f6b..be1cdac68 100644 --- a/workflow/engine/controllers/main.php +++ b/workflow/engine/controllers/main.php @@ -7,789 +7,794 @@ class Main extends Controller { - private $memcache; - private $conf; + private $memcache; + private $conf; - public function __construct() - { - G::LoadClass('memcached'); - $this->memcache = & PMmemcached::getSingleton(defined('SYS_SYS') ? SYS_SYS : ''); + public function __construct() + { + G::LoadClass('memcached'); + $this->memcache = & PMmemcached::getSingleton(defined('SYS_SYS') ? SYS_SYS : ''); - define('ERROR_EXCEPTION' , 1); - define('INFO_EXCEPTION' , 3); - define('WARNING_EXCEPTION', 2); + define('ERROR_EXCEPTION' , 1); + define('INFO_EXCEPTION' , 3); + define('WARNING_EXCEPTION', 2); - //$this->setDebug(true); - } - - function index($httpData) - { - 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()); - $this->setVar('userfullname', $this->getUserFullName()); - $this->setVar('user', isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : ''); - $this->setVar('pipe', isset($_SESSION['USR_USERNAME']) ? ' | ' : ''); - $this->setVar('rolename', $this->getUserRole()); - $this->setVar('logout', G::LoadTranslation('ID_LOGOUT')); - $this->setVar('workspace', defined('SYS_SYS')? ucfirst(SYS_SYS): ''); - $this->setVar('user_avatar', 'users/users_ViewPhotoGrid?pUID=' . $_SESSION['USER_LOGGED'].'&h=' . rand()); - $this->setVar('udate', G::getformatedDate(date('Y-m-d'), 'M d, yyyy', SYS_LANG)); - - // license notification - $expireInLabel = ''; - if (class_exists('pmLicenseManager')) { - $pmLicenseManager = &pmLicenseManager::getSingleton(); - $expireIn = $pmLicenseManager->getExpireIn(); - $expireInLabel = $pmLicenseManager->getExpireInLabel(); - } - $this->setVar('licenseNotification', $expireInLabel); - - // setting variables on javascript env. - $this->setJSVar('meta', array('menu'=>$this->getMenu())); - - $activeTab = 0; - if (isset($_SESSION['_defaultUserLocation'])) { - $activeTab = $this->resolveUrlToTabIndex($_SESSION['_defaultUserLocation']); - } - - if (isset($_GET['st'])) { - $activeTab = $this->getActiveTab($_GET['st']); - unset($_GET['st']); + //$this->setDebug(true); } - $this->setJSVar('activeTab', $activeTab); - $this->setJSVar('urlAddGetParams', $this->getUrlGetParams()); - $this->setJSVar('showSystemInfo', $showSystemInfo); + function index($httpData) + { + global $RBAC; + $RBAC->requirePermissions('PM_LOGIN'); + $meta = new stdClass; + $showSystemInfo = $RBAC->userCanAccess('PM_SETUP') == 1; - $switchInterface = isset($_SESSION['user_experience']) && $_SESSION['user_experience'] == 'SWITCHABLE'; + // setting variables for template + $this->setVar('logo_company', $this->getCompanyLogo()); + $this->setVar('userfullname', $this->getUserFullName()); + $this->setVar('user', isset($_SESSION['USR_USERNAME']) ? $_SESSION['USR_USERNAME'] : ''); + $this->setVar('pipe', isset($_SESSION['USR_USERNAME']) ? ' | ' : ''); + $this->setVar('rolename', $this->getUserRole()); + $this->setVar('logout', G::LoadTranslation('ID_LOGOUT')); + $this->setVar('workspace', defined('SYS_SYS')? ucfirst(SYS_SYS): ''); + $this->setVar('user_avatar', 'users/users_ViewPhotoGrid?pUID=' . $_SESSION['USER_LOGGED'].'&h=' . rand()); + $this->setVar('udate', G::getformatedDate(date('Y-m-d'), 'M d, yyyy', SYS_LANG)); - if (($flyNotify = $this->getFlyNotify()) !== false) { - $this->setJSVar('flyNotify', $flyNotify); - } - - $this->setJSVar('switchInterface', $switchInterface); - - $this->includeExtJSLib('ux/ux.menu'); - $this->includeExtJS('main/index'); - $this->setLayout('pm-modern'); - $this->afterLoad($httpData); - - $this->render(); - } - - function getSystemInfo() - { - $this->setResponseType('json'); - $infoList = $this->_getSystemInfo(); - $data = array(); - - foreach ($infoList as $row) { - $data[] = array( - 'label' => $row[0], - 'value' => $row[1], - 'section' => $row[2], - ); - } - return $data; - } - - /** - * Login - */ - public function login() - { - require_once 'classes/model/LoginLog.php'; - G::LoadClass('system'); - G::loadClass('configuration'); - $this->conf = new Configurations; - - // getting posibles errors passed by GET method - $this->getInUrlError(); - - if (!isset ($_SESSION ['G_MESSAGE'])) { - $_SESSION['G_MESSAGE'] = ''; - } - if (!isset ($_SESSION ['G_MESSAGE_TYPE'])) { - $_SESSION['G_MESSAGE_TYPE'] = ''; - } - - $msg = $_SESSION['G_MESSAGE']; - $msgType = $_SESSION['G_MESSAGE_TYPE']; - - if (! isset($_SESSION['FAILED_LOGINS'])) { - $_SESSION['FAILED_LOGINS'] = 0; - } - $sFailedLogins = $_SESSION ['FAILED_LOGINS']; - - if ( isset ($_SESSION ['USER_LOGGED']) ) { - //close the session, if the current session_id was used in PM. - $oCriteria = new Criteria ( 'workflow' ); - $oCriteria->add ( LoginLogPeer::LOG_SID, session_id () ); - $oCriteria->add ( LoginLogPeer::USR_UID, isset ( $_SESSION ['USER_LOGGED'] ) ? $_SESSION ['USER_LOGGED'] : '-' ); - $oCriteria->add ( LoginLogPeer::LOG_STATUS, 'ACTIVE' ); - $oCriteria->add ( LoginLogPeer::LOG_END_DATE, NULL, Criteria::ISNULL ); - $oDataset = LoginLogPeer::doSelectRS ( $oCriteria ); - $oDataset->setFetchmode ( ResultSet::FETCHMODE_ASSOC ); - $oDataset->next (); - $aRow = $oDataset->getRow (); - if ($aRow) { - if ($aRow ['LOG_STATUS'] != 'CLOSED' && $aRow ['LOG_END_DATE'] == NULL) { - $weblog = new LoginLog ( ); - $aLog ['LOG_UID'] = $aRow ['LOG_UID']; - $aLog ['LOG_STATUS'] = 'CLOSED'; - $aLog ['LOG_IP'] = $aRow ['LOG_IP']; - $aLog ['LOG_SID'] = session_id (); - $aLog ['LOG_INIT_DATE'] = $aRow ['LOG_INIT_DATE']; - $aLog ['LOG_END_DATE'] = date ( 'Y-m-d H:i:s' ); - $aLog ['LOG_CLIENT_HOSTNAME'] = $aRow ['LOG_CLIENT_HOSTNAME']; - $aLog ['USR_UID'] = $aRow ['USR_UID']; - $weblog->update ( $aLog ); + // license notification + $expireInLabel = ''; + if (class_exists('pmLicenseManager')) { + $pmLicenseManager = &pmLicenseManager::getSingleton(); + $expireIn = $pmLicenseManager->getExpireIn(); + $expireInLabel = $pmLicenseManager->getExpireInLabel(); } - } - //remove memcached session - $this->memcache->delete( 'rbacSession' . session_id() ) ; + $this->setVar('licenseNotification', $expireInLabel); + + // setting variables on javascript env. + $this->setJSVar('meta', array('menu'=>$this->getMenu())); + + $activeTab = 0; + if (isset($_SESSION['_defaultUserLocation'])) { + $activeTab = $this->resolveUrlToTabIndex($_SESSION['_defaultUserLocation']); + } + + if (isset($_GET['st'])) { + $activeTab = $this->getActiveTab($_GET['st']); + unset($_GET['st']); + } + + $this->setJSVar('activeTab', $activeTab); + $this->setJSVar('urlAddGetParams', $this->getUrlGetParams()); + $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->setLayout('pm-modern'); + $this->afterLoad($httpData); + + $this->render(); } - else { - // Execute SSO trigger - $pluginRegistry =& PMPluginRegistry::getSingleton(); - if (defined('PM_SINGLE_SIGN_ON')) { - if ($pluginRegistry->existsTrigger(PM_SINGLE_SIGN_ON)) { - if ($pluginRegistry->executeTriggers(PM_SINGLE_SIGN_ON, null)) { - // Start new session - @session_destroy(); - session_start(); - session_regenerate_id(); - // Authenticate - $result = $this->authentication(); - if ($result->success) { - // Redirect to landing page for the user - G::header('Location: ' . $result->url); - die(); + + function getSystemInfo() + { + $this->setResponseType('json'); + $infoList = $this->_getSystemInfo(); + $data = array(); + + foreach ($infoList as $row) { + $data[] = array( + 'label' => $row[0], + 'value' => $row[1], + 'section' => $row[2], + ); + } + return $data; + } + + /** + * Login + */ + public function login() + { + require_once 'classes/model/LoginLog.php'; + G::LoadClass('system'); + G::loadClass('configuration'); + $this->conf = new Configurations; + + // getting posibles errors passed by GET method + $this->getInUrlError(); + + if (!isset ($_SESSION ['G_MESSAGE'])) { + $_SESSION['G_MESSAGE'] = ''; + } + if (!isset ($_SESSION ['G_MESSAGE_TYPE'])) { + $_SESSION['G_MESSAGE_TYPE'] = ''; + } + + $msg = $_SESSION['G_MESSAGE']; + $msgType = $_SESSION['G_MESSAGE_TYPE']; + + if (! isset($_SESSION['FAILED_LOGINS'])) { + $_SESSION['FAILED_LOGINS'] = 0; + } + $sFailedLogins = $_SESSION ['FAILED_LOGINS']; + + if (isset ($_SESSION ['USER_LOGGED'])) { + //close the session, if the current session_id was used in PM. + $oCriteria = new Criteria ('workflow'); + $oCriteria->add (LoginLogPeer::LOG_SID, session_id ()); + $oCriteria->add (LoginLogPeer::USR_UID, isset ($_SESSION ['USER_LOGGED']) ? + $_SESSION ['USER_LOGGED'] : '-'); + $oCriteria->add (LoginLogPeer::LOG_STATUS, 'ACTIVE'); + $oCriteria->add (LoginLogPeer::LOG_END_DATE, null, Criteria::ISNULL); + $oDataset = LoginLogPeer::doSelectRS ($oCriteria); + $oDataset->setFetchmode (ResultSet::FETCHMODE_ASSOC); + $oDataset->next (); + $aRow = $oDataset->getRow (); + if ($aRow) { + if ($aRow ['LOG_STATUS'] != 'CLOSED' && $aRow ['LOG_END_DATE'] == null) { + $weblog = new LoginLog (); + $aLog ['LOG_UID'] = $aRow ['LOG_UID']; + $aLog ['LOG_STATUS'] = 'CLOSED'; + $aLog ['LOG_IP'] = $aRow ['LOG_IP']; + $aLog ['LOG_SID'] = session_id (); + $aLog ['LOG_INIT_DATE'] = $aRow ['LOG_INIT_DATE']; + $aLog ['LOG_END_DATE'] = date ('Y-m-d H:i:s'); + $aLog ['LOG_CLIENT_HOSTNAME'] = $aRow ['LOG_CLIENT_HOSTNAME']; + $aLog ['USR_UID'] = $aRow ['USR_UID']; + $weblog->update ($aLog); + } } - } - } - } - } - //end log - - //start new session - @session_destroy (); - session_start (); - session_regenerate_id (); - - if (strlen ( $msg ) > 0) { - $_SESSION ['G_MESSAGE'] = $msg; - } - if (strlen ( $msgType ) > 0) { - $_SESSION ['G_MESSAGE_TYPE'] = $msgType; - } - $_SESSION ['FAILED_LOGINS'] = $sFailedLogins; - - $availableLangArray = $this->getLanguagesList(); - - //$G_PUBLISH = new Publisher ( ); - //$G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/login', '', $aFields, SYS_URI . 'login/authentication.php' ); - - G::LoadClass ( 'serverConfiguration' ); - - if ( ($nextBeatDate = $this->memcache->get('nextBeatDate')) === false ) { - //get the serverconf singleton, and check if we can send the heartbeat - $oServerConf = & serverConf::getSingleton (); - - $sflag = $oServerConf->getHeartbeatProperty('HB_OPTION','HEART_BEAT_CONF'); - $sflag = (trim($sflag)!='')?$sflag:'1'; - - //get date of next beat - $nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE','HEART_BEAT_CONF'); - $this->memcache->set( 'nextBeatDate', $nextBeatDate, 1*3600 ); - } - - $sflag = 1; - //TODO analize this & enable to work with this new login - // if flag to send heartbeat is enabled, and it is time to send heartbeat, sent it using asynchronous beat. - // if( ($sflag=="1") && ((strtotime ( "now" ) > $nextBeatDate) || is_null($nextBeatDate) ) ){ - // $oHeadPublisher =& headPublisher::getSingleton(); - // //To do: we need to change to ExtJs - // $oHeadPublisher->addScriptCode( 'var flagHeartBeat = 1; '); - // } - // else - // $oHeadPublisher->addScriptCode( 'var flagHeartBeat = 0; '); - - //check if we show the panel with the getting started info - if ( ($flagGettingStarted = $this->memcache->get('flagGettingStarted')) === false ) { - require_once 'classes/model/Configuration.php'; - $oConfiguration = new Configuration ( ); - $oCriteria = new Criteria ( 'workflow' ); - $oCriteria->add ( ConfigurationPeer::CFG_UID, 'getStarted' ); - $oCriteria->add ( ConfigurationPeer::OBJ_UID, '' ); - $oCriteria->add ( ConfigurationPeer::CFG_VALUE, '1' ); - $oCriteria->add ( ConfigurationPeer::PRO_UID, '' ); - $oCriteria->add ( ConfigurationPeer::USR_UID, '' ); - $oCriteria->add ( ConfigurationPeer::APP_UID, '' ); - $flagGettingStarted = ConfigurationPeer::doCount ( $oCriteria ); - $this->memcache->set( 'flagGettingStarted', $flagGettingStarted, 8*3600 ) ; - } - - $this->setJSVar('flagGettingStarted', ($flagGettingStarted == 0)); - - G::loadClass('configuration'); - $oConf = new Configurations; - $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS',''); - - $flagForgotPassword = isset($oConf->aConfig['login_enableForgotPassword'])? $oConf->aConfig['login_enableForgotPassword']: 'off'; - //$oHeadPublisher->addScriptCode("var flagForgotPassword = '$flagForgotPassword';"); - - $this->includeExtJSLib('ux/virtualkeyboard'); - $this->includeExtJS('main/login'); - $this->setView('main/login'); - - $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS',''); - - $forgotPasswd = isset($oConf->aConfig['login_enableForgotPassword'])? $oConf->aConfig['login_enableForgotPassword']: false; - $virtualKeyboad = isset($oConf->aConfig['login_enableVirtualKeyboard'])? $oConf->aConfig['login_enableVirtualKeyboard']: false; - $defaultLanguaje = isset($oConf->aConfig['login_defaultLanguage'])? $oConf->aConfig['login_defaultLanguage']: 'en'; - - - $this->setJSVar('forgotPasswd', $forgotPasswd); - $this->setJSVar('virtualKeyboad', $virtualKeyboad); - - $this->setJSVar('languages', $availableLangArray); - $this->setJSVar('defaultLang', $defaultLanguaje); - - //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() - if (($flyNotify = $this->getFlyNotify()) !== false) { - $this->setJSVar('flyNotify', $flyNotify); - } - - //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() - if (isset($_GET['u'])) { - $this->setJSVar('urlRequested', urldecode($_GET['u'])); - } - - $this->setVar('logo_company', $this->getCompanyLogo()); - $this->setVar('pmos_version', System::getVersion()); - - $footerText = 'Copyright © 2003-2011 Colosa, Inc. All rights reserved.'; - $adviseText = 'Supplied free of charge with no support, certification, warranty, - maintenance nor indemnity by Colosa and its Certified Partners. '; - $this->setVar('footer_text', $footerText); - $this->setVar('advise_text', $adviseText); - $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); - $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); - $this->setVar('login_script', $loginScript); - $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript()); - - $this->setLayout('pm-modern-login'); - - $this->render(); - } - - /** - * SysLogin - */ - public function sysLogin() - { - require_once ("propel/Propel.php"); - require_once ("creole/Creole.php"); - G::LoadClass('system'); - G::LoadThirdParty ( "pake", "pakeColor.class" ); - Propel::init ( PATH_CORE . "config/databases.php" ); - Creole::registerDriver ( 'dbarray', 'creole.contrib.DBArrayConnection' ); - - // getting posibles errors passed by GET method - $this->getInUrlError(); - - $availableWorkspace = $this->getWorkspacesAvailable(); - $availableWorkspaceList = array(); - - foreach ($availableWorkspace as $ws) { - $availableWorkspaceList[] = array($ws, $ws); - } - - $aField ['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG'); - - //Get Server Configuration - G::LoadClass ( 'serverConfiguration' ); - $oServerConf = & serverConf::getSingleton (); - - $availableLangArray = $this->getLanguagesList(); - - $this->includeExtJSLib('ux/virtualkeyboard'); - $this->setJSVar('sysLang', SYS_LANG); - $this->includeExtJS('main/sysLogin'); - - $this->setVar('logo_company', $this->getCompanyLogo()); - $this->setVar('pmos_version', System::getVersion()); - - $footerText = 'Copyright © 2003-2011 Colosa, Inc. All rights reserved.'; - $adviseText = 'Supplied free of charge with no support, certification, warranty, - maintenance nor indemnity by Colosa and its Certified Partners. '; - $this->setVar('footer_text', $footerText); - $this->setVar('advise_text', $adviseText); - - //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() - if (($flyNotify = $this->getFlyNotify()) !== false) { - $this->setJSVar('flyNotify', $flyNotify); - } - - $this->setJSVar('languages', $availableLangArray); - $this->setJSVar('workspaces', $availableWorkspaceList); - $this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS')); - - $this->setJSVar('defaultLang', 'en'); - $this->setJSVar('defaultWS', ''); - - $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); - $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); - $this->setVar('login_script', $loginScript); - $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript()); - - $this->setLayout('pm-modern-login'); - - $this->render(); - } - - public function forgotPassword($httpData) - { - $this->setResponseType('json'); - global $RBAC; - require_once PATH_RBAC."model/RbacUsers.php"; - require_once 'classes/model/Users.php'; - G::LoadClass("system"); - - $rbacUser = new RbacUsers(); - $user = new Users(); - - try { - $userData = $rbacUser->getByUsername($httpData->username); - - if (!$userData) { - $msg = G::LoadTranslation('ID_USER') . ' ' . $httpData->username . ' '. G::LoadTranslation('ID_IS_NOT_REGISTERED'); - throw new Exception($msg); - } - - if (trim($userData['USR_EMAIL']) != trim($httpData->email)) { - $msg = G::LoadTranslation('ID_EMAIL_DOES_NOT_MATCH_FOR_USER') .' '. $httpData->username . ''; - throw new Exception($msg); - } - - $newPass = G::generate_password(); - - $aData['USR_UID'] = $userData['USR_UID']; - $aData['USR_PASSWORD'] = md5($newPass); - - $rbacUser->update($aData); - $user->update($aData); - - $subject = G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE'); - - $template = new TemplatePower(PATH_TPL . 'main/forgotPassword.tpl'); - $template->prepare(); - $template->assign('server', $_SERVER['SERVER_NAME']); - - $template->assign('serviceMsg', G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE')); - $template->assign('content', G::loadTranslation('ID_PASSWORD_CHANGED_SUCCESSFULLY')); - $template->assign('passwd', $newPass); - $template->assign('poweredBy', G::loadTranslation('ID_PROCESSMAKER_SLOGAN1')); - $template->assign('versionLabel', G::loadTranslation('ID_VERSION')); - $template->assign('version', System::getVersion()); - $template->assign('visit', G::loadTranslation('ID_VISIT')); - - $template->assign('footer', ''); - $body = $template->getOutputContent(); - - G::sendMail('', 'ProcessMaker Service', $httpData->email, $subject, $body); - - $result->success = true; - $result->message = G::LoadTranslation('ID_NEW_PASSWORD_SENT'); - } catch(Exception $e) { - $result->success = false; - $result->message = $e->getMessage(); - } - return $result; - } - - /** * - * Private Functions * - * **/ - - private function getMenu() - { - global $G_MAIN_MENU; - global $G_SUB_MENU; - global $G_MENU_SELECTED; - global $G_SUB_MENU_SELECTED; - global $G_ID_MENU_SELECTED; - global $G_ID_SUB_MENU_SELECTED; - - $G_MAIN_MENU = 'processmaker'; - $G_SUB_MENU = 'process'; - $G_ID_MENU_SELECTED = 'BPMN'; - - $oMenu = new Menu(); - $menus = $oMenu->generateArrayForTemplate($G_MAIN_MENU, 'SelectedMenu', 'mainMenu', $G_MENU_SELECTED, $G_ID_MENU_SELECTED); - - foreach ($menus as $i => $menu) { - if (strpos($menu['target'], 'cases/main') !== false) - $menus[$i]['target'] = str_replace('cases/main', 'cases/main_init', $menus[$i]['target']); - - if (strpos($menu['target'], 'bpmn/main') !== false) - $menus[$i]['target'] = str_replace('bpmn/main', 'bpmn/mainInit', $menus[$i]['target']); - - if (strpos($menu['target'], 'processes/main') !== false) - $menus[$i]['target'] = str_replace('processes/main', 'processes/mainInit', $menus[$i]['target']); - - if (strpos($menu['target'], 'setup/main') !== false) { - $menus[$i]['target'] = str_replace('setup/main', 'setup/main_init', $menus[$i]['target']); - - // $param = ''; - // if (isset($_GET['i18']) || isset($_GET['i18n'])) { - // $s = strpos($menus[$i]['target'], '?') !== false ? '&' : '?'; - // $menus[$i]['target'] .= $s . 'i18'; - // } - } - - if (strpos($menu['target'], 'dashboard/main') !== false) - $menus[$i]['target'] = str_replace('dashboard/main', 'dashboard', $menus[$i]['target']); - - $menus[$i]['elementclass'] = preg_replace(array('/class=/', '/"/'), array('', ''), $menus[$i]['elementclass']) ; - } - 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.logo2.png'; - - if(defined("SYS_SYS")){ - if ( ($aFotoSelect = $this->memcache->get('aFotoSelect')) === false ) { - G::LoadClass( 'replacementLogo' ); - $oLogoR = new replacementLogo(); - $aFotoSelect = $oLogoR->getNameLogo((isset($_SESSION['USER_LOGGED']))?$_SESSION['USER_LOGGED']:''); - $this->memcache->set( 'aFotoSelect', $aFotoSelect, 1*3600 ); - } - - if ( is_array ( $aFotoSelect ) ) { - $sFotoSelect = trim($aFotoSelect['DEFAULT_LOGO_NAME']); - $sWspaceSelect = trim($aFotoSelect['WORKSPACE_LOGO_NAME']); - } - } - - if (class_exists('PMPluginRegistry')) { - $oPluginRegistry = &PMPluginRegistry::getSingleton(); - - if ( isset($sFotoSelect) && $sFotoSelect!='' && !(strcmp($sWspaceSelect,SYS_SYS)) ){ - $sCompanyLogo = $oPluginRegistry->getCompanyLogo($sFotoSelect); - $sCompanyLogo = "/sys".SYS_SYS."/".SYS_LANG."/".SYS_SKIN."/adminProxy/showLogoFile?id=".base64_encode($sCompanyLogo); - } - else { - $sCompanyLogo = $oPluginRegistry->getCompanyLogo($sCompanyLogo); - } - } - - return $sCompanyLogo; - } - - public function getLanguagesList() - { - //translation - $Translations = G::getModel("Translation"); - $translationsTable = $Translations->getTranslationEnvironments(); - - if ( ($languagesList = $this->memcache->get('languagesList')) === false ) { - $languagesList = array (); - - foreach ( $translationsTable as $locale ) { - $LANG_ID = $locale['LOCALE']; - - if( $locale['COUNTRY'] != '.' ) - $LANG_NAME = $locale['LANGUAGE'] . ' (' . (ucwords(strtolower($locale['COUNTRY']))) . ')'; - else - $LANG_NAME = $locale['LANGUAGE']; - - $languagesList [] = array($LANG_ID, $LANG_NAME); - } - $this->memcache->set('languagesList', $languagesList, 1*3600 ); - } - - return $languagesList; - } - - private function getWorkspacesAvailable() { - G::LoadClass ( 'serverConfiguration' ); - $oServerConf = & serverConf::getSingleton (); - $dir = PATH_DB; - $filesArray = array (); - if (file_exists ( $dir )) { - if ($handle = opendir ( $dir )) { - while ( false !== ($file = readdir ( $handle )) ) { - if (($file != ".") && ($file != "..")) { - if (file_exists ( PATH_DB . $file . '/db.php' )) { - if (! $oServerConf->isWSDisabled ( $file )) - $filesArray [] = $file; + //remove memcached session + $this->memcache->delete('rbacSession' . session_id()) ; + } else { + // Execute SSO trigger + $pluginRegistry =& PMPluginRegistry::getSingleton(); + if (defined('PM_SINGLE_SIGN_ON')) { + if ($pluginRegistry->existsTrigger(PM_SINGLE_SIGN_ON)) { + if ($pluginRegistry->executeTriggers(PM_SINGLE_SIGN_ON, null)) { + // Start new session + @session_destroy(); + session_start(); + session_regenerate_id(); + // Authenticate + $result = $this->authentication(); + if ($result->success) { + // Redirect to landing page for the user + G::header('Location: ' . $result->url); + die(); + } + } + } } - } } - closedir ( $handle ); - } - } - sort ( $filesArray, SORT_STRING ); - return $filesArray; - } + //end log - private function getUserRole() - { - global $RBAC; - $rolCode = str_replace('_', ' ', $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']); - $rolUid = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_UID']; + //start new session + @session_destroy (); + session_start (); + session_regenerate_id (); - $oCriteria1 = new Criteria('workflow'); - $oCriteria1->add(ContentPeer::CON_CATEGORY, 'ROL_NAME'); - $oCriteria1->add(ContentPeer::CON_ID, $rolUid); - $oCriteria1->add(ContentPeer::CON_LANG, SYS_LANG); - $oDataset1 = ContentPeer::doSelectRS($oCriteria1); - $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); - $oDataset1->next(); - $aRow = $oDataset1->getRow(); - $rolName = $aRow['CON_VALUE']; + if (strlen ($msg) > 0) { + $_SESSION ['G_MESSAGE'] = $msg; + } + if (strlen ($msgType) > 0) { + $_SESSION ['G_MESSAGE_TYPE'] = $msgType; + } + $_SESSION ['FAILED_LOGINS'] = $sFailedLogins; - return $rolName ? $rolName : $rolCode; - } + $availableLangArray = $this->getLanguagesList(); + //$G_PUBLISH = new Publisher (); + //$G_PUBLISH->AddContent ('xmlform', 'xmlform', 'login/login', '', $aFields, SYS_URI . + //'login/authentication.php'); - /** - * binding G::SendTemporalMessage() to Javascript routine Ext.msgBoxSlider.msgTopCenter() - */ - private function getFlyNotify() - { - if (!isset($_SESSION['G_MESSAGE'])) { - return false; + G::LoadClass ('serverConfiguration'); + + if (($nextBeatDate = $this->memcache->get('nextBeatDate')) === false) { + //get the serverconf singleton, and check if we can send the heartbeat + $oServerConf = & serverConf::getSingleton (); + + $sflag = $oServerConf->getHeartbeatProperty('HB_OPTION','HEART_BEAT_CONF'); + $sflag = (trim($sflag)!='')?$sflag:'1'; + + //get date of next beat + $nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE','HEART_BEAT_CONF'); + $this->memcache->set('nextBeatDate', $nextBeatDate, 1*3600); + } + + $sflag = 1; + //check if we show the panel with the getting started info + if (($flagGettingStarted = $this->memcache->get('flagGettingStarted')) === false) { + require_once 'classes/model/Configuration.php'; + $oConfiguration = new Configuration (); + $oCriteria = new Criteria ('workflow'); + $oCriteria->add (ConfigurationPeer::CFG_UID, 'getStarted'); + $oCriteria->add (ConfigurationPeer::OBJ_UID, ''); + $oCriteria->add (ConfigurationPeer::CFG_VALUE, '1'); + $oCriteria->add (ConfigurationPeer::PRO_UID, ''); + $oCriteria->add (ConfigurationPeer::USR_UID, ''); + $oCriteria->add (ConfigurationPeer::APP_UID, ''); + $flagGettingStarted = ConfigurationPeer::doCount ($oCriteria); + $this->memcache->set('flagGettingStarted', $flagGettingStarted, 8*3600) ; + } + + $this->setJSVar('flagGettingStarted', ($flagGettingStarted == 0)); + + G::loadClass('configuration'); + $oConf = new Configurations; + $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS',''); + + $flagForgotPassword = isset($oConf->aConfig['login_enableForgotPassword'])? + $oConf->aConfig['login_enableForgotPassword']: 'off'; + + $this->includeExtJSLib('ux/virtualkeyboard'); + $this->includeExtJS('main/login'); + $this->setView('main/login'); + + $oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS',''); + + $forgotPasswd = isset($oConf->aConfig['login_enableForgotPassword'])? + $oConf->aConfig['login_enableForgotPassword']: false; + $virtualKeyboad = isset($oConf->aConfig['login_enableVirtualKeyboard'])? + $oConf->aConfig['login_enableVirtualKeyboard']: false; + $defaultLanguaje = isset($oConf->aConfig['login_defaultLanguage'])? + $oConf->aConfig['login_defaultLanguage']: 'en'; + + $this->setJSVar('forgotPasswd', $forgotPasswd); + $this->setJSVar('virtualKeyboad', $virtualKeyboad); + + $this->setJSVar('languages', $availableLangArray); + $this->setJSVar('defaultLang', $defaultLanguaje); + + //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() + if (($flyNotify = $this->getFlyNotify()) !== false) { + $this->setJSVar('flyNotify', $flyNotify); + } + + //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() + if (isset($_GET['u'])) { + $this->setJSVar('urlRequested', urldecode($_GET['u'])); + } + + $this->setVar('logo_company', $this->getCompanyLogo()); + $this->setVar('pmos_version', System::getVersion()); + + $footerText = 'Copyright ? 2003-2011 Colosa, Inc. All rights reserved.'; + $adviseText = 'Supplied free of charge with no support, certification, warranty, + maintenance nor indemnity by Colosa and its Certified Partners. '; + $this->setVar('footer_text', $footerText); + $this->setVar('advise_text', $adviseText); + $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); + $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); + $this->setVar('login_script', $loginScript); + $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript()); + + $this->setLayout('pm-modern-login'); + + $this->render(); } - $flyNotify['title'] = isset($_SESSION['G_MESSAGE_TITLE']) ? $_SESSION['G_MESSAGE_TITLE'] : ''; - $flyNotify['text'] = $_SESSION['G_MESSAGE']; + /** + * SysLogin + */ + public function sysLogin() + { + require_once ("propel/Propel.php"); + require_once ("creole/Creole.php"); + G::LoadClass('system'); + G::LoadThirdParty ("pake", "pakeColor.class"); + Propel::init (PATH_CORE . "config/databases.php"); + Creole::registerDriver ('dbarray', 'creole.contrib.DBArrayConnection'); - unset($_SESSION['G_MESSAGE']); - if (isset($_SESSION['G_MESSAGE_TYPE'])) { - $flyNotify['type'] = $_SESSION['G_MESSAGE_TYPE']; - unset($_SESSION['G_MESSAGE_TYPE']); - } - else { - $flyNotify['type'] = ''; + // getting posibles errors passed by GET method + $this->getInUrlError(); + + $availableWorkspace = $this->getWorkspacesAvailable(); + $availableWorkspaceList = array(); + + foreach ($availableWorkspace as $ws) { + $availableWorkspaceList[] = array($ws, $ws); + } + + $aField ['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG'); + + //Get Server Configuration + G::LoadClass ('serverConfiguration'); + $oServerConf = & serverConf::getSingleton (); + + $availableLangArray = $this->getLanguagesList(); + + $this->includeExtJSLib('ux/virtualkeyboard'); + $this->setJSVar('sysLang', SYS_LANG); + $this->includeExtJS('main/sysLogin'); + + $this->setVar('logo_company', $this->getCompanyLogo()); + $this->setVar('pmos_version', System::getVersion()); + + $footerText = 'Copyright ? 2003-2011 Colosa, Inc. All rights reserved.'; + $adviseText = 'Supplied free of charge with no support, certification, warranty, + maintenance nor indemnity by Colosa and its Certified Partners. '; + $this->setVar('footer_text', $footerText); + $this->setVar('advise_text', $adviseText); + + //binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter() + if (($flyNotify = $this->getFlyNotify()) !== false) { + $this->setJSVar('flyNotify', $flyNotify); + } + + $this->setJSVar('languages', $availableLangArray); + $this->setJSVar('workspaces', $availableWorkspaceList); + $this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS')); + + $this->setJSVar('defaultLang', 'en'); + $this->setJSVar('defaultWS', ''); + + $loginScript = $this->getHeadPublisher()->getExtJsLibraries(); + $loginScript .= $this->getHeadPublisher()->getExtJsScripts(); + $this->setVar('login_script', $loginScript); + $this->setVar('login_vars', $this->getHeadPublisher()->getExtJsVariablesScript()); + + $this->setLayout('pm-modern-login'); + + $this->render(); } - if ($flyNotify['title'] == '') { - switch($flyNotify['type']) { - case 'alert': case 'warning': case 'tmp-warning': - $flyNotify['title'] = G::loadTranslation('ID_WARNING'); - break; - case 'error': case 'tmp-error': - $flyNotify['title'] = G::loadTranslation('ID_ERROR'); - break; - case 'tmp-info': case 'info': - $flyNotify['title'] = G::loadTranslation('ID_INFO'); - break; - case 'success': case 'ok': - $flyNotify['title'] = G::loadTranslation('ID_SUCCESS'); - break; - } - $flyNotify['title'] = strtoupper($flyNotify['title']); + public function forgotPassword($httpData) + { + $this->setResponseType('json'); + global $RBAC; + require_once PATH_RBAC."model/RbacUsers.php"; + require_once 'classes/model/Users.php'; + G::LoadClass("system"); + + $rbacUser = new RbacUsers(); + $user = new Users(); + + try { + $userData = $rbacUser->getByUsername($httpData->username); + + if (!$userData) { + $msg = G::LoadTranslation('ID_USER') . ' ' . $httpData->username . ' '. + G::LoadTranslation('ID_IS_NOT_REGISTERED'); + throw new Exception($msg); + } + + if (trim($userData['USR_EMAIL']) != trim($httpData->email)) { + $msg = G::LoadTranslation('ID_EMAIL_DOES_NOT_MATCH_FOR_USER') .' '. $httpData->username . ''; + throw new Exception($msg); + } + + $newPass = G::generate_password(); + + $aData['USR_UID'] = $userData['USR_UID']; + $aData['USR_PASSWORD'] = md5($newPass); + + $rbacUser->update($aData); + $user->update($aData); + + $subject = G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE'); + + $template = new TemplatePower(PATH_TPL . 'main/forgotPassword.tpl'); + $template->prepare(); + $template->assign('server', $_SERVER['SERVER_NAME']); + + $template->assign('serviceMsg', G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE')); + $template->assign('content', G::loadTranslation('ID_PASSWORD_CHANGED_SUCCESSFULLY')); + $template->assign('passwd', $newPass); + $template->assign('poweredBy', G::loadTranslation('ID_PROCESSMAKER_SLOGAN1')); + $template->assign('versionLabel', G::loadTranslation('ID_VERSION')); + $template->assign('version', System::getVersion()); + $template->assign('visit', G::loadTranslation('ID_VISIT')); + + $template->assign('footer', ''); + $body = $template->getOutputContent(); + + G::sendMail('', 'ProcessMaker Service', $httpData->email, $subject, $body); + + $result->success = true; + $result->message = G::LoadTranslation('ID_NEW_PASSWORD_SENT'); + } catch (Exception $e) { + $result->success = false; + $result->message = $e->getMessage(); + } + return $result; } - $flyNotify['time'] = 5; //TODO make dinamic - $this->flyNotify = $flyNotify; + /** * + * Private Functions * + * **/ + private function getMenu() + { + global $G_MAIN_MENU; + global $G_SUB_MENU; + global $G_MENU_SELECTED; + global $G_SUB_MENU_SELECTED; + global $G_ID_MENU_SELECTED; + global $G_ID_SUB_MENU_SELECTED; - return $this->flyNotify; - } + $G_MAIN_MENU = 'processmaker'; + $G_SUB_MENU = 'process'; + $G_ID_MENU_SELECTED = 'BPMN'; - private function setFlyNotify($type, $title, $text, $time = 5) - { - $this->flyNotify = array( - 'type' => $type, - 'title' => $title, - 'text' => $text, - 'time' => $time - ); + $oMenu = new Menu(); + $menus = $oMenu->generateArrayForTemplate($G_MAIN_MENU, 'SelectedMenu', 'mainMenu', $G_MENU_SELECTED, + $G_ID_MENU_SELECTED); - $_SESSION ['G_MESSAGE'] = $text; - $_SESSION ['G_MESSAGE_TYPE'] = $type; - } - - private function getInUrlError() - { - if (isset($_GET['errno'])) { - switch ($_GET['errno']) { - case '1': $trnLabel = 'ID_USER_HAVENT_RIGHTS_PAGE'; break; - case '2': $trnLabel = 'ID_NOT_WORKSPACE'; break; - default : $trnLabel = 'ID_USER_HAVENT_RIGHTS_PAGE'; - } - - $this->setFlyNotify('error', 'ERROR', G::loadTranslation($trnLabel)); - } - } - - 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 : ''; + foreach ($menus as $i => $menu) { + if (strpos($menu['target'], 'cases/main') !== false) { + $menus[$i]['target'] = str_replace('cases/main', 'cases/main_init', $menus[$i]['target']); + } + if (strpos($menu['target'], 'bpmn/main') !== false) { + $menus[$i]['target'] = str_replace('bpmn/main', 'bpmn/mainInit', $menus[$i]['target']); + } + if (strpos($menu['target'], 'processes/main') !== false) { + $menus[$i]['target'] = str_replace('processes/main', 'processes/mainInit', $menus[$i]['target']); + } + if (strpos($menu['target'], 'setup/main') !== false) { + $menus[$i]['target'] = str_replace('setup/main', 'setup/main_init', $menus[$i]['target']); + } + if (strpos($menu['target'], 'dashboard/main') !== false) { + $menus[$i]['target'] = str_replace('dashboard/main', 'dashboard', $menus[$i]['target']); + } + $menus[$i]['elementclass'] = preg_replace(array('/class=/', '/"/'), array('', ''), + $menus[$i]['elementclass']) ; + } + return $menus; } - return $activeTab; - } + private function resolveUrlToTabIndex($url) + { + if (strpos($url, 'cases/main') !== false) { + $activeTab = 0; + } elseif (strpos($url, 'processes/main') !== false) { + $activeTab = 1; + } elseif (strpos($url, 'dashboard/main') !== false) { + $activeTab = 2; + } elseif (strpos($url, 'setup/main') !== false) { + $activeTab = 3; + } else { + $activeTab = 0; + } - private function getUrlGetParams() - { - $urlGetParams = ''; - foreach ($_GET as $key => $value) { - $urlGetParams .= $urlGetParams == '' ? $key : "&" . $key; - $urlGetParams .= trim($value) != '' ? '=' . $value : ''; - } - return $urlGetParams; - } - - private function getUserFullName() - { - return isset($_SESSION['USR_FULLNAME']) ? $_SESSION['USR_FULLNAME'] : ''; - } - - private function _getSystemInfo() - { - G::LoadClass("system"); - - if (getenv ( 'HTTP_CLIENT_IP' )) { - $ip = getenv ( 'HTTP_CLIENT_IP' ); - } - else { - if (getenv ( 'HTTP_X_FORWARDED_FOR' )) { - $ip = getenv ( 'HTTP_X_FORWARDED_FOR' ); - } - else { - $ip = getenv ( 'REMOTE_ADDR' ); - } + return $activeTab; } - $redhat = ''; - if (file_exists ( '/etc/redhat-release' )) { - $fnewsize = filesize ( '/etc/redhat-release' ); - $fp = fopen ( '/etc/redhat-release', 'r' ); - $redhat = trim ( fread ( $fp, $fnewsize ) ); - fclose ( $fp ); + private function getCompanyLogo() + { + $sCompanyLogo = '/images/processmaker2.logo2.png'; + + if (defined("SYS_SYS")) { + if (($aFotoSelect = $this->memcache->get('aFotoSelect')) === false) { + G::LoadClass('replacementLogo'); + $oLogoR = new replacementLogo(); + $aFotoSelect = $oLogoR->getNameLogo((isset($_SESSION['USER_LOGGED']))?$_SESSION['USER_LOGGED']:''); + $this->memcache->set('aFotoSelect', $aFotoSelect, 1*3600); + } + + if (is_array ($aFotoSelect)) { + $sFotoSelect = trim($aFotoSelect['DEFAULT_LOGO_NAME']); + $sWspaceSelect = trim($aFotoSelect['WORKSPACE_LOGO_NAME']); + } + } + + if (class_exists('PMPluginRegistry')) { + $oPluginRegistry = &PMPluginRegistry::getSingleton(); + + if (isset($sFotoSelect) && $sFotoSelect!='' && !(strcmp($sWspaceSelect,SYS_SYS))) { + $sCompanyLogo = $oPluginRegistry->getCompanyLogo($sFotoSelect); + $sCompanyLogo = "/sys".SYS_SYS."/".SYS_LANG."/".SYS_SKIN."/adminProxy/showLogoFile?id=". + base64_encode($sCompanyLogo); + } else { + $sCompanyLogo = $oPluginRegistry->getCompanyLogo($sCompanyLogo); + } + } + + return $sCompanyLogo; } - $redhat .= " (" . PHP_OS . ")"; - if (defined ( "DB_HOST" )) { - G::LoadClass ( 'net' ); - G::LoadClass ( 'dbConnections' ); - $dbNetView = new NET ( DB_HOST ); - $dbNetView->loginDbServer ( DB_USER, DB_PASS ); + public function getLanguagesList() + { + //translation + $Translations = G::getModel("Translation"); + $translationsTable = $Translations->getTranslationEnvironments(); - $dbConns = new dbConnections ( '' ); - $availdb = ''; - foreach ( $dbConns->getDbServicesAvailables () as $key => $val ) { - if ($availdb != '') - $availdb .= ', '; - $availdb .= $val ['name']; - } + if (($languagesList = $this->memcache->get('languagesList')) === false) { + $languagesList = array (); - try { + foreach ($translationsTable as $locale) { + $LANG_ID = $locale['LOCALE']; - $sMySQLVersion = $dbNetView->getDbServerVersion ( DB_ADAPTER ); + if ($locale['COUNTRY'] != '.') { + $LANG_NAME = $locale['LANGUAGE'] . ' (' . (ucwords(strtolower($locale['COUNTRY']))) . ')'; + } else { + $LANG_NAME = $locale['LANGUAGE']; + } - } - catch ( Exception $oException ) { - $sMySQLVersion = '?????'; - } + $languagesList [] = array($LANG_ID, $LANG_NAME); + } + $this->memcache->set('languagesList', $languagesList, 1*3600); + } + + return $languagesList; } - $sysSection = G::loadTranslation('ID_SYSTEM_INFO'); - $pmSection = 'ProcessMaker Information'; - - $properties = array(); - $ee = class_exists('pmLicenseManager') ? " - Enterprise Edition" : ''; - $properties[] = array('ProcessMaker Ver.', System::getVersion() . $ee, $pmSection); - $properties[] = array('Operating System', $redhat, $sysSection); - $properties[] = array('Time Zone', (defined('TIME_ZONE')) ? TIME_ZONE : "Unknown", $sysSection); - $properties[] = array('Web Server', getenv ( 'SERVER_SOFTWARE'), $sysSection); - $properties[] = array('Server Name', getenv ( 'SERVER_NAME'), $pmSection); - $properties[] = array('Server IP Address', $this->lookup ($ip), $sysSection); - $properties[] = array('PHP Version', phpversion(), $sysSection); - - if (defined ( "DB_HOST" )) { - $properties[] = array('Data Base', $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')', $pmSection); - $properties[] = array('Data Base Server', DB_HOST, $pmSection); - $properties[] = array('Data Base Name', DB_NAME, $pmSection); - $properties[] = array('Available DB Engines', $availdb, $sysSection); - } - else { - $properties[] = array('Data Base', "Not defined", $pmSection); - $properties[] = array('Data Base Server', "Not defined", $pmSection); - $properties[] = array('Data Base Name', "Not defined", $pmSection); - $properties[] = array('Available DB Engines', "Not defined", $sysSection); + private function getWorkspacesAvailable() + { + G::LoadClass ('serverConfiguration'); + $oServerConf = & serverConf::getSingleton (); + $dir = PATH_DB; + $filesArray = array (); + if (file_exists ($dir)) { + if ($handle = opendir ($dir)) { + while (false !== ($file = readdir ($handle))) { + if (($file != ".") && ($file != "..")) { + if (file_exists (PATH_DB . $file . '/db.php')) { + if (! $oServerConf->isWSDisabled ($file)) { + $filesArray [] = $file; + } + } + } + } + closedir ($handle); + } + } + sort ($filesArray, SORT_STRING); + return $filesArray; } - $properties[] = array('Workspace', defined ( "SYS_SYS" ) ? SYS_SYS : "Not defined", $pmSection); + private function getUserRole() + { + global $RBAC; + $rolCode = str_replace('_', ' ', $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE']); + $rolUid = $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_UID']; + $oCriteria1 = new Criteria('workflow'); + $oCriteria1->add(ContentPeer::CON_CATEGORY, 'ROL_NAME'); + $oCriteria1->add(ContentPeer::CON_ID, $rolUid); + $oCriteria1->add(ContentPeer::CON_LANG, SYS_LANG); + $oDataset1 = ContentPeer::doSelectRS($oCriteria1); + $oDataset1->setFetchmode(ResultSet::FETCHMODE_ASSOC); + $oDataset1->next(); + $aRow = $oDataset1->getRow(); + $rolName = $aRow['CON_VALUE']; - $properties[] = array('Server Protocol', getenv ( 'SERVER_PROTOCOL'), $sysSection); - $properties[] = array('Server Port', getenv ( 'SERVER_PORT'), $sysSection); - //$properties[] = array('Remote Host', getenv ( 'REMOTE_HOST'), $sysSection); - $properties[] = array('Server Addr.', getenv ( 'SERVER_ADDR'), $sysSection); - $properties[] = array('User\'s Browser', getenv ( 'HTTP_USER_AGENT'), $sysSection); - - - return $properties; - } - - private function lookup( $target ) { - global $ntarget; - $msg = $target . ' => '; - //if (eregi ( '[a-zA-Z]', $target )) - if (preg_match( '[a-zA-Z]', $target )) //Made compatible to PHP 5.3 - $ntarget = gethostbyname ( $target ); - else - $ntarget = gethostbyaddr ( $target ); - $msg .= $ntarget; - return ($msg); - } - - /** - * Execute common reoutes after index() action load - */ - private function afterLoad($httpData) - { - if (isset($httpData->i18) || isset($httpData->i18n)) { - $_SESSION['DEV_FLAG'] = true; + return $rolName ? $rolName : $rolCode; + } + + /** + * binding G::SendTemporalMessage() to Javascript routine Ext.msgBoxSlider.msgTopCenter() + */ + private function getFlyNotify() + { + if (!isset($_SESSION['G_MESSAGE'])) { + return false; + } + + $flyNotify['title'] = isset($_SESSION['G_MESSAGE_TITLE']) ? $_SESSION['G_MESSAGE_TITLE'] : ''; + $flyNotify['text'] = $_SESSION['G_MESSAGE']; + + unset($_SESSION['G_MESSAGE']); + if (isset($_SESSION['G_MESSAGE_TYPE'])) { + $flyNotify['type'] = $_SESSION['G_MESSAGE_TYPE']; + unset($_SESSION['G_MESSAGE_TYPE']); + } else { + $flyNotify['type'] = ''; + } + + if ($flyNotify['title'] == '') { + switch($flyNotify['type']) { + case 'alert': + case 'warning': + case 'tmp-warning': + $flyNotify['title'] = G::loadTranslation('ID_WARNING'); + break; + case 'error': + case 'tmp-error': + $flyNotify['title'] = G::loadTranslation('ID_ERROR'); + break; + case 'tmp-info': + case 'info': + $flyNotify['title'] = G::loadTranslation('ID_INFO'); + break; + case 'success': + case 'ok': + $flyNotify['title'] = G::loadTranslation('ID_SUCCESS'); + break; + } + $flyNotify['title'] = strtoupper($flyNotify['title']); + } + //TODO make dinamic + $flyNotify['time'] = 5; + $this->flyNotify = $flyNotify; + + return $this->flyNotify; + } + + private function setFlyNotify($type, $title, $text, $time=5) + { + $this->flyNotify = array( + 'type' => $type, + 'title' => $title, + 'text' => $text, + 'time' => $time + ); + + $_SESSION ['G_MESSAGE'] = $text; + $_SESSION ['G_MESSAGE_TYPE'] = $type; + } + + private function getInUrlError() + { + if (isset($_GET['errno'])) { + switch ($_GET['errno']) { + case '1': + $trnLabel = 'ID_USER_HAVENT_RIGHTS_PAGE'; + break; + case '2': + $trnLabel = 'ID_NOT_WORKSPACE'; + break; + default: + $trnLabel = 'ID_USER_HAVENT_RIGHTS_PAGE'; + break; + } + $this->setFlyNotify('error', 'ERROR', G::loadTranslation($trnLabel)); + } + } + + 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; + break; + } + } else { + $activeTab = $activeTab > -1 && $activeTab < 3 ? (int) $activeTab : ''; + } + return $activeTab; + } + + private function getUrlGetParams() + { + $urlGetParams = ''; + foreach ($_GET as $key => $value) { + $urlGetParams .= $urlGetParams == '' ? $key : "&" . $key; + $urlGetParams .= trim($value) != '' ? '=' . $value : ''; + } + return $urlGetParams; + } + + private function getUserFullName() + { + return isset($_SESSION['USR_FULLNAME']) ? $_SESSION['USR_FULLNAME'] : ''; + } + + private function _getSystemInfo() + { + G::LoadClass("system"); + + if (getenv('HTTP_CLIENT_IP')) { + $ip = getenv('HTTP_CLIENT_IP'); + } else { + if (getenv('HTTP_X_FORWARDED_FOR')) { + $ip = getenv('HTTP_X_FORWARDED_FOR'); + } else { + $ip = getenv('REMOTE_ADDR'); + } + } + + $redhat = ''; + if (file_exists ('/etc/redhat-release')) { + $fnewsize = filesize ('/etc/redhat-release'); + $fp = fopen ('/etc/redhat-release', 'r'); + $redhat = trim (fread ($fp, $fnewsize)); + fclose ($fp); + } + + $redhat .= " (" . PHP_OS . ")"; + if (defined ("DB_HOST")) { + G::LoadClass ('net'); + G::LoadClass ('dbConnections'); + $dbNetView = new NET (DB_HOST); + $dbNetView->loginDbServer (DB_USER, DB_PASS); + + $dbConns = new dbConnections (''); + $availdb = ''; + foreach ($dbConns->getDbServicesAvailables () as $key => $val) { + if ($availdb != '') { + $availdb .= ', '; + } + $availdb .= $val ['name']; + } + + try { + $sMySQLVersion = $dbNetView->getDbServerVersion (DB_ADAPTER); + } catch (Exception $oException) { + $sMySQLVersion = '?????'; + } + } + + $sysSection = G::loadTranslation('ID_SYSTEM_INFO'); + $pmSection = 'ProcessMaker Information'; + + $properties = array(); + $ee = class_exists('pmLicenseManager') ? " - Enterprise Edition" : ''; + $properties[] = array('ProcessMaker Ver.', System::getVersion() . $ee, $pmSection); + $properties[] = array('Operating System', $redhat, $sysSection); + $properties[] = array('Time Zone', (defined('TIME_ZONE')) ? TIME_ZONE : "Unknown", $sysSection); + $properties[] = array('Web Server', getenv ('SERVER_SOFTWARE'), $sysSection); + $properties[] = array('Server Name', getenv ('SERVER_NAME'), $pmSection); + $properties[] = array('Server IP Address', $this->lookup ($ip), $sysSection); + $properties[] = array('PHP Version', phpversion(), $sysSection); + + if (defined ("DB_HOST")) { + $properties[] = array('Data Base', $dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')', + $pmSection); + $properties[] = array('Data Base Server', DB_HOST, $pmSection); + $properties[] = array('Data Base Name', DB_NAME, $pmSection); + $properties[] = array('Available DB Engines', $availdb, $sysSection); + } else { + $properties[] = array('Data Base', "Not defined", $pmSection); + $properties[] = array('Data Base Server', "Not defined", $pmSection); + $properties[] = array('Data Base Name', "Not defined", $pmSection); + $properties[] = array('Available DB Engines', "Not defined", $sysSection); + } + + $properties[] = array('Workspace', defined ("SYS_SYS") ? SYS_SYS : "Not defined", $pmSection); + + $properties[] = array('Server Protocol', getenv ('SERVER_PROTOCOL'), $sysSection); + $properties[] = array('Server Port', getenv ('SERVER_PORT'), $sysSection); + //$properties[] = array('Remote Host', getenv ('REMOTE_HOST'), $sysSection); + $properties[] = array('Server Addr.', getenv ('SERVER_ADDR'), $sysSection); + $properties[] = array('User\'s Browser', getenv ('HTTP_USER_AGENT'), $sysSection); + + return $properties; + } + + private function lookup($target) + { + global $ntarget; + $msg = $target . ' => '; + //if (eregi ('[a-zA-Z]', $target)) + if (preg_match('[a-zA-Z]', $target)) { + //Made compatible to PHP 5.3 + $ntarget = gethostbyname ($target); + } else { + $ntarget = gethostbyaddr ($target); + } + $msg .= $ntarget; + return ($msg); + } + + /** + * Execute common reoutes after index() action load + */ + private function afterLoad($httpData) + { + if (isset($httpData->i18) || isset($httpData->i18n)) { + $_SESSION['DEV_FLAG'] = true; + } } - } } + diff --git a/workflow/engine/methods/login/sysLogin.php b/workflow/engine/methods/login/sysLogin.php index f1c06ca62..869e75272 100755 --- a/workflow/engine/methods/login/sysLogin.php +++ b/workflow/engine/methods/login/sysLogin.php @@ -22,58 +22,62 @@ * Coral Gables, FL, 33134, USA, or email info@colosa.com. * */ -if (isset ( $_POST ['form'] ['USER_ENV'] )) { - session_start (); - $_SESSION ['sysLogin'] = $_POST ['form']; - G::header ( 'location: /sys' . $_POST ['form'] ['USER_ENV'] . '/' . SYS_LANG . '/' . SYS_SKIN . '/login/sysLoginVerify' ); - die (); +if (isset ($_POST['form']['USER_ENV'])) { + session_start (); + $_SESSION ['sysLogin'] = $_POST ['form']; + G::header ('location: /sys' . $_POST ['form'] ['USER_ENV'] . '/' . SYS_LANG . '/' . SYS_SKIN . + '/login/sysLoginVerify'); + die (); } //Required classes for dbArray work require_once ("propel/Propel.php"); require_once ("creole/Creole.php"); -G::LoadThirdParty ( "pake", "pakeColor.class" ); -Propel::init ( PATH_CORE . "config/databases.php" ); -Creole::registerDriver ( 'dbarray', 'creole.contrib.DBArrayConnection' ); +G::LoadThirdParty ("pake", "pakeColor.class"); +Propel::init (PATH_CORE . "config/databases.php"); +Creole::registerDriver ('dbarray', 'creole.contrib.DBArrayConnection'); -function getLangFiles() { - $dir = PATH_LANGUAGECONT; - $filesArray = array (); - if (file_exists ( $dir )) { - if ($handle = opendir ( $dir )) { - while ( false !== ($file = readdir ( $handle )) ) { +function getLangFiles() +{ + $dir = PATH_LANGUAGECONT; + $filesArray = array (); + if (file_exists ($dir)) { + if ($handle = opendir ($dir)) { + while (false !== ($file = readdir ($handle))) { - $fileParts = explode ( ".", $file ); - if ($fileParts [0] == "translation") { - $filesArray [$fileParts [1]] = $file; + $fileParts = explode (".", $file); + if ($fileParts [0] == "translation") { + $filesArray [$fileParts [1]] = $file; + } + } + closedir ($handle); } - } - closedir ( $handle ); } - } - return $filesArray; + return $filesArray; } -function getWorkspacesAvailable() { - G::LoadClass ( 'serverConfiguration' ); - $oServerConf = & serverConf::getSingleton (); - $dir = PATH_DB; - $filesArray = array (); - if (file_exists ( $dir )) { - if ($handle = opendir ( $dir )) { - while ( false !== ($file = readdir ( $handle )) ) { - if (($file != ".") && ($file != "..")) { - if (file_exists ( PATH_DB . $file . '/db.php' )) { - if (! $oServerConf->isWSDisabled ( $file )) - $filesArray [] = $file; - } +function getWorkspacesAvailable() +{ + G::LoadClass ('serverConfiguration'); + $oServerConf = & serverConf::getSingleton (); + $dir = PATH_DB; + $filesArray = array (); + if (file_exists ($dir)) { + if ($handle = opendir ($dir)) { + while (false !== ($file = readdir ($handle))) { + if (($file != ".") && ($file != "..")) { + if (file_exists (PATH_DB . $file . '/db.php')) { + if (! $oServerConf->isWSDisabled ($file)) { + $filesArray [] = $file; + } + } + } + } + closedir ($handle); } - } - closedir ( $handle ); } - } - sort ( $filesArray, SORT_STRING ); - return $filesArray; + sort ($filesArray, SORT_STRING); + return $filesArray; } $availableWorkspace = getWorkspacesAvailable (); @@ -82,24 +86,25 @@ $Translations = G::getModel("Translation"); $translationsTable = $Translations->getTranslationEnvironments(); $availableLangArray = array (); -$availableLangArray [] = array ('LANG_ID' => 'char', 'LANG_NAME' => 'char' ); +$availableLangArray [] = array ('LANG_ID' => 'char', 'LANG_NAME' => 'char'); -foreach ( $translationsTable as $locale ) { - $aFields['LANG_ID'] = $locale['LOCALE']; - if( $locale['COUNTRY'] != '.' ) - $aFields['LANG_NAME'] = $locale['LANGUAGE'] . ' (' . (ucwords(strtolower($locale['COUNTRY']))) . ')'; - else - $aFields['LANG_NAME'] = $locale['LANGUAGE']; +foreach ($translationsTable as $locale) { + $aFields['LANG_ID'] = $locale['LOCALE']; + if ($locale['COUNTRY'] != '.') { + $aFields['LANG_NAME'] = $locale['LANGUAGE'] . ' (' . (ucwords(strtolower($locale['COUNTRY']))) . ')'; + } else { + $aFields['LANG_NAME'] = $locale['LANGUAGE']; + } - $availableLangArray [] = $aFields; + $availableLangArray [] = $aFields; } $availableWorkspaceArray = array (); -$availableWorkspaceArray [] = array ('ENV_ID' => 'char', 'ENV_NAME' => 'char' ); -foreach ( $availableWorkspace as $envKey => $envName ) { - $aFields = array ('ENV_ID' => $envName, 'ENV_NAME' => $envName ); - $availableWorkspaceArray [] = $aFields; +$availableWorkspaceArray [] = array ('ENV_ID' => 'char', 'ENV_NAME' => 'char'); +foreach ($availableWorkspace as $envKey => $envName) { + $aFields = array ('ENV_ID' => $envName, 'ENV_NAME' => $envName); + $availableWorkspaceArray [] = $aFields; } global $_DBArray; @@ -109,24 +114,22 @@ $_DBArray ['availableWorkspace'] = $availableWorkspaceArray; $_SESSION ['_DBArray'] = $_DBArray; -$aField ['LOGIN_VERIFY_MSG'] = G::loadTranslation ( 'LOGIN_VERIFY_MSG' ); +$aField ['LOGIN_VERIFY_MSG'] = G::loadTranslation ('LOGIN_VERIFY_MSG'); $aField['USER_LANG'] = SYS_LANG; //Get Server Configuration -G::LoadClass ( 'serverConfiguration' ); +G::LoadClass ('serverConfiguration'); $oServerConf = & serverConf::getSingleton (); -$G_PUBLISH = new Publisher ( ); -if ($oServerConf->getProperty ( 'LOGIN_NO_WS' )) { - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/sysLoginNoWS', '', $aField, 'sysLogin' ); -} -else { - $G_PUBLISH->AddContent ( 'xmlform', 'xmlform', 'login/sysLogin', '', $aField, 'sysLogin' ); +$G_PUBLISH = new Publisher (); +if ($oServerConf->getProperty ('LOGIN_NO_WS')) { + $G_PUBLISH->AddContent ('xmlform', 'xmlform', 'login/sysLoginNoWS', '', $aField, 'sysLogin'); +} else { + $G_PUBLISH->AddContent ('xmlform', 'xmlform', 'login/sysLogin', '', $aField, 'sysLogin'); } //g::dump($G_PUBLISH); -G::RenderPage ( "publish" ); - +G::RenderPage ("publish"); ?> @@ -134,48 +137,48 @@ G::RenderPage ( "publish" ); var oInfoPanel; var openInfoPanel = function() { - - // note added by carlos pacha carlos[at]colosa[dot]com pckrlos[at]gmail[dot]com - // the following lines of code are getting the hight of panel. Related 8021 bug - var hightpnl= 424; - var varjs = ""; - if(varjs !=' ') - hightpnl= 330; - - var oInfoPanel = new leimnud.module.panel(); - oInfoPanel.options = { - size :{w:500,h:hightpnl}, - position:{x:0,y:0,center:true}, - title :'System Information', - theme :'processmaker', - control :{ - close :true, - drag :false - }, - fx:{ - modal:true + // note added by carlos pacha carlos[at]colosa[dot]com pckrlos[at]gmail[dot]com + // the following lines of code are getting the hight of panel. Related 8021 bug + var hightpnl= 424; + var varjs = ""; + if (varjs !=' ') { + hightpnl= 330; } - }; - oInfoPanel.setStyle = {modal: { - backgroundColor: 'white' - }}; - oInfoPanel.make(); - var oRPC = new leimnud.module.rpc.xmlhttp({ - url : '../login/dbInfo', - //async : false, - method: 'POST', - args : '' - }); + var oInfoPanel = new leimnud.module.panel(); + oInfoPanel.options = { + size :{w:500,h:hightpnl}, + position:{x:0,y:0,center:true}, + title :'System Information', + theme :'processmaker', + control :{ + close :true, + drag :false + }, + fx:{ + modal:true + } + }; + oInfoPanel.setStyle = {modal: { + backgroundColor: 'white' + }}; + oInfoPanel.make(); - oRPC.callback = function(oRPC) { - oInfoPanel.loader.hide(); - var scs = oRPC.xmlhttp.responseText.extractScript(); - oInfoPanel.addContent(oRPC.xmlhttp.responseText); - scs.evalScript(); - }.extend(this); + var oRPC = new leimnud.module.rpc.xmlhttp({ + url : '../login/dbInfo', + //async : false, + method: 'POST', + args : '' + }); - oRPC.make(); - oInfoPanel.addContent(oRPC.xmlhttp.responseText); + oRPC.callback = function(oRPC) { + oInfoPanel.loader.hide(); + var scs = oRPC.xmlhttp.responseText.extractScript(); + oInfoPanel.addContent(oRPC.xmlhttp.responseText); + scs.evalScript(); + }.extend(this); + + oRPC.make(); + oInfoPanel.addContent(oRPC.xmlhttp.responseText); }; diff --git a/workflow/engine/templates/admin/system.js b/workflow/engine/templates/admin/system.js index 97aaac30c..e764a956d 100644 --- a/workflow/engine/templates/admin/system.js +++ b/workflow/engine/templates/admin/system.js @@ -122,10 +122,7 @@ Ext.onReady(function(){ bodyStyle:'padding:5px', frame: true, height: 'auto', - html:'The language that is set by default applies directly when the domain is entered '+ - ' (eg.- http://127.0.0.1:8081), the system reads the configuration and redirects '+ - ' the link to the selected language (eg.- http://127.0.0.1:8081/sys/en/classic/login/login),'+ - ' it should be emphasized that this configuration is for all environments.' + html: _('ID_MESSAGE_SYSTEM')+" "+_('ID_MESSAGE_SYSTEM2') } ] }); diff --git a/workflow/engine/templates/setup/loginSettings.js b/workflow/engine/templates/setup/loginSettings.js index 2ceb0ce2d..bcd431634 100755 --- a/workflow/engine/templates/setup/loginSettings.js +++ b/workflow/engine/templates/setup/loginSettings.js @@ -67,8 +67,7 @@ Ext.onReady(function(){ bodyStyle:'padding:5px', frame: true, height: 'auto', - html:'The default language that is configured in this place is for the "dropdown" of the '+ - 'languages that are displaying on the login screen, this configuration is set for each workspace.' + html: _('ID_MESSAGE_LOGIN') } ], buttons : [saveButton]