[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/class.contacts.php, 1.1.2.1
From: |
nomail |
Subject: |
[Phpgroupware-cvs] property/class.contacts.php, 1.1.2.1 |
Date: |
Sun, 23 May 2004 05:36:31 -0000 |
Update of /property
Added Files:
Branch: proposal-branch
class.contacts.php
date: 2004/04/30 09:52:25; author: sigurdne; state: Exp; lines: +245 -0
Log Message:
no message
=====================================================================
<?php
/**************************************************************************\
* phpGroupWare API - Contacts manager for SQL *
* This file written by Joseph Engo <address@hidden> *
* and Miles Lott <address@hidden> *
* View and manipulate contact records using SQL *
* Copyright (C) 2001 Joseph Engo *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare API *
* http://www.phpgroupware.org/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: class.contacts.php,v 1.1.2.1 2004/04/30 09:52:25 sigurdne Exp $ */
class property_contacts
{
var $db = '';
var $std_table='fm_addressbook';
var $ext_table='fm_addressbook_extra';
var $account_id = 0;
var $total_records = 0;
var $grants = '';
/* The left side are the array elements used throughout phpgw,
right side are the db field names. */
var $stock_contact_fields = array(
'fn' => 'fn',
'n_given' => 'n_given',
'n_family' => 'n_family',
'n_middle' => 'n_middle',
'n_prefix' => 'n_prefix',
'n_suffix' => 'n_suffix',
'sound' => 'sound',
'bday' => 'bday',
'note' => 'note',
'tz' => 'tz',
'geo' => 'geo',
'url' => 'url',
'pubkey' => 'pubkey',
'org_name' => 'org_name',
'org_unit' => 'org_unit',
'title' => 'title',
'adr_one_street' => 'adr_one_street',
'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',
'label' => 'label',
'adr_two_street' => 'adr_two_street',
'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',
'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',
'email' => 'email',
'email_type' => 'email_type',
'email_home' => 'email_home',
'email_home_type' => 'email_home_type'
);
var $non_contact_fields = array(
'id' => 'id',
'lid' => 'lid',
'tid' => 'tid',
'cat_id' => 'cat_id',
'access' => 'access',
'owner' => 'owner'
);
var $adr_types = array();
/* Used to set preferred number field */
var $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'
);
/* Used to set email_type fields */
var $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'
);
function property_contacts($useacl=True)
{
$this->db = $GLOBALS['phpgw']->db;
if($useacl)
{
// $this->grants =
$GLOBALS['phpgw']->acl->get_grants('.addressbook');
}
$this->account_id =
$GLOBALS['phpgw_data']['user']['id'];
/* Used to flag an address as being:
domestic AND/OR international(default)
parcel(default)
postal(default)
*/
$this->adr_types = array(
'dom' => lang('Domestic'),
'intl' => lang('International'),
'parcel' => lang('Parcel'),
'postal' => lang('Postal')
);
}
function split_stock_and_extras($fields)
{
while(list($field,$value) = @each($fields))
{
/* Depending on how the array was built, this
is needed. */
if(is_int($value))
{
$value = $field;
}
if($this->stock_contact_fields[$field])
{
$stock_fields[$field] = $value;
$stock_fieldnames[$field] =
$this->stock_contact_fields[$field];
}
else
{
$extra_fields[$field] = $value;
}
}
return
array($stock_fields,$stock_fieldnames,$extra_fields);
}
/* send this the id and whatever fields you want to see */
function read_single_entry($id,$fields='')
{
if(!$fields || empty($fields))
{
$fields = $this->stock_contact_fields;
}
list($stock_fields,$stock_fieldnames,$extra_fields) =
$this->split_stock_and_extras($fields);
if(count($stock_fieldnames))
{
$t_fields = ',' .
implode(',',$stock_fieldnames);
if($t_fields == ',')
{
unset($t_fields);
}
}
$dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
id,lid,tid,owner,access,cat_id $t_fields FROM $this->std_table WHERE id='$id'");
$return_fields[0]['id'] = $dbresult->fields['id'];
$return_fields[0]['lid'] = $dbresult->fields['lid'];
$return_fields[0]['tid'] = $dbresult->fields['tid'];
$return_fields[0]['owner'] =
$dbresult->fields['owner'];
$return_fields[0]['access'] =
$dbresult->fields['access'];
$return_fields[0]['cat_id'] =
$dbresult->fields['cat_id'];
if(is_array($stock_fieldnames))
{
while(list($f_name) = each($stock_fieldnames))
{
$return_fields[0][$f_name] =
$dbresult->fields[$f_name];
}
}
/* Setup address type fields for ui forms display */
if($dbresult->fields['adr_one_type'])
{
$one_type = $dbresult->fields['adr_one_type'];
reset($this->adr_types);
while(list($name,$val) = each($this->adr_types))
{
eval("if (strstr(\$one_type,\$name)) {
\$return_fields[0][\"one_\$name\"] = \"on\"; }");
}
}
if($dbresult->fields['adr_two_type'])
{
$two_type = $dbresult->fields['adr_two_type'];
reset($this->adr_types);
while(list($name,$val) = each($this->adr_types))
{
eval("if (strstr(\$two_type,\$name)) {
\$return_fields[0][\"two_\$name\"] = \"on\"; }");
}
}
$dbresult = $GLOBALS['phpgw']->db->Execute("SELECT
contact_name,contact_value FROM $this->ext_table where contact_id='" .
$dbresult->fields['id'] . "'");
if (!$dbresult->EOF)
{
if($extra_fields[$dbresult->fields['contact_name']])
{
$return_fields[0][$dbresult->fields['contact_name']] =
$dbresult->fields['contact_value'];
}
$dbresult->MoveNext();
}
return $return_fields;
}
}
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] property/class.contacts.php, 1.1.2.1,
nomail <=