mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 00:58:55 +01:00
Changed over to use mostly GLOBALS where possible.
This commit is contained in:
parent
33bd4e9714
commit
be83963d2b
@ -11,16 +11,15 @@
|
|||||||
|
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
$appname = $GLOBALS['HTTP_GET_VARS']['appname'];
|
$user = (@isset($GLOBALS['HTTP_POST_VARS']['user'])?$GLOBALS['HTTP_POST_VARS']['user']:'');
|
||||||
$user = $GLOBALS['HTTP_POST_VARS']['user'];
|
$global = (@isset($GLOBALS['HTTP_POST_VARS']['global'])?$GLOBALS['HTTP_POST_VARS']['global']:'');
|
||||||
$global = $GLOBALS['HTTP_POST_VARS']['global'];
|
$default = (@isset($GLOBALS['HTTP_POST_VARS']['default'])?$GLOBALS['HTTP_POST_VARS']['default']:'');
|
||||||
$default = $GLOBALS['HTTP_POST_VARS']['default'];
|
|
||||||
|
|
||||||
$GLOBALS['phpgw_info']['flags'] = array(
|
$GLOBALS['phpgw_info']['flags'] = array(
|
||||||
'noheader' => True,
|
'noheader' => True,
|
||||||
'noappheader' => True,
|
'noappheader' => True,
|
||||||
'nonavbar' => True,
|
'nonavbar' => True,
|
||||||
'currentapp' => $appname,
|
'currentapp' => $GLOBALS['HTTP_GET_VARS']['appname'],
|
||||||
'enable_nextmatchs_class' => True
|
'enable_nextmatchs_class' => True
|
||||||
);
|
);
|
||||||
include('../header.inc.php');
|
include('../header.inc.php');
|
||||||
@ -43,21 +42,21 @@
|
|||||||
|
|
||||||
/* Make things a little easier to follow */
|
/* Make things a little easier to follow */
|
||||||
/* Some places we will need to change this if there in common */
|
/* 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';
|
return 'common';
|
||||||
}
|
}
|
||||||
else
|
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;
|
return True;
|
||||||
}
|
}
|
||||||
@ -69,9 +68,9 @@
|
|||||||
|
|
||||||
function create_input_box($label_name,$preference_name,$size = '',$max_size = '')
|
function create_input_box($label_name,$preference_name,$size = '',$max_size = '')
|
||||||
{
|
{
|
||||||
global $appname, $t, $dp, $gp;
|
global $t;
|
||||||
$_appname = check_app($appname);
|
|
||||||
|
|
||||||
|
$_appname = check_app();
|
||||||
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color(&$t);
|
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color(&$t);
|
||||||
$t->set_var('row_name',lang($label_name));
|
$t->set_var('row_name',lang($label_name));
|
||||||
|
|
||||||
@ -84,9 +83,9 @@
|
|||||||
{
|
{
|
||||||
case 'user': $s = '<input name="user[' . $preference_name . ']" value="' . $GLOBALS['phpgw_info']['user']['preferences'][$_appname][$preference_name] . '">';
|
case 'user': $s = '<input name="user[' . $preference_name . ']" value="' . $GLOBALS['phpgw_info']['user']['preferences'][$_appname][$preference_name] . '">';
|
||||||
break;
|
break;
|
||||||
case 'default': $s = '<input name="default[' . $preference_name . ']" value="' . $dp->data[$_appname][$preference_name] . '">';
|
case 'default': $s = '<input name="default[' . $preference_name . ']" value="' . $GLOBALS['dp']->data[$_appname][$preference_name] . '">';
|
||||||
break;
|
break;
|
||||||
case 'forced': $s = '<input name="forced[' . $preference_name . ']" value="' . $gp->data[$_appname][$preference_name] . '">';
|
case 'forced': $s = '<input name="forced[' . $preference_name . ']" value="' . $GLOBALS['gp']->data[$_appname][$preference_name] . '">';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$t->set_var('row_value',$s);
|
$t->set_var('row_value',$s);
|
||||||
@ -110,10 +109,9 @@
|
|||||||
|
|
||||||
function create_select_box($label_name,$preference_name,$values)
|
function create_select_box($label_name,$preference_name,$values)
|
||||||
{
|
{
|
||||||
global $appname, $t, $dp, $gp;
|
global $t;
|
||||||
|
|
||||||
$_appname = check_app($appname);
|
|
||||||
|
|
||||||
|
$_appname = check_app();
|
||||||
if (is_forced_value($_appname,$preference_name))
|
if (is_forced_value($_appname,$preference_name))
|
||||||
{
|
{
|
||||||
return True;
|
return True;
|
||||||
@ -132,12 +130,12 @@
|
|||||||
break;
|
break;
|
||||||
case 'default':
|
case 'default':
|
||||||
$s = '<option value="">' . lang('Select one') . '</option>'
|
$s = '<option value="">' . lang('Select one') . '</option>'
|
||||||
. create_option_string($dp->data[$_appname][$preference_name],$values);
|
. create_option_string($GLOBALS['dp']->data[$_appname][$preference_name],$values);
|
||||||
$t->set_var('row_value','<select name="default[' . $preference_name . ']">' . $s . '</select>');
|
$t->set_var('row_value','<select name="default[' . $preference_name . ']">' . $s . '</select>');
|
||||||
break;
|
break;
|
||||||
case 'forced':
|
case 'forced':
|
||||||
$s = '<option value="**NULL**">' . lang('Users choice') . '</option>'
|
$s = '<option value="**NULL**">' . lang('Users choice') . '</option>'
|
||||||
. create_option_string($gp->data[$_appname][$preference_name],$values);
|
. create_option_string($GLOBALS['gp']->data[$_appname][$preference_name],$values);
|
||||||
$t->set_var('row_value','<select name="forced[' . $preference_name . ']">' . $s . '</select>');
|
$t->set_var('row_value','<select name="forced[' . $preference_name . ']">' . $s . '</select>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -147,9 +145,7 @@
|
|||||||
|
|
||||||
function process_array(&$_p, $array)
|
function process_array(&$_p, $array)
|
||||||
{
|
{
|
||||||
global $appname;
|
$_appname = check_app();
|
||||||
|
|
||||||
$_appname = check_app($appname);
|
|
||||||
|
|
||||||
while (is_array($array) && list($var,$value) = each($array))
|
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 */
|
/* So we can check if the admin is allowing users to make there own choices */
|
||||||
/* in life. */
|
/* in life. */
|
||||||
$gp = createobject('phpgwapi.preferences',-1);
|
$GLOBALS['gp'] = createobject('phpgwapi.preferences',-1);
|
||||||
$gp->read_repository();
|
$GLOBALS['gp']->read_repository();
|
||||||
|
|
||||||
/* Only check this once */
|
/* Only check this once */
|
||||||
if ($GLOBALS['phpgw']->acl->check('run',1,'admin'))
|
if ($GLOBALS['phpgw']->acl->check('run',1,'admin'))
|
||||||
@ -198,14 +194,14 @@
|
|||||||
{
|
{
|
||||||
/* This is where we will keep track of our postion. */
|
/* This is where we will keep track of our postion. */
|
||||||
/* Developers won't have to pass around a variable then */
|
/* 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))
|
if (! is_array($session_data))
|
||||||
{
|
{
|
||||||
$session_data = array(
|
$session_data = array(
|
||||||
'type' => 'user'
|
'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']))
|
if (!isset($GLOBALS['HTTP_GET_VARS']['type']))
|
||||||
@ -218,20 +214,20 @@
|
|||||||
$session_data = array(
|
$session_data = array(
|
||||||
'type' => $GLOBALS['type']
|
'type' => $GLOBALS['type']
|
||||||
);
|
);
|
||||||
$phpgw->session->appsession('session_data','preferences',$session_data);
|
$GLOBALS['phpgw']->session->appsession('session_data','preferences',$session_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tabs[] = array(
|
$tabs[] = array(
|
||||||
'label' => 'Your preferences',
|
'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(
|
$tabs[] = array(
|
||||||
'label' => 'Default preferences',
|
'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(
|
$tabs[] = array(
|
||||||
'label' => 'Forced preferences',
|
'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'])
|
switch($GLOBALS['type'])
|
||||||
@ -250,8 +246,8 @@
|
|||||||
/* Only load if there working on the default preferences */
|
/* Only load if there working on the default preferences */
|
||||||
if ($GLOBALS['type'] == 'default')
|
if ($GLOBALS['type'] == 'default')
|
||||||
{
|
{
|
||||||
$dp = createobject('phpgwapi.preferences',-2);
|
$GLOBALS['dp'] = createobject('phpgwapi.preferences',-2);
|
||||||
$dp->read_repository();
|
$GLOBALS['dp']->read_repository();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GLOBALS['HTTP_POST_VARS']['submit'])
|
if ($GLOBALS['HTTP_POST_VARS']['submit'])
|
||||||
@ -264,12 +260,12 @@
|
|||||||
|
|
||||||
if ($GLOBALS['type'] == 'default' && is_admin())
|
if ($GLOBALS['type'] == 'default' && is_admin())
|
||||||
{
|
{
|
||||||
process_array($dp, $default);
|
process_array($GLOBALS['dp'], $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GLOBALS['type'] == 'forced' && is_admin())
|
if ($GLOBALS['type'] == 'forced' && is_admin())
|
||||||
{
|
{
|
||||||
process_array($gp, $forced);
|
process_array($GLOBALS['gp'], $forced);
|
||||||
}
|
}
|
||||||
|
|
||||||
Header('Location: ' . $GLOBALS['phpgw']->link('/preferences/index.php'));
|
Header('Location: ' . $GLOBALS['phpgw']->link('/preferences/index.php'));
|
||||||
@ -279,22 +275,22 @@
|
|||||||
$GLOBALS['phpgw']->common->phpgw_header();
|
$GLOBALS['phpgw']->common->phpgw_header();
|
||||||
echo parse_navbar();
|
echo parse_navbar();
|
||||||
|
|
||||||
if ($appname == 'preferences')
|
if ($GLOBALS['HTTP_GET_VARS']['appname'] == 'preferences')
|
||||||
{
|
{
|
||||||
$t->set_var('lang_title',lang('Preferences'));
|
$t->set_var('lang_title',lang('Preferences'));
|
||||||
}
|
}
|
||||||
else
|
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_bg', $GLOBALS['phpgw_info']['theme']['th_bg']);
|
||||||
$t->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']);
|
$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_on', $GLOBALS['phpgw_info']['theme']['row_on']);
|
||||||
$t->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']);
|
$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))
|
if (! $GLOBALS['phpgw']->common->hook_single('settings','preferences',True))
|
||||||
{
|
{
|
||||||
@ -303,7 +299,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (! $GLOBALS['phpgw']->common->hook_single('settings',$appname))
|
if (! $GLOBALS['phpgw']->common->hook_single('settings',$GLOBALS['HTTP_GET_VARS']['appname']))
|
||||||
{
|
{
|
||||||
$error = True;
|
$error = True;
|
||||||
}
|
}
|
||||||
@ -312,8 +308,8 @@
|
|||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
$t->set_var('messages',lang('Error: There was a problem finding the preference file for %1 in %2',
|
$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
|
$GLOBALS['phpgw_info']['navbar'][$GLOBALS['HTTP_GET_VARS']['appname']]['title'],PHPGW_SERVER_ROOT . SEP
|
||||||
. $appname . SEP . 'inc' . SEP . 'hook_settings.inc.php'));
|
. $GLOBALS['HTTP_GET_VARS']['appname'] . SEP . 'inc' . SEP . 'hook_settings.inc.php'));
|
||||||
}
|
}
|
||||||
$t->pfp('out','header');
|
$t->pfp('out','header');
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user