mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 09:05:16 +01:00
Starting to commit mostly working redesign using 3layer
This commit is contained in:
parent
17fb6dc9f2
commit
ace91371c8
309
addressbook/inc/class.boXport.inc.php
Normal file
309
addressbook/inc/class.boXport.inc.php
Normal file
@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - addressbook *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Joseph Engo <jengo@phpgroupware.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;
|
||||
|
||||
function boXport ($session=False)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$this->contacts = &$phpgw->contacts;
|
||||
$this->so = CreateObject('addressbook.soaddressbook');
|
||||
if($session)
|
||||
{
|
||||
$this->read_sessiondata();
|
||||
$this->use_session = True;
|
||||
}
|
||||
global $start,$limit,$query,$sort,$order,$filter,$cat_id;
|
||||
|
||||
if($start || $start == 0) { $this->start = $start; }
|
||||
if($limit) { $this->limit = $limit; }
|
||||
if($query) { $this->query = $query; }
|
||||
if($sort) { $this->sort = $sort; }
|
||||
if($order) { $this->order = $order; }
|
||||
if($filter) { $this->filter = $filter; }
|
||||
$this->cat_id = $cat_id;
|
||||
}
|
||||
|
||||
function save_sessiondata()
|
||||
{
|
||||
global $phpgw,$start,$limit,$query,$sort,$order,$filter,$cat_id;
|
||||
|
||||
if ($this->use_session)
|
||||
{
|
||||
$data = array(
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
'query' => $query,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'filter' => $filter,
|
||||
'cat_id' => $cat_id
|
||||
);
|
||||
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
|
||||
$phpgw->session->appsession('session_data','addressbook',$data);
|
||||
}
|
||||
}
|
||||
|
||||
function read_sessiondata()
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$data = $phpgw->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'];
|
||||
}
|
||||
|
||||
function import()
|
||||
{
|
||||
global $tsvfile,$private;
|
||||
|
||||
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);
|
||||
$fp = fopen($tsvfile,'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);
|
||||
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
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fp);
|
||||
$buffer = $contacts->import_end_file($buffer,$private,$cat_id);
|
||||
|
||||
if ($download == '')
|
||||
{
|
||||
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL' )
|
||||
{
|
||||
// filename, default application/octet-stream, length of file, default nocache True
|
||||
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
|
||||
echo $buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
echo "<pre>$buffer</pre>";
|
||||
echo '<a href="'.$phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.get_list') . '">'.lang("OK").'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
echo "<pre>$buffer</pre>";
|
||||
echo '<a href="'.$phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.get_list'). '">'.lang("OK").'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
}
|
||||
|
||||
function export()
|
||||
{
|
||||
global $phpgw_info;
|
||||
|
||||
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($phpgw_info['user']['preferences']['addressbook']))
|
||||
{
|
||||
if ( substr($col,0,6) == 'extra_' )
|
||||
{
|
||||
$field = ereg_replace('extra_','',$col);
|
||||
$field = ereg_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 = $phpgw_info['server']['temp_dir'] . SEP . $tsvfilename;
|
||||
|
||||
return $buffer;
|
||||
}
|
||||
}
|
||||
?>
|
404
addressbook/inc/class.boaddressbook.inc.php
Normal file
404
addressbook/inc/class.boaddressbook.inc.php
Normal file
@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - addressbook *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Miles Lott <milosch@phpgroupware.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,
|
||||
'copy_entry' => True,
|
||||
'update_entry' => True
|
||||
);
|
||||
|
||||
var $debug = False;
|
||||
|
||||
var $so;
|
||||
var $start;
|
||||
var $limit;
|
||||
var $query;
|
||||
var $sort;
|
||||
var $order;
|
||||
var $filter;
|
||||
var $cat_id;
|
||||
|
||||
var $use_session = False;
|
||||
|
||||
function boaddressbook($session=False)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$this->so = CreateObject('addressbook.soaddressbook');
|
||||
|
||||
if($session)
|
||||
{
|
||||
$this->read_sessiondata();
|
||||
$this->use_session = True;
|
||||
}
|
||||
global $start,$limit,$query,$sort,$order,$filter,$cat_id;
|
||||
|
||||
if($start || $start == 0) { $this->start = $start; }
|
||||
if($limit) { $this->limit = $limit; }
|
||||
if(!empty($query)) { $this->query = $query; }
|
||||
if(!empty($sort)) { $this->sort = $sort; }
|
||||
if(!empty($order)) { $this->order = $order; }
|
||||
if(!empty($filter)) { $this->filter = $filter; }
|
||||
$this->cat_id = $cat_id;
|
||||
}
|
||||
|
||||
function save_sessiondata()
|
||||
{
|
||||
global $phpgw,$start,$limit,$query,$sort,$order,$filter,$cat_id;
|
||||
|
||||
if ($this->use_session)
|
||||
{
|
||||
$data = array(
|
||||
'start' => $start,
|
||||
'limit' => $limit,
|
||||
'query' => $query,
|
||||
'sort' => $sort,
|
||||
'order' => $order,
|
||||
'filter' => $filter,
|
||||
'cat_id' => $cat_id
|
||||
);
|
||||
if($this->debug) { echo '<br>Save:'; _debug_array($data); }
|
||||
$phpgw->session->appsession('session_data','addressbook',$data);
|
||||
}
|
||||
}
|
||||
|
||||
function read_sessiondata()
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$data = $phpgw->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'];
|
||||
}
|
||||
|
||||
function strip_html($dirty = '')
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
if ($dirty == ''){$dirty = array();}
|
||||
for($i=0;$i<count($dirty);$i++)
|
||||
{
|
||||
while (list($name,$value) = each($dirty[$i]))
|
||||
{
|
||||
$cleaned[$i][$name] = $phpgw->strip_html($dirty[$i][$name]);
|
||||
}
|
||||
}
|
||||
return $cleaned;
|
||||
}
|
||||
|
||||
function read_entries($start,$limit,$qcols,$qfilter,$userid='')
|
||||
{
|
||||
$entries = $this->so->read_entries($start,$limit,$qcols,$this->query,$qfilter,$this->sort,$this->order,$userid);
|
||||
return $this->strip_html($entries);
|
||||
}
|
||||
|
||||
function read_entry($id,$fields,$userid='')
|
||||
{
|
||||
$entry = $this->so->read_entry($id,$fields,$userid);
|
||||
return $this->strip_html($entry);
|
||||
}
|
||||
|
||||
function read_last_entry($fields)
|
||||
{
|
||||
$entry = $this->so->read_last_entry($fields);
|
||||
return $this->strip_html($entry);
|
||||
}
|
||||
|
||||
function add_vcard()
|
||||
{
|
||||
global $phpgw,$phpgw_info,$uploadedfile;
|
||||
|
||||
if($uploadedfile == 'none' || $uploadedfile == '')
|
||||
{
|
||||
Header('Location: ' . $phpgw->link('/addressbook/main.php','menuaction=addressbook.uivcard.in&action=GetFile'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$uploaddir = $phpgw_info['server']['temp_dir'] . SEP;
|
||||
|
||||
srand((double)microtime()*1000000);
|
||||
$random_number = rand(100000000,999999999);
|
||||
$newfilename = md5("$uploadedfile, $uploadedfile_name, "
|
||||
. time() . getenv("REMOTE_ADDR") . $random_number );
|
||||
|
||||
copy($uploadedfile, $uploaddir . $newfilename);
|
||||
$ftp = fopen($uploaddir . $newfilename . '.info','w');
|
||||
fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n");
|
||||
fclose($ftp);
|
||||
|
||||
$filename = $uploaddir . $newfilename;
|
||||
|
||||
$vcard = CreateObject('phpgwapi.vcard');
|
||||
$entry = $vcard->in_file($filename);
|
||||
/* _debug_array($entry);exit; */
|
||||
$this->so->add_entry($phpgw_info['user']['account_id'],$entry,'private','','n');
|
||||
$ab_id = $this->get_lastid();
|
||||
|
||||
/* Delete the temp file. */
|
||||
unlink($filename);
|
||||
unlink($filename . '.info');
|
||||
Header('Location: ' . $phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id));
|
||||
}
|
||||
}
|
||||
|
||||
function add_email()
|
||||
{
|
||||
global $phpgw_info,$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($phpgw_info['user']['account_id'],$fields,'private','','n');
|
||||
$ab_id = $this->get_lastid();
|
||||
|
||||
Header('Location: '
|
||||
. $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer"));
|
||||
}
|
||||
|
||||
function copy_entry()
|
||||
{
|
||||
global $phpgw,$phpgw_info,$ab_id;
|
||||
|
||||
$addnew = $this->read_entry($ab_id,$this->so->contacts->stock_contact_fields,$phpgw_info['user']['account_id']);
|
||||
|
||||
$addnew[0]['note'] .= "\nCopied from ".$phpgw->accounts->id2name($addnew[0]['owner']).", record #".$addnew[0]['id'].".";
|
||||
$addnew[0]['owner'] = $phpgw_info['user']['account_id'];
|
||||
$addnew[0]['id'] = '';
|
||||
$fields = $addnew[0];
|
||||
|
||||
if ($addnew['tid'])
|
||||
{
|
||||
$this->so->add_entry($fields['owner'],$fields,$fields['access'],$fields['cat_id'],$fields['tid']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->so->add_entry($fields['owner'],$fields,$fields['access'],$fields['cat_id']);
|
||||
}
|
||||
|
||||
$ab_id = $this->get_lastid();
|
||||
Header("Location: " . $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.edit&ab_id=$ab_id"));
|
||||
}
|
||||
|
||||
function add_entry()
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$fields = $this->get_form();
|
||||
|
||||
$referer = urlencode($fields['referer']);
|
||||
unset($fields['referer']);
|
||||
|
||||
$this->so->add_entry($phpgw_info['user']['account_id'],$fields,$fields['access'],$fields['cat_id'],$fields['tid']);
|
||||
|
||||
$ab_id = $this->get_lastid();
|
||||
|
||||
Header('Location: '
|
||||
. $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer"));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
function get_lastid()
|
||||
{
|
||||
return $this->so->get_lastid();
|
||||
}
|
||||
|
||||
function update_entry()
|
||||
{
|
||||
global $phpgw,$phpgw_info;
|
||||
|
||||
$fields = $this->get_form();
|
||||
$check = $this->read_entry($fields['ab_id'],array('owner' => 'owner'));
|
||||
|
||||
if (($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $phpgw_info['user']['account_id'])
|
||||
{
|
||||
$userid = $check[0]['owner'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$userid = $phpgw_info['user']['account_id'];
|
||||
}
|
||||
$referer = urlencode($fields['referer']);
|
||||
unset($fields['referer']);
|
||||
|
||||
$this->so->update_entry($fields['ab_id'],$fields['userid'],$fields,$fields['access'],$fields['cat_id'],$fields['tid']);
|
||||
|
||||
Header("Location: "
|
||||
. $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.view&ab_id=" . $fields['ab_id'] . "&referer=$referer"));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
function get_form()
|
||||
{
|
||||
global $entry;
|
||||
/* _debug_array($entry); */
|
||||
|
||||
if (!$entry['bday_month'] && !$entry['bday_day'] && !$entry['bday_year'])
|
||||
{
|
||||
$fields['bday'] = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$bday_day = $entry['bday_day'];
|
||||
if (strlen($bday_day) == 1)
|
||||
{
|
||||
$bday_day = '0' . $entry['bday_day'];
|
||||
}
|
||||
$fields['bday'] = $entry['bday_month'] . '/' . $bday_day . '/' . $entry['bday_year'];
|
||||
}
|
||||
|
||||
if ($entry['url'] == 'http://')
|
||||
{
|
||||
$fields['url'] = '';
|
||||
}
|
||||
|
||||
$fields['org_name'] = $entry['company'];
|
||||
$fields['org_unit'] = $entry['department'];
|
||||
$fields['n_given'] = $entry['firstname'];
|
||||
$fields['n_family'] = $entry['lastname'];
|
||||
$fields['n_middle'] = $entry['middle'];
|
||||
$fields['n_prefix'] = $entry['prefix'];
|
||||
$fields['n_suffix'] = $entry['suffix'];
|
||||
if ($entry['prefix']) { $pspc = ' '; }
|
||||
if ($entry['middle']) { $mspc = ' '; } else { $nspc = ' '; }
|
||||
if ($entry['suffix']) { $sspc = ' '; }
|
||||
$fields['fn'] = $entry['prefix'].$pspc.$entry['firstname'].$nspc.$mspc.$entry['middle'].$mspc.$entry['lastname'].$sspc.$entry['suffix'];
|
||||
$fields['email'] = $entry['email'];
|
||||
$fields['email_type'] = $entry['email_type'];
|
||||
$fields['email_home'] = $entry['hemail'];
|
||||
$fields['email_home_type'] = $entry['hemail_type'];
|
||||
$fields['title'] = $entry['title'];
|
||||
$fields['tel_work'] = $entry['wphone'];
|
||||
$fields['tel_home'] = $entry['hphone'];
|
||||
$fields['tel_fax'] = $entry['fax'];
|
||||
$fields['tel_pager'] = $entry['pager'];
|
||||
$fields['tel_cell'] = $entry['mphone'];
|
||||
$fields['tel_msg'] = $entry['msgphone'];
|
||||
$fields['tel_car'] = $entry['carphone'];
|
||||
$fields['tel_video'] = $entry['vidphone'];
|
||||
$fields['tel_isdn'] = $entry['isdnphone'];
|
||||
$fields['adr_one_street'] = $entry['bstreet'];
|
||||
$fields['adr_one_locality'] = $entry['bcity'];
|
||||
$fields['adr_one_region'] = $entry['bstate'];
|
||||
$fields['adr_one_postalcode'] = $entry['bzip'];
|
||||
$fields['adr_one_countryname'] = $entry['bcountry'];
|
||||
|
||||
if($entry['one_dom'])
|
||||
{
|
||||
$typea .= 'dom;';
|
||||
}
|
||||
if($entry['one_intl'])
|
||||
{
|
||||
$typea .= 'intl;';
|
||||
}
|
||||
if($entry['one_parcel'])
|
||||
{
|
||||
$typea .= 'parcel;';
|
||||
}
|
||||
if($entry['one_postal'])
|
||||
{
|
||||
$typea .= 'postal;';
|
||||
}
|
||||
$fields['adr_one_type'] = substr($typea,0,-1);
|
||||
|
||||
$fields['address2'] = $entry['address2'];
|
||||
$fields['address3'] = $entry['address3'];
|
||||
|
||||
$fields['adr_two_street'] = $entry['hstreet'];
|
||||
$fields['adr_two_locality'] = $entry['hcity'];
|
||||
$fields['adr_two_region'] = $entry['hstate'];
|
||||
$fields['adr_two_postalcode'] = $entry['hzip'];
|
||||
$fields['adr_two_countryname'] = $entry['hcountry'];
|
||||
|
||||
if($entry['two_dom'])
|
||||
{
|
||||
$typeb .= 'dom;';
|
||||
}
|
||||
if($entry['two_intl'])
|
||||
{
|
||||
$typeb .= 'intl;';
|
||||
}
|
||||
if($entry['two_parcel'])
|
||||
{
|
||||
$typeb .= 'parcel;';
|
||||
}
|
||||
if($entry['two_postal'])
|
||||
{
|
||||
$typeb .= 'postal;';
|
||||
}
|
||||
$fields['adr_two_type'] = substr($typeb,0,-1);
|
||||
|
||||
while (list($name,$val) = @each($entry['customfields']))
|
||||
{
|
||||
$fields[$name] = $val;
|
||||
}
|
||||
|
||||
$fields['ophone'] = $entry['ophone'];
|
||||
$fields['tz'] = $entry['timezone'];
|
||||
$fields['pubkey'] = $entry['pubkey'];
|
||||
$fields['note'] = $entry['notes'];
|
||||
$fields['label'] = $entry['label'];
|
||||
|
||||
if ($entry['access'] == True)
|
||||
{
|
||||
$fields['access'] = 'private';
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields['access'] = 'public';
|
||||
}
|
||||
|
||||
if (is_array($entry['cat_id']))
|
||||
{
|
||||
$fields['cat_id'] = count($entry['cat_id']) > 1 ? ','.implode(',',$entry['cat_id']).',' : $entry['cat_id'][0];
|
||||
}
|
||||
else
|
||||
{
|
||||
$fields['cat_id'] = $entry['cat_id'];
|
||||
}
|
||||
|
||||
$fields['ab_id'] = $entry['ab_id'];
|
||||
$fields['tid'] = $entry['tid'];
|
||||
$fields['referer'] = $entry['referer'];
|
||||
/* _debug_array($fields);exit; */
|
||||
return $fields;
|
||||
} /* end get_form() */
|
||||
}
|
||||
?>
|
87
addressbook/inc/class.soaddressbook.inc.php
Normal file
87
addressbook/inc/class.soaddressbook.inc.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - addressbook *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Joseph Engo <jengo@mail.com> *
|
||||
* -------------------------------------------- *
|
||||
* 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;
|
||||
|
||||
function soaddressbook()
|
||||
{
|
||||
global $phpgw,$rights;
|
||||
|
||||
$phpgw->contacts = CreateObject('phpgwapi.contacts');
|
||||
|
||||
$this->contacts = &$phpgw->contacts;
|
||||
$this->rights = $rights;
|
||||
}
|
||||
|
||||
function read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order)
|
||||
{
|
||||
$readrights = $this->rights & PHPGW_ACL_READ;
|
||||
return $this->contacts->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights);
|
||||
}
|
||||
|
||||
function read_entry($id,$fields)
|
||||
{
|
||||
if ($this->rights & PHPGW_ACL_READ)
|
||||
{
|
||||
return $this->contacts->read_single_entry($id,$fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rtrn = array('No access' => 'No access');
|
||||
return $rtrn;
|
||||
}
|
||||
}
|
||||
|
||||
function read_last_entry($fields)
|
||||
{
|
||||
if ($this->rights & PHPGW_ACL_READ)
|
||||
{
|
||||
return $this->contacts->read_last_entry($fields);
|
||||
}
|
||||
else
|
||||
{
|
||||
$rtrn = array('No access' => 'No access');
|
||||
return $rtrn;
|
||||
}
|
||||
}
|
||||
|
||||
function add_entry($userid,$fields,$access='',$cat_id='',$tid='n')
|
||||
{
|
||||
if ($this->rights & PHPGW_ACL_ADD)
|
||||
{
|
||||
$this->contacts->add($userid,$fields,$access,$cat_id,$tid);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
function get_lastid()
|
||||
{
|
||||
$entry = $this->contacts->read_last_entry();
|
||||
$ab_id = $entry[0]['id'];
|
||||
return $ab_id;
|
||||
}
|
||||
|
||||
function update_entry($id,$userid,$fields,$access,$cat_id)
|
||||
{
|
||||
if ($this->rights & PHPGW_ACL_EDIT)
|
||||
{
|
||||
$this->contacts->update($id,$userid,$fields,$access,$cat_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
?>
|
246
addressbook/inc/class.uiXport.inc.php
Normal file
246
addressbook/inc/class.uiXport.inc.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - addressbook *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Joseph Engo <jengo@phpgroupware.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()
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$this->template = &$phpgw->template;
|
||||
$this->cat = CreateObject('phpgwapi.categories');
|
||||
$this->bo = CreateObject('addressbook.boXport',True);
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
/* 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="cat_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()
|
||||
{
|
||||
global $phpgw,$convert,$download,$tsvfilename;
|
||||
|
||||
if ($convert)
|
||||
{
|
||||
$buffer = $this->bo->import();
|
||||
print_r($buffer);
|
||||
|
||||
if ($download == '')
|
||||
{
|
||||
if($conv_type == 'Debug LDAP' || $conv_type == 'Debug SQL' )
|
||||
{
|
||||
// filename, default application/octet-stream, length of file, default nocache True
|
||||
$phpgw->browser->content_header($tsvfilename,'',strlen($buffer));
|
||||
echo $buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
echo "<pre>$buffer</pre>";
|
||||
echo '<a href="'.$phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.get_list') . '">'.lang("OK").'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
echo "<pre>$buffer</pre>";
|
||||
echo '<a href="'.$phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.get_list'). '">'.lang("OK").'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$this->template->set_file(array('import' => 'import.tpl'));
|
||||
|
||||
$dir_handle = opendir(PHPGW_APP_INC . SEP . 'import');
|
||||
$i=0; $myfilearray = '';
|
||||
while ($file = readdir($dir_handle))
|
||||
{
|
||||
//echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."import".$sep.$file)." -->";
|
||||
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++)
|
||||
{
|
||||
$fname = ereg_replace('_',' ',$myfilearray[$i]);
|
||||
$conv .= '<OPTION VALUE="' . $myfilearray[$i].'">' . $fname . '</OPTION>';
|
||||
}
|
||||
|
||||
$this->template->set_var('lang_cancel',lang('Cancel'));
|
||||
$this->template->set_var('lang_cat',lang('Select Category'));
|
||||
$this->template->set_var('cancel_url',$phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.get_list'));
|
||||
$this->template->set_var('navbar_bg',$phpgw_info['theme']['navbar_bg']);
|
||||
$this->template->set_var('navbar_text',$phpgw_info['theme']['navbar_text']);
|
||||
$this->template->set_var('import_text',lang('Import from LDIF, CSV, or VCard'));
|
||||
$this->template->set_var('action_url',$phpgw->link('/addressbook/main.php','menuaction=addressbook.boXport.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->pparse('out','import');
|
||||
}
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
|
||||
function export()
|
||||
{
|
||||
global $phpgw,$phpgw_info,$convert,$tsvfilename;
|
||||
|
||||
if ($convert)
|
||||
{
|
||||
$buffer = $this->bo->export();
|
||||
|
||||
if ($conv_type == 'none')
|
||||
{
|
||||
$phpgw_info['flags']['noheader'] = False;
|
||||
$phpgw_info['flags']['noheader'] = True;
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
echo lang('<b>No conversion type <none> could be located.</b> Please choose a conversion type from the list');
|
||||
echo ' <a href="'.$phpgw->link('/addressbook/main.php','menuaction=addressbook.uiXport.export') . '">'.lang('OK').'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
if ( ($download == 'on') || ($o->type == 'pdb') )
|
||||
{
|
||||
// filename, default application/octet-stream, length of file, default nocache True
|
||||
$phpgw->browser->content_header($tsvfilename,'application/octet-stream',strlen($buffer));
|
||||
echo $buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "<pre>\n";
|
||||
echo $buffer;
|
||||
echo "\n</pre>\n";
|
||||
echo '<a href="'.$phpgw->link('/addressbook/index.php','menuaction=addressbook.uiaddressbook.get_list') . '">'.lang('OK').'</a>';
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
$this->template->set_file(array('export' => 'export.tpl'));
|
||||
|
||||
$dir_handle = opendir(PHPGW_APP_INC. SEP . 'export');
|
||||
$i=0; $myfilearray = '';
|
||||
while ($file = readdir($dir_handle))
|
||||
{
|
||||
#echo "<!-- ".is_file($phpgw_info["server"]["app_root"].$sep."conv".$sep.$file)." -->";
|
||||
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++)
|
||||
{
|
||||
$fname = ereg_replace('_',' ',$myfilearray[$i]);
|
||||
$conv .= ' <option value="'.$myfilearray[$i].'">'.$fname.'</option>'."\n";
|
||||
}
|
||||
|
||||
$this->template->set_var('lang_cancel',lang('Cancel'));
|
||||
$this->template->set_var('lang_cat',lang('Select Category'));
|
||||
$this->template->set_var('cat_link',$this->cat_option($this->cat_id,False,False));
|
||||
$this->template->set_var('cancel_url',$phpgw->link('/addressbook/index.php'));
|
||||
$this->template->set_var('navbar_bg',$phpgw_info['theme']['navbar_bg']);
|
||||
$this->template->set_var('navbar_text',$phpgw_info['theme']['navbar_text']);
|
||||
$this->template->set_var('export_text',lang('Export from Addressbook'));
|
||||
$this->template->set_var('action_url',$phpgw->link('/addressbook/export.php'));
|
||||
$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');
|
||||
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
1300
addressbook/inc/class.uiaddressbook.inc.php
Normal file
1300
addressbook/inc/class.uiaddressbook.inc.php
Normal file
File diff suppressed because it is too large
Load Diff
197
addressbook/inc/class.uivcard.inc.php
Normal file
197
addressbook/inc/class.uivcard.inc.php
Normal file
@ -0,0 +1,197 @@
|
||||
<?php
|
||||
/**************************************************************************\
|
||||
* phpGroupWare - Addressbook *
|
||||
* http://www.phpgroupware.org *
|
||||
* Written by Joseph Engo <jengo@phpgroupware.org> and *
|
||||
* Miles Lott <miloschphpgroupware.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()
|
||||
{
|
||||
global $phpgw;
|
||||
$this->template = &$phpgw->template;
|
||||
$this->contacts = &$phpgw->contacts;
|
||||
$this->browser = CreateObject('phpgwapi.browser');
|
||||
$this->vcard = CreateObject('phpgwapi.vcard');
|
||||
$this->bo = CreateObject('addressbook.boaddressbook',True);
|
||||
}
|
||||
|
||||
function in()
|
||||
{
|
||||
global $phpgw,$phpgw_info,$action;
|
||||
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
|
||||
echo '<body bgcolor="' . $phpgw_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('vcard_header','<p> <b>' . lang('Address book - VCard in') . '</b><hr><p>');
|
||||
$this->template->set_var('action_url',$phpgw->link('/addressbook/main.php','menuaction=addressbook.boaddressbook.add_vcard'));
|
||||
$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');
|
||||
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
|
||||
function out()
|
||||
{
|
||||
global $phpgw,$phpgw_info,$ab_id;
|
||||
|
||||
if ($nolname || $nofname)
|
||||
{
|
||||
$phpgw->common->phpgw_header();
|
||||
echo parse_navbar();
|
||||
}
|
||||
|
||||
if (!$ab_id)
|
||||
{
|
||||
Header('Location: ' . $phpgw->link('/addressbook/index.php'));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
// First, make sure they have permission to this entry
|
||||
$check = $this->bo->read_entry($ab_id,array('owner' => 'owner'));
|
||||
$perms = $this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_READ);
|
||||
|
||||
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
||||
{
|
||||
Header("Location: " . $phpgw->link('/addressbook/main.php','menuaction=addressbook.uiaddressbook.get_list'));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
$extrafields = array('address2' => 'address2');
|
||||
$qfields = $this->contacts->stock_contact_fields + $extrafields;
|
||||
|
||||
$fieldlist = $this->bo->read_entry($ab_id,$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: ' . $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uivcard.out&nolname=1&ab_id=$ab_id"));
|
||||
}
|
||||
if($firstname == '')
|
||||
{
|
||||
Header('Location: ' . $phpgw->link('/addressbook/main.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;
|
||||
$phpgw->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="' . $phpgw->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="' . $phpgw->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)
|
||||
{
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,244 +0,0 @@
|
||||
/**************************************************************************\
|
||||
* phpGroupWare API - Contacts class documentation *
|
||||
* This file written by Miles Lott <milosch@phpgroupware.org> *
|
||||
* -------------------------------------------------------------------------*
|
||||
* 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$ */
|
||||
|
||||
|
||||
Starting with the most cumbersome function:
|
||||
|
||||
function read($start,$offset,$fields,$query="",$filter="",$sort="",$order="")
|
||||
|
||||
Purpose:
|
||||
Returns a list of contacts based on limits, query, and filter,
|
||||
in an array of name/values, e.g.:
|
||||
|
||||
$fields[0]["id"] => "354",
|
||||
$fields[0]["email"] => "name@domain.com", ...
|
||||
|
||||
$fields[1]["id"] => "355",
|
||||
$fields[1]["email"] => "othername@otherdomain.com", ...
|
||||
|
||||
Inputs:
|
||||
|
||||
$start = start of list, e.g. 1,16,31
|
||||
$offset = numrows, e.g. 15,30,etc. from nextmatchs, usually
|
||||
$fields = simple array of fields to return:
|
||||
|
||||
$qfields = array(
|
||||
'id' => 'id',
|
||||
'n_given' => 'n_given
|
||||
);
|
||||
|
||||
$query = simple string to search for, e.g. "milosch" or "555"
|
||||
|
||||
$filter = for 'accounting' fields other than id (use read_single_entry for
|
||||
that):
|
||||
|
||||
owner = account_id of record owner
|
||||
access = public/private
|
||||
cat_id = category id for the record
|
||||
lid = account_lid for account records stored here, if any
|
||||
tid = type id:
|
||||
n = normal contact - almost always use this
|
||||
p = profiles for hr, tied to account records
|
||||
u = user account, if stored in contacts class
|
||||
g = group account, ""
|
||||
|
||||
Filters should be in the format:
|
||||
|
||||
example 1: 'tid=n' filter for normal contacts
|
||||
example 2: 'tid=u,lid=milosch' filter user accounts for lid
|
||||
'milosch'
|
||||
etc...
|
||||
|
||||
$sort = ASC, DESC, or "" (defaults to ASC)
|
||||
|
||||
$order = sort on this field, e.g. n_given
|
||||
|
||||
|
||||
function read_single_entry($id,$fields)
|
||||
|
||||
Purpose:
|
||||
returns a single array of name/value based on id
|
||||
and field selection, e.g.:
|
||||
|
||||
$fields[0]["email"] => "name@domain.com"
|
||||
$fields[0]["n_given"] => "Bob"
|
||||
|
||||
Inputs:
|
||||
|
||||
$id = id of entry you want to return
|
||||
|
||||
$fields = simple array of fields to return
|
||||
|
||||
$qfields = array(
|
||||
'id' => 'id',
|
||||
'n_given' => 'n_given
|
||||
);
|
||||
|
||||
|
||||
function add($owner,$fields,$access='',$cat_id='',$tid='n')
|
||||
|
||||
Purpose:
|
||||
|
||||
Add a new contact record of the type, category and access sent
|
||||
with a field list.
|
||||
|
||||
Inputs:
|
||||
|
||||
$owner = id of user adding this data
|
||||
|
||||
$fields = simple array of fields to write into the new record
|
||||
|
||||
$access = public/private
|
||||
|
||||
$cat_id = category id for the record, if desired
|
||||
|
||||
$tid = type id ( see read() above ), defaults to 'n'
|
||||
|
||||
|
||||
function update($id,$owner,$fields,$access='',$cat_id='',$tid='')
|
||||
|
||||
Purpose:
|
||||
|
||||
Update an entry already in the contacts list
|
||||
|
||||
Inputs:
|
||||
|
||||
$id = id of entry you want to update
|
||||
|
||||
$owner = id of user modifying this data
|
||||
|
||||
$fields = simple array of fields to update in the record
|
||||
(see examples above)
|
||||
|
||||
$access = public/private
|
||||
|
||||
$cat_id = category id for the record, if desired
|
||||
|
||||
|
||||
$tid = type id ( see read() above ), defaults to 'n'
|
||||
|
||||
|
||||
function delete_($id)
|
||||
|
||||
Purpose:
|
||||
|
||||
Delete an entry already in the contacts list
|
||||
|
||||
Inputs:
|
||||
|
||||
$id = id of entry you want to delete
|
||||
|
||||
|
||||
Stock contact fields, other than accounting fields mentioned above:
|
||||
|
||||
$this->stock_contact_fields = array(
|
||||
"fn" => "fn", // 'prefix given middle family suffix'
|
||||
"n_given" => "n_given", // firstname
|
||||
"n_family" => "n_family", // lastname
|
||||
"n_middle" => "n_middle",
|
||||
"n_prefix" => "n_prefix",
|
||||
"n_suffix" => "n_suffix",
|
||||
"sound" => "sound",
|
||||
"bday" => "bday", // Birthday (12/31/1969)
|
||||
"note" => "note", // Note, description, etc.
|
||||
"tz" => "tz", // Hours offset from phpgw install
|
||||
"geo" => "geo", // Not used
|
||||
"url" => "url",
|
||||
"pubkey" => "pubkey", // Similar to note, but for public encryption key
|
||||
|
||||
"org_name" => "org_name", // company
|
||||
"org_unit" => "org_unit", // division
|
||||
"title" => "title",
|
||||
|
||||
"adr_one_street" => "adr_one_street", // Business address entry
|
||||
"adr_one_locality" => "adr_one_locality",
|
||||
"adr_one_region" => "adr_one_region",
|
||||
"adr_one_postalcode" => "adr_one_postalcode",
|
||||
"adr_one_countryname" => "adr_one_countryname",
|
||||
"adr_one_type" => "adr_one_type", // address is domestic/intl/postal/parcel/work/home
|
||||
"label" => "label", // address label
|
||||
|
||||
"adr_two_street" => "adr_two_street", // Home address entry
|
||||
"adr_two_locality" => "adr_two_locality",
|
||||
"adr_two_region" => "adr_two_region",
|
||||
"adr_two_postalcode" => "adr_two_postalcode",
|
||||
"adr_two_countryname" => "adr_two_countryname",
|
||||
"adr_two_type" => "adr_two_type", // address is domestic/intl/postal/parcel/work/home
|
||||
|
||||
"tel_work" => "tel_work",
|
||||
"tel_home" => "tel_home",
|
||||
"tel_voice" => "tel_voice",
|
||||
"tel_fax" => "tel_fax",
|
||||
"tel_msg" => "tel_msg",
|
||||
"tel_cell" => "tel_cell",
|
||||
"tel_pager" => "tel_pager",
|
||||
"tel_bbs" => "tel_bbs",
|
||||
"tel_modem" => "tel_modem",
|
||||
"tel_car" => "tel_car",
|
||||
"tel_isdn" => "tel_isdn",
|
||||
"tel_video" => "tel_video",
|
||||
"tel_prefer" => "tel_prefer", // home;work;voice
|
||||
"email" => "email",
|
||||
"email_type" => "email_type", //'INTERNET','CompuServe',etc...
|
||||
"email_home" => "email_home",
|
||||
"email_home_type" => "email_home_type" //'INTERNET','CompuServe',etc...
|
||||
);
|
||||
|
||||
Other useful arrays for setting option dialogs, etc.
|
||||
|
||||
// Used to set adr_one_type/adr_two_type, e.g. 'intl;work'
|
||||
$this->adr_types = array(
|
||||
"dom" => lang("Domestic"),
|
||||
"intl" => lang("International"),
|
||||
"parcel" => lang("Parcel"),
|
||||
"postal" => lang("Postal")
|
||||
);
|
||||
|
||||
// Used to set preferred number field, e.g. 'cell' or 'work'
|
||||
$this->tel_types = array(
|
||||
"work" => "work",
|
||||
"home" => "home",
|
||||
"voice" => "voice",
|
||||
"fax" => "fax",
|
||||
"msg" => "msg",
|
||||
"cell" => "cell",
|
||||
"pager" => "pager",
|
||||
"bbs" => "bbs",
|
||||
"modem" => "modem",
|
||||
"car" => "car",
|
||||
"isdn" => "isdn",
|
||||
"video" => "video"
|
||||
);
|
||||
|
||||
$this->email_types = array(
|
||||
"INTERNET" => "INTERNET",
|
||||
"CompuServe" => "CompuServe",
|
||||
"AOL" => "AOL",
|
||||
"Prodigy" => "Prodigy",
|
||||
"eWorld" => "eWorld",
|
||||
"AppleLink" => "AppleLink",
|
||||
"AppleTalk" => "AppleTalk",
|
||||
"PowerShare" => "PowerShare",
|
||||
"IBMMail" => "IBMMail",
|
||||
"ATTMail" => "ATTMail",
|
||||
"MCIMail" => "MCIMail",
|
||||
"X.400" => "X.400",
|
||||
"TLX" => "TLX"
|
||||
);
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user