PM-4255 "Agregar soporte de licencia para multitimezone" SOLVED

Issue:
    Agregar soporte de licencia para multitimezone
Cause:
    New feature
Solution:
    Licence validations added
This commit is contained in:
Victor Saisa Lopez
2015-12-04 16:43:45 -04:00
parent 5e75b0047d
commit bbd0d687bf
6 changed files with 80 additions and 45 deletions

View File

@@ -444,7 +444,6 @@ class WebApplication
define("PATH_CONTROLLERS", PATH_CORE . "controllers" . PATH_SEP);
define("PATH_SERVICES_REST", PATH_CORE . "services" . PATH_SEP . "rest" . PATH_SEP);
\Bootstrap::registerSystemClasses();
$arraySystemConfiguration = \System::getSystemConfiguration();
@@ -497,8 +496,6 @@ class WebApplication
$arraySystemConfiguration = \System::getSystemConfiguration('', '', SYS_SYS);
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
//Do not change any of these settings directly, use env.ini instead
ini_set('display_errors', $arraySystemConfiguration['display_errors']);
ini_set('error_reporting', $arraySystemConfiguration['error_reporting']);
@@ -506,14 +503,12 @@ class WebApplication
ini_set('default_charset', 'UTF-8'); //??
ini_set('memory_limit', $arraySystemConfiguration['memory_limit']);
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 'UTC' : $arraySystemConfiguration['time_zone']); //Set Time Zone
define('DEBUG_SQL_LOG', $arraySystemConfiguration['debug_sql']);
define('DEBUG_TIME_LOG', $arraySystemConfiguration['debug_time']);
define('DEBUG_CALENDAR_LOG', $arraySystemConfiguration['debug_calendar']);
define('MEMCACHED_ENABLED', $arraySystemConfiguration['memcached']);
define('MEMCACHED_SERVER', $arraySystemConfiguration['memcached_server']);
define('TIME_ZONE', ini_get('date.timezone'));
define('SYS_SKIN', $arraySystemConfiguration['default_skin']);
require_once (PATH_DB . SYS_SYS . "/db.php");
@@ -573,6 +568,18 @@ class WebApplication
\Propel::init(PATH_CONFIG . "databases.php");
//Set Time Zone
/*----------------------------------********---------------------------------*/
if (\PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
}
/*----------------------------------********---------------------------------*/
ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 'UTC' : $arraySystemConfiguration['time_zone']); //Set Time Zone
define('TIME_ZONE', ini_get('date.timezone'));
//Return
return true;
}

View File

@@ -234,15 +234,19 @@ class Installer
$this->log("Write: " . $db_file . " => " . ((!$ff) ? $ff : "OK") . "\n", $ff === false);
fclose($fp);
//Generate the env.ini file
$envIniFile = $path_site . 'env.ini';
$content = 'system_utc_time_zone = 1' . "\n";
/*----------------------------------********---------------------------------*/
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
//Generate the env.ini file
$envIniFile = $path_site . 'env.ini';
$content = 'system_utc_time_zone = 1' . "\n";
$fp = @fopen($envIniFile, 'w');
$this->log('Create: ' . $envIniFile . ' => ' . ((!$fp)? $fp : 'OK') . "\n", $fp === false);
$ff = @fputs($fp, $content, strlen($content));
$this->log('Write: ' . $envIniFile . ' => ' . ((!$ff)? $ff : 'OK') . "\n", $ff === false);
fclose($fp);
$fp = @fopen($envIniFile, 'w');
$this->log('Create: ' . $envIniFile . ' => ' . ((!$fp)? $fp : 'OK') . "\n", $fp === false);
$ff = @fputs($fp, $content, strlen($content));
$this->log('Write: ' . $envIniFile . ' => ' . ((!$ff)? $ff : 'OK') . "\n", $ff === false);
fclose($fp);
}
/*----------------------------------********---------------------------------*/
//Set data
$this->setPartner();

View File

@@ -780,12 +780,16 @@ class Installer extends Controller
$this->installLog( G::LoadTranslation('ID_CREATING', SYS_LANG, Array($db_file) ));
file_put_contents( $db_file, $dbText );
//Generate the env.ini file
$envIniFile = $path_site . 'env.ini';
$content = 'system_utc_time_zone = 1' . "\n";
/*----------------------------------********---------------------------------*/
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
//Generate the env.ini file
$envIniFile = $path_site . 'env.ini';
$content = 'system_utc_time_zone = 1' . "\n";
$this->installLog(G::LoadTranslation('ID_CREATING', SYS_LANG, [$envIniFile]));
file_put_contents($envIniFile, $content);
$this->installLog(G::LoadTranslation('ID_CREATING', SYS_LANG, [$envIniFile]));
file_put_contents($envIniFile, $content);
}
/*----------------------------------********---------------------------------*/
//Generate the databases.php file
$databases_file = $path_site . 'databases.php';

View File

@@ -181,11 +181,15 @@ try {
$_SESSION['USR_USERNAME'] = $usr;
}
//Update User Time Zone
if (isset($_POST['form']['BROWSER_TIME_ZONE'])) {
$user = new Users();
$user->update(['USR_UID' => $_SESSION['USER_LOGGED'], 'USR_TIME_ZONE' => $_POST['form']['BROWSER_TIME_ZONE']]);
/*----------------------------------********---------------------------------*/
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
//Update User Time Zone
if (isset($_POST['form']['BROWSER_TIME_ZONE'])) {
$user = new Users();
$user->update(['USR_UID' => $_SESSION['USER_LOGGED'], 'USR_TIME_ZONE' => $_POST['form']['BROWSER_TIME_ZONE']]);
}
}
/*----------------------------------********---------------------------------*/
//Set User Time Zone
$user = UsersPeer::retrieveByPK($_SESSION['USER_LOGGED']);
@@ -202,27 +206,31 @@ try {
$_SESSION['USR_TIME_ZONE'] = $userTimeZone;
}
if (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) {
$dateTime = new \ProcessMaker\Util\DateTime();
/*----------------------------------********---------------------------------*/
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
if (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__']) {
$dateTime = new \ProcessMaker\Util\DateTime();
$timeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($_SESSION['USR_TIME_ZONE']);
$timeZoneOffset = $dateTime->getTimeZoneOffsetByTimeZoneId($_SESSION['USR_TIME_ZONE']);
if ($timeZoneOffset === false || $timeZoneOffset != (int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET'])) {
$_SESSION['__TIME_ZONE_FAILED__'] = true;
$_SESSION['USR_USERNAME'] = $usr;
$_SESSION['USR_PASSWORD'] = $pwd;
if ($timeZoneOffset === false || $timeZoneOffset != (int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET'])) {
$_SESSION['__TIME_ZONE_FAILED__'] = true;
$_SESSION['USR_USERNAME'] = $usr;
$_SESSION['USR_PASSWORD'] = $pwd;
$_SESSION['BROWSER_TIME_ZONE'] = $dateTime->getTimeZoneIdByTimeZoneOffset((int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET']), false);
$_SESSION['BROWSER_TIME_ZONE'] = $dateTime->getTimeZoneIdByTimeZoneOffset((int)($_POST['form']['BROWSER_TIME_ZONE_OFFSET']), false);
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => '', 'timeZoneFailed' => 1, 'userTimeZone' => $_SESSION['USR_TIME_ZONE'], 'browserTimeZone' => $_SESSION['BROWSER_TIME_ZONE']]);
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
if (strpos($_SERVER['HTTP_REFERER'], 'home/login') !== false) {
$d = serialize(['u' => $usr, 'p' => $pwd, 'm' => '', 'timeZoneFailed' => 1, 'userTimeZone' => $_SESSION['USR_TIME_ZONE'], 'browserTimeZone' => $_SESSION['BROWSER_TIME_ZONE']]);
$urlLogin = $urlLogin . '?d=' . base64_encode($d);
}
G::header('Location: ' . $urlLogin);
exit(0);
}
G::header('Location: ' . $urlLogin);
exit(0);
}
}
/*----------------------------------********---------------------------------*/
//Set data
$aUser = $RBAC->userObj->load($_SESSION['USER_LOGGED']);

View File

@@ -139,6 +139,7 @@ if (isset ($_SESSION['USER_LOGGED'])) {
}
//end log
/*----------------------------------********---------------------------------*/
$timeZoneFailed = false;
if (isset($_SESSION['__TIME_ZONE_FAILED__']) && $_SESSION['__TIME_ZONE_FAILED__']) {
@@ -148,6 +149,7 @@ if (isset($_SESSION['__TIME_ZONE_FAILED__']) && $_SESSION['__TIME_ZONE_FAILED__'
$userTimeZone = $_SESSION['USR_TIME_ZONE'];
$browserTimeZone = $_SESSION['BROWSER_TIME_ZONE'];
}
/*----------------------------------********---------------------------------*/
//start new session
@session_destroy();
@@ -191,7 +193,6 @@ if (in_array(G::encryptOld($licenseManager->result), array('38afd7ae34bd5e3e6fc1
G::RenderPage('publish');
die();
}
/*----------------------------------********---------------------------------*/
if ($timeZoneFailed) {
$dateTime = new \ProcessMaker\Util\DateTime();
@@ -222,6 +223,7 @@ if ($timeZoneFailed) {
G::RenderPage('publish');
exit(0);
}
/*----------------------------------********---------------------------------*/
//translation
//$Translations = G::getModel("Translation");

View File

@@ -303,12 +303,6 @@ if ((preg_match("/msie/i", $_SERVER ['HTTP_USER_AGENT']) != 1 ||
}
session_start();
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($config['system_utc_time_zone']) == 1;
$_GET = \ProcessMaker\Util\DateTime::convertDataToUtc($_GET);
$_POST = \ProcessMaker\Util\DateTime::convertDataToUtc($_POST);
$_REQUEST = \ProcessMaker\Util\DateTime::convertDataToUtc($_REQUEST);
//$e_all = defined( 'E_DEPRECATED' ) ? E_ALL & ~ E_DEPRECATED : E_ALL;
//$e_all = defined( 'E_STRICT' ) ? $e_all & ~ E_STRICT : $e_all;
//$e_all = $config['debug'] ? $e_all : $e_all & ~ E_NOTICE;
@@ -329,7 +323,7 @@ ini_set( 'short_open_tag', 'On' );
ini_set( 'default_charset', "UTF-8" );
ini_set( 'memory_limit', $config['memory_limit'] );
ini_set( 'soap.wsdl_cache_enabled', $config['wsdl_cache'] );
ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 'UTC' : $config['time_zone']); //Set Time Zone
ini_set('date.timezone', $config['time_zone']); //Set Time Zone
define( 'DEBUG_SQL_LOG', $config['debug_sql'] );
define( 'DEBUG_SQL', $config['debug'] );
@@ -337,7 +331,6 @@ define( 'DEBUG_TIME_LOG', $config['debug_time'] );
define( 'DEBUG_CALENDAR_LOG', $config['debug_calendar'] );
define( 'MEMCACHED_ENABLED', $config['memcached'] );
define( 'MEMCACHED_SERVER', $config['memcached_server'] );
define('TIME_ZONE', ini_get('date.timezone'));
define ('WS_IN_LOGIN', isset($config['WS_IN_LOGIN']) ? $config['WS_IN_LOGIN'] : 'serverconf');
@@ -691,6 +684,23 @@ if (defined( 'DEBUG_SQL_LOG' ) && DEBUG_SQL_LOG) {
Propel::init( PATH_CORE . "config/databases.php" );
}
//Set Time Zone
/*----------------------------------********---------------------------------*/
if (PMLicensedFeatures::getSingleton()->verifyfeature('oq3S29xemxEZXJpZEIzN01qenJUaStSekY4cTdJVm5vbWtVM0d4S2lJSS9qUT0=')) {
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($config['system_utc_time_zone']) == 1;
}
/*----------------------------------********---------------------------------*/
ini_set('date.timezone', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 'UTC' : $config['time_zone']); //Set Time Zone
define('TIME_ZONE', ini_get('date.timezone'));
/*----------------------------------********---------------------------------*/
$_GET = \ProcessMaker\Util\DateTime::convertDataToUtc($_GET);
$_POST = \ProcessMaker\Util\DateTime::convertDataToUtc($_POST);
$_REQUEST = \ProcessMaker\Util\DateTime::convertDataToUtc($_REQUEST);
/*----------------------------------********---------------------------------*/
Creole::registerDriver( 'dbarray', 'creole.contrib.DBArrayConnection' );
// Session Initializations