This commit is contained in:
Marco Antonio Nina Mena
2017-12-04 13:25:35 +00:00
committed by Julio Cesar Laura Avendaño
parent abe71a6ffe
commit 0d533e19d9
363 changed files with 23948 additions and 44623 deletions

View File

@@ -15,23 +15,23 @@ class Main extends Controller
private $memcache;
private $conf;
public function __construct ()
public function __construct()
{
$this->memcache = & PMmemcached::getSingleton( !empty(config("system.workspace")) ? config("system.workspace") : '' );
$this->memcache = PMmemcached::getSingleton( !empty(config("system.workspace")) ? config("system.workspace") : '' );
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)
public function index($httpData)
{
global $RBAC;
$RBAC->requirePermissions( 'PM_LOGIN' );
$RBAC->requirePermissions('PM_LOGIN');
$meta = new stdClass();
$showSystemInfo = $RBAC->userCanAccess( 'PM_SETUP' ) == 1;
$showSystemInfo = $RBAC->userCanAccess('PM_SETUP') == 1;
// setting variables for template
$this->setVar( 'logo_company', $this->getCompanyLogo() );
@@ -46,59 +46,60 @@ class Main extends Controller
// license notification
$expireInLabel = '';
require_once ("classes" . PATH_SEP . "class.pmLicenseManager.php");
$pmLicenseManager = &PmLicenseManager::getSingleton();
require_once("classes" . PATH_SEP . "class.pmLicenseManager.php");
$pmLicenseManager = PmLicenseManager::getSingleton();
$expireIn = $pmLicenseManager->getExpireIn();
$expireInLabel = $pmLicenseManager->getExpireInLabel();
$this->setVar( 'licenseNotification', $expireInLabel );
$this->setVar('licenseNotification', $expireInLabel);
// setting variables on javascript env.
$this->setJSVar( 'meta', array ('menu' => $this->getMenu()
) );
$this->setJSVar('meta', array('menu' => $this->getMenu()
));
$activeTab = 0;
if (isset( $_SESSION['_defaultUserLocation'] )) {
$activeTab = $this->resolveUrlToTabIndex( $_SESSION['_defaultUserLocation'] );
if (isset($_SESSION['_defaultUserLocation'])) {
$activeTab = $this->resolveUrlToTabIndex($_SESSION['_defaultUserLocation']);
}
if (isset( $_GET['st'] )) {
$activeTab = $this->getActiveTab( $_GET['st'] );
unset( $_GET['st'] );
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 );
$this->setJSVar('activeTab', $activeTab);
$this->setJSVar('urlAddGetParams', $this->getUrlGetParams());
$this->setJSVar('showSystemInfo', $showSystemInfo);
$switchInterface = isset( $_SESSION['user_experience'] ) && $_SESSION['user_experience'] == 'SWITCHABLE';
$switchInterface = isset($_SESSION['user_experience']) && $_SESSION['user_experience'] == 'SWITCHABLE';
if (($flyNotify = $this->getFlyNotify()) !== false) {
$this->setJSVar( 'flyNotify', $flyNotify );
$this->setJSVar('flyNotify', $flyNotify);
}
$this->setJSVar( 'switchInterface', $switchInterface );
$this->setJSVar('switchInterface', $switchInterface);
$this->includeExtJSLib( 'ux/ux.menu' );
$this->includeExtJS( 'main/index' );
$this->setLayout( 'pm-modern' );
$this->afterLoad( $httpData );
$this->includeExtJSLib('ux/ux.menu');
$this->includeExtJS('main/index');
$this->setLayout('pm-modern');
$this->afterLoad($httpData);
$this->render();
}
function screamFileUpgrades () {
G::streamFile( PATH_DATA . 'log/upgrades.log', true );
public function screamFileUpgrades()
{
G::streamFile(PATH_DATA . 'log/upgrades.log', true);
}
function getSystemInfo ()
public function getSystemInfo()
{
$this->setResponseType( 'json' );
$this->setResponseType('json');
$infoList = $this->_getSystemInfo();
$data = array ();
$data = array();
foreach ($infoList as $row) {
$data[] = array ('label' => $row[0],'value' => $row[1],'section' => $row[2]
$data[] = array('label' => $row[0],'value' => $row[1],'section' => $row[2]
);
}
return $data;
@@ -107,37 +108,37 @@ class Main extends Controller
/**
* Login
*/
public function login ()
public function login()
{
$this->conf = new Configurations();
// getting posibles errors passed by GET method
$this->getInUrlError();
if (! isset( $_SESSION['G_MESSAGE'] )) {
if (! isset($_SESSION['G_MESSAGE'])) {
$_SESSION['G_MESSAGE'] = '';
}
if (! isset( $_SESSION['G_MESSAGE_TYPE'] )) {
if (! isset($_SESSION['G_MESSAGE_TYPE'])) {
$_SESSION['G_MESSAGE_TYPE'] = '';
}
$msg = $_SESSION['G_MESSAGE'];
$msgType = $_SESSION['G_MESSAGE_TYPE'];
if (! isset( $_SESSION['FAILED_LOGINS'] )) {
if (! isset($_SESSION['FAILED_LOGINS'])) {
$_SESSION['FAILED_LOGINS'] = 0;
}
$sFailedLogins = $_SESSION['FAILED_LOGINS'];
if (isset( $_SESSION['USER_LOGGED'] )) {
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 );
$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) {
@@ -149,20 +150,20 @@ class Main extends Controller
$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_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 );
$weblog->update($aLog);
}
}
//remove memcached session
$this->memcache->delete( 'rbacSession' . session_id() );
$this->memcache->delete('rbacSession' . session_id());
} else {
// Execute SSO trigger
$pluginRegistry = PluginRegistry::loadSingleton();
if (defined( 'PM_SINGLE_SIGN_ON' )) {
if ($pluginRegistry->existsTrigger( PM_SINGLE_SIGN_ON )) {
if ($pluginRegistry->executeTriggers( PM_SINGLE_SIGN_ON, null )) {
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();
@@ -171,7 +172,7 @@ class Main extends Controller
$result = $this->authentication();
if ($result->success) {
// Redirect to landing page for the user
G::header( 'Location: ' . $result->url );
G::header('Location: ' . $result->url);
die();
}
}
@@ -186,10 +187,10 @@ class Main extends Controller
session_start();
session_regenerate_id();
if (strlen( $msg ) > 0) {
if (strlen($msg) > 0) {
$_SESSION['G_MESSAGE'] = $msg;
}
if (strlen( $msgType ) > 0) {
if (strlen($msgType) > 0) {
$_SESSION['G_MESSAGE_TYPE'] = $msgType;
}
$_SESSION['FAILED_LOGINS'] = $sFailedLogins;
@@ -198,80 +199,80 @@ class Main extends Controller
$sflag = 0;
if (($nextBeatDate = $this->memcache->get( 'nextBeatDate' )) === false) {
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';
$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 );
$nextBeatDate = $oServerConf->getHeartbeatProperty('HB_NEXT_BEAT_DATE', 'HEART_BEAT_CONF');
$this->memcache->set('nextBeatDate', $nextBeatDate, 1 * 3600);
} else {
$sflag = '1';
}
if (($sflag == '1') && ((strtotime( "now" ) > $nextBeatDate) || is_null( $nextBeatDate ))) {
if (($sflag == '1') && ((strtotime("now") > $nextBeatDate) || is_null($nextBeatDate))) {
//To do: we need to change to ExtJs
$this->setJSVar( 'flagHeartBeat', 1 );
$this->setJSVar('flagHeartBeat', 1);
} else {
$this->setJSVar( 'flagHeartBeat', 0 );
$this->setJSVar('flagHeartBeat', 0);
}
if (($flagGettingStarted = $this->memcache->get( 'flagGettingStarted' )) === false) {
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 );
$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) );
$this->setJSVar('flagGettingStarted', ($flagGettingStarted == 0));
$oConf = new Configurations();
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
$oConf->loadConfig($obj, 'ENVIRONMENT_SETTINGS', '');
$flagForgotPassword = isset( $oConf->aConfig['login_enableForgotPassword'] ) ? $oConf->aConfig['login_enableForgotPassword'] : 'off';
$flagForgotPassword = isset($oConf->aConfig['login_enableForgotPassword']) ? $oConf->aConfig['login_enableForgotPassword'] : 'off';
$this->includeExtJSLib( 'ux/virtualkeyboard' );
$this->includeExtJS( 'main/login' );
$this->setView( 'main/login' );
$this->includeExtJSLib('ux/virtualkeyboard');
$this->includeExtJS('main/login');
$this->setView('main/login');
$oConf->loadConfig( $obj, 'ENVIRONMENT_SETTINGS', '' );
$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';
$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('forgotPasswd', $forgotPasswd);
$this->setJSVar('virtualKeyboad', $virtualKeyboad);
$this->setJSVar( 'languages', $availableLangArray );
$this->setJSVar( 'defaultLang', $defaultLanguaje );
$this->setJSVar('languages', $availableLangArray);
$this->setJSVar('defaultLang', $defaultLanguaje);
//binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter()
if (($flyNotify = $this->getFlyNotify()) !== false) {
$this->setJSVar( 'flyNotify', $flyNotify );
$this->setJSVar('flyNotify', $flyNotify);
}
//binding G::SendTemporalMessage() to Ext.msgBoxSlider.msgTopCenter()
if (isset( $_GET['u'] )) {
$this->setJSVar( 'urlRequested', urldecode( $_GET['u'] ) );
if (isset($_GET['u'])) {
$this->setJSVar('urlRequested', urldecode($_GET['u']));
}
$this->setVar( 'logo_company', $this->getCompanyLogo() );
$this->setVar( 'pmos_version', System::getVersion() );
$this->setVar('logo_company', $this->getCompanyLogo());
$this->setVar('pmos_version', System::getVersion());
$footerText = 'Copyright © 2003-' . date( 'Y' ) . ' Colosa, Inc. All rights reserved.';
$footerText = 'Copyright © 2003-' . date('Y') . ' 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 );
$this->setVar('footer_text', $footerText);
$this->setVar('advise_text', $adviseText);
$loginScript = $this->getHeadPublisher()->getExtJsLibraries();
$loginScript .= $this->getHeadPublisher()->getExtJsScripts();
$this->setVar("login_script", $loginScript);
@@ -286,53 +287,52 @@ class Main extends Controller
/**
* SysLogin
*/
public function sysLogin ()
public function sysLogin()
{
Propel::init( PATH_CORE . "config/databases.php" );
Creole::registerDriver( 'dbarray', 'creole.contrib.DBArrayConnection' );
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 ();
$availableWorkspaceList = array();
foreach ($availableWorkspace as $ws) {
$availableWorkspaceList[] = array ($ws,$ws
$availableWorkspaceList[] = array($ws,$ws
);
}
$aField['LOGIN_VERIFY_MSG'] = G::loadTranslation( 'LOGIN_VERIFY_MSG' );
$aField['LOGIN_VERIFY_MSG'] = G::loadTranslation('LOGIN_VERIFY_MSG');
//Get Server Configuration
$oServerConf = & ServerConf::getSingleton();
$oServerConf = ServerConf::getSingleton();
$availableLangArray = $this->getLanguagesList();
$this->includeExtJSLib( 'ux/virtualkeyboard' );
$this->setJSVar( 'sysLang', SYS_LANG );
$this->includeExtJS( 'main/sysLogin' );
$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() );
$this->setVar('logo_company', $this->getCompanyLogo());
$this->setVar('pmos_version', System::getVersion());
$footerText = G::LoadTranslation('ID_COPYRIGHT_FROM') . date( 'Y' ) . G::LoadTranslation('ID_COPYRIGHT_COL');
$footerText = G::LoadTranslation('ID_COPYRIGHT_FROM') . date('Y') . G::LoadTranslation('ID_COPYRIGHT_COL');
$adviseText = G::LoadTranslation('ID_COLOSA_AND_CERTIFIED_PARTNERS');
$this->setVar( 'footer_text', $footerText );
$this->setVar( 'advise_text', $adviseText );
$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('flyNotify', $flyNotify);
}
$this->setJSVar( 'languages', $availableLangArray );
$this->setJSVar( 'workspaces', $availableWorkspaceList );
$this->setJSVar( 'wsPrivate', $oServerConf->getProperty( 'LOGIN_NO_WS' ) );
$this->setJSVar('languages', $availableLangArray);
$this->setJSVar('workspaces', $availableWorkspaceList);
$this->setJSVar('wsPrivate', $oServerConf->getProperty('LOGIN_NO_WS'));
$this->setJSVar( 'defaultLang', 'en' );
$this->setJSVar( 'defaultWS', '' );
$this->setJSVar('defaultLang', 'en');
$this->setJSVar('defaultWS', '');
$loginScript = $this->getHeadPublisher()->getExtJsLibraries();
$loginScript .= $this->getHeadPublisher()->getExtJsScripts();
@@ -345,56 +345,56 @@ class Main extends Controller
$this->render();
}
public function forgotPassword ($httpData)
public function forgotPassword($httpData)
{
$this->setResponseType( 'json' );
$this->setResponseType('json');
global $RBAC;
$rbacUser = new RbacUsers();
$user = new Users();
try {
$userData = $rbacUser->getByUsername( $httpData->username );
$userData = $rbacUser->getByUsername($httpData->username);
if (! $userData) {
$msg = G::LoadTranslation( 'ID_USER' ) . ' <b>' . $httpData->username . '</b> ' . G::LoadTranslation( 'ID_IS_NOT_REGISTERED' );
throw new Exception( $msg );
$msg = G::LoadTranslation('ID_USER') . ' <b>' . $httpData->username . '</b> ' . 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' ) . ' <b>' . $httpData->username . '</b>';
throw new Exception( $msg );
if (trim($userData['USR_EMAIL']) != trim($httpData->email)) {
$msg = G::LoadTranslation('ID_EMAIL_DOES_NOT_MATCH_FOR_USER') . ' <b>' . $httpData->username . '</b>';
throw new Exception($msg);
}
$newPass = G::generate_password();
$aData['USR_UID'] = $userData['USR_UID'];
$aData['USR_PASSWORD'] = Bootstrap::hashPassword( $newPass );
$aData['USR_PASSWORD'] = Bootstrap::hashPassword($newPass);
$rbacUser->update( $aData );
$user->update( $aData );
$rbacUser->update($aData);
$user->update($aData);
$subject = G::loadTranslation( 'ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE' );
$subject = G::loadTranslation('ID_PROCESSMAKER_FORGOT_PASSWORD_SERVICE');
$template = new TemplatePower( PATH_TPL . 'main/forgotPassword.tpl' );
$template = new TemplatePower(PATH_TPL . 'main/forgotPassword.tpl');
$template->prepare();
$template->assign( 'server', $_SERVER['SERVER_NAME'] );
$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('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', '' );
$template->assign('footer', '');
$body = $template->getOutputContent();
G::sendMail( '', 'ProcessMaker Service', $httpData->email, $subject, $body );
G::sendMail('', 'ProcessMaker Service', $httpData->email, $subject, $body);
$result->success = true;
$result->message = G::LoadTranslation( 'ID_NEW_PASSWORD_SENT' );
$result->message = G::LoadTranslation('ID_NEW_PASSWORD_SENT');
} catch (Exception $e) {
$result->success = false;
$result->message = $e->getMessage();
@@ -407,7 +407,7 @@ class Main extends Controller
* Private Functions *
* *
*/
private function getMenu ()
private function getMenu()
{
global $G_MAIN_MENU;
global $G_SUB_MENU;
@@ -421,37 +421,37 @@ class Main extends Controller
$G_ID_MENU_SELECTED = 'BPMN';
$oMenu = new Menu();
$menus = $oMenu->generateArrayForTemplate( $G_MAIN_MENU, 'SelectedMenu', 'mainMenu', $G_MENU_SELECTED, $G_ID_MENU_SELECTED );
$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'], 'cases/main') !== false) {
$menus[$i]['target'] = str_replace('cases/main', 'cases/main_init', $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'], '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'], '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'] );
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'] );
$menus[$i]['elementclass'] = preg_replace(array('/class=/','/"/'
), array('',''
), $menus[$i]['elementclass']);
}
return $menus;
}
private function resolveUrlToTabIndex ($url)
private function resolveUrlToTabIndex($url)
{
if (strpos( $url, 'cases/main' ) !== false) {
if (strpos($url, 'cases/main') !== false) {
$activeTab = 0;
} elseif (strpos( $url, 'processes/main' ) !== false) {
} elseif (strpos($url, 'processes/main') !== false) {
$activeTab = 1;
} elseif (strpos( $url, 'dashboard/main' ) !== false) {
} elseif (strpos($url, 'dashboard/main') !== false) {
$activeTab = 2;
} elseif (strpos( $url, 'setup/main' ) !== false) {
} elseif (strpos($url, 'setup/main') !== false) {
$activeTab = 3;
} else {
$activeTab = 0;
@@ -460,24 +460,24 @@ class Main extends Controller
return $activeTab;
}
private function getCompanyLogo ()
private function getCompanyLogo()
{
$sCompanyLogo = '/images/processmaker2.logo2.png';
if (!empty(config("system.workspace"))) {
if (($aFotoSelect = $this->memcache->get( 'aFotoSelect' )) === false) {
$oLogoR = new ReplacementLogo();
$aFotoSelect = $oLogoR->getNameLogo( (isset( $_SESSION['USER_LOGGED'] )) ? $_SESSION['USER_LOGGED'] : '' );
$this->memcache->set( 'aFotoSelect', $aFotoSelect, 1 * 3600 );
$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 (is_array($aFotoSelect)) {
$sFotoSelect = trim($aFotoSelect['DEFAULT_LOGO_NAME']);
$sWspaceSelect = trim($aFotoSelect['WORKSPACE_LOGO_NAME']);
}
}
if (class_exists( 'ProcessMaker\Plugins\PluginRegistry' )) {
if (class_exists('ProcessMaker\Plugins\PluginRegistry')) {
$oPluginRegistry = PluginRegistry::loadSingleton();
$logoPlugin = $oPluginRegistry->getCompanyLogo( $sCompanyLogo );
$logoPlugin = $oPluginRegistry->getCompanyLogo($sCompanyLogo);
if ($logoPlugin != '/images/processmaker2.logo2.png') {
$sCompanyLogo = $logoPlugin;
} elseif (isset( $sFotoSelect ) && $sFotoSelect != '' && ! (strcmp( $sWspaceSelect, config("system.workspace") ))) {
@@ -488,67 +488,67 @@ class Main extends Controller
return $sCompanyLogo;
}
public function getLanguagesList ()
public function getLanguagesList()
{
$Translations = new Translation;
$translationsTable = $Translations->getTranslationEnvironments();
if (($languagesList = $this->memcache->get( 'languagesList' )) === false) {
$languagesList = array ();
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'] ) )) . ')';
$LANG_NAME = $locale['LANGUAGE'] . ' (' . (ucwords(strtolower($locale['COUNTRY']))) . ')';
} else {
$LANG_NAME = $locale['LANGUAGE'];
}
$languagesList[] = array ($LANG_ID,$LANG_NAME
$languagesList[] = array($LANG_ID,$LANG_NAME
);
}
$this->memcache->set( 'languagesList', $languagesList, 1 * 3600 );
$this->memcache->set('languagesList', $languagesList, 1 * 3600);
}
return $languagesList;
}
private function getWorkspacesAvailable ()
private function getWorkspacesAvailable()
{
$oServerConf = & ServerConf::getSingleton();
$oServerConf = ServerConf::getSingleton();
$dir = PATH_DB;
$filesArray = array ();
if (file_exists( $dir )) {
if ($handle = opendir( $dir )) {
while (false !== ($file = readdir( $handle ))) {
$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 )) {
if (file_exists(PATH_DB . $file . '/db.php')) {
if (! $oServerConf->isWSDisabled($file)) {
$filesArray[] = $file;
}
}
}
}
closedir( $handle );
closedir($handle);
}
}
sort( $filesArray, SORT_STRING );
sort($filesArray, SORT_STRING);
return $filesArray;
}
private function getUserRole ()
private function getUserRole()
{
global $RBAC;
$rolCode = str_replace( '_', ' ', $RBAC->aUserInfo['PROCESSMAKER']['ROLE']['ROL_CODE'] );
$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 );
$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'];
@@ -559,19 +559,19 @@ class Main extends Controller
/**
* binding G::SendTemporalMessage() to Javascript routine Ext.msgBoxSlider.msgTopCenter()
*/
private function getFlyNotify ()
private function getFlyNotify()
{
if (! isset( $_SESSION['G_MESSAGE'] )) {
if (! isset($_SESSION['G_MESSAGE'])) {
return false;
}
$flyNotify['title'] = isset( $_SESSION['G_MESSAGE_TITLE'] ) ? $_SESSION['G_MESSAGE_TITLE'] : '';
$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'] )) {
unset($_SESSION['G_MESSAGE']);
if (isset($_SESSION['G_MESSAGE_TYPE'])) {
$flyNotify['type'] = $_SESSION['G_MESSAGE_TYPE'];
unset( $_SESSION['G_MESSAGE_TYPE'] );
unset($_SESSION['G_MESSAGE_TYPE']);
} else {
$flyNotify['type'] = '';
}
@@ -581,22 +581,22 @@ class Main extends Controller
case 'alert':
case 'warning':
case 'tmp-warning':
$flyNotify['title'] = G::loadTranslation( 'ID_WARNING' );
$flyNotify['title'] = G::loadTranslation('ID_WARNING');
break;
case 'error':
case 'tmp-error':
$flyNotify['title'] = G::loadTranslation( 'ID_ERROR' );
$flyNotify['title'] = G::loadTranslation('ID_ERROR');
break;
case 'tmp-info':
case 'info':
$flyNotify['title'] = G::loadTranslation( 'ID_INFO' );
$flyNotify['title'] = G::loadTranslation('ID_INFO');
break;
case 'success':
case 'ok':
$flyNotify['title'] = G::loadTranslation( 'ID_SUCCESS' );
$flyNotify['title'] = G::loadTranslation('ID_SUCCESS');
break;
}
$flyNotify['title'] = strtoupper( $flyNotify['title'] );
$flyNotify['title'] = strtoupper($flyNotify['title']);
}
//TODO make dinamic
$flyNotify['time'] = 5;
@@ -605,18 +605,18 @@ class Main extends Controller
return $this->flyNotify;
}
private function setFlyNotify ($type, $title, $text, $time = 5)
private function setFlyNotify($type, $title, $text, $time = 5)
{
$this->flyNotify = array ('type' => $type,'title' => $title,'text' => $text,'time' => $time
$this->flyNotify = array('type' => $type,'title' => $title,'text' => $text,'time' => $time
);
$_SESSION['G_MESSAGE'] = $text;
$_SESSION['G_MESSAGE_TYPE'] = $type;
}
private function getInUrlError ()
private function getInUrlError()
{
if (isset( $_GET['errno'] )) {
if (isset($_GET['errno'])) {
switch ($_GET['errno']) {
case '1':
$trnLabel = 'ID_USER_HAVENT_RIGHTS_PAGE';
@@ -628,13 +628,13 @@ class Main extends Controller
$trnLabel = 'ID_USER_HAVENT_RIGHTS_PAGE';
break;
}
$this->setFlyNotify( 'error', 'ERROR', G::loadTranslation( $trnLabel ) );
$this->setFlyNotify('error', 'ERROR', G::loadTranslation($trnLabel));
}
}
private function getActiveTab ($activeTab)
private function getActiveTab($activeTab)
{
if (! is_numeric( $activeTab )) {
if (! is_numeric($activeTab)) {
switch ($activeTab) {
case 'home':
$activeTab = 0;
@@ -658,48 +658,47 @@ class Main extends Controller
return $activeTab;
}
private function getUrlGetParams ()
private function getUrlGetParams()
{
$urlGetParams = '';
foreach ($_GET as $key => $value) {
$urlGetParams .= $urlGetParams == '' ? $key : "&" . $key;
$urlGetParams .= trim( $value ) != '' ? '=' . $value : '';
$urlGetParams .= trim($value) != '' ? '=' . $value : '';
}
return $urlGetParams;
}
private function getUserFullName ()
private function getUserFullName()
{
return isset( $_SESSION['USR_FULLNAME'] ) ? $_SESSION['USR_FULLNAME'] : '';
return isset($_SESSION['USR_FULLNAME']) ? $_SESSION['USR_FULLNAME'] : '';
}
private function _getSystemInfo ()
private function _getSystemInfo()
{
if (getenv( 'HTTP_CLIENT_IP' )) {
$ip = getenv( 'HTTP_CLIENT_IP' );
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} else {
if (getenv( 'HTTP_X_FORWARDED_FOR' )) {
$ip = getenv( 'HTTP_X_FORWARDED_FOR' );
if (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} else {
$ip = getenv( 'REMOTE_ADDR' );
$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 );
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" )) {
$dbNetView = new Net( DB_HOST );
$dbNetView->loginDbServer( DB_USER, DB_PASS );
if (defined("DB_HOST")) {
$dbNetView = new Net(DB_HOST);
$dbNetView->loginDbServer(DB_USER, DB_PASS);
$dbConns = new DbConnections( '' );
$dbConns = new DbConnections('');
$availdb = '';
foreach ($dbConns->getDbServicesAvailables() as $key => $val) {
if ($availdb != '') {
@@ -709,7 +708,7 @@ class Main extends Controller
}
try {
$sMySQLVersion = $dbNetView->getDbServerVersion( DB_ADAPTER );
$sMySQLVersion = $dbNetView->getDbServerVersion(DB_ADAPTER);
} catch (Exception $oException) {
$sMySQLVersion = '?????';
}
@@ -725,7 +724,7 @@ class Main extends Controller
$pmuiVer = $mafeVer = $pmdynaformVer = "(unknown)";
}
$sysSection = G::loadTranslation('ID_SYSTEM_INFO' );
$sysSection = G::loadTranslation('ID_SYSTEM_INFO');
$pmSection = G::LoadTranslation('ID_PROCESS_INFORMATION');
$properties = array ();
@@ -738,76 +737,76 @@ class Main extends Controller
if (defined('SYSTEM_NAME')) {
$systemName = SYSTEM_NAME;
}
$properties[] = array ($systemName. ' Ver.', System::getVersion() . $ee, $pmSection);
$properties[] = array($systemName. ' Ver.', System::getVersion() . $ee, $pmSection);
$properties[] = array("PMUI JS Lib. Ver.", $pmuiVer, $pmSection);
$properties[] = array("MAFE JS Lib. Ver.", $mafeVer, $pmSection);
$properties[] = array("PM Dynaform JS Lib. Ver.", $pmdynaformVer, $pmSection);
if (file_exists(PATH_DATA. 'log/upgrades.log')) {
$properties[] = array (G::LoadTranslation('ID_UPGRADES_PATCHES'), '<a href="#" onclick="showUpgradedLogs(); return false;">' . G::LoadTranslation( 'ID_UPGRADE_VIEW_LOG') . '</a>' ,$pmSection);
$properties[] = array(G::LoadTranslation('ID_UPGRADES_PATCHES'), '<a href="#" onclick="showUpgradedLogs(); return false;">' . G::LoadTranslation('ID_UPGRADE_VIEW_LOG') . '</a>' ,$pmSection);
} else {
$properties[] = array (G::LoadTranslation('ID_UPGRADES_PATCHES'), G::LoadTranslation( 'ID_UPGRADE_NEVER_UPGRADE') ,$pmSection);
$properties[] = array(G::LoadTranslation('ID_UPGRADES_PATCHES'), G::LoadTranslation('ID_UPGRADE_NEVER_UPGRADE') ,$pmSection);
}
$properties[] = array (G::LoadTranslation('ID_OPERATING_SYSTEM') ,$redhat,$sysSection
$properties[] = array(G::LoadTranslation('ID_OPERATING_SYSTEM') ,$redhat,$sysSection
);
$properties[] = array (G::LoadTranslation('ID_TIME_ZONE') ,(defined( 'TIME_ZONE' )) ? TIME_ZONE : "Unknown",$sysSection
$properties[] = array(G::LoadTranslation('ID_TIME_ZONE') ,(defined('TIME_ZONE')) ? TIME_ZONE : "Unknown",$sysSection
);
$properties[] = array (G::LoadTranslation('ID_WEB_SERVER') ,getenv( 'SERVER_SOFTWARE' ),$sysSection
$properties[] = array(G::LoadTranslation('ID_WEB_SERVER') ,getenv('SERVER_SOFTWARE'),$sysSection
);
$properties[] = array (G::LoadTranslation('ID_SERVER_NAME') ,getenv( 'SERVER_NAME' ),$pmSection
$properties[] = array(G::LoadTranslation('ID_SERVER_NAME') ,getenv('SERVER_NAME'),$pmSection
);
$properties[] = array (G::LoadTranslation('ID_SERVER_IP') ,$this->lookup( $ip ),$sysSection
$properties[] = array(G::LoadTranslation('ID_SERVER_IP') ,$this->lookup($ip),$sysSection
);
$properties[] = array (G::LoadTranslation('ID_PHP_VERSION') ,phpversion(),$sysSection
$properties[] = array(G::LoadTranslation('ID_PHP_VERSION') ,phpversion(),$sysSection
);
if (defined( "DB_HOST" )) {
$properties[] = array (G::LoadTranslation('ID_DATABASE') ,$dbNetView->dbName( DB_ADAPTER ) . ' (Version ' . $sMySQLVersion . ')',$pmSection
if (defined("DB_HOST")) {
$properties[] = array(G::LoadTranslation('ID_DATABASE') ,$dbNetView->dbName(DB_ADAPTER) . ' (Version ' . $sMySQLVersion . ')',$pmSection
);
$properties[] = array (G::LoadTranslation('ID_DATABASE_SERVER') ,DB_HOST,$pmSection
$properties[] = array(G::LoadTranslation('ID_DATABASE_SERVER') ,DB_HOST,$pmSection
);
$properties[] = array (G::LoadTranslation('ID_DATABASE_NAME') ,DB_NAME,$pmSection
$properties[] = array(G::LoadTranslation('ID_DATABASE_NAME') ,DB_NAME,$pmSection
);
$properties[] = array (G::LoadTranslation('ID_AVAILABLE_DB') ,$availdb,$sysSection
$properties[] = array(G::LoadTranslation('ID_AVAILABLE_DB') ,$availdb,$sysSection
);
} else {
$properties[] = array (G::LoadTranslation('ID_DATABASE') ,"Not defined",$pmSection
$properties[] = array(G::LoadTranslation('ID_DATABASE') ,"Not defined",$pmSection
);
$properties[] = array (G::LoadTranslation('ID_DATABASE_SERVER') ,"Not defined",$pmSection
$properties[] = array(G::LoadTranslation('ID_DATABASE_SERVER') ,"Not defined",$pmSection
);
$properties[] = array (G::LoadTranslation('ID_DATABASE_NAME') ,"Not defined",$pmSection
$properties[] = array(G::LoadTranslation('ID_DATABASE_NAME') ,"Not defined",$pmSection
);
$properties[] = array (G::LoadTranslation('ID_AVAILABLE_DB') ,"Not defined",$sysSection
$properties[] = array(G::LoadTranslation('ID_AVAILABLE_DB') ,"Not defined",$sysSection
);
}
$properties[] = array ( G::LoadTranslation('ID_WORKSPACE') ,!empty(config("system.workspace")) ? config("system.workspace") : "Not defined",$pmSection
);
$properties[] = array ( G::LoadTranslation('ID_SERVER_PROTOCOL') ,getenv( 'SERVER_PROTOCOL' ),$sysSection
$properties[] = array( G::LoadTranslation('ID_SERVER_PROTOCOL') ,getenv('SERVER_PROTOCOL'),$sysSection
);
$properties[] = array ( G::LoadTranslation('ID_SERVER_PORT') ,getenv( 'SERVER_PORT' ),$sysSection
$properties[] = array( G::LoadTranslation('ID_SERVER_PORT') ,getenv('SERVER_PORT'),$sysSection
);
//$sysSection[] = array('Remote Host', getenv ('REMOTE_HOST'), $sysSection);
$properties[] = array ( G::LoadTranslation('ID_SERVER_NAME') , getenv( 'SERVER_ADDR' ),$sysSection
$properties[] = array( G::LoadTranslation('ID_SERVER_NAME') , getenv('SERVER_ADDR'),$sysSection
);
$properties[] = array ( G::LoadTranslation('ID_USER_BROWSER') , getenv( 'HTTP_USER_AGENT' ),$sysSection
$properties[] = array( G::LoadTranslation('ID_USER_BROWSER') , getenv('HTTP_USER_AGENT'),$sysSection
);
return $properties;
}
private function lookup ($target)
private function lookup($target)
{
global $ntarget;
$msg = $target . ' => ';
//if (eregi ('[a-zA-Z]', $target))
if (preg_match( '[a-zA-Z]', $target )) {
if (preg_match('[a-zA-Z]', $target)) {
//Made compatible to PHP 5.3
$ntarget = gethostbyname( $target );
$ntarget = gethostbyname($target);
} else {
$ntarget = gethostbyaddr( $target );
$ntarget = gethostbyaddr($target);
}
$msg .= $ntarget;
return ($msg);
@@ -816,11 +815,10 @@ class Main extends Controller
/**
* Execute common reoutes after index() action load
*/
private function afterLoad ($httpData)
private function afterLoad($httpData)
{
if (isset( $httpData->i18 ) || isset( $httpData->i18n )) {
if (isset($httpData->i18) || isset($httpData->i18n)) {
$_SESSION['DEV_FLAG'] = true;
}
}
}