diff --git a/config_override.php b/config_override.php index b0c374e6fe369bbe1168b1699dd2b5efcc1d09ca..458b5a665acf429939cdda39151f40f01aa5d613 100644 --- a/config_override.php +++ b/config_override.php @@ -10,3 +10,11 @@ //Maximum number of Mailboxes in mail converter $max_mailboxes = 3; + +/** + * Configure runtime connectors to customization in core files. + * Ex: Sessions are currently handled by PHP default session handler. + * This can be customized using runtime connector hook and avoid core file modifications. + * array('session' => 'Vtiger_CustomSession_Handler') + */ +$runtime_connectors = array(); \ No newline at end of file diff --git a/include/utils/utils.php b/include/utils/utils.php index e1c93af892ba823fa64b3b4915351cddf075b78e..8f567566d834c4b281a0484dad6b294b8e5cb328 100755 --- a/include/utils/utils.php +++ b/include/utils/utils.php @@ -40,6 +40,7 @@ require_once 'vtlib/Vtiger/Deprecated.php'; require_once 'includes/runtime/Cache.php'; require_once 'modules/Vtiger/helpers/Util.php'; require_once 'vtlib/Vtiger/AccessControl.php'; +require_once 'includes/runtime/Configs.php'; // Constants to be defined here // For Migration status. diff --git a/includes/http/Session.php b/includes/http/Session.php index 789812e98096ac066cbe34c4ea8f386558a7a2b9..2c8257059f4bdf92062e61b7b0976f2bbd5309db 100644 --- a/includes/http/Session.php +++ b/includes/http/Session.php @@ -8,6 +8,16 @@ * All Rights Reserved. ************************************************************************************/ +/** + * Override default user-session storage functions if custom session connector exist. + */ +$runtime_configs = Vtiger_Runtime_Configs::getInstance(); +$custom_session_handlerclass = $runtime_configs->getConnector('session'); +if($custom_session_handlerclass) { + $handler = $custom_session_handlerclass::getInstance(); + session_set_save_handler($handler, true); +} + // Import dependencies include_once 'libraries/HTTP_Session2/HTTP/Session2.php'; diff --git a/includes/runtime/Cache.php b/includes/runtime/Cache.php index e89b800e96f62963a6a9e6dfdb1e8d5f4ddf4765..8f0f544b4618bd4dbb40175a396d60b551117239 100644 --- a/includes/runtime/Cache.php +++ b/includes/runtime/Cache.php @@ -17,7 +17,9 @@ class Vtiger_Cache { protected $connector; private function __construct() { - $this->connector = Vtiger_Cache_Connector::getInstance(); + $runtime_configs = Vtiger_Runtime_Configs::getInstance(); + $connector_class = $runtime_configs->getConnector('cache', 'Vtiger_Cache_Connector'); + $this->connector = $connector_class::getInstance(); } public static function getInstance(){ diff --git a/includes/runtime/Configs.php b/includes/runtime/Configs.php new file mode 100644 index 0000000000000000000000000000000000000000..6c7e446131315260c457ab3ad5021a092a602365 --- /dev/null +++ b/includes/runtime/Configs.php @@ -0,0 +1,44 @@ +<?php +/*+*********************************************************************************** + * The contents of this file are subject to the vtiger CRM Public License Version 1.0 + * ("License"); You may not use this file except in compliance with the License + * The Original Code is: vtiger CRM Open Source + * The Initial Developer of the Original Code is vtiger. + * Portions created by vtiger are Copyright (C) vtiger. + * All Rights Reserved. + *************************************************************************************/ + + require_once 'includes/runtime/BaseModel.php'; + + class Vtiger_Runtime_Configs extends Vtiger_Base_Model { + + private static $instance = false; + + public static function getInstance() { + if(self::$instance === false) { + self::$instance = new self(); + } + + return self::$instance; + } + + /** + * Function to fetch runtime connectors configured in config_override.php + * @params $identifier - Connector identifier Ex: session + * @params $default - Default connector class name. + */ + public function getConnector($identifier, $default = '') { + global $runtime_connectors; + + $connector = ''; + if(isset($runtime_connectors[$identifier])) { + $connector = $runtime_connectors[$identifier]; + } + + if(empty($connector) && !empty($default)) { + $connector = $default; + } + + return $connector; + } + } \ No newline at end of file