2000-08-18 05:24:22 +02:00
|
|
|
<?php
|
2001-02-10 13:56:49 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* 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$ */
|
|
|
|
|
2001-03-24 12:11:45 +01:00
|
|
|
// I don't think this is needed anymore
|
|
|
|
|
2001-02-18 14:41:24 +01:00
|
|
|
// Perform acl check, set $rights
|
2001-03-24 22:54:31 +01:00
|
|
|
|
2001-02-18 14:41:24 +01:00
|
|
|
if(!isset($owner)) { $owner = 0; }
|
2001-02-10 13:56:49 +01:00
|
|
|
|
2001-02-18 14:41:24 +01:00
|
|
|
$grants = $phpgw->acl->get_grants('addressbook');
|
2001-03-24 22:54:31 +01:00
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if(!isset($owner) || !$owner)
|
|
|
|
{
|
2001-02-18 14:41:24 +01:00
|
|
|
$owner = $phpgw_info['user']['account_id'];
|
|
|
|
$rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($grants[$owner])
|
|
|
|
{
|
2001-02-18 14:41:24 +01:00
|
|
|
$rights = $grants[$owner];
|
2001-05-06 18:43:45 +02:00
|
|
|
if (!($rights & PHPGW_ACL_READ))
|
|
|
|
{
|
2001-02-18 14:41:24 +01:00
|
|
|
$owner = $phpgw_info['user']['account_id'];
|
|
|
|
$rights = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-21 16:51:25 +02:00
|
|
|
function read_custom_fields($start='',$limit='',$query='',$sort='ASC')
|
|
|
|
{
|
|
|
|
global $phpgw,$phpgw_info;
|
|
|
|
$phpgw->preferences->read_repository($phpgw_info['user']['account_id']);
|
|
|
|
|
|
|
|
$i=0;$j=0;
|
2001-04-23 09:13:57 +02:00
|
|
|
while (list($col,$descr) = @each($phpgw_info["user"]["preferences"]["addressbook"]))
|
2001-04-21 16:51:25 +02:00
|
|
|
{
|
|
|
|
if ( substr($col,0,6) == 'extra_' )
|
|
|
|
{
|
|
|
|
$fields[$j]['name'] = ereg_replace('extra_','',$col);
|
|
|
|
$fields[$j]['name'] = ereg_replace(' ','_',$fields[$j]['name']);
|
|
|
|
$fields[$j]['id'] = $i;
|
|
|
|
|
|
|
|
if ($query && ($fields[$j]['name'] != $query))
|
|
|
|
{
|
|
|
|
unset($fields[$j]['name']);
|
|
|
|
unset($fields[$j]['id']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//echo "<br>".$j.": '".$fields[$j]['name']."'";
|
|
|
|
$j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
return $fields;
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_custom_field($old='',$new='')
|
|
|
|
{
|
|
|
|
global $phpgw,$phpgw_info;
|
|
|
|
|
|
|
|
$phpgw->preferences->read_repository($phpgw_info['user']['account_id']);
|
|
|
|
if ($old)
|
|
|
|
{
|
|
|
|
$phpgw->preferences->delete("addressbook","extra_".$old);
|
|
|
|
}
|
|
|
|
if($new)
|
|
|
|
{
|
|
|
|
$phpgw->preferences->add("addressbook","extra_".$new);
|
|
|
|
}
|
|
|
|
$phpgw->preferences->save_repository(1);
|
|
|
|
}
|
|
|
|
|
2001-03-28 14:53:39 +02:00
|
|
|
// Return a select form element with the categories option dialog in it
|
2001-05-23 22:16:19 +02:00
|
|
|
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False) {
|
2001-03-25 07:41:06 +02:00
|
|
|
global $phpgw_info;
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($java)
|
|
|
|
{
|
2001-04-17 11:30:08 +02:00
|
|
|
$jselect = ' onChange="this.form.submit();"';
|
2001-03-28 14:53:39 +02:00
|
|
|
}
|
2001-03-25 08:02:52 +02:00
|
|
|
// Setup all and none first
|
2001-05-23 22:16:19 +02:00
|
|
|
$cats_link = "\n" .'<select name="cat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple size="3"' : '') . ">\n";
|
2001-05-06 18:43:45 +02:00
|
|
|
if (!$notall)
|
|
|
|
{
|
2001-04-17 11:30:08 +02:00
|
|
|
$cats_link .= '<option value=""';
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($cat_id=="all")
|
|
|
|
{
|
2001-04-17 11:30:08 +02:00
|
|
|
$cats_link .= ' selected';
|
2001-03-25 08:07:00 +02:00
|
|
|
}
|
2001-04-17 11:30:08 +02:00
|
|
|
$cats_link .= '>'.lang("all").'</option>'."\n";
|
2001-03-25 08:02:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get global and app-specific category listings
|
2001-03-25 07:41:06 +02:00
|
|
|
$cats = CreateObject('phpgwapi.categories');
|
2001-03-25 11:07:58 +02:00
|
|
|
$cats_link .= $cats->formated_list('select','all',$cat_id,True);
|
2001-03-29 17:40:10 +02:00
|
|
|
$cats_link .= '</select>'."\n";
|
2001-03-25 07:41:06 +02:00
|
|
|
return $cats_link;
|
|
|
|
}
|
|
|
|
|
|
|
|
### SET THE FONT TO DEFAULT IF IT DOESNT EXISTS ###
|
2001-05-06 18:43:45 +02:00
|
|
|
function set_font()
|
|
|
|
{
|
|
|
|
if($phpgw_info["user"]["preferences"]["notes"]["notes_font"] == "")
|
|
|
|
{
|
2001-03-25 07:41:06 +02:00
|
|
|
$font = "Arial";
|
|
|
|
return $font;
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-25 07:41:06 +02:00
|
|
|
$font = $phpgw_info["user"]["preferences"]["notes"]["notes_font"];
|
|
|
|
return $font;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
### SET FONT SIZE ####
|
2001-05-06 18:43:45 +02:00
|
|
|
function set_font_size()
|
|
|
|
{
|
2001-03-25 07:41:06 +02:00
|
|
|
if($phpgw_info["user"]["preferences"]["notes"]["notes_font_size"] == "") {
|
|
|
|
$font_size = "3";
|
|
|
|
return $font_size;
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-25 07:41:06 +02:00
|
|
|
$font_size = $phpgw_info["user"]["preferences"]["notes"]["notes_font_size"];
|
|
|
|
return $font_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-18 14:41:24 +01:00
|
|
|
// this cleans up the fieldnames for display
|
2001-05-06 18:43:45 +02:00
|
|
|
function display_name($column)
|
|
|
|
{
|
2001-02-18 14:41:24 +01:00
|
|
|
$abc = array(
|
2001-05-06 18:43:45 +02:00
|
|
|
'fn' => 'full name',
|
|
|
|
'sound' => 'Sound',
|
|
|
|
'org_name' => 'company name',
|
|
|
|
'org_unit' => 'department',
|
|
|
|
'title' => 'title',
|
|
|
|
'n_prefix' => 'prefix',
|
|
|
|
'n_given' => 'first name',
|
|
|
|
'n_middle' => 'middle name',
|
|
|
|
'n_family' => 'last name',
|
|
|
|
'n_suffix' => 'suffix',
|
|
|
|
'label' => 'label',
|
|
|
|
'adr_one_street' => 'business street',
|
|
|
|
'adr_one_locality' => 'business city',
|
|
|
|
'adr_one_region' => 'business state',
|
|
|
|
'adr_one_postalcode' => 'business zip code',
|
|
|
|
'adr_one_countryname' => 'business country',
|
|
|
|
'adr_one_type' => 'business address type',
|
|
|
|
'adr_two_street' => 'home street',
|
|
|
|
'adr_two_locality' => 'home city',
|
|
|
|
'adr_two_region' => 'home state',
|
|
|
|
'adr_two_postalcode' => 'home zip code',
|
|
|
|
'adr_two_countryname' => 'home country',
|
|
|
|
'adr_two_type' => 'home address type',
|
|
|
|
'tz' => 'time zone',
|
|
|
|
'geo' => 'geo',
|
|
|
|
'tel_work' => 'business phone',
|
|
|
|
'tel_home' => 'home phone',
|
|
|
|
'tel_voice' => 'voice phone',
|
|
|
|
'tel_msg' => 'message phone',
|
|
|
|
'tel_fax' => 'fax',
|
|
|
|
'tel_pager' => 'pager',
|
|
|
|
'tel_cell' => 'mobile phone',
|
|
|
|
'tel_bbs' => 'bbs phone',
|
|
|
|
'tel_modem' => 'modem phone',
|
|
|
|
'tel_isdn' => 'isdn phone',
|
|
|
|
'tel_car' => 'car phone',
|
|
|
|
'tel_video' => 'video phone',
|
|
|
|
|
|
|
|
'tel_prefer' => 'preferred phone',
|
|
|
|
'email' => 'business email',
|
|
|
|
'email_type' => 'business email type',
|
|
|
|
'email_home' => 'home email',
|
|
|
|
'email_home_type' => 'home email type',
|
|
|
|
'address2' => 'address line 2',
|
|
|
|
'address3' => 'address line 3',
|
|
|
|
'ophone' => 'Other Phone',
|
|
|
|
'bday' => 'birthday',
|
|
|
|
'url' => 'url',
|
|
|
|
'pubkey' => 'public key',
|
|
|
|
'note' => 'notes'
|
2001-02-18 14:41:24 +01:00
|
|
|
);
|
2001-05-06 18:43:45 +02:00
|
|
|
|
|
|
|
if ($abc[$column])
|
|
|
|
{
|
|
|
|
return lang($abc[$column]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return;
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
}
|
2001-02-14 01:56:07 +01:00
|
|
|
|
2001-05-31 12:11:18 +02:00
|
|
|
function addressbook_strip_html($dirty = "")
|
2001-04-04 03:59:24 +02:00
|
|
|
{
|
|
|
|
global $phpgw;
|
2001-05-31 12:11:18 +02:00
|
|
|
if ($dirty == ""){$dirty = array();}
|
2001-04-04 03:59:24 +02:00
|
|
|
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 addressbook_read_entries($start,$offset,$qcols,$query,$qfilter,$sort,$order,$userid="")
|
|
|
|
{
|
2001-02-15 18:21:38 +01:00
|
|
|
global $this,$rights;
|
|
|
|
$readrights = $rights & PHPGW_ACL_READ;
|
|
|
|
$entries = $this->read($start,$offset,$qcols,$query,$qfilter,$sort,$order,$readrights);
|
2001-04-04 03:59:24 +02:00
|
|
|
$cleaned = addressbook_strip_html($entries);
|
|
|
|
return $cleaned;
|
2001-02-14 01:56:07 +01:00
|
|
|
}
|
|
|
|
|
2001-04-04 03:59:24 +02:00
|
|
|
function addressbook_read_entry($id,$fields,$userid="")
|
|
|
|
{
|
2001-02-15 18:21:38 +01:00
|
|
|
global $this,$rights;
|
2001-04-04 03:59:24 +02:00
|
|
|
if ($rights & PHPGW_ACL_READ)
|
|
|
|
{
|
2001-02-15 18:21:38 +01:00
|
|
|
$entry = $this->read_single_entry($id,$fields);
|
2001-04-04 03:59:24 +02:00
|
|
|
$cleaned = addressbook_strip_html($entry);
|
|
|
|
return $cleaned;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-19 04:34:59 +01:00
|
|
|
$rtrn = array("No access" => "No access");
|
|
|
|
return $rtrn;
|
|
|
|
}
|
2001-02-14 01:56:07 +01:00
|
|
|
}
|
|
|
|
|
2001-04-04 03:59:24 +02:00
|
|
|
function addressbook_read_last_entry($fields)
|
|
|
|
{
|
2001-03-18 03:46:50 +01:00
|
|
|
global $this,$rights;
|
2001-04-04 03:59:24 +02:00
|
|
|
if ($rights & PHPGW_ACL_READ)
|
|
|
|
{
|
2001-03-18 03:46:50 +01:00
|
|
|
$entry = $this->read_last_entry($fields);
|
2001-04-04 03:59:24 +02:00
|
|
|
$cleaned = addressbook_strip_html($entry);
|
|
|
|
return $cleaned;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-18 03:46:50 +01:00
|
|
|
$rtrn = array("No access" => "No access");
|
|
|
|
return $rtrn;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-04-04 03:59:24 +02:00
|
|
|
function addressbook_add_entry($userid,$fields,$access='',$cat_id='',$tid='n')
|
|
|
|
{
|
2001-02-15 18:21:38 +01:00
|
|
|
global $this,$rights;
|
2001-04-04 03:59:24 +02:00
|
|
|
if ($rights & PHPGW_ACL_ADD)
|
|
|
|
{
|
2001-03-27 15:11:23 +02:00
|
|
|
$this->add($userid,$fields,$access,$cat_id,$tid);
|
2001-02-19 04:34:59 +01:00
|
|
|
}
|
2001-02-14 01:56:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-04-04 03:59:24 +02:00
|
|
|
function addressbook_get_lastid()
|
|
|
|
{
|
2001-02-19 04:34:59 +01:00
|
|
|
global $this;
|
|
|
|
$entry = $this->read_last_entry();
|
|
|
|
$ab_id = $entry[0]["id"];
|
|
|
|
return $ab_id;
|
|
|
|
}
|
2001-03-27 23:20:56 +02:00
|
|
|
|
2001-05-22 00:31:31 +02:00
|
|
|
function addressbook_update_entry($id,$userid,$fields,$access,$cat_id)
|
2001-04-04 03:59:24 +02:00
|
|
|
{
|
2001-02-15 18:21:38 +01:00
|
|
|
global $this,$rights;
|
2001-04-04 03:59:24 +02:00
|
|
|
if ($rights & PHPGW_ACL_EDIT)
|
|
|
|
{
|
2001-05-22 00:31:31 +02:00
|
|
|
$this->update($id,$userid,$fields,$access,$cat_id);
|
2001-02-19 04:34:59 +01:00
|
|
|
}
|
2001-02-14 01:56:07 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-03-16 18:56:18 +01:00
|
|
|
// Folowing used for add/edit
|
2001-04-04 03:59:24 +02:00
|
|
|
function addressbook_form($format,$action,$title="",$fields="",$customfields="",$cat_id="")
|
|
|
|
{
|
2001-05-22 00:31:31 +02:00
|
|
|
global $phpgw,$phpgw_info,$referer;
|
2001-05-01 11:32:52 +02:00
|
|
|
|
2001-05-10 15:05:30 +02:00
|
|
|
$t = new Template(PHPGW_APP_TPL);
|
|
|
|
$t->set_file(array('form' => 'form.tpl'));
|
2001-05-11 16:01:06 +02:00
|
|
|
//$t->set_block('form','add','add');
|
|
|
|
//$t->set_block('form','edit','edit');
|
2001-05-10 20:09:15 +02:00
|
|
|
|
2001-06-22 01:40:09 +02:00
|
|
|
$countrylist = $phpgw_info['server']['countrylist'];
|
2001-05-22 00:31:31 +02:00
|
|
|
|
2001-05-10 15:05:30 +02:00
|
|
|
$email = $fields['email'];
|
|
|
|
$emailtype = $fields['email_type'];
|
|
|
|
$hemail = $fields['email_home'];
|
|
|
|
$hemailtype = $fields['email_home_type'];
|
|
|
|
$firstname = $fields['n_given'];
|
|
|
|
$middle = $fields['n_middle'];
|
|
|
|
$prefix = $fields['n_prefix'];
|
|
|
|
$suffix = $fields['n_suffix'];
|
|
|
|
$lastname = $fields['n_family'];
|
|
|
|
$title = $fields['title'];
|
|
|
|
$wphone = $fields['tel_work'];
|
|
|
|
$hphone = $fields['tel_home'];
|
|
|
|
$fax = $fields['tel_fax'];
|
|
|
|
$pager = $fields['tel_pager'];
|
|
|
|
$mphone = $fields['tel_cell'];
|
|
|
|
$ophone = $fields['ophone'];
|
|
|
|
$msgphone = $fields['tel_msg'];
|
|
|
|
$isdnphone = $fields['tel_isdn'];
|
|
|
|
$carphone = $fields['tel_car'];
|
|
|
|
$vidphone = $fields['tel_video'];
|
|
|
|
$preferred = $fields['tel_prefer'];
|
|
|
|
|
|
|
|
$bstreet = $fields['adr_one_street'];
|
|
|
|
$address2 = $fields['address2'];
|
|
|
|
$address3 = $fields['address3'];
|
|
|
|
$bcity = $fields['adr_one_locality'];
|
|
|
|
$bstate = $fields['adr_one_region'];
|
|
|
|
$bzip = $fields['adr_one_postalcode'];
|
|
|
|
$bcountry = $fields['adr_one_countryname'];
|
|
|
|
$one_dom = $fields['one_dom'];
|
|
|
|
$one_intl = $fields['one_intl'];
|
|
|
|
$one_parcel = $fields['one_parcel'];
|
|
|
|
$one_postal = $fields['one_postal'];
|
|
|
|
|
|
|
|
$hstreet = $fields['adr_two_street'];
|
|
|
|
$hcity = $fields['adr_two_locality'];
|
|
|
|
$hstate = $fields['adr_two_region'];
|
|
|
|
$hzip = $fields['adr_two_postalcode'];
|
|
|
|
$hcountry = $fields['adr_two_countryname'];
|
|
|
|
$btype = $fields['adr_two_type'];
|
|
|
|
$two_dom = $fields['two_dom'];
|
|
|
|
$two_intl = $fields['two_intl'];
|
|
|
|
$two_parcel = $fields['two_parcel'];
|
|
|
|
$two_postal = $fields['two_postal'];
|
|
|
|
|
|
|
|
$timezone = $fields['tz'];
|
|
|
|
$bday = $fields['bday'];
|
|
|
|
$notes = stripslashes($fields['note']);
|
|
|
|
$label = stripslashes($fields['label']);
|
|
|
|
$company = $fields['org_name'];
|
|
|
|
$department = $fields['org_unit'];
|
|
|
|
$url = $fields['url'];
|
|
|
|
$pubkey = $fields['pubkey'];
|
|
|
|
$access = $fields['access'];
|
2001-03-25 11:07:58 +02:00
|
|
|
if(!$cat_id) {
|
2001-05-10 15:05:30 +02:00
|
|
|
$cat_id = $fields['cat_id'];
|
2001-03-25 11:07:58 +02:00
|
|
|
}
|
2001-05-23 22:16:19 +02:00
|
|
|
// allow multiple categories on 'sql'
|
|
|
|
$cats_link = cat_option($cat_id,True,False,!$phpgw_info["server"]["contact_repository"] ||
|
|
|
|
$phpgw_info["server"]["contact_repository"] == 'sql');
|
2001-03-24 22:54:31 +01:00
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($access == 'private')
|
|
|
|
{
|
2001-03-24 22:54:31 +01:00
|
|
|
$access_check = ' checked';
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-24 22:54:31 +01:00
|
|
|
$access_check = '';
|
|
|
|
}
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($customfields)
|
|
|
|
{
|
|
|
|
while(list($name,$value) = each($customfields))
|
|
|
|
{
|
2001-03-16 18:56:18 +01:00
|
|
|
$custom .= '
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
|
|
|
<td><font color="#000000" face="" size="-1">'.$value.':</font></td>
|
|
|
|
<td>
|
|
|
|
<font size="-1">
|
2001-04-27 16:30:06 +02:00
|
|
|
<INPUT size="30" name="' . $name . '" value="' . $fields[$name] . '">
|
2001-03-16 18:56:18 +01:00
|
|
|
</font></td>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-16 02:31:25 +01:00
|
|
|
$this = CreateObject("phpgwapi.contacts");
|
2001-02-10 13:56:49 +01:00
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($format != "view")
|
|
|
|
{
|
2001-03-18 18:22:17 +01:00
|
|
|
// Preferred phone number radio buttons
|
|
|
|
$pref[0] = "<font size=\"-2\">";
|
|
|
|
$pref[1] = "(".lang('pref').")</font>";
|
2001-05-06 18:43:45 +02:00
|
|
|
while (list($name,$val) = each($this->tel_types))
|
|
|
|
{
|
2001-03-18 18:22:17 +01:00
|
|
|
$str[$name] = "\n".' <input type="radio" name="tel_prefer" value="'.$name.'"';
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($name == $preferred)
|
|
|
|
{
|
2001-03-16 02:31:25 +01:00
|
|
|
$str[$name] .= ' checked';
|
|
|
|
}
|
|
|
|
$str[$name] .= '>';
|
2001-03-18 18:22:17 +01:00
|
|
|
$str[$name] = $pref[0].$str[$name].$pref[1];
|
|
|
|
$t->set_var("pref_".$name,$str[$name]);
|
2001-03-16 02:31:25 +01:00
|
|
|
}
|
2000-08-18 05:24:22 +02:00
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if (strlen($bday) > 2)
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
list( $month, $day, $year ) = split( '/', $bday );
|
|
|
|
$temp_month[$month] = "SELECTED";
|
|
|
|
$bday_month = "<select name=bday_month>"
|
2001-05-06 18:43:45 +02:00
|
|
|
. "<option value=\"\" $temp_month[0]> </option>"
|
2001-05-10 15:05:30 +02:00
|
|
|
. "<option value=1 $temp_month[1]>" . lang('january') . "</option>"
|
|
|
|
. "<option value=2 $temp_month[2]>" . lang('february') . "</option>"
|
|
|
|
. "<option value=3 $temp_month[3]>" . lang('march') . "</option>"
|
|
|
|
. "<option value=4 $temp_month[4]>" . lang('april') . "</option>"
|
|
|
|
. "<option value=5 $temp_month[5]>" . lang('may') . "</option>"
|
|
|
|
. "<option value=6 $temp_month[6]>" . lang('june') . "</option>"
|
|
|
|
. "<option value=7 $temp_month[7]>" . lang('july') . "</option>"
|
|
|
|
. "<option value=8 $temp_month[8]>" . lang('august') . "</option>"
|
|
|
|
. "<option value=9 $temp_month[9]>" . lang('september') . "</option>"
|
|
|
|
. "<option value=10 $temp_month[10]>" . lang('october') . "</option>"
|
|
|
|
. "<option value=11 $temp_month[11]>" . lang('november') . "</option>"
|
|
|
|
. "<option value=12 $temp_month[12]>" . lang('december') . "</option>"
|
2001-05-06 18:43:45 +02:00
|
|
|
. "</select>";
|
2001-02-10 13:56:49 +01:00
|
|
|
$bday_day = '<input maxlength="2" name="bday_day" value="' . $day . '" size="2">';
|
|
|
|
$bday_year = '<input maxlength="4" name="bday_year" value="' . $year . '" size="4">';
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$bday_month = "<select name=bday_month>"
|
2001-05-06 18:43:45 +02:00
|
|
|
. "<option value=\"\" SELECTED> </option>"
|
2001-05-10 15:05:30 +02:00
|
|
|
. "<option value=1>" . lang('january') . "</option>"
|
|
|
|
. "<option value=2>" . lang('february') . "</option>"
|
|
|
|
. "<option value=3>" . lang('march') . "</option>"
|
|
|
|
. "<option value=4>" . lang('april') . "</option>"
|
|
|
|
. "<option value=5>" . lang('may') . "</option>"
|
|
|
|
. "<option value=6>" . lang('june') . "</option>"
|
|
|
|
. "<option value=7>" . lang('july') . "</option>"
|
|
|
|
. "<option value=8>" . lang('august') . "</option>"
|
|
|
|
. "<option value=9>" . lang('september') . "</option>"
|
|
|
|
. "<option value=10>" . lang('october') . "</option>"
|
|
|
|
. "<option value=11>" . lang('november') . "</option>"
|
|
|
|
. "<option value=12>" . lang('december') . "</option>"
|
2001-05-06 18:43:45 +02:00
|
|
|
. "</select>";
|
2001-02-10 13:56:49 +01:00
|
|
|
$bday_day = '<input name="bday_day" size="2" maxlength="2">';
|
|
|
|
$bday_year = '<input name="bday_year" size="4" maxlength="4">';
|
|
|
|
}
|
|
|
|
|
|
|
|
$time_zone = "<select name=\"timezone\">\n";
|
2001-05-06 18:43:45 +02:00
|
|
|
for ($i = -23; $i<24; $i++)
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$time_zone .= "<option value=\"$i\"";
|
|
|
|
if ($i == $timezone)
|
2001-05-06 18:43:45 +02:00
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$time_zone .= " selected";
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
2001-02-10 13:56:49 +01:00
|
|
|
if ($i < 1)
|
2001-05-06 18:43:45 +02:00
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$time_zone .= ">$i</option>\n";
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
2001-02-10 13:56:49 +01:00
|
|
|
else
|
2001-05-06 18:43:45 +02:00
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$time_zone .= ">+$i</option>\n";
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
$time_zone .= "</select>\n";
|
|
|
|
|
|
|
|
$email_type = '<select name=email_type>';
|
2001-05-06 18:43:45 +02:00
|
|
|
while ($type = each($this->email_types))
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$email_type .= '<option value="'.$type[0].'"';
|
|
|
|
if ($type[0] == $emailtype) { $email_type .= ' selected'; }
|
2001-05-06 18:43:45 +02:00
|
|
|
$email_type .= '>'.$type[1].'</option>';
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
$email_type .= "</select>";
|
2001-03-16 02:31:25 +01:00
|
|
|
|
|
|
|
reset($this->email_types);
|
2001-05-01 11:32:52 +02:00
|
|
|
$hemail_type = '<select name=hemail_type>';
|
2001-05-06 18:43:45 +02:00
|
|
|
while ($type = each($this->email_types))
|
|
|
|
{
|
2001-03-16 02:31:25 +01:00
|
|
|
$hemail_type .= '<option value="'.$type[0].'"';
|
|
|
|
if ($type[0] == $hemailtype) { $hemail_type .= ' selected'; }
|
2001-05-06 18:43:45 +02:00
|
|
|
$hemail_type .= '>'.$type[1].'</option>';
|
2001-03-16 02:31:25 +01:00
|
|
|
}
|
|
|
|
$hemail_type .= "</select>";
|
|
|
|
|
|
|
|
reset($this->adr_types);
|
2001-05-06 18:43:45 +02:00
|
|
|
while (list($type,$val) = each($this->adr_types))
|
|
|
|
{
|
2001-03-16 02:31:25 +01:00
|
|
|
$badrtype .= "\n".'<INPUT type="checkbox" name="one_'.$type.'"';
|
|
|
|
$ot = 'one_'.$type;
|
|
|
|
eval("
|
|
|
|
if (\$$ot=='on') {
|
|
|
|
\$badrtype \.= ' value=\"on\" checked';
|
|
|
|
}
|
|
|
|
");
|
|
|
|
$badrtype .= '>'.$val;
|
|
|
|
}
|
|
|
|
|
|
|
|
reset($this->adr_types);
|
2001-05-06 18:43:45 +02:00
|
|
|
while (list($type,$val) = each($this->adr_types))
|
|
|
|
{
|
2001-03-16 02:31:25 +01:00
|
|
|
$hadrtype .= "\n".'<INPUT type="checkbox" name="two_'.$type.'"';
|
|
|
|
$tt = 'two_'.$type;
|
|
|
|
eval("
|
|
|
|
if (\$$tt=='on') {
|
|
|
|
\$hadrtype \.= ' value=\"on\" checked';
|
|
|
|
}
|
|
|
|
");
|
|
|
|
$hadrtype .= '>'.$val;
|
|
|
|
}
|
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
$notes = '<TEXTAREA cols="60" name="notes" rows="4">' . $notes . '</TEXTAREA>';
|
|
|
|
$label = '<TEXTAREA cols="60" name="label" rows="6">' . $label . '</TEXTAREA>';
|
|
|
|
$pubkey = '<TEXTAREA cols="60" name="pubkey" rows="6">' . $pubkey . '</TEXTAREA>';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$notes = "<form><TEXTAREA cols=\"60\" name=\"notes\" rows=\"4\">"
|
2001-02-10 13:56:49 +01:00
|
|
|
. $notes . "</TEXTAREA></form>";
|
|
|
|
if ($bday == "//")
|
2001-05-06 18:43:45 +02:00
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$bday = "";
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($action)
|
|
|
|
{
|
2001-04-14 22:21:41 +02:00
|
|
|
echo '<FORM action="' . $phpgw->link('/addressbook/' . $action, 'referer='.urlencode($referer)).'" method="post">';
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
|
2001-05-06 18:43:45 +02:00
|
|
|
if (!ereg("^http://",$url))
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$url = "http://". $url;
|
|
|
|
}
|
|
|
|
|
|
|
|
$birthday = $phpgw->common->dateformatorder($bday_year,$bday_month,$bday_day)
|
2001-05-06 18:43:45 +02:00
|
|
|
. '<font face="'.$theme["font"].'" size="-2">(e.g. 1969)</font>';
|
2001-04-28 06:33:13 +02:00
|
|
|
if ($format == 'edit')
|
|
|
|
{
|
|
|
|
$create .= '<tr><td><font size="-1">' . lang("Created by") . ':</font></td>'
|
|
|
|
. '<td colspan="3"><font size="-1">'
|
|
|
|
. $phpgw->common->grab_owner_name($fields["owner"]);
|
|
|
|
}
|
2001-02-10 13:56:49 +01:00
|
|
|
else
|
2001-04-28 06:33:13 +02:00
|
|
|
{
|
|
|
|
$create .= '';
|
|
|
|
}
|
|
|
|
|
2001-05-10 15:05:30 +02:00
|
|
|
$t->set_var('lang_home',lang('Home'));
|
|
|
|
$t->set_var('lang_business',lang('Business'));
|
|
|
|
$t->set_var('lang_personal',lang('Personal'));
|
|
|
|
|
|
|
|
$t->set_var('lang_lastname',lang('Last Name'));
|
|
|
|
$t->set_var('lastname',$lastname);
|
|
|
|
$t->set_var('lang_firstname',lang('First Name'));
|
|
|
|
$t->set_var('firstname',$firstname);
|
|
|
|
$t->set_var('lang_middle',lang('Middle Name'));
|
|
|
|
$t->set_var('middle',$middle);
|
|
|
|
$t->set_var('lang_prefix',lang('Prefix'));
|
|
|
|
$t->set_var('prefix',$prefix);
|
|
|
|
$t->set_var('lang_suffix',lang('Suffix'));
|
|
|
|
$t->set_var('suffix',$suffix);
|
|
|
|
$t->set_var('lang_birthday',lang('Birthday'));
|
|
|
|
$t->set_var('birthday',$birthday);
|
|
|
|
|
|
|
|
$t->set_var('lang_company',lang('Company Name'));
|
|
|
|
$t->set_var('company',$company);
|
|
|
|
$t->set_var('lang_department',lang('Department'));
|
|
|
|
$t->set_var('department',$department);
|
|
|
|
$t->set_var('lang_title',lang('Title'));
|
|
|
|
$t->set_var('title',$title);
|
|
|
|
$t->set_var('lang_email',lang('Business Email'));
|
|
|
|
$t->set_var('email',$email);
|
|
|
|
$t->set_var('lang_email_type',lang('Business EMail Type'));
|
|
|
|
$t->set_var('email_type',$email_type);
|
|
|
|
$t->set_var('lang_url',lang('URL'));
|
|
|
|
$t->set_var('url',$url);
|
|
|
|
$t->set_var('lang_timezone',lang('time zone offset'));
|
|
|
|
$t->set_var('timezone',$time_zone);
|
|
|
|
$t->set_var('lang_fax',lang('Business Fax'));
|
|
|
|
$t->set_var('fax',$fax);
|
|
|
|
$t->set_var('lang_wphone',lang('Business Phone'));
|
|
|
|
$t->set_var('wphone',$wphone);
|
|
|
|
$t->set_var('lang_pager',lang('Pager'));
|
|
|
|
$t->set_var('pager',$pager);
|
|
|
|
$t->set_var('lang_mphone',lang('Cell Phone'));
|
|
|
|
$t->set_var('mphone',$mphone);
|
|
|
|
$t->set_var('lang_msgphone',lang('Message Phone'));
|
|
|
|
$t->set_var('msgphone',$msgphone);
|
|
|
|
$t->set_var('lang_isdnphone',lang('ISDN Phone'));
|
|
|
|
$t->set_var('isdnphone',$isdnphone);
|
|
|
|
$t->set_var('lang_carphone',lang('Car Phone'));
|
|
|
|
$t->set_var('carphone',$carphone);
|
|
|
|
$t->set_var('lang_vidphone',lang('Video Phone'));
|
|
|
|
$t->set_var('vidphone',$vidphone);
|
|
|
|
|
|
|
|
$t->set_var('lang_ophone',lang('Other Number'));
|
|
|
|
$t->set_var('ophone',$ophone);
|
|
|
|
$t->set_var('lang_bstreet',lang('Business Street'));
|
|
|
|
$t->set_var('bstreet',$bstreet);
|
|
|
|
$t->set_var('lang_address2',lang('Address Line 2'));
|
|
|
|
$t->set_var('address2',$address2);
|
|
|
|
$t->set_var('lang_address3',lang('Address Line 3'));
|
|
|
|
$t->set_var('address3',$address3);
|
|
|
|
$t->set_var('lang_bcity',lang('Business City'));
|
|
|
|
$t->set_var('bcity',$bcity);
|
|
|
|
$t->set_var('lang_bstate',lang('Business State'));
|
|
|
|
$t->set_var('bstate',$bstate);
|
|
|
|
$t->set_var('lang_bzip',lang('Business Zip Code'));
|
|
|
|
$t->set_var('bzip',$bzip);
|
|
|
|
$t->set_var('lang_bcountry',lang('Business Country'));
|
|
|
|
$t->set_var('bcountry',$bcountry);
|
2001-05-22 00:31:31 +02:00
|
|
|
if ($countrylist)
|
|
|
|
{
|
|
|
|
$t->set_var('bcountry',$phpgw->country->form_select($bcountry,'bcountry'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var('bcountry','<input name="bcountry" value="' . $bcountry . '">');
|
|
|
|
}
|
2001-05-10 15:05:30 +02:00
|
|
|
$t->set_var('lang_badrtype',lang('Address Type'));
|
|
|
|
$t->set_var('badrtype',$badrtype);
|
|
|
|
|
|
|
|
$t->set_var('lang_hphone',lang('Home Phone'));
|
|
|
|
$t->set_var('hphone',$hphone);
|
|
|
|
$t->set_var('lang_hemail',lang('Home Email'));
|
|
|
|
$t->set_var('hemail',$hemail);
|
|
|
|
$t->set_var('lang_hemail_type',lang('Home EMail Type'));
|
|
|
|
$t->set_var('hemail_type',$hemail_type);
|
|
|
|
$t->set_var('lang_hstreet',lang('Home Street'));
|
|
|
|
$t->set_var('hstreet',$hstreet);
|
|
|
|
$t->set_var('lang_hcity',lang('Home City'));
|
|
|
|
$t->set_var('hcity',$hcity);
|
|
|
|
$t->set_var('lang_hstate',lang('Home State'));
|
|
|
|
$t->set_var('hstate',$hstate);
|
|
|
|
$t->set_var('lang_hzip',lang('Home Zip Code'));
|
|
|
|
$t->set_var('hzip',$hzip);
|
|
|
|
$t->set_var('lang_hcountry',lang('Home Country'));
|
2001-05-22 00:31:31 +02:00
|
|
|
if ($countrylist)
|
|
|
|
{
|
|
|
|
$t->set_var('hcountry',$phpgw->country->form_select($hcountry,'hcountry'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var('hcountry','<input name="hcountry" value="' . $hcountry . '">');
|
|
|
|
}
|
2001-05-10 15:05:30 +02:00
|
|
|
$t->set_var('lang_hadrtype',lang('Address Type'));
|
|
|
|
$t->set_var('hadrtype',$hadrtype);
|
|
|
|
|
|
|
|
$t->set_var('create',$create);
|
|
|
|
$t->set_var('lang_notes',lang('notes'));
|
|
|
|
$t->set_var('notes',$notes);
|
|
|
|
$t->set_var('lang_label',lang('label'));
|
|
|
|
$t->set_var('label',$label);
|
|
|
|
$t->set_var('lang_pubkey',lang('Public Key'));
|
|
|
|
$t->set_var('pubkey',$pubkey);
|
|
|
|
$t->set_var('access_check',$access_check);
|
2001-03-16 18:56:18 +01:00
|
|
|
|
2001-03-24 12:11:45 +01:00
|
|
|
$t->set_var('lang_private',lang('Private'));
|
2001-03-25 07:41:06 +02:00
|
|
|
|
|
|
|
$t->set_var('lang_cats',lang('Category'));
|
|
|
|
$t->set_var('cats_link',$cats_link);
|
2001-05-06 18:43:45 +02:00
|
|
|
if ($customfields)
|
|
|
|
{
|
2001-03-24 12:11:45 +01:00
|
|
|
$t->set_var('lang_custom',lang('Custom Fields').':');
|
2001-05-10 15:05:30 +02:00
|
|
|
$t->set_var('custom',$custom);
|
2001-05-06 18:43:45 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-10 15:05:30 +02:00
|
|
|
$t->set_var('lang_custom','');
|
|
|
|
$t->set_var('custom','');
|
2001-03-16 18:56:18 +01:00
|
|
|
}
|
|
|
|
|
2001-05-10 15:05:30 +02:00
|
|
|
$t->pfp('out','form');
|
2001-02-10 13:56:49 +01:00
|
|
|
} //end form function
|
|
|
|
|
2001-04-04 03:59:24 +02:00
|
|
|
function parsevcard($filename,$access='')
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
global $phpgw;
|
|
|
|
global $phpgw_info;
|
|
|
|
|
|
|
|
$vcard = fopen($filename, "r");
|
|
|
|
// Make sure we have a file to read.
|
|
|
|
if (!$vcard) {
|
|
|
|
fclose($vcard);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Keep running through this to support vcards
|
|
|
|
// with multiple entries.
|
|
|
|
while (!feof($vcard)) {
|
|
|
|
if(!empty($varray))
|
|
|
|
unset($varray);
|
|
|
|
|
|
|
|
// Make sure our file is a vcard.
|
|
|
|
// I should deal with empty line at the
|
|
|
|
// begining of the file. Those will fail here.
|
|
|
|
$vline = fgets($vcard,20);
|
|
|
|
$vline = strtolower($vline);
|
|
|
|
if(strcmp("begin:vcard", substr($vline, 0, strlen("begin:vcard")) ) != 0) {
|
|
|
|
fclose($vcard);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Write the vcard into an array.
|
|
|
|
// You can have multiple vcards in one file.
|
|
|
|
// I only deal with halve of that. :)
|
|
|
|
// It will only return values from the 1st vcard.
|
|
|
|
$varray[0] = "begin";
|
|
|
|
$varray[1] = "vcard";
|
|
|
|
$i=2;
|
|
|
|
while(!feof($vcard) && strcmp("end:vcard", strtolower(substr($vline, 0, strlen("end:vcard"))) ) !=0 ) {
|
|
|
|
$vline = fgets($vcard,4096);
|
|
|
|
// Check for folded lines and escaped colons '\:'
|
|
|
|
$la = explode(":", $vline);
|
|
|
|
|
|
|
|
if (count($la) > 1) {
|
|
|
|
$varray[$i] = strtolower($la[0]);
|
|
|
|
$i++;
|
|
|
|
|
|
|
|
for($j=1;$j<=count($la);$j++) {
|
|
|
|
$varray[$i] .= $la[$j];
|
|
|
|
}
|
|
|
|
$i++;
|
|
|
|
} else { // This is the continuation of a folded line.
|
|
|
|
$varray[$i-1] .= $la[0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-13 18:14:08 +01:00
|
|
|
// Add this entry to the addressbook before moving on to the next one.
|
|
|
|
fillab($varray);
|
2001-02-10 13:56:49 +01:00
|
|
|
} // while(!feof($vcard))
|
|
|
|
|
|
|
|
fclose($vcard);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-13 18:14:08 +01:00
|
|
|
function fillab($varray,$access='') {
|
2001-02-10 13:56:49 +01:00
|
|
|
global $phpgw;
|
|
|
|
global $phpgw_info;
|
|
|
|
|
|
|
|
$i=0;
|
2001-03-19 10:07:00 +01:00
|
|
|
|
|
|
|
// while($i < count($varray)) {
|
|
|
|
// echo '<br>'.$varray[$i].' %% '.$varray[$i+1];
|
|
|
|
// $i++;$i++;
|
|
|
|
// }
|
|
|
|
// exit;
|
2001-02-10 13:56:49 +01:00
|
|
|
// incremented by 2
|
|
|
|
while($i < count($varray)) {
|
|
|
|
$k = explode(";",$varray[$i]); // Key
|
|
|
|
$v = explode(";",$varray[$i+1]); // Values
|
|
|
|
for($h=0;$h<count($k);$h++) {
|
2001-03-19 10:07:00 +01:00
|
|
|
// Cleanup groupings
|
|
|
|
$k[$h] = ereg_replace("a\.",'',$k[$h]);
|
|
|
|
$k[$h] = ereg_replace("b\.",'',$k[$h]);
|
|
|
|
$k[$h] = ereg_replace("c\.",'',$k[$h]);
|
|
|
|
$k[$h] = ereg_replace("d\.",'',$k[$h]);
|
|
|
|
//echo '<br>kh="'.$k[$h].'",v0="'.$v[0].'",v1="'.$v[1].'",v2="'.$v[2].'",v3="'.$v[3].'",v4="'.$v[4].'",v5="'.$v[5].'",v6="'.$v[6].'",v7="'.$v[7].'"';
|
2001-02-10 13:56:49 +01:00
|
|
|
switch($k[$h]) {
|
|
|
|
case "fn":
|
2001-03-19 10:07:00 +01:00
|
|
|
$fn = $v[0];
|
2001-02-10 13:56:49 +01:00
|
|
|
break;
|
|
|
|
case "n":
|
|
|
|
$lastname = $v[0];
|
|
|
|
$firstname = $v[1];
|
|
|
|
break;
|
|
|
|
case "bday":
|
|
|
|
$bday = $v[0];
|
|
|
|
break;
|
2001-02-27 14:44:31 +01:00
|
|
|
case "url":
|
|
|
|
$url = $v[0];
|
2001-03-13 18:14:08 +01:00
|
|
|
// Fix the result of exploding on ':' above
|
|
|
|
if (substr($url,0,5) == 'http/') {
|
|
|
|
$url = ereg_replace('http//','http://',$url);
|
|
|
|
} elseif (substr($url,0,6) == 'https/') {
|
|
|
|
$url = ereg_replace('https//','https://',$url);
|
|
|
|
} elseif (substr($url,0,7) != 'http://') {
|
|
|
|
$url = 'http://' . $url;
|
|
|
|
}
|
2001-02-27 14:44:31 +01:00
|
|
|
break;
|
2001-03-19 10:07:00 +01:00
|
|
|
case "label":
|
|
|
|
$label = $v[0];
|
2001-02-10 13:56:49 +01:00
|
|
|
break;
|
2001-03-19 10:07:00 +01:00
|
|
|
case "adr": // This one is real ugly. Still! :(
|
|
|
|
if(!$street) {
|
|
|
|
$street = $v[2];
|
|
|
|
$address2 = $v[1] . " " . $v[0];
|
|
|
|
$city = $v[3];
|
|
|
|
$state = $v[4];
|
|
|
|
$zip = $v[5];
|
|
|
|
$country = $v[6];
|
|
|
|
if (strstr($k[$h+1],"intl")) { $adronetype .= "INTL;"; }
|
|
|
|
if (strstr($k[$h+1],"dom")) { $adronetype .= "DOM;"; }
|
|
|
|
} else {
|
|
|
|
$hstreet = $v[2];
|
|
|
|
$hcity = $v[3];
|
|
|
|
$hstate = $v[4];
|
|
|
|
$hzip = $v[5];
|
|
|
|
$hcountry = $v[6];
|
|
|
|
if (strstr($k[$h+1],"intl")) { $adrtwotype .= "INTL;"; }
|
|
|
|
if (strstr($k[$h+1],"dom")) { $adrtwotype .= "DOM;"; }
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
break;
|
2001-03-19 10:07:00 +01:00
|
|
|
case "tel":
|
|
|
|
switch ($k[$h+1]) {
|
|
|
|
case "work":
|
|
|
|
$wphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "home":
|
|
|
|
$hphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "cell":
|
|
|
|
$mphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "pager":
|
|
|
|
$pager = $v[0];
|
|
|
|
break;
|
|
|
|
case "fax":
|
|
|
|
$fax = $v[0];
|
|
|
|
break;
|
|
|
|
case "msg":
|
|
|
|
$msgphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "bbs":
|
|
|
|
$bbsphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "modem":
|
|
|
|
$modem = $v[0];
|
|
|
|
break;
|
|
|
|
case "car":
|
|
|
|
$carphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "isdn":
|
|
|
|
$isdn = $v[0];
|
|
|
|
break;
|
|
|
|
case "video":
|
|
|
|
$vidphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "pref":
|
|
|
|
switch ($k[$h+2]) {
|
|
|
|
case "work":
|
|
|
|
$tel_prefer .= "work;";
|
|
|
|
$wphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "home":
|
|
|
|
$tel_prefer .= "home;";
|
|
|
|
$hphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "cell":
|
|
|
|
$tel_prefer .= "cell;";
|
|
|
|
$mphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "pager":
|
|
|
|
$tel_prefer .= "pager;";
|
|
|
|
$pager = $v[0];
|
|
|
|
break;
|
|
|
|
case "fax":
|
|
|
|
$tel_prefer .= "fax;";
|
|
|
|
$fax = $v[0];
|
|
|
|
break;
|
|
|
|
case "msg":
|
|
|
|
$tel_prefer .= "msg;";
|
|
|
|
$msgphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "bbs":
|
|
|
|
$tel_prefer .= "bbs;";
|
|
|
|
$bbsphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "modem":
|
|
|
|
$tel_prefer .= "modem;";
|
|
|
|
$modem = $v[0];
|
|
|
|
break;
|
|
|
|
case "car":
|
|
|
|
$tel_prefer .= "car;";
|
|
|
|
$carphone = $v[0];
|
|
|
|
break;
|
|
|
|
case "isdn":
|
|
|
|
$tel_prefer .= "isdn;";
|
|
|
|
$isdn = $v[0];
|
|
|
|
break;
|
|
|
|
case "video":
|
|
|
|
$tel_prefer .= "video;";
|
|
|
|
$vidphone = $v[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
$whphone = $v[0];
|
|
|
|
break;
|
|
|
|
}
|
2001-02-10 13:56:49 +01:00
|
|
|
break;
|
|
|
|
case "email":
|
2001-03-19 10:07:00 +01:00
|
|
|
if (empty($email)) { $email = $v[0]; }
|
|
|
|
else { $hemail = $v[0]; }
|
|
|
|
switch ($k[$h+1]) {
|
|
|
|
case "compuserve":
|
|
|
|
if (!$adronetype) { $emailtype="CompuServe"; }
|
|
|
|
else { $hemailtype="CompuServe"; }
|
|
|
|
break;
|
|
|
|
case "aol":
|
|
|
|
if (!$adronetype) { $emailtype="AOL"; }
|
|
|
|
else { $hemailtype="AOL"; }
|
|
|
|
break;
|
|
|
|
case "prodigy":
|
|
|
|
if (!$adronetype) { $emailtype="Prodigy"; }
|
|
|
|
else { $hemailtype="Prodigy"; }
|
|
|
|
break;
|
|
|
|
case "eworld":
|
|
|
|
if (!$adronetype) { $emailtype="eWorld"; }
|
|
|
|
else { $hemailtype="eWorld"; }
|
|
|
|
break;
|
|
|
|
case "applelink":
|
|
|
|
if (!$adronetype) { $emailtype="AppleLink"; }
|
|
|
|
else { $hemailtype="AppleLink"; }
|
|
|
|
break;
|
|
|
|
case "appletalk":
|
|
|
|
if (!$adronetype) { $emailtype="AppleTalk"; }
|
|
|
|
else { $hemailtype="AppleTalk"; }
|
|
|
|
break;
|
|
|
|
case "powershare":
|
|
|
|
if (!$adronetype) { $emailtype="PowerShare"; }
|
|
|
|
else { $hemailtype="PowerShare"; }
|
|
|
|
break;
|
|
|
|
case "ibmmail":
|
|
|
|
if (!$adronetype) { $emailtype="IBMMail"; }
|
|
|
|
else { $hemailtype="IBMMail"; }
|
|
|
|
break;
|
|
|
|
case "attmail":
|
|
|
|
if (!$adronetype) { $emailtype="ATTMail"; }
|
|
|
|
else { $hemailtype="ATTMail"; }
|
|
|
|
break;
|
|
|
|
case "mcimail":
|
|
|
|
if (!$adronetype) { $emailtype="MCIMail"; }
|
|
|
|
else { $hemailtype="MCIMail"; }
|
|
|
|
break;
|
|
|
|
case "x.400":
|
|
|
|
if (!$adronetype) { $emailtype="X.400"; }
|
|
|
|
else { $hemailtype="X.400"; }
|
|
|
|
break;
|
|
|
|
case "tlx":
|
|
|
|
if (!$adronetype) { $emailtype="TLX"; }
|
|
|
|
else { $hemailtype="TLX"; }
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!$adronetype) { $emailtype="INTERNET"; }
|
|
|
|
else { $hemailtype="INTERNET"; }
|
|
|
|
break;
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case "title":
|
|
|
|
$title = $v[0];
|
|
|
|
break;
|
2001-03-19 10:07:00 +01:00
|
|
|
case "org":
|
2001-02-10 13:56:49 +01:00
|
|
|
$company = $v[0];
|
|
|
|
if(count($v) > 1) {
|
|
|
|
$notes .= $v[0] . "\n";
|
|
|
|
for($j=1;$j<count($v);$j++) {
|
|
|
|
$notes .= $v[$j] . "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2001-03-19 10:07:00 +01:00
|
|
|
default:
|
2001-02-10 13:56:49 +01:00
|
|
|
break;
|
|
|
|
} // switch
|
|
|
|
} // for
|
|
|
|
$i++;
|
|
|
|
} // All of the values that are getting filled are.
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2001-03-19 10:07:00 +01:00
|
|
|
$fields["tel_prefer"] = substr($tel_prefer,0,-1);
|
|
|
|
$fields["owner"] = $phpgw_info["user"]["account_id"];
|
|
|
|
$fields["n_given"] = addslashes($firstname);
|
|
|
|
$fields["n_family"] = addslashes($lastname);
|
|
|
|
$fields["fn"] = addslashes($firstname . " " . $lastname);
|
|
|
|
$fields["title"] = addslashes($title);
|
|
|
|
$fields["email"] = addslashes($email);
|
|
|
|
$fields["email_type"] = $emailtype;
|
|
|
|
$fields["hemail"] = addslashes($hemail);
|
|
|
|
$fields["hemail_type"] = $hemailtype;
|
|
|
|
$fields["tel_work"] = addslashes($wphone);
|
|
|
|
$fields["tel_home"] = addslashes($hphone);
|
|
|
|
$fields["tel_fax"] = addslashes($fax);
|
|
|
|
$fields["tel_pager"] = addslashes($pager);
|
|
|
|
$fields["tel_cell"] = addslashes($mphone);
|
|
|
|
$fields["tel_msg"] = addslashes($ophone);
|
|
|
|
$fields["tel_car"] = addslashes($carphone);
|
|
|
|
$fields["tel_modem"] = addslashes($modem);
|
|
|
|
$fields["tel_bbs"] = addslashes($bbsphone);
|
|
|
|
$fields["tel_isdn"] = addslashes($isdn);
|
|
|
|
$fields["tel_video"] = addslashes($vidphone);
|
|
|
|
$fields["adr_one_street"] = addslashes($street);
|
|
|
|
$fields["address2"] = addslashes($address2);
|
|
|
|
$fields["adr_one_locality"] = addslashes($city);
|
|
|
|
$fields["adr_one_region"] = addslashes($state);
|
|
|
|
$fields["adr_one_postalcode"] = addslashes($zip);
|
|
|
|
$fields["adr_one_countryname"] = addslashes($country);
|
|
|
|
$fields["adr_one_type"] = substr($adronetype,0,-1);
|
|
|
|
$fields["adr_two_street"] = addslashes($hstreet);
|
|
|
|
$fields["adr_two_locality"] = addslashes($hcity);
|
|
|
|
$fields["adr_two_region"] = addslashes($hstate);
|
|
|
|
$fields["adr_two_postalcode"] = addslashes($hzip);
|
|
|
|
$fields["adr_two_countryname"] = addslashes($hcountry);
|
|
|
|
$fields["adr_two_type"] = substr($adrtwotype,0,-1);
|
|
|
|
$fields["bday"] = addslashes($bday);
|
|
|
|
$fields["url"] = $url;
|
|
|
|
$fields["note"] = addslashes($notes);
|
|
|
|
$fields["org_name"] = addslashes($company);
|
|
|
|
|
|
|
|
/*
|
|
|
|
echo '<br>tel_prefer: '.$fields["tel_prefer"];
|
|
|
|
echo '<br>owner: '.$fields["owner"];
|
|
|
|
echo '<br>firstname: '.$fields["n_given"];
|
|
|
|
echo '<br>lastname: '.$fields["n_family"];
|
|
|
|
echo '<br>full name: '.$fields["fn"];
|
|
|
|
echo '<br>title: '.$fields["title"];
|
|
|
|
echo '<br>email: '.$fields["email"];
|
|
|
|
echo '<br>work#: '.$fields["tel_work"];
|
|
|
|
echo '<br>home#: '.$fields["tel_home"];
|
|
|
|
echo '<br>fax#: '.$fields["tel_fax"];
|
|
|
|
echo '<br>pager#: '.$fields["tel_pager"];
|
|
|
|
echo '<br>cell#: '.$fields["tel_cell"];
|
|
|
|
echo '<br>msg#: '.$fields["tel_msg"];
|
|
|
|
echo '<br>car#: '.$fields["tel_car"];
|
|
|
|
echo '<br>modem# '.$fields["tel_modem"];
|
|
|
|
echo '<br>bbs#: '.$fields["tel_bbs"];
|
|
|
|
echo '<br>isdn#: '.$fields["tel_isdn"];
|
|
|
|
echo '<br>video#: '.$fields["tel_video"];
|
|
|
|
echo '<br>street: '.$fields["adr_one_street"];
|
|
|
|
echo '<br>addr2: '.$fields["address2"];
|
|
|
|
echo '<br>city: '.$fields["adr_one_locality"];
|
|
|
|
echo '<br>state: '.$fields["adr_one_region"];
|
|
|
|
echo '<br>zip: '.$fields["adr_one_postalcode"];
|
|
|
|
echo '<br>adronetype: '.$fields["adr_one_type"];
|
|
|
|
echo '<br>bday: '.$fields["bday"];
|
|
|
|
echo '<br>url: '.$fields["url"];
|
|
|
|
echo '<br>note: '.$fields["note"];
|
|
|
|
echo '<br>company: '.$fields["org_name"];
|
|
|
|
exit;
|
|
|
|
*/
|
2001-02-10 13:56:49 +01:00
|
|
|
$this = CreateObject("phpgwapi.contacts");
|
|
|
|
$this->add($phpgw_info["user"]["account_id"],$fields);
|
|
|
|
}
|
2001-02-05 06:38:26 +01:00
|
|
|
|
2000-09-28 02:19:04 +02:00
|
|
|
?>
|