Changeset 2429 for sandbox/workflow


Ignore:
Timestamp:
04/06/10 10:52:46 (14 years ago)
Author:
pedroerp
Message:

Ticket #993 - Melhorias internas na classe 'Settings' do módulo.

Location:
sandbox/workflow/branches/993
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sandbox/workflow/branches/993/inc/class.WorkflowObjects.inc.php

    r2418 r2429  
    2626        private $cache = array(); 
    2727 
    28         /** 
    29          * TODO We should remove this method.. 
    30          * Monta o ambiente requerido pelos métodos (somente se for necessário) 
    31          * @param bool $requireGalaxia Indica que os métodos da engine Galaxia são necessários 
    32          * @return void 
    33          * @access public 
    34          */ 
    35         private function assureEnvironment($requireGalaxia = true) 
    36         { 
    37                 if (!defined('PHPGW_API_INC')) 
    38                         define('PHPGW_API_INC', dirname(__FILE__) . '/../../phpgwapi/inc'); 
    39  
    40                 if ($requireGalaxia) 
    41                 { 
    42                         if (!function_exists('galaxia_get_config_values')) 
    43                         { 
    44                                 require_once 'engine/config.ajax.inc.php' ; 
    45                                 require_once 'engine/class.ajax_config.inc.php' ; 
    46                         } 
    47                 } 
    48         } 
    4928 
    5029        /** 
     
    5736                if (!isset($this->cache['DBGalaxia'])) 
    5837                { 
    59                         /* make sure the environment is set */ 
    60                         $this->assureEnvironment(); 
    61  
    6238                        /* check if all configuration is OK */ 
    6339                        $dedicatedDB = true; 
     
    10581                if (!isset($this->cache['DBExpresso'])) 
    10682                { 
    107                         /* make sure the environment is set */ 
    108                         $this->assureEnvironment(false); 
    109  
    11083                        /* connect to the database */ 
    11184                        $this->cache['DBExpresso'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
     
    136109                if (!isset($this->cache['DBWorkflow'])) 
    137110                { 
    138                         /* make sure the environment is set */ 
    139                         $this->assureEnvironment(); 
    140  
    141111                        /* connect to the database */ 
    142112                        $this->cache['DBWorkflow'] = Factory::newInstance('WorkflowWatcher', Factory::newInstance('db')); 
     
    167137                if (!isset($this->cache['ldap'])) 
    168138                { 
    169                         /* make sure the environment is set */ 
    170                         $this->assureEnvironment(); 
    171  
    172139                        /* which ldap host to connect? */ 
    173140                        $ldapHost = Settings::get('workflow', 'ldap', 'host'); 
     
    190157                                                        ); 
    191158                } 
    192  
    193159                return $this->cache['ldap']; 
    194160        } 
  • sandbox/workflow/branches/993/inc/common.inc.php

    r2418 r2429  
    8383require_once WF_LIB_ROOT . 'settings/Settings.php'; 
    8484 
    85 Settings::load(); 
    86  
    8785$GLOBALS['workflow']['workflowObjects'] = Factory::getInstance('WorkflowObjects'); 
    8886?> 
  • sandbox/workflow/branches/993/lib/settings/Settings.php

    r2418 r2429  
    1111 
    1212/** 
    13  *  
     13 * General settings class. This class should be used to centralize all settings 
     14 * used by the module. 
    1415 * 
    1516 * @package Settings 
     
    1718 * @author Pedro Eugênio Rocha - pedro.eugenio.rocha@gmail.com 
    1819 */ 
    19  
    2020class Settings { 
    2121 
     
    2525         *                                              an exception when someone asks for it. 
    2626         * @access private 
     27         * @static 
    2728         */ 
    2829        private static $_configs = array( 
     
    7172        ); 
    7273 
    73         private static $loaded_from_db = false; 
     74        /** 
     75         * @var boolean $_isLoaded Stores whether the settings are loaded or not. 
     76         * @access private 
     77         * @static 
     78         */ 
     79        private static $_isLoaded = false; 
    7480 
    7581 
     
    109115                } 
    110116 
    111                 /* check if the setting was loaded */ 
    112                 $methodName = "populate" . ucfirst(strtolower($args[0])); 
    113                 self::$methodName(); 
    114  
     117                /* check if we already load the settings */ 
     118                if (!self::$_isLoaded) 
     119                        self::_load(); 
    115120 
    116121                /* retrieving the setting. More 'for' programming. */ 
     
    121126 
    122127 
    123         public static function load() { 
     128        /** 
     129         * Loads settings into $_configs private array. 
     130         * 
     131         * @access private 
     132         * @return void 
     133         * @static 
     134         */ 
     135        private static function _load() { 
    124136 
     137                /* loading global variables into $_configs */ 
    125138                self::$_configs['expresso']['db']['name'] = $GLOBALS['phpgw_info']['server']['db_name']; 
    126139                self::$_configs['expresso']['db']['host'] = $GLOBALS['phpgw_info']['server']['db_host']; 
     
    131144 
    132145                self::$_configs['expresso']['ldap']['host'] = $GLOBALS['phpgw_info']['server']['ldap_host']; 
    133         } 
    134146 
    135         private static function populateWorkflow() { 
    136  
    137                 $values = self::loadFromDb(); 
     147                /* loading database settings */ 
     148                $config = &Factory::newInstance('config', 'workflow'); 
     149                $values = $config->read_repository(); 
    138150 
    139151                self::$_configs['workflow']['intranet_subnetworks'] = $values['intranet_subnetworks']; 
     
    157169                self::$_configs['workflow']['ldap']['password'] = $values['ldap_password']; 
    158170                self::$_configs['workflow']['ldap']['follow_referrals'] = $values['ldap_follow_referrals']; 
    159         } 
    160171 
    161         private static function populateExpresso() {} 
    162  
    163  
    164         private static function loadFromDb() { 
    165  
    166                 /* */ 
    167                 $config = &Factory::newInstance('config', 'workflow'); 
    168                 $values = $config->read_repository(); 
    169  
    170                 /* 
    171                 foreach ($values as $key => $value) { 
    172                         self::$_configs[$key] = $value; 
    173                 } 
    174                 self::$loaded_from_db = true; 
    175                 */ 
    176                 return $values; 
     172                /* the settings are already loaded. No need to call this method again. */ 
     173                self::$_isLoaded = true; 
    177174        } 
    178175} 
Note: See TracChangeset for help on using the changeset viewer.