use new et2 site config

This commit is contained in:
Ralf Becker 2016-04-25 15:57:38 +00:00
parent 5740c448ad
commit 06c4b2db23
6 changed files with 233 additions and 355 deletions

View File

@ -10,6 +10,8 @@
* @version $Id$
*/
use EGroupware\Api;
/**
* Class containing admin, preferences and sidebox-menus and other hooks
*/
@ -452,15 +454,80 @@ class addressbook_hooks
}
/**
* Hook returning options for deny_acl groups
* Called before displaying site configuration
*
* @param array $config
* @return array with additional config to merge and "sel_options" values
*/
public static function allow_account_edit($config)
public static function config(array $config)
{
$accountsel = new uiaccountsel();
$bocontacts = new Api\Contacts();
return '<input type="hidden" value="" name="newsettings[allow_account_edit]" />'.
$accountsel->selection('newsettings[allow_account_edit]', 'allow_account_edit', $config['allow_account_edit'], 'groups', 4);
// get the list of account fields
$own_account_acl = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// some fields the user should never be allowed to edit or are covert by an other attribute (n_fn for all n_*)
if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix')))
{
$own_account_acl[$field] = $label;
}
}
$own_account_acl['link_to'] = 'Links';
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{
foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
{
$own_account_acl['#'.$name] = $data['label'];
}
}
$org_fields = $own_account_acl;
unset($org_fields['n_fn'], $org_fields['account_id']);
// Remove country codes as an option, it will be added by BO constructor
unset($org_fields['adr_one_countrycode'], $org_fields['adr_two_countrycode']);
$supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$copy_fields = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// some fields the user should never be allowed to copy or are coverted by an other attribute (n_fn for all n_*)
if (!in_array($field,array('id','tid','created','creator','modified','modifier','account_id','uid','etag','n_fn')))
{
$copy_fields[$field] = $label;
}
}
if ($config['contact_repository'] != 'ldap') // no custom-fields in ldap
{
foreach(Api\Storage\Customfields::get('addressbook') as $name => $data)
{
$copy_fields['#'.$name] = $data['label'];
}
}
// Remove country codes as an option, it will be added by UI constructor
if(in_array('adr_one_countrycode', $supported_fields))
{
unset($copy_fields['adr_one_countrycode'], $copy_fields['adr_two_countrycode']);
}
$repositories = array('sql' => 'SQL');
// check account-repository, contact-repository LDAP is only availible for account-repository == ldap
if ($config['account_repository'] == 'ldap' || !$config['account_repository'] && $config['auth_type'] == 'ldap')
{
$repositories['ldap'] = 'LDAP';
$repositories['sql-ldap'] = 'SQL --> LDAP ('.lang('read only').')';
}
$ret = array(
'sel_options' => array(
'own_account_acl' => $own_account_acl,
'org_fileds_to_update' => $org_fields, // typo has to stay, as it was there allways and we would loose existing config :(
'copy_fields' => $copy_fields,
'fileas' => $bocontacts->fileas_options(),
'contact_repository' => $repositories,
),
);
return $ret;
}
}

View File

@ -1,171 +0,0 @@
<?php
/**
* eGroupware - Addressbook configuration
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* Hook to query available contact repositories for addressbook config
*
* @param array $config
* @return string with options
*/
function contact_repositories($config)
{
$repositories = array('sql' => 'SQL');
// check account-repository, contact-repository LDAP is only availible for account-repository == ldap
if ($config['account_repository'] == 'ldap' || !$config['account_repository'] && $config['auth_type'] == 'ldap')
{
$repositories['ldap'] = 'LDAP';
$repositories['sql-ldap'] = 'SQL --> LDAP ('.lang('read only').')';
}
$options = '';
foreach($repositories as $repo => $label)
{
$options .= '<option value="'.$repo.'"'.($config['contact_repository'] == $repo ? ' selected="1">' : '>').
$label."</option>\n";
}
return $options;
}
/**
* Hook to get available fileas types selectbox for addressbook config
*
* @param array $config
* @return string html
*/
function select_fileas($config)
{
$bocontacts = new addressbook_bo();
return html::select('fileas','',array('' => lang('Set only full name'))+$bocontacts->fileas_options(),true);
}
/**
* Hook to get a multiselect box with all fieleds of onw-account-acl for addressbook config
*
* @param array $config
* @return string html
*/
function own_account_acl($config)
{
$bocontacts = new addressbook_bo();
$supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$fields = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// some fields the user should never be allowed to edit or are covert by an other attribute (n_fn for all n_*)
if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix')))
{
$fields[$field] = $label;
}
}
$fields['link_to'] = 'Links';
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{
foreach(config::get_customfields('addressbook') as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
}
return html::checkbox_multiselect('newsettings[own_account_acl]',$config['own_account_acl'],$fields,true,'',4);
}
/**
* Hook to get a multiselect box with all fields of org-fields-to-update for addressbook config
*
* @param array $config
* @return string html
*/
function org_fileds_to_update($config)
{
$bocontacts = new addressbook_bo();
$supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$fields = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// some fields never making sense for an organisation
if (!in_array($field,array('id','tid','owner','created','creator','modified','modifier','private','n_prefix','n_given','n_middle','n_family','n_suffix','n_fn','account_id')))
{
$fields[$field] = $label;
}
}
if ($config['contact_repository'] != 'ldap') // no custom-fields in ldap
{
foreach(config::get_customfields('addressbook') as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
}
// Remove country codes as an option, it will be added by BO constructor
unset($fields['adr_one_countrycode']);
unset($fields['adr_two_countrycode']);
return html::table(array(array(
html::checkbox_multiselect('newsettings[org_fileds_to_update]',
$config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',6,
true,'',false
),
html::submit_button(
'','',"var boxen = \$j('[name^=\'newsettings\[org_fileds_to_update\]\']'); boxen.prop('checked', !boxen.prop('checked')); return false;",
true,'style="float:left;"','check','phpgwapi','button'
)
)));
}
/**
* Hook to get a multiselect box with all fieleds of fields used for copying for addressbook config
*
* @param array $config
* @return string html
*/
function copy_fields($config)
{
$bocontacts = new addressbook_bo();
$supported_fields = $bocontacts->get_fields('supported',null,0); // fields supported by the backend (ldap schemas!)
// get the list of account fields
$fields = array();
foreach($bocontacts->contact_fields as $field => $label)
{
// some fields the user should never be allowed to copy or are coverted by an other attribute (n_fn for all n_*)
if (!in_array($field,array('id','tid','created','creator','modified','modifier','account_id','uid','etag','n_fn')))
{
$fields[$field] = $label;
}
}
if ($config['contact_repository'] != 'ldap') // no custom-fields in ldap
{
foreach(config::get_customfields('addressbook') as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
}
// Remove country codes as an option, it will be added by UI constructor
if(in_array('adr_one_countrycode', $supported_fields))
{
unset($fields['adr_one_countrycode']);
unset($fields['adr_two_countrycode']);
}
return html::table(array(array(
html::checkbox_multiselect('newsettings[copy_fields]',
$config['copy_fields'] ? $config['copy_fields'] : addressbook_ui::$copy_fields,
$fields,true,'',6,true,'',false
),
html::submit_button(
'','',"var boxen = \$j('[name^=\'newsettings\[copy_fields\]\']'); boxen.prop('checked', !boxen.prop('checked')); return false;",
true,'style="float:left;"','check','phpgwapi','button'
)
)));
}

View File

@ -41,7 +41,7 @@ $setup_info['addressbook']['hooks']['deletegroup'] = 'addressbook.addressbook_bo
$setup_info['addressbook']['hooks']['delete_category'] = 'addressbook.addressbook_bo.delete_category';
$setup_info['addressbook']['hooks']['search_link'] = 'addressbook_hooks::search_link';
$setup_info['addressbook']['hooks']['calendar_resources'] = 'addressbook_hooks::calendar_resources';
$setup_info['addressbook']['hooks'][] = 'config';
$setup_info['addressbook']['hooks']['config'] = 'addressbook_hooks::config';
$setup_info['addressbook']['hooks']['group_acl'] = 'addressbook_hooks::group_acl';
$setup_info['addressbook']['hooks']['not_enum_group_acls'] = 'addressbook_hooks::not_enum_group_acls';
$setup_info['addressbook']['hooks']['export_limit'] = 'addressbook_hooks::getAppExportLimit';

View File

@ -1,178 +0,0 @@
<!-- BEGIN header -->
<style>
select[multiple] { width:100%;}
</style>
<form method="POST" action="{action_url}">
{hidden_vars}
<table border="0" align="center">
<tr class="th">
<td colspan="2"><font color="{th_text}">&nbsp;<b>{title}</b></font></td>
</tr>
<tr>
<td colspan="2">&nbsp;<i><font color="red">{error}</i></font></td>
</tr>
<!-- END header -->
<!-- BEGIN body -->
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_Telephony_integration}</b></td>
</tr>
<tr class="row_on">
<td width="60%">&nbsp;{lang_URL_to_link_telephone_numbers_to_(use_%1_=_number_to_call,_%u_=_account_name,_%t_=_account_phone)}:</td>
<td><input name="newsettings[call_link]" value="{value_call_link}" size="40"></td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Size_of_popup_(WxH,_eg.400x300,_if_a_popup_should_be_used)}:</td>
<td><input name="newsettings[call_popup]" value="{value_call_popup}" size="10"></td>
</tr>
<tr class="th">
<td colspan="2">
&nbsp;<b>{lang_Allow_users_to_maintain_their_own_account-data}</b>
</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Fields_the_user_is_allowed_to_edit_himself}</td>
<td>
{hook_own_account_acl}
</td>
</tr>
<tr class="th">
<td colspan="2">
&nbsp;<b>{lang_General}</b>
</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Use_a_category_tree?}</td>
<td>
<select name="newsettings[cat_tab]">
<option value="True">{lang_No}</option>
<option value="Tree"{selected_cat_tab_Tree}>{lang_Yes}</option>
</select>
</td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Update_Fields_by_edited_organisations?}</td>
<td>
{hook_org_fileds_to_update}
</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Fields_to_copy_when_copying_an_address?}</td>
<td>
{hook_copy_fields}
</td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Use_an_extra_tab_for_private_custom_fields?}</td>
<td>
<select name="newsettings[private_cf_tab]">
<option value="">{lang_No}</option>
<option value="True"{selected_private_cf_tab_True}>{lang_Yes}</option>
</select>
</td>
</tr>
<tr class="th">
<td colspan="2">
&nbsp;<b>{lang_Security}</b>
</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_How_many_contacts_should_non-admins_be_able_to_export}
{lang_(empty_=_use_global_limit,_no_=_no_export_at_all)}:</td>
<td><input name="newsettings[contact_export_limit]" value="{value_contact_export_limit}" size="5"></td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_Allow_members_of_following_groups_to_edit_contact-data_of_accounts}:</td>
<td>{call_addressbook_hooks::allow_account_edit}</td>
</tr>
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_History_logging}</b></td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Prevent_deleting_of_contacts}</td>
<td>
<select name="newsettings[history]">
<option value="">{lang_No}</option>
<option value="history"{selected_history_history}>{lang_Yes,_only_admins_can_purge_deleted_items}</option>
<option value="userpurge"{selected_history_userpurge}>{lang_Yes,_users_can_purge_their_deleted_items}</option>
</select>
</td>
</tr>
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_Contact_maintenance}</b></td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Set_full_name_and_file_as_field_in_contacts_of_all_users_(either_all_or_only_empty_values)}:</td>
<td>
{hook_select_fileas}
<input type="button" onclick="document.location.href='index.php?menuaction=addressbook.addressbook_ui.admin_set_fileas&all=1&type='+this.form.fileas.value;" value="{lang_All}" />
<input type="button" onclick="document.location.href='index.php?menuaction=addressbook.addressbook_ui.admin_set_fileas&type='+this.form.fileas.value;" value="{lang_Empty}" />
</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Cleanup_addressbook_fields_(apply_if_synchronization_creates_duplicates)}:</td>
<td>
<input type="button" onclick="document.location.href='index.php?menuaction=addressbook.addressbook_ui.admin_set_all_cleanup'" value="{lang_Start}" />
</td>
</tr>
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_Contact_repository}</b></td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Select_where_you_want_to_store_/_retrieve_contacts}:</td>
<td>
<select name="newsettings[contact_repository]">
{hook_contact_repositories}
</select>
</td>
</tr>
<tr class="row_off">
<td colspan="2">&nbsp;{lang_You_can_only_use_LDAP_as_contact_repository_if_the_accounts_are_stored_in_LDAP_too!}</td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_Account_repository}:</td>
<td>
<b><script>document.write('{value_account_repository}' == 'ldap' || '{value_account_repository}' == '' && '{value_auth_type}' == 'ldap' ? 'LDAP' : 'SQL');</script></b>
({lang_Can_be_changed_via_Setup_>>_Configuration})
</td>
</tr>
<tr class="th">
<td colspan="2">&nbsp;<b>{lang_LDAP_settings_for_contacts}</b></td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_LDAP_host_for_contacts}:</td>
<td><input name="newsettings[ldap_contact_host]" value="{value_ldap_contact_host}"></td>
</tr>
<tr class="row_off">
<td>&nbsp;{lang_LDAP_context_for_contacts}:</td>
<td><input name="newsettings[ldap_contact_context]" value="{value_ldap_contact_context}" size="40"></td>
</tr>
<tr class="th">
<td colspan="2">
&nbsp;{lang_Additional_information_about_using_LDAP_as_contact_repository}:
<a href="addressbook/doc/README" target="_blank">README</a>
</td>
</tr>
<tr class="row_on">
<td>&nbsp;<b>{lang_Migration_to_LDAP}</b></td>
<td>
<select name="migrate">
<option value="">{lang_Select_migration_type}</option>
<option value="contacts" title="{lang_if_accounts_are_already_in_LDAP}">{lang_contacts_to_LDAP}</option>
<option value="contacts,accounts" title="{lang_use_setup_for_a_full_account-migration}">{lang_contacts_and_account_contact-data_to_LDAP}</option>
<option value="contacts,accounts-back" title="{lang_for_read_only_LDAP}">{lang_contacts_to_LDAP,_account_contact-data_to_SQL}</option>
<option value="sql" title="{lang_for_read_only_LDAP}">{lang_contacts_and_account_contact-data_to_SQL}</option>
</select>
<input type="button" onclick="if (this.form.migrate.value) document.location.href='index.php?menuaction=addressbook.addressbook_ui.migrate2ldap&type='+this.form.migrate.value;" value="{lang_Start}" />
</td>
</tr>
<!-- END body -->
<!-- BEGIN footer -->
<tr valign="bottom" style="height: 30px;">
<td colspan="2" align="center">
<input type="submit" name="submit" value="{lang_submit}">
<input type="submit" name="cancel" value="{lang_cancel}">
</td>
</tr>
</table>
</form>
<!-- END footer -->

View File

@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="addressbook.config" template="" lang="" group="0" version="16.1">
<grid width="100%" class="admin-config egwGridView_grid">
<columns>
<column width="60%"/>
<column/>
</columns>
<rows>
<row>
<description value="Telephony integration" span="all" class="subHeader"/>
</row>
<row>
<description value="URL to link telephone numbers to (use %1 = number to call, %u = account name, %t = account phone)" label="%s:"/>
<textbox id="newsettings[call_link]" size="40"/>
</row>
<row>
<description value="Size of popup (WxH, eg.400x300, if a popup should be used)" label="%s:"/>
<textbox id="newsettings[call_popup]" size="10"/>
</row>
<row>
<description value="Allow users to maintain their own account-data" span="all" class="subHeader"/>
</row>
<row>
<description value="Fields the user is allowed to edit himself"/>
<select id="newsettings[own_account_acl]" multiple="true" tags="true"/>
</row>
<row>
<description value="General" span="all" class="subHeader"/>
</row>
<row>
<description value="Use a category tree?"/>
<select id="newsettings[cat_tab]">
<option value="True">No</option>
<option value="Tree">Yes</option>
</select>
</row>
<row>
<description value="Update Fields by edited organisations?"/>
<hbox>
<select id="newsettings[org_fileds_to_update]" multiple="true" rows="4"/>
<button onclick="widget.getParent().getWidgetById('newsettings[org_fileds_to_update]').select_all_toggle();" label="Select all" image="check"/>
</hbox>
</row>
<row>
<description value="Fields to copy when copying an address?"/>
<hbox>
<select id="newsettings[copy_fields]" multiple="true" rows="4"/>
<button onclick="widget.getParent().getWidgetById('newsettings[copy_fields]').select_all_toggle();" label="Select all" image="check"/>
</hbox>
</row>
<row>
<description value="Use an extra tab for private custom fields?"/>
<select id="newsettings[private_cf_tab]">
<option value="">No</option>
<option value="True">Yes</option>
</select>
</row>
<row>
<description value="Security" span="all" class="subHeader"/>
</row>
<row>
<vbox>
<description value="How many contacts should non-admins be able to export"/>
<description value="(empty = use global limit, no = no export at all)"/>
</vbox>
<textbox id="newsettings[contact_export_limit]" size="5"/>
</row>
<row>
<description value="Allow members of following groups to edit contact-data of accounts" label="%s:"/>
<select-account id="newsettings[allow_account_edit]" account_type="groups" multiple="true" tags="true" width="100%"/>
</row>
<row>
<description value="History logging" span="all" class="subHeader"/>
</row>
<row>
<description value="Prevent deleting of contacts"/>
<select id="newsettings[history]">
<option value="">No</option>
<option value="history">Yes, only admins can purge deleted items</option>
<option value="userpurge">Yes, users can purge their deleted items</option>
</select>
</row>
<row>
<description value="Contact maintenance" span="all" class="subHeader"/>
</row>
<row>
<description value="Set full name and file as field in contacts of all users (either all or only empty values)" label="%s:"/>
<hbox>
<select id="fileas" empty_label="Set only full name" width="70%"/>
<button onclick="document.location.href='index.php?menuaction=addressbook.addressbook_ui.admin_set_fileas&amp;all=1&amp;type='+this.form.fileas.value;" label="All"/>
<button onclick="document.location.href='index.php?menuaction=addressbook.addressbook_ui.admin_set_fileas&amp;type='+this.form.fileas.value;" label="Empty"/>
</hbox>
</row>
<row>
<description value="Cleanup addressbook fields (apply if synchronization creates duplicates)" label="%s:"/>
<button onclick="document.location.href='index.php?menuaction=addressbook.addressbook_ui.admin_set_all_cleanup'" label="Start"/>
</row>
<row>
<description value="Contact repository" span="all" class="subHeader"/>
</row>
<row>
<description value="Select where you want to store / retrieve contacts" label="%s:"/>
<select id="newsettings[contact_repository]"/>
</row>
<row>
<description value="You can only use LDAP as contact repository if the accounts are stored in LDAP too!" span="all"/>
</row>
<row>
<description value="Account repository" label="%s:"/>
<hbox>
<description id="newsettings[account_repository]" class="subHeader"/>
<description value="Can be changed via Setup >> Configuration"/>
</hbox>
</row>
<row>
<description value="LDAP settings for contacts" span="all" class="subHeader"/>
</row>
<row>
<description value="LDAP host for contacts" label="%s:"/>
<textbox id="newsettings[ldap_contact_host]"/>
</row>
<row>
<description value="LDAP context for contacts" label="%s:"/>
<textbox id="newsettings[ldap_contact_context]" size="40"/>
</row>
<row>
<description value="Additional information about using LDAP as contact repository" class="subHeader"/>
<description value="README" href="/doc/ldap/README.contacts" extra_link_target="_blank"/>
</row>
<row>
<description value="Migration to LDAP"/>
<hbox>
<select id="migrate">
<option value="">Select migration type</option>
<option value="contacts" title="if accounts are already in LDAP">contacts to LDAP</option>
<option value="contacts,accounts" title="use setup for a full account-migration">contacts and account contact-data to LDAP</option>
<option value="contacts,accounts-back" title="for read only LDAP">contacts to LDAP, account contact-data to SQL</option>
<option value="sql" title="for read only LDAP">contacts and account contact-data to SQL</option>
</select>
<button onclick="if (this.form.migrate.value) document.location.href='index.php?menuaction=addressbook.addressbook_ui.migrate2ldap&amp;type='+this.form.migrate.value;" label="Start"/>
</hbox>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -609,6 +609,17 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
this.value = _value;
},
/**
* Method to check all options of a multi-select, if not all are selected, or none if all where selected
*
* @todo: add an attribute to automatic add a button calling this method
*/
select_all_toggle: function()
{
var all = jQuery("input",this.multiOptions);
all.prop("checked", jQuery("input:checked",this.multiOptions).length == all.length ? false : true);
},
/**
* Add a button to toggle between single select and multi select.
*