removed no longer needed old classes

This commit is contained in:
Ralf Becker 2006-09-20 04:39:21 +00:00
parent acd9ac7777
commit e376d27008
9 changed files with 0 additions and 4512 deletions

View File

@ -1,399 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Miles Lott <milos@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class boXport
{
var $public_functions = array(
'import' => True,
'export' => True
);
var $so;
var $contacts;
var $start;
var $limit;
var $query;
var $sort;
var $order;
var $filter;
var $cat_id;
var $use_session = False;
var $debug = False;
function boXport($session=False)
{
$this->contacts = &$GLOBALS['egw']->contacts;
$this->so = CreateObject('addressbook.soaddressbook');
if($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
$_start = get_var('_start',array('POST','GET'));
$_query = get_var('_query',array('POST','GET'));
$_sort = get_var('_sort',array('POST','GET'));
$_order = get_var('_order',array('POST','GET'));
$_filter = get_var('_filter',array('POST','GET'));
$_cat_id = get_var('_cat_id',array('POST','GET'));
$_fcat_id = get_var('_fcat_id',array('POST','GET'));
if(!empty($_start) || ($_start == '0') || ($_start == 0))
{
if($this->debug) { echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"'; }
$this->start = $_start;
}
if($_limit)
{
$this->limit = $_limit;
}
if((empty($_query) && !empty($this->query)) || !empty($_query))
{
$this->query = $_query;
}
if(isset($_POST['fcat_id']) || isset($_POST['fcat_id']))
{
$this->cat_id = $_fcat_id;
}
else
{
$this->cat_id = -1;
}
if(isset($_sort) && !empty($_sort))
{
if($this->debug) { echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"'; }
$this->sort = $_sort;
}
if(isset($_order) && !empty($_order))
{
if($this->debug) { echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"'; }
$this->order = $_order;
}
if(isset($_filter) && !empty($_filter))
{
if($this->debug) { echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"'; }
$this->filter = $_filter;
}
}
function save_sessiondata($data)
{
if($this->use_session)
{
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
$GLOBALS['egw']->session->appsession('session_data','addressbook',$data);
}
}
function read_sessiondata()
{
$data = $GLOBALS['egw']->session->appsession('session_data','addressbook');
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$this->start = $data['start'];
$this->limit = $data['limit'];
$this->query = $data['query'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->filter = $data['filter'];
$this->cat_id = $data['cat_id'];
if($this->debug) { echo '<br>read_sessiondata();'; $this->_debug_sqsof(); }
}
function import($tsvfile,$conv_type,$private,$fcat_id)
{
if($conv_type == 'none')
{
return False;
}
include(PHPGW_APP_INC . '/import/' . $conv_type);
if($private == '')
{
$private = 'public';
}
$row = 0;
$buffer = array();
$contacts = new import_conv;
$buffer = $contacts->import_start_file($buffer);
if($tsvfile['type'] == 'application/zip')
{
if(!@function_exists('zip_open'))
{
return False;
}
$fp = $this->unzip($tsvfile['tmp_name'],$contacts->type);
}
else
{
$fp = fopen($tsvfile['tmp_name'],'r');
}
if($contacts->type == 'csv')
{
while($data = fgetcsv($fp,8000,','))
{
$num = count($data);
$row++;
if($row == 1)
{
$header = $data;
/* Changed here to ignore the header, set to our array
while(list($lhs,$rhs) = each($contacts->import))
{
$header[] = $lhs;
}
*/
}
else
{
$buffer = $contacts->import_start_record($buffer);
for($c=0; $c<$num; $c++ )
{
//Send name/value pairs along with the buffer
if($contacts->import[$header[$c]] != '' && $data[$c] != '')
{
$buffer = $contacts->import_new_attrib($buffer, $contacts->import[$header[$c]],$data[$c]);
}
}
$buffer = $contacts->import_end_record($buffer,$private);
}
}
}
elseif($contacts->type == 'ldif')
{
while($data = fgets($fp,8000))
{
$url = '';
list($name,$value,$extra) = split(':', $data);
$name = strtolower($name);
if(substr($name,0,2) == 'dn')
{
$buffer = $contacts->import_start_record($buffer);
}
$test = trim($value);
if($name && !empty($test) && $extra)
{
// Probable url string
$url = $test;
$value = $extra;
}
elseif($name && empty($test) && $extra)
{
// Probable multiline encoding
$newval = base64_decode(trim($extra));
$value = $newval;
//echo $name.':'.$value;
}
if($name && $value)
{
$test = split(',mail=',$value);
if($test[1])
{
$name = 'mail';
$value = $test[1];
}
if($url)
{
$name = 'homeurl';
$value = $url. ':' . $value;
}
//echo '<br>'.$j.': '.$name.' => '.$value;
if($contacts->import[$name] != '' && $value != '')
{
$buffer = $contacts->import_new_attrib($buffer, $contacts->import[$name],$value);
}
}
else
{
$buffer = $contacts->import_end_record($buffer,$private);
}
}
}
else
{
$needToCallEndRecord = 0;
while($data = fgets($fp,8000))
{
$data = trim($data);
// RB 2001/05/07 added for Lotus Organizer
while(substr($data,-1) == '=')
{
// '=' at end-of-line --> line to be continued with next line
$data = substr($data,0,-1) . trim(fgets($fp,8000));
}
if(strstr($data,';ENCODING=QUOTED-PRINTABLE'))
{
// RB 2001/05/07 added for Lotus Organizer
$data = quoted_printable_decode(str_replace(';ENCODING=QUOTED-PRINTABLE','',$data));
}
list($name,$value) = explode(':', $data,2); // RB 2001/05/09 to allow ':' in Values (not only in URL's)
if(strtolower(substr($name,0,5)) == 'begin')
{
$buffer = $contacts->import_start_record($buffer);
$needToCallEndRecord = 1;
}
if($name && $value)
{
reset($contacts->import);
while(list($fname,$fvalue) = each($contacts->import))
{
if(strstr(strtolower($name), $contacts->import[$fname]))
{
$buffer = $contacts->import_new_attrib($buffer,$name,$value);
}
}
}
else
{
$buffer = $contacts->import_end_record($buffer);
$needToCallEndRecord = 0;
}
}
if($needToCallEndRecord)
{
$buffer = $contacts->import_end_record($buffer);
}
}
fclose($fp);
$buffer = $contacts->import_end_file($buffer,$private,$fcat_id);
return $buffer;
}
/* Use the Zip extension to open a zip file, hopefully containing multiple .vcf files
* Return a pointer to a temporary file that will then contain all files concatenated.
*/
function unzip($filename,$type)
{
$ext = '';
switch($type)
{
case 'vcard':
$ext = '.vcf';
break;
case 'csv':
$ext = '.csv';
break;
case 'ldif':
$ext = '.ldif';
break;
default:
return False;
}
/* Open the (uploaded) zip file */
$zip = zip_open($filename);
$temp = tempnam('/tmp','zip2contact');
/* Open a temp file for read/write */
$fp = fopen($temp, 'w+');
$out = '';
/* Now read each entry in the zip file */
while($dirent = zip_read($zip))
{
if(zip_entry_open($zip,$dirent,'r'))
{
//echo '<br>zip_entry_name==' . zip_entry_name($dirent);
/* If an allowed extenstion based on conversion type */
if(strstr(zip_entry_name($dirent),$ext))
{
/* Write the data to our temp file */
$data = zip_entry_read($dirent,zip_entry_filesize($dirent));
//echo $data;
fwrite($fp,$data);
}
zip_entry_close($dirent);
}
}
/* Close the zip file resource handle */
zip_close($zip);
/* Set the file pointer of our new file to the beginning for use by the import routines */
rewind($fp);
return $fp;
}
function export($conv_type,$cat_id='')
{
if($conv_type == 'none')
{
return False;
}
include(PHPGW_APP_INC . '/export/' . $conv_type);
$buffer = array();
$contacts = new export_conv;
// Read in user custom fields, if any
$customfields = array();
while(list($col,$descr) = @each($GLOBALS['egw_info']['user']['preferences']['addressbook']))
{
if(substr($col,0,6) == 'extra_')
{
$field = str_replace('extra_','',$col);
$field = str_replace(' ','_',$field);
$customfields[$field] = ucfirst($field);
}
}
$extrafields = array(
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
);
if($contacts->type != 'vcard')
{
$contacts->qfields = $contacts->stock_contact_fields;# + $extrafields;# + $customfields;
}
if(!empty($cat_id))
{
$buffer = $contacts->export_start_file($buffer,$cat_id);
}
else
{
$buffer = $contacts->export_start_file($buffer);
}
for($i=0;$i<count($contacts->ids);$i++)
{
$buffer = $contacts->export_start_record($buffer);
while(list($name,$value) = each($contacts->currentrecord))
{
$buffer = $contacts->export_new_attrib($buffer,$name,$value);
}
$buffer = $contacts->export_end_record($buffer);
}
// Here, buffer becomes a string suitable for printing
$buffer = $contacts->export_end_file($buffer);
$tsvfilename = $GLOBALS['egw_info']['server']['temp_dir'] . SEP . $tsvfilename;
return $buffer;
}
}
?>

View File

@ -1,793 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org *
* and Miles Lott <milos@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class boaddressbook
{
var $public_functions = array(
'read_entries' => True,
'read_entry' => True,
'read_last_entry' => True,
'add_entry' => True,
'add_vcard' => True,
'add_email' => True,
'update_entry' => True,
'delete_entry' => True
);
var $xml_functions = array();
var $xmlrpc_methods = array();
var $soap_functions = array(
'read_entries' => array(
'in' => array('int','int','struct','string','int'),
'out' => array('array')
),
'read_entry' => array(
'in' => array('int','struct'),
'out' => array('array')
),
'read_last_entry' => array(
'in' => array('struct'),
'out' => array('array')
),
'add_entry' => array(
'in' => array('int','struct'),
'out' => array()
),
'update_entry' => array(
'in' => array('int','struct'),
'out' => array()
),
'categories' => array(
'in' => array('bool'),
'out' => array('struct')
),
'customfields' => array(
'in' => array('array'),
'out'=> array('struct')
)
);
var $debug = False;
var $so;
var $start;
var $limit;
var $query;
var $sort;
var $order;
var $filter;
var $cat_id;
var $total;
var $contact_cache = array();
var $use_session = False;
function boaddressbook($session=False)
{
$this->so = CreateObject('addressbook.soaddressbook');
// make some fields of the contacts-object availible
$this->grants = &$this->so->grants;
$this->stock_contact_fields = &$this->so->contacts->stock_contact_fields;
$this->tel_types = &$this->so->contacts->tel_types;
$this->email_types = &$this->so->contacts->email_types;
$this->adr_types = &$this->so->contacts->adr_types;
if($session)
{
$this->read_sessiondata();
$this->use_session = True;
}
// are we called via xmlrpc?
$this->xmlrpc = is_object($GLOBALS['server']) && $GLOBALS['server']->last_method;
//_debug_array($_POST);
$_start = get_var('start',array('POST','GET'));
$_query = get_var('query',array('POST','GET'),'_UNSET_');
$_cquery = get_var('cquery', array('GET','POST'),'_UNSET_');
$_sort = get_var('sort',array('POST','GET'));
$_order = get_var('order',array('POST','GET'));
$_filter = get_var('filter',array('POST','GET'));
// $_cat_id = get_var('cat_id',array('POST','GET'));
$_fcat_id = get_var('fcat_id',array('POST','GET'));
$_typeid = get_var('typeid',array('POST','GET'),'_UNSET_');
if(!empty($_start) || ($_start == '0') || ($_start == 0))
{
if($this->debug) { echo '<br>overriding $start: "' . $this->start . '" now "' . $_start . '"'; }
$this->start = $_start;
}
if($_limit)
{
$this->limit = $_limit;
}
if($_query != '_UNSET_')
{
$this->query = $_query;
}
if($_cquery != '_UNSET_')
{
$this->cquery = $_cquery;
}
if($_typeid != '_UNSET_')
{
$this->typeid = $_typeid;
}
/*
if(!@in_array($this->typeid,array('n','c')))
{
$this->typeid = 'n';
}
*/
if(isset($_POST['fcat_id']) || isset($_POST['fcat_id']))
{
$this->cat_id = $_fcat_id;
}
else
{
$this->cat_id = -1;
}
/*
if(isset($_POST['typeid']) || isset($_POST['typeid']))
{
$this->typeid = $typeid;
}
else
{
$this->typeid = 'n';
}
*/
if(isset($_sort) && !empty($_sort))
{
if($this->debug) { echo '<br>overriding $sort: "' . $this->sort . '" now "' . $_sort . '"'; }
$this->sort = $_sort;
}
if(isset($_order) && !empty($_order))
{
if($this->debug) { echo '<br>overriding $order: "' . $this->order . '" now "' . $_order . '"'; }
$this->order = $_order;
}
if(isset($_filter) && !empty($_filter))
{
if($this->debug) { echo '<br>overriding $filter: "' . $this->filter . '" now "' . $_filter . '"'; }
$this->filter = $_filter;
}
if($this->debug) { $this->_debug_sqsof(); }
}
function _debug_sqsof()
{
$data = array(
'start' => $this->start,
'limit' => $this->limit,
'query' => $this->query,
'cquery' => $this->cquery,
'sort' => $this->sort,
'order' => $this->order,
'filter' => $this->filter,
'cat_id' => $this->cat_id,
'typeid' => $this->typeid
);
echo '<br>BO:';
_debug_array($data);
}
function save_sessiondata($data)
{
if($this->use_session)
{
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
$GLOBALS['egw']->session->appsession('session_data','addressbook',$data);
}
}
function read_sessiondata()
{
$data = $GLOBALS['egw']->session->appsession('session_data','addressbook');
if($this->debug) { echo '<br>Read:'; _debug_array($data); }
$this->start = $data['start'];
$this->limit = $data['limit'];
$this->query = $data['query'];
$this->cquery = $data['cquery'];
$this->sort = $data['sort'];
$this->order = $data['order'];
$this->filter = $data['filter'];
$this->cat_id = $data['cat_id'];
$this->typeid = $data['typeid'];
if($this->debug) { echo '<br>read_sessiondata();'; $this->_debug_sqsof(); }
}
function strip_html($dirty='')
{
if($dirty == '')
{
$dirty = array();
}
for($i=0;$i<count($dirty);$i++)
{
if(@is_array($dirty[$i]))
{
foreach($dirty[$i] as $name => $value)
{
$cleaned[$i][$name] = $GLOBALS['egw']->strip_html($dirty[$i][$name]);
}
}
else
{
$cleaned[$i] == $GLOBALS['egw']->strip_html($dirty[$i]);
}
}
return $cleaned;
}
// return array with all addressbook categories (for xmlrpc)
function categories($complete = False)
{
return $this->xmlrpc ? $GLOBALS['server']->categories($complete) : False;
}
// return array with all addressbook customfields (for xmlrpc)
function customfields($new_fields=False)
{
$fields = CreateObject('addressbook.bofields');
if(is_array($new_fields) && count($new_fields))
{
if(!$GLOBALS['egw_info']['user']['apps']['admin'])
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
}
foreach($new_fields as $new)
{
$fields->_save('',$new);
}
}
$customfields = array();
foreach($fields->_read() as $data)
{
$customfields[$data['name']] = $data['title'];
}
if($this->xmlrpc && !isset($customfields['freebusy_url']))
{
$fields->_save('','freebusy URL');
$customfields['freebusy_url'] = 'freebusy URL';
}
return $customfields;
}
// translate array of internal datas to xmlrpc, eg. format bday as iso8601
function data2xmlrpc($datas)
{
if(is_array($datas))
{
foreach($datas as $n => $data)
{
// translate birthday to a iso8601 date
if(isset($data['bday']))
{
if(strlen($data['bday']) > 2)
{
list($m,$d,$y) = explode('/',$data['bday']);
}
else
{
$y = $m = $d = 0;
}
$datas[$n]['bday'] = $GLOBALS['server']->date2iso8601(array('year'=>$y,'month'=>$m,'mday'=>$d));
}
// translate modification time
if(isset($data['last_mod']))
{
$datas[$n]['last_mod'] = $GLOBALS['server']->date2iso8601($data['last_mod']);
}
// translate categories-id-list to array with id-name pairs
if(isset($data['cat_id']))
{
$datas[$n]['cat_id'] = $GLOBALS['server']->cats2xmlrpc(explode(',',$data['cat_id']));
}
}
}
return $datas;
}
// retranslate from xmlrpc / iso8601 to internal format
function xmlrpc2data($data)
{
if(isset($data['bday']))
{
$arr = $GLOBALS['server']->iso86012date($data['bday']);
$data['bday'] = $arr['year'] && $arr['month'] && $arr['mday'] ? sprintf('%d/%02d/%04d',$arr['month'],$arr['mday'],$arr['year']) : '';
}
if(isset($data['last_mod']))
{
$data['last_mod'] = $GLOBALS['server']->iso86012date($data['last_mod'],True);
}
if(isset($data['cat_id']))
{
$cats = $GLOBALS['server']->xmlrpc2cats($data['cat_id']);
$data['cat_id'] = count($cats) > 1 ? ','.implode(',',$cats).',' : (int)$cats[0];
}
return $data;
}
// return a pseudo addressbook-entry for a user
function user_pseudo_entry($account)
{
static $prefs=False;
if(!is_object($prefs))
{
$prefs = CreateObject('phpgwapi.preferences'); // wie need a new copy, as wie change the user
}
if(!is_array($account))
{
$GLOBALS['egw']->accounts->account_id = $account;
$account = $GLOBALS['egw']->accounts->read_repository();
}
$prefs->account_id = $account['account_id'];
$prefs->read_repository();
$freebusy_url = $GLOBALS['egw_info']['server']['webserver_url'].'/calendar/freebusy.php?user='.$account['account_lid'];
if($freebusy_url[0] == '/')
{
$freebusy_url = ($_SERVER['HTTPS'] ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$freebusy_url;
}
$firstname = $account['account_firstname'] ? $account['account_firstname'] : $account['firstname'];
$lastname = $account['account_lastname'] ? $account['account_lastname'] : $account['lastname'];
$ret = array(
'n_family' => $lastname,
'n_given' => $firstname,
'fn' => $GLOBALS['egw']->common->display_fullname($account['account_lid'],$firstname,$lastname),
'email' => $prefs->email_address($account['account_id']),
'freebusy_url' => $freebusy_url,
'rights' => PHPGW_ACL_READ, // readonly access
'id' => -$account['account_id'],
'tid' => 'p', // Profil
);
//echo "<p>user_pseudo_entry(".print_r($account,True).")=".print_r($ret,True)."</p>";
return $ret;
}
function get_users($type='all')
{
$users = array();
switch($type)
{
case 'all': // all
$accounts = $GLOBALS['egw']->accounts->get_list('accounts');
break;
case 'calendar': // Calendar users
$accounts = $GLOBALS['egw']->acl->get_ids_for_location('run',1,'calendar');
break;
case 'groupmates': // Groupmates
$accounts = array();
foreach($GLOBALS['egw']->accounts->membership() as $group)
{
$accounts[] = $group['account_id'];
}
break;
}
foreach($accounts as $key => $account)
{
if($type == 'calendar' && $GLOBALS['egw']->accounts->get_type($account) == 'g' || $type == 'groupmates')
{
// $account is a group
unset($accounts[$key]);
$members = $GLOBALS['egw']->accounts->member($account);
if(is_array($members))
{
foreach($members as $member)
{
$accounts[] = $member['account_id'];
}
}
}
}
if($type != 'all')
{
$accounts = array_unique($accounts); // remove doubles
}
$prefs = CreateObject('phpgwapi.preferences'); // wie need a new copy, as wie change the user
foreach($accounts as $account)
{
$users[] = $this->user_pseudo_entry($account);
}
return $users;
}
function read_entries($data)
{
if($this->xmlrpc && !isset($data['fields']))
{
$data['fields'] = array_keys(array_merge($this->so->contacts->non_contact_fields,$this->so->contacts->stock_contact_fields,$this->customfields()));
}
$entries = $this->so->read_entries($data);
$this->total = $this->so->contacts->total_records;
if(!is_array($entries))
{
$entries = array();
}
$entries = $this->strip_html($entries);
// evtl. get uses as read-only addressbook entries, just with Name, Firstname, Email
if(@$data['include_users'])
{
$entries = array_merge($entries,$this->get_users($data['include_users']));
}
if($this->xmlrpc)
{
$entries = $this->data2xmlrpc($entries);
}
if($this->debug) { echo '<br>Total records="' . $this->total . '"'; }
return $entries;
}
function read_entry($data)
{
if($this->xmlrpc && !isset($data['fields']))
{
$data['fields'] = array_keys(array_merge($this->so->contacts->non_contact_fields,$this->so->contacts->stock_contact_fields,$this->customfields()));
}
if($data['id'] < 0)
{
$entry = array($this->user_pseudo_entry(-$data['id']));
if($this->xmlrpc)
{
$entry = $this->data2xmlrpc($entry);
}
return $entry;
}
if($this->check_perms($data,PHPGW_ACL_READ))
{
$entry = $this->so->read_entry($data['id'],$data['fields']);
$entry = $this->strip_html($entry);
if($this->xmlrpc)
{
$entry = $this->data2xmlrpc($entry);
}
return $entry;
}
if($this->xmlrpc)
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
}
return False;
}
function read_last_entry($fields)
{
if($this->check_perms($fields,PHPGW_ACL_READ))
{
$entry = $this->so->read_last_entry($fields);
$entry = $this->strip_html($entry);
if($this->xmlrpc)
{
$entry = $this->data2xmlrpc($entry);
}
return $entry;
}
if($this->xmlrpc)
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
}
return False;
}
function add_vcard($uploadedfile='')
{
if($uploadedfile == 'none' || $uploadedfile == '' || substr($uploadedfile['name'],-4) != '.vcf')
{
return False;
}
else
{
$filename = $uploadedfile['tmp_name'];
$vcard = CreateObject('phpgwapi.vcard');
$entry = $vcard->in_file($filename);
/* _debug_array($entry);exit; */
$entry['owner'] = (int)$GLOBALS['egw_info']['user']['account_id'];
$entry['access'] = 'private';
$entry['tid'] = 'n';
/* _debug_array($entry);exit; */
$this->so->add_entry($entry);
$ab_id = $this->get_lastid();
return(int)$ab_id;
}
}
function add_email()
{
global $name,$referer;
$named = explode(' ', $name);
for($i=count($named);$i>=0;$i--) { $names[$i] = $named[$i]; }
if($names[2])
{
$fields['n_given'] = $names[0];
$fields['n_middle'] = $names[1];
$fields['n_family'] = $names[2];
}
else
{
$fields['n_given'] = $names[0];
$fields['n_family'] = $names[1];
}
$fields['email'] = $add_email;
$referer = urlencode($referer);
$this->so->add_entry($GLOBALS['egw_info']['user']['account_id'],$fields,'private','','n');
$ab_id = $this->get_lastid();
Header('Location: '
. $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer"));
}
function add_entry($fields)
{
// setting some defaults, if not set eg. via xmlrpc
$fields['tid'] = trim($fields['tid']);
if(empty($fields['tid']))
{
$fields['tid'] = 'n';
}
if(!@$fields['owner'])
{
$fields['owner'] = (int)$GLOBALS['egw_info']['user']['account_id'];
}
if(empty($fields['access']))
{
$fields['access'] = 'public';
}
if($this->xmlrpc)
{
$fields = $this->xmlrpc2data($fields);
}
$id = $this->so->add_entry($fields);
if($id)
{
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'add', time());
}
if($this->xmlrpc && !$id)
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
}
return $id;
}
function get_lastid()
{
return $this->so->get_lastid();
}
function update_entry($fields)
{
if(!$fields['id'] && !$fields['ab_id'])
{
return $this->add_entry($fields);
}
$ok = False;
if($this->check_perms($fields,PHPGW_ACL_EDIT))
{
if($this->xmlrpc)
{
$fields = $this->xmlrpc2data($fields);
}
$ok = $this->so->update_entry($fields);
if($ok)
{
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $fields['ab_id'], 'modify', time());
}
}
if($this->xmlrpc && !$ok)
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
}
return $ok;
}
function delete_entry($addr)
{
if(!is_array($addr))
{
$id = (int)$addr;
}
else
{
if(is_numeric($addr[0])) // xmlrpc liefert array($id)
{
$id = (int)$addr[0];
}
else
{
$id = isset($addr['id']) ? $addr['id'] : $addr['ab_id'];
}
}
if($this->check_perms($id,PHPGW_ACL_DELETE))
{
$this->so->delete_entry($id);
$GLOBALS['egw']->contenthistory->updateTimeStamp('contacts', $id, 'delete', time());
}
elseif($this->xmlrpc)
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['no_access'],$GLOBALS['xmlrpcstr']['no_access']);
}
}
/*!
@function check_perms
@abstract checks if user has the necessary rights on the given address or address-id
@syntax check_perms($addr,$rights)
@param $addr mixed address-record with id and owner or addr-id
@param $rights integer PHPGW_ACL_{READ|EDIT|ADD|DELETE}
@return True if the user has the requested rights, else False
*/
function check_perms($addr,$rights)
{
$id = (int) (!is_array($addr) ? $addr : (isset($addr['id']) ? $addr['id'] : $addr['ab_id']));
if($id < 0)
{
return $rights == PHPGW_ACL_READ;
}
if(!is_array($addr) || !isset($addr['rights']) && !isset($addr['owner']))
{
$addr = $this->so->read_entry($id,array('owner'));
if(!$addr && $this->xmlrpc)
{
$GLOBALS['server']->xmlrpc_error($GLOBALS['xmlrpcerr']['not_exist'],$GLOBALS['xmlrpcstr']['not_exist']);
}
$addr = $addr[0];
}
$ret = $this->so->contacts->check_perms(False,$rights,$addr);
//echo "<p>boaddressbook::check_perms(".print_r($addr,True).",$rights) = ".($ret?'True':'False')."</p>\n";
return $ret;
}
function save_preferences($prefs,$other,$qfields,$fcat_id)
{
$GLOBALS['egw']->preferences->read_repository();
if(is_array($prefs))
{
/* _debug_array($prefs);exit; */
while(list($pref,$x) = each($qfields))
{
/* echo '<br>checking: ' . $pref . '=' . $prefs[$pref]; */
if($prefs[$pref] == 'on')
{
$GLOBALS['egw']->preferences->add('addressbook',$pref,'addressbook_on');
}
else
{
$GLOBALS['egw']->preferences->delete('addressbook',$pref);
}
}
}
if(is_array($other))
{
$GLOBALS['egw']->preferences->delete('addressbook','mainscreen_showbirthdays');
if($other['mainscreen_showbirthdays'])
{
$GLOBALS['egw']->preferences->add('addressbook','mainscreen_showbirthdays',True);
}
$GLOBALS['egw']->preferences->delete('addressbook','default_filter');
if($other['default_filter'])
{
$GLOBALS['egw']->preferences->add('addressbook','default_filter',$other['default_filter']);
}
$GLOBALS['egw']->preferences->delete('addressbook','autosave_category');
if($other['autosave_category'])
{
$GLOBALS['egw']->preferences->add('addressbook','autosave_category',True);
}
}
$GLOBALS['egw']->preferences->delete('addressbook','default_category');
$GLOBALS['egw']->preferences->add('addressbook','default_category',$fcat_id);
$GLOBALS['egw']->preferences->save_repository(True);
}
function list_methods($_type='xmlrpc')
{
/*
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.
*/
if(is_array($_type))
{
$_type = $_type['type'] ? $_type['type'] : $_type[0];
}
switch($_type)
{
case 'xmlrpc':
$xml_functions = array(
'read' => array(
'function' => 'read_entry',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Read a single entry by passing the id and fieldlist.')
),
'add' => array(
'function' => 'add_entry',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Add a single entry by passing the fields.')
),
'save' => array(
'function' => 'update_entry',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Update a single entry by passing the fields.')
),
'write' => array( // alias for consistent nameing
'function' => 'update_entry',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Write (update or add) a single entry by passing the fields.')
),
'delete' => array(
'function' => 'delete_entry',
'signature' => array(array(xmlrpcString,xmlrpcString)),
'docstring' => lang('Delete a single entry by passing the id.')
),
'read_list' => array(
'function' => 'read_entries',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Read a list / search for entries.')
),
'search' => array( // alias for consitent nameing
'function' => 'read_entries',
'signature' => array(array(xmlrpcStruct,xmlrpcStruct)),
'docstring' => lang('Read a list / search for entries.')
),
'categories' => array(
'function' => 'categories',
'signature' => array(array(xmlrpcBoolean,xmlrpcBoolean)),
'docstring' => lang('List all categories')
),
'customfields' => array(
'function' => 'customfields',
'signature' => array(array(xmlrpcArray,xmlrpcArray)),
'docstring' => lang('List all customfields')
),
'list_methods' => array(
'function' => 'list_methods',
'signature' => array(array(xmlrpcStruct,xmlrpcString)),
'docstring' => lang('Read this list of methods.')
)
);
return $xml_functions;
break;
case 'soap':
return $this->soap_functions;
break;
default:
return array();
break;
}
}
}
?>

View File

@ -1,102 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> and *
* Miles Lott <milosch@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class bofields
{
var $so;
function bofields()
{
/* Config class here is the so object */
$this->so = CreateObject('phpgwapi.config','addressbook');
}
function _read($start=0,$limit=5,$query='')
{
$i = 0;
$fields = array();
$this->so->read_repository();
$config_name = isset($this->so->config_data['customfields']) ? 'customfields' : 'custom_fields';
while(list($name,$descr) = @each($this->so->config_data[$config_name]))
{
if(is_array($descr))
{
$descr = $descr['label'];
}
/*
if($start < $i)
{
continue;
}
*/
$test = @strtolower($name);
//if($query && !strstr($test,strtolower($query)))
if($query && ($query != $test))
{
}
else
{
$fields[$i]['name'] = $name;
$fields[$i]['title'] = $descr;
$fields[$i]['id'] = $i;
/*
if($i >= $limit)
{
break;
}
*/
$i++;
}
}
switch($sort)
{
case 'DESC';
krsort($fields);
break;
case 'ASC':
default:
ksort($fields);
}
@reset($fields);
return $fields;
}
function _save($old='',$new='')
{
$this->so->read_repository();
if(!is_array($this->so->config_data['custom_fields']))
{
$this->so->config_data['custom_fields'] = array();
}
if($old)
{
unset($this->so->config_data['custom_fields'][$old]);
}
if($new)
{
$tmp = strtolower(str_replace(' ','_',$new));
$this->so->config_data['custom_fields'][$tmp] = $new;
}
$this->so->save_repository();
}
}
?>

View File

@ -1,284 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare API - Palm Database Access *
* This file written by Miles Lott <milos@groupwhere.org> *
* Access to palm OS database structures (?) *
* ------------------------------------------------------------------------ *
* Portions of code from ToPTIP *
* Copyright (C) 2000-2001 Pierre Dittgen *
* This file is a translation of the txt2pdbdoc tool *
* written in C Paul J. Lucas (plj@best.com) *
* ------------------------------------------------------------------------ *
* This library may be part of the eGroupWare API *
* ------------------------------------------------------------------------ *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, *
* or any later version. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
/* $Id$ */
// ONLY THE FETCH FUNCTION SHOULD BE CALLED AT THIS TIME:
// $pdb = CreateObject('addressbook.pdb');
// $pdb->fetch($content, $title, $document);
//
// This will force a download of the pdb file.
//
// READ DOES NOT WORK
// FORMAT OF FILE IS A DOC, NOT A TRUE PALM ADDRESS BOOK
class pdb
{
var $record_size = 4096; // Size of text record
var $pdb_header_size = 78; // Size of the file header (don't touch!)
var $pdb_record_header_size = 8; // Size of a text record header (don't touch either!)
/**
* Convert a integer value to a two bytes value string
*/
function int2($value)
{
return sprintf("%c%c", $value / 256, $value % 256);
}
/**
* Convert a integer value to a four bytes value string
*/
function int4($value)
{
for($i=0; $i<4; $i++)
{
$b[$i] = $value % 256;
$value = (int)(($value - $b[$i]) / 256);
}
return sprintf("%c%c%c%c", $b[3], $b[2], $b[1], $b[0]);
}
/**
* Writes the header of the pdb file containing the title of the document
* and different parameters including its size
*/
function write_header($fd, $title, $content_length)
{
// ============ File header =========================================
// Title of the document, it's limited to 31 characters
if(strlen($title) > 31)
{
$title = substr($title, 0, 31);
}
fwrite($fd, $title);
// Completion with null '\0' characters
for($i=0; $i<32-strlen($title); $i++)
{
fwrite($fd, sprintf("%c", 0), 1);
}
// attributes & version fields
fwrite($fd, $this->int2(0));
fwrite($fd, $this->int2(0));
// create & modify time
fwrite($fd, sprintf("%c%c%c%c", 6, 209, 68, 174), 4);
fwrite($fd, sprintf("%c%c%c%c", 6, 209, 68, 174), 4);
// backup time, modification number, app Info Id, sort info Id
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
// Type & creator
fwrite($fd, 'TEXt', 4);
fwrite($fd, 'REAd', 4);
// Id seed & next record list
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
// Number of text records
$full_tr = (int)($content_length / $this->record_size);
$notfull_tr = $content_length % $this->record_size;
$num_records = $full_tr;
if($notfull_tr != 0)
{
$num_records++;
}
// + 1 cause of record 0
fwrite($fd, $this->int2($num_records + 1));
// From here...
$num_offsets = $num_records + 1;
$offset = $this->pdb_header_size + $this->pdb_record_header_size * $num_offsets;
$index = 0x40 << 24 | 0x6F8000; // Why not!
fwrite($fd, $this->int4($offset));
fwrite($fd, $this->int4($index++));
$val = 110 + ($num_offsets - 2) * 8;
while(--$num_offsets != 0)
{
fwrite($fd, $this->int4($val));
$val += 4096;
fwrite($fd, $this->int4($index++));
}
// To here
// Don't ask me how it works ;-)
// ====== Write record 0 ============
fwrite($fd, $this->int2(1)); // Version
fwrite($fd, $this->int2(0)); // Reserved1
fwrite($fd, $this->int4($content_length)); // doc size
fwrite($fd, $this->int2($num_records)); // num records
fwrite($fd, $this->int2($this->record_size)); // record size
fwrite($fd, $this->int4(0)); // Reserved2
}
/**
* Writes the given text, title on the given file descriptor
* Note: It's saved as uncompressed doc
* Note2: File descriptor is not closed at the end of the function
*/
function write($fd, $content, $title)
{
// Write header
$this->write_header($fd, $title, strlen($content));
// Write content
fwrite($fd, $content);
// And flushes all
fflush($fd);
}
/**
* Reads the header of the pdb file
* and different parameters including its size
*/
function read_header($fd)
{
// ============ File header =========================================
// Title of the document, it's limited to 31 characters
$title = fread(31,$fd);
// Completion with null '\0' characters
for($i=0; $i<32-strlen($title); $i++)
{
fwrite($fd, sprintf("%c", 0), 1);
}
// attributes & version fields
fwrite($fd, $this->int2(0));
fwrite($fd, $this->int2(0));
// create & modify time
fwrite($fd, sprintf("%c%c%c%c", 6, 209, 68, 174), 4);
fwrite($fd, sprintf("%c%c%c%c", 6, 209, 68, 174), 4);
// backup time, modification number, app Info Id, sort info Id
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
// Type & creator
fwrite($fd, 'TEXt', 4);
fwrite($fd, 'REAd', 4);
// Id seed & next record list
fwrite($fd, $this->int4(0));
fwrite($fd, $this->int4(0));
// Number of text records
$full_tr = (int)($content_length / $this->record_size);
$notfull_tr = $content_length % $this->record_size;
$num_records = $full_tr;
if($notfull_tr != 0)
{
$num_records++;
}
// + 1 cause of record 0
fwrite($fd, $this->int2($num_records + 1));
// From here...
$num_offsets = $num_records + 1;
$offset = $this->pdb_header_size + $this->pdb_record_header_size * $num_offsets;
$index = 0x40 << 24 | 0x6F8000; // Why not!
fwrite($fd, $this->int4($offset));
fwrite($fd, $this->int4($index++));
$val = 110 + ($num_offsets - 2) * 8;
while(--$num_offsets != 0)
{
fwrite($fd, $this->int4($val));
$val += 4096;
fwrite($fd, $this->int4($index++));
}
// To here
// Don't ask me how it works ;-)
// ====== Write record 0 ============
fwrite($fd, $this->int2(1)); // Version
fwrite($fd, $this->int2(0)); // Reserved1
fwrite($fd, $this->int4($content_length)); // doc size
fwrite($fd, $this->int2($num_records)); // num records
fwrite($fd, $this->int2($this->record_size)); // record size
fwrite($fd, $this->int4(0)); // Reserved2
}
/**
* Reads a pdb from the given file descriptor
* Note2: File descriptor is not closed at the end of the function
*/
function read($fd)
{
// Read header
$header = $this->read_header($fd);
// Read content
$content = fread($fd);
// And flushes all
flush($fd);
}
/**
* Creates a palmdoc and force the user to download it
*/
function fetch($content, $title, $document)
{
// Creates a temp file to put the current doc
$tempfile = tempnam(".", "palm");
// Creates the doc from the content
$fd = fopen($tempfile, 'w');
$this->write($fd, $content, $title);
fclose($fd);
// Forces the download
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"$document\"");
// And writes the file content on stdout
$fd = fopen("$tempfile", 'r');
$content = fread($fd, filesize($tempfile));
fclose($fd);
print($content);
// Cleaning
unlink($tempfile);
exit;
}
}
?>

View File

@ -1,100 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org *
* and Miles Lott <milos@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class soaddressbook
{
var $contacts;
var $rights;
var $grants;
var $owner;
function soaddressbook()
{
if(!is_object($GLOBALS['egw']->contacts))
{
$GLOBALS['egw']->contacts = CreateObject('phpgwapi.contacts');
}
$this->contacts = &$GLOBALS['egw']->contacts;
$this->grants = &$this->contacts->grants;
/* _debug_array($GLOBALS['egw_info']); */
/* _debug_array($grants); */
}
function read_entries($data)
{
// echo 'OK!';
// _debug_array($data);exit;
return $this->contacts->read(
$data['start'],
$data['limit'],
$data['fields'],
$data['query'],
$data['filter'],
$data['sort'],
$data['order'],
-1,
$data['cquery']
);
}
function read_entry($id,$fields)
{
return $this->contacts->read_single_entry($id,$fields);
}
function read_last_entry($fields)
{
return $this->contacts->read_last_entry($fields);
}
function add_entry($fields)
{
$owner = $fields['owner'];
$access = $fields['access'];
$cat_id = $fields['cat_id'];
$tid = $fields['tid'];
unset($fields['owner']);
unset($fields['access']);
unset($fields['cat_id']);
unset($fields['ab_id']);
unset($fields['tid']);
return $this->contacts->add($owner,$fields,$access,$cat_id,$tid);
}
function get_lastid()
{
$entry = $this->contacts->read_last_entry();
return $entry[0]['id'];
}
function update_entry($fields)
{
$ab_id = isset($fields['ab_id']) ? $fields['ab_id'] : $fields['id'];
$owner = $fields['owner'];
unset($fields['owner']);
unset($fields['ab_id']);
unset($fields['id']);
return $this->contacts->update($ab_id,$owner,$fields);
}
function delete_entry($id)
{
return $this->contacts->delete($id);
}
}
?>

View File

@ -1,324 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Miles Lott <milos@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class uiXport
{
var $template;
var $public_functions = array(
'import' => True,
'export' => True
);
var $bo;
var $cat;
var $start;
var $limit;
var $query;
var $sort;
var $order;
var $filter;
var $cat_id;
function uiXport()
{
$this->template = $GLOBALS['egw']->template;
$this->cat = CreateObject('phpgwapi.categories');
$this->bo = CreateObject('addressbook.boXport',True);
$this->browser = CreateObject('phpgwapi.browser');
$this->_set_sessiondata();
}
function _set_sessiondata()
{
$this->start = $this->bo->start;
$this->limit = $this->bo->limit;
$this->query = $this->bo->query;
$this->sort = $this->bo->sort;
$this->order = $this->bo->order;
$this->filter = $this->bo->filter;
$this->cat_id = $this->bo->cat_id;
if($this->debug) { $this->_debug_sqsof(); }
}
/* Called only by index(), just prior to page footer. */
function save_sessiondata()
{
$data = array(
'start' => $this->start,
'limit' => $this->limit,
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order,
'filter' => $this->filter,
'cat_id' => $this->cat_id
);
$this->bo->save_sessiondata($data);
}
/* Return a select form element with the categories option dialog in it */
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
{
if($java)
{
$jselect = ' onChange="this.form.submit();"';
}
/* Setup all and none first */
$cats_link = "\n" .'<select name="fcat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple size="3"' : '') . ">\n";
if(!$notall)
{
$cats_link .= '<option value=""';
if($cat_id=='all')
{
$cats_link .= ' selected';
}
$cats_link .= '>'.lang('all').'</option>'."\n";
}
/* Get global and app-specific category listings */
$cats_link .= $this->cat->formated_list('select','all',$cat_id,True);
$cats_link .= '</select>'."\n";
return $cats_link;
}
function import()
{
$tsvfile = get_var('tsvfile','FILES');
$tsvfilename = get_var('tsvfilename','POST');
$convert = get_var('convert','POST');
$conv_type = get_var('conv_type','POST');
$fcat_id = get_var('fcat_id','POST');
$private = get_var('private','POST');
$download = get_var('download','POST');
if($convert)
{
if($conv_type == 'none')
{
$GLOBALS['egw_info']['flags']['noheader'] = False;
$GLOBALS['egw_info']['flags']['noheader'] = True;
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo lang('<b>No conversion type &lt;none&gt; could be located.</b> Please choose a conversion type from the list');
echo '&nbsp<a href="'.$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.import') . '">' . lang('OK') . '</a>';
$GLOBALS['egw']->common->phpgw_footer();
$GLOBALS['egw']->common->phpgw_exit();
}
$buffer = $this->bo->import($tsvfile,$conv_type,$private,$fcat_id);
if($download == '')
{
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL')
{
// filename, default application/octet-stream, length of file, default nocache True
$GLOBALS['egw']->browser->content_header($tsvfilename,'',strlen($buffer));
echo $buffer;
}
else
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo "<pre>$buffer</pre>";
echo '<a href="'.$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index') . '">'.lang('OK').'</a>';
$GLOBALS['egw']->common->phpgw_footer();
}
}
else
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo "<pre>$buffer</pre>";
echo '<a href="'.$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'). '">'.lang('OK').'</a>';
$GLOBALS['egw']->common->phpgw_footer();
}
}
else
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
set_time_limit(0);
$this->template->set_file(array('import' => 'import.tpl'));
$dir_handle = opendir(PHPGW_APP_INC . SEP . 'import');
$i=0; $myfilearray = '';
while($file = readdir($dir_handle))
{
if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file))
{
$myfilearray[$i] = $file;
$i++;
}
}
closedir($dir_handle);
sort($myfilearray);
for($i=0;$i<count($myfilearray);$i++)
{
if ($myfilearray[$i] == 'Import_Multiple_VCard')
{
$fname = lang('import multiple vcard');
}
else
{
$fname = str_replace('Import_from_', lang('import from') . ' ' ,$myfilearray[$i]);
$fname = str_replace('_', ' ', $fname);
}
$conv .= '<OPTION VALUE="' . $myfilearray[$i].'">' . $fname . '</OPTION>';
}
$this->template->set_var('lang_none', lang('none'));
$this->template->set_var('lang_cancel',lang('Cancel'));
$this->template->set_var('lang_cat',lang('Select Category'));
$this->template->set_var('cancel_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
$this->template->set_var('navbar_bg',$GLOBALS['egw_info']['theme']['navbar_bg']);
$this->template->set_var('navbar_text',$GLOBALS['egw_info']['theme']['navbar_text']);
$this->template->set_var('import_text',lang('Import from LDIF, CSV, or VCard'));
$this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.import'));
$this->template->set_var('cat_link',$this->cat_option($this->cat_id,True,False));
$this->template->set_var('tsvfilename','');
$this->template->set_var('conv',$conv);
$this->template->set_var('debug',lang('Debug output in browser'));
$this->template->set_var('filetype',lang('LDIF'));
$this->template->set_var('download',lang('Submit'));
$this->template->set_var('start',$this->start);
$this->template->set_var('sort',$this->sort);
$this->template->set_var('order',$this->order);
$this->template->set_var('filter',$this->filter);
$this->template->set_var('query',$this->query);
$this->template->set_var('cat_id',$this->cat_id);
$this->template->set_var('lang_import_instructions',lang('import_instructions'));
$this->template->set_var('zip_note','');
if(extension_loaded('zip'))
{
$this->template->set_var('zip_note',lang('zip_note'));
}
$this->template->set_var('lang_exported_file',lang('enter the path to the exported file here'));
$this->template->set_var('lang_conv_type',lang('select the type of conversion'));
$this->template->set_var('lang_mark_priv',lang('Mark records as private'));
$this->template->set_var('lang_debug',lang('Debug output in browser'));
$this->template->pparse('out','import');
}
// $GLOBALS['egw']->common->phpgw_footer();
}
function export()
{
$convert = get_var('convert','POST');
$conv_type = get_var('conv_type','POST');
$fcat_id = get_var('fcat_id','POST');
$download = get_var('download','POST');
$tsvfilename = get_var('tsvfilename','POST');
if($convert)
{
if($conv_type == 'none')
{
$GLOBALS['egw_info']['flags']['noheader'] = False;
$GLOBALS['egw_info']['flags']['noheader'] = True;
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo lang('<b>No conversion type &lt;none&gt; could be located.</b> Please choose a conversion type from the list');
echo '&nbsp<a href="'.$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.export') . '">' . lang('OK') . '</a>';
$GLOBALS['egw']->common->phpgw_footer();
$GLOBALS['egw']->common->phpgw_exit();
}
$buffer = $this->bo->export($conv_type,$fcat_id);
if($conv_type == 'Palm_PDB')
{
$pdb = CreateObject('addressbook.pdb');
$pdb->fetch($buffer, 'phpgw Contacts', $tsvfilename);
}
elseif($download == 'on')
{
// filename, default application/octet-stream, length of file, default nocache True
$this->browser->content_header($tsvfilename,'application/x-octet-stream',strlen($buffer));
echo $buffer;
}
else
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo "<pre>\n";
echo $buffer;
echo "\n</pre>\n";
echo '<a href="'.$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.export') . '">' . lang('OK') . '</a>';
$GLOBALS['egw']->common->phpgw_footer();
}
}
else
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
set_time_limit(0);
$this->template->set_file(array('export' => 'export.tpl'));
$dir_handle = opendir(PHPGW_APP_INC. SEP . 'export');
$i=0; $myfilearray = '';
while($file = readdir($dir_handle))
{
if((substr($file, 0, 1) != '.') && is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file))
{
$myfilearray[$i] = $file;
$i++;
}
}
closedir($dir_handle);
sort($myfilearray);
for($i=0;$i<count($myfilearray);$i++)
{
if ($myfilearray[$i] == 'Multiple_VCard')
{
$fname = lang('multiple vcard');
}
else
{
$fname = str_replace('_',' ',$myfilearray[$i]);
}
$conv .= ' <option value="'.$myfilearray[$i].'">'.$fname.'</option>'."\n";
}
$this->template->set_var('lang_none', lang('none'));
$this->template->set_var('lang_cancel',lang('Cancel'));
$this->template->set_var('lang_cat',lang('Select Category'));
$this->template->set_var('lang_export_instructions',lang('Download export file (Uncheck to debug output in browser)'));
$this->template->set_var('lang_select',lang('Select the type of conversion:'));
$this->template->set_var('cat_link',$this->cat_option($this->cat_id,False,False));
$this->template->set_var('cancel_url',$GLOBALS['egw']->link('/addressbook/index.php'));
$this->template->set_var('navbar_bg',$GLOBALS['egw_info']['theme']['navbar_bg']);
$this->template->set_var('navbar_text',$GLOBALS['egw_info']['theme']['navbar_text']);
$this->template->set_var('export_text',lang('Export from Addressbook'));
$this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.export'));
$this->template->set_var('filename',lang('Export file name'));
$this->template->set_var('conv',$conv);
$this->template->set_var('debug',lang(''));
$this->template->set_var('download',lang('Submit'));
$this->template->set_var('start',$this->start);
$this->template->set_var('sort',$this->sort);
$this->template->set_var('order',$this->order);
$this->template->set_var('filter',$this->filter);
$this->template->set_var('query',$this->query);
$this->template->set_var('cat_id',$this->cat_id);
$this->template->pparse('out','export');
$GLOBALS['egw']->common->phpgw_footer();
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,358 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> and *
* Miles Lott <milosch@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class uifields
{
var $public_functions = array(
'index' => True,
'add' => True,
'edit' => True,
'delete' => True
);
var $bo;
function uifields()
{
$GLOBALS['egw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$GLOBALS['egw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
$this->bo = CreateObject('addressbook.bofields');
}
function index()
{
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo lang('access not permitted');
$GLOBALS['egw']->common->phpgw_exit();
}
$GLOBALS['egw']->template->set_file(array(
'field_list_t' => 'listfields.tpl',
'field_list' => 'listfields.tpl'
));
$GLOBALS['egw']->template->set_block('field_list_t','field_list','list');
$field = $_POST['field'];
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
$query = $_POST['query'] ? $_POST['query'] : $_GET['query'];
$sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort'];
$common_hidden_vars =
'<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
. '<input type="hidden" name="order" value="' . $order . '">' . "\n"
. '<input type="hidden" name="query" value="' . $query . '">' . "\n"
. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
. '<input type="hidden" name="filter" value="' . $filter . '">' . "\n";
$GLOBALS['egw']->template->set_var('lang_action',lang('Custom Fields'));
$GLOBALS['egw']->template->set_var('add_action',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.add'));
$GLOBALS['egw']->template->set_var('lang_add',lang('Add'));
$GLOBALS['egw']->template->set_var('title_fields',lang('addressbook').' - '.lang('Custom Fields'));
$GLOBALS['egw']->template->set_var('lang_search',lang('Search'));
$GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index'));
$GLOBALS['egw']->template->set_var('lang_done',lang('Done'));
$GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/admin/index.php'));
if(!$start)
{
$start = 0;
}
if(!$sort)
{
$sort = 'ASC';
}
$fields = $this->bo->_read($start,$limit,$query,$sort);
$total_records = count($fields);
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
$GLOBALS['egw']->template->set_var('left',$GLOBALS['egw']->nextmatchs->left('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index'));
$GLOBALS['egw']->template->set_var('right',$GLOBALS['egw']->nextmatchs->right('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index'));
$GLOBALS['egw']->template->set_var('lang_showing',$GLOBALS['egw']->nextmatchs->show_hits($total_records,$start));
$GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
$GLOBALS['egw']->template->set_var('sort_field',$GLOBALS['egw']->nextmatchs->show_sort_order($sort,'name',$order,'/index.php',lang('Name')),'menuaction=addressbook.uifields.index');
$GLOBALS['egw']->template->set_var('lang_edit',lang('Edit'));
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
for($i=0;$i<count($fields);$i++)
{
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
$GLOBALS['egw']->template->set_var(tr_color,$tr_color);
$field = $fields[$i]['name'];
$title = $fields[$i]['title'];
$GLOBALS['egw']->template->set_var('cfield',$title);
$params = array(
'menuaction' => 'addressbook.uifields.edit',
'field' => urlencode($field),
'start' => $start,
'query' => $query,
'sort' => $sort,
'order' => $order,
'filter' => $filter
);
$GLOBALS['egw']->template->set_var('edit',$GLOBALS['egw']->link('/index.php',$params));
$GLOBALS['egw']->template->set_var('lang_edit_entry',lang('Edit'));
$params['menuaction'] = 'addressbook.uifields.delete';
$GLOBALS['egw']->template->set_var('delete',$GLOBALS['egw']->link('/index.php',$params));
$GLOBALS['egw']->template->set_var('lang_delete_entry',lang('Delete'));
$GLOBALS['egw']->template->parse('list','field_list',True);
}
$GLOBALS['egw']->template->parse('out','field_list_t',True);
$GLOBALS['egw']->template->p('out');
}
function add()
{
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo lang('access not permitted');
$GLOBALS['egw']->common->phpgw_exit();
}
$field = stripslashes($_POST['field']);
$field_name = stripslashes($_POST['field_name']);
$start = $_POST['start'];
$query = $_POST['query'];
$sort = $_POST['sort'];
$submit = $_POST['submit'];
$GLOBALS['egw']->template->set_file(array('form' => 'field_form.tpl'));
$GLOBALS['egw']->template->set_block('form','add','addhandle');
$GLOBALS['egw']->template->set_block('form','edit','edithandle');
if($submit)
{
$errorcount = 0;
if(!$field_name)
{
$error[$errorcount++] = lang('Please enter a name for that field !');
}
$fields = $this->bo->_read($start,$limit,$field_name);
if($fields[0]['name'])
{
$error[$errorcount++] = lang('That field name has been used already !');
}
if(!$error)
{
$this->bo->_save($field,$field_name);
}
}
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
if($errorcount)
{
$GLOBALS['egw']->template->set_var('message',$GLOBALS['egw']->common->error_list($error));
}
if(($submit) && (!$error) && (!$errorcount))
{
$GLOBALS['egw']->template->set_var('message',lang('Field %1 has been added !', $field_name));
}
if((!$submit) && (!$error) && (!$errorcount))
{
$GLOBALS['egw']->template->set_var('message','');
}
$GLOBALS['egw']->template->set_var('title_fields',lang('Add Custom Field'));
$GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.add'));
$GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index'));
$GLOBALS['egw']->template->set_var('hidden_vars','<input type="hidden" name="field" value="' . $field . '">');
$GLOBALS['egw']->template->set_var('lang_name',lang('Field name'));
$GLOBALS['egw']->template->set_var('lang_add',lang('Add'));
$GLOBALS['egw']->template->set_var('lang_reset',lang('Clear Form'));
$GLOBALS['egw']->template->set_var('lang_done',lang('Done'));
$GLOBALS['egw']->template->set_var('field_name',$field_name);
$GLOBALS['egw']->template->set_var('edithandle','');
$GLOBALS['egw']->template->set_var('addhandle','');
$GLOBALS['egw']->template->pparse('out','form');
$GLOBALS['egw']->template->pparse('addhandle','add');
}
function edit()
{
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo lang('access not permitted');
$GLOBALS['egw']->common->phpgw_exit();
}
$field = stripslashes($_POST['field'] ? $_POST['field'] : $_GET['field']);
$field_name = stripslashes($_POST['field_name']);
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
$query = $_POST['query'] ? $_POST['query'] : $_GET['query'];
$sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort'];
$submit = $_POST['submit'];
if(!$field)
{
Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&sort=$sort&query=$query&start=$start"));
}
$GLOBALS['egw']->template->set_file(array('form' => 'field_form.tpl'));
$GLOBALS['egw']->template->set_block('form','add','addhandle');
$GLOBALS['egw']->template->set_block('form','edit','edithandle');
$hidden_vars = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
. '<input type="hidden" name="query" value="' . $query . '">' . "\n"
. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
. '<input type="hidden" name="field" value="' . $field . '">' . "\n";
if($submit)
{
$errorcount = 0;
if(!$field_name)
{
$error[$errorcount++] = lang('Please enter a name for that field !');
}
if(!$error)
{
$this->bo->_save($field,$field_name);
}
}
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
if($errorcount)
{
$GLOBALS['egw']->template->set_var('message',$GLOBALS['egw']->common->error_list($error));
}
if(($submit) && (!$error) && (!$errorcount))
{
$GLOBALS['egw']->template->set_var('message',lang('Field %1 has been updated !', $field_name));
}
if((!$submit) && (!$error) && (!$errorcount))
{
$GLOBALS['egw']->template->set_var('message','');
}
if($submit)
{
$field = $field_name;
}
else
{
$fields = $this->bo->_read($start,$limit,$field);
$field = $GLOBALS['egw']->strip_html($fields[0]['title']);
$fn = $fields[0]['name'];
}
$GLOBALS['egw']->template->set_var('title_fields',lang('Edit Custom Field'));
$GLOBALS['egw']->template->set_var('actionurl',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.edit'));
$GLOBALS['egw']->template->set_var('deleteurl',$GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.delete&field=$fn&start=$start&query=$query&sort=$sort"));
$GLOBALS['egw']->template->set_var('doneurl',$GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
$GLOBALS['egw']->template->set_var('hidden_vars',$hidden_vars);
$GLOBALS['egw']->template->set_var('lang_name',lang('Field name'));
$GLOBALS['egw']->template->set_var('lang_done',lang('Done'));
$GLOBALS['egw']->template->set_var('lang_edit',lang('Edit'));
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
$GLOBALS['egw']->template->set_var('field_name',$field);
$GLOBALS['egw']->template->set_var('edithandle','');
$GLOBALS['egw']->template->set_var('addhandle','');
$GLOBALS['egw']->template->pparse('out','form');
$GLOBALS['egw']->template->pparse('edithandle','edit');
}
function delete()
{
if(!$GLOBALS['egw']->acl->check('run',1,'admin'))
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo lang('access not permitted');
$GLOBALS['egw']->common->phpgw_exit();
}
$field = urldecode($_POST['field'] ? $_POST['field'] : $_GET['field']);
$field_id = $_POST['field_id'] ? $_POST['field_id'] : $_GET['field_id'];
$start = $_POST['start'] ? $_POST['start'] : $_GET['start'];
$query = $_POST['query'] ? $_POST['query'] : $_GET['query'];
$sort = $_POST['sort'] ? $_POST['sort'] : $_GET['sort'];
if(!$field)
{
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.index'));
}
if($_POST['confirm'])
{
$this->bo->_save($field);
Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
}
else
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
$hidden_vars = '<input type="hidden" name="sort" value="' . $sort . '">' . "\n"
. '<input type="hidden" name="order" value="' . $order .'">' . "\n"
. '<input type="hidden" name="query" value="' . $query .'">' . "\n"
. '<input type="hidden" name="start" value="' . $start .'">' . "\n"
. '<input type="hidden" name="field" value="' . $field .'">' . "\n";
$GLOBALS['egw']->template->set_file(array('field_delete' => 'delete_common.tpl'));
$GLOBALS['egw']->template->set_var('messages',lang('Are you sure you want to delete this field?'));
$nolinkf = $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uifields.index&field_id=$field_id&start=$start&query=$query&sort=$sort");
$nolink = '<a href="' . $nolinkf . '">' . lang('No') . '</a>';
$GLOBALS['egw']->template->set_var('no',$nolink);
$yeslinkf = $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifieldsdelete&field_id=' . $field_id . '&confirm=True');
$yeslinkf = '<form method="POST" name="yesbutton" action="' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uifields.delete') . '">'
. $hidden_vars
. '<input type="hidden" name="field_id" value="' . $field_id . '">'
. '<input type="hidden" name="confirm" value="True">'
. '<input type="submit" name="yesbutton" value="Yes">'
. '</form><script>document.yesbutton.yesbutton.focus()</script>';
$yeslink = '<a href="' . $yeslinkf . '">' . lang('Yes') . '</a>';
$yeslink = $yeslinkf;
$GLOBALS['egw']->template->set_var('yes',$yeslink);
$GLOBALS['egw']->template->pparse('out','field_delete');
}
}
}
?>

View File

@ -1,209 +0,0 @@
<?php
/**************************************************************************\
* eGroupWare - Addressbook *
* http://www.egroupware.org *
* Written by Joseph Engo <jengo@phpgroupware.org> and *
* Miles Lott <milos@groupwhere.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. *
\**************************************************************************/
/* $Id$ */
class uivcard
{
var $template;
var $contacts;
var $browser;
var $vcard;
var $bo;
var $public_functions = array(
'in' => True,
'out' => True
);
var $extrafields = array(
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
);
function uivcard()
{
$this->template = &$GLOBALS['egw']->template;
$this->contacts = CreateObject('phpgwapi.contacts');
$this->browser = CreateObject('phpgwapi.browser');
$this->vcard = CreateObject('phpgwapi.vcard');
$this->bo = CreateObject('addressbook.boaddressbook',True);
}
function in()
{
$uploadedfile = get_var('uploadedfile','FILES');
$action = get_var('action',array('POST','GET'));
if($uploadedfile)
{
$ab_id = $this->bo->add_vcard($uploadedfile);
if($ab_id)
{
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id));
}
}
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
echo '<body bgcolor="' . $GLOBALS['egw_info']['theme']['bg_color'] . '">';
if($action == 'GetFile')
{
echo '<b><center>' . lang('You must select a vcard. (*.vcf)') . '</b></center><br><br>';
}
$this->template->set_file(array('vcardin' => 'vcardin.tpl'));
$this->template->set_var('lang_load_vcard', lang('load vcard'));
$this->template->set_var('vcard_header','<p>&nbsp;<b>' . lang('Address book - VCard in') . '</b><hr><p>');
$this->template->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uivcard.in'));
$this->template->set_var('lang_access',lang('Access'));
$this->template->set_var('lang_groups',lang('Which groups'));
$this->template->set_var('access_option',$access_option);
$this->template->set_var('group_option',$group_option);
$this->template->pparse('out','vcardin');
$GLOBALS['egw']->common->phpgw_footer();
}
function out()
{
$ab_id = get_var('ab_id',array('GET','POST'));
$nolname = get_var('nolname','GET');
$nofname = get_var('nofname','GET');
if($nolname || $nofname)
{
$GLOBALS['egw']->common->phpgw_header();
echo parse_navbar();
}
if(!$ab_id)
{
Header('Location: ' . $GLOBALS['egw']->link('/addressbook/index.php'));
$GLOBALS['egw']->common->phpgw_exit();
}
// First, make sure they have permission to this entry
$check = $this->bo->read_entry(array('id' => $ab_id, 'fields' => array('owner' => 'owner')));
$perms = $this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_READ);
if((!$perms) && ($check[0]['owner'] != $GLOBALS['egw_info']['user']['account_id']))
{
Header("Location: " . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.get_list'));
$GLOBALS['egw']->common->phpgw_exit();
}
$extrafields = array('address2' => 'address2');
$qfields = $this->contacts->stock_contact_fields + $extrafields;
$fieldlist = $this->bo->read_entry(array('id' => $ab_id, 'fields' => $qfields));
$fields = $fieldlist[0];
$email = $fields['email'];
$emailtype = $fields['email_type'];
if(!$emailtype)
{
$fields['email_type'] = 'INTERNET';
}
$hemail = $fields['email_home'];
$hemailtype = $fields['email_home_type'];
if(!$hemailtype)
{
$fields['email_home_type'] = 'INTERNET';
}
$firstname = $fields['n_given'];
$lastname = $fields['n_family'];
if(!$nolname && !$nofname)
{
/* First name and last must be in the vcard. */
if($lastname == '')
{
/* Run away here. */
Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uivcard.out&nolname=1&ab_id=$ab_id"));
}
if($firstname == '')
{
Header('Location: ' . $GLOBALS['egw']->link('/index.php',"menuaction=addressbook.uivcard.out&nofname=1&ab_id=$ab_id"));
}
if($email)
{
$fn = explode('@',$email);
$filename = sprintf("%s.vcf", $fn[0]);
}
elseif($hemail)
{
$fn = explode('@',$hemail);
$filename = sprintf("%s.vcf", $fn[0]);
}
else
{
$fn = strtolower($firstname);
$filename = sprintf("%s.vcf", $fn);
}
// set translation variable
$myexport = $this->vcard->export;
// check that each $fields exists in the export array and
// set a new array to equal the translation and original value
while(list($name,$value) = each($fields))
{
if($myexport[$name] && ($value != ''))
{
//echo '<br>'.$name."=".$fields[$name]."\n";
$buffer[$myexport[$name]] = $value;
}
}
// create a vcard from this translated array
$entry = $this->vcard->out($buffer);
// print it using browser class for headers
// filename, mimetype, no length, default nocache True
$this->browser->content_header($filename,'text/x-vcard');
echo $entry;
exit;
//$GLOBALS['egw']->common->exit;
} /* !nolname && !nofname */
if($nofname)
{
echo '<br><br><center>';
echo lang("This person's first name was not in the address book.") .'<br>';
echo lang('Vcards require a first name entry.') . '<br><br>';
echo '<a href="' . $GLOBALS['egw']->link('/addressbook/index.php',
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
echo '</center>';
}
if($nolname)
{
echo '<br><br><center>';
echo lang("This person's last name was not in the address book.") . '<br>';
echo lang('Vcards require a last name entry.') . '<br><br>';
echo '<a href="' . $GLOBALS['egw']->link('/addressbook/index.php',
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id") . '">' . lang('OK') . '</a>';
echo '</center>';
}
if($nolname || $nofname)
{
//$GLOBALS['egw']->common->phpgw_footer();
}
}
}
?>