renamed addressbook classes to use autoloading, was just a test to get

an idea about the effort - not sure I want to do that with all apps ;-)
This commit is contained in:
Ralf Becker 2008-05-10 12:02:49 +00:00
parent e0454b0558
commit 7a2e1a66e2
28 changed files with 710 additions and 741 deletions

View File

@ -1,434 +1,427 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook: CSV - Import *
* http://www.egroupware.org *
* Written by Ralf Becker <RalfBecker@outdoor-training.de> *
* -------------------------------------------- *
* 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. *
\**************************************************************************/
/**
* Addressbook - CSV Import
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2003-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/* $Id$ */
$GLOBALS['egw_info']['flags'] = array(
$GLOBALS['egw_info'] = array(
'flags' => array(
'currentapp' => 'addressbook',
'noheader' => True,
'enable_contacts_class' => True,
);
include('../header.inc.php');
),
);
include('../header.inc.php');
if (isset($_FILES['csvfile']['tmp_name']))
if (isset($_FILES['csvfile']['tmp_name']))
{
$csvfile = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$GLOBALS['egw']->session->appsession('csvfile','',$csvfile);
$_POST['action'] = move_uploaded_file($_FILES['csvfile']['tmp_name'],$csvfile) ?
'download' : '';
}
else
{
$csvfile = $GLOBALS['egw']->session->appsession('csvfile');
}
if ($_POST['cancel'])
{
@unlink($csvfile);
$GLOBALS['egw']->redirect_link('/addressbook/index.php');
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Import CSV-File into Addressbook');
$GLOBALS['egw']->common->egw_header();
$GLOBALS['egw']->contacts = new contacts();
//$GLOBALS['egw']->template->set_unknowns('keep');
$GLOBALS['egw']->template->set_file(array('import' => 'csv_import.tpl'));
$GLOBALS['egw']->template->set_block('import','filename','filenamehandle');
$GLOBALS['egw']->template->set_block('import','fheader','fheaderhandle');
$GLOBALS['egw']->template->set_block('import','fields','fieldshandle');
$GLOBALS['egw']->template->set_block('import','ffooter','ffooterhandle');
$GLOBALS['egw']->template->set_block('import','imported','importedhandle');
if(($_POST['action'] == 'download' || $_POST['action'] == 'continue') && (!$_POST['fieldsep'] || !$csvfile || !($fp=fopen($csvfile,'rb'))))
{
$_POST['action'] = '';
}
$GLOBALS['egw']->template->set_var('action_url',$GLOBALS['egw']->link('/addressbook/csv_import.php'));
$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in trans
$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
$VPre = '|#'; // Value-Prefix, is expanded to \ for ereg_replace
$CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field
$CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted
// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
function addr_id($n_family,$n_given,$org_name)
{
$addrs = $GLOBALS['egw']->contacts->search(array('n_family'=>$n_family,'n_given'=>$n_given,'org_name'=>$org_name));
if(!count($addrs))
{
$csvfile = tempnam($GLOBALS['egw_info']['server']['temp_dir'],$GLOBALS['egw_info']['flags']['currentapp']."_");
$GLOBALS['egw']->session->appsession('csvfile','',$csvfile);
$_POST['action'] = move_uploaded_file($_FILES['csvfile']['tmp_name'],$csvfile) ?
'download' : '';
$addrs = $GLOBALS['egw']->contacts->search(array('n_family'=>$n_family,'n_given'=>$n_given));
}
else
if(!count($addrs))
{
$csvfile = $GLOBALS['egw']->session->appsession('csvfile');
$addrs = $GLOBALS['egw']->contacts->search(array('n_family'=>$n_family,'org_name'=>$org_name));
}
if ($_POST['cancel'])
if(count($addrs))
{
@unlink($csvfile);
$GLOBALS['egw']->redirect_link('/addressbook/index.php');
return $addrs[0]['id'];
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Import CSV-File into Addressbook');
$GLOBALS['egw']->common->egw_header();
$GLOBALS['egw']->contacts = createobject('phpgwapi.contacts');
return False;
}
//$GLOBALS['egw']->template->set_unknowns('keep');
$GLOBALS['egw']->template->set_file(array('import' => 'csv_import.tpl'));
$GLOBALS['egw']->template->set_block('import','filename','filenamehandle');
$GLOBALS['egw']->template->set_block('import','fheader','fheaderhandle');
$GLOBALS['egw']->template->set_block('import','fields','fieldshandle');
$GLOBALS['egw']->template->set_block('import','ffooter','ffooterhandle');
$GLOBALS['egw']->template->set_block('import','imported','importedhandle');
if(($_POST['action'] == 'download' || $_POST['action'] == 'continue') && (!$_POST['fieldsep'] || !$csvfile || !($fp=fopen($csvfile,'rb'))))
function cat_id($cats)
{
if(!$cats)
{
$_POST['action'] = '';
return '';
}
$GLOBALS['egw']->template->set_var('action_url',$GLOBALS['egw']->link('/addressbook/csv_import.php'));
$PSep = '||'; // Pattern-Separator, separats the pattern-replacement-pairs in trans
$ASep = '|>'; // Assignment-Separator, separats pattern and replacesment
$VPre = '|#'; // Value-Prefix, is expanded to \ for ereg_replace
$CPre = '|['; $CPreReg = '\|\['; // |{csv-fieldname} is expanded to the value of the csv-field
$CPos = ']'; $CPosReg = '\]'; // if used together with @ (replacement is eval-ed) value gets autom. quoted
// find in Addressbook, at least n_family AND (n_given OR org_name) have to match
function addr_id($n_family,$n_given,$org_name)
$ids = array();
foreach(split(' *[,;] *',$cats) as $cat)
{
$addrs = $GLOBALS['egw']->contacts->search(array('n_family'=>$n_family,'n_given'=>$n_given,'org_name'=>$org_name));
if(!count($addrs))
if (is_numeric($cat) && $GLOBALS['egw']->categories->id2name($cat) != '--')
{
$addrs = $GLOBALS['egw']->contacts->search(array('n_family'=>$n_family,'n_given'=>$n_given));
$id = (int) $cat;
}
if(!count($addrs))
elseif ($id = $GLOBALS['egw']->categories->name2id(addslashes($cat)))
{
$addrs = $GLOBALS['egw']->contacts->search(array('n_family'=>$n_family,'org_name'=>$org_name));
// cat exists
}
if(count($addrs))
{
return $addrs[0]['id'];
else
{ // create new cat
$id = $GLOBALS['egw']->categories->add(array('name' => $cat,'descr' => $cat));
}
return False;
$ids[$id] = $id; // we use the $id as index to not ass a cat twice
}
return implode(',',$ids);
}
function cat_id($cats)
{
if(!$cats)
if ($_POST['next']) $_POST['action'] = 'next';
switch($_POST['action'])
{
case '': // Start, ask Filename
$GLOBALS['egw']->template->set_var('lang_csvfile',lang('CSV-Filename'));
$GLOBALS['egw']->template->set_var('lang_fieldsep',lang('Fieldseparator'));
$GLOBALS['egw']->template->set_var('lang_charset',lang('Charset of file'));
$GLOBALS['egw']->template->set_var('select_charset',
html::select('charset','',
$GLOBALS['egw']->translation->get_installed_charsets()+
array('utf-8' => 'utf-8 (Unicode)'),True));
$GLOBALS['egw']->template->set_var('fieldsep',$_POST['fieldsep'] ? $_POST['fieldsep'] : ';');
$GLOBALS['egw']->template->set_var('submit',lang('Import'));
$GLOBALS['egw']->template->set_var('csvfile',$csvfile);
$GLOBALS['egw']->template->set_var('enctype','ENCTYPE="multipart/form-data"');
$GLOBALS['egw']->template->parse('filenamehandle','filename');
break;
case 'continue':
case 'download':
$defaults = $GLOBALS['egw_info']['user']['preferences']['addressbook']['cvs_import'];
if(!is_array($defaults))
{
return '';
$defaults = array();
}
$ids = array();
foreach(split(' *[,;] *',$cats) as $cat)
$GLOBALS['egw']->template->set_var('lang_csv_fieldname',lang('CSV-Fieldname'));
$GLOBALS['egw']->template->set_var('lang_addr_fieldname',lang('Addressbook-Fieldname'));
$GLOBALS['egw']->template->set_var('lang_translation',lang("Translation").' <a href="#help">'.lang('help').'</a>');
$GLOBALS['egw']->template->set_var('submit',
html::submit_button('convert','Import') . '&nbsp;'.
html::submit_button('cancel','Cancel'));
$GLOBALS['egw']->template->set_var('lang_debug',lang('Test Import (show importable records <u>only</u> in browser)'));
$GLOBALS['egw']->template->parse('fheaderhandle','fheader');
$addr_names = $GLOBALS['egw']->contacts->contact_fields;
$addr_names['cat_id'] .= ': id or name, comma separated list';
$addr_names['private'] .= ': 0 = public, 1 = private';
$addr_names['owner'] .= ': id or account name of user or group, defaults to importing user';
$addr_names['bday'] .= ': YYYY-mm-dd';
unset($addr_names['jpegphoto']); // cant cvs import that
foreach($GLOBALS['egw']->contacts->customfields as $name => $data)
{
if (is_numeric($cat) && $GLOBALS['egw']->categories->id2name($cat) != '--')
$addr_names['#'.$name] = $data['label'];
}
$addr_name_options = "<option value=\"\">none\n";
foreach($addr_names as $field => $name)
{
$addr_name_options .= "<option value=\"$field\">".$GLOBALS['egw']->strip_html($name)."\n";
}
$csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']);
$csv_fields = $GLOBALS['egw']->translation->convert($csv_fields,$_POST['charset']);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3';
foreach($csv_fields as $csv_idx => $csv_field)
{
$GLOBALS['egw']->template->set_var('csv_field',$csv_field);
$GLOBALS['egw']->template->set_var('csv_idx',$csv_idx);
if($def = $defaults[$csv_field])
{
$id = (int) $cat;
}
elseif ($id = $GLOBALS['egw']->categories->name2id(addslashes($cat)))
{
// cat exists
list($addr,$_POST['trans']) = explode($PSep,$def,2);
$GLOBALS['egw']->template->set_var('trans',$_POST['trans']);
$GLOBALS['egw']->template->set_var('addr_fields',str_replace('="'.$addr.'">','="'.$addr.'" selected>',$addr_name_options));
}
else
{ // create new cat
$id = $GLOBALS['egw']->categories->add(array('name' => $cat,'descr' => $cat));
{
$GLOBALS['egw']->template->set_var('trans','');
$GLOBALS['egw']->template->set_var('addr_fields',$addr_name_options);
}
$ids[$id] = $id; // we use the $id as index to not ass a cat twice
$GLOBALS['egw']->template->parse('fieldshandle','fields',True);
}
return implode(',',$ids);
}
$GLOBALS['egw']->template->set_var('lang_start',lang('Startrecord'));
$GLOBALS['egw']->template->set_var('start',get_var('start',array('POST'),1));
$msg = ($safe_mode = ini_get('safe_mode') == 'On') ? lang('to many might exceed your execution-time-limit'):
lang('empty for all');
$GLOBALS['egw']->template->set_var('lang_max',lang('Number of records to read (%1)',$msg));
$GLOBALS['egw']->template->set_var('max',get_var('max',array('POST'),$safe_mode ? 200 : ''));
$GLOBALS['egw']->template->set_var('debug',get_var('debug',array('POST'),True)?' checked':'');
$GLOBALS['egw']->template->parse('ffooterhandle','ffooter');
fclose($fp);
if (!is_object($GLOBALS['egw']->html))
{
$GLOBALS['egw']->html = CreateObject('phpgwapi.html');
}
$hiddenvars = html::input_hidden(array(
'action' => 'import',
'fieldsep'=> $_POST['fieldsep'],
'charset' => $_POST['charset']
));
$mktime_lotus = "${PSep}0?([0-9]+)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*).*$ASep@mktime(${VPre}4,${VPre}5,${VPre}6,${VPre}2,${VPre}3,${VPre}1)";
$help_on_trans = "<a name=\"help\"></a><b>How to use Translation's</b><p>".
"Translations enable you to change / adapt the content of each CSV field for your needs. <br>".
"General syntax is: <b>pattern1 ${ASep} replacement1 ${PSep} ... ${PSep} patternN ${ASep} replacementN</b><br>".
"If the pattern-part of a pair is ommited it will match everything ('^.*$'), which is only ".
"usefull for the last pair, as they are worked from left to right.<p>".
"First example: <b>1${ASep}private${PSep}public</b><br>".
"This will translate a '1' in the CSV field to 'privat' and everything else to 'public'.<p>".
"Patterns as well as the replacement can be regular expressions (the replacement is done via ereg_replace). ".
"If, after all replacements, the value starts with an '@' the whole value is eval()'ed, so you ".
"may use all php, phpgw plus your own functions. This is quiet powerfull, but <u>circumvents all ACL</u>. ".
"Therefor this feature is only availible to Adminstrators.<p>".
"Example using regular expressions and '@'-eval(): <br><b>$mktime_lotus</b><br>".
"It will read a date of the form '2001-05-20 08:00:00.00000000000000000' (and many more, see the regular expr.). ".
"The&nbsp;[&nbsp;.:-]-separated fields are read and assigned in different order to @mktime(). Please note to use ".
"${VPre} insted of a backslash (I couldn't get backslash through all the involved templates and forms.) ".
"plus the field-number of the pattern.<p>".
"In addintion to the fields assign by the pattern of the reg.exp. you can use all other CSV-fields, with the ".
"syntax <b>${CPre}CSV-FIELDNAME$CPos</b>. Here is an example: <br>".
"<b>.+$ASep${CPre}Company$CPos: ${CPre}NFamily$CPos, ${CPre}NGiven$CPos$PSep${CPre}NFamily$CPos, ${CPre}NGiven$CPos</b><br>".
"It is used on the CSV-field 'Company' and constructs a something like <i>Company: FamilyName, GivenName</i> or ".
"<i>FamilyName, GivenName</i> if 'Company' is empty.<p>".
"You can use the 'No CSV #'-fields to assign csv-values to more than on field, the following example uses the ".
"csv-field 'Note' (which gots already assingned to the description) and construct a short subject: ".
"<b>@substr(${CPre}Note$CPos,0,60).' ...'</b><p>".
"Their is one important user-function for the Addressbook:<br>".
"<b>@cat_id(Cat1,...,CatN)</b> returns a (','-separated) list with the cat_id's. If a category isn't found, it ".
"will be automaticaly added.<p>".
"I hope that helped to understand the features, if not <a href='mailto:egroupware-users@lists.sf.net'>ask</a>.";
if ($_POST['next']) $_POST['action'] = 'next';
switch($_POST['action'])
{
case '': // Start, ask Filename
$GLOBALS['egw']->template->set_var('lang_csvfile',lang('CSV-Filename'));
$GLOBALS['egw']->template->set_var('lang_fieldsep',lang('Fieldseparator'));
$GLOBALS['egw']->template->set_var('lang_charset',lang('Charset of file'));
$GLOBALS['egw']->template->set_var('select_charset',
$GLOBALS['egw']->html->select('charset','',
$GLOBALS['egw']->translation->get_installed_charsets()+
array('utf-8' => 'utf-8 (Unicode)'),True));
$GLOBALS['egw']->template->set_var('fieldsep',$_POST['fieldsep'] ? $_POST['fieldsep'] : ';');
$GLOBALS['egw']->template->set_var('submit',lang('Import'));
$GLOBALS['egw']->template->set_var('csvfile',$csvfile);
$GLOBALS['egw']->template->set_var('enctype','ENCTYPE="multipart/form-data"');
$GLOBALS['egw']->template->set_var('help_on_trans',lang($help_on_trans)); // I don't think anyone will translate this
break;
$GLOBALS['egw']->template->parse('filenamehandle','filename');
break;
case 'next':
$_POST['addr_fields'] = unserialize(stripslashes($_POST['addr_fields']));
$_POST['trans'] = unserialize(stripslashes($_POST['trans']));
// fall-through
case 'import':
$hiddenvars = html::input_hidden(array(
'action' => 'continue',
'fieldsep'=> $_POST['fieldsep'],
'charset' => $_POST['charset'],
'start' => $_POST['start']+(!$_POST['debug'] ? $_POST['max'] : 0),
'max' => $_POST['max'],
'debug' => $_POST['debug'],
'addr_fields' => $_POST['addr_fields'],
'trans' => $_POST['trans']
));
@set_time_limit(0);
$fp=fopen($csvfile,'rb');
$csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']);
$csv_fields = $GLOBALS['egw']->translation->convert($csv_fields,$_POST['charset']);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3';
case 'continue':
case 'download':
$defaults = $GLOBALS['egw_info']['user']['preferences']['addressbook']['cvs_import'];
if(!is_array($defaults))
$addr_fields = array_diff($_POST['addr_fields'],array('')); // throw away empty / not assigned entrys
$defaults = array();
foreach($addr_fields as $csv_idx => $addr)
{ // convert $_POST['trans'][$csv_idx] into array of pattern => value
$defaults[$csv_fields[$csv_idx]] = $addr;
if($_POST['trans'][$csv_idx])
{
$defaults = array();
$defaults[$csv_fields[$csv_idx]] .= $PSep.$_POST['trans'][$csv_idx];
}
$GLOBALS['egw']->template->set_var('lang_csv_fieldname',lang('CSV-Fieldname'));
$GLOBALS['egw']->template->set_var('lang_addr_fieldname',lang('Addressbook-Fieldname'));
$GLOBALS['egw']->template->set_var('lang_translation',lang("Translation").' <a href="#help">'.lang('help').'</a>');
$GLOBALS['egw']->template->set_var('submit',
$GLOBALS['egw']->html->submit_button('convert','Import') . '&nbsp;'.
$GLOBALS['egw']->html->submit_button('cancel','Cancel'));
$GLOBALS['egw']->template->set_var('lang_debug',lang('Test Import (show importable records <u>only</u> in browser)'));
$GLOBALS['egw']->template->parse('fheaderhandle','fheader');
}
$GLOBALS['egw']->preferences->read_repository();
$GLOBALS['egw']->preferences->add('addressbook','cvs_import',$defaults);
$GLOBALS['egw']->preferences->save_repository(True);
$addr_names = $GLOBALS['egw']->contacts->contact_fields;
$addr_names['cat_id'] .= ': id or name, comma separated list';
$addr_names['private'] .= ': 0 = public, 1 = private';
$addr_names['owner'] .= ': id or account name of user or group, defaults to importing user';
$addr_names['bday'] .= ': YYYY-mm-dd';
unset($addr_names['jpegphoto']); // cant cvs import that
$log = "<table border=1>\n\t<tr><td>#</td>\n";
foreach($GLOBALS['egw']->contacts->customfields as $name => $data)
foreach($addr_fields as $csv_idx => $addr)
{ // convert $_POST['trans'][$csv_idx] into array of pattern => value
// if (!$_POST['debug']) echo "<p>$csv_idx: ".$csv_fields[$csv_idx].": $addr".($_POST['trans'][$csv_idx] ? ': '.$_POST['trans'][$csv_idx] : '')."</p>";
$pat_reps = explode($PSep,stripslashes($_POST['trans'][$csv_idx]));
$replaces = ''; $values = '';
if($pat_reps[0] != '')
{
$addr_names['#'.$name] = $data['label'];
}
$addr_name_options = "<option value=\"\">none\n";
foreach($addr_names as $field => $name)
{
$addr_name_options .= "<option value=\"$field\">".$GLOBALS['egw']->strip_html($name)."\n";
}
$csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']);
$csv_fields = $GLOBALS['egw']->translation->convert($csv_fields,$_POST['charset']);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3';
foreach($csv_fields as $csv_idx => $csv_field)
{
$GLOBALS['egw']->template->set_var('csv_field',$csv_field);
$GLOBALS['egw']->template->set_var('csv_idx',$csv_idx);
if($def = $defaults[$csv_field])
foreach($pat_reps as $k => $pat_rep)
{
list($addr,$_POST['trans']) = explode($PSep,$def,2);
$GLOBALS['egw']->template->set_var('trans',$_POST['trans']);
$GLOBALS['egw']->template->set_var('addr_fields',str_replace('="'.$addr.'">','="'.$addr.'" selected>',$addr_name_options));
}
else
{
$GLOBALS['egw']->template->set_var('trans','');
$GLOBALS['egw']->template->set_var('addr_fields',$addr_name_options);
}
$GLOBALS['egw']->template->parse('fieldshandle','fields',True);
}
$GLOBALS['egw']->template->set_var('lang_start',lang('Startrecord'));
$GLOBALS['egw']->template->set_var('start',get_var('start',array('POST'),1));
$msg = ($safe_mode = ini_get('safe_mode') == 'On') ? lang('to many might exceed your execution-time-limit'):
lang('empty for all');
$GLOBALS['egw']->template->set_var('lang_max',lang('Number of records to read (%1)',$msg));
$GLOBALS['egw']->template->set_var('max',get_var('max',array('POST'),$safe_mode ? 200 : ''));
$GLOBALS['egw']->template->set_var('debug',get_var('debug',array('POST'),True)?' checked':'');
$GLOBALS['egw']->template->parse('ffooterhandle','ffooter');
fclose($fp);
$hiddenvars = $GLOBALS['egw']->html->input_hidden(array(
'action' => 'import',
'fieldsep'=> $_POST['fieldsep'],
'charset' => $_POST['charset']
));
$mktime_lotus = "${PSep}0?([0-9]+)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*)[ .:-]+0?([0-9]*).*$ASep@mktime(${VPre}4,${VPre}5,${VPre}6,${VPre}2,${VPre}3,${VPre}1)";
$help_on_trans = "<a name=\"help\"></a><b>How to use Translation's</b><p>".
"Translations enable you to change / adapt the content of each CSV field for your needs. <br>".
"General syntax is: <b>pattern1 ${ASep} replacement1 ${PSep} ... ${PSep} patternN ${ASep} replacementN</b><br>".
"If the pattern-part of a pair is ommited it will match everything ('^.*$'), which is only ".
"usefull for the last pair, as they are worked from left to right.<p>".
"First example: <b>1${ASep}private${PSep}public</b><br>".
"This will translate a '1' in the CSV field to 'privat' and everything else to 'public'.<p>".
"Patterns as well as the replacement can be regular expressions (the replacement is done via ereg_replace). ".
"If, after all replacements, the value starts with an '@' the whole value is eval()'ed, so you ".
"may use all php, phpgw plus your own functions. This is quiet powerfull, but <u>circumvents all ACL</u>. ".
"Therefor this feature is only availible to Adminstrators.<p>".
"Example using regular expressions and '@'-eval(): <br><b>$mktime_lotus</b><br>".
"It will read a date of the form '2001-05-20 08:00:00.00000000000000000' (and many more, see the regular expr.). ".
"The&nbsp;[&nbsp;.:-]-separated fields are read and assigned in different order to @mktime(). Please note to use ".
"${VPre} insted of a backslash (I couldn't get backslash through all the involved templates and forms.) ".
"plus the field-number of the pattern.<p>".
"In addintion to the fields assign by the pattern of the reg.exp. you can use all other CSV-fields, with the ".
"syntax <b>${CPre}CSV-FIELDNAME$CPos</b>. Here is an example: <br>".
"<b>.+$ASep${CPre}Company$CPos: ${CPre}NFamily$CPos, ${CPre}NGiven$CPos$PSep${CPre}NFamily$CPos, ${CPre}NGiven$CPos</b><br>".
"It is used on the CSV-field 'Company' and constructs a something like <i>Company: FamilyName, GivenName</i> or ".
"<i>FamilyName, GivenName</i> if 'Company' is empty.<p>".
"You can use the 'No CSV #'-fields to assign csv-values to more than on field, the following example uses the ".
"csv-field 'Note' (which gots already assingned to the description) and construct a short subject: ".
"<b>@substr(${CPre}Note$CPos,0,60).' ...'</b><p>".
"Their is one important user-function for the Addressbook:<br>".
"<b>@cat_id(Cat1,...,CatN)</b> returns a (','-separated) list with the cat_id's. If a category isn't found, it ".
"will be automaticaly added.<p>".
"I hope that helped to understand the features, if not <a href='mailto:egroupware-users@lists.sf.net'>ask</a>.";
$GLOBALS['egw']->template->set_var('help_on_trans',lang($help_on_trans)); // I don't think anyone will translate this
break;
case 'next':
$_POST['addr_fields'] = unserialize(stripslashes($_POST['addr_fields']));
$_POST['trans'] = unserialize(stripslashes($_POST['trans']));
// fall-through
case 'import':
$hiddenvars = $GLOBALS['egw']->html->input_hidden(array(
'action' => 'continue',
'fieldsep'=> $_POST['fieldsep'],
'charset' => $_POST['charset'],
'start' => $_POST['start']+(!$_POST['debug'] ? $_POST['max'] : 0),
'max' => $_POST['max'],
'debug' => $_POST['debug'],
'addr_fields' => $_POST['addr_fields'],
'trans' => $_POST['trans']
));
@set_time_limit(0);
$fp=fopen($csvfile,'rb');
$csv_fields = fgetcsv($fp,8000,$_POST['fieldsep']);
$csv_fields = $GLOBALS['egw']->translation->convert($csv_fields,$_POST['charset']);
$csv_fields[] = 'no CSV 1'; // eg. for static assignments
$csv_fields[] = 'no CSV 2';
$csv_fields[] = 'no CSV 3';
$addr_fields = array_diff($_POST['addr_fields'],array('')); // throw away empty / not assigned entrys
$defaults = array();
foreach($addr_fields as $csv_idx => $addr)
{ // convert $_POST['trans'][$csv_idx] into array of pattern => value
$defaults[$csv_fields[$csv_idx]] = $addr;
if($_POST['trans'][$csv_idx])
{
$defaults[$csv_fields[$csv_idx]] .= $PSep.$_POST['trans'][$csv_idx];
}
}
$GLOBALS['egw']->preferences->read_repository();
$GLOBALS['egw']->preferences->add('addressbook','cvs_import',$defaults);
$GLOBALS['egw']->preferences->save_repository(True);
$log = "<table border=1>\n\t<tr><td>#</td>\n";
foreach($addr_fields as $csv_idx => $addr)
{ // convert $_POST['trans'][$csv_idx] into array of pattern => value
// if (!$_POST['debug']) echo "<p>$csv_idx: ".$csv_fields[$csv_idx].": $addr".($_POST['trans'][$csv_idx] ? ': '.$_POST['trans'][$csv_idx] : '')."</p>";
$pat_reps = explode($PSep,stripslashes($_POST['trans'][$csv_idx]));
$replaces = ''; $values = '';
if($pat_reps[0] != '')
{
foreach($pat_reps as $k => $pat_rep)
list($pattern,$replace) = explode($ASep,$pat_rep,2);
if($replace == '')
{
list($pattern,$replace) = explode($ASep,$pat_rep,2);
if($replace == '')
{
$replace = $pattern; $pattern = '^.*$';
}
$values[$pattern] = $replace; // replace two with only one, added by the form
$replaces .= ($replaces != '' ? $PSep : '') . $pattern . $ASep . $replace;
$replace = $pattern; $pattern = '^.*$';
}
$_POST['trans'][$csv_idx] = $values;
$values[$pattern] = $replace; // replace two with only one, added by the form
$replaces .= ($replaces != '' ? $PSep : '') . $pattern . $ASep . $replace;
}
else
{
unset( $_POST['trans'][$csv_idx] );
}
$log .= "\t\t<td><b>$addr</b></td>\n";
$_POST['trans'][$csv_idx] = $values;
}
if (!in_array('private',$addr_fields)) // autocreate public access if not set by user
else
{
$log .= "\t\t<td><b>private</b></td>\n";
unset( $_POST['trans'][$csv_idx] );
}
$start = $_POST['start'] < 1 ? 1 : $_POST['start'];
$log .= "\t\t<td><b>$addr</b></td>\n";
}
if (!in_array('private',$addr_fields)) // autocreate public access if not set by user
{
$log .= "\t\t<td><b>private</b></td>\n";
}
$start = $_POST['start'] < 1 ? 1 : $_POST['start'];
// ignore empty lines, is_null($fields[0]) is returned on empty lines !!!
for($i = 1; $i < $start; ++$i) // overread lines before our start-record
// ignore empty lines, is_null($fields[0]) is returned on empty lines !!!
for($i = 1; $i < $start; ++$i) // overread lines before our start-record
{
while(($fields = fgetcsv($fp,8000,$_POST['fieldsep'])) && is_null($fields[0])) ;
}
for($anz = 0; !$_POST['max'] || $anz < $_POST['max']; ++$anz)
{
while(($fields = fgetcsv($fp,8000,$_POST['fieldsep'])) && is_null($fields[0])) ;
if (!$fields)
{
while(($fields = fgetcsv($fp,8000,$_POST['fieldsep'])) && is_null($fields[0])) ;
break; // EOF
}
for($anz = 0; !$_POST['max'] || $anz < $_POST['max']; ++$anz)
$fields = $GLOBALS['egw']->translation->convert($fields,$_POST['charset']);
$log .= "\t</tr><tr><td>".($start+$anz)."</td>\n";
$values = array();
foreach($addr_fields as $csv_idx => $addr)
{
while(($fields = fgetcsv($fp,8000,$_POST['fieldsep'])) && is_null($fields[0])) ;
if (!$fields)
//echo "<p>$csv: $addr".($_POST['trans'][$csv] ? ': '.$_POST['trans'][$csv] : '')."</p>";
$val = $fields[$csv_idx];
if(isset($_POST['trans'][$csv_idx]))
{
break; // EOF
}
$fields = $GLOBALS['egw']->translation->convert($fields,$_POST['charset']);
$log .= "\t</tr><tr><td>".($start+$anz)."</td>\n";
$values = array();
foreach($addr_fields as $csv_idx => $addr)
{
//echo "<p>$csv: $addr".($_POST['trans'][$csv] ? ': '.$_POST['trans'][$csv] : '')."</p>";
$val = $fields[$csv_idx];
if(isset($_POST['trans'][$csv_idx]))
$trans_csv = $_POST['trans'][$csv_idx];
while(list($pattern,$replace) = each($trans_csv))
{
$trans_csv = $_POST['trans'][$csv_idx];
while(list($pattern,$replace) = each($trans_csv))
if(ereg((string) $pattern,$val))
{
if(ereg((string) $pattern,$val))
{
// echo "<p>csv_idx='$csv_idx',info='$addr',trans_csv=".print_r($trans_csv).",ereg_replace('$pattern','$replace','$val') = ";
$val = ereg_replace((string) $pattern,str_replace($VPre,'\\',$replace),(string) $val);
// echo "'$val'</p>";
// echo "<p>csv_idx='$csv_idx',info='$addr',trans_csv=".print_r($trans_csv).",ereg_replace('$pattern','$replace','$val') = ";
$val = ereg_replace((string) $pattern,str_replace($VPre,'\\',$replace),(string) $val);
// echo "'$val'</p>";
$reg = $CPreReg.'([a-zA-Z_0-9]+)'.$CPosReg;
while(ereg($reg,$val,$vars))
{ // expand all CSV fields
$val = str_replace($CPre . $vars[1] . $CPos, $val[0] == '@' ? "'"
. addslashes($fields[array_search($vars[1], $csv_fields)])
. "'" : $fields[array_search($vars[1], $csv_fields)], $val);
}
if($val[0] == '@')
$reg = $CPreReg.'([a-zA-Z_0-9]+)'.$CPosReg;
while(ereg($reg,$val,$vars))
{ // expand all CSV fields
$val = str_replace($CPre . $vars[1] . $CPos, $val[0] == '@' ? "'"
. addslashes($fields[array_search($vars[1], $csv_fields)])
. "'" : $fields[array_search($vars[1], $csv_fields)], $val);
}
if($val[0] == '@')
{
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
if (!$GLOBALS['egw_info']['user']['apps']['admin'])
{
echo lang('@-eval() is only availible to admins!!!');
}
else
{
// removing the $ to close security hole of showing vars, which contain eg. passwords
$val = 'return '.substr(str_replace('$','',$val),1).';';
// echo "<p>eval('$val')=";
$val = eval($val);
// echo "'$val'</p>";
}
echo lang('@-eval() is only availible to admins!!!');
}
if($pattern[0] != '@' || $val)
else
{
break;
// removing the $ to close security hole of showing vars, which contain eg. passwords
$val = 'return '.substr(str_replace('$','',$val),1).';';
// echo "<p>eval('$val')=";
$val = eval($val);
// echo "'$val'</p>";
}
}
if($pattern[0] != '@' || $val)
{
break;
}
}
}
$values[$addr] = $val;
}
$values[$addr] = $val;
$log .= "\t\t<td>$val</td>\n";
}
$empty = !count($values);
// convert the category name to an id
if ($values['cat_id'])
$log .= "\t\t<td>$val</td>\n";
}
$empty = !count($values);
// convert the category name to an id
if ($values['cat_id'])
{
$values['cat_id'] = cat_id($values['cat_id']);
}
// convert dates to timestamps
foreach(array('created','modified') as $date)
{
if (isset($values[$date]) && !is_numeric($date))
{
$values['cat_id'] = cat_id($values['cat_id']);
}
// convert dates to timestamps
foreach(array('created','modified') as $date)
{
if (isset($values[$date]) && !is_numeric($date))
{
// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
$values[$date] = ereg_replace('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})','\3-\2-\1',$values[$date]);
// remove fractures of seconds if present at the end of the string
if (ereg('(.*)\.[0-9]+',$values[$date],$parts)) $values[$date] = $parts[1];
$values[$date] = strtotime($values[$date]);
}
}
// convert user-names to user-id's
foreach(array('owner','modifier','creator') as $user)
{
if (isset($values[$user]) && !is_numeric($user))
{
$values[$user] = $GLOBALS['egw']->accounts->name2id($values[$user]);
}
}
if (!in_array('owner',$addr_fields) || !$values['owner'])
{
$values['owner'] = $GLOBALS['egw_info']['user']['account_id'];
}
if (!in_array('private',$addr_fields))
{
$values['private'] = 0; // public access if not set by user
$log .= "\t\t<td>".$values['private']."</td>\n";
}
else
{
$values['private'] = (int) in_array($values['private'],array(lang('yes'),'yes','private','1','true'));
}
if(!$_POST['debug'] && !$empty) // dont import empty contacts
{
$rvalue=$GLOBALS['egw']->contacts->save($values);
//echo "<p>adding: ".print_r($values,true)."</p>\n";
// convert german DD.MM.YYYY format into ISO YYYY-MM-DD format
$values[$date] = ereg_replace('([0-9]{1,2}).([0-9]{1,2}).([0-9]{4})','\3-\2-\1',$values[$date]);
// remove fractures of seconds if present at the end of the string
if (ereg('(.*)\.[0-9]+',$values[$date],$parts)) $values[$date] = $parts[1];
$values[$date] = strtotime($values[$date]);
}
}
$log .= "\t</tr>\n</table>\n";
// convert user-names to user-id's
foreach(array('owner','modifier','creator') as $user)
{
if (isset($values[$user]) && !is_numeric($user))
{
$values[$user] = $GLOBALS['egw']->accounts->name2id($values[$user]);
}
}
if (!in_array('owner',$addr_fields) || !$values['owner'])
{
$values['owner'] = $GLOBALS['egw_info']['user']['account_id'];
}
if (!in_array('private',$addr_fields))
{
$values['private'] = 0; // public access if not set by user
$log .= "\t\t<td>".$values['private']."</td>\n";
}
else
{
$values['private'] = (int) in_array($values['private'],array(lang('yes'),'yes','private','1','true'));
}
if(!$_POST['debug'] && !$empty) // dont import empty contacts
{
$rvalue=$GLOBALS['egw']->contacts->save($values);
//echo "<p>adding: ".print_r($values,true)."</p>\n";
}
}
$log .= "\t</tr>\n</table>\n";
$GLOBALS['egw']->template->set_var('anz_imported',($_POST['debug'] ?
lang('%1 records read (not yet imported, you may go %2back%3 and uncheck Test Import)',
$anz,'','') :
lang('%1 records imported',$anz)). '&nbsp;'.
(!$_POST['debug'] && $fields ? $GLOBALS['egw']->html->submit_button('next','Import next set') . '&nbsp;':'').
$GLOBALS['egw']->html->submit_button('continue','Back') . '&nbsp;'.
$GLOBALS['egw']->html->submit_button('cancel','Cancel'));
$GLOBALS['egw']->template->set_var('log',$log);
$GLOBALS['egw']->template->parse('importedhandle','imported');
break;
}
$GLOBALS['egw']->template->set_var('anz_imported',($_POST['debug'] ?
lang('%1 records read (not yet imported, you may go %2back%3 and uncheck Test Import)',
$anz,'','') :
lang('%1 records imported',$anz)). '&nbsp;'.
(!$_POST['debug'] && $fields ? html::submit_button('next','Import next set') . '&nbsp;':'').
html::submit_button('continue','Back') . '&nbsp;'.
html::submit_button('cancel','Cancel'));
$GLOBALS['egw']->template->set_var('log',$log);
$GLOBALS['egw']->template->parse('importedhandle','imported');
break;
}
$GLOBALS['egw']->template->set_var('hiddenvars',str_replace('{','&#x7B;',$hiddenvars));
$GLOBALS['egw']->template->pfp('out','import',True);
$GLOBALS['egw']->common->egw_footer();
?>
$GLOBALS['egw']->template->set_var('hiddenvars',str_replace('{','&#x7B;',$hiddenvars));
$GLOBALS['egw']->template->pfp('out','import',True);
$GLOBALS['egw']->common->egw_footer();

View File

@ -12,7 +12,6 @@
*/
require_once(EGW_INCLUDE_ROOT. '/importexport/inc/class.iface_egw_record.inc.php');
require_once(EGW_INCLUDE_ROOT. '/addressbook/inc/class.bocontacts.inc.php');
/**
* class egw_addressbook_record
@ -35,7 +34,7 @@ class egw_addressbook_record implements iface_egw_record
*/
public function __construct( $_identifier='' ){
$this->identifier = $_identifier;
$this->bocontacts = new bocontacts();
$this->bocontacts = new addressbook_bo();
$this->contact = $this->bocontacts->read($this->identifier);
}

View File

@ -39,7 +39,7 @@ class export_contacts_csv implements iface_export_plugin {
$uicontacts->get_rows($query,$selection,$readonlys,true); // true = only return the id's
}
elseif ( $options['selection'] == 'all_contacts' ) {
$selection = ExecMethod('addressbook.bocontacts.search',array());
$selection = ExecMethod('addressbook.addressbook_bo.search',array());
//$uicontacts->get_rows($query,$selection,$readonlys,true);
} else {
$selection = explode(',',$options['selection']);

View File

@ -102,7 +102,7 @@ class import_contacts_csv implements iface_import_plugin {
$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false;
// fetch the addressbook bo
$this->bocontacts = CreateObject('addressbook.bocontacts');
$this->bocontacts = new addressbook_bo();
// set FieldMapping.
$import_csv->mapping = $_definition->plugin_options['field_mapping'];

View File

@ -6,23 +6,16 @@
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de> and Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.socontacts.inc.php');
/**
* General business object of the adressbook
*
* @package addressbook
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de> and Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class bocontacts extends socontacts
class addressbook_bo extends addressbook_so
{
/**
* @var int $tz_offset_s offset in secconds between user and server-time,
@ -125,9 +118,9 @@ class bocontacts extends socontacts
*/
var $default_private;
function bocontacts($contact_app='addressbook')
function __construct($contact_app='addressbook')
{
$this->socontacts($contact_app);
parent::__construct($contact_app);
$this->tz_offset_s = 3600 * $GLOBALS['egw_info']['user']['preferences']['common']['tz_offset'];
$this->now_su = time() + $this->tz_offset_s;
@ -389,7 +382,7 @@ class bocontacts extends socontacts
function photo_src($id,$jpeg,$default='')
{
return $jpeg ? array(
'menuaction' => 'addressbook.uicontacts.photo',
'menuaction' => 'addressbook.addressbook_ui.photo',
'contact_id' => $id,
) : $default;
}
@ -1209,7 +1202,7 @@ class bocontacts extends socontacts
{
if (!is_object($this->categories))
{
$this->categories =& CreateObject('phpgwapi.categories',$this->owner,'addressbook');
$this->categories = new categories($this->owner,'addressbook');
}
$cat_id_list = array();
@ -1246,7 +1239,7 @@ class bocontacts extends socontacts
{
if (!is_object($this->categories))
{
$this->categories =& CreateObject('phpgwapi.categories',$this->owner,'addressbook');
$this->categories = new categories($this->owner,'addressbook');
}
if (!is_array($cat_id_list))

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007/8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -45,13 +45,11 @@ class addressbook_contactform
}
elseif ($content['submitit'])
{
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
$contact = new bocontacts();
$contact = new addressbook_bo();
if ($content['owner']) // save the contact in the addressbook
{
if ($content['email_contactform']) // only necessary as long addressbook is not doing this itself
{
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.addressbook_tracking.inc.php');
$tracking = new addressbook_tracking($contact);
}
if ($contact->save($content))
@ -103,8 +101,7 @@ class addressbook_contactform
static $contact;
if (is_null($contact))
{
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
$contact = new bocontacts();
$contact = new addressbook_bo();
}
$content['show']['custom'.$custom] = true;
$content['customfield'][$custom] = $name;

View File

@ -4,19 +4,15 @@
*
* @link www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @subpackage export
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/**
* export to csv
*
* @package addressbook
* @subpackage export
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2006 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class csv_export
{
@ -25,9 +21,9 @@ class csv_export
var $charset_out;
var $separator;
function csv_export($obj,$charset=null,$separator=';')
function __construct($obj,$charset=null,$separator=';')
{
$this->obj =& $obj;
$this->obj = $obj;
$this->separator = $separator;
$this->charset_out = $charset;
$this->charset = $GLOBALS['egw']->translation->charset();
@ -46,7 +42,7 @@ class csv_export
if (!$file)
{
$browser =& CreateObject('phpgwapi.browser');
$browser = new browser();
$browser->content_header('addressbook.csv','text/comma-separated-values');
}
if (!($fp = fopen($file ? $file : 'php://output','w')))

View File

@ -10,14 +10,11 @@
* @version $Id: class.addressbook_display.inc.php 24099 2008-02-18 16:29:06Z stefanbecker $
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.uietemplate.inc.php');
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.uicontacts.inc.php');
/**
* SiteMgr Display form for the addressbook
*
*/
class addressbook_display extends uicontacts
class addressbook_display extends addressbook_ui
{
/**
* Shows the Addressbook Entry and stores the submitted data

View File

@ -11,8 +11,6 @@
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
/**
* eGroupWare: GroupDAV access: addressbook handler
*/
@ -21,7 +19,7 @@ class addressbook_groupdav extends groupdav_handler
/**
* bo class of the application
*
* @var vcaladdressbook
* @var addressbook_vcal
*/
var $bo;
@ -43,7 +41,7 @@ class addressbook_groupdav extends groupdav_handler
{
parent::__construct('addressbook',$debug);
$this->bo =& new bocontacts();
$this->bo =& new addressbook_bo();
// SoGo Connector for Thunderbird works only with iso-8859-1!
if (strpos($_SERVER['HTTP_USER_AGENT'],'Thunderbird') !== false) $charset = 'iso-8859-1';
@ -262,12 +260,11 @@ class addressbook_groupdav extends groupdav_handler
/**
* Get the handler and set the supported fields
*
* @return vcaladdressbook
* @return addressbook_vcal
*/
private function _get_handler()
{
include_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.vcaladdressbook.inc.php');
$handler =& new vcaladdressbook();
$handler =& new addressbook_vcal();
if (strpos($_SERVER['HTTP_USER_AGENT'],'KHTML') !== false)
{
$handler->setSupportedFields('KDE');

View File

@ -30,7 +30,7 @@ class addressbook_hooks
{
$file = array(
array(
'text' => '<a class="textSidebox" href="'.$GLOBALS['egw']->link('/index.php',array('menuaction' => 'addressbook.uicontacts.edit')).
'text' => '<a class="textSidebox" href="'.$GLOBALS['egw']->link('/index.php',array('menuaction' => 'addressbook.addressbook_ui.edit')).
'" onclick="window.open(this.href,\'_blank\',\'dependent=yes,width=850,height=440,scrollbars=yes,status=yes\');
return false;">'.lang('Add').'</a>',
'no_lang' => true,
@ -38,7 +38,7 @@ class addressbook_hooks
),
array(
'text' => '<a class="textSidebox" href="'.$GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'addressbook.uicontacts.search',)).
'menuaction' => 'addressbook.addressbook_ui.search',)).
'" onclick="window.open(this.href,\'advanced_search\',\'dependent=yes,width=850,height=480,scrollbars=yes,status=yes\');
return false;">'.lang('Advanced search').'</a>',
'no_lang' => true,
@ -113,7 +113,7 @@ class addressbook_hooks
'label' => 'Default addressbook for adding contacts',
'name' => 'add_default',
'help' => 'Which addressbook should be selected when adding a contact AND you have no add rights to the current addressbook.',
'values' => ExecMethod('addressbook.uicontacts.get_addressbooks',EGW_ACL_ADD),
'values' => ExecMethod('addressbook.addressbook_ui.get_addressbooks',EGW_ACL_ADD),
'xmlrpc' => True,
'admin' => False,
);
@ -264,7 +264,7 @@ class addressbook_hooks
$menuData[] = array(
'description' => 'Addressbook',
'url' => '/index.php',
'extradata' => 'menuaction=addressbook.uicontacts.edit',
'extradata' => 'menuaction=addressbook.addressbook_ui.edit',
'options' => "onclick=\"window.open(this,'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;\"".
' title="'.htmlspecialchars(lang('Edit extra account-data in the addressbook')).'"',
);
@ -279,15 +279,15 @@ class addressbook_hooks
static function search_link($location)
{
return array(
'query' => 'addressbook.bocontacts.link_query',
'title' => 'addressbook.bocontacts.link_title',
'titles' => 'addressbook.bocontacts.link_titles',
'query' => 'addressbook.addressbook_bo.link_query',
'title' => 'addressbook.addressbook_bo.link_title',
'titles' => 'addressbook.addressbook_bo.link_titles',
'view' => array(
'menuaction' => 'addressbook.uicontacts.view'
'menuaction' => 'addressbook.addressbook_ui.view'
),
'view_id' => 'contact_id',
'add' => array(
'menuaction' => 'addressbook.uicontacts.edit'
'menuaction' => 'addressbook.addressbook_ui.edit'
),
'add_app' => 'link_app',
'add_id' => 'link_id',
@ -305,7 +305,7 @@ class addressbook_hooks
{
return array(
'type' => 'c',// one char type-identifiy for this resources
'info' => 'addressbook.bocontacts.calendar_info',// info method, returns array with id, type & name for a given id
'info' => 'addressbook.addressbook_bo.calendar_info',// info method, returns array with id, type & name for a given id
);
}
}

View File

@ -22,13 +22,8 @@ define('ADDRESSBOOK_GROUP',3);
*
* All values used to construct filters need to run through ldap::quote(),
* to be save against LDAP query injection!!!
*
* @package addressbook
* @author Cornelius Weiss <egw-AT-von-und-zu-weiss.de>
* @author Lars Kneschke <l.kneschke-AT-metaways.de>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
*/
class so_ldap
class addressbook_ldap
{
var $data;
@ -207,7 +202,7 @@ class so_ldap
/**
* constructor of the class
*/
function so_ldap()
function __construct()
{
//$this->db_data_cols = $this->stock_contact_fields + $this->non_contact_fields;
$this->accountName = $GLOBALS['egw_info']['user']['account_lid'];

View File

@ -10,8 +10,6 @@
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
/**
* Addressbook - document merge object
*/
@ -24,9 +22,9 @@ class addressbook_merge // extends bo_merge
*/
var $public_functions = array('show_replacements' => true);
/**
* Instance of the bocontacts class
* Instance of the addressbook_bo class
*
* @var bocontacts
* @var addressbook_bo
*/
var $contacts;
@ -35,9 +33,9 @@ class addressbook_merge // extends bo_merge
*
* @return addressbook_merge
*/
function addressbook_merge()
function __construct()
{
$this->contacts =& new bocontacts();
$this->contacts =& new addressbook_bo();
}
/**

View File

@ -6,13 +6,12 @@
* @author Lars Kneschke <lkneschke@egroupware.org>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @subpackage export
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
require_once EGW_SERVER_ROOT.'/addressbook/inc/class.bocontacts.inc.php';
class sifaddressbook extends bocontacts
class addressbook_sif extends addressbook_bo
{
var $sifMapping = array(
'Anniversary' => '',
@ -175,7 +174,7 @@ class sifaddressbook extends bocontacts
unset($contact['n_fileas']);
// we probably need to ignore even more as we do in vcaladdressbook
if(($foundContacts = bocontacts::search($contact)))
if(($foundContacts = addressbook_bo::search($contact)))
{
error_log(print_r($foundContacts,true));
return $foundContacts[0]['id'];

View File

@ -6,7 +6,8 @@
* @author Cornelius Weiss <egw-AT-von-und-zu-weiss.de>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de> and Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005-8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
@ -27,15 +28,9 @@
*
* If sql-ldap is used as contact-storage (LDAP is managed from eGroupWare) the filter all, searches
* the accounts in the SQL contacts-table too. Change in made in LDAP, are not detected in that case!
*
* @package addressbook
* @author Cornelius Weiss <egw-AT-von-und-zu-weiss.de>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2005/6 by Cornelius Weiss <egw@von-und-zu-weiss.de> and Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class socontacts
class addressbook_so
{
/**
* name of customefields table
@ -202,7 +197,7 @@ class socontacts
var $sodistrib_list;
var $backend;
function socontacts($contact_app='addressbook')
function __construct($contact_app='addressbook')
{
$this->db = $GLOBALS['egw']->db;
@ -222,7 +217,7 @@ class socontacts
if($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' && $this->account_repository == 'ldap')
{
$this->contact_repository = 'ldap';
$this->somain =& CreateObject('addressbook.so_ldap');
$this->somain =& new addressbook_ldap();
if ($this->user) // not set eg. in setup
{
@ -241,7 +236,7 @@ class socontacts
{
$this->contact_repository = 'sql-ldap';
}
$this->somain =& CreateObject('addressbook.socontacts_sql');
$this->somain =& new addressbook_sql();
if ($this->user) // not set eg. in setup
{
@ -256,7 +251,7 @@ class socontacts
{
if ($this->account_repository != $this->contact_repository)
{
$this->so_accounts =& CreateObject('addressbook.so_ldap');
$this->so_accounts = new addressbook_ldap();
$this->account_cols_to_search = $this->ldap_search_attributes;
}
else
@ -790,8 +785,8 @@ class socontacts
*/
function migrate2ldap($type)
{
$sql_contacts =& CreateObject('addressbook.socontacts_sql');
$ldap_contacts =& CreateObject('addressbook.so_ldap');
$sql_contacts = new addressbook_sql();
$ldap_contacts = new addressbook_ldap();
$start = $n = 0;
$num = 100;

View File

@ -15,7 +15,7 @@ include_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
/**
* SQL storage object of the adressbook
*/
class socontacts_sql extends so_sql
class addressbook_sql extends so_sql
{
/**
* name of customefields table
@ -50,7 +50,7 @@ class socontacts_sql extends so_sql
*/
var $ab2list_table = 'egw_addressbook2list';
function socontacts_sql()
function __construct()
{
$this->so_sql('phpgwapi','egw_addressbook',null,'contact_',true); // true = using the global db object, no clone!

View File

@ -10,8 +10,6 @@
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.bo_tracking.inc.php');
/**
* Addressbook - tracking object
*/
@ -68,9 +66,9 @@ class addressbook_tracking extends bo_tracking
* @param bocontacts &$bocontacts
* @return tracker_tracking
*/
function addressbook_tracking(&$bocontacts)
function __construct(&$bocontacts)
{
$this->bo_tracking(); // calling the constructor of the extended class
parent::__construct(); // calling the constructor of the extended class
$this->contacts =& $bocontacts;
}

View File

@ -12,12 +12,10 @@
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
/**
* General user interface object of the adressbook
*/
class uicontacts extends bocontacts
class addressbook_ui extends addressbook_bo
{
var $public_functions = array(
'search' => True,
@ -50,9 +48,9 @@ class uicontacts extends bocontacts
*/
var $tabs = 'general|cats|home|details|links|distribution_list|custom|custom_private';
function uicontacts($contact_app='addressbook')
function __construct($contact_app='addressbook')
{
$this->bocontacts($contact_app);
parent::__construct($contact_app);
$this->tmpl = new etemplate();
@ -166,7 +164,7 @@ class uicontacts extends bocontacts
if (!is_array($content['nm']))
{
$content['nm'] = array(
'get_rows' => 'addressbook.uicontacts.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
'get_rows' => 'addressbook.addressbook_ui.get_rows', // I method/callback to request the data for the rows eg. 'notes.bo.get_rows'
'bottom_too' => false, // I show the nextmatch-line (arrows, filters, search, ...) again after the rows
'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie
'start' => 0, // IO position in list
@ -314,7 +312,7 @@ class uicontacts extends bocontacts
$content['nm']['org_view_label'] = $sel_options['org_view'][(string) $content['nm']['org_view']];
$this->tmpl->read(/*$do_email ? 'addressbook.email' :*/ 'addressbook.index');
return $this->tmpl->exec($do_email ? 'addressbook.uicontacts.emailpopup' : 'addressbook.uicontacts.index',
return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index',
$content,$sel_options,$readonlys,$preserv,$do_email ? 2 : 0);
}
@ -1285,7 +1283,7 @@ class uicontacts extends bocontacts
$content['msg'] = lang('Error: the entry has been updated since you opened it for editing!').'<br />'.
lang('Copy your changes to the clipboard, %1reload the entry%2 and merge them.','<a href="'.
htmlspecialchars($GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'addressbook.uicontacts.edit',
'menuaction' => 'addressbook.addressbook_ui.edit',
'contact_id' => $content['id'],
))).'">','</a>');
break; // dont refresh the list
@ -1307,7 +1305,7 @@ class uicontacts extends bocontacts
addslashes(urlencode($content['msg']))."'; window.close();</script></body></html>\n";
/*
$link = $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'addressbook.uicontacts.view',
'menuaction' => 'addressbook.addressbook_ui.view',
'contact_id' => $content['id'],
));
echo "<html><body><script>opener.location.href = '$link&msg=".
@ -1502,7 +1500,7 @@ class uicontacts extends bocontacts
$content['msg'] .= lang('Please update the templatename in your customfields section!');
$this->tmpl->read('addressbook.edit');
}
return $this->tmpl->exec('addressbook.uicontacts.edit',$content,$sel_options,$readonlys,$content, 2);
return $this->tmpl->exec('addressbook.addressbook_ui.edit',$content,$sel_options,$readonlys,$content, 2);
}
/**
@ -1621,11 +1619,11 @@ class uicontacts extends bocontacts
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']);
case 'cancel':
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uicontacts.index');
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index');
case 'delete':
$GLOBALS['egw']->redirect_link('/index.php',array(
'menuaction' => 'addressbook.uicontacts.index',
'menuaction' => 'addressbook.addressbook_ui.index',
'msg' => $this->delete($content) ? lang('Contact deleted') : lang('Error deleting the contact !!!'),
));
}
@ -1635,7 +1633,7 @@ class uicontacts extends bocontacts
if(!$_GET['contact_id'] || !is_array($content = $this->read($_GET['contact_id'])))
{
$GLOBALS['egw']->redirect_link('/index.php',array(
'menuaction' => 'addressbook.uicontacts.index',
'menuaction' => 'addressbook.addressbook_ui.index',
'msg' => $content,
));
}
@ -1726,7 +1724,7 @@ $readonlys['button[vcard]'] = true;
// set id for automatic linking via quick add
$GLOBALS['egw_info']['flags']['currentid'] = $content['id'];
$this->tmpl->exec('addressbook.uicontacts.view',$content,$sel_options,$readonlys,array('id' => $content['id']));
$this->tmpl->exec('addressbook.addressbook_ui.view',$content,$sel_options,$readonlys,array('id' => $content['id']));
$GLOBALS['egw']->hooks->process(array(
'location' => 'addressbook_view',
@ -1848,7 +1846,7 @@ $readonlys['button[vcard]'] = true;
$content['disable_change_org'] = true;
$this->tmpl->read('addressbook.search');
return $this->tmpl->exec('addressbook.uicontacts.search',$content,$sel_options,$readonlys,$preserv,2);
return $this->tmpl->exec('addressbook.addressbook_ui.search',$content,$sel_options,$readonlys,$preserv,2);
}
/**
@ -1963,7 +1961,7 @@ $readonlys['button[vcard]'] = true;
if (family) name.value += family+" ";
if (suffix) name.value += suffix;
xajax_doXMLHTTP("addressbook.uicontacts.ajax_setFileasOptions",prefix,given,middle,family,suffix,org);
xajax_doXMLHTTP("addressbook.addressbook_ui.ajax_setFileasOptions",prefix,given,middle,family,suffix,org);
}
function add_whole_list(list)
@ -1976,7 +1974,7 @@ $readonlys['button[vcard]'] = true;
{
email_type = "email";
}
xajax_doXMLHTTP("addressbook.uicontacts.ajax_add_whole_list",list,email_type);
xajax_doXMLHTTP("addressbook.addressbook_ui.ajax_add_whole_list",list,email_type);
}
function setOptions(options_str)
@ -2009,7 +2007,7 @@ $readonlys['button[vcard]'] = true;
if (name)
{
document.location.href = "'.$GLOBALS['egw']->link('/index.php',array(
'menuaction'=>$_GET['menuaction'],//'addressbook.uicontacts.index',
'menuaction'=>$_GET['menuaction'],//'addressbook.addressbook_ui.index',
'add_list'=>'',
)).'"+encodeURIComponent(name)+"&owner="+owner;
}
@ -2202,6 +2200,6 @@ $readonlys['button[vcard]'] = true;
$content['cat_tab'] = $this->config['cat_tab'];
$this->tmpl->read('addressbook.index.cat_add');
return $this->tmpl->exec('addressbook.uicontacts.cat_add',$content,$sel_options,$readonlys,$content, 2);
return $this->tmpl->exec('addressbook.addressbook_ui.cat_add',$content,$sel_options,$readonlys,$content, 2);
}
}

View File

@ -6,15 +6,31 @@
* @author Lars Kneschke <lkneschke@egroupware.org>
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @subpackage export
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
require_once EGW_SERVER_ROOT.'/addressbook/inc/class.bocontacts.inc.php';
require_once EGW_SERVER_ROOT.'/phpgwapi/inc/horde/Horde/iCalendar.php';
class vcaladdressbook extends bocontacts
/**
* Addressbook - vCard parser
*
*/
class addressbook_vcal extends addressbook_bo
{
/**
* product manufacturer from setSupportedFields (lowercase!)
*
* @var string
*/
var $productManufacturer='file';
/**
* product name from setSupportedFields (lowercase!)
*
* @var string
*/
var $productName;
/**
* import a vard into addressbook
@ -114,7 +130,11 @@ class vcaladdressbook extends bocontacts
if(preg_match('/([\177-\377])/',$valueData))
{
$options['CHARSET'] = $_charset;
$options['ENCODING'] = 'QUOTED-PRINTABLE';
// KAddressbook requires non-ascii chars to be qprint encoded, other clients eg. nokia phones have trouble with that
if ($this->productManufacturer == 'kde')
{
$options['ENCODING'] = 'QUOTED-PRINTABLE';
}
}
elseif(preg_match('/([\000-\012\015\016\020-\037\075])/',$value))
{
@ -183,6 +203,10 @@ class vcaladdressbook extends bocontacts
function setSupportedFields($_productManufacturer='file', $_productName='')
{
// store product manufacturer and name, to be able to use it elsewhere
$this->productManufacturer = strtolower($_productManufacturer);
$this->productName = strtolower($_productName);
/**
* ToDo Lars:
* + changes / renamed fields in 1.3+:
@ -394,10 +418,10 @@ class vcaladdressbook extends bocontacts
));
//error_log("Client: $_productManufacturer $_productName");
switch(strtolower($_productManufacturer))
switch($this->productManufacturer)
{
case 'funambol':
switch (strtolower($_productName))
switch ($this->productName)
{
case 'thunderbird':
$this->supportedFields = $defaultFields[6];
@ -412,7 +436,7 @@ class vcaladdressbook extends bocontacts
case 'nexthaus corporation':
case 'nexthaus corp':
switch(strtolower($_productName))
switch($this->productName)
{
case 'syncje outlook edition':
$this->supportedFields = $defaultFields[1];
@ -425,7 +449,7 @@ class vcaladdressbook extends bocontacts
break;
case 'nokia':
switch(strtolower($_productName))
switch($this->productName)
{
case 'e61':
$this->supportedFields = $defaultFields[5];
@ -444,7 +468,7 @@ class vcaladdressbook extends bocontacts
// multisync does not provide anymore information then the manufacturer
// we suppose multisync with evolution
case 'the multisync project':
switch(strtolower($_productName))
switch($this->productName)
{
default:
$this->supportedFields = $defaultFields[0];
@ -453,7 +477,7 @@ class vcaladdressbook extends bocontacts
break;
case 'siemens':
switch(strtolower($_productName))
switch($this->productName)
{
case 'sx1':
$this->supportedFields = $defaultFields[3];
@ -467,7 +491,7 @@ class vcaladdressbook extends bocontacts
case 'sonyericsson':
case 'sony ericsson':
switch(strtolower($_productName))
switch($this->productName)
{
case 'd750i':
$this->supportedFields = $defaultFields[2];
@ -481,7 +505,7 @@ class vcaladdressbook extends bocontacts
break;
case 'synthesis ag':
switch(strtolower($_productName))
switch($this->productName)
{
case 'sysync client pocketpc pro':
case 'sysync client pocketpc std':

View File

@ -5,16 +5,16 @@
* The original addressbook xmlrpc interface was written by Joseph Engo <jengo@phpgroupware.org>
* and Miles Lott <milos@groupwhere.org>
*
* Please note: dont use addressbook_... naming convention, as it would break the existing xmlrpc clients
*
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package addressbook
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright (c) 2007/8 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
require_once(EGW_API_INC.'/class.contacts.inc.php');
/**
* Class to access AND manipulate addressbook data via XMLRPC or SOAP
*
@ -50,7 +50,7 @@ class boaddressbook
*
* @return boaddressbook
*/
function boaddressbook()
function __construct()
{
$this->contacts = $GLOBALS['egw']->contacts;

View File

@ -29,7 +29,7 @@ function contact_repositories($config)
function own_account_acl($config)
{
$bocontacts =& CreateObject('addressbook.bocontacts');
$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();
@ -45,8 +45,7 @@ function own_account_acl($config)
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{
$custom =& CreateObject('admin.customfields','addressbook');
foreach($custom->get_customfields() as $name => $data)
foreach(config::get_customfields('addressbook') as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
@ -56,7 +55,7 @@ function own_account_acl($config)
function org_fileds_to_update($config)
{
$bocontacts =& CreateObject('addressbook.bocontacts');
$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();
@ -71,16 +70,11 @@ function org_fileds_to_update($config)
if ($config['account_repository'] != 'ldap') // no custom-fields in ldap
{
$custom =& CreateObject('admin.customfields','addressbook');
foreach($custom->get_customfields() as $name => $data)
foreach(config::get_customfields('addressbook') as $name => $data)
{
$fields['#'.$name] = $data['label'];
}
}
if (!is_object($GLOBALS['egw']->html))
{
$GLOBALS['egw']->html =& CreateObject('phpgwapi.html');
}
return html::checkbox_multiselect('newsettings[org_fileds_to_update]',
$config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',4);
}

View File

@ -15,8 +15,7 @@ if ($GLOBALS['egw_info']['user']['apps']['addressbook'] &&
if (!(int) $days) $days = 1; // old pref
include_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
$contacts =& new bocontacts();
$contacts =& new addressbook_bo();
$month_start = date('*-m-*',$contacts->now_su);
$bdays =& $contacts->search(array('bday' => $month_start),array('id','n_family','n_given','bday'),'n_given,n_family');
@ -82,7 +81,7 @@ if ($GLOBALS['egw_info']['user']['apps']['addressbook'] &&
}
$portalbox->data[] = array(
'text' => $text,
'link' => $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uicontacts.view&contact_id=' . $contact['id'])
'link' => $GLOBALS['egw']->link('/index.php','menuaction=addressbook.addressbook_ui.view&contact_id=' . $contact['id'])
);
}
}

View File

@ -1,29 +1,26 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.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. *
\**************************************************************************/
/**
* eGroupWare Addressbook
*
* @link http://www.egroupware.org
* @package addressbook
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
/* $Id$ */
$GLOBALS['egw_info'] = array(
'flags' => array(
'currentapp' => 'addressbook',
'noheader' => True,
'nonavbar' => True
));
include('../header.inc.php');
$GLOBALS['egw_info'] = array(
'flags' => array(
'currentapp' => 'addressbook',
'noheader' => True,
'nonavbar' => True
));
include('../header.inc.php');
// check if we have an advanced search and reset it in case
$old_state = $GLOBALS['egw']->session->appsession('index','addressbook');
if ($old_state['advanced_search'])
{
unset($old_state['advanced_search']);
$GLOBALS['egw']->session->appsession('index','addressbook',$old_state);
}
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uicontacts.index');
// check if we have an advanced search and reset it in case
$old_state = $GLOBALS['egw']->session->appsession('index','addressbook');
if ($old_state['advanced_search'])
{
unset($old_state['advanced_search']);
$GLOBALS['egw']->session->appsession('index','addressbook',$old_state);
}
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.addressbook_ui.index');

File diff suppressed because one or more lines are too long

View File

@ -35,7 +35,7 @@ $setup_info['addressbook']['hooks']['preferences'] = 'addressbook_hooks::all_hoo
$setup_info['addressbook']['hooks']['sidebox_menu'] = 'addressbook_hooks::all_hooks';
$setup_info['addressbook']['hooks']['settings'] = 'addressbook_hooks::settings';
$setup_info['addressbook']['hooks'][] = 'home';
$setup_info['addressbook']['hooks']['deleteaccount'] = 'addressbook.bocontacts.deleteaccount';
$setup_info['addressbook']['hooks']['deleteaccount'] = 'addressbook.addressbook_bo.deleteaccount';
$setup_info['addressbook']['hooks']['search_link'] = 'addressbook_hooks::search_link';
$setup_info['addressbook']['hooks']['calendar_resources'] = 'addressbook_hooks::calendar_resources';
$setup_info['addressbook']['hooks']['edit_user'] = 'addressbook_hooks::edit_user';

View File

@ -10,8 +10,6 @@
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.sitemgr_module.inc.php');
/**
* SiteMgr contact form for the addressbook
*
@ -23,7 +21,7 @@ class module_addressbook_contactform extends sitemgr_module
*
* @return module_addressbook_contactform
*/
function module_addressbook_contactform()
function __construct()
{
$this->arguments = array(); // get's set in get_user_interface
$this->title = lang('Contactform');
@ -41,8 +39,7 @@ class module_addressbook_contactform extends sitemgr_module
{
$GLOBALS['egw']->translation->add_app('addressbook');
require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.uicontacts.inc.php');
$uicontacts = new uicontacts();
$uicontacts = new addressbook_ui();
$default = $fields = array(
'org_name' => lang('Company'),

View File

@ -10,11 +10,8 @@
* @version $Id: class.module_addressbook_display.inc.php 24028 2008-02-18 09:04:36Z stefanbecker $
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.sitemgr_module.inc.php');
/**
* SiteMgr contact form for the addressbook
*
*/
class module_addressbook_display extends sitemgr_module
{
@ -23,7 +20,7 @@ class module_addressbook_display extends sitemgr_module
*
* @return module_addressbook_showcontactblock
*/
function module_addressbook_display()
function __construct()
{
$this->arguments = array(); // get's set in get_user_interface
$this->title = lang('Display Contact');
@ -41,8 +38,7 @@ class module_addressbook_display extends sitemgr_module
{
$GLOBALS['egw']->translation->add_app('addressbook');
include_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.uicontacts.inc.php');
$uicontacts = new uicontacts();
$uicontacts = new addressbook_ui();
$default = $fields = array(
'org_name' => lang('Company'),

View File

@ -114,7 +114,7 @@
<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.uicontacts.migrate2ldap&type='+this.form.migrate.value;" value="{lang_Start}" />
<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 -->

View File

@ -6,19 +6,20 @@
<menupopup rows="1" cols="1" id="org_view" no_lang="1" statustext="Select a view" onchange="1" options="All contacts"/>
</menulist>
</template>
<template id="addressbook.index.right_add" template="" lang="" group="0" version="1.3.005">
<template id="addressbook.index.right_add" template="" lang="" group="0" version="1.5.001">
<hbox>
<buttononly id="search" label="Advanced search" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.search'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;"/>
<buttononly id="add" label="Add" statustext="Add a new contact" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.edit'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" class="rightPadAdd"/>
<buttononly id="search" label="Advanced search" onclick="window.open(egw::link('/index.php','menuaction=addressbook.addressbook_ui.search'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;"/>
<buttononly id="add" label="Add" statustext="Add a new contact" onclick="window.open(egw::link('/index.php','menuaction=addressbook.addressbook_ui.edit'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" class="rightPadAdd"/>
<description id="manual" class="rightPadAdd"/>
</hbox>
<styles>.rightPadAdd { width: 30px; }</styles>
</template>
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.5.003">
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.5.005">
<grid width="100%">
<columns>
<column/>
<column/>
<column disabled="@no_role"/>
<column/>
<column width="60" disabled="@no_photo"/>
<column/>
@ -63,6 +64,7 @@
</row>
</rows>
</grid>
<nextmatch-header label="role" id="role"/>
<nextmatch-header label="Category" id="cat_id"/>
<nextmatch-header label="Photo" id="photo"/>
<vbox options="0,0">
@ -106,6 +108,7 @@
<description id="${row}[title]" no_lang="1"/>
<description id="${row}[first_org]" no_lang="1"/>
</vbox>
<description id="${row}[role]"/>
<menulist>
<menupopup type="select-cat" options="1" id="${row}[cat_id]" readonly="true"/>
</menulist>
@ -160,8 +163,8 @@
</vbox>
<hbox options="0" class="noPrint" orient="0">
<button id="document[$row_cont[id]]" image="new" label="Insert in document"/>
<image options="addressbook.uicontacts.view&amp;contact_id=$row_cont[id]" label="View" src="view"/>
<button image="edit" label="Edit" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.edit&amp;contact_id=$row_cont[id]'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" id="edit[$row_cont[id]]"/>
<image options="addressbook.addressbook_ui.view&amp;contact_id=$row_cont[id]" label="View" src="view"/>
<button image="edit" label="Edit" onclick="window.open(egw::link('/index.php','menuaction=addressbook.addressbook_ui.edit&amp;contact_id=$row_cont[id]'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" id="edit[$row_cont[id]]"/>
<button id="delete[$row_cont[id]]" image="delete" label="Delete" statustext="Delete this contact" onclick="return confirm('Delete this contact');"/>
<checkbox id="checked[]" options="$row_cont[id]" statustext="Select multiple contacts for a further action" align="right"/>
</hbox>
@ -188,11 +191,11 @@
<nextmatch options="addressbook.index.rows" id="nm" span="all"/>
</row>
<row class="noPrint">
<button id="add" label="Add" statustext="Add a new contact" onclick="window.open(egw::link('/index.php','menuaction=addressbook.uicontacts.edit'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;"/>
<button id="add" label="Add" statustext="Add a new contact" onclick="window.open(egw::link('/index.php','menuaction=addressbook.addressbook_ui.edit'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;"/>
<hbox align="right">
<checkbox id="use_all" label="whole query" onchange="if (this.checked==true &amp;&amp; !confirm('Apply the action on the whole query, NOT only the shown contacts!!!')) this.checked=false;" statustext="Apply the action on the whole query, NOT only the shown contacts!!!"/>
<menulist>
<menupopup onchange="if (this.value != '') {if (this.value == 'infolog_add') {ids=get_selected(this.form,'[rows][checked][]');win=window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&amp;type=task&amp;action=addressbook&amp;action_id=')+ids,'_blank','width=750,height=550,left=100,top=200'); win.focus();}if (this.value == 'cat_add'){win=window.open(egw::link('/etemplate/process_exec.php','menuaction=addressbook.uicontacts.cat_add'),'_blank','width=300,height=400,left=100,top=200'); win.focus();} else {this.form.submit(); } this.value=''; }" options="Select an action or addressbook to move to..." no_lang="1" id="action" statustext="Select an action or addressbook to move to"/>
<menupopup onchange="if (this.value != '') {if (this.value == 'infolog_add') {ids=get_selected(this.form,'[rows][checked][]');win=window.open(egw::link('/index.php','menuaction=infolog.uiinfolog.edit&amp;type=task&amp;action=addressbook&amp;action_id=')+ids,'_blank','width=750,height=550,left=100,top=200'); win.focus();}if (this.value == 'cat_add'){win=window.open(egw::link('/etemplate/process_exec.php','menuaction=addressbook.addressbook_ui.cat_add'),'_blank','width=300,height=400,left=100,top=200'); win.focus();} else {this.form.submit(); } this.value=''; }" options="Select an action or addressbook to move to..." no_lang="1" id="action" statustext="Select an action or addressbook to move to"/>
</menulist>
<button image="arrow_ltr" label="Check all" id="check_all" statustext="Check all" onclick="toggle_all(this.form,form::name('nm[rows][checked][]')); return false;" needed="1" class="checkAllArrow"/>
</hbox>