forked from extern/egroupware
Fix some of the horrendous formatting
This commit is contained in:
parent
cbd35e90eb
commit
6f63d49bd0
@ -1,15 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
phpGroupWare admin/config.php
|
phpGroupWare admin/config.php
|
||||||
|
|
||||||
Abstract
|
Abstract
|
||||||
|
|
||||||
A brief introduction to writing hooks and templates for any
|
A brief introduction to writing hooks and templates for any application to use
|
||||||
application to use this admin interface, by
|
this admin interface, by Miles Lott <milosch@phpgroupware.org> Dec 22, 2001.
|
||||||
|
|
||||||
Abstract
|
|
||||||
|
|
||||||
Miles Lott <milosch@phpgroupware.org> Dec 22, 2001.
|
|
||||||
|
|
||||||
1 Files
|
1 Files
|
||||||
|
|
||||||
@ -22,67 +17,39 @@ include a POST method form. The following template tags
|
|||||||
may be used:
|
may be used:
|
||||||
|
|
||||||
1. {action_url} - A phpgw->link to config.php will be inserted.
|
1. {action_url} - A phpgw->link to config.php will be inserted.
|
||||||
|
|
||||||
2. {title} - This will be parsed to display 'Site Configuration'.
|
2. {title} - This will be parsed to display 'Site Configuration'.
|
||||||
|
3. {th_bg},{th_text},{row_on},{row_off} - Replaced with the current theme colors.
|
||||||
3. {th_bg},{th_text},{row_on},{row_off} - Replaced with the
|
|
||||||
current theme colors.
|
|
||||||
|
|
||||||
and the following special types:
|
and the following special types:
|
||||||
|
|
||||||
1. {lang_XXX} - Filled with lang('XXX').
|
1. {lang_XXX} - Filled with lang('XXX').
|
||||||
|
2. {value_XXX} - Filled with the current value of config item 'XXX'.
|
||||||
2. {value_XXX} - Filled with the current value of config item
|
3. {selected_XXX} - set to '', or ' selected' if an option value is current.
|
||||||
'XXX'.
|
4. {hook_XXX} - Calls a function named XXX (will be discussed later).
|
||||||
|
|
||||||
3. {selected_XXX} - set to '', or ' selected' if an option
|
|
||||||
value is current.
|
|
||||||
|
|
||||||
4. {hook_XXX} - Calls a function named XXX (will be discussed
|
|
||||||
later).
|
|
||||||
|
|
||||||
Following is an example from the addressbook application:
|
Following is an example from the addressbook application:
|
||||||
|
|
||||||
<form method="POST" action="{action_url}">
|
<form method="POST" action="{action_url}">
|
||||||
|
|
||||||
<table border="0" align="center">
|
<table border="0" align="center">
|
||||||
|
|
||||||
<tr bgcolor="{th_bg}">
|
<tr bgcolor="{th_bg}">
|
||||||
|
|
||||||
<td colspan="2"><font color="{th_text}"> <b>{title}</b></font></td>
|
<td colspan="2"><font color="{th_text}"> <b>{title}</b></font></td>
|
||||||
|
|
||||||
</tr> <tr bgcolor="{th_err}">
|
</tr> <tr bgcolor="{th_err}">
|
||||||
|
|
||||||
<td colspan="2"> <b>{error}</b></font></td>
|
<td colspan="2"> <b>{error}</b></font></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<!-- END header -->
|
<!-- END header -->
|
||||||
|
|
||||||
<!-- BEGIN body -->
|
<!-- BEGIN body -->
|
||||||
|
|
||||||
<tr bgcolor="{row_on}">
|
<tr bgcolor="{row_on}">
|
||||||
|
|
||||||
<td colspan="2"> </td>
|
<td colspan="2"> </td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr bgcolor="{row_off}">
|
<tr bgcolor="{row_off}">
|
||||||
|
|
||||||
<td colspan="2"> <b>{lang_Addressbook}/{lang_Contact_Settings}</b></font>
|
<td colspan="2"> <b>{lang_Addressbook}/{lang_Contact_Settings}</b></font>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr bgcolor="{row_on}">
|
<tr bgcolor="{row_on}">
|
||||||
|
|
||||||
<td>{lang_Contact_application}:</td>
|
<td>{lang_Contact_application}:</td>
|
||||||
|
|
||||||
<td><input name="newsettings[contact_application]" value="{value_contact_application}"></td>
|
<td><input name="newsettings[contact_application]" value="{value_contact_application}"></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
Note the fieldname, newsettings[contact_application]. This
|
Note the fieldname, newsettings[contact_application]. This
|
||||||
@ -97,19 +64,12 @@ if available.
|
|||||||
Let's take a look at part of the preferences/default/config.tpl:
|
Let's take a look at part of the preferences/default/config.tpl:
|
||||||
|
|
||||||
<tr bgcolor="{row_on}">
|
<tr bgcolor="{row_on}">
|
||||||
|
|
||||||
<td>{lang_Country_Selection} ({lang_Text_Entry}/{lang_SelectBox}):</td>
|
<td>{lang_Country_Selection} ({lang_Text_Entry}/{lang_SelectBox}):</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|
||||||
<select name="newsettings[countrylist]">
|
<select name="newsettings[countrylist]">
|
||||||
|
|
||||||
{hook_country_set}
|
{hook_country_set}
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
Here, we are adding a new element, {hook_country_set}. This
|
Here, we are adding a new element, {hook_country_set}. This
|
||||||
@ -125,41 +85,22 @@ hook_country_set, here is the corresponding function in
|
|||||||
preferences/inc/hook_config.inc.php:
|
preferences/inc/hook_config.inc.php:
|
||||||
|
|
||||||
function country_set($config)
|
function country_set($config)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
$country = array( 'user_choice' => 'Users Choice', 'force_select' => 'Force Selectbox' );
|
||||||
$country = array( 'user_choice' => 'Users Choice', 'force_select'
|
|
||||||
=> 'Force Selectbox' );
|
|
||||||
|
|
||||||
while (list ($key, $value) = each ($country))
|
while (list ($key, $value) = each ($country))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if ($config['countrylist'] == $key)
|
if ($config['countrylist'] == $key)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$selected = ' selected';
|
$selected = ' selected';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$selected = '';
|
$selected = '';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$descr = lang($value);
|
$descr = lang($value);
|
||||||
|
$out .= '<option value="' . $key . '"' . $selected . '>' . $descr . '</option>' . "\n";
|
||||||
$out .= '<option value="' . $key . '"' . $selected
|
|
||||||
. '>' . $descr . '</option>' . "\n";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Note again the template value we used earlier, {hook_country_set}.
|
Note again the template value we used earlier, {hook_country_set}.
|
||||||
@ -182,42 +123,24 @@ was found. Following then are functions named after each
|
|||||||
config we want to validate. The following example is for
|
config we want to validate. The following example is for
|
||||||
addressbook:
|
addressbook:
|
||||||
|
|
||||||
$GLOBALS['phpgw_info']['server']['found_validation_hook']
|
$GLOBALS['phpgw_info']['server']['found_validation_hook'] = True;
|
||||||
= True;
|
|
||||||
|
|
||||||
/* Check a specific setting. Name must match the setting.
|
/* Check a specific setting. Name must match the setting. */
|
||||||
*/
|
|
||||||
|
|
||||||
function ldap_contact_context($value='')
|
function ldap_contact_context($value='')
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if($value == $GLOBALS['phpgw_info']['server']['ldap_context'])
|
if($value == $GLOBALS['phpgw_info']['server']['ldap_context'])
|
||||||
|
|
||||||
{
|
{
|
||||||
|
$GLOBALS['config_error'] = 'Contact context for ldap must be different from the context used for accounts';
|
||||||
$GLOBALS['config_error'] = 'Contact context for
|
|
||||||
ldap must be different from the context used for accounts';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif($value == $GLOBALS['phpgw_info']['server']['ldap_group_context'])
|
elseif($value == $GLOBALS['phpgw_info']['server']['ldap_group_context'])
|
||||||
|
|
||||||
{
|
{
|
||||||
|
$GLOBALS['config_error'] = 'Contact context for ldap must be different from the context used for groups';
|
||||||
$GLOBALS['config_error'] = 'Contact context for
|
|
||||||
ldap must be different from the context used for groups';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$GLOBALS['config_error'] = '';
|
$GLOBALS['config_error'] = '';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Here we created a function to check the entered value for
|
Here we created a function to check the entered value for
|
||||||
@ -240,40 +163,21 @@ config.php redirects to admin/index.php.
|
|||||||
However, there is one more function that may be included
|
However, there is one more function that may be included
|
||||||
in hook_config_validate.inc.php:
|
in hook_config_validate.inc.php:
|
||||||
|
|
||||||
/* Check all settings to validate input. Name must be
|
/* Check all settings to validate input. Name must be 'final_validation' */
|
||||||
'final_validation' */
|
|
||||||
|
|
||||||
function final_validation($value='')
|
function final_validation($value='')
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
if($value['contact_repository'] == 'ldap' && !$value['ldap_contact_dn'])
|
if($value['contact_repository'] == 'ldap' && !$value['ldap_contact_dn'])
|
||||||
|
|
||||||
{
|
{
|
||||||
|
$GLOBALS['config_error'] = 'Contact dn must be set';
|
||||||
$GLOBALS['config_error'] = 'Contact dn must be
|
|
||||||
set';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
elseif($value['contact_repository'] == 'ldap' && !$value['ldap_contact_context'])
|
||||||
elseif($value['contact_repository'] == 'ldap' &&
|
|
||||||
!$value['ldap_contact_context'])
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
$GLOBALS['config_error'] = 'Contact context must be set';
|
||||||
$GLOBALS['config_error'] = 'Contact context must
|
|
||||||
be set';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$GLOBALS['config_error'] = '';
|
$GLOBALS['config_error'] = '';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.php checks for the existence of the function 'final_validation()'.
|
config.php checks for the existence of the function 'final_validation()'.
|
||||||
|
Loading…
Reference in New Issue
Block a user