コード例 #1
0
 /**
  * Check if version number has changed and perfom additional upgarde code
  * Furthermore assign array with module menu names for the top right
  * module html seletor
  *
  * @param array $data
  */
 function perform($data)
 {
     // get data of the client browser
     $this->_get_client_data();
     // get os related separator to set include path
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         $tmp_separator = ';';
     } else {
         $tmp_separator = ':';
     }
     // set include path to the PEAR packages
     ini_set('include_path', SF_BASE_DIR . 'modules/common/PEAR' . $tmp_separator . ini_get('include_path'));
     unset($tmp_separator);
     // set charset to utf-8
     ini_set('default_charset', 'utf-8');
     @header('Content-type: text/html; charset=utf-8');
     // Define base location
     define('SF_BASE_LOCATION', commonUtil::base_location());
     // init system config array
     $this->B->sys = array();
     // include system config array $this->B->sys
     if (file_exists(SF_BASE_DIR . 'data/common/config/config.php')) {
         include_once SF_BASE_DIR . 'data/common/config/config.php';
     }
     // if setup was done
     if ($this->B->sys['info']['status'] == TRUE) {
         // here you may create db connection and start a session.
         // .... things, which are required by all other modules
         // include session class
         include_once SF_BASE_DIR . 'modules/common/includes/class.session.php';
         @ob_start();
         /* Create new object of session class */
         $this->B->session =& new session();
         @ob_end_flush();
     } else {
         // switch to the admin section if we comes from the public section
         if (SF_SECTION == 'public') {
             @header('Location: ' . SF_BASE_LOCATION . '/' . SF_CONTROLLER . '?' . SF_ADMIN_CODE . '=1');
             exit;
         }
         // launch setup screen
         M(MOD_SYSTEM, 'get_view', array('m' => 'setup', 'view' => 'index'));
         // Send the output buffer to the client
         ob_end_flush();
         exit;
     }
     // Check for upgrade
     if (MOD_COMMON_VERSION != (string) $this->B->sys['module']['common']['version']) {
         // set the new version num of this module
         $this->B->sys['module']['common']['version'] = MOD_COMMON_VERSION;
         $this->B->system_update_flag = TRUE;
         // include here additional upgrade code
     }
     return SF_IS_VALID_ACTION;
 }
コード例 #2
0
 /**
  * Check if version number has changed and perfom additional upgarde code
  * Furthermore assign array with module menu names for the top right
  * module html seletor
  *
  * @param array $data
  */
 function perform($data)
 {
     // get os related separator to set include path
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         $tmp_separator = ';';
     } else {
         $tmp_separator = ':';
     }
     // set include path to the PEAR packages
     ini_set('include_path', SF_BASE_DIR . 'modules/common/PEAR' . $tmp_separator . ini_get('include_path'));
     unset($tmp_separator);
     // Define base location
     define('SF_BASE_LOCATION', commonUtil::base_location());
     // init system config array
     $this->B->sys = array();
     // include system config array $this->B->sys
     if (file_exists(SF_BASE_DIR . 'data/common/config/config.php')) {
         include_once SF_BASE_DIR . 'data/common/config/config.php';
     }
     // if setup was done
     if (isset($this->B->sys['info']['status']) && $this->B->sys['info']['status'] == TRUE) {
         // include PEAR DB class
         include_once SF_BASE_DIR . 'modules/common/PEAR/DB.php';
         $this->B->dsn = array('phptype' => $this->B->sys['db']['dbtype'], 'username' => $this->B->sys['db']['user'], 'password' => $this->B->sys['db']['passwd'], 'hostspec' => $this->B->sys['db']['host'], 'database' => $this->B->sys['db']['name']);
         $this->B->dboptions = array('debug' => 0, 'portability' => DB_PORTABILITY_NONE);
         $this->B->db =& DB::connect($this->B->dsn, $this->B->dboptions, TRUE);
         if (DB::isError($this->B->db)) {
             trigger_error('Cannot connect to the database: ' . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
         }
         // include session class
         include_once SF_BASE_DIR . 'modules/common/includes/class.session.php';
         @ob_start();
         /* Create new object of session class */
         $this->B->session =& new session();
         @ob_end_flush();
     } else {
         // switch to the admin section if we come from the public section
         if (SF_SECTION == 'public') {
             @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1');
             exit;
         }
         // launch setup screen
         M(MOD_SYSTEM, 'get_view', array('m' => 'setup', 'view' => 'index'));
         // Send the output buffer to the client
         ob_end_flush();
         exit;
     }
     // Check for upgrade
     if (MOD_COMMON_VERSION != (string) $this->B->sys['module']['common']['version']) {
         // include here additional upgrade code
         M(MOD_COMMON, 'upgrade');
         // set the new version num of this module
         $this->B->sys['module']['common']['version'] = MOD_COMMON_VERSION;
         $this->B->system_update_flag = TRUE;
     }
     if (SF_SECTION == 'admin') {
         $m_list = $GLOBALS['sf_module_list'];
         // sort handler array by name
         ksort($m_list);
         // assign template handler names array
         // this array is used to build the modul select form of the admin menu
         $this->B->tpl_mod_list = array();
         foreach ($m_list as $key => $value) {
             if (isset($value['menu_visibility']) && $value['menu_visibility'] == TRUE) {
                 $this->B->tpl_mod_list[$key] = $value;
             }
         }
     }
 }