[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: preferences preferences.php,1.27,1.28
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: preferences preferences.php,1.27,1.28 |
Date: |
Mon, 31 Mar 2003 13:16:36 -0500 |
Update of /cvsroot/phpgroupware/preferences
In directory subversions:/tmp/cvs-serv514
Modified Files:
preferences.php
Log Message:
update preferences: helptexts
Index: preferences.php
===================================================================
RCS file: /cvsroot/phpgroupware/preferences/preferences.php,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -r1.27 -r1.28
*** preferences.php 30 Mar 2003 01:46:16 -0000 1.27
--- preferences.php 31 Mar 2003 18:16:33 -0000 1.28
***************
*** 12,59 ****
/* $Id$ */
- $user =
(@isset($GLOBALS['HTTP_POST_VARS']['user'])?$GLOBALS['HTTP_POST_VARS']['user']:'');
- $forced =
(@isset($GLOBALS['HTTP_POST_VARS']['forced'])?$GLOBALS['HTTP_POST_VARS']['forced']:'');
- $default =
(@isset($GLOBALS['HTTP_POST_VARS']['default'])?$GLOBALS['HTTP_POST_VARS']['default']:'');
-
$GLOBALS['phpgw_info']['flags'] = array(
'noheader' => True,
'noappheader' => True,
'nonavbar' => True,
! 'currentapp' =>
$GLOBALS['HTTP_GET_VARS']['appname'],
'enable_nextmatchs_class' => True
);
include('../header.inc.php');
!
$user = get_var('user',Array('POST'));
$forced = get_var('forced',Array('POST'));
$default = get_var('default',Array('POST'));
- $GLOBALS['appname'] = get_var('appname',Array('GET'));
-
- if(get_var('cancel',Array('POST')))
- {
- Header('Location: ' .
$GLOBALS['phpgw']->link('/preferences/index.php'));
- }
-
$t =
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('preferences'));
$t->set_file(array(
! '_preferences' => 'preferences.tpl'
));
! $t->set_block('_preferences','list');
! $t->set_block('_preferences','row');
!
! $t->set_block('_preferences','header');
! $t->set_block('_preferences','footer');
! $t->set_block('_preferences','row_error');
!
! if ($GLOBALS['HTTP_GET_VARS']['appname'] != 'preverences')
{
$GLOBALS['phpgw']->translation->add_app('preferences'); // we
need the prefs translations too
}
/* Make things a little easier to follow */
/* Some places we will need to change this if there in common */
function check_app()
{
! if ($GLOBALS['appname'] == 'preferences')
{
return 'common';
--- 12,52 ----
/* $Id$ */
$GLOBALS['phpgw_info']['flags'] = array(
'noheader' => True,
'noappheader' => True,
'nonavbar' => True,
! 'currentapp' => $_GET['appname'],
'enable_nextmatchs_class' => True
);
include('../header.inc.php');
!
! if ($_POST['cancel'])
! {
! $GLOBALS['phpgw']->redirect_link('/preferences/index.php');
! }
!
$user = get_var('user',Array('POST'));
$forced = get_var('forced',Array('POST'));
$default = get_var('default',Array('POST'));
$t =
CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('preferences'));
$t->set_file(array(
! 'preferences' => 'preferences.tpl'
));
! $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')
{
$GLOBALS['phpgw']->translation->add_app('preferences'); // we
need the prefs translations too
}
+
/* Make things a little easier to follow */
/* Some places we will need to change this if there in common */
function check_app()
{
! if ($_GET['appname'] == 'preferences')
{
return 'common';
***************
*** 61,65 ****
else
{
! return $GLOBALS['appname'];
}
}
--- 54,58 ----
else
{
! return $_GET['appname'];
}
}
***************
*** 67,71 ****
function is_forced_value($_appname,$preference_name)
{
! if ($GLOBALS['gp']->data[$_appname][$preference_name] &&
$GLOBALS['type'] != 'forced')
{
return True;
--- 60,64 ----
function is_forced_value($_appname,$preference_name)
{
! if (isset($GLOBALS['gp']->data[$_appname][$preference_name]) &&
$GLOBALS['type'] != 'forced')
{
return True;
***************
*** 77,134 ****
}
! function create_input_box($label_name,$preference_name,$size =
'',$max_size = '')
{
! global $t;
!
$_appname = check_app();
- $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
- $t->set_var('row_name',lang($label_name));
-
if (is_forced_value($_appname,$preference_name))
{
return True;
}
! switch ($GLOBALS['type'])
{
! case 'user':
! $s = '<input name="user[' . $preference_name .
']" value="' .
$GLOBALS['phpgw_info']['user']['preferences'][$_appname][$preference_name] .
'">';
! break;
! case 'default':
! $s = '<input name="default[' . $preference_name
. ']" value="' . $GLOBALS['dp']->data[$_appname][$preference_name] . '">';
! break;
! case 'forced':
! $s = '<input name="forced[' . $preference_name
. ']" value="' . $GLOBALS['gp']->data[$_appname][$preference_name] . '">';
! break;
}
- $t->set_var('row_value',$s);
-
- $t->fp('rows','row',True);
- }
! function create_check_box($label_name,$preference_name)
! {
! global $t;
! if ($GLOBALS['type'] != 'user') // for default and forced we
need a 3. setting
{
! return
create_select_box($label_name,$preference_name,array(
! '0' => lang('No'),
! '1' => lang('Yes')
! ));
}
! $_appname = check_app();
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
- $t->set_var('row_name',lang($label_name));
! if (is_forced_value($_appname,$preference_name))
{
! return True;
}
! $s = '<input type="checkbox" name="user[' . $preference_name .
']" value="1"' .
($GLOBALS['phpgw_info']['user']['preferences'][$_appname][$preference_name] ? '
CHECKED' : '') . '">';
! $t->set_var('row_value',$s);
!
! $t->fp('rows','row',True);
}
--- 70,156 ----
}
! function
create_password_box($label_name,$preference_name,$help='',$size = '',$max_size
= '')
{
! global $user,$forced,$default;
!
$_appname = check_app();
if (is_forced_value($_appname,$preference_name))
{
return True;
}
+
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;
! $_appname = check_app();
! if (is_forced_value($_appname,$name))
{
! return True;
}
! if ($type) // used to specify password
! {
! $options = " TYPE='$type'";
! }
! if ($size)
! {
! $options .= " SIZE='$size'";
! }
! if ($maxsize)
! {
! $options .= " MAXSIZE='$maxsize'";
! }
! if (isset($prefs[$name]) || $GLOBALS['type'] != 'user')
{
! $default = $prefs[$name];
}
!
! $t->set_var('row_value',"<input
name=\"${GLOBALS[type]}[$name]\" value=\"$default\"$options>");
! $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);
! }
!
! function process_help($help)
! {
! global $t,$show_help,$has_help;
!
! if (!empty($help))
{
! $has_help = True;
!
! if ($show_help)
! {
! $t->set_var('help_value',lang($help));
!
! return True;
! }
}
+ return False;
+ }
! 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);
}
***************
*** 138,142 ****
{
$s .= '<option value="' . $var . '"';
! if ($var == $selected)
{
$s .= ' selected';
--- 160,164 ----
{
$s .= '<option value="' . $var . '"';
! if ("$var" == "$selected") // the "'s are
necessary to force a string-compare
{
$s .= ' selected';
***************
*** 147,214 ****
}
! function create_select_box($label_name,$preference_name,$values)
{
! global $t;
$_appname = check_app();
! if (is_forced_value($_appname,$preference_name))
{
return True;
}
!
! $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
!
! $t->set_var('row_name',lang($label_name));
switch ($GLOBALS['type'])
{
case 'user':
! $s = '<option value="">' . lang('Select one') .
'</option>'
! .
create_option_string($GLOBALS['phpgw_info']['user']['preferences'][$_appname][$preference_name],$values);
! $t->set_var('row_value','<select name="user[' .
$preference_name . ']">' . $s . '</select>');
break;
case 'default':
! $s = '<option value="">' . lang('Select one') .
'</option>'
! .
create_option_string($GLOBALS['dp']->data[$_appname][$preference_name],$values);
! $t->set_var('row_value','<select
name="default[' . $preference_name . ']">' . $s . '</select>');
break;
case 'forced':
! $s = '<option value="**NULL**">' . lang('Users
choice') . '</option>'
! .
create_option_string($GLOBALS['gp']->data[$_appname][$preference_name],$values);
! $t->set_var('row_value','<select name="forced['
. $preference_name . ']">' . $s . '</select>');
break;
}
! $t->fp('rows','row',True);
}
! function create_text_area($label_name,$preference_name,$rows,$cols)
{
! global $t;
$_appname = check_app();
! $GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($t);
! $t->set_var('row_name',lang($label_name));
!
! if (is_forced_value($_appname,$preference_name))
{
return True;
}
!
! switch ($GLOBALS['type'])
{
! case 'user':
! $s = '<textarea rows="'.$rows.'"
cols="'.$cols.'" name="user[' . $preference_name . ']">' .
$GLOBALS['phpgw_info']['user']['preferences'][$_appname][$preference_name] .
'</textarea>';
! break;
! case 'default':
! $s = '<textarea rows="'.$rows.'"
cols="'.$cols.'" name="default[' . $preference_name . ']">' .
$GLOBALS['dp']->data[$_appname][$preference_name] . '</textarea>';
! break;
! case 'forced':
! $s = '<textarea rows="'.$rows.'"
cols="'.$cols.'" name="forced[' . $preference_name . ']">' .
$GLOBALS['gp']->data[$_appname][$preference_name] . '</textarea>';
! break;
}
- $t->set_var('row_value',$s);
! $t->fp('rows','row',True);
}
--- 169,227 ----
}
! function create_select_box($label,$name,$values,$help='',$default='')
{
! global $t,$prefs;
$_appname = check_app();
! if (is_forced_value($_appname,$name))
{
return True;
}
!
! if (isset($prefs[$name]) || $GLOBALS['type'] != 'user')
! {
! $default = $prefs[$name];
! }
switch ($GLOBALS['type'])
{
case 'user':
! $s = '<option value="">' . lang('Select one') .
'</option>';
break;
case 'default':
! $s = '<option value="">' . lang('Select one') .
'</option>';
break;
case 'forced':
! $s = '<option value="**NULL**">' . lang('Users
choice') . '</option>';
break;
}
+ $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);
! $t->fp('rows',process_help($help) ? 'help_row' : 'row',True);
}
! function create_text_area($label,$name,$rows,$cols,$help='',$default='')
{
! global $t,$prefs;
$_appname = check_app();
! if (is_forced_value($_appname,$name))
{
return True;
}
!
! if (isset($prefs[$name]) || $GLOBALS['type'] != 'user')
{
! $default = $prefs[$name];
}
! $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);
}
***************
*** 221,224 ****
--- 234,245 ----
if (isset($value) && $value != '' && $value !=
'**NULL**')
{
+ if (is_array($value))
+ {
+ $value = $value['pw'];
+ if (empty($value))
+ {
+ continue; // dont write
empty password-fields
+ }
+ }
$_p->add($_appname,$var,$value);
}
***************
*** 231,237 ****
}
- $p = createobject('phpgwapi.preferences');
- $p->read_repository();
-
/* So we can check if the admin is allowing users to make there own
choices */
/* in life. */
--- 252,255 ----
***************
*** 250,254 ****
function is_admin()
{
! if (HAS_ADMIN_RIGHTS == 1)
{
return True;
--- 268,272 ----
function is_admin()
{
! if (HAS_ADMIN_RIGHTS == 1 && !isset($_GET['prefix'])) // tabs
only without prefix
{
return True;
***************
*** 259,262 ****
--- 277,293 ----
}
}
+
+ 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');
if (is_admin())
***************
*** 264,301 ****
/* This is where we will keep track of our postion. */
/* Developers won't have to pass around a variable then */
- $session_data =
$GLOBALS['phpgw']->session->appsession('session_data','preferences');
! if (!($GLOBALS['type'] = get_var('type',Array('GET','POST'))))
! {
! $GLOBALS['type'] = is_array($session_data) ?
$session_data['type'] : 'user';
! }
if (empty($GLOBALS['type']))
{
$GLOBALS['type'] = 'user';
}
-
$GLOBALS['phpgw']->session->appsession('session_data','preferences',array(
- 'type' => $GLOBALS['type']
- ));
-
- $tabs[] = array(
- 'label' => lang('Your preferences'),
- 'link' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' .
$GLOBALS['appname'] . '&type=user')
- );
- $tabs[] = array(
- 'label' => lang('Default preferences'),
- 'link' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' .
$GLOBALS['appname'] . '&type=default')
- );
- $tabs[] = array(
- 'label' => lang('Forced preferences'),
- 'link' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=' .
$GLOBALS['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));
}
else
--- 295,305 ----
/* This is where we will keep track of our postion. */
/* Developers won't have to pass around a variable then */
! $GLOBALS['type'] =
get_var('type',Array('GET','POST'),$session_data['type']);
!
if (empty($GLOBALS['type']))
{
$GLOBALS['type'] = 'user';
}
}
else
***************
*** 303,306 ****
--- 307,320 ----
$GLOBALS['type'] = 'user';
}
+ $prefix = get_var('prefix',array('GET'),$session_data['prefix']);
+
+ $show_help = "$session_data[show_help]" != '' ?
$session_data['show_help'] :
+
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['show_help']);
+
+ if ($toggle_help = get_var('toggle_help','POST'))
+ {
+ $show_help = intval(!$show_help);
+ }
+ $has_help = 0;
/* Only load if there working on the default preferences */
***************
*** 311,320 ****
}
! if (get_var('submit',Array('POST')))
{
/* Don't use a switch here, we need to check some permissions
durring the ifs */
if ($GLOBALS['type'] == 'user' || !($GLOBALS['type']))
{
! process_array($p, $user);
}
--- 325,334 ----
}
! if ($_POST['submit'])
{
/* Don't use a switch here, we need to check some permissions
durring the ifs */
if ($GLOBALS['type'] == 'user' || !($GLOBALS['type']))
{
! process_array($GLOBALS['phpgw']->preferences, $user);
}
***************
*** 329,340 ****
}
! Header('Location: ' .
$GLOBALS['phpgw']->link('/preferences/index.php'));
! $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
! exit;
! }
! $GLOBALS['phpgw']->common->phpgw_header();
! if ($GLOBALS['appname'] == 'preferences')
{
$t->set_var('lang_title',lang('Preferences'));
--- 343,363 ----
}
! if (!is_admin())
! {
!
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
! }
! if ($GLOBALS['type'] == 'user' && $_GET['appname'] ==
'preferences' && $user['show_help'] != '')
! {
! $show_help = $user['show_help']; // use it, if
admin changes his help-prefs
! }
! }
!
$GLOBALS['phpgw']->session->appsession('session_data','preferences',array(
! 'type' => $GLOBALS['type'], // save our state in
the app-session
! 'show_help' => $show_help,
! 'prefix' => $prefix
! ));
! if ($_GET['appname'] == 'preferences')
{
$t->set_var('lang_title',lang('Preferences'));
***************
*** 342,355 ****
else
{
! $t->set_var('lang_title',lang('%1 -
Preferences',$GLOBALS['phpgw_info']['apps'][$GLOBALS['HTTP_GET_VARS']['appname']]['title']));
}
!
$t->set_var('action_url',$GLOBALS['phpgw']->link('/preferences/preferences.php','appname='
. $GLOBALS['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 ($GLOBALS['appname'] == 'preferences')
{
if (!
$GLOBALS['phpgw']->hooks->single('settings','preferences',True))
--- 365,396 ----
else
{
! $t->set_var('lang_title',lang('%1 -
Preferences',$GLOBALS['phpgw_info']['apps'][$_GET['appname']]['title']));
}
!
$t->set_var('action_url',$GLOBALS['phpgw']->link('/preferences/preferences.php','appname='
. $_GET['appname']));
! 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
! if ($_GET['prefix'] != '')
! {
! $prefix = explode('/',$_GET['prefix']);
! foreach ($prefix as $pre)
! {
! $prefs = &$prefs[$pre];
! }
! }
! }
! //echo "prefs=<pre>"; print_r($prefs); echo "</pre>\n";
!
! if ($_GET['appname'] == 'preferences')
{
if (!
$GLOBALS['phpgw']->hooks->single('settings','preferences',True))
***************
*** 360,364 ****
else
{
! if (!
$GLOBALS['phpgw']->hooks->single('settings',$GLOBALS['appname']))
{
$error = True;
--- 401,405 ----
else
{
! if (!
$GLOBALS['phpgw']->hooks->single('settings',$_GET['appname']))
{
$error = True;
***************
*** 368,385 ****
if ($error)
{
$t->set_var('messages',lang('Error: There was a problem finding
the preference file for %1 in %2',
!
$GLOBALS['phpgw_info']['navbar'][$GLOBALS['appname']]['title'],PHPGW_SERVER_ROOT
. SEP
! . $GLOBALS['appname'] . SEP . 'inc' . SEP .
'hook_settings.inc.php'));
}
- $t->pfp('out','header');
! $t->set_var('lang_submit', lang('submit'));
$t->set_var('lang_cancel', lang('cancel'));
! if (! $error)
{
! $t->pfp('out','list');
! $t->pfp('out','footer');
}
! $GLOBALS['phpgw']->common->phpgw_footer();
?>
--- 409,453 ----
if ($error)
{
+ $t->set_block('preferences','form','formhandle'); // skip
the form
+ $t->set_var('formhandle','');
+
$t->set_var('messages',lang('Error: There was a problem finding
the preference file for %1 in %2',
!
$GLOBALS['phpgw_info']['navbar'][$_GET['appname']]['title'],PHPGW_SERVER_ROOT .
SEP
! . $_GET['appname'] . SEP . 'inc' . SEP .
'hook_settings.inc.php'));
}
! 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'));
$t->set_var('lang_cancel', lang('cancel'));
+ $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')).'">' : '');
! if (!$list_shown)
{
! show_list();
}
! $t->parse('phpgw_body','preferences');
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: preferences preferences.php,1.27,1.28,
Ralf Becker <address@hidden> <=