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,21 +12,20 @@
*/
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
* compability layer for iface_egw_record needet for importexport
*/
class egw_addressbook_record implements iface_egw_record
class egw_addressbook_record implements iface_egw_record
{
private $identifier = '';
private $contact = array();
private $bocontacts;
/**
* constructor
* reads record from backend if identifier is given.
@ -35,19 +34,19 @@ 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);
}
/**
* magic method to set attributes of record
*
* @param string $_attribute_name
*/
public function __get($_attribute_name) {
}
/**
* magig method to set attributes of record
*
@ -55,11 +54,11 @@ class egw_addressbook_record implements iface_egw_record
* @param data $data
*/
public function __set($_attribute_name, $data) {
}
/**
* converts this object to array.
* converts this object to array.
* @abstract We need such a function cause PHP5
* dosn't allow objects do define it's own casts :-(
* once PHP can deal with object casts we will change to them!
@ -69,10 +68,10 @@ class egw_addressbook_record implements iface_egw_record
public function get_record_array() {
return $this->contact;
}
/**
* gets title of record
*
*
*@return string tiltle
*/
public function get_title() {
@ -81,7 +80,7 @@ class egw_addressbook_record implements iface_egw_record
}
return $this->contact['fn'];
}
/**
* sets complete record from associative array
*
@ -91,7 +90,7 @@ class egw_addressbook_record implements iface_egw_record
public function set_record(array $_record){
$this->contact = $_record;
}
/**
* gets identifier of this record
*
@ -100,16 +99,16 @@ class egw_addressbook_record implements iface_egw_record
public function get_identifier() {
return $this->identifier;
}
/**
* saves record into backend
*
*
* @return string identifier
*/
public function save ( $_dst_identifier ) {
}
/**
* copys current record to record identified by $_dst_identifier
*
@ -117,9 +116,9 @@ class egw_addressbook_record implements iface_egw_record
* @return string dst_identifier
*/
public function copy ( $_dst_identifier ) {
}
/**
* moves current record to record identified by $_dst_identifier
* $this will become moved record
@ -128,17 +127,17 @@ class egw_addressbook_record implements iface_egw_record
* @return string dst_identifier
*/
public function move ( $_dst_identifier ) {
}
/**
* delets current record from backend
*
*
*/
public function delete () {
}
/**
* destructor
*

View File

@ -21,7 +21,7 @@ require_once(EGW_INCLUDE_ROOT. '/addressbook/inc/class.uicontacts.inc.php');
* export plugin of addressbook
*/
class export_contacts_csv implements iface_export_plugin {
/**
* Exports records as defined in $_definition
*
@ -29,34 +29,34 @@ class export_contacts_csv implements iface_export_plugin {
*/
public function export( $_stream, definition $_definition) {
$options = $_definition->plugin_options;
$uicontacts = new uicontacts();
$selection = array();
if ($options['selection'] == 'use_all') {
// uicontacts selection with checkbox 'use_all'
// uicontacts selection with checkbox 'use_all'
$query = $GLOBALS['egw']->session->appsession('index','addressbook');
$query['num_rows'] = -1; // all
$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']);
}
$export_object = new export_csv($_stream, (array)$options);
$export_object->set_mapping($options['mapping']);
// $options['selection'] is array of identifiers as this plugin doesn't
// support other selectors atm.
foreach ($selection as $identifier) {
$contact = new egw_addressbook_record($identifier);
$export_object->export_record($contact);
unset($contact);
}
}
}
/**
* returns translated name of plugin
*
@ -65,7 +65,7 @@ class export_contacts_csv implements iface_export_plugin {
public static function get_name() {
return lang('Addressbook CSV export');
}
/**
* returns translated (user) description of plugin
*
@ -74,7 +74,7 @@ class export_contacts_csv implements iface_export_plugin {
public static function get_description() {
return lang("Exports contacts from your Addressbook into a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
}
/**
* retruns file suffix for exported file
*
@ -83,17 +83,17 @@ class export_contacts_csv implements iface_export_plugin {
public static function get_filesuffix() {
return 'csv';
}
/**
* return html for options.
* this way the plugin has all opertunities for options tab
*
*
* @return string html
*/
public function get_options_etpl() {
return 'addressbook.export_csv_options';
}
/**
* returns slectors of this plugin via xajax
*

View File

@ -18,18 +18,18 @@ require_once(EGW_INCLUDE_ROOT.'/importexport/inc/class.import_csv.inc.php');
* class import_csv for addressbook
*/
class import_contacts_csv implements iface_import_plugin {
private static $plugin_options = array(
'fieldsep', // char
'charset', // string
'contact_owner', // int
'update_cats', // string {override|add} overides record
'update_cats', // string {override|add} overides record
// with cat(s) from csv OR add the cat from
// csv file to exeisting cat(s) of record
'num_header_lines', // int number of header lines
'field_conversion', // array( $csv_col_num => conversion)
'field_mapping', // array( $csv_col_num => adb_filed)
'conditions', /* => array containing condition arrays:
'conditions', /* => array containing condition arrays:
'type' => exists, // exists
'string' => '#kundennummer',
'true' => array(
@ -37,49 +37,49 @@ class import_contacts_csv implements iface_import_plugin {
'last' => true,
),
'false' => array(
'action' => insert,
'action' => insert,
'last' => true,
),*/
);
/**
* actions wich could be done to data entries
*/
private static $actions = array( 'none', 'update', 'insert', 'delete', );
/**
* conditions for actions
*
* @var array
*/
private static $conditions = array( 'exists', 'greater', 'greater or equal', );
/**
* @var definition
*/
private $definition;
/**
* @var bocontacts
*/
private $bocontacts;
/**
* @var bool
*/
private $dry_run = false;
/**
* @var bool is current user admin?
*/
private $is_admin = false;
/**
* @var int
*/
private $user = null;
/**
* imports entries according to given definition object.
* @param resource $_stream
@ -91,43 +91,43 @@ class import_contacts_csv implements iface_import_plugin {
'fieldsep' => $_definition->plugin_options['fieldsep'],
'charset' => $_definition->plugin_options['charset'],
));
$this->definition = $_definition;
// user, is admin ?
$this->is_admin = isset( $GLOBALS['egw_info']['user']['apps']['admin'] ) && $GLOBALS['egw_info']['user']['apps']['admin'];
$this->user = $GLOBALS['egw_info']['user']['account_id'];
// dry run?
$this->dry_run = isset( $_definition->plugin_options['dry_run'] ) ? $_definition->plugin_options['dry_run'] : false;
$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'];
// set FieldConversion
$import_csv->conversion = $_definition->plugin_options['field_conversion'];
//check if file has a header lines
if ( isset( $_definition->plugin_options['num_header_lines'] ) ) {
$import_csv->skip_records($_definition->plugin_options['num_header_lines']);
}
// set eventOwner
$_definition->plugin_options['contact_owner'] = isset( $_definition->plugin_options['contact_owner'] ) ?
$_definition->plugin_options['contact_owner'] = isset( $_definition->plugin_options['contact_owner'] ) ?
$_definition->plugin_options['contact_owner'] : $this->user;
while ( $record = $import_csv->get_record() ) {
// don't import empty contacts
if( count( array_unique( $record ) ) < 2 ) continue;
if ( $_definition->plugin_options['contact_owner'] != -1 ) {
$record['owner'] = $_definition->plugin_options['contact_owner'];
} else unset( $record['owner'] );
if ( $_definition->plugin_options['conditions'] ) {
foreach ( $_definition->plugin_options['conditions'] as $condition ) {
switch ( $condition['type'] ) {
@ -137,7 +137,7 @@ class import_contacts_csv implements iface_import_plugin {
array( $condition['string'] => $record[$condition['string']],),
$_definition->plugin_options['update_cats'] == 'add' ? false : true
);
if ( is_array( $contacts ) && count( array_keys( $contacts ) >= 1 ) ) {
// apply action to all contacts matching this exists condition
$action = $condition['true'];
@ -155,8 +155,8 @@ class import_contacts_csv implements iface_import_plugin {
$this->action( $action['action'], $record );
}
break;
// not supported action
// not supported action
default :
die('condition / action not supported!!!');
break;
@ -169,7 +169,7 @@ class import_contacts_csv implements iface_import_plugin {
}
}
}
/**
* perform the required action
*
@ -191,7 +191,7 @@ class import_contacts_csv implements iface_import_plugin {
case 'delete' :
}
}
/**
* returns translated name of plugin
*
@ -200,7 +200,7 @@ class import_contacts_csv implements iface_import_plugin {
public static function get_name() {
return lang('Addressbook CSV export');
}
/**
* returns translated (user) description of plugin
*
@ -209,7 +209,7 @@ class import_contacts_csv implements iface_import_plugin {
public static function get_description() {
return lang("Imports contacts into your Addressbook from a CSV File. CSV means 'Comma Seperated Values'. However in the options Tab you can also choose other seperators.");
}
/**
* retruns file suffix(s) plugin can handle (e.g. csv)
*
@ -218,12 +218,12 @@ class import_contacts_csv implements iface_import_plugin {
public static function get_filesuffix() {
return 'csv';
}
/**
* return etemplate components for options.
* @abstract We can't deal with etemplate objects here, as an uietemplate
* objects itself are scipt orientated and not "dialog objects"
*
*
* @return array (
* name => string,
* content => array,
@ -234,7 +234,7 @@ class import_contacts_csv implements iface_import_plugin {
public function get_options_etpl() {
// lets do it!
}
/**
* returns etemplate name for slectors of this plugin
*

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$
* @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();
@ -37,7 +33,7 @@ class csv_export
* Exports some contacts as CSV: download or write to a file
*
* @param array $ids contact-ids
* @param array $fields
* @param array $fields
* @param string $file filename or null for download
*/
function export($ids,$fields,$file=null)
@ -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')))
@ -66,14 +62,14 @@ class csv_export
fwrite($fp,$this->csv_encode($data,$fields)."\n");
}
fclose($fp);
if (!$file)
{
$GLOBALS['egw']->common->egw_exit();
}
}
return true;
}
function csv_encode($data,$fields)
{
$out = array();
@ -87,14 +83,14 @@ class csv_export
$out[] = $value;
}
$out = implode($this->separator,$out);
if ($this->charset_out && $this->charset != $this->charset_out)
{
$out = $GLOBALS['egw']->translation->convert($out,$this->charset,$this->charset_out);
}
return $out;
}
function csv_prepare(&$data,$fields)
{
foreach(array('owner','creator','modifier') as $name)
@ -113,16 +109,16 @@ class csv_export
if ($data[$name]) $data[$name] = date('Y-m-d H:i:s',$data[$name]);
}
if ($data['tel_prefer']) $data['tel_prefer'] = $fields[$data['tel_prefer']];
$cats = array();
foreach(explode(',',$data['cat_id']) as $cat_id)
{
if ($cat_id) $cats[] = $GLOBALS['egw']->categories->id2name($cat_id);
}
$data['cat_id'] = implode('; ',$cats);
$data['private'] = $data['private'] ? lang('yes') : lang('no');
$data['n_fileas'] = $this->obj->fileas($data);
$data['n_fn'] = $this->obj->fullname($data);
}

View File

@ -7,17 +7,14 @@
* @package addressbook
* @copyright (c) 2008 by Stefan Becker <StefanBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id: class.addressbook_display.inc.php 24099 2008-02-18 16:29:06Z stefanbecker $
* @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
@ -35,23 +32,23 @@ class addressbook_display extends uicontacts
function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
{
$query['sitemgr_display'] = ($readonlys['sitemgr_display'] ?$readonlys['sitemgr_display']:'addressbook.display');
$total = parent::get_rows($query,$rows,$readonlys);
$total = parent::get_rows($query,$rows,$readonlys);
$query['template'] = $query['sitemgr_display'].'.rows';
foreach($query['fields'] as $name)
{
$rows['show'][$name]=true;
}
return $total;
}
function display($content=null,$addressbook=null,$fields=null,$msg=null,$email=null,$tpl_name=null,$subject=null)
{
$tpl_name=($tpl_name ? $tpl_name : 'addressbook.display');
$tpl = new etemplate($tpl_name);
$tpl = new etemplate($tpl_name);
$content = array(
'msg' => $msg ? $msg : $_GET['msg'],
);
@ -87,10 +84,10 @@ function get_rows(&$query,&$rows,&$readonlys,$id_only=false)
'no_columnselection' => True,
'csv_fields' => false,
);
$content['nm1']['fields'] = $fields;
}
return $tpl->exec('addressbook.addressbook_display.display',$content,$sel_options,$readonlys,$preserv);
}
}

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

@ -7,11 +7,9 @@
* @package addressbook
* @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$
* @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,11 +33,11 @@ class addressbook_merge // extends bo_merge
*
* @return addressbook_merge
*/
function addressbook_merge()
function __construct()
{
$this->contacts =& new bocontacts();
$this->contacts =& new addressbook_bo();
}
/**
* Return replacements for a contact
*
@ -125,7 +123,7 @@ class addressbook_merge // extends bo_merge
/**
* Return replacements for the calendar (next events) of a contact
*
*
* @param int $contact contact-id
* @param boolean $last_event_too=false also include information about the last event
* @return array
@ -134,7 +132,7 @@ class addressbook_merge // extends bo_merge
{
require_once(EGW_INCLUDE_ROOT.'/calendar/inc/class.bocalupdate.inc.php');
$calendar =& new bocalupdate();
// next events
$events = $calendar->search(array(
'start' => $calendar->now_su,
@ -212,8 +210,8 @@ class addressbook_merge // extends bo_merge
$err = lang('for more then one contact in a document use the tag pagerepeat!');
return false;
}
foreach ($ids as $id)
{
foreach ($ids as $id)
{
if ($contentrepeat) $content = $contentrepeat; //content to repeat
// generate replacements
if (!($replacements = $this->contact_replacements($id)))
@ -230,46 +228,46 @@ class addressbook_merge // extends bo_merge
$replacements += $this->calendar_replacements($id,strpos($content,'$$calendar/-1/') !== null);
}
$replacements['$$date$$'] = date($GLOBALS['egw_info']['user']['preferences']['common']['dateformat'],time()+$this->contacts->tz_offset_s);
if ($this->contacts->prefs['csv_charset']) // if we have an export-charset defined, use it here to
{
$replacements = $GLOBALS['egw']->translation->convert($replacements,$GLOBALS['egw']->translation->charset(),$this->contacts->prefs['csv_charset']);
}
$content = str_replace(array_keys($replacements),array_values($replacements),$content);
if (strpos($content,'$$calendar/') !== null) // remove not existing event-replacements
{
$content = preg_replace('/\$\$calendar\/[0-9]+\/[a-z_]+\$\$/','',$content);
}
$this->replacements = $replacements;
if (strpos($content,'$$IF'))
{ //Example use to use: $$IF n_prefix~Herr~Sehr geehrter~Sehr geehrte$$
$content = preg_replace_callback('/\$\$IF ([0-9a-z_-]+)~(.*)~(.*)~(.*)\$\$/imU',Array($this,'replace_callback'),$content);
}
if ($contentrepeat) $contentrep[$id] = $content;
}
if ($contentrepeat)
if ($contentrepeat)
{
$content = "";
foreach ($contentrep as $idrep => $repvalue)
{
$counter++;
$content .= $repvalue;
if (each($contentrep) != false && count($contentrep) !=1) $content .= "\par \page\pard\plain"; // page break
if (each($contentrep) != false && count($contentrep) !=1) $content .= "\par \page\pard\plain"; // page break
}
$content = $contentstart.$content.$contentend;
}
}
return $content;
}
function replace_callback($param)
{
$replace = preg_match('/'.$param[2].'/',$this->replacements['$$'.$param[1].'$$']) ? $param[3] : $param[4];
return $replace;
}
}
/**
* Download document merged with contact(s)
@ -290,7 +288,7 @@ class addressbook_merge // extends bo_merge
$GLOBALS['egw']->common->egw_exit();
}
/**
* Generate table with replacements for the preferences
*

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$
* @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' => '',
@ -104,11 +103,11 @@ class sifaddressbook extends bocontacts
}
unset($this->sifData);
}
function characterData($_parser, $_data) {
$this->sifData .= $_data;
}
function siftoegw($_sifdata) {
$sifData = base64_decode($_sifdata);
@ -144,7 +143,7 @@ class sifaddressbook extends bocontacts
$finalContact[$key] = '';
}
break;
case 'private':
$finalContact[$key] = (int) ($value > 0); // eGW private is 0 (public) or 1 (private), SIF seems to use 0 and 2
break;
@ -158,24 +157,24 @@ class sifaddressbook extends bocontacts
$this->fixup_contact($finalContact);
return $finalContact;
}
/**
* Search an exactly matching entry (used for slow sync)
*
* @param string $_sifdata
* @return boolean/int/string contact-id or false, if not found
*/
function search($_sifdata)
function search($_sifdata)
{
if(!$contact = $this->siftoegw($_sifdata))
if(!$contact = $this->siftoegw($_sifdata))
{
return false;
}
// patch from Di Guest says: we need to ignore the n_fileas
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'];
@ -194,7 +193,7 @@ class sifaddressbook extends bocontacts
{
#error_log('ABID: '.$_abID);
#error_log(base64_decode($_sifdata));
if(!$contact = $this->siftoegw($_sifdata)) {
return false;
}
@ -232,7 +231,7 @@ class sifaddressbook extends bocontacts
foreach($this->sifMapping as $sifField => $egwField)
{
if(empty($egwField)) continue;
#error_log("$sifField => $egwField");
#error_log('VALUE1: '.$entry[0][$egwField]);
$value = $GLOBALS['egw']->translation->convert($entry[$egwField], $sysCharSet, 'utf-8');
@ -246,19 +245,19 @@ class sifaddressbook extends bocontacts
$value = implode("; ", $this->get_categories($value));
$value = $GLOBALS['egw']->translation->convert($value, $sysCharSet, 'utf-8');
}
$sifContact .= "<$sifField>$value</$sifField>";
$sifContact .= "<$sifField>$value</$sifField>";
break;
case 'Sensitivity':
$value = 2 * $value; // eGW private is 0 (public) or 1 (private)
$sifContact .= "<$sifField>$value</$sifField>";
$sifContact .= "<$sifField>$value</$sifField>";
break;
case 'Folder':
# skip currently. This is the folder where Outlook stores the contact.
#$sifContact .= "<$sifField>/</$sifField>";
break;
default:
$sifContact .= "<$sifField>".trim($value)."</$sifField>";
break;

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

@ -7,11 +7,9 @@
* @package addressbook
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.bo_tracking.inc.php');
/**
* Addressbook - tracking object
*/
@ -56,7 +54,7 @@ class addressbook_tracking extends bo_tracking
var $prefer_user_as_sender = true;
/**
* Instance of the bocontacts class calling us
*
*
* @access private
* @var bocontacts
*/
@ -68,13 +66,13 @@ 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;
}
/**
* Get a notification-config value
*
@ -97,7 +95,7 @@ class addressbook_tracking extends bo_tracking
return split(', ?',$data['email_contactform']);
}
break;
case 'sender':
if ($data['is_contactform'])
{
@ -108,10 +106,10 @@ class addressbook_tracking extends bo_tracking
}
return null;
}
/**
* Get the modified / new message (1. line of mail body) for a given entry, can be reimplemented
*
*
* @param array $data
* @param array $old
* @return string
@ -128,10 +126,10 @@ class addressbook_tracking extends bo_tracking
$GLOBALS['egw']->common->grab_owner_name($data['modifier']),
$this->datetime($data['modified']-$this->tracker->tz_offset_s));
}
/**
* Get the subject of the notification
*
*
* @param array $data
* @param array $old
* @return string
@ -144,10 +142,10 @@ class addressbook_tracking extends bo_tracking
}
return $prefix.$this->contacts->link_title($data);
}
/**
* Get the details of an entry
*
*
* @param array $data
* @param string $datetime_format of user to notify, eg. 'Y-m-d H:i'
* @param int $tz_offset_s offset in sec to be add to server-time to get the user-time of the user to notify

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$
* @version $Id$
*/
require_once(EGW_API_INC.'/class.contacts.inc.php');
/**
* Class to access AND manipulate addressbook data via XMLRPC or SOAP
*
@ -30,14 +30,14 @@ class boaddressbook
* @var contacts
*/
var $contacts;
/**
* Field-mapping for certain user-agents
*
* @var array
*/
var $mapping=array();
/**
* User agent: 'KDE-AddressBook', 'eGWOSync', ...
*
@ -50,7 +50,7 @@ class boaddressbook
*
* @return boaddressbook
*/
function boaddressbook()
function __construct()
{
$this->contacts = $GLOBALS['egw']->contacts;
@ -66,7 +66,7 @@ class boaddressbook
* This handles introspection or discovery by the logged in client,
* in which case the input might be an array. The server always calls
* this function to fill the server dispatch map using a string.
*
*
* @param string/array $_type='xmlrpc' xmlrpc or soap
* @return array
*/
@ -149,8 +149,8 @@ class boaddressbook
/**
* Get field-mapping for user agents expecting old / other field-names
*
* @internal
*
* @internal
*/
function set_mapping_for_user_agent()
{
@ -173,7 +173,7 @@ class boaddressbook
'adr_two_type' => "'Home'",
);
break;
case 'eGWOSync': // no idea what is necessary
break;
}
@ -181,8 +181,8 @@ class boaddressbook
/**
* translate array of internal datas to xmlrpc, eg. format bday as iso8601
*
* @internal
*
* @internal
* @param array $datas array of contact arrays
* @param boolean $read_customfields=false should the customfields be read, default no (contacts::read() does it already)
* @return array
@ -203,7 +203,7 @@ class boaddressbook
foreach($datas as $n => $nul)
{
$data =& $datas[$n]; // $n => &$data is php5 ;-)
if ($customfields && isset($customfields[$data['id']]))
{
foreach($customfields[$data['id']] as $name => $value)
@ -212,7 +212,7 @@ class boaddressbook
}
}
// remove empty or null elements, they dont need to be transfered
$data = array_diff($data,array('',null));
$data = array_diff($data,array('',null));
// translate birthday to a iso8601 date
if(isset($data['bday']) && $data['bday'])
@ -248,11 +248,11 @@ class boaddressbook
case 'grants[owner]':
$data[$to] = $this->contacts->grants[$data['owner']];
break;
case 'private':
$data[$to] = $data['private'] ? 'private' : 'public';
break;
default:
if ($to{0} == "'") // constant value enclosed in single quotes
{
@ -260,7 +260,7 @@ class boaddressbook
}
elseif(isset($data[$from]))
{
if ($to) $data[$to] =& $data[$from];
if ($to) $data[$to] =& $data[$from];
unset($data[$from]);
}
break;
@ -273,8 +273,8 @@ class boaddressbook
/**
* retranslate from xmlrpc / iso8601 to internal format
*
* @internal
*
* @internal
* @param array $data
* @return array
*/
@ -290,7 +290,7 @@ class boaddressbook
case 'private':
$data[$to] = $data['access'] == 'private';
break;
default:
$data[$to] =& $data[$from]; unset($data[$from]);
break;
@ -336,9 +336,9 @@ class boaddressbook
/**
* Search the addressbook
*
*
* Todo: use contacts::search and all it's possebilities instead of the depricated contacts::old_read()
*
*
* @param array $param
* @param int $param['start']=0 starting number of the range, if $param['limit'] != 0
* @param int $param['limit']=0 max. number of entries to return, 0=all
@ -355,7 +355,7 @@ class boaddressbook
function search($param)
{
$read_customfields = !isset($param['customfields']) || $param['customfields'];
$extra_accounts = array();
if ($this->user_agent == 'KDE-AddressBook' && strpos($this->contacts->contact_repository,$this->contacts->account_repository) === false)
{
@ -385,13 +385,13 @@ class boaddressbook
function read($id)
{
if(is_array($id)) $id = isset($id[0]) ? $id[0] : $id['id'];
$data = $this->contacts->read($id);
if($data !== false) // permission denied
{
$data = $this->data2xmlrpc(array($data));
return $data[0];
}
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
@ -408,7 +408,7 @@ class boaddressbook
$data = $this->xmlrpc2data($data);
$id = $this->contacts->save($data);
if($id) return $id;
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
@ -433,7 +433,7 @@ class boaddressbook
/**
* return all addressbook categories
*
*
* @param boolean $complete complete cat-array or just the name
* @param array with cat_id => name or cat_id => cat-array pairs
*/
@ -444,7 +444,7 @@ class boaddressbook
/**
* get or set addressbook customfields
*
*
* @param array $new_fields=null
* @return array
*/

View File

@ -6,9 +6,9 @@
* @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$
* @version $Id$
*/
function contact_repositories($config)
{
$repositories = array('sql' => 'SQL');
@ -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();
@ -68,19 +67,14 @@ function org_fileds_to_update($config)
$fields[$field] = $label;
}
}
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

@ -7,7 +7,7 @@
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
*/
if ($GLOBALS['egw_info']['user']['apps']['addressbook'] &&
($days = $GLOBALS['egw_info']['user']['preferences']['addressbook']['mainscreen_showbirthdays']))
{
@ -15,9 +15,8 @@ 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');
@ -67,7 +66,7 @@ if ($GLOBALS['egw_info']['user']['apps']['addressbook'] &&
if (!$ab_lang_loaded++) $GLOBALS['egw']->translation->add_app('addressbook');
switch($n)
{
case 0:
case 0:
$text = lang("Today is %1's birthday!", $contact['n_given'].' '.$contact['n_family']);
break;
case 1:
@ -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'])
);
}
}
@ -91,7 +90,7 @@ if ($GLOBALS['egw_info']['user']['apps']['addressbook'] &&
{
echo $portalbox->draw();
}
unset($portalbox);
unset($portalbox);
unset($days); unset($day);
unset($n); unset($y); unset($m); unset($d);
}

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

@ -7,31 +7,29 @@
* @package addressbook
* @copyright (c) 2007 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.sitemgr_module.inc.php');
/**
* SiteMgr contact form for the addressbook
*
*/
class module_addressbook_contactform extends sitemgr_module
class module_addressbook_contactform extends sitemgr_module
{
/**
* Constructor
*
* @return module_addressbook_contactform
*/
function module_addressbook_contactform()
function __construct()
{
$this->arguments = array(); // get's set in get_user_interface
$this->title = lang('Contactform');
$this->description = lang('This module displays a contactform, that stores direct into the addressbook.');
$this->etemplate_method = 'addressbook.addressbook_contactform.display';
}
/**
* Reimplemented to add the addressbook translations and fetch the addressbooks only if needed for the user-interface
*
@ -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'),
@ -69,29 +66,29 @@ class module_addressbook_contactform extends sitemgr_module
'sep4' => '----------------------------',
'note' => lang('message'),
'sep5' => '----------------------------',
'captcha' => lang('Verification'),
'captcha' => lang('Verification'),
);
$this->arguments = array(
'arg1' => array(
'type' => 'select',
'type' => 'select',
'label' => lang('Addressbook the contact should be saved to').' ('.lang('The anonymous user needs add rights for it!').')',
'options' => array(
'' => lang('None'),
)+$uicontacts->get_addressbooks(EGW_ACL_ADD) // add to not show the accounts!
),
'arg4' => array(
'type' => 'textfield',
'type' => 'textfield',
'label' => lang('Email addresses (comma separated) to send the contact data'),
'params' => array('size' => 80),
),
'arg6' => array(
'type' => 'textfield',
'type' => 'textfield',
'label' => lang('Subject for email'),
'params' => array('size' => 80),
'default' => lang('Contactform'),
),
'arg2' => array(
'type' => 'select',
'type' => 'select',
'label' => lang('Contact fields to show'),
'multiple' => true,
'options' => $fields,
@ -99,18 +96,18 @@ class module_addressbook_contactform extends sitemgr_module
'params' => array('size' => 9),
),
'arg3' => array(
'type' => 'textfield',
'type' => 'textfield',
'label' => lang('Message after submitting the form'),
'params' => array('size' => 80),
'default' => lang('Thank you for contacting us.'),
),
'arg5' => array(
'type' => 'textfield',
'type' => 'textfield',
'label' => lang('Custom eTemplate for the contactform'),
'params' => array('size' => 40),
'default' => 'addressbook.contactform',
),
);
);
return parent::get_user_interface();
}
}

View File

@ -7,31 +7,28 @@
* @package addressbook
* @copyright (c) 2008 by stefan Becker <StefanBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id: class.module_addressbook_display.inc.php 24028 2008-02-18 09:04:36Z stefanbecker $
* @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
class module_addressbook_display extends sitemgr_module
{
/**
* Constructor
*
* @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');
$this->description = lang('This module displays Block from a Adddressbook Group.');
$this->etemplate_method = 'addressbook.addressbook_display.display';
}
/**
* Reimplemented to add the addressbook translations and fetch the addressbooks only if needed for the user-interface
*
@ -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'),
@ -65,17 +61,17 @@ class module_addressbook_display extends sitemgr_module
{
$fields['#'.$name] = $data['label'];
}
$this->arguments = array(
'arg1' => array(
'type' => 'select',
'type' => 'select',
'label' => lang('Addressbook the contact should be shown').' ('.lang('The anonymous user needs read it!').')',
'options' => array(
'' => lang('All'),
)+$uicontacts->get_addressbooks(EGW_ACL_ADD) // add to not show the accounts!
),
'arg2' => array(
'type' => 'select',
'type' => 'select',
'label' => lang('Contact fields to show'),
'multiple' => true,
'options' => $fields,
@ -83,12 +79,12 @@ class module_addressbook_display extends sitemgr_module
'params' => array('size' => 9),
),
'arg5' => array(
'type' => 'textfield',
'type' => 'textfield',
'label' => lang('Custom eTemplate for the contactform'),
'params' => array('size' => 40),
'default' => 'addressbook.display',
),
);
);
return parent::get_user_interface();
}
}

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>