From be83963d2b3f98a0ed97e8dff1be72fba638724f Mon Sep 17 00:00:00 2001 From: skeeter Date: Tue, 18 Sep 2001 03:47:31 +0000 Subject: [PATCH] Changed over to use mostly GLOBALS where possible. --- preferences/preferences.php | 78 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 41 deletions(-) diff --git a/preferences/preferences.php b/preferences/preferences.php index d229b4acab..34f91a34d5 100755 --- a/preferences/preferences.php +++ b/preferences/preferences.php @@ -11,16 +11,15 @@ /* $Id$ */ - $appname = $GLOBALS['HTTP_GET_VARS']['appname']; - $user = $GLOBALS['HTTP_POST_VARS']['user']; - $global = $GLOBALS['HTTP_POST_VARS']['global']; - $default = $GLOBALS['HTTP_POST_VARS']['default']; + $user = (@isset($GLOBALS['HTTP_POST_VARS']['user'])?$GLOBALS['HTTP_POST_VARS']['user']:''); + $global = (@isset($GLOBALS['HTTP_POST_VARS']['global'])?$GLOBALS['HTTP_POST_VARS']['global']:''); + $default = (@isset($GLOBALS['HTTP_POST_VARS']['default'])?$GLOBALS['HTTP_POST_VARS']['default']:''); $GLOBALS['phpgw_info']['flags'] = array( 'noheader' => True, 'noappheader' => True, 'nonavbar' => True, - 'currentapp' => $appname, + 'currentapp' => $GLOBALS['HTTP_GET_VARS']['appname'], 'enable_nextmatchs_class' => True ); include('../header.inc.php'); @@ -43,21 +42,21 @@ /* Make things a little easier to follow */ /* Some places we will need to change this if there in common */ - function check_app($appname) + function check_app() { - if ($appname == 'preferences') + if ($GLOBALS['HTTP_GET_VARS']['appname'] == 'preferences') { return 'common'; } else { - return $appname; + return $GLOBALS['HTTP_GET_VARS']['appname']; } } - function is_forced_value($appname,$preference_name) + function is_forced_value($_appname,$preference_name) { - if ($GLOBALS['gp']->data[$appname][$preference_name] && $GLOBALS['type'] != 'forced') + if ($GLOBALS['gp']->data[$_appname][$preference_name] && $GLOBALS['type'] != 'forced') { return True; } @@ -69,9 +68,9 @@ function create_input_box($label_name,$preference_name,$size = '',$max_size = '') { - global $appname, $t, $dp, $gp; - $_appname = check_app($appname); + global $t; + $_appname = check_app(); $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color(&$t); $t->set_var('row_name',lang($label_name)); @@ -84,9 +83,9 @@ { case 'user': $s = ''; break; - case 'default': $s = ''; + case 'default': $s = ''; break; - case 'forced': $s = ''; + case 'forced': $s = ''; break; } $t->set_var('row_value',$s); @@ -110,10 +109,9 @@ function create_select_box($label_name,$preference_name,$values) { - global $appname, $t, $dp, $gp; - - $_appname = check_app($appname); + global $t; + $_appname = check_app(); if (is_forced_value($_appname,$preference_name)) { return True; @@ -132,12 +130,12 @@ break; case 'default': $s = '' - . create_option_string($dp->data[$_appname][$preference_name],$values); + . create_option_string($GLOBALS['dp']->data[$_appname][$preference_name],$values); $t->set_var('row_value',''); break; case 'forced': $s = '' - . create_option_string($gp->data[$_appname][$preference_name],$values); + . create_option_string($GLOBALS['gp']->data[$_appname][$preference_name],$values); $t->set_var('row_value',''); break; } @@ -147,9 +145,7 @@ function process_array(&$_p, $array) { - global $appname; - - $_appname = check_app($appname); + $_appname = check_app(); while (is_array($array) && list($var,$value) = each($array)) { @@ -170,8 +166,8 @@ /* So we can check if the admin is allowing users to make there own choices */ /* in life. */ - $gp = createobject('phpgwapi.preferences',-1); - $gp->read_repository(); + $GLOBALS['gp'] = createobject('phpgwapi.preferences',-1); + $GLOBALS['gp']->read_repository(); /* Only check this once */ if ($GLOBALS['phpgw']->acl->check('run',1,'admin')) @@ -198,14 +194,14 @@ { /* This is where we will keep track of our postion. */ /* Developers won't have to pass around a variable then */ - $session_data = $phpgw->session->appsession('session_data','preferences'); + $session_data = $GLOBALS['phpgw']->session->appsession('session_data','preferences'); if (! is_array($session_data)) { $session_data = array( 'type' => 'user' ); - $phpgw->session->appsession('session_data','preferences',$session_data); + $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data); } if (!isset($GLOBALS['HTTP_GET_VARS']['type'])) @@ -218,20 +214,20 @@ $session_data = array( 'type' => $GLOBALS['type'] ); - $phpgw->session->appsession('session_data','preferences',$session_data); + $GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data); } $tabs[] = array( 'label' => 'Your preferences', - 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $appname . '&type=user') + 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $GLOBALS['HTTP_GET_VARS']['appname'] . '&type=user') ); $tabs[] = array( 'label' => 'Default preferences', - 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $appname . '&type=default') + 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $GLOBALS['HTTP_GET_VARS']['appname'] . '&type=default') ); $tabs[] = array( 'label' => 'Forced preferences', - 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $appname . '&type=forced') + 'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $GLOBALS['HTTP_GET_VARS']['appname'] . '&type=forced') ); switch($GLOBALS['type']) @@ -250,8 +246,8 @@ /* Only load if there working on the default preferences */ if ($GLOBALS['type'] == 'default') { - $dp = createobject('phpgwapi.preferences',-2); - $dp->read_repository(); + $GLOBALS['dp'] = createobject('phpgwapi.preferences',-2); + $GLOBALS['dp']->read_repository(); } if ($GLOBALS['HTTP_POST_VARS']['submit']) @@ -264,12 +260,12 @@ if ($GLOBALS['type'] == 'default' && is_admin()) { - process_array($dp, $default); + process_array($GLOBALS['dp'], $default); } if ($GLOBALS['type'] == 'forced' && is_admin()) { - process_array($gp, $forced); + process_array($GLOBALS['gp'], $forced); } Header('Location: ' . $GLOBALS['phpgw']->link('/preferences/index.php')); @@ -279,22 +275,22 @@ $GLOBALS['phpgw']->common->phpgw_header(); echo parse_navbar(); - if ($appname == 'preferences') + if ($GLOBALS['HTTP_GET_VARS']['appname'] == 'preferences') { $t->set_var('lang_title',lang('Preferences')); } else { - $t->set_var('lang_title',lang('%1 - Preferences',$GLOBALS['phpgw_info']['navbar'][$appname]['title'])); + $t->set_var('lang_title',lang('%1 - Preferences',$GLOBALS['phpgw_info']['navbar'][$GLOBALS['HTTP_GET_VARS']['appname']]['title'])); } - $t->set_var('action_url',$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $appname)); + $t->set_var('action_url',$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $GLOBALS['HTTP_GET_VARS']['appname'])); $t->set_var('th_bg', $GLOBALS['phpgw_info']['theme']['th_bg']); $t->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']); $t->set_var('row_on', $GLOBALS['phpgw_info']['theme']['row_on']); $t->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']); - if ($appname == 'preferences') + if ($GLOBALS['HTTP_GET_VARS']['appname'] == 'preferences') { if (! $GLOBALS['phpgw']->common->hook_single('settings','preferences',True)) { @@ -303,7 +299,7 @@ } else { - if (! $GLOBALS['phpgw']->common->hook_single('settings',$appname)) + if (! $GLOBALS['phpgw']->common->hook_single('settings',$GLOBALS['HTTP_GET_VARS']['appname'])) { $error = True; } @@ -312,8 +308,8 @@ if ($error) { $t->set_var('messages',lang('Error: There was a problem finding the preference file for %1 in %2', - $GLOBALS['phpgw_info']['navbar'][$appname]['title'],PHPGW_SERVER_ROOT . SEP - . $appname . SEP . 'inc' . SEP . 'hook_settings.inc.php')); + $GLOBALS['phpgw_info']['navbar'][$GLOBALS['HTTP_GET_VARS']['appname']]['title'],PHPGW_SERVER_ROOT . SEP + . $GLOBALS['HTTP_GET_VARS']['appname'] . SEP . 'inc' . SEP . 'hook_settings.inc.php')); } $t->pfp('out','header');