2001-07-08 15:54:40 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
2004-01-25 23:02:59 +01:00
|
|
|
* eGroupWare - Addressbook *
|
|
|
|
* http://www.egroupware.org *
|
2001-07-08 15:54:40 +02:00
|
|
|
* Written by Joseph Engo <jengo@phpgroupware.org> and *
|
2003-10-16 12:20:13 +02:00
|
|
|
* Miles Lott <milos@groupwhere.org> *
|
2001-07-08 15:54:40 +02:00
|
|
|
* -------------------------------------------- *
|
|
|
|
* 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 uiaddressbook
|
|
|
|
{
|
|
|
|
var $contacts;
|
|
|
|
var $bo;
|
|
|
|
var $cat;
|
|
|
|
var $company;
|
|
|
|
var $prefs;
|
|
|
|
|
|
|
|
var $debug = False;
|
|
|
|
|
|
|
|
var $start;
|
2003-08-28 16:16:30 +02:00
|
|
|
var $limit;
|
2001-07-08 15:54:40 +02:00
|
|
|
var $query;
|
|
|
|
var $sort;
|
|
|
|
var $order;
|
|
|
|
var $filter;
|
|
|
|
var $cat_id;
|
|
|
|
|
|
|
|
var $public_functions = array(
|
2003-08-28 16:16:30 +02:00
|
|
|
'index' => True,
|
|
|
|
'view' => True,
|
|
|
|
'add' => True,
|
2001-07-09 19:35:27 +02:00
|
|
|
'add_email' => True,
|
2003-08-28 16:16:30 +02:00
|
|
|
'copy' => True,
|
|
|
|
'edit' => True,
|
2001-07-13 11:03:31 +02:00
|
|
|
'delete' => True,
|
2003-08-28 16:16:30 +02:00
|
|
|
'preferences' => True
|
2001-07-08 15:54:40 +02:00
|
|
|
);
|
|
|
|
|
2001-09-20 05:55:57 +02:00
|
|
|
var $extrafields = array(
|
2001-07-08 15:54:40 +02:00
|
|
|
'ophone' => 'ophone',
|
|
|
|
'address2' => 'address2',
|
|
|
|
'address3' => 'address3'
|
|
|
|
);
|
|
|
|
|
2004-02-22 16:18:36 +01:00
|
|
|
var $contact_types = array(
|
|
|
|
'n' => 'People',
|
|
|
|
'c' => 'Companies'
|
|
|
|
);
|
|
|
|
var $contact_type = array(
|
|
|
|
'n' => 'Person',
|
|
|
|
'c' => 'Company'
|
|
|
|
);
|
|
|
|
|
2001-07-08 15:54:40 +02:00
|
|
|
function uiaddressbook()
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->country = CreateObject('phpgwapi.country');
|
|
|
|
$GLOBALS['egw']->browser = CreateObject('phpgwapi.browser');
|
|
|
|
$GLOBALS['egw']->nextmatchs = CreateObject('phpgwapi.nextmatchs');
|
2002-04-13 05:34:23 +02:00
|
|
|
$this->fields = CreateObject('addressbook.uifields');
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
$this->bo = CreateObject('addressbook.boaddressbook',True);
|
|
|
|
$this->cat = CreateObject('phpgwapi.categories');
|
2004-01-17 05:03:37 +01:00
|
|
|
// $this->company = CreateObject('phpgwapi.categories','addressbook_company');
|
2005-05-01 16:34:59 +02:00
|
|
|
$this->prefs = $GLOBALS['egw_info']['user']['preferences']['addressbook'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-12-23 18:28:14 +01:00
|
|
|
$this->_set_sessiondata();
|
|
|
|
}
|
|
|
|
|
|
|
|
function _set_sessiondata()
|
|
|
|
{
|
2004-02-22 16:18:36 +01:00
|
|
|
$this->start = $this->bo->start;
|
|
|
|
$this->limit = $this->bo->limit;
|
|
|
|
$this->query = $this->bo->query;
|
|
|
|
$this->cquery = $this->bo->cquery;
|
|
|
|
$this->sort = $this->bo->sort;
|
|
|
|
$this->order = $this->bo->order;
|
|
|
|
$this->filter = $this->bo->filter;
|
|
|
|
$this->cat_id = $this->bo->cat_id;
|
|
|
|
$this->typeid = $this->bo->typeid;
|
2003-08-28 16:16:30 +02:00
|
|
|
if($this->debug) { $this->_debug_sqsof(); }
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function _debug_sqsof()
|
|
|
|
{
|
|
|
|
$data = array(
|
|
|
|
'start' => $this->start,
|
2003-08-28 16:16:30 +02:00
|
|
|
'limit' => $this->limit,
|
2001-07-08 15:54:40 +02:00
|
|
|
'query' => $this->query,
|
2004-01-17 04:21:21 +01:00
|
|
|
'cquery' => $this->cquery,
|
2001-07-08 15:54:40 +02:00
|
|
|
'sort' => $this->sort,
|
|
|
|
'order' => $this->order,
|
|
|
|
'filter' => $this->filter,
|
2004-02-22 16:18:36 +01:00
|
|
|
'cat_id' => $this->cat_id,
|
|
|
|
'typeid' => $this->typeid
|
2001-07-08 15:54:40 +02:00
|
|
|
);
|
|
|
|
echo '<br>UI:';
|
|
|
|
_debug_array($data);
|
|
|
|
}
|
|
|
|
|
2001-12-28 05:29:31 +01:00
|
|
|
/* Called only by index(), just prior to page footer. */
|
2001-07-08 15:54:40 +02:00
|
|
|
function save_sessiondata()
|
|
|
|
{
|
2001-07-12 06:09:12 +02:00
|
|
|
$data = array(
|
|
|
|
'start' => $this->start,
|
2003-08-28 16:16:30 +02:00
|
|
|
'limit' => $this->limit,
|
2001-07-12 06:09:12 +02:00
|
|
|
'query' => $this->query,
|
2004-01-17 04:21:21 +01:00
|
|
|
'cquery' => $this->cquery,
|
2001-07-12 06:09:12 +02:00
|
|
|
'sort' => $this->sort,
|
|
|
|
'order' => $this->order,
|
|
|
|
'filter' => $this->filter,
|
2004-02-22 16:18:36 +01:00
|
|
|
'cat_id' => $this->cat_id,
|
|
|
|
'typeid' => $this->typeid
|
2001-07-12 06:09:12 +02:00
|
|
|
);
|
|
|
|
$this->bo->save_sessiondata($data);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function formatted_list($name,$list,$id='',$default=False,$java=False)
|
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if($java)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$jselect = ' onChange="this.form.submit();"';
|
|
|
|
}
|
|
|
|
|
2003-12-03 05:28:20 +01:00
|
|
|
$select = "\n" .'<select name="' . $name . '"' . $jselect . ">\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
if($default)
|
|
|
|
{
|
|
|
|
$select .= '<option value="">' . lang('Please Select') . '</option>'."\n";
|
|
|
|
}
|
2004-02-22 16:18:36 +01:00
|
|
|
settype($list,'array');
|
2004-01-02 00:31:13 +01:00
|
|
|
foreach($list as $key => $val)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$select .= '<option value="' . $key . '"';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($key == $id && $id != '')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$select .= ' selected';
|
|
|
|
}
|
|
|
|
$select .= '>' . $val . '</option>'."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$select .= '</select>'."\n";
|
2004-02-22 16:18:36 +01:00
|
|
|
$select .= '<noscript><input type="submit" name="' . $name . '_select" value="'
|
|
|
|
. lang('Submit') . '"></noscript>' . "\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
return $select;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return a select form element with the categories option dialog in it */
|
|
|
|
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
|
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if($java)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$jselect = ' onChange="this.form.submit();"';
|
|
|
|
}
|
|
|
|
/* Setup all and none first */
|
2004-05-24 04:35:08 +02:00
|
|
|
$cats_link = "\n" .'<select name="fcat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple ' : '') . ">\n";
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$notall)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$cats_link .= '<option value=""';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($cat_id == 'all')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$cats_link .= ' selected';
|
|
|
|
}
|
2003-12-03 05:28:20 +01:00
|
|
|
$cats_link .= '>'.lang("all").'</option>'."\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get global and app-specific category listings */
|
2003-08-28 16:16:30 +02:00
|
|
|
$cats_link .= $this->cat->formated_list('select','all',$cat_id,True);
|
2003-12-03 05:28:20 +01:00
|
|
|
$cats_link .= '</select>'."\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
return $cats_link;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this cleans up the fieldnames for display */
|
|
|
|
function display_name($column)
|
|
|
|
{
|
|
|
|
$abc = array(
|
|
|
|
'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-09-20 05:55:57 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($abc[$column])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
return lang($abc[$column]);
|
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
return;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
function index()
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('addressbook_list_t' => 'index.tpl'));
|
|
|
|
$GLOBALS['egw']->template->set_block('addressbook_list_t','addressbook_header','addressbook_header');
|
|
|
|
$GLOBALS['egw']->template->set_block('addressbook_list_t','column','column');
|
|
|
|
$GLOBALS['egw']->template->set_block('addressbook_list_t','row','row');
|
|
|
|
$GLOBALS['egw']->template->set_block('addressbook_list_t','delete_block','delete_block');
|
|
|
|
$GLOBALS['egw']->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
|
|
|
|
$GLOBALS['egw']->template->set_block('addressbook_list_t','addressbook_alpha','addressbook_alpha');
|
2004-01-17 04:21:21 +01:00
|
|
|
|
|
|
|
/* Setup query for 1st char of fullname, company, lastname using user lang */
|
2004-01-17 04:57:14 +01:00
|
|
|
$chars = lang('alphabet');
|
|
|
|
if($chars == 'alphabet*')
|
2004-01-17 04:21:21 +01:00
|
|
|
{
|
2004-01-17 04:52:33 +01:00
|
|
|
$chars = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z';
|
2004-01-17 04:21:21 +01:00
|
|
|
}
|
2004-01-17 04:57:14 +01:00
|
|
|
$aar = explode(',', $chars);
|
2004-01-25 22:39:54 +01:00
|
|
|
unset($chars);
|
2004-01-17 04:21:21 +01:00
|
|
|
$aar[] = 'all';
|
|
|
|
foreach($aar as $char)
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('charclass',$this->cquery == $char ||
|
2004-06-16 02:53:45 +02:00
|
|
|
$char == 'all' && !$this->cquery ? 'letter_box_active' : 'letter_box');
|
|
|
|
|
2004-01-17 04:21:21 +01:00
|
|
|
if($char == 'all')
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('charlink',
|
|
|
|
$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index&cquery=')
|
2004-01-17 04:21:21 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('charlink',
|
|
|
|
$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index&cquery=' . $char)
|
2004-01-17 04:21:21 +01:00
|
|
|
);
|
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('char',$char != 'all' ? strtoupper($char) : lang('all'));
|
|
|
|
$GLOBALS['egw']->template->fp('alphalinks','addressbook_alpha',True);
|
2004-01-17 04:21:21 +01:00
|
|
|
}
|
2004-01-25 22:39:54 +01:00
|
|
|
unset($aar);
|
|
|
|
unset($char);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
|
|
|
$customfields = array();
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($x,$y) = @each($custom))
|
|
|
|
foreach($custom as $x => $y)
|
2002-04-13 05:34:23 +02:00
|
|
|
{
|
|
|
|
$customfields[$y['name']] = $y['name'];
|
|
|
|
$namedfields[$y['name']] = $y['title'];
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->cat_id == -1)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$this->cat_id = $this->prefs['default_category'];
|
2003-08-28 16:16:30 +02:00
|
|
|
}
|
2003-10-16 12:20:13 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->prefs['autosave_category'])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->preferences->read_repository();
|
|
|
|
$GLOBALS['egw']->preferences->delete('addressbook','default_category');
|
|
|
|
$GLOBALS['egw']->preferences->add('addressbook','default_category',$this->cat_id);
|
|
|
|
$GLOBALS['egw']->preferences->save_repository();
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2005-04-22 14:45:23 +02:00
|
|
|
/* global here so nextmatchs accepts our setting of $query and $filter - may be changed again below */
|
|
|
|
$GLOBALS['query'] = $this->query;
|
|
|
|
$GLOBALS['filter'] = $this->filter;
|
|
|
|
|
2001-07-08 15:54:40 +02:00
|
|
|
/* $qfields = $contacts->stock_contact_fields + $extrafields + $customfields; */
|
|
|
|
/* create column list and the top row of the table based on user prefs */
|
2004-03-23 10:11:49 +01:00
|
|
|
foreach($this->bo->stock_contact_fields as $column => $db_name)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-02-02 15:04:05 +01:00
|
|
|
$test = strtolower($column);
|
2002-01-17 04:52:56 +01:00
|
|
|
if(isset($this->prefs[$test]) && $this->prefs[$test])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-02-02 15:04:05 +01:00
|
|
|
$showcol = $this->display_name($column);
|
2001-07-08 15:54:40 +02:00
|
|
|
$cols .= ' <td height="21">' . "\n";
|
|
|
|
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
2005-05-01 16:34:59 +02:00
|
|
|
$cols .= $GLOBALS['egw']->nextmatchs->show_sort_order($this->sort,
|
2004-02-02 15:04:05 +01:00
|
|
|
$column,$this->order,'/index.php',$showcol,'&menuaction=addressbook.uiaddressbook.index'
|
2004-01-17 04:33:58 +01:00
|
|
|
);
|
2001-07-08 15:54:40 +02:00
|
|
|
$cols .= "</font>\n </td>";
|
|
|
|
$cols .= "\n";
|
|
|
|
|
|
|
|
/* To be used when displaying the rows */
|
2004-02-02 15:04:05 +01:00
|
|
|
$columns_to_display[$column] = True;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Setup the columns for non-standard fields, since we don't allow sorting */
|
|
|
|
$nonstd = $this->extrafields + $customfields;
|
2004-02-02 15:04:05 +01:00
|
|
|
foreach($nonstd as $column)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-02-02 15:04:05 +01:00
|
|
|
$test = strtolower($column);
|
2003-12-01 01:46:45 +01:00
|
|
|
if(isset($this->prefs[$test]) && $this->prefs[$test])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$showcol = $this->display_name($column[0]);
|
|
|
|
/* This must be a custom field */
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$showcol)
|
|
|
|
{
|
2004-02-02 15:04:05 +01:00
|
|
|
// $showcol = $column;
|
|
|
|
$showcol = $namedfields[$column];
|
2002-01-17 04:52:56 +01:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
$cols .= ' <td height="21">' . "\n";
|
|
|
|
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
|
|
|
$cols .= $showcol;
|
|
|
|
$cols .= "</font>\n </td>";
|
|
|
|
$cols .= "\n";
|
|
|
|
|
|
|
|
/* To be used when displaying the rows */
|
2004-02-02 15:04:05 +01:00
|
|
|
$columns_to_display[$column] = True;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
2003-08-28 16:16:30 +02:00
|
|
|
|
2001-07-08 15:54:40 +02:00
|
|
|
/* Check if prefs were set, if not, create some defaults */
|
2003-10-14 10:11:35 +02:00
|
|
|
if(!$columns_to_display)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
/* No prefs,. so cols above may have been set to '' or a bunch of <td></td> */
|
2001-07-08 15:54:40 +02:00
|
|
|
$cols='';
|
2003-10-03 12:04:01 +02:00
|
|
|
$columns_to_display = array(
|
|
|
|
'fn' => True,
|
|
|
|
'org_name' => True,
|
|
|
|
'adr_one_locality' => True,
|
|
|
|
'tel_work' => True,
|
|
|
|
'tel_cell' => True,
|
|
|
|
'email' => True
|
|
|
|
);
|
|
|
|
foreach($columns_to_display as $col => $nul)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-10-03 12:04:01 +02:00
|
|
|
$showcol = $this->display_name($col);
|
2001-07-08 15:54:40 +02:00
|
|
|
$cols .= ' <td height="21">' . "\n";
|
|
|
|
$cols .= ' <font size="-1" face="Arial, Helvetica, sans-serif">';
|
2005-05-01 16:34:59 +02:00
|
|
|
$cols .= $GLOBALS['egw']->nextmatchs->show_sort_order(
|
2004-01-17 04:33:58 +01:00
|
|
|
$this->sort,$col,$this->order,
|
|
|
|
"/index.php",$showcol,
|
|
|
|
'&menuaction=addressbook.uiaddressbook.index&cat_id=' . $this->cat_id . '&cquery=' . $this->cquery
|
|
|
|
);
|
2001-07-08 15:54:40 +02:00
|
|
|
$cols .= "</font>\n </td>";
|
|
|
|
$cols .= "\n";
|
2003-10-03 12:04:01 +02:00
|
|
|
|
|
|
|
$prefs[$col] = 'on';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-10-03 12:04:01 +02:00
|
|
|
$this->bo->save_preferences($prefs,'',$columns_to_display,'');
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2002-01-17 04:52:56 +01:00
|
|
|
if(!$this->start)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$this->start = 0;
|
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
if($GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] &&
|
|
|
|
$GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'] > 0)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$this->limit = $GLOBALS['egw_info']['user']['preferences']['common']['maxmatchs'];
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$this->limit = 15;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-09-20 05:55:57 +02:00
|
|
|
/*global $filter; */
|
2002-01-17 04:52:56 +01:00
|
|
|
if(empty($this->filter) || !isset($this->filter))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
if($this->prefs['default_filter'])
|
|
|
|
{
|
|
|
|
$this->filter = $this->prefs['default_filter'];
|
|
|
|
$this->query = '';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$this->filter = 'none';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Set qfilter to display entries where tid=n (normal contact entry),
|
|
|
|
else they may be accounts, etc.
|
|
|
|
*/
|
2004-02-22 16:18:36 +01:00
|
|
|
$qfilter = 'tid=' . (string)$this->typeid;
|
2003-12-01 01:46:45 +01:00
|
|
|
switch($this->filter)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
case 'blank':
|
|
|
|
$nosearch = True;
|
|
|
|
break;
|
|
|
|
case 'none':
|
|
|
|
break;
|
|
|
|
case 'private':
|
2001-09-20 05:55:57 +02:00
|
|
|
$qfilter .= ',access=private'; /* fall through */
|
2001-07-08 15:54:40 +02:00
|
|
|
case 'yours':
|
2005-05-01 16:34:59 +02:00
|
|
|
$qfilter .= ',owner=' . $GLOBALS['egw_info']['user']['account_id'];
|
2001-07-08 15:54:40 +02:00
|
|
|
break;
|
|
|
|
default:
|
2001-08-27 11:52:35 +02:00
|
|
|
$qfilter .= ',owner=' . $this->filter;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->cat_id)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$qfilter .= ',cat_id='.$this->cat_id;
|
|
|
|
}
|
2003-10-16 12:20:13 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$userid)
|
2001-08-27 11:52:35 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$userid = $GLOBALS['egw_info']['user']['account_id'];
|
2001-08-27 11:52:35 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($nosearch && !$this->query)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
$entries = array();
|
2001-07-12 03:01:11 +02:00
|
|
|
$total_records = 0;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-08-28 16:16:30 +02:00
|
|
|
else
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
|
|
|
/* read the entry list */
|
2001-08-09 02:19:28 +02:00
|
|
|
$entries = $this->bo->read_entries(array(
|
|
|
|
'start' => $this->start,
|
2003-08-28 16:16:30 +02:00
|
|
|
'limit' => $this->limit,
|
2001-08-09 02:19:28 +02:00
|
|
|
'fields' => $columns_to_display,
|
2001-08-23 08:57:37 +02:00
|
|
|
'filter' => $qfilter,
|
|
|
|
'query' => $this->query,
|
2004-01-17 04:21:21 +01:00
|
|
|
'cquery' => $this->cquery,
|
2001-08-23 08:57:37 +02:00
|
|
|
'sort' => $this->sort,
|
|
|
|
'order' => $this->order
|
2001-08-09 02:19:28 +02:00
|
|
|
));
|
2001-07-12 03:01:11 +02:00
|
|
|
$total_records = $this->bo->total;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
/* global here so nextmatchs accepts our setting of $query and $filter */
|
|
|
|
$GLOBALS['query'] = $this->query;
|
|
|
|
$GLOBALS['filter'] = $this->filter;
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$search_filter = $GLOBALS['egw']->nextmatchs->show_tpl('/index.php',
|
2004-01-17 04:33:58 +01:00
|
|
|
$this->start, $total_records,
|
|
|
|
'&menuaction=addressbook.uiaddressbook.index&fcat_id=' . $this->cat_id . '&cquery=' . $this->cquery,'95%',
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw_info']['theme']['th_bg'],1,1,1,array('filter' => $this->filter,'yours' => 1),
|
2004-01-17 04:33:58 +01:00
|
|
|
$this->cat_id
|
|
|
|
);
|
2003-08-28 16:16:30 +02:00
|
|
|
$query = $filter = '';
|
2002-03-14 15:06:04 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$lang_showing = $GLOBALS['egw']->nextmatchs->show_hits($total_records,$this->start);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
/* set basic vars and parse the header */
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('font',$GLOBALS['egw_info']['theme']['font']);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_actions',lang('Actions'));
|
|
|
|
$GLOBALS['egw']->template->set_var('check',$GLOBALS['egw']->common->image('phpgwapi','transparent'));
|
|
|
|
$GLOBALS['egw']->template->set_var('select_all','');
|
2003-12-03 05:28:20 +01:00
|
|
|
if(count($entries))
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('check', $GLOBALS['egw']->common->image('addressbook','check'));
|
|
|
|
$GLOBALS['egw']->template->set_var('select_all',lang('Select all'));
|
2003-12-03 05:28:20 +01:00
|
|
|
}
|
2003-10-16 12:20:13 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('searchreturn',$noprefs . ' ' . $searchreturn);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_showing',$lang_showing);
|
|
|
|
$GLOBALS['egw']->template->set_var('search_filter',$search_filter);
|
2004-02-22 16:18:36 +01:00
|
|
|
/*
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_show',lang('Show') . ':');
|
|
|
|
$GLOBALS['egw']->template->set_var('contact_type_list',$this->formatted_list('typeid',$this->contact_types,$this->typeid,False,True));
|
|
|
|
$GLOBALS['egw']->template->set_var('self_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
2004-02-22 16:18:36 +01:00
|
|
|
*/
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_show','');
|
|
|
|
$GLOBALS['egw']->template->set_var('contact_type_list','');
|
|
|
|
$GLOBALS['egw']->template->set_var('self_url','');
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('cats',lang('Category'));
|
|
|
|
$GLOBALS['egw']->template->set_var('cats_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
|
|
|
/* $GLOBALS['egw']->template->set_var('cats_link',$this->cat_option($this->cat_id)); */
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_cats',lang('Select'));
|
|
|
|
// $GLOBALS['egw']->template->set_var('lang_addressbook',lang('Address book'));
|
|
|
|
$GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
|
|
|
|
$GLOBALS['egw']->template->set_var('th_font',$GLOBALS['egw_info']['theme']['font']);
|
|
|
|
$GLOBALS['egw']->template->set_var('th_text',$GLOBALS['egw_info']['theme']['th_text']);
|
|
|
|
$GLOBALS['egw']->template->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_add',lang('Add'));
|
|
|
|
$GLOBALS['egw']->template->set_var('add_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.add'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_addvcard',lang('AddVCard'));
|
|
|
|
$GLOBALS['egw']->template->set_var('vcard_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uivcard.in'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_import',lang('Import Contacts'));
|
|
|
|
$GLOBALS['egw']->template->set_var('import_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.import'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_import_alt',lang('Alt. CSV Import'));
|
|
|
|
$GLOBALS['egw']->template->set_var('import_alt_url',$GLOBALS['egw']->link('/addressbook/csv_import.php'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_export',lang('Export Contacts'));
|
|
|
|
$GLOBALS['egw']->template->set_var('export_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiXport.export'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_delete',lang('Delete'));
|
|
|
|
$GLOBALS['egw']->template->set_var('column_count',count($columns_to_display));
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('start',$this->start);
|
|
|
|
$GLOBALS['egw']->template->set_var('sort',$this->sort);
|
|
|
|
$GLOBALS['egw']->template->set_var('order',$this->order);
|
|
|
|
$GLOBALS['egw']->template->set_var('filter',$this->filter);
|
|
|
|
$GLOBALS['egw']->template->set_var('query',$this->query);
|
|
|
|
$GLOBALS['egw']->template->set_var('cat_id',$this->cat_id);
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('qfield',$qfield);
|
|
|
|
$GLOBALS['egw']->template->set_var('cols',$cols);
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->pparse('out','addressbook_header');
|
2001-07-08 15:54:40 +02:00
|
|
|
|
|
|
|
/* Show the entries */
|
|
|
|
/* each entry */
|
2003-12-01 01:46:45 +01:00
|
|
|
for($i=0;$i<count($entries);$i++)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('columns','');
|
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var('row_tr_color',$tr_color);
|
2001-07-08 15:54:40 +02:00
|
|
|
$myid = $entries[$i]['id'];
|
|
|
|
$myowner = $entries[$i]['owner'];
|
|
|
|
|
|
|
|
/* each entry column */
|
2004-01-02 00:31:13 +01:00
|
|
|
// @reset($columns_to_display);
|
|
|
|
// while($column = @each($columns_to_display))
|
|
|
|
foreach($columns_to_display as $column => $nul)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$ref = $data='';
|
2004-01-02 00:31:13 +01:00
|
|
|
$coldata = $entries[$i][$column];
|
2001-07-13 17:05:50 +02:00
|
|
|
/* echo '<br>coldata="' . $coldata . '"'; */
|
2001-07-08 15:54:40 +02:00
|
|
|
/* Some fields require special formatting. */
|
2004-02-09 00:05:18 +01:00
|
|
|
if($column == 'url')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!empty($coldata) && (substr($coldata,0,7) != 'http://'))
|
|
|
|
{
|
|
|
|
$coldata = 'http://' . $coldata;
|
|
|
|
}
|
2003-08-28 16:16:30 +02:00
|
|
|
$ref='<a href="'.$coldata.'" target="_new">';
|
|
|
|
$data=$coldata.'</a>';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2004-02-09 00:05:18 +01:00
|
|
|
elseif(($column == 'email') || ($column == 'email_home'))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
if($GLOBALS['egw_info']['user']['apps']['email'])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$ref = '<a href="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/email/compose.php','to=' . urlencode($coldata))
|
2003-12-03 05:28:20 +01:00
|
|
|
. '" target="_new">';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
elseif($GLOBALS['egw_info']['user']['apps']['felamimail'])
|
2004-02-09 00:05:18 +01:00
|
|
|
{
|
|
|
|
$link_data = array(
|
|
|
|
'menuaction' => 'felamimail.uicompose.compose',
|
|
|
|
'send_to' => base64_encode($coldata)
|
|
|
|
);
|
|
|
|
$ref = '<a href="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/index.php',$link_data)
|
2004-02-09 00:05:18 +01:00
|
|
|
. '" target="_new">';
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
else
|
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$ref = '<a href="mailto:' . $coldata . '">';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-12-03 05:28:20 +01:00
|
|
|
$data = $coldata . '</a>';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else /* But these do not */
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$ref = ''; $data = $coldata;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('col_data',$ref.$data);
|
|
|
|
$GLOBALS['egw']->template->parse('columns','column',True);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-12-03 05:28:20 +01:00
|
|
|
$actions = '<a href="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/index.php',array(
|
2003-11-15 00:35:03 +01:00
|
|
|
'menuaction' => 'addressbook.uiaddressbook.view',
|
|
|
|
'ab_id' => $entries[$i]['id']
|
2003-12-03 05:28:20 +01:00
|
|
|
))
|
|
|
|
. '"><img src="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->common->image('addressbook','view')
|
2003-12-03 05:28:20 +01:00
|
|
|
. '" border="0" title="'.lang('View').'"></a> ';
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->bo->check_perms($entries[$i],PHPGW_ACL_EDIT))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$actions .= '<a href="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/index.php',array(
|
2003-11-15 00:35:03 +01:00
|
|
|
'menuaction' => 'addressbook.uiaddressbook.edit',
|
|
|
|
'ab_id' => $entries[$i]['id']
|
2003-12-03 05:28:20 +01:00
|
|
|
))
|
|
|
|
. '"><img src="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->common->image('addressbook','edit')
|
2003-12-03 05:28:20 +01:00
|
|
|
. '" border="0" title="' . lang('Edit') . '"></a> ';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-11-15 00:35:03 +01:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->bo->check_perms($entries[$i],PHPGW_ACL_DELETE))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$actions .= '<a href="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/index.php',array(
|
2003-11-15 00:35:03 +01:00
|
|
|
'menuaction' => 'addressbook.uiaddressbook.delete',
|
|
|
|
'ab_id' => $entries[$i]['id']
|
2003-12-03 05:28:20 +01:00
|
|
|
))
|
|
|
|
. '"><img src="'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->common->image('addressbook','delete')
|
2003-12-03 05:28:20 +01:00
|
|
|
. '" border="0" title="'.lang('Delete').'"></a>';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-12-03 05:28:20 +01:00
|
|
|
$actions .= '<input type="checkbox" name="select[' . $entries[$i]['id'] . ']">';
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('actions',$actions);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->parse('rows','row',True);
|
|
|
|
$GLOBALS['egw']->template->pparse('out','row');
|
2001-07-08 15:54:40 +02:00
|
|
|
reset($columns_to_display);
|
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('delete_button','');
|
2003-12-03 05:28:20 +01:00
|
|
|
if(count($entries))
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->fp('delete_button','delete_block');
|
2003-12-03 05:28:20 +01:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->pfp('out','addressbook_footer');
|
2001-07-08 15:54:40 +02:00
|
|
|
$this->save_sessiondata();
|
2005-05-01 16:34:59 +02:00
|
|
|
/* $GLOBALS['egw']->common->phpgw_footer(); */
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
function add_email()
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$name = $_POST['name'] ? $_POST['name'] : $_GET['name'];
|
|
|
|
$referer = $_POST['referer'] ? $_POST['referer'] : $_GET['referer'];
|
|
|
|
$add_email = $_POST['add_email'] ? $_POST['add_email'] : $_GET['add_email'];
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$named = explode(' ', $name);
|
2003-12-01 01:46:45 +01:00
|
|
|
for($i=count($named);$i>=0;$i--)
|
2001-12-11 02:44:13 +01:00
|
|
|
{
|
|
|
|
$names[$i] = $named[$i];
|
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if($names[2])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['n_given'] = $names[0];
|
|
|
|
$fields['n_middle'] = $names[1];
|
|
|
|
$fields['n_family'] = $names[2];
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['n_given'] = $names[0];
|
|
|
|
$fields['n_family'] = $names[1];
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
2001-12-11 02:44:13 +01:00
|
|
|
$fields['n_given'] = $fields['n_given'] ? $fields['n_given'] : ' ';
|
|
|
|
$fields['n_family'] = $fields['n_family'] ? $fields['n_family'] : ' ';
|
2003-12-03 05:28:20 +01:00
|
|
|
$fields['fn'] = $fields['n_given'] . ' ' . $fields['n_family'];
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['email'] = $add_email;
|
|
|
|
$fields['access'] = 'private';
|
|
|
|
$fields['tid'] = 'n';
|
|
|
|
$referer = urlencode($referer);
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$fields['owner'] = $GLOBALS['egw_info']['user']['account_id'];
|
2001-12-11 02:44:13 +01:00
|
|
|
// _debug_array($fields);exit;
|
2001-08-09 02:19:28 +02:00
|
|
|
$this->bo->add_entry($fields);
|
2001-07-13 11:03:31 +02:00
|
|
|
$ab_id = $this->bo->get_lastid();
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id . '&referer=' . $referer);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
function copy()
|
|
|
|
{
|
2003-11-14 23:12:59 +01:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
|
|
|
$customfields = array();
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($x,$y) = @each($custom))
|
|
|
|
foreach($custom as $x => $y)
|
2003-11-14 23:12:59 +01:00
|
|
|
{
|
|
|
|
$customfields[$y['name']] = $y['title'];
|
|
|
|
}
|
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
list($addnew) = $this->bo->read_entry(array(
|
2005-03-15 15:32:30 +01:00
|
|
|
'id' => (int) $_GET['ab_id'],
|
2003-11-14 23:12:59 +01:00
|
|
|
'fields' => $this->bo->stock_contact_fields + $this->extrafields + $customfields
|
2003-08-28 16:16:30 +02:00
|
|
|
));
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$addnew['note'] .= "\n".lang("Copied by %1, from record #%2.",$GLOBALS['egw']->accounts->id2name($addnew['owner']),$addnew['id']);
|
|
|
|
$addnew['owner'] = $GLOBALS['egw_info']['user']['account_id'];
|
2003-11-14 23:12:59 +01:00
|
|
|
unset($addnew['rights']);
|
2003-08-28 16:16:30 +02:00
|
|
|
unset($addnew['id']);
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
$ab_id = $this->bo->add_entry($addnew);
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uiaddressbook.edit&ab_id=' . $ab_id);
|
2002-03-14 15:06:04 +01:00
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
function add()
|
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if($_POST['submit'])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields = $this->get_form();
|
|
|
|
|
|
|
|
$referer = urlencode($fields['referer']);
|
|
|
|
unset($fields['referer']);
|
2005-05-01 16:34:59 +02:00
|
|
|
$fields['owner'] = $GLOBALS['egw_info']['user']['account_id'];
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2004-01-17 04:21:21 +01:00
|
|
|
$ab_id = $this->bo->add_entry($fields);
|
|
|
|
if(@is_array($ab_id) || !$ab_id)
|
|
|
|
{
|
|
|
|
/* Errors encountered during validation */
|
|
|
|
$errors = $ab_id;
|
|
|
|
}
|
|
|
|
// $ab_id = $this->bo->get_lastid();
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2004-02-24 15:05:39 +01:00
|
|
|
if(!$errors)
|
|
|
|
{
|
|
|
|
Header('Location: '
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id . '&referer=' . $referer));
|
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2004-02-24 15:05:39 +01:00
|
|
|
}
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('add' => 'add.tpl'));
|
2003-08-28 16:16:30 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Add');
|
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
2004-01-02 00:31:13 +01:00
|
|
|
foreach($custom as $x => $y)
|
2002-04-13 05:34:23 +02:00
|
|
|
{
|
|
|
|
$customfields[$y['name']] = $y['title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->addressbook_form('','menuaction=addressbook.uiaddressbook.add','Add','',$customfields,$this->cat_id);
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('errors','');
|
2004-01-17 04:21:21 +01:00
|
|
|
if(@is_array($errors))
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('errors',implode(',',$errors));
|
2004-01-17 04:21:21 +01:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_save',lang('Save'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
|
|
|
|
$GLOBALS['egw']->template->set_var('cancel_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
|
|
|
$GLOBALS['egw']->template->parse('out','add');
|
|
|
|
$GLOBALS['egw']->template->pparse('out','add');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function edit()
|
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if($_POST['submit'])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2001-09-03 14:00:38 +02:00
|
|
|
$_fields = $this->get_form();
|
2001-12-28 05:29:31 +01:00
|
|
|
/* _debug_array($_fields);exit; */
|
2001-09-03 14:00:38 +02:00
|
|
|
$check = $this->bo->read_entry(array('id' => $_fields['ab_id'], 'fields' => array('owner' => 'owner','tid' => 'tid')));
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->bo->check_perms($check[0],PHPGW_ACL_EDIT))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$userid = $check[0]['owner'];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$userid = $GLOBALS['egw_info']['user']['account_id'];
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-09-03 14:00:38 +02:00
|
|
|
$_fields['owner'] = $userid;
|
|
|
|
$referer = urlencode($_fields['referer']);
|
|
|
|
unset($_fields['referer']);
|
|
|
|
|
|
|
|
$this->bo->update_entry($_fields);
|
|
|
|
|
2001-08-27 11:52:35 +02:00
|
|
|
Header('Location: '
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $_fields['ab_id'] . '&referer=' . $referer)
|
2001-09-03 14:00:38 +02:00
|
|
|
);
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
|
|
|
/* First, make sure they have permission to this entry */
|
2005-03-15 15:32:30 +01:00
|
|
|
$check = $this->bo->read_entry(array('id' => (int) $_GET['ab_id'], 'fields' => array('owner' => 'owner','tid' => 'tid')));
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$this->bo->check_perms($check[0],PHPGW_ACL_EDIT))
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Edit');
|
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
/* Read in user custom fields, if any */
|
2002-04-13 05:34:23 +02:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
2002-04-15 05:04:10 +02:00
|
|
|
$customfields = array();
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($x,$y) = @each($custom))
|
|
|
|
foreach($custom as $x => $y)
|
2002-04-13 05:34:23 +02:00
|
|
|
{
|
|
|
|
$customfields[$y['name']] = $y['title'];
|
|
|
|
}
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
/* merge in extra fields */
|
2003-10-25 12:16:12 +02:00
|
|
|
$qfields = $this->bo->stock_contact_fields + $this->extrafields + $customfields;
|
2005-03-15 15:32:30 +01:00
|
|
|
$fields = $this->bo->read_entry(array('id' => (int) $_GET['ab_id'], 'fields' => $qfields));
|
2003-04-06 14:09:35 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$this->addressbook_form('edit','menuaction=addressbook.uiaddressbook.edit',lang('Edit'),$fields[0],$customfields);
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('edit' => 'edit.tpl'));
|
2003-08-28 16:16:30 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('th_bg',$GLOBALS['egw_info']['theme']['th_bg']);
|
|
|
|
$GLOBALS['egw']->template->set_var('ab_id',(int) $_GET['ab_id']);
|
|
|
|
$GLOBALS['egw']->template->set_var('tid',$check[0]['tid']);
|
|
|
|
$GLOBALS['egw']->template->set_var('referer',$referer);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_save',lang('Save'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
|
|
|
|
$GLOBALS['egw']->template->set_var('cancel_link','<form method="POST" action="'
|
|
|
|
. $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index') . '">');
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
if(($this->bo->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $GLOBALS['egw_info']['user']['account_id'])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('delete_link','<form method="POST" action="'.$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete') . '">');
|
|
|
|
$GLOBALS['egw']->template->set_var('delete_button','<input type="submit" name="delete" value="' . lang('Delete') . '">');
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->pfp('out','edit');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function delete()
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$ab_id = $_POST['entry']['ab_id'] ? $_POST['entry']['ab_id'] : $_POST['ab_id'];
|
|
|
|
$confirm = $_GET['confirm'] ? $_GET['confirm'] :$_POST['confirm'];
|
2003-12-03 05:28:20 +01:00
|
|
|
$select = $_POST['select'];
|
|
|
|
if(@is_array($select))
|
|
|
|
{
|
|
|
|
/* The original values are sent as select[number] = on */
|
|
|
|
$select = array_keys($select);
|
|
|
|
}
|
|
|
|
elseif(is_string($select))
|
|
|
|
{
|
|
|
|
/* This is imploded below and sent along with the form if the answer is yes */
|
|
|
|
$select = explode(',',$select);
|
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$ab_id)
|
2001-10-08 18:04:23 +02:00
|
|
|
{
|
2005-03-15 15:32:30 +01:00
|
|
|
$ab_id = (int) $_GET['ab_id']; // else plain Link in delete does not work
|
2001-10-08 18:04:23 +02:00
|
|
|
}
|
2003-12-03 05:28:20 +01:00
|
|
|
if((!$ab_id && !$select) || $_POST['no'])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
|
2003-12-03 05:28:20 +01:00
|
|
|
if(!@is_array($select))
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$select[] = $ab_id;
|
|
|
|
}
|
|
|
|
foreach($select as $null => $_id)
|
|
|
|
{
|
|
|
|
if(!(int)$_id)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$check = $this->bo->read_entry(array('id' => $_id, 'fields' => array('owner' => 'owner','tid' => 'tid')));
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
if(!(($this->bo->grants[$check[0]['owner']] & PHPGW_ACL_DELETE) || $check[0]['owner'] == $GLOBALS['egw_info']['user']['account_id']))
|
2003-12-03 05:28:20 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2003-12-03 05:28:20 +01:00
|
|
|
}
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('delete' => 'delete.tpl'));
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$_POST['yes'])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' - '.lang('Delete');
|
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
|
|
|
|
2003-12-03 05:28:20 +01:00
|
|
|
if(count($select) == 1)
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_sure',lang('Are you sure you want to delete this entry ?'));
|
2003-12-03 05:28:20 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_sure',lang('Are you sure you want to delete these entries ?'));
|
2003-12-03 05:28:20 +01:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('no_link',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_no',lang('NO'));
|
|
|
|
$GLOBALS['egw']->template->set_var('yes_link',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete&ab_id=' . $ab_id . '&confirm=true'));
|
|
|
|
$GLOBALS['egw']->template->set_var('select',implode(',',$select));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_yes',lang('YES'));
|
|
|
|
$GLOBALS['egw']->template->pparse('out','delete');
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
if(!@is_array($select))
|
|
|
|
{
|
|
|
|
$select[] = $ab_id;
|
|
|
|
}
|
|
|
|
foreach($select as $null => $_id)
|
|
|
|
{
|
|
|
|
$this->bo->delete_entry(array('id' => $_id));
|
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
@Header('Location: ' . $GLOBALS['egw']->link('/addressbook/index.php','menuaction=addressbook.uiaddressbook.index'));
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2004-01-02 00:31:13 +01:00
|
|
|
function rebuild_referer($val)
|
|
|
|
{
|
|
|
|
$val = urldecode($val);
|
|
|
|
$vars = split('&',$val);
|
|
|
|
$i = 0;
|
|
|
|
foreach($vars as $key => $var)
|
|
|
|
{
|
|
|
|
$pair = split('=',$var);
|
|
|
|
if($pair[0] == 'sq')
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$pair[1] = $GLOBALS['egw']->session->sq;
|
2004-01-02 00:31:13 +01:00
|
|
|
}
|
|
|
|
$vars[$i] = implode('=',$pair);
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
$val = implode('&',$vars);
|
|
|
|
return $val;
|
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
function view()
|
|
|
|
{
|
2005-03-15 15:32:30 +01:00
|
|
|
$ab_id = (int) $_GET['ab_id'];
|
2003-08-28 16:16:30 +02:00
|
|
|
$submit = $_POST['submit'];
|
2004-01-02 00:31:13 +01:00
|
|
|
$referer = $this->rebuild_referer($_GET['referer']);
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2001-08-04 16:12:32 +02:00
|
|
|
/* First, make sure they have permission to this entry */
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$ab_id || !$this->bo->check_perms($ab_id,PHPGW_ACL_READ))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
Header('Location: ' . $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
|
|
|
$GLOBALS['egw']->common->phpgw_exit();
|
2003-08-28 16:16:30 +02:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
elseif(!$submit && $ab_id)
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('Address book - view');
|
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('view_t' => 'view.tpl'));
|
|
|
|
$GLOBALS['egw']->template->set_block('view_t','view_header','view_header');
|
|
|
|
$GLOBALS['egw']->template->set_block('view_t','view_row','view_row');
|
|
|
|
$GLOBALS['egw']->template->set_block('view_t','view_footer','view_footer');
|
|
|
|
$GLOBALS['egw']->template->set_block('view_t','view_buttons','view_buttons');
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
2002-04-15 05:04:10 +02:00
|
|
|
$customfields = array();
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($x,$y) = @each($custom))
|
|
|
|
foreach($custom as $x => $y)
|
2002-04-13 05:34:23 +02:00
|
|
|
{
|
|
|
|
$customfields[$y['name']] = $y['title'];
|
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
/* _debug_array($this->prefs); */
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($column,$x) = each($this->bo->stock_contact_fields))
|
|
|
|
foreach($this->bo->stock_contact_fields as $column => $x)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if(isset($this->prefs[$column]) && $this->prefs[$column])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$columns_to_display[$column] = True;
|
|
|
|
$colname[$column] = $column;
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
/* merge in extra fields */
|
2003-10-25 12:16:12 +02:00
|
|
|
$qfields = $this->bo->stock_contact_fields + $this->extrafields + $customfields;
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-08-09 02:19:28 +02:00
|
|
|
$fields = $this->bo->read_entry(array('id' => $ab_id, 'fields' => $qfields));
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$record_owner = $fields[0]['owner'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($fields[0]['access'] == 'private')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$access_check = lang('private');
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$access_check = lang('public');
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-04-06 14:09:35 +02:00
|
|
|
unset($qfields['email_type']); // noone is useing that any more
|
2003-08-28 16:16:30 +02:00
|
|
|
unset($qfields['email_home_type']);
|
2003-04-06 14:09:35 +02:00
|
|
|
|
2004-01-02 00:31:13 +01:00
|
|
|
// @reset($qfields);
|
|
|
|
// while(list($column,$null) = @each($qfields))
|
|
|
|
foreach($qfields as $column => $nul)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
if($this->display_name($colname[$column]))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('display_col',$this->display_name($colname[$column]));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
elseif($this->display_name($column))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('display_col',$this->display_name($column));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('display_col',ucfirst($column));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
$ref = $data = '';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($fields[0][$column])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var('th_bg',$tr_color);
|
2001-07-13 11:03:31 +02:00
|
|
|
$coldata = $fields[0][$column];
|
|
|
|
/* Some fields require special formatting. */
|
2003-12-01 01:46:45 +01:00
|
|
|
if(($column == 'note' || $column == 'pubkey') && $coldata)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
$datarray = explode("\n",$coldata);
|
|
|
|
if($datarray[1])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($key,$info) = each($datarray))
|
|
|
|
foreach($datarray as $key => $info)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if($key)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$data .= '</td></tr><tr bgcolor="'.$tr_color.'"><td width="30%"> </td><td width="70%">' .$info;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* First row, don't close td/tr */
|
|
|
|
$data .= $info;
|
|
|
|
}
|
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
$data .= '</tr>';
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$data = $coldata;
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
elseif($column == 'url' && $coldata)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$ref = '<a href="' . $coldata . '" target="_new">';
|
|
|
|
$data = $coldata . '</a>';
|
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
elseif((($column == 'email') || ($column == 'email_home')) && $coldata)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
if($GLOBALS['egw_info']['user']['apps']['email'])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$ref='<a href="' . $GLOBALS['egw']->link('/email/compose.php','to='
|
2003-08-28 16:16:30 +02:00
|
|
|
. urlencode($coldata)) . '" target="_new">';
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ref = '<a href="mailto:'.$coldata.'">';
|
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
$data = $coldata.'</a>';
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
elseif($column == 'bday')
|
2003-07-02 02:18:11 +02:00
|
|
|
{
|
|
|
|
list($month,$day,$year) = explode('/',$coldata);
|
2005-05-01 16:34:59 +02:00
|
|
|
$data = $GLOBALS['egw']->common->dateformatorder($year,$month,$day,True);
|
2003-07-02 02:18:11 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* But these do not */
|
2001-08-27 11:52:35 +02:00
|
|
|
$ref = ''; $data = $coldata;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$data)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('ref_data',' ');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('ref_data',$ref . $data);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->parse('cols','view_row',True);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
/* Following cleans up view_row, since we were only using it to fill {cols} */
|
2005-05-01 16:34:59 +02:00
|
|
|
//$GLOBALS['egw']->template->set_var('view_row','');
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['cat_id'] = is_array($this->cat_id) ? implode(',',$this->cat_id) : $this->cat_id;
|
|
|
|
|
|
|
|
$cats = explode(',',$fields[0]['cat_id']);
|
2004-03-07 13:27:07 +01:00
|
|
|
$catnames = array();
|
|
|
|
foreach($cats as $cat)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2004-03-07 13:27:07 +01:00
|
|
|
if ($cat)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-03-07 13:27:07 +01:00
|
|
|
$cat = $this->cat->return_single((int)$cat);
|
|
|
|
$catnames[] = stripslashes($cat[0]['name']);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
2004-03-07 13:27:07 +01:00
|
|
|
$catname = implode('; ',$catnames);
|
|
|
|
if (!$this->cat_id)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-03-07 13:27:07 +01:00
|
|
|
$this->cat_id = count($cats) > 1 ? $cats[1] : $cats[0];
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2004-03-07 13:27:07 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var(array(
|
|
|
|
'ref_data' => $GLOBALS['egw']->common->grab_owner_name($record_owner),
|
2003-11-15 00:35:03 +01:00
|
|
|
'display_col' => lang('Record owner'),
|
|
|
|
'th_bg' => $tr_color
|
|
|
|
));
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->parse('cols','view_row',True);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var(array(
|
2003-11-15 00:35:03 +01:00
|
|
|
'ref_data' => $access_check,
|
|
|
|
'display_col' => lang('Record access'),
|
|
|
|
'th_bg' => $tr_color
|
|
|
|
));
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->parse('cols','view_row',True);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($catname)
|
2003-11-15 00:35:03 +01:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var(array(
|
2003-11-15 00:35:03 +01:00
|
|
|
'ref_data' => $catname,
|
|
|
|
'display_col' => lang('Category'),
|
|
|
|
'th_bg' => $tr_color
|
|
|
|
));
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->parse('cols','view_row',True);
|
2003-11-15 00:35:03 +01:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
if(($this->bo->grants[$record_owner] & PHPGW_ACL_EDIT) || ($record_owner == $GLOBALS['egw_info']['user']['account_id']))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$extra_vars = array('cd' => 16,'query' => $this->query,'cat_id' => $this->cat_id);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($referer)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$extra_vars += array('referer' => urlencode($referer));
|
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('edit_button',$this->html_1button_form('edit','Edit',
|
|
|
|
$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.edit&ab_id=' .$ab_id)));
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('copy_button',$this->html_1button_form('submit','copy',
|
|
|
|
$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.copy&ab_id=' . $fields[0]['id'])));
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($fields[0]['n_family'] && $fields[0]['n_given'])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('vcard_button',$this->html_1button_form('VCardForm','VCard',
|
|
|
|
$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$ab_id)));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('vcard_button',lang('no vcard'));
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('done_button',$this->html_1button_form('DoneForm','Done',
|
|
|
|
$referer ? $referer : $GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')));
|
|
|
|
$GLOBALS['egw']->template->set_var('access_link',$access_link);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('view_row',''); // cleanup to avoid showing categories twice
|
|
|
|
$GLOBALS['egw']->template->pfp('phpgw_body','view_t');
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->hooks->process(array(
|
2003-04-28 00:37:37 +02:00
|
|
|
'location' => 'addressbook_view',
|
|
|
|
'ab_id' => $ab_id
|
|
|
|
));
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function html_1button_form($name,$lang,$link)
|
|
|
|
{
|
|
|
|
$html = '<form method="POST" action="' . $link . '">' . "\n";
|
|
|
|
$html .= '<input type="submit" name="' . $name .'" value="' . lang($lang) . '">' . "\n";
|
|
|
|
$html .= '</form>' . "\n";
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
function preferences()
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$prefs = $_POST['prefs'];
|
|
|
|
$other = $_POST['other'];
|
2003-12-19 10:27:23 +01:00
|
|
|
$fcat_id = (int)$_POST['fcat_id'];
|
2001-09-15 14:54:43 +02:00
|
|
|
|
2002-04-13 05:34:23 +02:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
2002-04-13 05:49:39 +02:00
|
|
|
$customfields = array();
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($x,$y) = @each($custom))
|
|
|
|
foreach($custom as $x => $y)
|
2002-04-13 05:34:23 +02:00
|
|
|
{
|
|
|
|
$customfields[$y['name']] = $y['name'];
|
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2003-10-25 12:16:12 +02:00
|
|
|
$qfields = $this->bo->stock_contact_fields + $this->extrafields + $customfields;
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($_POST['cancel'])
|
2003-10-03 12:04:01 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->redirect_link('/preferences/index.php');
|
2003-10-03 12:04:01 +02:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($_POST['save'])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$totalerrors = 0;
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!count($prefs))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$errors[$totalerrors++] = lang('You must select at least 1 column to display');
|
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$totalerrors)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
@reset($qfields);
|
|
|
|
$this->bo->save_preferences($prefs,$other,$qfields,$fcat_id);
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->redirect_link('/preferences/index.php');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('Addressbook').' '.lang('Preferences');
|
|
|
|
$GLOBALS['egw']->common->phpgw_header();
|
2003-08-28 16:16:30 +02:00
|
|
|
echo parse_navbar();
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($totalerrors)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
echo '<p><center>' . $GLOBALS['egw']->common->error_list($errors) . '</center>';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('preferences' => 'preferences.tpl'));
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('action_url',$GLOBALS['egw']->link('/index.php','menuaction=addressbook.uiaddressbook.preferences'));
|
2001-07-13 11:03:31 +02:00
|
|
|
|
|
|
|
$i = 0; $j = 0;
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($col, $descr) = each($qfields))
|
|
|
|
foreach($qfields as $col => $descr)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
/* echo '<br>test: $col - $i $j - ' . count($abc); */
|
2001-07-13 11:03:31 +02:00
|
|
|
$i++; $j++;
|
|
|
|
$showcol = $this->display_name($col);
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$showcol) { $showcol = $col; }
|
2001-08-04 16:12:32 +02:00
|
|
|
/* yank the *'s prior to testing for a valid column description */
|
2001-08-27 11:52:35 +02:00
|
|
|
$coltest = ereg_replace('\*','',$showcol);
|
2003-12-01 01:46:45 +01:00
|
|
|
if($coltest)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var($col,$showcol);
|
|
|
|
if($GLOBALS['egw_info']['user']['preferences']['addressbook'][$col])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var($col.'_checked',' checked');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var($col.'_checked','');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-09-15 14:54:43 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($customfields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$custom_var = '
|
|
|
|
<tr>
|
2003-08-28 16:16:30 +02:00
|
|
|
<td bgcolor="'.$tr_color.'" colspan="6"><font color="#000000" face="">'.lang('Custom Fields').':</font></td>
|
2001-07-13 11:03:31 +02:00
|
|
|
</tr>
|
|
|
|
';
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
2003-08-28 16:16:30 +02:00
|
|
|
$i = 0;
|
2004-01-02 00:31:13 +01:00
|
|
|
while(list($cf) = each($customfields))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!($i % 6))
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
|
|
|
$custom_var .= "\n <tr bgcolor='$tr_color'>\n";
|
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
$custom_var .= ' <td><input type="checkbox" name="prefs['
|
|
|
|
. strtolower($cf) . ']"'
|
|
|
|
. ($this->prefs[$cf] ? ' checked' : '')
|
2003-08-28 16:16:30 +02:00
|
|
|
. '>' . str_replace('_',' ',$cf) . '</option></td>' . "\n";
|
2004-01-17 04:21:21 +01:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!(++$i % 6))
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
|
|
|
echo "</tr>\n";
|
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if($i = 6 - ($i % 6))
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
|
|
|
$custom_var .= " <td colspan=$i> </td>\n </tr>\n";
|
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('custom_fields',$custom_var);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('custom_fields','');
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$tr_color = $GLOBALS['egw']->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var(tr_color,$tr_color);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_showbirthday',lang('show birthday reminders on main screen'));
|
2001-09-15 14:54:43 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->prefs['mainscreen_showbirthdays'])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('show_birthday',' checked');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('show_birthday','');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$list = array(
|
2003-08-28 16:16:30 +02:00
|
|
|
'none' => lang('Show all'),
|
|
|
|
'yours' => lang('Only yours'),
|
|
|
|
'private' => lang('Private') /*,
|
|
|
|
'blank' => lang('Blank') */
|
2001-07-13 11:03:31 +02:00
|
|
|
);
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_default_filter',lang('Default Filter'));
|
|
|
|
$GLOBALS['egw']->template->set_var('filter_select',$this->formatted_list('other[default_filter]',$list,$this->prefs['default_filter']));
|
2001-09-15 14:54:43 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_autosave',lang('Autosave default category'));
|
2003-12-01 01:46:45 +01:00
|
|
|
if($this->prefs['autosave_category'])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('autosave',' checked');
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('autosave','');
|
|
|
|
}
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_defaultcat',lang('Default Category'));
|
|
|
|
$GLOBALS['egw']->template->set_var('cat_select',$this->cat_option($this->prefs['default_category'], false, false));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_fields',lang('Fields to show in address list'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_personal',lang('Personal'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_business',lang('Business'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_home',lang('Home'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_phones',lang('Extra').' '.lang('Phone Numbers'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_other',lang('Other').' '.lang('Fields'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_otherprefs',lang('Other').' '.lang('Preferences'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_save',lang('Save'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
|
|
|
|
$GLOBALS['egw']->template->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']);
|
|
|
|
$GLOBALS['egw']->template->set_var('th_text',$GLOBALS['egw_info']['theme']['th_text']);
|
|
|
|
$GLOBALS['egw']->template->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']);
|
|
|
|
$GLOBALS['egw']->template->set_var('row_off',$GLOBALS['egw_info']['theme']['row_off']);
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->pparse('out','preferences');
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
function get_form()
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$entry = $_POST['entry'];
|
|
|
|
$fcat_id = $_POST['fcat_id'];
|
|
|
|
$referer = $entry['referer'] ? $entry['referer'] : $_GET['referer'];
|
|
|
|
$referer = $referer ? $referer : $_POST['referer'];
|
2001-09-03 14:00:38 +02:00
|
|
|
|
2001-12-28 05:29:31 +01:00
|
|
|
$test = @unserialize(rawurldecode($entry));
|
|
|
|
if($test && ($test != $entry))
|
2001-12-23 18:28:14 +01:00
|
|
|
{
|
|
|
|
$entry = $test;
|
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
/* _debug_array($entry); exit; */
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$entry['bday_month'] && !$entry['bday_day'] && !$entry['bday_year'])
|
2001-07-09 19:35:27 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['bday'] = '';
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$bday_day = $entry['bday_day'];
|
2003-12-01 01:46:45 +01:00
|
|
|
if(strlen($bday_day) == 1)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$bday_day = '0' . $entry['bday_day'];
|
|
|
|
}
|
|
|
|
$fields['bday'] = $entry['bday_month'] . '/' . $bday_day . '/' . $entry['bday_year'];
|
2001-07-09 19:35:27 +02:00
|
|
|
}
|
|
|
|
|
2001-10-08 17:43:57 +02:00
|
|
|
$fields['url'] = $entry['url'] == 'http://' ? '' : $entry['url'];
|
|
|
|
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-08-28 16:16:30 +02:00
|
|
|
$fields['lid'] = $entry['lid'];
|
2001-07-13 11:03:31 +02:00
|
|
|
$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'];
|
2003-12-01 01:46:45 +01:00
|
|
|
if($entry['prefix']) { $pspc = ' '; }
|
|
|
|
if($entry['middle']) { $mspc = ' '; } else { $nspc = ' '; }
|
|
|
|
if($entry['suffix']) { $sspc = ' '; }
|
2001-07-13 11:03:31 +02:00
|
|
|
$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'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
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);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['address2'] = $entry['address2'];
|
|
|
|
$fields['address3'] = $entry['address3'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$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'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
if($entry['two_dom'])
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$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);
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2002-04-19 01:32:48 +02:00
|
|
|
$custom = $this->fields->read_custom_fields();
|
2004-01-02 00:31:13 +01:00
|
|
|
foreach($custom as $name => $val)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$fields[$val['name']] = $entry[$val['name']];
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['ophone'] = $entry['ophone'];
|
|
|
|
$fields['tz'] = $entry['timezone'];
|
|
|
|
$fields['pubkey'] = $entry['pubkey'];
|
|
|
|
$fields['note'] = $entry['notes'];
|
|
|
|
$fields['label'] = $entry['label'];
|
2001-07-09 19:35:27 +02:00
|
|
|
|
2004-02-15 19:14:44 +01:00
|
|
|
if($entry['access'] == 'True')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$fields['access'] = 'private';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$fields['access'] = 'public';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(is_array($fcat_id))
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2004-03-07 13:27:07 +01:00
|
|
|
$fields['cat_id'] = count($fcat_id) > 1 ? ','.implode(',',$fcat_id).',' : (int)$fcat_id[0];
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-03-07 13:27:07 +01:00
|
|
|
$fields['cat_id'] = (int)$fcat_id;
|
2001-09-20 05:55:57 +02:00
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-03 05:28:20 +01:00
|
|
|
$fields['ab_id'] = $entry['ab_id'];
|
|
|
|
$fields['tid'] = $entry['tid'];
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!$fields['tid'])
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$fields['tid'] = 'n';
|
|
|
|
}
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2002-09-16 02:08:38 +02:00
|
|
|
$fields['referer'] = $referer;
|
2001-07-13 11:03:31 +02:00
|
|
|
/* _debug_array($fields);exit; */
|
|
|
|
return $fields;
|
|
|
|
} /* end get_form() */
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
/* Following used for add/edit */
|
|
|
|
function addressbook_form($format,$action,$title='',$fields='',$customfields='',$cat_id='')
|
|
|
|
{
|
2003-08-28 16:16:30 +02:00
|
|
|
$referer = $_GET['referer'] ? $_GET['referer'] : $_POST['referer'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_file(array('form' => 'form.tpl'));
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
if(($GLOBALS['egw_info']['server']['countrylist'] == 'user_choice' &&
|
|
|
|
$GLOBALS['egw_info']['user']['preferences']['common']['countrylist'] == 'use_select') ||
|
|
|
|
($GLOBALS['egw_info']['server']['countrylist'] == 'force_select'))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$countrylist = True;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2001-07-13 11:03:31 +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'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$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'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$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'];
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$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'];
|
|
|
|
if(!$cat_id)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$cat_id = $fields['cat_id'];
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-11-23 03:10:21 +01:00
|
|
|
$cats_link = $this->cat_option($cat_id,True,False,True);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($access == 'private')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$access_check = ' checked';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
else
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$access_check = '';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($customfields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($name,$value) = each($customfields))
|
|
|
|
foreach($customfields as $name => $value)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-19 10:27:23 +01:00
|
|
|
$value = str_replace('_',' ',$value);
|
2001-07-13 11:03:31 +02:00
|
|
|
$custom .= '
|
2005-05-01 16:34:59 +02:00
|
|
|
<tr bgcolor="' . $GLOBALS['egw_info']['theme']['row_off'] . '">
|
2001-07-13 11:03:31 +02:00
|
|
|
<td> </td>
|
2005-05-01 16:34:59 +02:00
|
|
|
<td><font color="' . $GLOBALS['egw_info']['theme']['th_text'] . '" face="" size="-1">'.$value.':</font></td>
|
2003-04-06 14:09:35 +02:00
|
|
|
<td colspan="3"><INPUT size="30" name="entry[' . $name . ']" value="' . $fields[$name] . '"></td>
|
2001-07-13 11:03:31 +02:00
|
|
|
</tr>
|
|
|
|
';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-03 05:28:20 +01:00
|
|
|
if($format != "view")
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-04 16:12:32 +02:00
|
|
|
/* Preferred phone number radio buttons */
|
2001-07-13 11:03:31 +02:00
|
|
|
$pref[0] = '<font size="-2">';
|
|
|
|
$pref[1] = '(' . lang('pref') . ')</font>';
|
2004-01-02 00:31:13 +01:00
|
|
|
// while(list($name,$val) = each($this->bo->tel_types))
|
|
|
|
foreach($this->bo->tel_types as $name => $val)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2003-12-03 05:28:20 +01:00
|
|
|
$str[$name] = "\n".' <input type="radio" name="entry[tel_prefer]" value="'.$name.'"';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($name == $preferred)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
|
|
|
$str[$name] .= ' checked';
|
|
|
|
}
|
|
|
|
$str[$name] .= '>';
|
|
|
|
$str[$name] = $pref[0].$str[$name].$pref[1];
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var("pref_".$name,$str[$name]);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(strlen($bday) > 2)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2004-02-22 16:18:36 +01:00
|
|
|
list($month, $day, $year) = split('/', $bday);
|
2001-07-13 11:03:31 +02:00
|
|
|
$temp_month[$month] = ' selected';
|
|
|
|
$bday_month = '<select name="entry[bday_month]">'
|
|
|
|
. '<option value=""' . $temp_month[0] . '>' . '</option>'
|
2004-01-17 04:21:21 +01:00
|
|
|
. '<option value="1"' . $temp_month[1] . '>' . lang('january') . '</option>'
|
2001-07-13 11:03:31 +02:00
|
|
|
. '<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>'
|
2004-01-17 04:21:21 +01:00
|
|
|
. '<option value="6"' . $temp_month[6] . '>' . lang('june') . '</option>'
|
2001-07-13 11:03:31 +02:00
|
|
|
. '<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>'
|
|
|
|
. '</select>';
|
|
|
|
$bday_day = '<input maxlength="2" name="entry[bday_day]" value="' . $day . '" size="2">';
|
|
|
|
$bday_year = '<input maxlength="4" name="entry[bday_year]" value="' . $year . '" size="4">';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$bday_month = '<select name="entry[bday_month]">'
|
|
|
|
. '<option value="" selected> </option>'
|
|
|
|
. '<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>'
|
|
|
|
. '</select>';
|
|
|
|
$bday_day = '<input name="entry[bday_day]" size="2" maxlength="2">';
|
|
|
|
$bday_year = '<input name="entry[bday_year]" size="4" maxlength="4">';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
|
|
|
$time_zone = '<select name="entry[timezone]">' . "\n";
|
2003-12-01 01:46:45 +01:00
|
|
|
for($i = -23; $i<24; $i++)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
$time_zone .= '<option value="' . $i . '"';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($i == $timezone)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
$time_zone .= ' selected';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2003-12-01 01:46:45 +01:00
|
|
|
if($i < 1)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
$time_zone .= '>' . $i . '</option>' . "\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
$time_zone .= '>+' . $i . '</option>' . "\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
$time_zone .= '</select>' . "\n";
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2001-07-13 11:03:31 +02:00
|
|
|
$email_type = '<select name=entry[email_type]>';
|
2004-01-02 00:31:13 +01:00
|
|
|
// while($type = each($this->bo->email_types))
|
|
|
|
foreach($this->bo->email_types as $type => $name)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2004-01-02 00:31:13 +01:00
|
|
|
$email_type .= '<option value="' . $type . '"';
|
|
|
|
if($type == $emailtype)
|
|
|
|
{
|
|
|
|
$email_type .= ' selected';
|
|
|
|
}
|
|
|
|
$email_type .= '>' . $name . '</option>';
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
$email_type .= '</select>';
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2004-01-02 00:31:13 +01:00
|
|
|
// reset($this->bo->email_types);
|
2001-07-13 11:03:31 +02:00
|
|
|
$hemail_type = '<select name=entry[hemail_type]>';
|
2004-01-02 00:31:13 +01:00
|
|
|
// while($type = each($this->bo->email_types))
|
|
|
|
foreach($this->bo->email_types as $type => $name)
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2004-01-02 00:31:13 +01:00
|
|
|
$hemail_type .= '<option value="' . $type . '"';
|
|
|
|
if($type == $hemailtype)
|
|
|
|
{
|
|
|
|
$hemail_type .= ' selected';
|
|
|
|
}
|
|
|
|
$hemail_type .= '>' . $name . '</option>';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-08-27 11:52:35 +02:00
|
|
|
$hemail_type .= '</select>';
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2004-01-02 00:31:13 +01:00
|
|
|
// reset($this->bo->adr_types);
|
|
|
|
// while(list($type,$val) = each($this->bo->adr_types))
|
|
|
|
foreach($this->bo->adr_types as $type => $val)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$badrtype .= "\n".'<INPUT type="checkbox" name="entry[one_'.$type.']"';
|
|
|
|
$ot = 'one_'.$type;
|
|
|
|
eval("
|
2003-12-01 01:46:45 +01:00
|
|
|
if(\$$ot=='on') {
|
2001-07-13 11:03:31 +02:00
|
|
|
\$badrtype .= ' value=\"on\" checked';
|
|
|
|
}
|
|
|
|
");
|
|
|
|
$badrtype .= '>'.$val;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2004-01-02 00:31:13 +01:00
|
|
|
// reset($this->bo->adr_types);
|
|
|
|
// while(list($type,$val) = each($this->bo->adr_types))
|
|
|
|
foreach($this->bo->adr_types as $type => $val)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$hadrtype .= "\n".'<INPUT type="checkbox" name="entry[two_'.$type.']"';
|
|
|
|
$tt = 'two_'.$type;
|
|
|
|
eval("
|
2003-12-01 01:46:45 +01:00
|
|
|
if(\$$tt=='on') {
|
2001-07-13 11:03:31 +02:00
|
|
|
\$hadrtype .= ' value=\"on\" checked';
|
|
|
|
}
|
|
|
|
");
|
|
|
|
$hadrtype .= '>'.$val;
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
|
|
|
$notes = '<TEXTAREA cols="60" name="entry[notes]" rows="4">' . $notes . '</TEXTAREA>';
|
|
|
|
$label = '<TEXTAREA cols="60" name="entry[label]" rows="6">' . $label . '</TEXTAREA>';
|
|
|
|
$pubkey = '<TEXTAREA cols="60" name="entry[pubkey]" rows="6">' . $pubkey . '</TEXTAREA>';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$notes = '<form><TEXTAREA cols="60" name="entry[notes]" rows="4">'
|
2001-09-20 05:55:57 +02:00
|
|
|
. $notes . '</TEXTAREA></form>';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($bday == '//')
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
$bday = '';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if($action)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
echo '<FORM action="' . $GLOBALS['egw']->link('/index.php', $action . '&referer='.urlencode($referer)).'" method="post">';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
|
2003-12-01 01:46:45 +01:00
|
|
|
if(!ereg('^http://',$url))
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2001-08-27 11:52:35 +02:00
|
|
|
$url = 'http://' . $url;
|
2004-01-17 04:21:21 +01:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$birthday = $GLOBALS['egw']->common->dateformatorder($bday_year,$bday_month,$bday_day)
|
2003-12-03 05:28:20 +01:00
|
|
|
. '<font face="'.$theme["font"].'" size="-2">'.lang('(e.g. 1969)').'</font>';
|
2003-12-01 01:46:45 +01:00
|
|
|
if($format == 'edit')
|
2001-07-13 11:03:31 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$create .= '<tr bgcolor="' . $GLOBALS['egw_info']['theme']['th_bg'] . '"><td colspan="2"><font size="-1">' . lang("Created by") . ':</font></td>'
|
2001-07-13 11:03:31 +02:00
|
|
|
. '<td colspan="3"><font size="-1">'
|
2005-05-01 16:34:59 +02:00
|
|
|
. $GLOBALS['egw']->common->grab_owner_name($fields["owner"]);
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-07-13 11:03:31 +02:00
|
|
|
$create .= '';
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2004-01-17 04:21:21 +01:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_home',lang('Home'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_business',lang('Business'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_personal',lang('Personal'));
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_lastname',lang('Last Name'));
|
|
|
|
$GLOBALS['egw']->template->set_var('lastname',$lastname);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_firstname',lang('First Name'));
|
|
|
|
$GLOBALS['egw']->template->set_var('firstname',$firstname);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_middle',lang('Middle Name'));
|
|
|
|
$GLOBALS['egw']->template->set_var('middle',$middle);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_prefix',lang('Prefix'));
|
|
|
|
$GLOBALS['egw']->template->set_var('prefix',$prefix);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_suffix',lang('Suffix'));
|
|
|
|
$GLOBALS['egw']->template->set_var('suffix',$suffix);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_birthday',lang('Birthday'));
|
|
|
|
$GLOBALS['egw']->template->set_var('birthday',$birthday);
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_company',lang('Company Name'));
|
|
|
|
$GLOBALS['egw']->template->set_var('company',$company);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_department',lang('Department'));
|
|
|
|
$GLOBALS['egw']->template->set_var('department',$department);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_title',lang('Title'));
|
|
|
|
$GLOBALS['egw']->template->set_var('title',$title);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_email',lang('Business Email'));
|
|
|
|
$GLOBALS['egw']->template->set_var('email',$email);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_email_type',lang('Business EMail Type'));
|
|
|
|
$GLOBALS['egw']->template->set_var('email_type',$email_type);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_url',lang('URL'));
|
|
|
|
$GLOBALS['egw']->template->set_var('url',$url);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_timezone',lang('time zone offset'));
|
|
|
|
$GLOBALS['egw']->template->set_var('timezone',$time_zone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_fax',lang('Business Fax'));
|
|
|
|
$GLOBALS['egw']->template->set_var('fax',$fax);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_wphone',lang('Business Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('wphone',$wphone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_pager',lang('Pager'));
|
|
|
|
$GLOBALS['egw']->template->set_var('pager',$pager);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_mphone',lang('Cell Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('mphone',$mphone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_msgphone',lang('Message Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('msgphone',$msgphone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_isdnphone',lang('ISDN Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('isdnphone',$isdnphone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_carphone',lang('Car Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('carphone',$carphone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_vidphone',lang('Video Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('vidphone',$vidphone);
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_ophone',lang('Other Number'));
|
|
|
|
$GLOBALS['egw']->template->set_var('ophone',$ophone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_bstreet',lang('Business Street'));
|
|
|
|
$GLOBALS['egw']->template->set_var('bstreet',$bstreet);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_address2',lang('Address Line 2'));
|
|
|
|
$GLOBALS['egw']->template->set_var('address2',$address2);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_address3',lang('Address Line 3'));
|
|
|
|
$GLOBALS['egw']->template->set_var('address3',$address3);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_bcity',lang('Business City'));
|
|
|
|
$GLOBALS['egw']->template->set_var('bcity',$bcity);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_bstate',lang('Business State'));
|
|
|
|
$GLOBALS['egw']->template->set_var('bstate',$bstate);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_bzip',lang('Business Zip Code'));
|
|
|
|
$GLOBALS['egw']->template->set_var('bzip',$bzip);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_bcountry',lang('Business Country'));
|
|
|
|
$GLOBALS['egw']->template->set_var('bcountry',$bcountry);
|
2003-12-01 01:46:45 +01:00
|
|
|
if($countrylist)
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('bcountry',$GLOBALS['egw']->country->form_select($bcountry,'entry[bcountry]'));
|
2001-07-12 06:09:12 +02:00
|
|
|
}
|
2001-07-13 11:03:31 +02:00
|
|
|
else
|
2001-07-12 06:09:12 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('bcountry','<input name="entry[bcountry]" value="' . $bcountry . '">');
|
|
|
|
}
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_badrtype',lang('Address Type'));
|
|
|
|
$GLOBALS['egw']->template->set_var('badrtype',$badrtype);
|
|
|
|
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hphone',lang('Home Phone'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hphone',$hphone);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hemail',lang('Home Email'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hemail',$hemail);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hemail_type',lang('Home EMail Type'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hemail_type',$hemail_type);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hstreet',lang('Home Street'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hstreet',$hstreet);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hcity',lang('Home City'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hcity',$hcity);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hstate',lang('Home State'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hstate',$hstate);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hzip',lang('Home Zip Code'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hzip',$hzip);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_hcountry',lang('Home Country'));
|
2003-12-01 01:46:45 +01:00
|
|
|
if($countrylist)
|
2003-08-28 16:16:30 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('hcountry',$GLOBALS['egw']->country->form_select($hcountry,'entry[hcountry]'));
|
2001-07-12 06:09:12 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('hcountry','<input name="entry[hcountry]" value="' . $hcountry . '">');
|
2001-07-12 06:09:12 +02:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_hadrtype',lang('Address Type'));
|
|
|
|
$GLOBALS['egw']->template->set_var('hadrtype',$hadrtype);
|
2001-07-12 06:09:12 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('create',$create);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_notes',lang('notes'));
|
|
|
|
$GLOBALS['egw']->template->set_var('notes',$notes);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_label',lang('label'));
|
|
|
|
$GLOBALS['egw']->template->set_var('label',$label);
|
|
|
|
$GLOBALS['egw']->template->set_var('lang_pubkey',lang('Public Key'));
|
|
|
|
$GLOBALS['egw']->template->set_var('pubkey',$pubkey);
|
|
|
|
$GLOBALS['egw']->template->set_var('access_check',$access_check);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_private',lang('Private'));
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_cats',lang('Category'));
|
|
|
|
$GLOBALS['egw']->template->set_var('cats_link',$cats_link);
|
2003-12-01 01:46:45 +01:00
|
|
|
if($customfields)
|
2001-07-08 15:54:40 +02:00
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_custom',lang('Custom Fields').':');
|
|
|
|
$GLOBALS['egw']->template->set_var('custom',$custom);
|
2001-07-13 11:03:31 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('lang_custom','');
|
|
|
|
$GLOBALS['egw']->template->set_var('custom','');
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->set_var('th_bg', $GLOBALS['egw_info']['theme']['th_bg']);
|
|
|
|
$GLOBALS['egw']->template->set_var('th_text', $GLOBALS['egw_info']['theme']['th_text']);
|
|
|
|
$GLOBALS['egw']->template->set_var('row_on', $GLOBALS['egw_info']['theme']['row_on']);
|
|
|
|
$GLOBALS['egw']->template->set_var('row_off', $GLOBALS['egw_info']['theme']['row_off']);
|
|
|
|
$GLOBALS['egw']->template->set_var('row_text',$GLOBALS['egw_info']['theme']['row_text']);
|
2001-07-08 15:54:40 +02:00
|
|
|
|
2005-05-01 16:34:59 +02:00
|
|
|
$GLOBALS['egw']->template->pfp('out','form');
|
2001-08-04 16:12:32 +02:00
|
|
|
} /* end form function */
|
2001-07-08 15:54:40 +02:00
|
|
|
}
|
|
|
|
?>
|