2001-08-27 05:17:14 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - Preferences *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2001-08-31 18:23:31 +02:00
|
|
|
$GLOBALS['phpgw_info']['flags'] = array(
|
2001-08-27 05:17:14 +02:00
|
|
|
'noheader' => True,
|
2001-09-05 05:49:40 +02:00
|
|
|
'noappheader' => True,
|
2001-08-27 05:17:14 +02:00
|
|
|
'nonavbar' => True,
|
2003-03-31 20:16:33 +02:00
|
|
|
'currentapp' => $_GET['appname'],
|
2001-08-27 05:17:14 +02:00
|
|
|
'enable_nextmatchs_class' => True
|
|
|
|
);
|
|
|
|
include('../header.inc.php');
|
2003-03-31 20:16:33 +02:00
|
|
|
|
|
|
|
if ($_POST['cancel'])
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
|
|
|
|
}
|
|
|
|
|
2002-04-30 00:25:02 +02:00
|
|
|
$user = get_var('user',Array('POST'));
|
2002-12-26 16:31:32 +01:00
|
|
|
$forced = get_var('forced',Array('POST'));
|
2002-04-30 00:25:02 +02:00
|
|
|
$default = get_var('default',Array('POST'));
|
2002-05-09 00:43:52 +02:00
|
|
|
|
2001-09-04 01:01:42 +02:00
|
|
|
$t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('preferences'));
|
|
|
|
$t->set_file(array(
|
2003-03-31 20:16:33 +02:00
|
|
|
'preferences' => 'preferences.tpl'
|
2001-09-04 01:01:42 +02:00
|
|
|
));
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->set_block('preferences','list','lists');
|
|
|
|
$t->set_block('preferences','row','rowhandle');
|
|
|
|
$t->set_block('preferences','help_row','help_rowhandle');
|
|
|
|
$t->set_var(array('rowhandle' => '','help_rowhandle' => '','messages' => ''));
|
|
|
|
|
|
|
|
if ($_GET['appname'] != 'preverences')
|
2003-03-28 03:20:53 +01:00
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->translation->add_app('preferences'); // we need the prefs translations too
|
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
|
2001-09-05 05:49:40 +02:00
|
|
|
/* Make things a little easier to follow */
|
|
|
|
/* Some places we will need to change this if there in common */
|
2001-09-18 05:47:31 +02:00
|
|
|
function check_app()
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
if ($_GET['appname'] == 'preferences')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
|
|
|
return 'common';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
return $_GET['appname'];
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-18 05:47:31 +02:00
|
|
|
function is_forced_value($_appname,$preference_name)
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
if (isset($GLOBALS['gp']->data[$_appname][$preference_name]) && $GLOBALS['type'] != 'forced')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-01-11 15:04:40 +01:00
|
|
|
return False;
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
function create_password_box($label_name,$preference_name,$help='',$size = '',$max_size = '')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
global $user,$forced,$default;
|
|
|
|
|
2001-09-18 05:47:31 +02:00
|
|
|
$_appname = check_app();
|
2001-09-04 01:01:42 +02:00
|
|
|
if (is_forced_value($_appname,$preference_name))
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2001-09-04 01:01:42 +02:00
|
|
|
return True;
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
create_input_box($label_name,$preference_name.'][pw',$help,'',$size,$max_size,'password');
|
|
|
|
}
|
|
|
|
|
|
|
|
function create_input_box($label,$name,$help='',$default='',$size = '',$max_size = '',$type='')
|
|
|
|
{
|
|
|
|
global $t,$prefs;
|
2001-09-04 01:01:42 +02:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
$_appname = check_app();
|
|
|
|
if (is_forced_value($_appname,$name))
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
return True;
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
if ($type) // used to specify password
|
|
|
|
{
|
|
|
|
$options = " TYPE='$type'";
|
|
|
|
}
|
|
|
|
if ($size)
|
|
|
|
{
|
|
|
|
$options .= " SIZE='$size'";
|
|
|
|
}
|
|
|
|
if ($maxsize)
|
|
|
|
{
|
|
|
|
$options .= " MAXSIZE='$maxsize'";
|
|
|
|
}
|
2003-03-28 03:20:53 +01:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
if (isset($prefs[$name]) || $GLOBALS['type'] != 'user')
|
2003-03-30 03:46:16 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
$default = $prefs[$name];
|
2003-03-30 03:46:16 +02:00
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
|
|
|
|
$t->set_var('row_value',"<input name=\"${GLOBALS[type]}[$name]\" value=\"$default\"$options>");
|
|
|
|
$t->set_var('row_name',lang($label));
|
2003-03-28 03:20:53 +01:00
|
|
|
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->fp('rows',process_help($help) ? 'help_row' : 'row',True);
|
|
|
|
}
|
|
|
|
|
|
|
|
function process_help($help)
|
|
|
|
{
|
|
|
|
global $t,$show_help,$has_help;
|
|
|
|
|
|
|
|
if (!empty($help))
|
2003-03-28 03:20:53 +01:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
$has_help = True;
|
|
|
|
|
|
|
|
if ($show_help)
|
|
|
|
{
|
|
|
|
$t->set_var('help_value',lang($help));
|
|
|
|
|
|
|
|
return True;
|
|
|
|
}
|
2003-03-28 03:20:53 +01:00
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
return False;
|
|
|
|
}
|
2003-03-28 03:20:53 +01:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
function create_check_box($label,$name,$help='',$default='')
|
|
|
|
{
|
|
|
|
// checkboxes itself can't be use as they return nothing if uncheckt !!!
|
|
|
|
global $prefs;
|
|
|
|
|
|
|
|
if ($GLOBALS['type'] != 'user')
|
|
|
|
{
|
|
|
|
$default = ''; // no defaults for default or forced prefs
|
|
|
|
}
|
|
|
|
if (isset($prefs[$name]))
|
|
|
|
{
|
|
|
|
$prefs[$name] = intval(!!$prefs[$name]); // to care for '' and 'True'
|
|
|
|
}
|
|
|
|
|
|
|
|
return create_select_box($label,$name,array(
|
|
|
|
'0' => lang('No'),
|
|
|
|
'1' => lang('Yes')
|
|
|
|
),$help,$default);
|
2003-03-28 03:20:53 +01:00
|
|
|
}
|
|
|
|
|
2001-08-27 05:17:14 +02:00
|
|
|
function create_option_string($selected,$values)
|
|
|
|
{
|
|
|
|
while (is_array($values) && list($var,$value) = each($values))
|
|
|
|
{
|
|
|
|
$s .= '<option value="' . $var . '"';
|
2003-03-31 20:16:33 +02:00
|
|
|
if ("$var" == "$selected") // the "'s are necessary to force a string-compare
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
|
|
|
$s .= ' selected';
|
|
|
|
}
|
|
|
|
$s .= '>' . $value . '</option>';
|
|
|
|
}
|
|
|
|
return $s;
|
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
function create_select_box($label,$name,$values,$help='',$default='')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
global $t,$prefs;
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2001-09-18 05:47:31 +02:00
|
|
|
$_appname = check_app();
|
2003-03-31 20:16:33 +02:00
|
|
|
if (is_forced_value($_appname,$name))
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
|
|
|
return True;
|
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
|
|
|
|
if (isset($prefs[$name]) || $GLOBALS['type'] != 'user')
|
|
|
|
{
|
|
|
|
$default = $prefs[$name];
|
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2001-09-04 01:01:42 +02:00
|
|
|
switch ($GLOBALS['type'])
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2001-09-04 01:01:42 +02:00
|
|
|
case 'user':
|
2003-03-31 20:16:33 +02:00
|
|
|
$s = '<option value="">' . lang('Select one') . '</option>';
|
2001-09-04 01:01:42 +02:00
|
|
|
break;
|
|
|
|
case 'default':
|
2003-03-31 20:16:33 +02:00
|
|
|
$s = '<option value="">' . lang('Select one') . '</option>';
|
2001-09-04 01:01:42 +02:00
|
|
|
break;
|
|
|
|
case 'forced':
|
2003-03-31 20:16:33 +02:00
|
|
|
$s = '<option value="**NULL**">' . lang('Users choice') . '</option>';
|
2001-09-04 01:01:42 +02:00
|
|
|
break;
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
$s .= create_option_string($default,$values);
|
|
|
|
$t->set_var('row_value',"<select name=\"${GLOBALS[type]}[$name]\">$s</select>");
|
|
|
|
$t->set_var('row_name',lang($label));
|
|
|
|
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
|
2001-09-04 01:01:42 +02:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->fp('rows',process_help($help) ? 'help_row' : 'row',True);
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
2003-03-28 03:20:53 +01:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
function create_text_area($label,$name,$rows,$cols,$help='',$default='')
|
2003-03-28 03:20:53 +01:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
global $t,$prefs;
|
2003-03-28 03:20:53 +01:00
|
|
|
|
|
|
|
$_appname = check_app();
|
2003-03-31 20:16:33 +02:00
|
|
|
if (is_forced_value($_appname,$name))
|
2003-03-28 03:20:53 +01:00
|
|
|
{
|
|
|
|
return True;
|
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
|
|
|
|
if (isset($prefs[$name]) || $GLOBALS['type'] != 'user')
|
2003-03-28 03:20:53 +01:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
$default = $prefs[$name];
|
2003-03-28 03:20:53 +01:00
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->set_var('row_value',"<textarea rows=\"$rows\" cols=\"$cols\" name=\"${GLOBALS[type]}[$name]\">$default</textarea>");
|
|
|
|
$t->set_var('row_name',lang($label));
|
|
|
|
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
|
|
|
|
|
|
|
|
$t->fp('rows',process_help($help) ? 'help_row' : 'row',True);
|
2003-03-28 03:20:53 +01:00
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2003-04-06 12:35:51 +02:00
|
|
|
function process_array(&$_p,$array,$prefix='')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2001-09-18 05:47:31 +02:00
|
|
|
$_appname = check_app();
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2003-04-06 12:35:51 +02:00
|
|
|
$prefs = &$_p->data[$_appname];
|
|
|
|
|
|
|
|
if ($prefix != '')
|
|
|
|
{
|
|
|
|
$prefix_arr = explode('/',$prefix);
|
|
|
|
foreach ($prefix_arr as $pre)
|
|
|
|
{
|
|
|
|
$prefs = &$prefs[$pre];
|
|
|
|
}
|
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
while (is_array($array) && list($var,$value) = each($array))
|
|
|
|
{
|
2002-12-27 11:29:42 +01:00
|
|
|
if (isset($value) && $value != '' && $value != '**NULL**')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
if (is_array($value))
|
|
|
|
{
|
|
|
|
$value = $value['pw'];
|
|
|
|
if (empty($value))
|
|
|
|
{
|
|
|
|
continue; // dont write empty password-fields
|
|
|
|
}
|
|
|
|
}
|
2003-04-06 12:35:51 +02:00
|
|
|
$prefs[$var] = $value;
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-04-06 12:35:51 +02:00
|
|
|
unset($prefs[$var]);
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
}
|
2003-04-06 12:35:51 +02:00
|
|
|
//echo "prefix='$prefix', prefs=<pre>"; print_r($_p->data[$_appname]);
|
|
|
|
|
2001-08-27 05:17:14 +02:00
|
|
|
$_p->save_repository(True);
|
|
|
|
}
|
|
|
|
|
2001-09-05 05:49:40 +02:00
|
|
|
/* So we can check if the admin is allowing users to make there own choices */
|
|
|
|
/* in life. */
|
2001-09-18 05:47:31 +02:00
|
|
|
$GLOBALS['gp'] = createobject('phpgwapi.preferences',-1);
|
|
|
|
$GLOBALS['gp']->read_repository();
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2001-09-05 05:49:40 +02:00
|
|
|
/* Only check this once */
|
2001-08-31 18:23:31 +02:00
|
|
|
if ($GLOBALS['phpgw']->acl->check('run',1,'admin'))
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2001-09-05 05:49:40 +02:00
|
|
|
/* Don't use a global variable for this ... */
|
2001-08-27 05:17:14 +02:00
|
|
|
define('HAS_ADMIN_RIGHTS',1);
|
2001-09-04 01:01:42 +02:00
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2001-09-05 05:49:40 +02:00
|
|
|
/* Makes the ifs a little nicer, plus ... this will change once the ACL manager is in place */
|
|
|
|
/* and is able to create less powerfull admins. This will handle the ACL checks for that (jengo) */
|
2001-09-05 04:57:30 +02:00
|
|
|
function is_admin()
|
|
|
|
{
|
2003-04-06 12:35:51 +02:00
|
|
|
global $prefix;
|
|
|
|
|
|
|
|
if (HAS_ADMIN_RIGHTS == 1 && empty($prefix)) // tabs only without prefix
|
2001-09-05 04:57:30 +02:00
|
|
|
{
|
|
|
|
return True;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return False;
|
|
|
|
}
|
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
|
|
|
|
function show_list($header = ' ')
|
|
|
|
{
|
|
|
|
global $t,$list_shown;
|
|
|
|
|
|
|
|
$t->set_var('list_header',$header);
|
|
|
|
$t->parse('lists','list',$list_shown);
|
|
|
|
|
|
|
|
$t->set_var('rows','');
|
|
|
|
$list_shown = True;
|
|
|
|
}
|
|
|
|
|
|
|
|
$session_data = $GLOBALS['phpgw']->session->appsession('session_data','preferences');
|
2001-09-05 04:57:30 +02:00
|
|
|
|
2003-04-06 12:35:51 +02:00
|
|
|
$prefix = get_var('prefix',array('GET'),$session_data['appname'] == $_GET['appname'] ? $session_data['prefix'] : '');
|
|
|
|
|
2001-09-04 01:01:42 +02:00
|
|
|
if (is_admin())
|
|
|
|
{
|
2001-09-05 05:49:40 +02:00
|
|
|
/* This is where we will keep track of our postion. */
|
|
|
|
/* Developers won't have to pass around a variable then */
|
2001-09-04 01:01:42 +02:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
$GLOBALS['type'] = get_var('type',Array('GET','POST'),$session_data['type']);
|
|
|
|
|
2003-03-30 03:32:46 +02:00
|
|
|
if (empty($GLOBALS['type']))
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
2003-03-30 03:32:46 +02:00
|
|
|
$GLOBALS['type'] = 'user';
|
2001-09-04 01:01:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-09-18 04:21:31 +02:00
|
|
|
$GLOBALS['type'] = 'user';
|
2001-09-04 01:01:42 +02:00
|
|
|
}
|
2003-04-06 12:35:51 +02:00
|
|
|
$show_help = "$session_data[show_help]" != '' && $session_data['appname'] == $_GET['appname'] ?
|
|
|
|
$session_data['show_help'] : intval($GLOBALS['phpgw_info']['user']['preferences']['common']['show_help']);
|
2003-03-31 20:16:33 +02:00
|
|
|
|
|
|
|
if ($toggle_help = get_var('toggle_help','POST'))
|
|
|
|
{
|
|
|
|
$show_help = intval(!$show_help);
|
|
|
|
}
|
|
|
|
$has_help = 0;
|
2001-09-04 01:01:42 +02:00
|
|
|
|
2001-09-05 05:49:40 +02:00
|
|
|
/* Only load if there working on the default preferences */
|
2001-09-18 04:21:31 +02:00
|
|
|
if ($GLOBALS['type'] == 'default')
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
2001-09-18 05:47:31 +02:00
|
|
|
$GLOBALS['dp'] = createobject('phpgwapi.preferences',-2);
|
|
|
|
$GLOBALS['dp']->read_repository();
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
if ($_POST['submit'])
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2001-09-05 05:49:40 +02:00
|
|
|
/* Don't use a switch here, we need to check some permissions durring the ifs */
|
2002-05-09 00:43:52 +02:00
|
|
|
if ($GLOBALS['type'] == 'user' || !($GLOBALS['type']))
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
2003-04-06 12:35:51 +02:00
|
|
|
process_array($GLOBALS['phpgw']->preferences,$user,$prefix);
|
2001-09-04 01:01:42 +02:00
|
|
|
}
|
|
|
|
|
2001-09-18 04:21:31 +02:00
|
|
|
if ($GLOBALS['type'] == 'default' && is_admin())
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
2002-01-11 15:04:40 +01:00
|
|
|
process_array($GLOBALS['dp'], $default);
|
2001-09-04 01:01:42 +02:00
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2001-09-18 04:21:31 +02:00
|
|
|
if ($GLOBALS['type'] == 'forced' && is_admin())
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2001-09-18 05:47:31 +02:00
|
|
|
process_array($GLOBALS['gp'], $forced);
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
if (!is_admin())
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
|
|
|
|
}
|
2003-04-06 12:35:51 +02:00
|
|
|
|
|
|
|
if ($GLOBALS['type'] == 'user' && $_GET['appname'] == 'preferences' && $user['show_help'] != '')
|
2003-03-31 20:16:33 +02:00
|
|
|
{
|
2003-04-06 12:35:51 +02:00
|
|
|
$show_help = $user['show_help']; // use it, if admin changes his help-prefs
|
2003-03-31 20:16:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$GLOBALS['phpgw']->session->appsession('session_data','preferences',array(
|
|
|
|
'type' => $GLOBALS['type'], // save our state in the app-session
|
|
|
|
'show_help' => $show_help,
|
2003-04-06 12:35:51 +02:00
|
|
|
'prefix' => $prefix,
|
|
|
|
'appname' => $_GET['appname'] // we use this to reset prefix on appname-change
|
2003-03-31 20:16:33 +02:00
|
|
|
));
|
2003-04-06 12:35:51 +02:00
|
|
|
// changes for the admin itself, should have immediate feedback ==> redirect
|
|
|
|
if ($_POST['submit'] && $GLOBALS['type'] == 'user' && $_GET['appname'] == 'preferences') {
|
|
|
|
$GLOBALS['phpgw']->redirect_link('/preferences/preferences.php','appname='.$_GET['appname']);
|
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2003-04-20 22:47:50 +02:00
|
|
|
$GLOBALS['phpgw_info']['flags']['app_header'] = $_GET['appname'] == 'preferences' ?
|
|
|
|
lang('Preferences') : lang('%1 - Preferences',$GLOBALS['phpgw_info']['apps'][$_GET['appname']]['title']);
|
|
|
|
$GLOBALS['phpgw']->common->phpgw_header();
|
2001-09-04 01:01:42 +02:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->set_var('action_url',$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname']));
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
switch ($GLOBALS['type']) // set up some globals to be used by the hooks
|
|
|
|
{
|
|
|
|
case 'forced':
|
|
|
|
$prefs = &$GLOBALS['gp']->data[check_app()];
|
|
|
|
break;
|
|
|
|
case 'default':
|
|
|
|
$prefs = &$GLOBALS['dp']->data[check_app()];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$prefs = &$GLOBALS['phpgw']->preferences->data[check_app()];
|
|
|
|
// use prefix if given in the url, used for email extra-accounts
|
2003-04-06 12:35:51 +02:00
|
|
|
if ($prefix != '')
|
2003-03-31 20:16:33 +02:00
|
|
|
{
|
2003-04-06 12:35:51 +02:00
|
|
|
$prefix_arr = explode('/',$prefix);
|
|
|
|
foreach ($prefix_arr as $pre)
|
2003-03-31 20:16:33 +02:00
|
|
|
{
|
|
|
|
$prefs = &$prefs[$pre];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//echo "prefs=<pre>"; print_r($prefs); echo "</pre>\n";
|
|
|
|
|
|
|
|
if ($_GET['appname'] == 'preferences')
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2002-01-02 15:33:05 +01:00
|
|
|
if (! $GLOBALS['phpgw']->hooks->single('settings','preferences',True))
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
|
|
|
$error = True;
|
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
if (! $GLOBALS['phpgw']->hooks->single('settings',$_GET['appname']))
|
2001-09-04 01:01:42 +02:00
|
|
|
{
|
|
|
|
$error = True;
|
2002-01-11 15:04:40 +01:00
|
|
|
}
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
|
2001-09-04 01:01:42 +02:00
|
|
|
if ($error)
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->set_block('preferences','form','formhandle'); // skip the form
|
|
|
|
$t->set_var('formhandle','');
|
|
|
|
|
2001-08-27 05:17:14 +02:00
|
|
|
$t->set_var('messages',lang('Error: There was a problem finding the preference file for %1 in %2',
|
2003-03-31 20:16:33 +02:00
|
|
|
$GLOBALS['phpgw_info']['navbar'][$_GET['appname']]['title'],PHPGW_SERVER_ROOT . SEP
|
|
|
|
. $_GET['appname'] . SEP . 'inc' . SEP . 'hook_settings.inc.php'));
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
if (is_admin())
|
|
|
|
{
|
|
|
|
$tabs[] = array(
|
|
|
|
'label' => lang('Your preferences'),
|
|
|
|
'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'] . "&type=user")
|
|
|
|
);
|
|
|
|
$tabs[] = array(
|
|
|
|
'label' => lang('Default preferences'),
|
|
|
|
'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'] . "&type=default")
|
|
|
|
);
|
|
|
|
$tabs[] = array(
|
|
|
|
'label' => lang('Forced preferences'),
|
|
|
|
'link' => $GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' . $_GET['appname'] . "&type=forced")
|
|
|
|
);
|
|
|
|
|
|
|
|
switch($GLOBALS['type'])
|
|
|
|
{
|
|
|
|
case 'user': $selected = 0; break;
|
|
|
|
case 'default': $selected = 1; break;
|
|
|
|
case 'forced': $selected = 2; break;
|
|
|
|
}
|
|
|
|
$t->set_var('tabs',$GLOBALS['phpgw']->common->create_tabs($tabs,$selected));
|
|
|
|
}
|
|
|
|
$t->set_var('lang_submit', lang('save'));
|
2001-08-27 05:17:14 +02:00
|
|
|
$t->set_var('lang_cancel', lang('cancel'));
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->set_var('show_help',intval($show_help));
|
|
|
|
$t->set_var('help_button',$has_help ? '<input type="submit" name="toggle_help" value="'.
|
|
|
|
($show_help ? lang('help off') : lang('help')).'">' : '');
|
2001-08-27 05:17:14 +02:00
|
|
|
|
2003-03-31 20:16:33 +02:00
|
|
|
if (!$list_shown)
|
2001-08-27 05:17:14 +02:00
|
|
|
{
|
2003-03-31 20:16:33 +02:00
|
|
|
show_list();
|
2001-08-27 05:17:14 +02:00
|
|
|
}
|
2003-03-31 20:16:33 +02:00
|
|
|
$t->parse('phpgw_body','preferences');
|
2001-09-05 04:57:30 +02:00
|
|
|
?>
|