addressbook maintenance: set full name and file as in contacts of all

users
This commit is contained in:
Ralf Becker 2009-05-09 07:58:16 +00:00
parent c84a6fd78a
commit 4634465bb8
6 changed files with 151 additions and 2 deletions

View File

@ -369,6 +369,70 @@ class addressbook_bo extends addressbook_so
return $options;
}
/**
* Set n_fileas (and n_fn) in contacts of all users (called by Admin >> Addressbook >> Site configuration (Admin only)
*
* If $all all fileas fields will be set, if !$all only empty ones
*
* @param string $fileas_type '' or type of $this->fileas_types
* @param int $all=false update all contacts or only ones with empty values
* @param int &$errors=null on return number of errors
* @return int|boolean number of contacts updated, false for wrong fileas type
*/
function set_all_fileas($fileas_type,$all=false,&$errors=null,$ignore_acl=false)
{
if ($type != '' && !in_array($type,$this->fileas_types))
{
return false;
}
if ($ignore_acl)
{
unset($this->somain->grants); // to NOT limit search to contacts readable by current user
}
// to be able to work on huge contact repositories we read the contacts in chunks of 100
for($n = $updated = $errors = 0; ($contacts = parent::search($all ? array() : array(
'n_fileas IS NULL',
"n_fileas=''",
'n_fn IS NULL',
"n_fn=''",
),false,'','','',false,'OR',array($n*100,100))); ++$n)
{
foreach($contacts as $contact)
{
$old_fn = $contact['n_fn'];
$old_fileas = $contact['n_fileas'];
$contact['n_fn'] = $this->fullname($contact);
// only update fileas if type is given AND (all should be updated or n_fileas is empty)
if ($fileas_type && ($all || empty($contact['n_fileas'])))
{
$contact['n_fileas'] = $this->fileas($contact,$fileas_type);
}
if ($old_fileas != $contact['n_fileas'] || $old_fn != $contact['n_fn'])
{
//echo "<p>('$old_fileas' != '{$contact['n_fileas']}' || '$old_fn' != '{$contact['n_fn']}')=".array2string($old_fileas != $contact['n_fileas'] || $old_fn != $contact['n_fn'])."</p>\n";
// only specify/write updated fields plus "keys"
$contact = array_intersect_key($contact,array(
'id' => true,
'owner' => true,
'private' => true,
'account_id' => true,
'uid' => true,
)+($old_fileas != $contact['n_fileas'] ? array('n_fileas' => true) : array())+($old_fn != $contact['n_fn'] ? array('n_fn' => true) : array()));
if ($this->save($contact,$ignore_acl))
{
$updated++;
}
else
{
$errors++;
}
}
}
}
return $updated;
}
/**
* get full name from the name-parts
*

View File

@ -25,6 +25,7 @@ class addressbook_ui extends addressbook_bo
'photo' => True,
'emailpopup'=> True,
'migrate2ldap' => True,
'admin_set_fileas' => True,
'cat_add' => True,
);
/**
@ -1934,6 +1935,10 @@ $readonlys['button[vcard]'] = true;
</script>';
}
/**
* Migrate contacts to or from LDAP (called by Admin >> Addressbook >> Site configuration (Admin only)
*
*/
function migrate2ldap()
{
$GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Migration to LDAP');
@ -1952,6 +1957,32 @@ $readonlys['button[vcard]'] = true;
$GLOBALS['egw']->common->egw_footer();
}
/**
* Set n_fileas (and n_fn) in contacts of all users (called by Admin >> Addressbook >> Site configuration (Admin only)
*
* If $_GET[all] all fileas fields will be set, if !$_GET[all] only empty ones
*
*/
function admin_set_fileas()
{
translation::add_app('admin');
$GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Contact maintenance');
$GLOBALS['egw']->common->egw_header();
parse_navbar();
// check if user has admin rights AND if a valid fileas type is given (Security)
if (!$this->is_admin() || $_GET['type'] != '' && !in_array($_GET['type'],$this->fileas_types))
{
echo '<h1>'.lang('Permission denied !!!')."</h1>\n";
}
else
{
$updated = parent::set_all_fileas($_GET['type'],(boolean)$_GET['all'],$errors,true); // true = ignore acl
echo '<p style="margin-top: 20px;"><b>'.lang('%1 contacts updated (%2 errors).',$updated,$errors)."</b></p>\n";
}
$GLOBALS['egw']->common->egw_footer();
}
/**
* Download a document with inserted contact(s)
*

View File

@ -1,6 +1,6 @@
<?php
/**
* Addressbook - configuration
* eGroupware - Addressbook configuration
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
@ -9,6 +9,12 @@
* @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');
@ -27,6 +33,26 @@ function contact_repositories($config)
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();
@ -53,6 +79,12 @@ function own_account_acl($config)
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();

View File

@ -1,6 +1,7 @@
%1 added addressbook de %1 hinzugefügt
%1 contact(s) %2 addressbook de %1 Kontakt(e) %2
%1 contact(s) %2, %3 failed because of insufficent rights !!! addressbook de %1 Kontakt(e) %2, %3 nicht wegen fehlender Rechte !!!
%1 contacts updated (%2 errors). addressbook de %1 Kontakte aktualisiert (%2 Fehler).
%1 fields in %2 other organisation member(s) changed addressbook de %1 Felder in %2 Mitglied(ern) der Organisation geändert
%1 records imported addressbook de %1 Datensätze importiert
%1 records read (not yet imported, you may go %2back%3 and uncheck test import) addressbook de %1 Datensätze gelesen (noch nicht importiert, sie können %2zurück%3 gehen und Test-Import auschalten)
@ -96,6 +97,7 @@ contact deleted addressbook de Kontakt gelöscht
contact fields to show addressbook de Kontaktfelder die angezeigt werden sollen
contact fields: addressbook de Kontaktfelder:
contact id addressbook de Kontakt ID
contact maintenance admin de Kontakt Wartung
contact modified by %1 at %2 addressbook de Kontakt geändert von %1 am %2
contact not found! addressbook de Kontakt nicht gefunden!
contact repository admin de Speicherort Kontakte
@ -160,8 +162,10 @@ edit phonenumbers - addressbook de Telefonnummern bearbeiten
either the configured email addesses are wrong or the mail configuration. addressbook de Entweder die konfigurierte Email Adresse ist falsch oder die Mail Konfiguration.
email & internet addressbook de E-Mail & Internet
email addresses (comma separated) to send the contact data addressbook de Email Adressen (Komma getrennt) zum Senden der Kontaktdaten
empty admin de leere
empty for all addressbook de leer für alle
enable an extra private addressbook addressbook de Privates Adressbuch einschalten
enclosure addressbook de Einschluss
end addressbook de Ende
enter the path to the exported file here addressbook de Bitte geben Sie den Pfad für die exportierte Datei an
error deleting the contact !!! addressbook de Fehler beim Löschen des Kontakts !!!
@ -341,6 +345,8 @@ select the type of conversion: addressbook de Typ der Umwandlung auswählen:
select where you want to store / retrieve contacts admin de Auswählen wo Sie Adressen speichern wollen
selected contacts addressbook de ausgewählte Kontakte
seperator addressbook de Feldtrenner
set full name and file as field in contacts of all users (either all or only empty values) admin de Setzt vollen Namen und eigene Sortierung in Kontakten aller Benutzer (entweder alle oder nur leere Werte)
set only full name addressbook de Nur vollen Namen setzen
should the columns photo and home address always be displayed, even if they are empty. addressbook de Sollen die Spalten Foto und Privatadresse immer angezeigt werden, auch wenn sie leer sind.
show addressbook de Anzeigen
show birthday reminders on main screen addressbook de Geburtstagserinnerungen auf der Startseite anzeigen

View File

@ -1,6 +1,7 @@
%1 added addressbook en %1 added
%1 contact(s) %2 addressbook en %1 contact(s) %2
%1 contact(s) %2, %3 failed because of insufficent rights !!! addressbook en %1 contact(s) %2, %3 failed because of insufficent rights !!!
%1 contacts updated (%2 errors). addressbook en %1 contacts updated (%2 errors).
%1 fields in %2 other organisation member(s) changed addressbook en %1 fields in %2 other organisation member(s) changed
%1 records imported addressbook en %1 records imported
%1 records read (not yet imported, you may go %2back%3 and uncheck test import) addressbook en %1 records read (not yet imported, you may go %2back%3 and uncheck Test Import)
@ -96,6 +97,7 @@ contact deleted addressbook en Contact deleted
contact fields to show addressbook en Contact fields to show
contact fields: addressbook en Contact fields:
contact id addressbook en Contact ID
contact maintenance admin en Contact maintenance
contact modified by %1 at %2 addressbook en Contact modified by %1 at %2
contact not found! addressbook en Contact not found!
contact repository admin en Contact repository
@ -160,6 +162,7 @@ edit phonenumbers - addressbook en Edit Phonenumbers -
either the configured email addesses are wrong or the mail configuration. addressbook en Either the configured email addesses are wrong or the mail configuration.
email & internet addressbook en Email & Internet
email addresses (comma separated) to send the contact data addressbook en Email addresses (comma separated) to send the contact data
empty admin en Empty
empty for all addressbook en empty for all
enable an extra private addressbook addressbook en Enable an extra private addressbook
enclosure addressbook en Enclosure
@ -342,6 +345,8 @@ select the type of conversion: addressbook en Select the type of conversion:
select where you want to store / retrieve contacts admin en Select where you want to store / retrieve contacts
selected contacts addressbook en selected contacts
seperator addressbook en Seperator
set full name and file as field in contacts of all users (either all or only empty values) admin en Set full name and file as field in contacts of all users (either all or only empty values)
set only full name addressbook en Set only full name
should the columns photo and home address always be displayed, even if they are empty. addressbook en Should the columns photo and home address always be displayed, even if they are empty.
show addressbook en Show
show birthday reminders on main screen addressbook en Show birthday reminders on main screen

View File

@ -14,7 +14,7 @@
<td colspan="2">&nbsp;<b>{lang_Telephony_integration}</b></td>
</tr>
<tr class="row_on">
<td>&nbsp;{lang_URL_to_link_telephone_numbers_to_(use_%1_=_number_to_call,_%u_=_account_name,_%t_=_account_phone)}:</td>
<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">
@ -67,6 +67,17 @@
{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="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="th">
<td colspan="2">&nbsp;<b>{lang_Contact_repository}</b></td>
</tr>