From d2a5441ed80a6af4c76fc9371f0c3137d4926a95 Mon Sep 17 00:00:00 2001 From: skeeter Date: Sat, 1 Sep 2001 23:42:16 +0000 Subject: [PATCH] Now using GLOBALS. --- phpgwapi/inc/class.accounts_ldap.inc.php | 2 +- phpgwapi/inc/class.accounts_shared.inc.php | 24 +- phpgwapi/inc/class.acl.inc.php | 105 +++++--- phpgwapi/inc/class.applications.inc.php | 53 ++-- phpgwapi/inc/class.common.inc.php | 296 +++++++++------------ phpgwapi/inc/class.sessions.inc.php | 133 ++++----- 6 files changed, 276 insertions(+), 337 deletions(-) diff --git a/phpgwapi/inc/class.accounts_ldap.inc.php b/phpgwapi/inc/class.accounts_ldap.inc.php index 3d04722965..23270bfe9d 100644 --- a/phpgwapi/inc/class.accounts_ldap.inc.php +++ b/phpgwapi/inc/class.accounts_ldap.inc.php @@ -233,7 +233,7 @@ { static $name_list; - if(@isset($name_list[$account_lid])) + if(@isset($name_list[$account_lid]) && $name_list[$account_lid]) { return $name_list[$account_lid]; } diff --git a/phpgwapi/inc/class.accounts_shared.inc.php b/phpgwapi/inc/class.accounts_shared.inc.php index 3c41cb770a..fa5e0981b8 100644 --- a/phpgwapi/inc/class.accounts_shared.inc.php +++ b/phpgwapi/inc/class.accounts_shared.inc.php @@ -35,9 +35,7 @@ \**************************************************************************/ function accounts($account_id = '') { - global $phpgw, $phpgw_info; - - $this->db = $phpgw->db; + $this->db = $GLOBALS['phpgw']->db; if($account_id != '') { @@ -80,11 +78,10 @@ function membership($accountid = '') { - global $phpgw_info, $phpgw; $account_id = get_account_id($accountid); $security_equals = Array(); - $security_equals = $phpgw->acl->get_location_list_for_id('phpgw_group', 1, $account_id); + $security_equals = $GLOBALS['phpgw']->acl->get_location_list_for_id('phpgw_group', 1, $account_id); if ($security_equals == False) { @@ -104,7 +101,6 @@ function members ($accountid = '') { - global $phpgw_info, $phpgw; $account_id = get_account_id($accountid); $security_equals = Array(); @@ -133,10 +129,8 @@ */ function get_nextid($account_type='u') { - global $phpgw,$phpgw_info; - - if ($phpgw_info['server']['account_min_id']) { $min = $phpgw_info['server']['account_min_id']; } - if ($phpgw_info['server']['account_max_id']) { $max = $phpgw_info['server']['account_max_id']; } + if ($GLOBALS['phpgw_info']['server']['account_min_id']) { $min = $GLOBALS['phpgw_info']['server']['account_min_id']; } + if ($GLOBALS['phpgw_info']['server']['account_max_id']) { $max = $GLOBALS['phpgw_info']['server']['account_max_id']; } if ($account_type == 'g') { @@ -146,7 +140,7 @@ { $type = 'accounts'; } - $nextid = $phpgw->common->last_id($type,$min,$max); + $nextid = $GLOBALS['phpgw']->common->last_id($type,$min,$max); /* Loop until we find a free id */ $free = 0; @@ -155,14 +149,14 @@ //echo '
calling search for id: '.$nextid; if ($this->exists($nextid)) { - $nextid = $phpgw->common->next_id($type,$min,$max); + $nextid = $GLOBALS['phpgw']->common->next_id($type,$min,$max); } else { /* echo '
calling search for lid: '.$account_lid; */ if ($this->exists($account_lid)) { - $nextid = $phpgw->common->next_id($type,$min,$max); + $nextid = $GLOBALS['phpgw']->common->next_id($type,$min,$max); } else { @@ -170,8 +164,8 @@ } } } - if ($phpgw_info['server']['account_max_id'] && - ($nextid > $phpgw_info['server']['account_max_id'])) + if ($GLOBALS['phpgw_info']['server']['account_max_id'] && + ($nextid > $GLOBALS['phpgw_info']['server']['account_max_id'])) { return False; } diff --git a/phpgwapi/inc/class.acl.inc.php b/phpgwapi/inc/class.acl.inc.php index b88e3b4da0..15a020cf5b 100644 --- a/phpgwapi/inc/class.acl.inc.php +++ b/phpgwapi/inc/class.acl.inc.php @@ -60,11 +60,10 @@ */ function acl($account_id = '') { - global $phpgw, $phpgw_info; - $this->db = $phpgw->db; + $this->db = $GLOBALS['phpgw']->db; if($account_id != '') { - $this->account_id = get_account_id($account_id,$phpgw_info['user']['account_id']); + $this->account_id = get_account_id($account_id,$GLOBALS['phpgw_info']['user']['account_id']); } } @@ -83,7 +82,6 @@ */ function read_repository() { - global $phpgw, $phpgw_info; $sql = 'select * from phpgw_acl where (acl_account in ('.$this->account_id.', 0'; $groups = $this->get_location_list_for_id('phpgw_group', 1, $this->account_id); @@ -140,7 +138,8 @@ { if ($appname == False) { - $appname = $phpgw_info['flags']['currentapp']; + settype($appname,'string'); + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } $this->data[] = array('appname' => $appname, 'location' => $location, 'account' => $this->account_id, 'rights' => $rights); reset($this->data); @@ -160,7 +159,8 @@ { if ($appname == False) { - $appname = $phpgw_info['flags']['currentapp']; + settype($appname,'string'); + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } $count = count($this->data); reset ($this->data); @@ -185,7 +185,6 @@ function save_repository() { - global $phpgw, $phpgw_info; reset($this->data); $sql = 'delete from phpgw_acl where acl_account = '.$this->account_id; @@ -220,15 +219,15 @@ */ function get_rights($location,$appname = False) { - global $phpgw, $phpgw_info; if (count($this->data) == 0){ $this->read_repository(); } reset ($this->data); if ($appname == False) { - $appname = $phpgw_info['flags']['currentapp']; + settype($appname,'string'); + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } $count = count($this->data); - if ($count == 0 && $phpgw_info['server']['acl_default'] != 'deny'){ return True; } + if ($count == 0 && $GLOBALS['phpgw_info']['server']['acl_default'] != 'deny'){ return True; } $rights = 0; //for ($idx = 0; $idx < $count; ++$idx){ reset ($this->data); @@ -254,7 +253,6 @@ */ function check($location, $required, $appname = False) { - global $phpgw, $phpgw_info; $rights = $this->get_rights($location,$appname); return !!($rights & $required); } @@ -267,15 +265,14 @@ */ function get_specific_rights($location, $appname = False) { - global $phpgw, $phpgw_info; - if ($appname == False) { - $appname = $phpgw_info['flags']['currentapp']; + settype($appname,'string'); + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } $count = count($this->data); - if ($count == 0 && $phpgw_info['server']['acl_default'] != 'deny'){ return True; } + if ($count == 0 && $GLOBALS['phpgw_info']['server']['acl_default'] != 'deny'){ return True; } $rights = 0; reset ($this->data); @@ -313,11 +310,10 @@ */ function get_location_list($app, $required) { - global $phpgw, $phpgw_info; // User piece $sql = "select acl_location, acl_rights from phpgw_acl where acl_appname = '$app' "; $sql .= " and (acl_account in ('".$this->account_id."', 0"; // group 0 covers all users - $equalto = $phpgw->accounts->security_equals($this->account_id); + $equalto = $GLOBALS['phpgw']->accounts->security_equals($this->account_id); if (is_array($equalto) && count($equalto) > 0) { for ($idx = 0; $idx < count($equalto); ++$idx) @@ -352,14 +348,13 @@ function get_location_list($app, $required) { - global $phpgw, $phpgw_info; if ($appname == False) { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } $count = count($this->data); - if ($count == 0 && $phpgw_info['server']['acl_default'] != 'deny'){ return True; } + if ($count == 0 && $GLOBALS['phpgw_info']['server']['acl_default'] != 'deny'){ return True; } $rights = 0; reset ($this->data); @@ -412,7 +407,17 @@ */ function delete_repository($app, $location, $accountid = '') { - $account_id = get_account_id($accountid,$this->account_id); + static $cache_accountid; + + if($cache_accountid[$accountid]) + { + $account_id = $cache_accountid[$accountid]; + } + else + { + $account_id = get_account_id($accountid,$this->account_id); + $cache_accountid[$accountid] = $account_id; + } $sql = "delete from phpgw_acl where acl_appname like '".$app."'" . " and acl_location like '".$location."' and " . " acl_account = ".$account_id; @@ -429,8 +434,17 @@ */ function get_app_list_for_id($location, $required, $accountid = '') { - global $phpgw, $phpgw_info; - $account_id = get_account_id($accountid,$this->account_id); + static $cache_accountid; + + if($cache_accountid[$accountid]) + { + $account_id = $cache_accountid[$accountid]; + } + else + { + $account_id = get_account_id($accountid,$this->account_id); + $cache_accountid[$accountid] = $account_id; + } $sql = "select acl_appname, acl_rights from phpgw_acl where acl_location = '$location' and "; $sql .= 'acl_account = '.$account_id; $this->db->query($sql ,__LINE__,__FILE__); @@ -458,8 +472,17 @@ */ function get_location_list_for_id($app, $required, $accountid = '') { - global $phpgw, $phpgw_info; - $account_id = get_account_id($accountid); + static $cache_accountid; + + if($cache_accountid[$accountid]) + { + $account_id = $cache_accountid[$accountid]; + } + else + { + $account_id = get_account_id($accountid,$this->account_id); + $cache_accountid[$accountid] = $account_id; + } $sql = "select acl_location, acl_rights from phpgw_acl where acl_appname = '$app' and "; $sql .= "acl_account = ".$account_id; $this->db->query($sql ,__LINE__,__FILE__); @@ -487,10 +510,9 @@ */ function get_ids_for_location($location, $required, $app = False) { - global $phpgw, $phpgw_info; if ($app == False) { - $app = $phpgw_info['flags']['currentapp']; + $app = $GLOBALS['phpgw_info']['flags']['currentapp']; } $sql = "select acl_account, acl_rights from phpgw_acl where acl_appname = '$app' and "; $sql .= "acl_location = '".$location."'"; @@ -517,12 +539,19 @@ */ function get_user_applications($accountid = '') { - global $phpgw, $phpgw_info; + static $cache_accountid; + if($cache_accountid[$accountid]) + { + $account_id = $cache_accountid[$accountid]; + } + else + { + $account_id = get_account_id($accountid,$this->account_id); + $cache_accountid[$accountid] = $account_id; + } $db2 = $this->db; - - $account_id = get_account_id($accountid,$this->account_id); - $memberships = $phpgw->accounts->membership($account_id); + $memberships = $GLOBALS['phpgw']->accounts->membership($account_id); $sql = "select acl_appname, acl_rights from phpgw_acl where acl_location = 'run' and " . 'acl_account in '; $security = '('.$account_id; @@ -558,18 +587,15 @@ */ function get_grants($app='') { - global $phpgw, $phpgw_info; - $db2 = $this->db; if ($app=='') { - $app = $phpgw_info['flags']['currentapp']; + $app = $GLOBALS['phpgw_info']['flags']['currentapp']; } $sql = "select acl_account, acl_rights from phpgw_acl where acl_appname = '$app' and " . "acl_location in "; -// $security = "('". $phpgw_info['user']['account_id'] ."'"; $security = "('". $this->account_id ."'"; $myaccounts = CreateObject('phpgwapi.accounts'); $my_memberships = $myaccounts->membership($this->account_id); @@ -585,7 +611,7 @@ $accounts = Array(); if ($db2->num_rows() == 0) { - $grants[$phpgw_info['user']['account_id']] = (~ 0); + $grants[$GLOBALS['phpgw_info']['user']['account_id']] = (~ 0); return $grants; } while ($db2->next_record()) @@ -593,11 +619,6 @@ $grantor = $db2->f('acl_account'); $rights = $db2->f('acl_rights'); -// if($grantor == $phpgw_info['user']['account_id']) -// { -// continue; -// } - if(!isset($accounts[$grantor])) // cache the group-members for performance { @@ -629,7 +650,7 @@ } reset($accounts[$grantor]); } - $grants[$phpgw_info['user']['account_id']] = (~ 0); + $grants[$GLOBALS['phpgw_info']['user']['account_id']] = (~ 0); return $grants; } } //end of acl class diff --git a/phpgwapi/inc/class.applications.inc.php b/phpgwapi/inc/class.applications.inc.php index 60d2ab649e..9e365428f7 100755 --- a/phpgwapi/inc/class.applications.inc.php +++ b/phpgwapi/inc/class.applications.inc.php @@ -43,8 +43,7 @@ */ function applications($account_id = '') { - global $phpgw, $phpgw_info; - $this->db = $phpgw->db; + $this->db = $GLOBALS['phpgw']->db; $this->account_id = get_account_id($account_id); } @@ -60,26 +59,26 @@ function read_repository() { global $phpgw, $phpgw_info; - if (!isset($phpgw_info['apps']) || - gettype($phpgw_info['apps']) != 'array') + if (!isset($GLOBALS['phpgw_info']['apps']) || + !is_array($GLOBALS['phpgw_info']['apps'])) { $this->read_installed_apps(); } $this->data = Array(); if($this->account_id == False) { return False; } - $apps = $phpgw->acl->get_user_applications($this->account_id); - reset($phpgw_info['apps']); - while ($app = each($phpgw_info['apps'])) + $apps = $GLOBALS['phpgw']->acl->get_user_applications($this->account_id); + reset($GLOBALS['phpgw_info']['apps']); + while ($app = each($GLOBALS['phpgw_info']['apps'])) { // $check = $phpgw->acl->check('run',1,$app[0]); $check = (isset($apps[$app[0]])?$apps[$app[0]]:False); if ($check) { $this->data[$app[0]] = array( - 'title' => $phpgw_info['apps'][$app[0]]['title'], + 'title' => $GLOBALS['phpgw_info']['apps'][$app[0]]['title'], 'name' => $app[0], 'enabled' => True, - 'status' => $phpgw_info['apps'][$app[0]]['status'] + 'status' => $GLOBALS['phpgw_info']['apps'][$app[0]]['status'] ); } } @@ -106,26 +105,25 @@ */ function add($apps) { - global $phpgw_info; - if(gettype($apps) == 'array') + if(is_array($apps)) { while($app = each($apps)) { $this->data[$app[1]] = array( - 'title' => $phpgw_info['apps'][$app[1]]['title'], + 'title' => $GLOBALS['phpgw_info']['apps'][$app[1]]['title'], 'name' => $app[1], 'enabled' => True, - 'status' => $phpgw_info['apps'][$app[1]]['status'] + 'status' => $GLOBALS['phpgw_info']['apps'][$app[1]]['status'] ); } } elseif(gettype($apps)) { $this->data[$apps] = array( - 'title' => $phpgw_info['apps'][$apps]['title'], + 'title' => $GLOBALS['phpgw_info']['apps'][$apps]['title'], 'name' => $apps, 'enabled' => True, - 'status' => $phpgw_info['apps'][$apps]['status'] + 'status' => $GLOBALS['phpgw_info']['apps'][$apps]['status'] ); } reset($this->data); @@ -167,13 +165,12 @@ */ function save_repository() { - global $phpgw; - $num_rows = $phpgw->acl->delete_repository("%%", 'run', $this->account_id); + $num_rows = $GLOBALS['phpgw']->acl->delete_repository("%%", 'run', $this->account_id); reset($this->data); while($app = each($this->data)) { if(!$this->is_system_enabled($app[0])) { continue; } - $phpgw->acl->add_repository($app[0],'run',$this->account_id,1); + $GLOBALS['phpgw']->acl->add_repository($app[0],'run',$this->account_id,1); } reset($this->data); return $this->data; @@ -185,7 +182,6 @@ function app_perms() { - global $phpgw, $phpgw_info; if (count($this->data) == 0) { $this->read_repository(); @@ -200,12 +196,11 @@ function read_account_specific() { - global $phpgw, $phpgw_info; - if (gettype($phpgw_info['apps']) != 'array') + if (!is_array($GLOBALS['phpgw_info']['apps'])) { $this->read_installed_apps(); } - $app_list = $phpgw->acl->get_app_list_for_id('run',1,$this->account_id); + $app_list = $GLOBALS['phpgw']->acl->get_app_list_for_id('run',1,$this->account_id); if(!$app_list) { reset($this->data); @@ -217,10 +212,10 @@ if ($this->is_system_enabled($app[1])) { $this->data[$app[1]] = array( - 'title' => $phpgw_info['apps'][$app[1]]['title'], + 'title' => $GLOBALS['phpgw_info']['apps'][$app[1]]['title'], 'name' => $app[1], 'enabled' => True, - 'status' => $phpgw_info['apps'][$app[1]]['status'] + 'status' => $GLOBALS['phpgw_info']['apps'][$app[1]]['status'] ); } } @@ -238,8 +233,7 @@ */ function read_installed_apps() { - global $phpgw_info; - $this->db->query("select * from phpgw_applications where app_enabled != '0' order by app_order asc",__LINE__,__FILE__); + $this->db->query('select * from phpgw_applications where app_enabled != 0 order by app_order asc',__LINE__,__FILE__); if($this->db->num_rows()) { while ($this->db->next_record()) @@ -247,7 +241,7 @@ $name = $this->db->f('app_name'); $title = $this->db->f('app_title'); $status = $this->db->f('app_enabled'); - $phpgw_info['apps'][$name] = array( + $GLOBALS['phpgw_info']['apps'][$name] = Array( 'title' => $title, 'name' => $name, 'enabled' => True, @@ -263,12 +257,11 @@ */ function is_system_enabled($appname) { - global $phpgw_info; - if(gettype($phpgw_info['apps']) != 'array') + if(!is_array($GLOBALS['phpgw_info']['apps'])) { $this->read_installed_apps(); } - if ($phpgw_info['apps'][$appname]['enabled']) + if ($GLOBALS['phpgw_info']['apps'][$appname]['enabled']) { return True; } diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 41ac387436..28f46136b4 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -134,12 +134,10 @@ */ function getInstalledLanguages() { - global $phpgw; - - $phpgw->db->query('select distinct lang from lang'); - while (@$phpgw->db->next_record()) + $GLOBALS['phpgw']->db->query('select distinct lang from lang'); + while (@$GLOBALS['phpgw']->db->next_record()) { - $installedLanguages[$phpgw->db->f('lang')] = $phpgw->db->f('lang'); + $installedLanguages[$GLOBALS['phpgw']->db->f('lang')] = $GLOBALS['phpgw']->db->f('lang'); } return $installedLanguages; @@ -156,10 +154,8 @@ */ function getPreferredLanguage() { - global $HTTP_ACCEPT_LANGUAGE; - // create a array of languages the user is accepting - $userLanguages = explode(',',$HTTP_ACCEPT_LANGUAGE); + $userLanguages = explode(',',$GLOBALS['HTTP_ACCEPT_LANGUAGE']); $supportedLanguages = $this->getInstalledLanguages(); // find usersupported language @@ -196,28 +192,26 @@ */ function ldapConnect($host = '', $dn = '', $passwd = '') { - global $phpgw_info, $phpgw; - if (! $host) { - $host = $phpgw_info['server']['ldap_host']; + $host = $GLOBALS['phpgw_info']['server']['ldap_host']; } if (! $dn) { - $dn = $phpgw_info['server']['ldap_root_dn']; + $dn = $GLOBALS['phpgw_info']['server']['ldap_root_dn']; } if (! $passwd) { - $passwd = $phpgw_info['server']['ldap_root_pw']; + $passwd = $GLOBALS['phpgw_info']['server']['ldap_root_pw']; } // connect to ldap server if (! $ds = ldap_connect($host)) { - $phpgw->log->message('F-Abort, Failed connecting to LDAP server'); - $phpgw->log->commit(); + $GLOBALS['phpgw']->log->message('F-Abort, Failed connecting to LDAP server'); + $GLOBALS['phpgw']->log->commit(); printf("Error: Can't connect to LDAP server %s!
",$host); return False; @@ -226,8 +220,8 @@ // bind as admin, we not to able to do everything if (! ldap_bind($ds,$dn,$passwd)) { - $phpgw->log->message('F-Abort, Failed binding to LDAP server'); - $phpgw->log->commit(); + $GLOBALS['phpgw']->log->message('F-Abort, Failed binding to LDAP server'); + $GLOBALS['phpgw']->log->commit(); printf("Error: Can't bind to LDAP server: %s!
",$dn); return False; @@ -247,13 +241,11 @@ */ function phpgw_exit($call_footer = False) { - global $phpgw; - if ($call_footer) { $this->phpgw_footer(); } - $phpgw->db->disconnect(); + $GLOBALS['phpgw']->db->disconnect(); exit; } /*! @@ -315,20 +307,18 @@ // This is a depreciated function - use ACL instead (jengo) function check_owner($record,$link,$label,$extravars = '') { - global $phpgw, $phpgw_info; - $this->debug_info[] = 'check_owner() is a depreciated function - use ACL instead'; - $s = ' ' . lang($label) . ' '; + $s = ' ' . lang($label) . ' '; if (ereg('^[0-9]+$',$record)) { - if ($record != $phpgw_info['user']['account_id']) + if ($record != $GLOBALS['phpgw_info']['user']['account_id']) { $s = ' '; } } else { - if ($record != $phpgw_info['user']['userid']) + if ($record != $GLOBALS['phpgw_info']['user']['userid']) { $s = ' '; } @@ -348,10 +338,9 @@ { if (! $lid && ! $firstname && ! $lastname) { - global $phpgw_info; - $lid = $phpgw_info['user']['account_lid']; - $firstname = $phpgw_info['user']['firstname']; - $lastname = $phpgw_info['user']['lastname']; + $lid = $GLOBALS['phpgw_info']['user']['account_lid']; + $firstname = $GLOBALS['phpgw_info']['user']['firstname']; + $lastname = $GLOBALS['phpgw_info']['user']['lastname']; } if ($lastname) @@ -392,14 +381,12 @@ */ function grab_owner_name($accountid = '') { - global $phpgw; - $account_id = get_account_id($accountid); - $db = $phpgw->db; + $db = $GLOBALS['phpgw']->db; $db->query('select account_lid,account_firstname,account_lastname from phpgw_accounts where account_id='.$account_id,__LINE__,__FILE__); $db->next_record(); - return $phpgw->common->display_fullname($db->f('account_lid'),$db->f('account_firstname'),$db->f('account_lastname')); + return $this->display_fullname($db->f('account_lid'),$db->f('account_firstname'),$db->f('account_lastname')); } /*! @@ -411,7 +398,6 @@ */ function create_tabs($tabs, $selected, $fontsize = '') { - global $phpgw_info; $output_text = ''; $ir = PHPGW_IMAGES_DIR; @@ -493,10 +479,9 @@ */ function get_app_dir($appname = '') { - global $phpgw_info; if ($appname == '') { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } if ($appname == 'home' || $appname == 'logout' || $appname == 'login') { @@ -528,11 +513,9 @@ */ function get_inc_dir($appname = '') { - global $phpgw_info; - if (! $appname) { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } if ($appname == 'home' || $appname == 'logout' || $appname == 'login') { @@ -581,7 +564,6 @@ */ function list_templates() { - global $phpgw_info; $d = dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates'); while ($entry=$d->read()) { @@ -592,7 +574,7 @@ if (file_exists ($f)) { include($f); - $list[$entry]['title'] = 'Use '.$phpgw_info['template'][$entry]['title'].'interface'; + $list[$entry]['title'] = 'Use '.$GLOBALS['phpgw_info']['template'][$entry]['title'].'interface'; } else { @@ -662,10 +644,9 @@ */ function get_image_dir($appname = '') { - global $phpgw_info; if ($appname == '') { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } if (empty($phpgw_info['server']['template_set'])) { @@ -673,7 +654,7 @@ } $imagedir = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/' - . $phpgw_info['server']['template_set'] . '/images'; + . $GLOBALS['phpgw_info']['server']['template_set'] . '/images'; $imagedir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default/images'; $imagedir_olddefault = PHPGW_SERVER_ROOT . '/' . $appname . '/images'; @@ -702,33 +683,31 @@ */ function get_image_path($appname = '') { - global $phpgw_info; - if ($appname == '') { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } - if (empty($phpgw_info['server']['template_set'])) + if (empty($GLOBALS['phpgw_info']['server']['template_set'])) { - $phpgw_info['server']['template_set'] = 'default'; + $GLOBALS['phpgw_info']['server']['template_set'] = 'default'; } - $imagedir = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images'; + $imagedir = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'; $imagedir_default = PHPGW_SERVER_ROOT . '/'.$appname.'/templates/default/images'; $imagedir_olddefault = PHPGW_SERVER_ROOT . '/'.$appname.'/images'; if (@is_dir ($imagedir)) { - return $phpgw_info['server']['webserver_url'].'/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images'; + return $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'; } elseif (@is_dir ($imagedir_default)) { - return $phpgw_info['server']['webserver_url'].'/'.$appname.'/templates/default/images'; + return $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/templates/default/images'; } elseif (@is_dir ($imagedir_olddefault)) { - return $phpgw_info['server']['webserver_url'].'/'.$appname.'/images'; + return $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$appname.'/images'; } else { @@ -738,23 +717,21 @@ function find_image($appname,$image) { - global $phpgw_info; - - $imagedir = '/'.$appname.'/templates/'.$phpgw_info['server']['template_set'].'/images'; + $imagedir = '/'.$appname.'/templates/'.$GLOBALS['phpgw_info']['server']['template_set'].'/images'; $imagedir_default = '/'.$appname.'/templates/default/images'; $imagedir_olddefault = '/'.$appname.'/images'; if(file_exists(PHPGW_SERVER_ROOT.$imagedir.'/'.$image)) { - $imgfile = $phpgw_info['server']['webserver_url'].$imagedir.'/'.$image; + $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$imagedir.'/'.$image; } elseif(file_exists(PHPGW_SERVER_ROOT.$imagedir_default.'/'.$image)) { - $imgfile = $phpgw_info['server']['webserver_url'].$imagedir_default.'/'.$image; + $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$imagedir_default.'/'.$image; } elseif(file_exists(PHPGW_SERVER_ROOT.$imagedir_olddefault.'/'.$image)) { - $imgfile = $phpgw_info['server']['webserver_url'].$imagedir_olddefault.'/'.$image; + $imgfile = $GLOBALS['phpgw_info']['server']['webserver_url'].$imagedir_olddefault.'/'.$image; } else { @@ -793,55 +770,53 @@ */ function navbar() { - global $phpgw_info, $phpgw; + $GLOBALS['phpgw_info']['navbar']['home']['title'] = 'Home'; + $GLOBALS['phpgw_info']['navbar']['home']['url'] = $GLOBALS['phpgw']->link('/index.php'); + $GLOBALS['phpgw_info']['navbar']['home']['icon'] = $this->image('phpgwapi','home.gif'); - $phpgw_info['navbar']['home']['title'] = 'Home'; - $phpgw_info['navbar']['home']['url'] = $phpgw->link('/index.php'); - $phpgw_info['navbar']['home']['icon'] = $this->image('phpgwapi','home.gif'); - - reset($phpgw_info['user']['apps']); - while ($permission = each($phpgw_info['user']['apps'])) + reset($GLOBALS['phpgw_info']['user']['apps']); + while ($permission = each($GLOBALS['phpgw_info']['user']['apps'])) { if (is_long($permission[0])) { continue; } - if ($phpgw_info['apps'][$permission[0]]['status'] != 2 && $phpgw_info['apps'][$permission[0]]['status'] != 3) + if ($GLOBALS['phpgw_info']['apps'][$permission[0]]['status'] != 2 && $GLOBALS['phpgw_info']['apps'][$permission[0]]['status'] != 3) { - $phpgw_info['navbar'][$permission[0]]['title'] = $phpgw_info['apps'][$permission[0]]['title']; - $phpgw_info['navbar'][$permission[0]]['url'] = $phpgw->link('/' . $permission[0] . '/index.php'); - $phpgw_info['navbar'][$permission[0]]['name'] = $permission[0]; + $GLOBALS['phpgw_info']['navbar'][$permission[0]]['title'] = $GLOBALS['phpgw_info']['apps'][$permission[0]]['title']; + $GLOBALS['phpgw_info']['navbar'][$permission[0]]['url'] = $GLOBALS['phpgw']->link('/' . $permission[0] . '/index.php'); + $GLOBALS['phpgw_info']['navbar'][$permission[0]]['name'] = $permission[0]; - $phpgw_info['navbar'][$permission[0]]['icon'] = $this->image($permission[0],'navbar.gif'); - if($phpgw_info['navbar'][$permission[0]]['icon'] == '') + $GLOBALS['phpgw_info']['navbar'][$permission[0]]['icon'] = $this->image($permission[0],'navbar.gif'); + if($GLOBALS['phpgw_info']['navbar'][$permission[0]]['icon'] == '') { - $phpgw_info['navbar'][$permission[0]]['icon'] = $this->image('phpgwapi','nonav.gif'); + $GLOBALS['phpgw_info']['navbar'][$permission[0]]['icon'] = $this->image('phpgwapi','nonav.gif'); } } } - $phpgw_info['navbar']['preferences']['title'] = 'preferences'; - $phpgw_info['navbar']['preferences']['url'] = $phpgw->link('/preferences/index.php'); - $phpgw_info['navbar']['preferences']['icon'] = $this->image('preferences','navbar.gif'); + $GLOBALS['phpgw_info']['navbar']['preferences']['title'] = 'preferences'; + $GLOBALS['phpgw_info']['navbar']['preferences']['url'] = $GLOBALS['phpgw']->link('/preferences/index.php'); + $GLOBALS['phpgw_info']['navbar']['preferences']['icon'] = $this->image('preferences','navbar.gif'); - if ($phpgw_info['flags']['currentapp'] == 'home' || $phpgw_info['flags']['currentapp'] == 'preferences' || $phpgw_info['flags']['currentapp'] == 'about') + if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'preferences' || $GLOBALS['phpgw_info']['flags']['currentapp'] == 'about') { $app = 'phpGroupWare'; } else { - $app = $phpgw_info['flags']['currentapp']; + $app = $GLOBALS['phpgw_info']['flags']['currentapp']; } // We handle this here becuase its special - $phpgw_info['navbar']['about']['title'] = lang('About x',$app); + $GLOBALS['phpgw_info']['navbar']['about']['title'] = lang('About x',$app); - $phpgw_info['navbar']['about']['url'] = $phpgw->link('/about.php','app='.$app); - $phpgw_info['navbar']['about']['icon'] = $this->image('phpgwapi','about.gif'); + $GLOBALS['phpgw_info']['navbar']['about']['url'] = $GLOBALS['phpgw']->link('/about.php','app='.$app); + $GLOBALS['phpgw_info']['navbar']['about']['icon'] = $this->image('phpgwapi','about.gif'); - $phpgw_info['navbar']['logout']['title'] = 'Logout'; - $phpgw_info['navbar']['logout']['url'] = $phpgw->link('/logout.php'); - $phpgw_info['navbar']['logout']['icon'] = $this->image('phpgwapi','logout.gif'); + $GLOBALS['phpgw_info']['navbar']['logout']['title'] = 'Logout'; + $GLOBALS['phpgw_info']['navbar']['logout']['url'] = $GLOBALS['phpgw']->link('/logout.php'); + $GLOBALS['phpgw_info']['navbar']['logout']['icon'] = $this->image('phpgwapi','logout.gif'); } /*! @@ -861,14 +836,12 @@ */ function phpgw_header() { - global $phpgw, $phpgw_info; - - include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $phpgw_info['server']['template_set'] + include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] . '/head.inc.php'); $this->navbar(False); - include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $phpgw_info['server']['template_set'] + include(PHPGW_INCLUDE_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info']['server']['template_set'] . '/navbar.inc.php'); - if (!@$phpgw_info['flags']['nonavbar'] && !@$phpgw_info['flags']['navbar_target']) + if (!@$GLOBALS['phpgw_info']['flags']['nonavbar'] && !@$GLOBALS['phpgw_info']['flags']['navbar_target']) { echo parse_navbar(); } @@ -876,9 +849,9 @@ function phpgw_footer() { - global $phpgw, $phpgw_info, $HTMLCOMPLIANT, $menuaction, $obj; + global $HTMLCOMPLIANT; - if (!isset($phpgw_info['flags']['nofooter']) || !$phpgw_info['flags']['nofooter']) + if (!isset($GLOBALS['phpgw_info']['flags']['nofooter']) || !$GLOBALS['phpgw_info']['flags']['nofooter']) { include(PHPGW_API_INC . '/footer.inc.php'); } @@ -903,10 +876,8 @@ */ function encrypt($data) { - global $phpgw_info, $phpgw; - $data = serialize($data); - return $phpgw->crypto->encrypt($data); + return $GLOBALS['phpgw']->crypto->encrypt($data); } /*! @function decrypt @@ -915,9 +886,7 @@ */ function decrypt($data) { - global $phpgw_info, $phpgw; - - $data = $phpgw->crypto->decrypt($data); + $data = $GLOBALS['phpgw']->crypto->decrypt($data); return unserialize($data); } /*! @@ -960,14 +929,12 @@ */ function encrypt_password($password) { - global $phpgw, $phpgw_info; - - if ($phpgw_info['server']['ldap_encryption_type'] == 'DES') + if ($GLOBALS['phpgw_info']['server']['ldap_encryption_type'] == 'DES') { $salt = $this->randomstring(2); $e_password = $this->des_cryptpasswd($password, $salt); } - if ($phpgw_info['server']['ldap_encryption_type'] == 'MD5') + if ($GLOBALS['phpgw_info']['server']['ldap_encryption_type'] == 'MD5') { //$salt = $this->randomstring(9); $salt = $this->randomstring(8); // patch @@ -986,7 +953,7 @@ if ($order == '') { settype($order,'array'); - $order[] = $phpgw_info['flags']['currentapp']; + $order[] = $GLOBALS['phpgw_info']['flags']['currentapp']; } /* First include the ordered apps hook file */ @@ -995,7 +962,7 @@ { $f = PHPGW_SERVER_ROOT . '/' . $appname . '/inc/hook_' . $location . '.inc.php'; if (file_exists($f) && - ( $phpgw_info['user']['apps'][$appname] || ( ($location == 'preferences') && $appname) ) ) + ( $GLOBALS['phpgw_info']['user']['apps'][$appname] || ( ($location == 'preferences') && $appname) ) ) { //echo '
including: ' . $f; include($f); @@ -1004,8 +971,8 @@ } /* Then add the rest */ - reset ($phpgw_info['user']['apps']); - while (list(,$p) = each($phpgw_info['user']['apps'])) + reset ($GLOBALS['phpgw_info']['user']['apps']); + while (list(,$p) = each($GLOBALS['phpgw_info']['user']['apps'])) { $appname = $p['name']; if (! isset($completed_hooks[$appname]) || $completed_hooks[$appname] != True) @@ -1030,14 +997,14 @@ global $phpgw, $phpgw_info, $PHP_VERSION; if (! $appname) { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } $SEP = filesystem_separator(); /* First include the ordered apps hook file */ $f = PHPGW_SERVER_ROOT . $SEP . $appname . $SEP . 'inc' . $SEP . 'hook_' . $location . '.inc.php'; if (file_exists($f) && - ( $phpgw_info['user']['apps'][$appname] || ( ($location == 'config') && $appname) ) ) + ( $GLOBALS['phpgw_info']['user']['apps'][$appname] || ( ($location == 'config') && $appname) ) ) { include($f); return True; @@ -1054,11 +1021,10 @@ */ function hook_count($location) { - global $phpgw, $phpgw_info; $count = 0; - reset($phpgw_info['user']['apps']); + reset($GLOBALS['phpgw_info']['user']['apps']); $SEP = filesystem_separator(); - while ($permission = each($phpgw_info['user']['apps'])) + while ($permission = each($GLOBALS['phpgw_info']['user']['apps'])) { $f = PHPGW_SERVER_ROOT . $SEP . $permission[0] . $SEP . 'inc' . $SEP . 'hook_' . $location . '.inc.php'; @@ -1073,11 +1039,10 @@ /* Wrapper to the session->appsession() */ function appsession($data = '##NOTHING##') { - global $phpgw_info, $phpgw; $this->debug_info[] = '$phpgw->common->appsession() is a depreciated function' . ' - use $phpgw->session->appsession() instead'; - return $phpgw->session->appsession('default','',$data); + return $GLOBALS['phpgw']->session->appsession('default','',$data); } /*! @@ -1088,19 +1053,17 @@ */ function show_date($t = '', $format = '') { - global $phpgw_info; - if (! $t) { $t = time(); } - $t = $t + ((60*60) * $phpgw_info['user']['preferences']['common']['tz_offset']); + $t = $t + ((60*60) * $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']); if (! $format) { - $format = $phpgw_info['user']['preferences']['common']['dateformat'] . ' - '; - if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12') + $format = $GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'] . ' - '; + if ($GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] == '12') { $format .= 'h:i:s a'; } @@ -1121,9 +1084,8 @@ */ function dateformatorder($yearstr,$monthstr,$daystr,$add_seperator = False) { - global $phpgw_info; - $dateformat = strtolower($phpgw_info['user']['preferences']['common']['dateformat']); - $sep = substr($phpgw_info['user']['preferences']['common']['dateformat'],1,1); + $dateformat = strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']); + $sep = substr($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],1,1); $dlarr[strpos($dateformat,'y')] = $yearstr; $dlarr[strpos($dateformat,'m')] = $monthstr; @@ -1148,10 +1110,8 @@ */ function formattime($hour,$min,$sec='') { - global $phpgw_info; - $h12 = $hour; - if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12') { + if ($GLOBALS['phpgw_info']['user']['preferences']['common']['timeformat'] == '12') { if ($hour >= 12) $ampm = ' pm'; else @@ -1180,32 +1140,30 @@ /* function get_email_passwd_ex() { - global $phpgw_info, $phpgw; - // ---- Create the email Message Class if needed ----- - if (isset($phpgw->msg)) + if (isset($GLOBALS['phpgw']->msg)) { $do_free_me = False; } else { - $phpgw->msg = CreateObject("email.mail_msg"); + $GLOBALS['phpgw']->msg = CreateObject('email.mail_msg'); $do_free_me = True; } // use the Msg class to obtain the appropriate password - $tmp_prefs = $phpgw->preferences->read(); + $tmp_prefs = $GLOBALS['phpgw']->preferences->read(); if (!isset($tmp_prefs['email']['passwd'])) { - $email_passwd = $phpgw_info['user']['passwd']; + $email_passwd = $GLOBALS['phpgw_info']['user']['passwd']; } else { - $email_passwd = $phpgw->msg->decrypt_email_passwd($tmp_prefs['email']['passwd']); + $email_passwd = $GLOBALS['phpgw']->msg->decrypt_email_passwd($tmp_prefs['email']['passwd']); } // cleanup and return if ($do_free_me) { - unset ($phpgw->msg); + unset ($GLOBALS['phpgw']->msg); } return $email_passwd; } @@ -1222,34 +1180,30 @@ */ function create_emailpreferences($prefs='',$accountid='') { - global $phpgw, $phpgw_info; - // ---- Create the email Message Class if needed ----- - if (isset($phpgw->msg)) + if (isset($GLOBALS['phpgw']->msg)) { $do_free_me = False; } else { - $phpgw->msg = CreateObject("email.mail_msg"); + $GLOBALS['phpgw']->msg = CreateObject('email.mail_msg'); $do_free_me = True; } // this sets the prederences into the phpgw_info structure - $phpgw->msg->create_email_preferences(); + $GLOBALS['phpgw']->msg->create_email_preferences(); // cleanup and return if ($do_free_me) { - unset ($phpgw->msg); + unset ($GLOBALS['phpgw']->msg); } } /* function create_emailpreferences($prefs,$accountid='') { - global $phpgw, $phpgw_info; - $account_id = get_account_id($accountid); // NEW EMAIL PASSWD METHOD (shared between SM and aeromail) @@ -1258,26 +1212,26 @@ // Add default preferences info if (!isset($prefs['email']['userid'])) { - if ($phpgw_info['server']['mail_login_type'] == 'vmailmgr') + if ($GLOBALS['phpgw_info']['server']['mail_login_type'] == 'vmailmgr') { - $prefs['email']['userid'] = $phpgw->accounts->id2name($account_id) - . '@' . $phpgw_info['server']['mail_suffix']; + $prefs['email']['userid'] = $GLOBALS['phpgw']->accounts->id2name($account_id) + . '@' . $GLOBALS['phpgw_info']['server']['mail_suffix']; } else { - $prefs['email']['userid'] = $phpgw->accounts->id2name($account_id); + $prefs['email']['userid'] = $GLOBALS['phpgw']->accounts->id2name($account_id); } } // Set Server Mail Type if not defined - if (empty($phpgw_info['server']['mail_server_type'])) + if (empty($GLOBALS['phpgw_info']['server']['mail_server_type'])) { - $phpgw_info['server']['mail_server_type'] = 'imap'; + $GLOBALS['phpgw_info']['server']['mail_server_type'] = 'imap'; } // OLD EMAIL PASSWD METHOD if (!isset($prefs['email']['passwd'])) { - $prefs['email']['passwd'] = $phpgw_info['user']['passwd']; + $prefs['email']['passwd'] = $GLOBALS['phpgw_info']['user']['passwd']; } else { @@ -1287,20 +1241,20 @@ if (!isset($prefs['email']['address'])) { - $prefs['email']['address'] = $phpgw->accounts->id2name($account_id) - . '@' . $phpgw_info['server']['mail_suffix']; + $prefs['email']['address'] = $GLOBALS['phpgw']->accounts->id2name($account_id) + . '@' . $GLOBALS['phpgw_info']['server']['mail_suffix']; } if (!isset($prefs['email']['mail_server'])) { - $prefs['email']['mail_server'] = $phpgw_info['server']['mail_server']; + $prefs['email']['mail_server'] = $GLOBALS['phpgw_info']['server']['mail_server']; } if (!isset($prefs['email']['mail_server_type'])) { - $prefs['email']['mail_server_type'] = $phpgw_info['server']['mail_server_type']; + $prefs['email']['mail_server_type'] = $GLOBALS['phpgw_info']['server']['mail_server_type']; } if (!isset($prefs['email']['imap_server_type'])) { - $prefs['email']['imap_server_type'] = $phpgw_info['server']['imap_server_type']; + $prefs['email']['imap_server_type'] = $GLOBALS['phpgw_info']['server']['imap_server_type']; } // These sets the mail_port server variable if ($prefs['email']['mail_server_type']=='imap') @@ -1313,7 +1267,7 @@ } // This is going to be used to switch to the nntp class if (isset($phpgw_info['flags']['newsmode']) && - $phpgw_info['flags']['newsmode']) + $GLOBALS['phpgw_info']['flags']['newsmode']) { $prefs['email']['mail_server_type'] = 'nntp'; } @@ -1356,7 +1310,7 @@ . lang('To correct this error for the future you will need to properly set the') . '
' . lang('permissions to the files/users directory') . '
' . lang('On *nix systems please type: x','chmod 770 ' - . $phpgw_info['server']['files_dir'] . '/users/'); + . $GLOBALS['phpgw_info']['server']['files_dir'] . '/users/'); break; case 35: $s .= lang('Account has been updated') . '

' . lang('Error renaming x x directory',lang('users'), @@ -1366,7 +1320,7 @@ . lang('To correct this error for the future you will need to properly set the') . '
' . lang('permissions to the files/users directory') . '
' . lang('On *nix systems please type: x','chmod 770 ' - . $phpgw_info['server']['files_dir'] . '/users/'); + . $GLOBALS['phpgw_info']['server']['files_dir'] . '/users/'); break; case 36: $s .= lang('Account has been created') . '

' . lang('Error creating x x directory',lang('users'), @@ -1376,7 +1330,7 @@ . lang('To correct this error for the future you will need to properly set the') . '
' . lang('permissions to the files/users directory') . '
' . lang('On *nix systems please type: x','chmod 770 ' - . $phpgw_info['server']['files_dir'] . '/users/'); + . $GLOBALS['phpgw_info']['server']['files_dir'] . '/users/'); break; case 37: $s .= lang('Group has been added') . '

' . lang('Error creating x x directory',lang('groups'),' ') @@ -1385,7 +1339,7 @@ . lang('To correct this error for the future you will need to properly set the') . '
' . lang('permissions to the files/users directory') . '
' . lang('On *nix systems please type: x','chmod 770 ' - . $phpgw_info['server']['files_dir'] . '/groups/'); + . $GLOBALS['phpgw_info']['server']['files_dir'] . '/groups/'); break; case 38: $s .= lang('Group has been deleted') . '

' . lang('Error deleting x x directory',lang('groups'),' ') @@ -1394,7 +1348,7 @@ . lang('To correct this error for the future you will need to properly set the') . '
' . lang('permissions to the files/users directory') . '
' . lang('On *nix systems please type: x','chmod 770 ' - . $phpgw_info['server']['files_dir'] . '/groups/'); + . $GLOBALS['phpgw_info']['server']['files_dir'] . '/groups/'); break; case 39: $s .= lang('Group has been updated') . '

' . lang('Error renaming x x directory',lang('groups'),' ') @@ -1403,7 +1357,7 @@ . lang('To correct this error for the future you will need to properly set the') . '
' . lang('permissions to the files/users directory') . '
' . lang('On *nix systems please type: x','chmod 770 ' - . $phpgw_info['server']['files_dir'] . '/groups/'); + . $GLOBALS['phpgw_info']['server']['files_dir'] . '/groups/'); break; case 40: $s .= lang('You have not entered a title').'.'; break; @@ -1552,28 +1506,26 @@ */ function next_id($appname,$min=0,$max=0) { - global $phpgw; - if (!$appname) { return -1; } - $phpgw->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'",__LINE__,__FILE__); - while( $phpgw->db->next_record() ) + $GLOBALS['phpgw']->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'",__LINE__,__FILE__); + while( $GLOBALS['phpgw']->db->next_record() ) { - $id = $phpgw->db->f("id"); + $id = $GLOBALS['phpgw']->db->f('id'); } if (empty($id) || !$id) { $id = 1; - $phpgw->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")",__LINE__,__FILE__); + $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")",__LINE__,__FILE__); } elseif($id<$min) { $id = $min; - $phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__); + $GLOBALS['phpgw']->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__); } elseif ($max && ($id > $max)) { @@ -1582,7 +1534,7 @@ else { $id = $id + 1; - $phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__); + $GLOBALS['phpgw']->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__); } return intval($id); @@ -1596,17 +1548,15 @@ */ function last_id($appname,$min=0,$max=0) { - global $phpgw; - if (!$appname) { return -1; } - $phpgw->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'",__LINE__,__FILE__); - while( $phpgw->db->next_record() ) + $GLOBALS['phpgw']->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'",__LINE__,__FILE__); + while( $GLOBALS['phpgw']->db->next_record() ) { - $id = $phpgw->db->f("id"); + $id = $GLOBALS['phpgw']->db->f('id'); } if (empty($id) || !$id) @@ -1619,12 +1569,12 @@ { $id = 1; } - $phpgw->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")",__LINE__,__FILE__); + $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")",__LINE__,__FILE__); } elseif($id<$min) { $id = $min; - $phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__); + $GLOBALS['phpgw']->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__); } elseif ($max && ($id > $max)) { diff --git a/phpgwapi/inc/class.sessions.inc.php b/phpgwapi/inc/class.sessions.inc.php index 41d53b67c6..3618b50450 100644 --- a/phpgwapi/inc/class.sessions.inc.php +++ b/phpgwapi/inc/class.sessions.inc.php @@ -48,12 +48,10 @@ \*************************************************************************/ function sessions() { - global $phpgw, $phpgw_info, $sessionid, $kp3; - - $this->db = $phpgw->db; - $this->db2 = $phpgw->db; - $this->sessionid = $sessionid; - $this->kp3 = $kp3; + $this->db = $GLOBALS['phpgw']->db; + $this->db2 = $GLOBALS['phpgw']->db; + $this->sessionid = $GLOBALS['sessionid']; + $this->kp3 = $GLOBALS['kp3']; } /*************************************************************************\ @@ -400,8 +398,6 @@ function create_server($login,$passwd) { - global $phpgw_info, $phpgw, $PHP_SELF; - $phpgw->interserver = CreateObject('phpgwapi.interserver'); $this->login = $login; $this->passwd = $passwd; @@ -416,7 +412,7 @@ } else { - $this->account_domain = $phpgw_info['server']['default_domain']; + $this->account_domain = $GLOBALS['phpgw_info']['server']['default_domain']; } $serverdata = array( @@ -424,50 +420,50 @@ 'username' => $this->account_lid, 'password' => $passwd ); - if (!$phpgw->interserver->auth($serverdata)) + if (!$GLOBALS['phpgw']->interserver->auth($serverdata)) { return False; exit; } - if (!$phpgw->interserver->exists($this->account_lid)) + if (!$GLOBALS['phpgw']->interserver->exists($this->account_lid)) { - $this->account_id = $phpgw->interserver->name2id($this->account_lid); + $this->account_id = $GLOBALS['phpgw']->interserver->name2id($this->account_lid); } - $phpgw_info['user']['account_id'] = $this->account_id; - $phpgw->interserver->serverid = $this->account_id; + $GLOBALS['phpgw_info']['user']['account_id'] = $this->account_id; + $GLOBALS['phpgw']->interserver->serverid = $this->account_id; - $this->sessionid = md5($phpgw->common->randomstring(10)); - $this->kp3 = md5($phpgw->common->randomstring(15)); + $this->sessionid = md5($GLOBALS['phpgw']->common->randomstring(10)); + $this->kp3 = md5($GLOBALS['phpgw']->common->randomstring(15)); - $phpgw->common->key = md5($this->kp3 . $this->sessionid . $phpgw_info['server']['encryptkey']); - $phpgw->common->iv = $phpgw_info['server']['mcrypt_iv']; - $cryptovars[0] = $phpgw->common->key; - $cryptovars[1] = $phpgw->common->iv; + $GLOBALS['phpgw']->common->key = md5($this->kp3 . $this->sessionid . $GLOBALS['phpgw_info']['server']['encryptkey']); + $GLOBALS['phpgw']->common->iv = $GLOBALS['phpgw_info']['server']['mcrypt_iv']; + $cryptovars[0] = $GLOBALS['phpgw']->common->key; + $cryptovars[1] = $GLOBALS['phpgw']->common->iv; $phpgw->crypto = CreateObject('phpgwapi.crypto', $cryptovars); //$this->read_repositories(False); - $phpgw_info['user'] = $this->user; - $phpgw_info['hooks'] = $this->hooks; + $GLOBALS['phpgw_info']['user'] = $this->user; + $GLOBALS['phpgw_info']['hooks'] = $this->hooks; $this->appsession('password','phpgwapi',base64_encode($this->passwd)); $session_flags = 'S'; $user_ip = $this->getuser_ip(); - $phpgw->db->transaction_begin(); - $phpgw->db->query("INSERT INTO phpgw_sessions VALUES ('" . $this->sessionid + $GLOBALS['phpgw']->db->transaction_begin(); + $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_sessions VALUES ('" . $this->sessionid . "','".$login."','" . $user_ip . "','" - . $now . "','" . $now . "','" . $PHP_SELF . "','" . $session_flags + . $now . "','" . $now . "','" . $GLOBALS['PHP_SELF'] . "','" . $session_flags . "')",__LINE__,__FILE__); - $phpgw->db->query("INSERT INTO phpgw_access_log VALUES ('" . $this->sessionid . "','" + $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_access_log VALUES ('" . $this->sessionid . "','" . "$login','" . $user_ip . "','$now','','" . $this->account_id . "')",__LINE__,__FILE__); - $this->appsession('account_previous_login','phpgwapi',$phpgw->auth->previous_login); - $phpgw->auth->update_lastlogin($this->account_id,$user_ip); - $phpgw->db->transaction_commit(); + $this->appsession('account_previous_login','phpgwapi',$GLOBALS['phpgw']->auth->previous_login); + $GLOBALS['phpgw']->auth->update_lastlogin($this->account_id,$user_ip); + $GLOBALS['phpgw']->db->transaction_commit(); return array($this->sessionid,$this->kp3); } @@ -475,21 +471,19 @@ // This will update the DateLastActive column, so the login does not expire function update_dla() { - global $phpgw_info, $phpgw, $PHP_SELF, $menuaction; - - if ($menuaction) + if ($GLOBALS['menuaction']) { - $action = $menuaction; + $action = $GLOBALS['menuaction']; } else { - $action = $PHP_SELF; + $action = $GLOBALS['PHP_SELF']; } - $phpgw->db->query("update phpgw_sessions set session_dla='" . time() . "', session_action='$action' " + $GLOBALS['phpgw']->db->query("update phpgw_sessions set session_dla='" . time() . "', session_action='$action' " . "where session_id='" . $this->sessionid."'",__LINE__,__FILE__); - $phpgw->db->query("update phpgw_app_sessions set session_dla='" . time() . "' " + $GLOBALS['phpgw']->db->query("update phpgw_app_sessions set session_dla='" . time() . "' " . "where sessionid='" . $this->sessionid."'",__LINE__,__FILE__); } @@ -547,8 +541,7 @@ if(!empty($this->user)) { $GLOBALS['phpgw']->preferences->data = $this->user['preferences']; - if (!isset($GLOBALS['phpgw_info']['apps']) || - gettype($GLOBALS['phpgw_info']['apps']) != 'array') + if (!isset($GLOBALS['phpgw_info']['apps']) || !is_array($GLOBALS['phpgw_info']['apps'])) { $GLOBALS['phpgw']->applications->read_installed_apps(); } @@ -567,12 +560,10 @@ function setup_cache() { - global $phpgw, $phpgw_info; - - $this->user = $phpgw->accounts->read_repository(); - $this->user['acl'] = $phpgw->acl->read_repository(); - $this->user['preferences'] = $phpgw->preferences->read_repository(); - $this->user['apps'] = $phpgw->applications->read_repository(); + $this->user = $GLOBALS['phpgw']->accounts->read_repository(); + $this->user['acl'] = $GLOBALS['phpgw']->acl->read_repository(); + $this->user['preferences'] = $GLOBALS['phpgw']->preferences->read_repository(); + $this->user['apps'] = $GLOBALS['phpgw']->applications->read_repository(); //@reset($this->data['user']['apps']); $this->user['domain'] = $this->account_domain; @@ -584,7 +575,7 @@ $this->user['account_lid'] = $this->account_lid; $this->user['userid'] = $this->account_lid; $this->user['passwd'] = @$this->passwd; - if(@$phpgw_info['server']['cache_phpgw_info']) + if(@$GLOBALS['phpgw_info']['server']['cache_phpgw_info']) { $this->appsession('phpgw_info_cache','phpgwapi',$this->user); } @@ -592,25 +583,21 @@ function delete_cache($accountid='') { - global $phpgw; - $account_id = get_account_id($accountid,$this->account_id); $query = "DELETE FROM phpgw_app_sessions WHERE loginid = '".$account_id."'" ." AND app = 'phpgwapi' and location = 'phpgw_info_cache'"; - $phpgw->db->query($query); + $GLOBALS['phpgw']->db->query($query); } function save_repositories() { - global $phpgw, $phpgw_info; - - $phpgw_info_temp = $phpgw_info; + $phpgw_info_temp = $GLOBALS['phpgw_info']; $phpgw_info_temp['user']['kp3'] = ''; $phpgw_info_temp['flags'] = array(); - if ($phpgw_info['server']['cache_phpgw_info']) + if ($GLOBALS['phpgw_info']['server']['cache_phpgw_info']) { $this->appsession('phpgw_info_cache','phpgwapi',$phpgw_info_temp); } @@ -618,11 +605,9 @@ function appsession($location = 'default', $appname = '', $data = '##NOTHING##') { - global $phpgw_info, $phpgw; - if (! $appname) { - $appname = $phpgw_info['flags']['currentapp']; + $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } /* This allows the user to put "" as the value. */ @@ -631,29 +616,29 @@ ." sessionid = '".$this->sessionid."' and loginid = '".$this->account_id."'" ." and app = '".$appname."' and location = '".$location."'"; - $phpgw->db->query($query,__LINE__,__FILE__); - $phpgw->db->next_record(); + $GLOBALS['phpgw']->db->query($query,__LINE__,__FILE__); + $GLOBALS['phpgw']->db->next_record(); // I added these into seperate steps for easier debugging - $data = $phpgw->db->f('content'); + $data = $GLOBALS['phpgw']->db->f('content'); // Changed by Skeeter 2001 Mar 04 0400Z // This was not properly decoding structures saved into session data properly -// $data = $phpgw->common->decrypt($data); +// $data = $GLOBALS['phpgw']->common->decrypt($data); // return stripslashes($data); - return $phpgw->crypto->decrypt($data); + return $GLOBALS['phpgw']->crypto->decrypt($data); } else { - $phpgw->db->query("select content from phpgw_app_sessions where " + $GLOBALS['phpgw']->db->query("select content from phpgw_app_sessions where " . "sessionid = '".$this->sessionid."' and loginid = '".$this->account_id."'" - . "and app = '".$appname."' and location = '".$location."'",__LINE__,__FILE__); + . " and app = '".$appname."' and location = '".$location."'",__LINE__,__FILE__); - $encrypteddata = $phpgw->crypto->encrypt($data); - if ($phpgw->db->num_rows()==0) { - $phpgw->db->query("INSERT INTO phpgw_app_sessions (sessionid,loginid,app,location,content,session_dla) " + $encrypteddata = $GLOBALS['phpgw']->crypto->encrypt($data); + if ($GLOBALS['phpgw']->db->num_rows()==0) { + $GLOBALS['phpgw']->db->query("INSERT INTO phpgw_app_sessions (sessionid,loginid,app,location,content,session_dla) " . "VALUES ('".$this->sessionid."','".$this->account_id."','".$appname . "','".$location."','".$encrypteddata."','" . time() . "')",__LINE__,__FILE__); } else { - $phpgw->db->query("update phpgw_app_sessions set content = '".$encrypteddata."'" + $GLOBALS['phpgw']->db->query("update phpgw_app_sessions set content = '".$encrypteddata."'" . "where sessionid = '".$this->sessionid."'" . "and loginid = '".$this->account_id."' and app = '".$appname."'" . "and location = '".$location."'",__LINE__,__FILE__); @@ -664,8 +649,6 @@ function restore() { - global $phpgw; - $sessionData = $this->appsession("sessiondata"); if (is_array($sessionData)) @@ -684,8 +667,6 @@ // save the current values of the variables function save() { - global $phpgw; - if (is_array($this->variableNames)) { reset($this->variableNames); @@ -824,22 +805,22 @@ } /* $url = str_replace('/?', '/index.php?', $url); - $webserver_url_count = strlen($phpgw_info['server']['webserver_url']); + $webserver_url_count = strlen($GLOBALS['phpgw_info']['server']['webserver_url']); $slash_check = strtolower(substr($url ,0,1)); - if (substr($url ,0,$webserver_url_count) != $phpgw_info['server']['webserver_url']) + if (substr($url ,0,$webserver_url_count) != $GLOBALS['phpgw_info']['server']['webserver_url']) { - $app = $phpgw_info['flags']['currentapp']; + $app = $GLOBALS['phpgw_info']['flags']['currentapp']; if ($slash_check == '/') { - $url = $phpgw_info['server']['webserver_url'] . $url; + $url = $GLOBALS['phpgw_info']['server']['webserver_url'] . $url; } elseif ($app == 'home' || $app == 'logout' || $app == 'login') { - $url = $phpgw_info['server']['webserver_url'].'/'.$url; + $url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$url; } else { - $url = $phpgw_info['server']['webserver_url'].'/'.$app.'/'.$url; + $url = $GLOBALS['phpgw_info']['server']['webserver_url'].'/'.$app.'/'.$url; } } */ //echo "$url\n";