From a922754d1a2fd99b163ac36ddc854ea3c567cd04 Mon Sep 17 00:00:00 2001 From: "Paula V. Quispe" Date: Thu, 2 Jun 2016 10:23:09 -0400 Subject: [PATCH] HOR-61: new feature expiration date --- workflow/engine/classes/class.system.php | 1 + workflow/engine/controllers/adminProxy.php | 4 ++++ workflow/engine/methods/users/usersEdit.php | 11 +++++++++ workflow/engine/methods/users/usersInit.php | 11 +++++++++ workflow/engine/methods/users/usersNew.php | 10 ++++++++ workflow/engine/templates/admin/system.js | 26 +++++++++++++++++++++ workflow/engine/templates/users/users.js | 2 +- 7 files changed, 64 insertions(+), 1 deletion(-) diff --git a/workflow/engine/classes/class.system.php b/workflow/engine/classes/class.system.php index 9bc4e9242..2cb48a60d 100755 --- a/workflow/engine/classes/class.system.php +++ b/workflow/engine/classes/class.system.php @@ -57,6 +57,7 @@ class System 'wsdl_cache' => 1, 'memory_limit' => "256M", 'time_zone' => 'America/New_York', + 'expiration_year' => '1', 'memcached' => 0, 'memcached_server' => '', 'default_skin' => 'neoclassic', diff --git a/workflow/engine/controllers/adminProxy.php b/workflow/engine/controllers/adminProxy.php index c1e7e47d9..ee0433e04 100644 --- a/workflow/engine/controllers/adminProxy.php +++ b/workflow/engine/controllers/adminProxy.php @@ -64,6 +64,10 @@ class adminProxy extends HttpProxyController $updatedConf['time_zone'] = $httpData->time_zone; } + if ($sysConf['expiration_year'] != $httpData->expiration_year) { + $updatedConf['expiration_year'] = $httpData->expiration_year; + } + $httpData->memory_limit .= 'M'; if ($sysConf['memory_limit'] != $httpData->memory_limit) { $updatedConf['memory_limit'] = $httpData->memory_limit; diff --git a/workflow/engine/methods/users/usersEdit.php b/workflow/engine/methods/users/usersEdit.php index 4b321099a..1415fdc6c 100644 --- a/workflow/engine/methods/users/usersEdit.php +++ b/workflow/engine/methods/users/usersEdit.php @@ -13,6 +13,16 @@ $uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul; if ($postMaxSize < $uploadMaxSize) { $uploadMaxSize = $postMaxSize; } +//Add year by expiration date +$expirationDate = 1; +$envFile = PATH_CONFIG . 'env.ini'; +if (file_exists($envFile) ) { + $sysConf = System::getSystemConfiguration($envFile); + if(isset($sysConf['expiration_year']) && $sysConf['expiration_year']>0){ + $expirationDate = $sysConf['expiration_year']; + } +} + $languageManagement = 0; /*----------------------------------********---------------------------------*/ $licensedFeatures = & PMLicensedFeatures::getSingleton(); @@ -31,6 +41,7 @@ $oHeadPublisher->assign( 'MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') ' ); $oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']); $oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) { return [$value, $value]; }, DateTimeZone::listIdentifiers())); $oHeadPublisher->assign('__SYSTEM_UTC_TIME_ZONE__', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 1 : 0); +$oHeadPublisher->assign('EXPIRATION_DATE', (int)$expirationDate); $oHeadPublisher->assign('LANGUAGE_MANAGEMENT', $languageManagement); G::RenderPage( 'publish', 'extJs' ); diff --git a/workflow/engine/methods/users/usersInit.php b/workflow/engine/methods/users/usersInit.php index fbb7fae72..2f71826af 100644 --- a/workflow/engine/methods/users/usersInit.php +++ b/workflow/engine/methods/users/usersInit.php @@ -28,6 +28,16 @@ $uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul; if ($postMaxSize < $uploadMaxSize) { $uploadMaxSize = $postMaxSize; } +//Add year by expiration date +$expirationDate = 1; +$envFile = PATH_CONFIG . 'env.ini'; +if (file_exists($envFile) ) { + $sysConf = System::getSystemConfiguration($envFile); + if(isset($sysConf['expiration_year']) && $sysConf['expiration_year']>0){ + $expirationDate = $sysConf['expiration_year']; + } +} + $languageManagement = 0; /*----------------------------------********---------------------------------*/ $licensedFeatures = & PMLicensedFeatures::getSingleton(); @@ -51,6 +61,7 @@ $oHeadPublisher->assign( 'MODE', '' ); $oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']); $oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) { return [$value, $value]; }, DateTimeZone::listIdentifiers())); $oHeadPublisher->assign('__SYSTEM_UTC_TIME_ZONE__', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 1 : 0); +$oHeadPublisher->assign('EXPIRATION_DATE', (int)$expirationDate); $oHeadPublisher->assign('LANGUAGE_MANAGEMENT', $languageManagement); G::RenderPage( 'publish', 'extJs' ); diff --git a/workflow/engine/methods/users/usersNew.php b/workflow/engine/methods/users/usersNew.php index 0af4c3ab5..1fef6f10d 100644 --- a/workflow/engine/methods/users/usersNew.php +++ b/workflow/engine/methods/users/usersNew.php @@ -16,6 +16,15 @@ $uploadMaxSize = (int) $UPLOAD_MAX_SIZE * $mul; if ($postMaxSize < $uploadMaxSize) { $uploadMaxSize = $postMaxSize; } +//Add year by expiration date +$expirationDate = 1; +$envFile = PATH_CONFIG . 'env.ini'; +if (file_exists($envFile) ) { + $sysConf = System::getSystemConfiguration($envFile); + if(isset($sysConf['expiration_year']) && $sysConf['expiration_year']>0){ + $expirationDate = $sysConf['expiration_year']; + } +} $languageManagement = 0; @@ -36,6 +45,7 @@ $oHeadPublisher->assign('MAX_FILES_SIZE', ' (' . $UPLOAD_MAX_SIZE . ') '); $oHeadPublisher->assign('SYSTEM_TIME_ZONE', $arraySystemConfiguration['time_zone']); $oHeadPublisher->assign('TIME_ZONE_DATA', array_map(function ($value) { return [$value, $value]; }, DateTimeZone::listIdentifiers())); $oHeadPublisher->assign('__SYSTEM_UTC_TIME_ZONE__', (isset($_SESSION['__SYSTEM_UTC_TIME_ZONE__']) && $_SESSION['__SYSTEM_UTC_TIME_ZONE__'])? 1 : 0); +$oHeadPublisher->assign('EXPIRATION_DATE', (int)$expirationDate); $oHeadPublisher->assign('LANGUAGE_MANAGEMENT', $languageManagement); G::RenderPage( 'publish', 'extJs' ); diff --git a/workflow/engine/templates/admin/system.js b/workflow/engine/templates/admin/system.js index b260e8901..20a985bab 100644 --- a/workflow/engine/templates/admin/system.js +++ b/workflow/engine/templates/admin/system.js @@ -85,6 +85,31 @@ Ext.onReady(function(){ cmbTimeZone.setValue(sysConf.time_zone); + txtExpirationYear = new Ext.form.TextField({ + xtype: 'numberfield', + id : 'expiration_year', + name : 'expiration_year', + fieldLabel: _('ID_DEFAULT_EXPIRATION_YEAR'), + allowBlank: false, + allowNegative: false, + value: 1, + maxlength: 15, + minValue: 1, + validator: function(value){ + if(value > 0) { + return true; + } else { + PMExt.error( _('ID_ERROR'), _('ERROR_ONLY_POSITIVE_NUMBER')); + } + }, + listeners:{ + change: function(){ + changeSettings(); + } + } + }); + txtExpirationYear.setValue(sysConf.expiration_year); + saveButton = new Ext.Action({ text : _('ID_SAVE_SETTINGS'), disabled : true, @@ -122,6 +147,7 @@ Ext.onReady(function(){ } } } + ,txtExpirationYear ] }); diff --git a/workflow/engine/templates/users/users.js b/workflow/engine/templates/users/users.js index e1a31f3b8..c9164bda0 100755 --- a/workflow/engine/templates/users/users.js +++ b/workflow/engine/templates/users/users.js @@ -320,7 +320,7 @@ Ext.onReady(function () { editable : false, readOnly : readMode, width : 120, - value : (new Date().add(Date.YEAR, 1)).format("Y-m-d") + value : (new Date().add(Date.YEAR, EXPIRATION_DATE)).format("Y-m-d") }); storeCalendar = new Ext.data.Store({