[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] addressbook/inc class.uicatalog_contact_addr_type.inc
From: |
skwashd |
Subject: |
[Phpgroupware-cvs] addressbook/inc class.uicatalog_contact_addr_type.inc.php, 1.2 class.uicatalog_contact_comm_descr.inc.php, 1.2 class.uicatalog_contact_comm_type.inc.php, 1.2 class.uiaddressbook_prefs.inc.php, 1.2 class.socatalog_contact_comm_descr.inc.php, 1.2 class.socatalog_contact_comm_type.inc.php, 1.2 class.socatalog_contact_note_type.inc.php, 1.2 class.uicatalog_contact_note_type.inc.php, 1.2 class.uicategorize_contacts.inc.php, 1.2 class.widget_lists.inc.php, 1.2 class.socatalog_contact_addr_type.inc.php, 1.2 arr.php, 1.2 class.addressbook_importer.inc.php, 1.2 class.catalog_manager.inc.php, 1.2 class.ipc_addressbook.inc.php, 1.2 class.bocatalog_contact_note_type.inc.php, 1.2 class.bocatalog_contact_comm_type.inc.php, 1.2 class.boaddressbook_prefs.inc.php, 1.2 class.bocatalog_contact_addr_type.inc.php, 1.2 class.bocatalog_contact_comm_descr.inc.php, 1.2 hook_manual.inc.php, 1.6 hook_sidebox_menu.inc.php, 1.2 class.uiXport.inc.php, 1.20 hook_config_validate.inc.php, 1.2 hook_deleteaccount.inc.php, 1.6 hook_home.inc.php, 1.23 hook_admin.inc.php, 1.15 functions.inc.php, 1.103 class.uifields.inc.php, 1.12 class.uivcard.inc.php, 1.11 class.soaddressbook.inc.php, 1.17 class.boXport.inc.php, 1.10 class.boaddressbook.inc.php, 1.26 class.pdb.inc.php, 1.4 class.uiaddressbook.inc.php, 1.56 hook_notifywindow.inc.php, 1.8 hook_preferences.inc.php, 1.22 |
Date: |
Thu, 24 Feb 2005 13:20:10 -0000 |
Update of addressbook/inc
Added Files:
Branch: MAIN
class.uicatalog_contact_addr_type.inc.php lines: +92 -0
class.uicatalog_contact_comm_descr.inc.php lines: +124 -0
class.uicatalog_contact_comm_type.inc.php lines: +93 -0
class.uiaddressbook_prefs.inc.php lines: +961 -0
class.socatalog_contact_comm_descr.inc.php lines: +75 -0
class.socatalog_contact_comm_type.inc.php lines: +60 -0
class.socatalog_contact_note_type.inc.php lines: +60 -0
class.uicatalog_contact_note_type.inc.php lines: +93 -0
class.uicategorize_contacts.inc.php lines: +192 -0
class.widget_lists.inc.php lines: +374 -0
class.socatalog_contact_addr_type.inc.php lines: +60 -0
arr.php lines: +16 -0
class.addressbook_importer.inc.php lines: +50 -0
class.catalog_manager.inc.php lines: +338 -0
class.ipc_addressbook.inc.php lines: +394 -0
class.bocatalog_contact_note_type.inc.php lines: +34 -0
class.bocatalog_contact_comm_type.inc.php lines: +34 -0
class.boaddressbook_prefs.inc.php lines: +155 -0
class.bocatalog_contact_addr_type.inc.php lines: +34 -0
class.bocatalog_contact_comm_descr.inc.php lines: +91 -0
hook_manual.inc.php lines: +1 -1
hook_sidebox_menu.inc.php lines: +31 -0
Modified Files:
Branch: MAIN
class.uiXport.inc.php lines: +109 -92
hook_config_validate.inc.php lines: +1 -1
hook_deleteaccount.inc.php lines: +5 -4
hook_home.inc.php lines: +78 -43
hook_admin.inc.php lines: +18 -14
functions.inc.php lines: +8 -14
class.uifields.inc.php lines: +210 -38
class.uivcard.inc.php lines: +120 -43
class.soaddressbook.inc.php lines: +981 -89
class.boXport.inc.php lines: +83 -93
class.boaddressbook.inc.php lines: +785 -242
class.pdb.inc.php lines: +1 -1
class.uiaddressbook.inc.php lines: +2982 -1429
hook_notifywindow.inc.php lines: +16 -13
hook_preferences.inc.php lines: +2 -2
Log Message:
merge from 16
====================================================
Index: class.uicatalog_contact_addr_type.inc.php
<?php
include('class.catalog_manager.inc.php');
class uicatalog_contact_addr_type extends catalog_manager
{
var $public_functions = array('view' => True);
var $modify = False;
function uicatalog_contact_addr_type()
{
$this->_constructor();
$this->bo =
CreateObject('addressbook.bocatalog_contact_addr_type');
$this->form_action =
'menuaction=addressbook.uicatalog_contact_addr_type.view';
$this->catalog_name = 'addr_types';
$this->headers = array('Type', 'Edit', 'Delete');
$this->array_name = 'addr_types_array';
$this->index = 'key_addr_id';
$this->title = 'Location Types - Catalog';
$this->catalog_button_name = 'addr_types_add_row';
$this->key_edit_name = 'addr_type_id';
$this->num_cols = 1;
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[addr_description]',
'value'=> $this->entry['addr_description']))));
$this->objs_data = array('value'=> array('type' =>
'data',
'field' =>
'addr_description'),
'edit' => array('type' =>
'link',
'mode' =>
'edit',
'key' =>
'addr_type_id',
'action'=>
'addr_types_edit_row',
'extra'=> ''),
'delete'=>array('type' =>
'link',
'mode' =>
'delete',
'key' =>
'addr_type_id',
'action'=>
'addr_types_del_row',
'extra'=> ''));
}
function view()
{
$this->get_vars();
$this->validate_action($this->action);
$this->create_window($this->catalog_name, $this->entry,
$this->title);
if($this->modify)
{
$contacts = CreateObject('phpgwapi.contacts');
$contacts->delete_sessiondata('addr_type');
}
}
function select_catalog()
{
$this->addr_types_array = $this->bo->select_catalog();
}
function insert($fields)
{
$this->bo->insert($fields);
$this->modify = True;
}
function delete($key)
{
$this->bo->delete($key);
$this->modify = True;
}
function update($key, $fields)
{
$this->bo->update($key, $fields);
$this->modify = True;
}
function edit($key)
{
$this->catalog_button_name = 'addr_types_update_row';
$this->key_edit_name = 'addr_type_id';
$this->key_edit_id = $key;
$record = $this->bo->get_record($key);
$this->entry['addr_description'] =
$record[0]['addr_description'];
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[addr_description]',
'value'=> $this->entry['addr_description']))));
}
}
?>
====================================================
Index: class.uicatalog_contact_comm_descr.inc.php
<?php
include('class.catalog_manager.inc.php');
class uicatalog_contact_comm_descr extends catalog_manager
{
var $public_functions = array('view' => True);
var $modify = False;
function uicatalog_contact_comm_descr()
{
$this->_constructor();
$this->bo =
CreateObject('addressbook.bocatalog_contact_comm_descr');
$this->form_action =
'menuaction=addressbook.uicatalog_contact_comm_descr.view';
$this->catalog_name = 'comm_descr';
$this->headers = array('Type', 'Description', 'Edit',
'Delete');
$this->array_name = 'comm_descr_array';
$this->index = '';
$this->title = 'Communications Description - Catalog';
$this->catalog_button_name = 'comm_descr_add_row';
$this->key_edit_name = 'comm_descr_id';
$this->num_cols = 2;
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'combo',
'name' => 'entry[comm_type]',
'value'=> $this->get_options()))),
2 => array('Description',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[comm_description]',
'value'=> ''))));
$this->objs_data = array('value'=> array('type' =>
'data',
'field' =>
'comm_type'),
'value1'=> array('type' =>
'data',
'field' =>
'comm_description'),
'edit' => array('type' =>
'link',
'mode' =>
'edit',
'key' =>
'comm_descr_id',
'action'=>
'comm_descr_edit_row',
'extra'=> ''),
'delete'=>array('type' =>
'link',
'mode' =>
'delete',
'key' =>
'comm_descr_id',
'action'=>
'comm_descr_del_row',
'extra'=> ''));
}
function view()
{
$this->get_vars();
$this->validate_action($this->action);
$this->create_window($this->catalog_name, $this->entry,
$this->title);
if($this->modify)
{
$contacts = CreateObject('phpgwapi.contacts');
$contacts->delete_sessiondata('comm_descr');
}
}
function select_catalog()
{
$this->comm_descr_array = $this->bo->select_catalog();
}
function insert($fields)
{
$this->bo->insert($fields);
$this->modify = True;
}
function delete($key)
{
$this->bo->delete($key);
$this->modify = True;
}
function update($key, $fields)
{
$this->bo->update($key, $fields);
$this->modify = True;
}
function edit($key)
{
$this->catalog_button_name = 'comm_descr_update_row';
$this->key_edit_name = 'comm_descr_id';
$this->key_edit_id = $key;
$record = $this->bo->get_record($key);
$entry['comm_type'] = $record[0]['comm_type'];
$entry['comm_description'] =
$record[0]['comm_description'];
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'combo',
'name' => 'entry[comm_type]',
'value'=> $this->get_options($entry['comm_type'])))),
2 => array('Description',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[comm_description]',
'value'=> $entry['comm_description']))));
}
function get_options($selected='')
{
$this->comm_type_array =
$this->bo->select_catalog_types();
foreach($this->comm_type_array as $option)
{
if ($option['comm_type_id'] == $selected)
{
$options .= '<option
value="'.$option['comm_type_id'].'" selected>'
.
$option['comm_type_description'] . '</option>';
}
else
{
$options .= '<option
value="'.$option['comm_type_id'].'">'
.
$option['comm_type_description'] . '</option>';
}
}
return $options;
}
}
?>
====================================================
Index: class.uicatalog_contact_comm_type.inc.php
<?php
include('class.catalog_manager.inc.php');
class uicatalog_contact_comm_type extends catalog_manager
{
var $public_functions = array('view' => True);
var $modify = False;
function uicatalog_contact_comm_type()
{
$this->_constructor();
$this->bo =
CreateObject('addressbook.bocatalog_contact_comm_type');
$this->form_action =
'menuaction=addressbook.uicatalog_contact_comm_type.view';
$this->catalog_name = 'comm_types';
$this->headers = array('Type', 'Edit', 'Delete');
$this->array_name = 'comm_types_array';
$this->index = 'key_comm_id';
$this->title = 'Communication Types - Catalog';
$this->catalog_button_name = 'comm_types_add_row';
$this->key_edit_name = 'comm_type_id';
$this->num_cols = 1;
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[comm_type_description]',
'value'=> $this->entry['comm_type_description']))));
$this->objs_data = array('value'=> array('type' =>
'data',
'field' =>
'comm_type_description'),
'edit' => array('type' =>
'link',
'mode' =>
'edit',
'key' =>
'comm_type_id',
'action'=>
'comm_types_edit_row',
'extra'=> ''),
'delete'=>array('type' =>
'link',
'mode' =>
'delete',
'key' =>
'comm_type_id',
'action'=>
'comm_types_del_row',
'extra'=> ''));
}
function view()
{
$this->get_vars();
$this->validate_action($this->action);
$this->create_window($this->catalog_name, $this->entry,
$this->title);
if($this->modify)
{
$contacts = CreateObject('phpgwapi.contacts');
$contacts->delete_sessiondata('comm_type');
}
}
function select_catalog()
{
$this->comm_types_array = $this->bo->select_catalog();
}
function insert($fields)
{
$this->bo->insert($fields);
$this->modify = True;
}
function delete($key)
{
$this->bo->delete($key);
$this->modify = True;
}
function update($key, $fields)
{
$this->bo->update($key, $fields);
$this->modify = True;
}
function edit($key)
{
$this->catalog_button_name = 'comm_types_update_row';
$this->key_edit_name = 'comm_type_id';
$this->key_edit_id = $key;
$record = $this->bo->get_record($key);
$this->entry['comm_type_description'] =
$record[0]['comm_type_description'];
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[comm_type_description]',
'value'=> $this->entry['comm_type_description']))));
}
}
?>
====================================================
Index: class.uiaddressbook_prefs.inc.php
<?php
/**************************************************************************\
* phpGroupWare API - Commononly used functions *
* This file written by Alex Borges <address@hidden> *
* UI for addressbook preferences *
* Copyright (C) 2003 Free Software Foundation *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare Addressbook app *
* http://www.phpgroupware.org/ *
* ------------------------------------------------------------------------ *
* This library 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. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* You should have received a copy of the GNU General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
class uiaddressbook_prefs
{
var $prefs;
var $template;
//@param selected_fields
//@discussion transient selected fields. Allways holds what the fields
//that are found as selected in GET/POST vars, NOT the ones in session
data
var $selected_fields;
//@param cached_selected_fields
//@discussion Selected fields that are in the session data
var $cached_selected_fields;
var $public_functions = array(
'index' => True,
'remove_me' => True,
'css' => true
);
/address@hidden remove_me
@discussion transient field representing the false field to remove from
the
table's column
*/
var $remove_me;
/*
@param contacts
@discussion Should be contacts but for now we are going to make a
uiaddressbook
because its where the addressbook caches the com-types catalog
*/
var $contacts;
/*
@param org_or_person
@discussion A simple flag that determines if we are editing the
showable fields for
orgs or persons.
*/
var $org_or_person='Persons';
var $map_tpl_to_real=array(
'select_columns_form_name'=> 'on_constructor',
'select_columns_form_action' => 'on_constructor',
'select_columns_selectbox_name' => 'var_dependant',
'select_columns_submit_value' => 'on_constructor',
'lang_select_cols' => 'on_constructor',
'lang_abprefs' => 'on_constructor',
'B_select_columns_form_options' => 'on_constructor',
'select_columns_comtypes_name' => 'var_dependant',
'B_select_columns_comtypes_options' => 'on_constructor',
'org_preferences_link' => 'on_constructor',
'person_preferences_link' => 'on_constructor',
'cat_options' => 'on_contructor',
'adm_pref_type' => 'user',
'hider_open' => '',
'hider_close' => ''
);
//@param fields_show_selectbox
//@discussion fields to show in the selectbox
var $fields_show_selectbox;
var $lang_fields;
var $bo;
var $submit;
function uiaddressbook_prefs()
{
$this->template = $GLOBALS['phpgw']->template;
if(!$this->session_data_saved())
{
$this->map_tpl_to_real['lang_select_cols']=$GLOBALS['phpgw']->lang('Fields to
show in address list');
$this->map_tpl_to_real['lang_abprefs']=$GLOBALS['phpgw']->lang('addressbook
preferences');
$this->map_tpl_to_real['select_columns_submit_value']=$GLOBALS['phpgw']->lang('select
fields');
$this->map_tpl_to_real['submit_save_value']=$GLOBALS['phpgw']->lang('save');
$this->map_tpl_to_real['submit_cancel_value']=$GLOBALS['phpgw']->lang('cancel');
$this->map_tpl_to_real['submit_remove_value']=$GLOBALS['phpgw']->lang('remove');
}
else
{
$this->read_sessiondata();
}
$this->contacts = CreateObject('phpgwapi.contacts');
$this->bo=CreateObject('addressbook.boaddressbook_prefs');
if($this->is_current_admin())
{
$temp=get_var('adm_pref_type',array('get','post'));
//print "<BR><B>Admin user var
is".$temp."</B><BR>";
//Changed preference type tav
if(isset($temp))
{
//Prefs type change, flush cache
if($temp !=
$this->map_tpl_to_real['adm_pref_type'])
{
//print "<BR><B>Flushing
cache</B><BR>";
$this->clear_dinamic_data();
}
$this->map_tpl_to_real['adm_pref_type']=$temp;
}
$this->build_admin_tabs();
}
$this->bo->read_preferences($this->map_tpl_to_real['adm_pref_type']);
// print "<BR><B>current tab
is".$this->map_tpl_to_real['adm_pref_type']."</B><BR>";
$this->map_tpl_to_real['org_preferences_link']=$GLOBALS['phpgw']->link('/index.php',
array(
'menuaction' =>
'addressbook.uiaddressbook_prefs.index',
'org_or_person' =>
'Organizations',
'adm_pref_type' =>
$this->map_tpl_to_real['adm_pref_type']
)
);
$this->map_tpl_to_real['person_preferences_link']=$GLOBALS['phpgw']->link('/index.php',
array(
'menuaction' =>
'addressbook.uiaddressbook_prefs.index',
'org_or_person' => 'Persons',
'adm_pref_type' =>
$this->map_tpl_to_real['adm_pref_type']
)
);
/* print "<p><b>Preferences</b></p>";
print_r($this->bo->person_columns);
print "<p><b>Preferences</b></p>";
print_r($this->bo->org_columns);
*/
}
//@function get_addressbook_cats
//Gets the <option> tags of the categories of the addressbook,
also asks what return selected
function get_addressbook_cats($selected=0)
{
$tmp=CreateObject('phpgwapi.categories');
$tmp->app_name='addressbook';
//Forced category, can be an administrator not the
forced
//preferences tab
//print "<BR><B>Default category is
".$this->bo->default_category_forced."</B><BR>";
// print "<BR><B>Tab is
".$this->map_tpl_to_real['adm_pref_type']."</B><BR>";
if($this->bo->default_category_forced &&
$this->map_tpl_to_real['adm_pref_type']!='forced')
{
//print "<BR><B>FORCED cat</B><BR";
$ret="<option value='"
.$this->bo->default_category.
"'>".
$tmp->id2name($this->bo->default_category)
."</option>";
}
else
{
$ret=
$tmp->formated_list('select','all',$selected,True);
}
if($this->map_tpl_to_real['adm_pref_type']=="forced")
{
$ret="<option value='user_default'>User
default</option>".$ret;
}
return $ret;
}
//@function hashify
//I dislike single dimmension numeric key arrays, i use this
function to convert them to a hash
function hashify($ar,$exclude)
{
if(is_array($ar))
{
reset($ar);
while(list($k,$v)=each($ar))
{
if(!is_array($v))
{
$tmp[$v]=True;
}
else
{
$name=array_pop($exclude);
$tmp[$name]=$this->hashify($v,$exclude);
}
}
}
else
{
if(!empty($ar))
{
$tmp[$ar]=$ar;
}
else
{
return $false;
}
}
return $tmp;
}
function get_vars()
{
$temp=get_var('org_or_person',array('get','post'));
if($temp=='Organizations' || $temp == 'Persons')
{
$this->org_or_person=$temp;
}
$this->map_tpl_to_real['select_columns_form_action']=$GLOBALS['phpgw']->link
('/index.php',
array(
'menuaction' =>
"addressbook.uiaddressbook_prefs.columns_selected",
'org_or_person' =>
$this->org_or_person
)
);
$this->map_tpl_to_real['select_columns_selectbox_name']='selected_fields['.$this->org_or_person.'][]';
$this->map_tpl_to_real['select_columns_comtypes_name']='selected_fields['.$this->org_or_person.'][comm_types][]';
$this->selected_fields=get_var('selected_fields',array('post','GET'));
/*
print "<p><b>Selected fields</b></p>";
print_r($this->selected_fields);*/
if(is_array($this->selected_fields[$this->org_or_person]))
{
/* print "<p><b>There are
".count($this->selected_fields[$this->org_or_person])." selected</b></p>"; */
$this->selected_fields[$this->org_or_person]=$this->hashify($this->selected_fields[$this->org_or_person],array('comm_types'));
}
//three kinds of submit
//They have hit the button to add selected fields
if(get_var('select_fields',array('post','get')))
{
/* print '<BR><B>selectfields</B><BR>'; */
$temp='select_fields';
}
elseif(get_var('save',array('post','get')))
{
$temp='save';
}
elseif(get_var('cancel',array('post','get')))
{
$temp='cancel';
}
else
{
$temp=get_var('remove_me',array('get','post'));
/*print '<BR><B>remove type'.$temp.'</B><BR>';*/
if($this->selected_fields[$this->org_or_person][$temp])
{
//if we have found an element to be
removed
//remove it from here
//This should never happen though
unset($this->select_fields[$this->org_or_person][$temp]);
}
$this->remove_me=$temp;
$temp='remove';
}
$this->submit=$temp;
/*print '<BR><B>selected </B>';
print_r($this->selected_fields);
print '<BR><B>Submited</B>';
print $this->submit; */
$temp=get_var('org_or_person',array('get','post'));
if($temp=='Organizations' || $temp == 'Persons')
{
$this->org_or_person=$temp;
}
$temp=get_var('cat_id',array('get','post'));
// print $temp;
if($temp)
{
//Admin wants to delete the cat_id from
preferences
if($temp=='user_default' &&
$this->map_tpl_to_real['adm_pref_type']=='forced')
{
$this->bo->default_category_forced=false;
$this->bo->default_category='__NONE__';
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats();
$temp=($this->bo->default_category ==
'' ) ? '__NONE__' : $this->bo->default_category;
}
else
{
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats($temp);
}
$this->map_tpl_to_real['cat_id']=$temp;
//print '<br><b>Selected
catid!'.$temp.'</b><br>';
}
else
{
/// print '<br><b>Cached catid</b><br>';
//fetch from preferences
$this->map_tpl_to_real['cat_id']=$this->bo->default_category;
if($this->map_tpl_to_real['adm_pref_type']=='forced')
{
if($this->bo->default_category!='__NONE__' &&
$this->bo->default_category_forced)
{
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats($this->bo->default_category);
}
else
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats();
}
else
{
$this->map_tpl_to_real['cat_options']=$this->get_addressbook_cats($this->map_tpl_to_real['cat_id']);
}
// print '<br><b>Preference catid</b><br>';
}
}
function cache_is_empty()
{
if(is_array($this->cached_selected_fields[$this->org_or_person]['comm_types']))
{
if(count($this->cached_selected_fields[$this->org_or_person]['comm_types']) < 1)
{
if(count
($this->cached_selected_fields[$this->org_or_person]) <= 1)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
elseif(count
($this->cached_selected_fields[$this->org_or_person]) < 1)
{
return true;
}
return false;
}
function fields_to_show()
{
//have uiaddressbook fill up its field => english
array, stock_contact_fields
$org_person_array['Persons']=$this->contacts->get_person_properties();
$org_person_array['Organizations']=$this->contacts->get_organization_properties();
//print "<BR><B>orgpersonarray
properties".$orgpersonarray."</B><BR>";
/*print "<br><b>catalogs</b><br>";*/
//now go translating each field
reset($this->contacts->stock_contact_fields);
//Constructing simple 'showable' fields
while(list($falsefield,$english)=each($this->contacts->stock_contact_fields))
{
//If it in selected_fields, then it has been
selected, and it doesnt go into
//the fields_show_selectbox array
if((!$this->selected_fields[$this->org_or_person][$falsefield]))
{
if($this->org_or_person=='Persons')
{
if(!
in_array($falsefield,$org_person_array['Organizations']) )
{
$this->fields_show_selectbox[$falsefield]=$GLOBALS['phpgw']->lang($this->contacts->stock_contact_fields[$falsefield]);
// print "<br><br><b>
$falsefield<\b>";
$this->lang_fields[$falsefield]=$this->fields_show_selectbox[$falsefield];
}
unset($org_person_array['Organizations'][$falsefield]);
}
elseif($this->org_or_person=='Organizations')
{
if(!
in_array($falsefield,$org_person_array['Persons'] ))
{
$this->fields_show_selectbox[$falsefield]=$GLOBALS['phpgw']->lang($this->contacts->stock_contact_fields[$falsefield]);
$this->lang_fields[$falsefield]=$this->fields_show_selectbox[$falsefield];
}
unset($org_person_array['Persons'][$falsefield]);
}
}
else
{
//If it in selected_fields, then it has
been selected, excluded from the selectbox, and
//added to the lang_fields array which
shows the columns that have been selected
$this->lang_fields[$falsefield]=$GLOBALS['phpgw']->lang($this->contacts->stock_contact_fields[$falsefield]);
}
//Constructing commtype descriptions
}
$possible_comtypes=$this->linearize_query($this->contacts->get_contact_comm_descr(),'comm_description');
while(list($k,$v)=each($possible_comtypes))
{
if(!$this->selected_fields[$this->org_or_person]['comm_types'][$v])
{
// print "<B><BR>Commtypes
$this->selected_fields[$this->org_or_person]['comm_types'][$v]</b><br>";
$this->fields_show_selectbox['comm_types'][$v]=$v;
}
else
{
// print "<B><BR>langfields
$this->lang_fields[$v]=$v</b><br>";
$this->lang_fields[$v]=$v;
}
}
/*
print "<br><b>Columns</b><br>";
print_r($this->lang_fields);
print "<br><b>Columns</b><br>"; */
}
function linearize_query($qresult,$key)
{
// print_r($qresult);
reset($qresult);
for($i=0;$i < count($qresult);$i++)
{
$ret[$qresult[$i][$key]]=$qresult[$i][$key];
}
return $ret;
}
function get_exact_fields()
{
//Selecting fields, let it roll
/*print '<BR><B>SELECTFIELDS!</B><BR>';*/
if(is_array($this->cached_selected_fields[$this->org_or_person]) &&
is_array($this->selected_fields[$this->org_or_person]))
{
//We have cached selected fields, and someone
selected more
//Need to agregate the selected to the cached
/*print '<BR><B>Merging Selected
Fields</B><BR>';
print_r($this->selected_fields[$this->org_or_person]);
print '<BR><B>Merging Cached Selected
Fields</B><BR>';
print_r($this->cached_selected_fields[$this->org_or_person]);
*/
$this->cached_selected_fields[$this->org_or_person]=$this->selected_fields[$this->org_or_person]=array_merge_recursive($this->cached_selected_fields[$this->org_or_person],$this->selected_fields[$this->org_or_person]);
// print '<BR><B>Merging Result</B><BR>';
//
print_r($this->selected_fields[$this->org_or_person]);
}
elseif(is_array($this->selected_fields[$this->org_or_person]))
{
$this->cached_selected_fields[$this->org_or_person]=$this->selected_fields[$this->org_or_person];
//print '<BR><B>Selected awright</B><BR>';
}
elseif(is_array($this->cached_selected_fields[$this->org_or_person]))
{
$this->selected_fields[$this->org_or_person]=$this->cached_selected_fields[$this->org_or_person];
//print '<BR><B>Cached awright</B><BR>';
}
elseif($this->org_or_person == 'Persons' &&
is_array($this->bo->person_columns))
{
//print '<BR><B>Old preferences found</B><BR>';
$this->selected_fields['Persons']=$this->cached_selected_fields['Persons']=$this->bo->person_columns;
}
elseif($this->org_or_person == 'Organizations' &&
is_array($this->bo->org_columns))
{
//print '<BR><B>Old preferences found</B><BR>';
$this->selected_fields['Organizations']=$this->cached_selected_fields['Organizations']=$this->bo->org_columns;
}
}
function index()
{
$this->get_vars();
/*print '<BR><B>It is a
!'.$this->org_or_person.'</B><BR>';*/
switch($this->submit)
{
case 'cancel':
{
$this->save_sessiondata(true);
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
return;
}
case 'save':
{
//print_r($this->cached_selected_fields);
//Need to get it all, we are in
a tab, so actual data is
//combinedly in the cache or in
the selected_fields array
if(is_array($this->selected_fields['Persons']))
{
$person_columns=$this->selected_fields['Persons'];
}
else
{
$person_columns=$this->cached_selected_fields['Persons'];
}
if(is_array($this->selected_fields['Organizations']))
{
$org_columns=$this->selected_fields['Organizations'];
}
else
{
$org_columns=$this->cached_selected_fields['Organizations'];
}
$this->bo->person_columns=$person_columns;
$this->bo->org_columns=$org_columns;
//print
'<BR><B>Catid'.$this->map_tpl_to_real['cat_id'].'</B><BR>';
$this->bo->default_category=$this->map_tpl_to_real['cat_id'];
//print "<BR><B>Person Columns";
//print_r($this->bo->person_columns)."</B><BR>";
$this->bo->save_preferences($this->map_tpl_to_real['adm_pref_type']);
// $this->save_sessiondata(true);
// print
$GLOBALS['phpgw']->redirect_link('/preferences/index.php');
// return;
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
$this->get_exact_fields();
break;
}
case 'remove':
{
//if removing
//print '<BR><B>Removing!</B><BR>';
if($this->cached_selected_fields[$this->org_or_person][$this->remove_me])
{
//kill the field to be removed
//print
'<BR><B>Removing!'.$this->remove_me.'</B><BR>';
unset($this->cached_selected_fields[$this->org_or_person][$this->remove_me]);
}
elseif($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me])
{
//print
'<BR><B>Removing!'.$this->remove_me.'</B><BR>';
unset($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me]);
}
//Look if we remove_me is the last
field to be removed
if($this->cache_is_empty())
{
if($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me])
{
unset($this->cached_selected_fields[$this->org_or_person]['comm_types'][$this->remove_me]);
}
else
{
unset($this->cached_selected_fields[$this->org_or_person][$this->remove_me]);
}
}
}
default:
{
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
//Selecting fields, let it roll
//print '<BR><B>SELECTFIELDS!</B><BR>';
$this->get_exact_fields();
//print_r($this->selected_fields);
}
}
$this->template->set_file(
array(
'addressbook_preferences_t'
=>'preferences.tpl',
'preferences_bits_t' =>
'preferences_bits.tpl',
'select_columns_form_options_t' =>
'preferences_bits.tpl',
'select_columns_commtypes_options_t' =>
'preferences_bits.tpl',
'selected_rows_t' =>
'preferences_bits.tpl',
'principal_tabs_t' =>
'principal_tabs.tpl'
)
);
//first, build the selectbox, select where needed
$this->show_selectbox();
//Obviously Not first time, fields have been selected
if( (is_array($this->selected_fields[$org_or_person])) ||
(is_array($this->cached_selected_fields[$this->org_or_person])) &&
!$this->cache_is_empty())
{
//print_r($this->cached_selected_fields);
$this->show_cols();
}
$this->set_static_vars();
$this->set_tabs();
$this->template->parse('out','addressbook_preferences_t');
$this->template->p('out');
$this->save_sessiondata();
}
function set_static_vars()
{
$this->template->set_var('lang_abprefs',$this->map_tpl_to_real['lang_abprefs']);
$this->template->set_var('lang_select_cols',$this->map_tpl_to_real['lang_select_cols']);
$this->template->set_var('select_columns_submit_value',$this->map_tpl_to_real['select_columns_submit_value']);
$this->template->set_var('select_columns_selectbox_name',$this->map_tpl_to_real['select_columns_selectbox_name']);
$this->template->set_var('select_columns_comtypes_name',$this->map_tpl_to_real['select_columns_comtypes_name']);
$this->template->set_var('submit_cancel_value',$this->map_tpl_to_real['submit_cancel_value']);
$this->template->set_var('submit_save_value',$this->map_tpl_to_real['submit_save_value']);
$this->template->set_var('lang_remove_field',$GLOBALS['phpgw']->lang('remove'));
$this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
//Catergories
$this->template->set_var('cat_options',$this->map_tpl_to_real['cat_options']);
if($this->is_current_admin())
{
$tabs=$this->map_tpl_to_real['final_admin_tabs'];
}
else
{
$tabs='';
}
$this->template->set_var('admin_tabs',$tabs);
if($this->current_columns_value_is_forced() &&
$this->map_tpl_to_real['adm_pref_type'] != 'forced')
{
$hider_open="<!--";
$hider_close="-->";
}
$this->template->set_var('hider_open',$hider_open);
$this->template->set_var('hider_close',$hider_close);
}
function set_tabs()
{
$this->template->set_block('principal_tabs_t','principal_button');
$this->template->set_block('principal_tabs_t','principal_tab');
//print '<BR><B>Now it is a '.$this->org_or_person.'</B><BR>';
$this->parse_principal_tabs(
$this->map_tpl_to_real['person_preferences_link'],
$this->get_class_css(
'Persons',
$this->org_or_person
),
'Persons',
'Person'
);
$this->parse_principal_tabs(
$this->map_tpl_to_real['org_preferences_link'],
$this->get_class_css(
'Organizations',
$this->org_or_person),
'Organizations',
'Organization'
);
$this->template->set_var('tabs',$this->template->fp('out','principal_tab'));
}
function current_columns_value_is_forced($commtypes=false)
{
switch($this->org_or_person)
{
case 'Persons':
{
return
$this->bo->person_columns_forced;
}
case 'Organizations':
{
return
$this->bo->org_columns_forced;
}
}
}
function show_selectbox($org_or_person='')
{
if(empty($org_or_person))
{
$org_or_person=$this->org_or_person;
}
$this->fields_to_show();
$this->template->set_block('select_columns_form_options_t','B_select_columns_form_options','V_select_columns_form_options');
$this->template->set_block('select_columns_commtypes_options_t','B_select_ctypes_options','V_select_columns_commtypes_options');
if(count($this->fields_show_selectbox) > 1)
{
reset($this->fields_show_selectbox);
// print "<BR><B> To Show in
Selectbox<br>".print_r($this->fields_show_selectbox)."</B><BR>";
while(list($field,$lang)=each($this->fields_show_selectbox))
{
//not a comtype
if(!is_array($lang))
{
$this->template->set_var('lang_contact_field',$lang);
$this->template->set_var('value',$field);
$this->template->parse('V_select_columns_form_options','B_select_columns_form_options',True);
}
else
{
while(list($k,$description)=each($lang))
{
$this->template->set_var('lang_comtype_field',$description);
$this->template->set_var('commtype_description',$description);
$this->template->parse('V_select_ctypes_options',
'B_select_ctypes_options',True);
}
}
}
}
else
{
$this->template->set_var('lang_contact_field',$GLOBALS['phpgw']->lang('Empty'));
$this->template->set_var('value',"");
$this->template->parse('V_select_columns_form_options','B_select_columns_form_options');
}
$this->template->parse('B_select_columns_form_options','V_select_columns_form_options');
$this->template->parse('B_select_ctypes_options',
'V_select_ctypes_options');
}
function show_cols($org_or_person='')
{
if(empty($org_or_person))
{
$org_or_person=$this->org_or_person;
}
$this->template->set_block('selected_rows_t','B_selected_rows','V_selected_rows');
//print "<BR><B>Selected</B><BR>";
//print_r($this->selected_fields[$this->org_or_person]);
reset($this->selected_fields[$this->org_or_person]);
while(list($k,$v)=each($this->selected_fields[$this->org_or_person]))
{
if(!is_array($v))
{
$this->template->set_var('lang_selected_contact_field',$this->lang_fields[$k]);
if($this->current_columns_value_is_forced() &&
$this->map_tpl_to_real['adm_pref_type'] != 'forced')
{
$removelink='';
}
else
{
$removelink=$GLOBALS['phpgw']->link
('/index.php',
array("menuaction"=>"addressbook.uiaddressbook_prefs.index",
"remove_me"=>$k,
"org_or_person" =>
$this->org_or_person,
"adm_pref_type" =>
$this->map_tpl_to_real['adm_pref_type']
)
);
}
$this->template->set_var('remove_me_link',$removelink);
$this->template->parse('V_selected_rows','B_selected_rows',True);
}
else
{
reset($v);
$arrays[]=$v;
}
}
if(is_array($arrays))
{
if($this->current_columns_value_is_forced() &&
$this->map_tpl_to_real['adm_pref_type'] != 'forced')
{
$removelink='';
}
else
{
$removelink=true;
}
while(list($k,$v)=each($arrays))
{
while(list($ok,$ov)=each($v))
{
if($removelink)
{
$removelink=$GLOBALS['phpgw']->link
('/index.php',
array("menuaction"=>"addressbook.uiaddressbook_prefs.index",
"remove_me"=>$ok,
"org_or_person" => $this->org_or_person,
"adm_pref_type" => $this->map_tpl_to_real['adm_pref_type']
)
);
}
$this->template->set_var('lang_selected_contact_field',$this->lang_fields[$ok]);
$this->template->set_var('remove_me_link',$removelink);
$this->template->parse('V_selected_rows','B_selected_rows',True);
}
}
}
$this->template->parse('B_selected_rows','V_selected_rows');
}
function save_sessiondata($clear=false)
{
if(!$clear)
{
$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref',
array(
'selected_fields' =>
$this->cached_selected_fields,
'map_tpl_to_real' =>
$this->map_tpl_to_real,
'lang_fields' =>
$this->lang_fields
)
);
}
else
{
// print '<BR><B>Clearing Cache </B><BR>';
$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref','');
}
}
function read_sessiondata()
{
// print '<BR><B>READING SESSIONDATA!</B><BR>';
$data=$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref');
$this->cached_selected_fields=$data['selected_fields'];
$this->map_tpl_to_real=$data['map_tpl_to_real'];
$this->cat_id=$this->map_tpl_to_real['cat_id'];
$this->lang_fields=$data['lang_fields'];
$this->cache_is_empty=$data['cache_is_empty'];
}
//Strange, the cached fields need to be really unset, then we clear the
cache and we are really clean
function clear_dinamic_data()
{
unset($this->cached_selected_fields);
unset($this->lang_fields);
$this->save_sessiondata('true');
}
function session_data_saved()
{
$data=$GLOBALS['phpgw']->session->appsession('session_data','addressbookpref');
//print "<BR><B>Actually got sessiondata</B><BR>";
//print_r($data);
return is_array($data);
}
function parse_principal_tabs($action,$class_css,$name,$value)
{
$button = array('principal_action' => $action,
'principal_class_css' => $class_css,
'principal_name' => $name,
'principal_value' => $value);
$this->template->set_var($button);
$this->template->parse('principal_buttons',
'principal_button',true);
}
function get_class_css($tab, $current_tab)
{
//print "<BR><B>ITS AN $tab == $current_tab";
if ($tab == $current_tab)
{
return 'button_style_sel';
}
else
{
return 'button_style';
}
}
function css()
{
$tmp = 'input[type="submit"].button_style,
input[type="button"].button_style {
color: #555;
margin-left: 1px;
margin-right: 1px;
background-color: #ddd;
border:1px #888 solid;
border-bottom-width: 0px;
padding: 1px;
width: 85px;
}
input[type="submit"].button_style_sel,
input[type="button"].button_style_sel {
color: #555;
margin-left: 1px;
margin-right: 1px;
/*background-color: #e5e5e5;*/
border:1px #888 solid;
border-bottom-width: 0px;
padding: 1px;
width: 85px;
}
input[type="submit"]:hover.button_style,
input[type="button"]:hover.button_style {
background-color: #eee;
color: #36c;
}
input[type="submit"]:active.button_style,
input[type="button"]:active.button_style {
background-color: #eee;
color: #9ac;
}';
return $tmp;
}
function is_current_admin()
{
// print "<BR><B> Current is admin? ".
$GLOBALS['phpgw']->acl->check('run',1,'admin')."</B><BR>";
return $GLOBALS['phpgw']->acl->check('run',1,'admin');
}
function build_admin_tabs()
{
if ($this->is_current_admin())
{
$tabs[] = array(
'label' => lang('Your
preferences'),
'link' =>
$GLOBALS['phpgw']->link('/index.php',array(
"menuaction" =>
"addressbook.uiaddressbook_prefs.index",
"adm_pref_type"=>"user"
))
);
$tabs[] = array(
'label' => lang('Default
preferences'),
'link' =>
$GLOBALS['phpgw']->link('/index.php',array(
"menuaction" =>
"addressbook.uiaddressbook_prefs.index",
"adm_pref_type"=>"default"
))
);
$tabs[] = array(
'label' => lang('Forced
preferences'),
'link' =>
$GLOBALS['phpgw']->link('/index.php',array(
"menuaction" =>
"addressbook.uiaddressbook_prefs.index",
"adm_pref_type"=>"forced"
))
);
switch($this->map_tpl_to_real['adm_pref_type'])
{
case 'user': $selected = 0; break;
case 'default': $selected = 1; break;
case 'forced': $selected = 2; break;
}
$this->map_tpl_to_real['final_admin_tabs']=$GLOBALS['phpgw']->common->create_tabs($tabs,$selected);
}
}
}
?>
====================================================
Index: class.socatalog_contact_comm_descr.inc.php
<?php
class socatalog_contact_comm_descr
{
function socatalog_contact_comm_descr()
{
$this->db = &$GLOBALS['phpgw']->db;
}
function _constructor()
{
}
function select_catalog()
{
$comm_type =
CreateObject('phpgwapi.contact_comm_descr');
$comm_type->add_select('comm_descr_id');
$comm_type->add_select('comm_type');
$comm_type->add_select('comm_description');
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
function insert($fields)
{
$comm_type =
CreateObject('phpgwapi.contact_comm_descr');
return $comm_type->insert($fields, PHPGW_SQL_RUN_SQL);
}
function delete($key)
{
$comm_type =
CreateObject('phpgwapi.contact_comm_descr');
return $comm_type->delete('comm_descr_id ='. $key,
PHPGW_SQL_RUN_SQL);
}
function update($key, $fields)
{
$comm_type =
CreateObject('phpgwapi.contact_comm_descr');
return $comm_type->update($fields, 'comm_descr_id ='.
$key, PHPGW_SQL_RUN_SQL);
}
function get_record($key)
{
$comm_type =
CreateObject('phpgwapi.contact_comm_descr');
$comm_type->add_select('comm_type');
$comm_type->add_select('comm_description');
$comm_type->set_criteria('comm_descr_id='. $key);
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
function select_catalog_types()
{
$comm_type = CreateObject('phpgwapi.contact_comm_type');
$comm_type->add_select('comm_type_id');
$comm_type->add_select('comm_type_description');
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
}
?>
====================================================
Index: class.socatalog_contact_comm_type.inc.php
<?php
class socatalog_contact_comm_type
{
function socatalog_contact_comm_type()
{
$this->db = &$GLOBALS['phpgw']->db;
}
function _constructor()
{
}
function select_catalog()
{
$comm_type = CreateObject('phpgwapi.contact_comm_type');
$comm_type->add_select('comm_type_id');
$comm_type->add_select('comm_type_description');
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
function insert($fields)
{
$comm_type = CreateObject('phpgwapi.contact_comm_type');
return $comm_type->insert($fields, PHPGW_SQL_RUN_SQL);
}
function delete($key)
{
$comm_type = CreateObject('phpgwapi.contact_comm_type');
return $comm_type->delete('comm_type_id ='. $key,
PHPGW_SQL_RUN_SQL);
}
function update($key, $fields)
{
$comm_type = CreateObject('phpgwapi.contact_comm_type');
return $comm_type->update($fields, 'comm_type_id ='.
$key, PHPGW_SQL_RUN_SQL);
}
function get_record($key)
{
$comm_type = CreateObject('phpgwapi.contact_comm_type');
$comm_type->add_select('comm_type_id');
$comm_type->add_select('comm_type_description');
$comm_type->set_criteria('comm_type_id='. $key);
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
}
?>
====================================================
Index: class.socatalog_contact_note_type.inc.php
<?php
class socatalog_contact_note_type
{
function socatalog_contact_note_type()
{
$this->db = &$GLOBALS['phpgw']->db;
}
function _constructor()
{
}
function select_catalog()
{
$comm_type = CreateObject('phpgwapi.contact_note_type');
$comm_type->add_select('note_type_id');
$comm_type->add_select('note_description');
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
function insert($fields)
{
$comm_type = CreateObject('phpgwapi.contact_note_type');
return $comm_type->insert($fields, PHPGW_SQL_RUN_SQL);
}
function delete($key)
{
$comm_type = CreateObject('phpgwapi.contact_note_type');
return $comm_type->delete('note_type_id ='. $key,
PHPGW_SQL_RUN_SQL);
}
function update($key, $fields)
{
$comm_type = CreateObject('phpgwapi.contact_note_type');
return $comm_type->update($fields, 'note_type_id ='.
$key, PHPGW_SQL_RUN_SQL);
}
function get_record($key)
{
$comm_type = CreateObject('phpgwapi.contact_note_type');
$comm_type->add_select('note_type_id');
$comm_type->add_select('note_description');
$comm_type->set_criteria('note_type_id='. $key);
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
}
?>
====================================================
Index: class.uicatalog_contact_note_type.inc.php
<?php
include('class.catalog_manager.inc.php');
class uicatalog_contact_note_type extends catalog_manager
{
var $public_functions = array('view' => True);
var $modify = False;
function uicatalog_contact_note_type()
{
$this->_constructor();
$this->bo =
CreateObject('addressbook.bocatalog_contact_note_type');
$this->form_action =
'menuaction=addressbook.uicatalog_contact_note_type.view';
$this->catalog_name = 'note_types';
$this->headers = array('Type', 'Edit', 'Delete');
$this->array_name = 'note_types_array';
$this->index = 'key_note_id';
$this->title = 'Notes Type - Catalog';
$this->catalog_button_name = 'note_types_add_row';
$this->key_edit_name = 'note_type_id';
$this->num_cols = 1;
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[note_description]',
'value'=> $this->entry['note_description']))));
$this->objs_data = array('value'=> array('type' =>
'data',
'field' =>
'note_description'),
'edit' => array('type' =>
'link',
'mode' =>
'edit',
'key' =>
'note_type_id',
'action'=>
'note_types_edit_row',
'extra'=> ''),
'delete'=>array('type' =>
'link',
'mode' =>
'delete',
'key' =>
'note_type_id',
'action'=>
'note_types_del_row',
'extra'=> ''));
}
function view()
{
$this->get_vars();
$this->validate_action($this->action);
$this->create_window($this->catalog_name, $this->entry,
$this->title);
if($this->modify)
{
$contacts = CreateObject('phpgwapi.contacts');
$contacts->delete_sessiondata('note_type');
}
}
function select_catalog()
{
$this->note_types_array = $this->bo->select_catalog();
}
function insert($fields)
{
$this->bo->insert($fields);
$this->modify = True;
}
function delete($key)
{
$this->bo->delete($key);
$this->modify = True;
}
function update($key, $fields)
{
$this->bo->update($key, $fields);
$this->modify = True;
}
function edit($key)
{
$this->catalog_button_name = 'note_types_update_row';
$this->key_edit_name = 'note_type_id';
$this->key_edit_id = $key;
$record = $this->bo->get_record($key);
$this->entry['note_description'] =
$record[0]['note_description'];
$this->form_fields = array(1 => array('Type',
$this->get_column_data(
array('type' => 'text',
'name' => 'entry[note_description]',
'value'=> $this->entry['note_description']))));
}
}
?>
====================================================
Index: class.uicategorize_contacts.inc.php
<?php
/**************************************************************************\
* phpGroupWare - uicategorize_contacts *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/ *
* *
* Copyright 2003 Free Software Foundation, Inc. *
* *
* Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* -------------------------------------------- *
* Development of this application was funded by http://www.sogrp.com *
* -------------------------------------------- *
* This program is Free Software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
class uicategorize_contacts
{
var $public_functions = array(
'index' => True,
'java_script' => True
);
function uicategorize_contacts()
{
$this->template = &$GLOBALS['phpgw']->template;
$this->lists = CreateObject('addressbook.widget_lists',
'Categories', 'categorize_contacts_form');
$this->cat = CreateObject('phpgwapi.categories');
$this->contacts = CreateObject('phpgwapi.contacts');
}
function index()
{
$this->get_vars();
$this->lists->set_left_combo('Category', 'all_cats',
$this->get_categories(), $this->selected_cat, True);
$this->lists->set_all_option_list('All Persons',
'person_all[]', $this->get_all_persons());
$this->lists->set_selected_option_list('Current
Persons', 'person_current[]',
$this->get_persons_by_cat($this->selected_cat));
switch($this->action)
{
case 'save':
$persons = $this->lists->get_resul_list();
$this->save_categories_by_person($this->selected_cat, $persons);
Header('Location: '
.
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicategorize_contacts.index'));
$GLOBALS['phpgw']->common->phpgw_exit();
break;
case 'cancel':
Header('Location: '
.
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index§ion=Persons'));
$GLOBALS['phpgw']->common->phpgw_exit();
break;
}
$this->draw_form();
}
function draw_form()
{
$this->template->set_file(array('manage_cats_t' =>
'categorize_contacts.tpl'));
$list_widget = $this->lists->get_widget();
$onsubjs = $this->lists->get_onsubmit_js_string();
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
$this->template->set_var('action',
$GLOBALS['phpgw']->link('/index.php',
'menuaction=addressbook.uicategorize_contacts.index'));
$this->template->set_var('form_name',
'categorize_contacts_form');
$this->template->set_var('onsubjs', $onsubjs);
$this->template->set_var('widget_lists', $list_widget);
$this->template->pfp('out', 'manage_cats_t');
$GLOBALS['phpgw']->common->phpgw_exit();
}
function save_categories_by_person($selected_cat,
$persons=array())
{
$delete = $persons['delete'];
$insert = $persons['insert'];
$edit = $persons['edit'];
if($selected_cat==-1)
{
return;
}
if(is_array($delete))
{
foreach($delete as $person_id)
{
$cats =
$this->contacts->get_cats_by_person($person_id);
foreach($cats as $key => $value)
{
if($value == '' ||
$value==$selected_cat)
{
unset($cats[$key]);
}
}
$this->contacts->edit_category($person_id, $cats, PHPGW_SQL_RUN_SQL);
}
}
if(is_array($insert))
{
foreach($insert as $person_id)
{
$cats =
$this->contacts->get_cats_by_person($person_id);
$cats[] = $selected_cat;
foreach($cats as $key => $value)
{
if($value == '')
{
unset($cats[$key]);
}
}
$this->contacts->edit_category($person_id, $cats, PHPGW_SQL_RUN_SQL);
}
}
}
function get_all_persons()
{
return $this->get_persons();
}
function get_persons_by_cat($cat_id='')
{
if($cat_id)
{
return $this->get_persons($cat_id);
}
}
function get_persons($cat_id=PHPGW_CONTACTS_CATEGORIES_ALL,
$access=PHPGW_CONTACTS_ALL)
{
$criteria = $this->contacts->criteria_for_index(
$GLOBALS['phpgw_info']['user']['account_id'],
$access, $cat_id);
$persons = $this->contacts->get_persons(
array('person_id', 'per_full_name'),
'','','','','',$criteria);
if(is_array($persons))
{
foreach($persons as $key => $data)
{
$persons_data[$data['person_id']] =
$data['per_full_name'];
}
asort($persons_data);
}
return $persons_data;
}
function get_categories()
{
$cats =
$this->cat->return_array($type,$start,$limit,$query,$sort,$order,False);
$categories[-1] = 'Select one...';
if(is_array($cats))
{
foreach($cats as $data)
{
$categories[$data['id']] =
$data['name'];
}
}
return $categories;
}
function java_script()
{
return $this->lists->java_script();
}
function get_vars()
{
$save = get_var('save', array('post', 'get'));
$cancel = get_var('cancel', array('post', 'get'));
if($save)
{
$this->action = 'save';
}
elseif($cancel)
{
$this->action = 'cancel';
}
$this->selected_cat = get_var('all_cats', array('post',
'get'));
}
}
?>
====================================================
Index: class.widget_lists.inc.php
<?php
/**************************************************************************\
* phpGroupWare - widget_lists *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/ *
* *
* Copyright 2003 Free Software Foundation, Inc. *
* *
* Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* -------------------------------------------- *
* Development of this application was funded by http://www.sogrp.com *
* -------------------------------------------- *
* This program is Free Software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
class widget_lists
{
var $title;
var $form_name;
var $use_combos;
/**
* Set the parameters for the list box with all options
*
* @param string $title The title of the widget
* @param array $form_name The name form where it will be this
widget
* @param string $use_combos Use True if you want to have combos
in your widget
*/
function widget_lists($title, $form_name, $use_combos=True,
$use_filter=False)
{
$this->template = &$GLOBALS['phpgw']->template;
$this->title = $title;
$this->form_name = $form_name;
$this->use_combos = $use_combos;
$this->use_filter = $use_filter;
}
/**
* Draw the widget
*
* @return string The html code for this widget
*/
function get_widget()
{
$this->template->set_root($GLOBALS['phpgw']->common->get_tpl_dir('addressbook'));
$this->template->set_file(array('widget_list_t' =>
'widget_lists.tpl'));
$this->template->set_block('widget_list_t',
'many_actions', 'many_actions');
$this->template->set_block('widget_list_t', 'combos',
'combos');
$this->template->set_block('widget_list_t',
'option_filter', 'option_filter');
$this->template->set_var('lang_general_title',
$this->title);
$this->template->set_var('widget_list_form_name',
$this->form_name);
if($this->use_combos)
{
$this->template->set_var('lang_left_combo_title', $this->left_combo_title);
$this->template->set_var('left_combo',
$this->left_combo);
$this->template->set_var('lang_right_combo_title', $this->right_combo_title);
$this->template->set_var('right_combo',
$this->right_combo);
$this->template->parse('combos_lists',
'combos');
}
if($this->use_filter)
{
$this->template->set_var('filter_by_label',
lang('Filter by: '));
$this->template->set_var('filter_by_option_list',
$this->get_list_filters());
$this->template->set_var('search_by_label',
lang('Search: '));
$this->template->set_var('all_option_list_filter',
$this->get_list_filters());
$this->template->parse('all_option_list_filter_body',
'option_filter');
}
if(is_array($this->selected_option_list))
{
$this->all_option_list =
array_diff($this->all_option_list, $this->selected_option_list);
}
else
{
$this->all_option_list = $this->all_option_list;
}
$this->template->set_var('lang_all_option_list_title',
$this->all_option_list_title);
$this->template->set_var('all_option_list_name',
$this->all_option_list_name);
$this->template->set_var('all_option_list',
$this->get_option_list($this->all_option_list));
$this->template->set_var('lang_selected_option_list_title',
$this->selected_option_list_title);
$this->template->set_var('selected_option_list_name',
$this->selected_option_list_name);
$this->template->set_var('selected_option_list',
$this->get_option_list($this->selected_option_list));
if($this->right_combo_link_opt)
{
$this->template->set_var('current_opt',
$this->right_combo_name);
}
elseif($this->left_combo_link_opt)
{
$this->template->set_var('current_opt',
$this->left_combo_name);
}
$this->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
$this->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
$this->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
$this->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
return $this->template->fp('out', 'many_actions');
}
/**
* Set the parameters for the list box with all options
*
* @param string $title The title of the list box
* @param array $list_name The name of the list box
* @param string $list The array with the data for this list box
($list[$key] = $value)
* @return mixed The option list box which have all options
*/
function set_all_option_list($title, $list_name, $list=array())
{
if(!is_array($list))
{
$list = array();
}
$this->all_option_list_title = $title;
$this->all_option_list = $list;
$this->all_option_list_name = $list_name;
}
/**
* Set the parameters for the list box with selected options
*
* @param string $title The title of the list box
* @param array $list_name The name of the list box
* @param string $list The array with the data for this list box
($list[$key] = $value)
* @return mixed The option list box which have selected options
*/
function set_selected_option_list($title, $list_name,
$list=array())
{
if(!is_array($list))
{
$list = array();
}
$this->selected_option_list_title = $title;
$this->selected_option_list = $list;
$this->selected_option_list_name = $list_name;
$this->old_option_list = $list;
}
/**
* Set the parameters for the left combo
*
* @param string $title The title of the combo
* @param array $list_name The name of the combo
* @param string $list The array with the data for this list box
($list[$key] = $value)
* @param string $selected The option selected for this combo
* @param boolean $use_js For use javascript
* @return mixed The left combo box
*/
function set_left_combo($title, $list_name, $list=array(),
$selected='', $use_js=False, $link_opt=False)
{
$this->left_combo_title = $title;
$this->left_combo_name = $list_name;
$this->left_combo = $this->get_combo($list_name, $list,
$selected, $use_js);
$this->left_combo_link_opt = $link_opt;
}
function set_left_text($title, $list_name, $value='')
{
$this->left_combo_title = $title;
$this->left_combo = $this->get_text($list_name, $value);
}
/**
* Set the parameters for the right combo
*
* @param string $title The title of the combo
* @param array $list_name The name of the combo
* @param string $list The array with the data for this list box
($list[$key] = $value)
* @param string $selected The option selected for this combo
* @param boolean $use_js For use javascript
* @return mixed The right combo box
*/
function set_right_combo($title, $list_name, $list=array(),
$selected='', $use_js=False, $link_opt=False)
{
$this->right_combo_title = $title;
$this->right_combo_name = $list_name;
$this->right_combo = $this->get_combo($list_name,
$list, $selected, $use_js);
$this->right_combo_link_opt = $link_opt;
}
/**
* Get the records to process, new and deleted
*
* @return array The array with all new records and deleted
* ($array = array(delete => values, insert => values, edit =>
values))
*/
function get_resul_list()
{
$pos = strpos($this->selected_option_list_name, '[]');
$var_option_name =
$pos?substr($this->selected_option_list_name,0,$pos):$this->selected_option_list_name;
return
$this->diff_arrays(array_keys($this->old_option_list),
get_var($var_option_name));
}
/**
* Compare two arrays and return the diferences
*
* @param array $old_array The array with old options
* @param array $new_array The array with new options
* @return array The array with diferences
* ($array = array(delete => values, insert => values, edit =>
values))
*/
function diff_arrays($old_array=array(), $new_array=array())
{
if(!is_array($old_array))
{
$old_array = array();
}
if(!is_array($new_array))
{
$new_array = array();
}
$result['delete'] = array_diff($old_array, $new_array);
$result['insert'] = array_diff($new_array, $old_array);
$result['edit'] = array_intersect($old_array,
$new_array);
return $result;
}
/**
* Get the combo box
*
* @param string $name The name of the combo
* @param array $list The array with the data for this list box
($list[$key] = $value)
* @param string $selected The option selected for this combo
* @param boolean $use_js For use javascript
* @return mixed The combo box
*/
function get_combo($name, $list=array(), $selected='',
$use_js=False)
{
$js_str = $use_js?'onChange="this.form.submit();"':'';
$str = '<select name="'.$name.'" '. $js_str .'
style="width:220">'.$this->get_option_list($list, $selected).'</select>';
return $str;
}
function get_text($list_name, $value)
{
$str = '<input type="text" name="'.$list_name.'"
value="'.$value.'">';
return $str;
}
/**
* Make the option list html code
*
* @param array $list The array with the data for this list box
($list[$key] = $value)
* @param string $selected The option what you selected
* @return string The html code with all options
*/
function get_option_list($list=array(), $selected='')
{
$selected_option[$selected] = ' selected';
if(is_array($list))
{
foreach($list as $key => $data)
{
$str .= '<option value="'.$key.'" ' .
$selected_option[$key] . '>'.$data.'</option>';
}
}
return $str;
}
/**
* Get the javascript function for use in the form
*
* @return string The javascript function for use in the form
*/
function get_onsubmit_js_string()
{
return 'onsubmit="process_list(\''
.$this->all_option_list_name
.'\',\''
.$this->selected_option_list_name.'\')"';
}
function set_list_filters($list_options, $selected='')
{
if(is_array($list_options))
{
$sel_opt[$selected] = 'selected';
foreach($list_options as $key => $value)
{
$opt .= '<option
value="'.$key.'"'.$sel_opt[$key].'>'.$value.'</option>';
}
$this->filter_option_list = $opt;
}
else
{
$this->filter_option_list = $list_options;
}
}
function get_list_filters()
{
return $this->filter_option_list;
}
function get_onload_js_string()
{
return 'onload="setUpVisual(\''
.$this->form_name
.'\',\''.$this->all_option_list_name
.'\',\'searchautocomplete\');obj1.bldUpdate();"';
}
/**
* Get the javascript functions which are necesary for this
widget
*
* @return string The javascript functions
*/
function java_script()
{
$tmp= '
<SCRIPT LANGUAGE="JavaScript">
function move_cbo(sboxname, cboxname) {
sbox =
document.'.$this->form_name.'.elements[sboxname];
cbox =
document.'.$this->form_name.'.elements[cboxname];
if(sbox.length > 0)
{
sel_opt =
sbox.options[sbox.selectedIndex].text;
}
else
{
sel_opt="";
}
sbox.length = 0;
for(c = 0; c < cbox.length; c++)
{
var no = new Option();
no.value = cbox[c].value;
no.text = cbox[c].text;
if(no.text == sel_opt)
{
i = c;
}
sbox[c] = no;
}
if(i>0)
{
sbox.options[i].selected = true;
}
}
function process_list(allboxname, myboxname) {
mybox =
document.'.$this->form_name.'.elements[myboxname];
for(c = 0; c < mybox.options.length; c++)
{
mybox.options[c].selected = true;
}
}
</script>'
.
'<script
src="'.$GLOBALS['phpgw']->link("/phpgwapi/js/contacts/selectboxes.js").'">
</script>';
return $tmp;
}
}
?>
====================================================
Index: class.socatalog_contact_addr_type.inc.php
<?php
class socatalog_contact_addr_type
{
function socatalog_contact_addr_type()
{
$this->db = &$GLOBALS['phpgw']->db;
}
function _constructor()
{
}
function select_catalog()
{
$addr_type = CreateObject('phpgwapi.contact_addr_type');
$addr_type->add_select('addr_type_id');
$addr_type->add_select('addr_description');
$sql = $addr_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
function insert($fields)
{
$comm_type = CreateObject('phpgwapi.contact_addr_type');
return $comm_type->insert($fields, PHPGW_SQL_RUN_SQL);
}
function delete($key)
{
$comm_type = CreateObject('phpgwapi.contact_addr_type');
return $comm_type->delete('addr_type_id ='. $key,
PHPGW_SQL_RUN_SQL);
}
function update($key, $fields)
{
$comm_type = CreateObject('phpgwapi.contact_addr_type');
return $comm_type->update($fields, 'addr_type_id ='.
$key, PHPGW_SQL_RUN_SQL);
}
function get_record($key)
{
$comm_type = CreateObject('phpgwapi.contact_addr_type');
$comm_type->add_select('addr_type_id');
$comm_type->add_select('addr_description');
$comm_type->set_criteria('addr_type_id='. $key);
$sql = $comm_type->select();
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$return_fields[] = $this->db->Record;
}
return $return_fields;
}
}
?>
====================================================
Index: arr.php
[comm] => Array (
[0] => Array (
[description] => asddsadsa
[value] => dsadsa
[type] =>
[preferred] => on )
[1] => Array (
[description] => weewq
[value] => dssadas
[type] =>
[preferred] => )
[2] => Array (
[description] => vfdhytjyt
[value] => trher
[type] =>
[preferred] => ))
====================================================
Index: class.addressbook_importer.inc.php
<?php
/**************************************************************************\
* phpGroupWare - uicategorize_contacts *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/ *
* *
* Copyright 2003 Free Software Foundation, Inc. *
* *
* Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* -------------------------------------------- *
* Development of this application was funded by http://www.sogrp.com *
* -------------------------------------------- *
* This program is Free Software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
class addressbook_importer
{
var $record;
function addressbook_importer()
{
}
function person($element, $value, $args='')
{
$this->record[$element] = $value;
}
function location($element, $value, $args='')
{
$this->record['locations'][$args]['type'] = $args;
$this->record['locations'][$args][$element] = $value;
}
function comms($element, $value, $args='')
{
$this->record['comm_media'][$element] = $value;
}
function notes($element, $value, $args='')
{
$this->record['notes'][$args]['type'] = $args;
$this->record['notes'][$args][$element] = $value;
}
}
?>
====================================================
Index: class.catalog_manager.inc.php
<?php
/**************************************************************************\
* phpGroupWare - catalog_manager *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/ *
* *
* Copyright 2003 Free Software Foundation, Inc. *
* *
* Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* -------------------------------------------- *
* Development of this application was funded by http://www.sogrp.com *
* -------------------------------------------- *
* This program is Free Software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
class catalog_manager
{
var $form_action;
var $catalog_name;
var $headers;
var $array_name;
var $objs_data;
var $index;
var $entry;
var $action;
var $form_fields;
var $title;
var $catalog_button_name;
var $num_cols;
function catalog_manager()
{
}
function _constructor()
{
$this->template = &$GLOBALS['phpgw']->template;
$this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
}
function create_window($catalog_name, $entry, $title)
{
//start to draw the add window
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
$this->main_form($catalog_name, $entry, $title);
}
/**
* Start to draw the html screens
*
* @param
* @return
*/
function main_form($catalog_name, $entry, $title)
{
$this->template->set_file(array('form' => 'form.tpl'));
$this->template->set_var('principal_tabs_inc', '');
$this->template->set_var('action',
$GLOBALS['phpgw']->link('/index.php',
$this->form_action));
$this->template->set_var('tab', '');
$this->template->set_var('current_tab_body',
$this->current_body($catalog_name, $entry, $title));
$this->template->set_var('control_buttons', '');
$this->template->pparse('out', 'form');
}
function current_body($catalog_name, $entry, $title)
{
$this->form_start();
$this->template->set_var('lang_general_data', $title);
$this->template->set_var('current_id_name',
$this->key_edit_name);
$this->template->set_var('current_id',
$this->key_edit_id);
$this->set_form_fields($this->form_fields);
$this->select_catalog();
$this->template->set_var('detail_fields',
$this->get_detail_form($catalog_name, $this->headers,
$this->array_name, $this->objs_data,
$this->index));
$this->form_end();
return $this->template->fp('out',
'tab_body_general_data');
}
/**
* Draw the detail form, this form is as show in comms, addr and
othes windows
*
* @param string $tab The name which identify the section
* @param array $headers Array with all headers which you want
to show in the form
* @param string $array_name The array name from you want to
show data
* @param array $objs_data Array with all properties of all data
which you want to show
* @param string $idx The index name (for edit mode use)
* @param boolean $button Flag for indicate if you want draw the
Add button
* @return string All the detail form html code in the template
*/
function get_detail_form($catalog_name, $headers, $array_name,
$objs_data, $idx, $button=True)
{
$this->template->set_file(array('detail_data' =>
'body_detail.tpl'));
$this->template->set_block('detail_data','detail_body','detail_body');
$this->template->set_block('detail_data','input_detail_row','input_detail_row');
$this->template->set_block('detail_data','input_detail_data','input_detail_data');
$add_button = '<input type="submit" name="'.
$this->catalog_button_name .'" value="Add">';
if($button)
{
$this->template->set_var('caption_detail',
$title);
$this->template->set_var('add_button',
$add_button);
}
else
{
$this->template->set_var('caption_detail', '');
$this->template->set_var('add_button', '');
}
$this->template->set_var('row_bgc',
$GLOBALS['phpgw_info']['theme']['th_bg']);
$tr_color = $GLOBALS['phpgw_info']['theme']['row_on'];
$cols='';
foreach($headers as $head)
{
$cols .= '<td>' . $head . '</td>';
}
$this->template->set_var('input_cols', $cols);
$this->template->fp('input_detail',
'input_detail_data', True);
$this->template->fp('detail_body_set',
'input_detail_row');
if (is_array($this->$array_name))
{
foreach($this->$array_name as $k => $v)
{
$id = $v[$idx];
$this->array_value = $v;
$tr_color =
$this->nextmatchs->alternate_row_color($tr_color);
$this->template->set_var('row_bgc',
$tr_color);
$cols='';
reset($objs_data);
foreach($objs_data as $type =>
$properties)
{
$cols .= '<td>' .
$this->get_column_data($properties) . '</td>';
}
$this->template->set_var('input_cols',
$cols);
$this->template->fp('input_detail',
'input_detail_data', True);
$this->template->fp('detail_body_set',
'input_detail_row');
}
}
$this->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
$this->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
$this->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
$this->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
return $this->template->fp('out', 'detail_body');
}
/**
* This function initialize the template for draw the tabs
windows
*
* @param
* @return
*/
function form_start()
{
$this->template->set_file(array('person_data' =>
'current_catalog_body.tpl'));
$this->template->set_block('person_data','tab_body_general_data','general_data');
$this->template->set_block('person_data','input_data','input_data');
}
/**
* This function end the template for draw the tabs windows
*
* @param
* @return
*/
function form_end()
{
$this->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
$this->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
$this->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
$this->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
$this->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
}
function set_form_fields($form_fields)
{
$tr_color = $GLOBALS['phpgw_info']['theme']['row_on'];
ksort($form_fields, SORT_NUMERIC);
$last_element = count($form_fields);
$cols='';
$count=1;
foreach($form_fields as $key => $row)
{
$tr_color =
$this->nextmatchs->alternate_row_color($tr_color);
$cols = $cols .
'<td>'.$row[0].'</td>'.'<td>'.$row[1].'</td>';;
if($count == $this->num_cols ||
$key==$last_element)
{
$this->template->set_var('input_fields_cols', $cols);
$this->template->fp('input_fields',
'input_data', True);
$cols = '';
$count=0;
}
$count ++;
}
}
function set_row_input($field_name, $input_name, $input_value,
$col)
{
if ($col==1)
{
$this->template->set_var('field_name_one',
$field_name);
$this->template->set_var('input_name_one',
$input_name);
$this->template->set_var('input_value_one',
$input_value);
}
else
{
$this->template->set_var('field_name_two',
$field_name);
$this->template->set_var('input_name_two',
$input_name);
$this->template->set_var('input_value_two',
$input_value);
}
}
function set_row_other_input($field_name, $field_value, $col)
{
if ($col==1)
{
$this->template->set_var('field_other_name1',
$field_name);
$this->template->set_var('value_other_name1',
$field_value);
}
else
{
$this->template->set_var('field_other_name2',
$field_name);
$this->template->set_var('value_other_name2',
$field_value);
}
}
function get_column_data($properties=array())
{
switch($properties['type'])
{
case 'data':
$column_data =
$this->array_value[$properties['field']];
break;
case 'text':
if(isset($properties['field']) &&
$properties['field']!='')
{
$sub_name = '[' .
$this->array_value[$properties['field']] . ']" ';
}
if($this->array_value[$properties['value']])
{
$value =
$this->array_value[$properties['value']];
}
else
{
$value = $properties['value'];
}
$name = $properties['name'] . $sub_name;
$column_data = '<input type="text"
name="'.$name.'" value="'.$value.'">';
break;
case 'radio':
if($this->array_value[$properties['field']]=='Y'){$checked='checked';}
$column_data = '<input type="radio" name="' .
$properties['name']
.'" value="' .
$this->array_value[$properties['value']] . '"'. $checked . '>';
break;
case 'link':
$link = $GLOBALS['phpgw']->link('/index.php',
$this->form_action)
. '&'. $properties['action'] . '=' .
$this->array_value[$properties['key']] . $properties['extra'];
$column_data = '<a
href="'.$link.'">'.$properties['mode'].'</a>';
break;
case 'combo':
$column_data = '<select
name="'.$properties['name'].'">'.$properties['value'].'</select>';
break;
}
return $column_data;
}
function get_vars()
{
$this->entry = get_var('entry',array('get','post'));
if(get_var($this->catalog_name.'_add_row',array('get','post')))
{
$this->action = 'insert';
}
elseif(get_var($this->catalog_name.'_update_row',array('get','post')))
{
$this->action = 'update';
$this->key = (get_var($this->key_edit_name,
array('get','post')));
}
elseif(get_var($this->catalog_name.'_del_row',array('get','post')))
{
$this->action = 'delete';
$this->key =
(get_var($this->catalog_name.'_del_row',array('get','post')));
}
elseif(get_var($this->catalog_name.'_edit_row',array('get','post')))
{
$this->action = 'edit';
$this->key =
(get_var($this->catalog_name.'_edit_row',array('get','post')));
}
}
function validate_action($action='')
{
switch($action)
{
case 'insert':
$this->insert($this->entry);
unset($this->entry);
break;
case 'delete':
$this->delete($this->key);
unset($this->key);
break;
case 'edit':
$this->edit($this->key);
break;
case 'update':
$this->update($this->key, $this->entry);
break;
}
}
}
?>
====================================================
Index: class.ipc_addressbook.inc.php
<?php
/**
* IPC Layer
*
* @author Dirk Schaller <address@hidden>
* @copyright Copyright (C) 2003 Free Software Foundation
http://www.fsf.org/
* @license http://www.fsf.org/licenses/gpl.html GNU General Public
License
* @package phpgwapi
* @subpackage ipc
* @version $Id: class.ipc_addressbook.inc.php,v 1.2 2004/12/31
04:55:22 skwashd Exp $
*/
/**
* Fassade of the adressbook application.
*
* @package notes
*/
class ipc_addressbook extends ipc_
{
/**
* @var object $contacts phpgwapi contacts object
* @access private
*/
var $contacts;
/**
* @var object $vcard import/export vcard object
* @access private
*/
var $vcard;
/**
* Constructor
*
* @access public
*/
function ipc_addressbook()
{
$this->contacts = CreateObject('phpgwapi.contacts');
$this->vcard = CreateObject('phpgwapi.vcard');
}
/**
* Add data in a certain mime type format to the application.
*
* @access public
* @param mixed $data data for adding to the application,
the datatype depends on the mime type
* @param string $type specifies the mime type of the
passed data
* @return integer id of the added data
*/
function addData($data, $type)
{
// 1: mapping the mime type to application data
if($type != 'text/x-vcard')
return false;
$data = ereg_replace("\n\n", "\r\n", $data);
$data_lines = explode("\r\n", $data);
$buffer = array();
$temp_line = '';
while(list(, $line) = each($data_lines))
{
$line = trim($line);
if(substr($line, -1) == '=')
{
// '=' at end-of-line --line to be
continued with next line
$temp_line .= substr($line, 0, -1);
continue;
}
else
{
$line = $temp_line . $line;
$temp_line = ''; // important for next
line which ends with =
}
if (strstr($line, 'BEGIN:VCARD'))
{
// added for p800 vcards: problem if
vcard starts with "<![CDATA["
$line = strstr($line, 'BEGIN:VCARD');
}
$buffer +=
$this->vcard->parse_vcard_line($line);
}
$fields = $this->vcard->in($buffer);
$fields['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
$fields['access'] = 'private';
$id = $this->contacts->contact_import($fields);
return $id;
}
/**
* Convert data from a mime type to another.
*
* @access public
* @param mixed $data data for converting, the datatype
depends on the input mime type
* @param string $typeIn specifies the input mime type of
the passed data
* @param string $typeOut specifies the output mime type of
the passed data
* @return mixed converted data from application,
the datatype depends on the passed output mime type
*/
function convertData($data, $typeIn, $typeOut)
{
return false;
}
/**
* Get data from the application in a certain mime type format.
*
* @param integer $id id of data to get from the
application
* @param string $type specifies the mime type of the
returned data
* @return mixed data from application, the datatype
depends on the passed mime type, false if no data exists for the passed id
*/
function getData($id, $type)
{
if($type != 'text/x-vcard')
{
return false;
}
if(!$this->contacts->check_read($id))
{
return false;
}
// First, make sure they have permission to this entry
$fieldlist = $this->contacts->person_complete_data($id);
$type_work =
$this->contacts->search_location_type('work');
$type_home =
$this->contacts->search_location_type('home');
/*
$fields['full_name'] =
$fieldlist['full_name'];
bug: $fieldlist['full_name'] contains two spaces
between first and last name, when middle name is empty
workaround: calculate the fullname like shown below
*/
$fields['first_name'] =
$fieldlist['first_name'];
$fields['last_name'] =
$fieldlist['last_name'];
$fields['middle_name'] =
$fieldlist['middle_name'];
$fields['full_name'] = $fields['first_name']
. ' ';
$fields['full_name'] .=
($fields['middle_name'] != '') ? $fields['middle_name'] . ' ' : '';
$fields['full_name'] .= $fields['last_name'];
$fields['prefix'] = $fieldlist['prefix'];
$fields['suffix'] = $fieldlist['suffix'];
$fields['sound'] = $fieldlist['sound'];
$fields['birthday'] =
$fieldlist['birthday'];
//$fields['note'] = $fieldlist[''];
//$fields['tz'] =
$fieldlist['locations'][$type_work][''];
//$fields['geo'] = $fieldlist[''];
$fields['pubkey'] = $fieldlist['pubkey'];
$fields['org_name'] =
$fieldlist['org_name'];
$fields['org_unit'] =
$fieldlist['department'];
$fields['title'] = $fieldlist['title'];
$fields['adr_one_type'] = 'WORK';
$fields['adr_two_type'] = 'HOME';
//$fields['tel_prefer'] = $fieldlist[''];
$fields['email_type'] = 'INTERNET';
$fields['email_home_type'] = 'INTERNET';
// locations contains a list of loc_id and its date
if (isset($fieldlist['locations']) &&
is_array($fieldlist['locations']))
{
// locations[loc_id][type] is work or home
// loc_id is not interested here, but the type
is important!
while ( list($loc_id, $loc_data) =
each($fieldlist['locations']) )
{
$loc_type_id =
$this->contacts->search_location_type($loc_data['type']);
switch($loc_type_id)
{
case $type_work:
$adr = 'adr_one_';
break;
case $type_home:
$adr = 'adr_two_';
break;
default:
continue;
break;
}
$fields[$adr.'street'] =
$loc_data['add1'];
$fields[$adr.'ext'] =
$loc_data['add2'];
$fields[$adr.'locality'] =
$loc_data['city'];
$fields[$adr.'region'] =
$loc_data['state'];
$fields[$adr.'postalcode'] =
$loc_data['postal_code'];
$fields[$adr.'countryname'] =
$loc_data['country'];
}
}
$fields['tel_work'] =
$fieldlist['comm_media']['work phone'];
$fields['tel_home'] =
$fieldlist['comm_media']['home phone'];
$fields['tel_voice'] =
$fieldlist['comm_media']['voice phone'];
$fields['tel_work_fax'] =
$fieldlist['comm_media']['work fax'];
$fields['tel_home_fax'] =
$fieldlist['comm_media']['home fax'];
$fields['tel_msg'] =
$fieldlist['comm_media']['msg phone'];
$fields['tel_cell'] =
$fieldlist['comm_media']['mobile (cell) phone'];
$fields['tel_pager'] =
$fieldlist['comm_media']['pager'];
$fields['tel_bbs'] =
$fieldlist['comm_media']['bbs'];
$fields['tel_modem'] =
$fieldlist['comm_media']['modem'];
$fields['tel_car'] =
$fieldlist['comm_media']['car phone'];
$fields['tel_isdn'] =
$fieldlist['comm_media']['isdn'];
$fields['tel_video'] =
$fieldlist['comm_media']['video'];
$fields['email'] =
$fieldlist['comm_media']['work email'];
$fields['email_home'] =
$fieldlist['comm_media']['home email'];
$fields['url'] =
$fieldlist['comm_media']['website'];
$email = $fields['email'];
$emailtype = $fields['email_type'];
if (!$emailtype)
{
$fields['email_type'] = 'INTERNET';
}
$hemail = $fields['email_home'];
$hemailtype = $fields['email_home_type'];
if (!$hemailtype)
{
$fields['email_home_type'] = 'INTERNET';
}
// set translation variable
$myexport = $this->vcard->export;
// check that each $fields exists in the export array
and
// set a new array to equal the translation and
original value
while( list($name,$value) = each($fields) )
{
if ($myexport[$name] && ($value != "") )
{
//echo
'<br>'.$name."=".$fields[$name]."\n";
$buffer[$myexport[$name]] = $value;
}
}
// create a vcard from this translated array
$data = $this->vcard->out($buffer);
if ($data == false)
{
return false;
}
return $data;
}
/**
* Return a list with the available id's in the application.
* The optional lastmod parameter allows a limitations of the
data id list.
* The list contains all the id's of the modified data since the
passed lastmod timestamp.
*
* @param integer $lastmod last modification time, default
is -1 and means return all data id's
* @return array list of data id's
*/
function getIdList($lastmod=-1)
{
$idList = array();
$lastmod = intval($lastmod);
//$this->contacts->read(null, false, null, null, null,
null, null, $lastmod);
// read_contacts doesnt allow lastmod time -workaround:
$owner =
intval($GLOBALS['phpgw_info']['user']['account_id']);
if($lastmod >= 0)
{
$sql = 'SELECT DISTINCT c.contact_id AS
contact_id '.
'FROM phpgw_contact c '.
'LEFT JOIN phpgw_contact_addr ca ON
(c.contact_id=ca.contact_id) '.
'LEFT JOIN phpgw_contact_comm cc ON
(c.contact_id=cc.contact_id) '.
'LEFT JOIN phpgw_contact_note cn ON
(c.contact_id=cn.contact_id) '.
'LEFT JOIN phpgw_contact_person cp ON
(c.contact_id=cp.person_id) '.
'WHERE '.
' (c.owner = '.$owner.')'.
' AND'.
' ('.
' (ca.modified_on '.$lastmod.') OR '.
' (cc.modified_on '.$lastmod.') OR '.
' (cn.modified_on '.$lastmod.') OR '.
' (cp.modified_on '.$lastmod.') '.
' ) '.
'ORDER BY c.contact_id';
}
else
{
$sql = 'SELECT DISTINCT contact_id '.
'FROM phpgw_contact '.
'WHERE owner = '.$owner.' '.
'ORDER BY contact_id';
}
$contacts =
$this->contacts->db->query($sql,__LINE__,__FILE__);
while ($this->contacts->db->next_record())
{
$idList[] =
$this->contacts->db->Record['contact_id'];
}
return $idList;
}
/**
* Remove data of the passed id.
*
* @param integer $id id of data to remove from the
application
* @return boolean true if the data is removed, otherwise
false
*/
function removeData($id)
{
return $this->contacts->delete_contact($id);
}
/**
* Replace the existing data of the passed id with the passed
data in a certain mime type format.
*
* @param integer $id id of data to replace
* @param mixed $data the new data, the datatype depends
on the passed mime type
* @param string $type specifies the mime type of the
passed data
* @return boolean true if the data is replaced,
otherwise false
*/
function replaceData($id, $data, $type)
{
if($type != 'text/x-vcard')
{
return false;
}
if(!$this->contacts->check_read($id))
{
return false;
}
$data = ereg_replace("\n\n", "\r\n", $data);
$data_lines = explode("\r\n", $data);
$buffer = array();
$temp_line = '';
while(list(, $line) = each($data_lines))
{
$line = trim($line);
if(substr($line, -1) == '=')
{
// '=' at end-of-line --line to be
continued with next line
$temp_line .= substr($line, 0, -1);
continue;
}
else
{
$line = $temp_line . $line;
$temp_line = ''; // important for next
line which ends with =
}
if (strstr($line, 'BEGIN:VCARD'))
{
// added for p800 vcards: problem if
vcard starts with "<![CDATA["
$line = strstr($line, 'BEGIN:VCARD');
}
$buffer +=
$this->vcard->parse_vcard_line($line);
}
$fields = $this->vcard->in($buffer);
$fields['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
$fields['access'] = 'private';
$fields['contact_id'] = $id;
return $this->contacts->contact_import($fields, '',
true);
}
/**
* Checks if data for the passed id exists.
*
* @param integer $id id to check
* @return boolean true if the data with id exist,
otherwise false
*/
function existData($id)
{
if(!$this->contacts->check_read($id))
{
return false;
}
else
{
return true;
}
}
}
?>
====================================================
Index: class.bocatalog_contact_note_type.inc.php
<?php
class bocatalog_contact_note_type
{
function bocatalog_contact_note_type()
{
$this->so =
CreateObject('addressbook.socatalog_contact_note_type');
}
function select_catalog()
{
return $this->so->select_catalog();
}
function insert($fields)
{
return $this->so->insert($fields);
}
function delete($key)
{
return $this->so->delete($key);
}
function update($key, $fields)
{
$this->so->update($key, $fields);
}
function get_record($key)
{
return $this->so->get_record($key);
}
}
?>
====================================================
Index: class.bocatalog_contact_comm_type.inc.php
<?php
class bocatalog_contact_comm_type
{
function bocatalog_contact_comm_type()
{
$this->so =
CreateObject('addressbook.socatalog_contact_comm_type');
}
function select_catalog()
{
return $this->so->select_catalog();
}
function insert($fields)
{
return $this->so->insert($fields);
}
function delete($key)
{
return $this->so->delete($key);
}
function update($key, $fields)
{
$this->so->update($key, $fields);
}
function get_record($key)
{
return $this->so->get_record($key);
}
}
?>
====================================================
Index: class.boaddressbook_prefs.inc.php
<?php
/**************************************************************************\
* phpGroupWare API - Commononly used functions *
* This file written by Alex Borges <address@hidden> *
* Business Logic for addressbook preferences *
* Copyright (C) 2003 Alex Borges *
* -------------------------------------------------------------------------*
* This library is part of the phpGroupWare Addressbook app *
* http://www.phpgroupware.org/ *
* ------------------------------------------------------------------------ *
* This library 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. *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
\**************************************************************************/
class boaddressbook_prefs
{
var $preferences;
var $person_columns;
var $org_columns;
var $default_category='__NONE__';
var $person_columns_forced=false;
var $org_columns_forced=false;
var $default_category_forced=false;
var $public=array('read_preferences' => True);
function boaddressbook_prefs()
{
$this->preferences=CreateObject('phpgwapi.preferences');
}
function save_preferences($type='')
{
if(is_array($this->person_columns))
{
if(count($this->person_columns) >=1 ||
(
isset($this->person_columns['comm_types'])
&&(count($this->person_columns['comm_types'])>0)))
{
//print "<BR><B>count(Person )columns >=
1".print_r($this->person_columns)."</B><BR>";
$this->preferences->add('addressbook','person_columns',serialize($this->person_columns),$type);
}
else
{
//print "<BR><B>Deleting person_columns
$type</B><BR>";
$this->preferences->delete('addressbook',"person_columns",$type);
$this->remove_from_forced("person_columns");
}
}
else
{
$this->preferences->delete('addressbook','person_columns',$type);
$this->remove_from_forced("person_columns");
}
if(count($this->org_columns) >=1 ||
(
isset($this->org_columns['comm_types'])
&&(count($this->org_columns['comm_types'])>0)))
{
if(count($this->org_columns) >=1)
{
$this->preferences->add('addressbook','org_columns',serialize($this->org_columns),$type);
}
else
{
$this->preferences->delete('addressbook','org_columns',$type);
//print "<BR><B>Deleting person_columns
$type</B><BR>";
$this->remove_from_forced("org_columns");
$this->org_columns_forced=false;
}
}
else
{
$this->preferences->delete('addressbook','org_columns',$type);
$this->remove_from_forced("org_columns");
$this->org_columns_forced=false;
}
if($this->default_category!='__NONE__')
{
/* print "<B>DSASDADSADSADAS</B>";
print $this->default_category; */
$this->preferences->add('addressbook','default_category',$this->default_category,$type);
}
else
{
$this->preferences->delete('addressbook','default_category',$type);
$this->remove_from_forced('default_category');
}
$this->preferences->save_repository(true,$type);
}
function read_preferences($type='')
{
$this->preferences->read();
$temp=$this->preferences->data['addressbook'];
$this->person_columns=unserialize($temp['person_columns']);
$this->person_columns_forced=$this->is_forced_value('person_columns');
//Check that we dont reflect types that arent asked of us in
'type'
if(!$this->person_columns_forced && $type=='forced')
{
unset($this->person_columns);
}
$this->org_columns=unserialize($temp['org_columns']);
$this->org_columns_forced=$this->is_forced_value('org_columns');
if(!$this->org_columns_forced && $type=='forced')
{
//print "<BR><B>GRABLING</B><BR>";
unset($this->org_columns);
}
$this->default_category=$temp['default_category'];
$this->default_category_forced=$this->is_forced_value('default_category');
if($this->default_category_forced && $type!='forced')
{
$this->default_category='__NONE__';
}
}
function remove_from_forced($preference_name)
{
if(!empty($this->preferences->forced['addressbook'][$preference_name]))
{
unset($this->preferences->forced['addressbook'][$preference_name]);
}
}
function is_forced_value($preference_name)
{
if ($this->preferences->forced['addressbook'][$preference_name])
{
return True;
}
else
{
return False;
}
}
}
====================================================
Index: class.bocatalog_contact_addr_type.inc.php
<?php
class bocatalog_contact_addr_type
{
function bocatalog_contact_addr_type()
{
$this->so =
CreateObject('addressbook.socatalog_contact_addr_type');
}
function select_catalog()
{
return $this->so->select_catalog();
}
function insert($fields)
{
return $this->so->insert($fields);
}
function delete($key)
{
return $this->so->delete($key);
}
function update($key, $fields)
{
$this->so->update($key, $fields);
}
function get_record($key)
{
return $this->so->get_record($key);
}
}
?>
====================================================
Index: class.bocatalog_contact_comm_descr.inc.php
<?php
class bocatalog_contact_comm_descr
{
function bocatalog_contact_comm_descr()
{
$this->so =
CreateObject('addressbook.socatalog_contact_comm_descr');
}
function select_catalog()
{
$comm_descr = $this->so->select_catalog();
foreach($comm_descr as $key => $value)
{
$comm_descr_array[] = array('comm_type_id' =>
$value['comm_type'],
'comm_type' =>
$this->search_comm_type_id($value['comm_type']),
'comm_descr_id' =>
$value['comm_descr_id'],
'comm_description'
=> $value['comm_description']);
}
return $comm_descr_array;
}
function insert($fields)
{
return $this->so->insert($fields);
}
function delete($key)
{
return $this->so->delete($key);
}
function update($key, $fields)
{
$this->so->update($key, $fields);
}
function get_record($key)
{
return $this->so->get_record($key);
}
function select_catalog_types()
{
$this->comm_type = $this->so->select_catalog_types();
return $this->comm_type;
}
/**
* Search communication type id in communications catalog
*
* @param integer $id The communication id to find
* @return string The description type of id
*/
function search_comm_type_id($id)
{
return $this->search_catalog('comm_type_id', $id,
'comm_type_description', 'comm_type');
}
/**
* Search communication type in location catalog
*
* @param string $description The communication type to find
* @return integer The id of description
*/
function search_comm_type($description)
{
return $this->search_catalog('comm_type_description',
$description, 'comm_type_id', 'comm_type');
}
/**
* Search a value into an array
*
* @param string $field_to_search Field into what you want to
find
* @param string $value_to_search Value what you want
* @param string $field Field what you want return
* @param string $catalog Catalog name into you want to find
* @return string The value which you requiere in $field
*/
function search_catalog($field_to_search, $value_to_search,
$field, $catalog)
{
reset($this->$catalog);
foreach ($this->$catalog as $key => $value)
{
if ($value[$field_to_search] ==
$value_to_search)
{
return $value[$field];
}
}
}
}
?>
====================================================
Index: hook_manual.inc.php
<?php
/**************************************************************************\
* phpGroupWare - Calendar Holidays *
* http://www.phpgroupware.org *
* Written by Mark Peters <address@hidden> *
* -------------------------------------------- *
* 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: hook_manual.inc.php,v 1.6 2004/12/31 04:55:24 skwashd Exp $ */
// Only Modify the $file variable.....
$file = Array();
//Do not modify below this line
display_manual_section($appname,$file);
?>
====================================================
Index: hook_sidebox_menu.inc.php
<?php
$menu_title = $GLOBALS['phpgw_info']['apps'][$appname]['title'] . ' '.
lang('Menu');
$file = Array(
array('text' => 'New Person',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add_person')),
array('text' => 'New Org',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add_org')),
array('text' => '_NewLine_'),
array('text' => 'Add VCard',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.in')),
array('text' => 'Categorize Persons',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicategorize_contacts.index')),
array('text' => 'Import Contacts',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.import')),
array('text' => 'Import CSV',
'url' =>
$GLOBALS['phpgw']->link('/addressbook/csv_import.php')),
array('text' => 'Export Contacts',
'url' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export')),
array('text' => '_NewLine_') // give a newline
);
display_sidebox($appname,$menu_title,$file);
?>
====================================================
Index: addressbook/inc/class.uiXport.inc.php
diff -u addressbook/inc/class.uiXport.inc.php:1.19
addressbook/inc/class.uiXport.inc.php:1.20
--- addressbook/inc/class.uiXport.inc.php:1.19 Sat Mar 1 15:44:58 2003
+++ addressbook/inc/class.uiXport.inc.php Fri Dec 31 04:55:22 2004
@@ -14,7 +14,7 @@
class uiXport
{
- var $output = '';
+ var $template;
var $public_functions = array(
'import' => True,
'export' => True
@@ -32,6 +32,7 @@
function uiXport()
{
+ $this->template = $GLOBALS['phpgw']->template;
$this->cat = CreateObject('phpgwapi.categories');
$this->bo =
CreateObject('addressbook.boXport',True);
$this->browser = CreateObject('phpgwapi.browser');
@@ -45,28 +46,19 @@
$this->cat_id = $this->bo->cat_id;
}
- function totpl()
- {
- if(@isset($this->output) && !empty($this->output))
- {
-
$GLOBALS['phpgw']->template->set_var('phpgw_body', $this->output,True);
- unset($this->output);
- }
- }
-
/* Return a select form element with the categories option
dialog in it */
function
cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
{
- if($java)
+ if ($java)
{
$jselect = ' onChange="this.form.submit();"';
}
/* Setup all and none first */
$cats_link = "\n" .'<select
name="fcat_id'.($multiple?'[]':'').'"' .$jselect . ($multiple ? 'multiple
size="3"' : '') . ">\n";
- if(!$notall)
+ if (!$notall)
{
$cats_link .= '<option value=""';
- if($cat_id=='all')
+ if ($cat_id=='all')
{
$cats_link .= ' selected';
}
@@ -74,22 +66,20 @@
}
/* Get global and app-specific category listings */
- $cats_link .=
$this->cat->formatted_list('select','all',$cat_id,True);
+ $cats_link .=
$this->cat->formated_list('select','all',$cat_id,True);
$cats_link .= '</select>'."\n";
return $cats_link;
}
function import()
{
- global
$convert,$download,$tsvfile,$private,$conv_type,$fcat_id;
-
- if($convert)
+ if ($_REQUEST['convert']) //&&
($_FILES['tsvfile']['error'] == UPLOAD_ERR_OK))
{
- $buffer =
$this->bo->import($tsvfile,$conv_type,$private,$fcat_id);
+ $buffer =
$this->bo->import($_FILES['tsvfile']['tmp_name'],$_REQUEST['conv_type'],$_REQUEST['private'],$_REQUEST['fcat_id']);
- if($download == '')
+ if ($_REQUEST['download'] == '')
{
- if($conv_type == 'Debug LDAP' ||
$conv_type == 'Debug SQL' )
+ if($_REQUEST['conv_type'] == 'Debug
LDAP' || $_REQUEST['conv_type'] == 'Debug SQL' )
{
// filename, default
application/octet-stream, length of file, default nocache True
$GLOBALS['phpgw']->browser->content_header($tsvfilename,'',strlen($buffer));
@@ -98,30 +88,36 @@
else
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo "<pre>$buffer</pre>";
echo '<a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')
. '">'.lang('OK').'</a>';
+
$GLOBALS['phpgw']->common->phpgw_footer();
}
}
else
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo "<pre>$buffer</pre>";
echo '<a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index').
'">'.lang('OK').'</a>';
+
$GLOBALS['phpgw']->common->phpgw_footer();
}
+
}
else
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
set_time_limit(0);
-
$GLOBALS['phpgw']->template->set_file(array('import' => 'import.tpl'));
+ $this->template->set_file(array('import' =>
'import.tpl'));
$dir_handle = opendir(PHPGW_APP_INC . SEP .
'import');
$i=0; $myfilearray = '';
- while($file = readdir($dir_handle))
+ while ($file = readdir($dir_handle))
{
- if((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) )
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'import' . SEP . $file) )
{
$myfilearray[$i] = $file;
$i++;
@@ -129,92 +125,116 @@
}
closedir($dir_handle);
sort($myfilearray);
- for($i=0;$i<count($myfilearray);$i++)
+ for ($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_','
',$myfilearray[$i]);
$conv .= '<OPTION VALUE="' .
$myfilearray[$i].'">' . $fname . '</OPTION>';
}
-
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
-
$GLOBALS['phpgw']->template->set_var('lang_cat',lang('Select Category'));
-
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
-
$GLOBALS['phpgw']->template->set_var('conversion',lang('Select the type of
conversion'));
-
$GLOBALS['phpgw']->template->set_var('export_path',lang('Enter the path to the
export file here'));
-
$GLOBALS['phpgw']->template->set_var('navbar_bg',$GLOBALS['phpgw_info']['theme']['navbar_bg']);
-
$GLOBALS['phpgw']->template->set_var('navbar_text',$GLOBALS['phpgw_info']['theme']['navbar_text']);
-
$GLOBALS['phpgw']->template->set_var('mark_private',lang('Mark records as
private'));
-
$GLOBALS['phpgw']->template->set_var('help_import',lang('In Netscape, open the
Addressbook and select <b>Export</b> from the <b>File</b> menu.<br>The file
exported will be in LDIF format.<P>Or, in Outlook, select your Contacts folder,
select <b>Import and Export...</b> from'));
-
$GLOBALS['phpgw']->template->set_var('help_import2',lang('the <b>File</b> menu
and export your contacts into a comma separated text (CSV) file. <P>Or, in Palm
Desktop 4.0 or greater, visit your addressbook and select <b>Export</b> from
the <b>File</b> menu. The file exported will be in VCard format.<P>'));
-
$GLOBALS['phpgw']->template->set_var('none',lang('none'));
-
$GLOBALS['phpgw']->template->set_var('debug_browser',lang('Debug output in
browser'));
-
$GLOBALS['phpgw']->template->set_var('import_text',lang('Import from LDIF, CSV,
or VCard'));
-
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.import'));
-
$GLOBALS['phpgw']->template->set_var('cat_link',$this->cat_option($this->cat_id,True,False));
-
$GLOBALS['phpgw']->template->set_var('tsvfilename','');
-
$GLOBALS['phpgw']->template->set_var('conv',$conv);
-
$GLOBALS['phpgw']->template->set_var('debug',lang('Debug output in browser'));
-
$GLOBALS['phpgw']->template->set_var('filetype',lang('LDIF'));
-
$GLOBALS['phpgw']->template->set_var('download',lang('Submit'));
-
$GLOBALS['phpgw']->template->set_var('start',$this->start);
-
$GLOBALS['phpgw']->template->set_var('sort',$this->sort);
-
$GLOBALS['phpgw']->template->set_var('order',$this->order);
-
$GLOBALS['phpgw']->template->set_var('filter',$this->filter);
-
$GLOBALS['phpgw']->template->set_var('query',$this->query);
-
$GLOBALS['phpgw']->template->set_var('cat_id',$this->cat_id);
-
- $this->output =
$GLOBALS['phpgw']->template->fp('out','import');
- $this->totpl();
+
$this->template->set_var('lang_cancel',lang('Cancel'));
+
$this->template->set_var('lang_cat',lang('Select Category'));
+
$this->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
+
$this->template->set_var('navbar_bg',$GLOBALS['phpgw_info']['theme']['navbar_bg']);
+
$this->template->set_var('navbar_text',$GLOBALS['phpgw_info']['theme']['navbar_text']);
+
$this->template->set_var('import_text',lang('Import from LDIF, CSV, or VCard'));
+
$this->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.import'));
+
$this->template->set_var('cat_link',$this->cat_option($this->cat_id,False,False));
+
//$this->template->set_var('cat_link',$this->cat_option($this->cat_id,True,False));
+ $this->template->set_var('tsvfilename','');
+ $this->template->set_var('conv',$conv);
+ $this->template->set_var('debug',lang('Debug
output in browser'));
+
$this->template->set_var('filetype',lang('LDIF'));
+
$this->template->set_var('download',lang('Submit'));
+ $this->template->set_var('start',$this->start);
+ $this->template->set_var('sort',$this->sort);
+ $this->template->set_var('order',$this->order);
+
$this->template->set_var('filter',$this->filter);
+ $this->template->set_var('query',$this->query);
+
$this->template->set_var('cat_id',$this->cat_id);
+ $this->template->pparse('out','import');
}
+// $GLOBALS['phpgw']->common->phpgw_footer();
}
function export()
{
- global
$convert,$tsvfilename,$cat_id,$download,$conv_type;
-
- if($convert)
+ //global $tsvfilename,$both_types,$sub_cats;
+ $convert = get_var('convert', array('GET','POST'));
+ $tsvfilename = get_var('tsvfilename',
array('GET','POST'));
+ $fcat_id = get_var('fcat_id', array('GET','POST'));
+ $download = get_var('download', array('GET','POST'));
+ $conv_type = get_var('conv_type', array('GET','POST'));
+ $both_types = get_var('both_types',
array('GET','POST'));
+ $sub_cats = get_var('sub_cats', array('GET','POST'));
+
+ // get the data to create the sql query used by the
addressbook display
+ $export_vars =
$GLOBALS['phpgw']->session->appsession('export_vars','addressbook');
+ //echo "<pre>Export_vars: "; print_r($export_vars);
echo "</pre>\n";
+
+ //$entries = $this->bo->$get_data_function($fields,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
+
+ if ($_REQUEST['convert'])
{
- if($conv_type == 'none')
+ if ($_REQUEST['conv_type'] == 'none')
{
$GLOBALS['phpgw_info']['flags']['noheader'] = False;
$GLOBALS['phpgw_info']['flags']['noheader'] = True;
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo lang('<b>No conversion type
<none> could be located.</b> Please choose a conversion type from the
list');
echo ' <a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export')
. '">' . lang('OK') . '</a>';
-
$GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+
$GLOBALS['phpgw']->common->phpgw_footer();
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
- $buffer = $this->bo->export($conv_type,$cat_id);
-
- if(($download == 'on') || ($conv_type ==
'Palm_PDB'))
+ $buffer =
$this->bo->export($_REQUEST['conv_type'],$_REQUEST['fcat_id'],$both_types,$sub_cats);
+
+ // Note our use of ===. Simply == would not
work as expected
+ if(!(strpos($_REQUEST['conv_type'],
'OpenOffice') === false))
+ {
+ // filename, default
application/octet-stream, length of file, default nocache True
+
//$this->browser->content_header($tsvfilename,'application/x-octet-stream',strlen($buffer));
+
//$this->browser->content_header($tsvfilename,'application/vnd.sun.xml.writer');
+ //echo $tsvfilename;
+ //echo $buffer;
+ //echo basename($buffer);
+
//$this->browser->content_header($tsvfilename,'');
+
$this->browser->content_header(basename($buffer),'');//echo $buffer;
+ readfile($buffer);
+ //echo $tsvfilename;
+
+ }
+ elseif(($_REQUEST['download'] == 'on') ||
($_REQUEST['conv_type'] == 'Palm_PDB') )
{
// filename, default
application/octet-stream, length of file, default nocache True
$this->browser->content_header($tsvfilename,'application/x-octet-stream',strlen($buffer));
echo $buffer;
- exit;
}
else
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo "<pre>\n";
echo $buffer;
echo "\n</pre>\n";
echo '<a
href="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export')
. '">' . lang('OK') . '</a>';
+
$GLOBALS['phpgw']->common->phpgw_footer();
}
}
else
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
set_time_limit(0);
-
-
$GLOBALS['phpgw']->template->set_file(array('export' => 'export.tpl'));
+
+ $this->template->set_file(array('export' =>
'export.tpl'));
$dir_handle = opendir(PHPGW_APP_INC. SEP .
'export');
$i=0; $myfilearray = '';
- while($file = readdir($dir_handle))
+ while ($file = readdir($dir_handle))
{
- if((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) )
+ if ((substr($file, 0, 1) != '.') &&
is_file(PHPGW_APP_INC . SEP . 'export' . SEP . $file) )
{
$myfilearray[$i] = $file;
$i++;
@@ -222,36 +242,33 @@
}
closedir($dir_handle);
sort($myfilearray);
- for($i=0;$i<count($myfilearray);$i++)
+ for ($i=0;$i<count($myfilearray);$i++)
{
$fname = ereg_replace('_','
',$myfilearray[$i]);
$conv .= ' <option
value="'.$myfilearray[$i].'">'.$fname.'</option>'."\n";
}
-
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
-
$GLOBALS['phpgw']->template->set_var('lang_cat',lang('Select Category'));
-
$GLOBALS['phpgw']->template->set_var('cat_link',$this->cat_option($this->cat_id,False,False));
-
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/addressbook/index.php'));
-
$GLOBALS['phpgw']->template->set_var('navbar_bg',$GLOBALS['phpgw_info']['theme']['navbar_bg']);
-
$GLOBALS['phpgw']->template->set_var('navbar_text',$GLOBALS['phpgw_info']['theme']['navbar_text']);
-
$GLOBALS['phpgw']->template->set_var('export_text',lang('Export from
Addressbook'));
-
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export'));
-
$GLOBALS['phpgw']->template->set_var('filename',lang('Export file name'));
-
$GLOBALS['phpgw']->template->set_var('conversion',lang('Select the type of
conversion'));
-
$GLOBALS['phpgw']->template->set_var('conv',$conv);
-
$GLOBALS['phpgw']->template->set_var('debug',lang(''));
-
$GLOBALS['phpgw']->template->set_var('download',lang('Submit'));
-
$GLOBALS['phpgw']->template->set_var('download_export',lang('Download export
file (Uncheck to debug output in browser)'));
-
$GLOBALS['phpgw']->template->set_var('none',lang('none'));
-
$GLOBALS['phpgw']->template->set_var('start',$this->start);
-
$GLOBALS['phpgw']->template->set_var('sort',$this->sort);
-
$GLOBALS['phpgw']->template->set_var('order',$this->order);
-
$GLOBALS['phpgw']->template->set_var('filter',$this->filter);
-
$GLOBALS['phpgw']->template->set_var('query',$this->query);
-
$GLOBALS['phpgw']->template->set_var('cat_id',$this->cat_id);
+
$this->template->set_var('lang_cancel',lang('Cancel'));
+
$this->template->set_var('lang_cat',lang('Select Category'));
+
$this->template->set_var('cat_link',$this->cat_option($this->cat_id,False,False));
+
$this->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/addressbook/index.php'));
+
$this->template->set_var('navbar_bg',$GLOBALS['phpgw_info']['theme']['navbar_bg']);
+
$this->template->set_var('navbar_text',$GLOBALS['phpgw_info']['theme']['navbar_text']);
+
$this->template->set_var('export_text',lang('Export from Addressbook'));
+
$this->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export'));
+
$this->template->set_var('filename',lang('Export file name'));
+ $this->template->set_var('conv',$conv);
+ $this->template->set_var('debug',lang(''));
+
$this->template->set_var('download',lang('Submit'));
+ $this->template->set_var('start',$this->start);
+ $this->template->set_var('sort',$this->sort);
+ $this->template->set_var('order',$this->order);
+
$this->template->set_var('filter',$this->filter);
+ $this->template->set_var('query',$this->query);
+
$this->template->set_var('cat_id',$this->cat_id);
+ $this->template->pparse('out','export');
- $this->output =
$GLOBALS['phpgw']->template->fp('out','export');
- $this->totpl();
+ $GLOBALS['phpgw']->common->phpgw_footer();
}
}
}
====================================================
====================================================
Index: addressbook/inc/hook_deleteaccount.inc.php
diff -u addressbook/inc/hook_deleteaccount.inc.php:1.5
addressbook/inc/hook_deleteaccount.inc.php:1.6
--- addressbook/inc/hook_deleteaccount.inc.php:1.5 Wed Nov 28 03:42:56 2001
+++ addressbook/inc/hook_deleteaccount.inc.php Fri Dec 31 04:55:24 2004
@@ -14,12 +14,13 @@
$contacts = CreateObject('phpgwapi.contacts');
- if(intval($GLOBALS['HTTP_POST_VARS']['new_owner'])==0)
+ if(intval($_POST['new_owner'])==0)
{
-
$contacts->delete_all(intval($GLOBALS['HTTP_POST_VARS']['account_id']));
+ $contacts->delete_all(intval($_POST['account_id']));
}
else
{
-
$contacts->change_owner(intval($GLOBALS['HTTP_POST_VARS']['account_id']),intval($GLOBALS['HTTP_POST_VARS']['new_owner']));
+
$contacts->change_owner(intval($_POST['account_id']),intval($_POST['new_owner']));
+
$contacts->change_owner_others(intval($_POST['account_id']),intval($_POST['new_owner']));
}
?>
====================================================
Index: addressbook/inc/hook_home.inc.php
diff -u addressbook/inc/hook_home.inc.php:1.22
addressbook/inc/hook_home.inc.php:1.23
--- addressbook/inc/hook_home.inc.php:1.22 Sun Apr 27 21:12:59 2003
+++ addressbook/inc/hook_home.inc.php Fri Dec 31 04:55:24 2004
@@ -1,73 +1,108 @@
<?php
-
/**************************************************************************\
- * phpGroupWare - Addressbook hook_home
*
- * http://www.phpgroupware.org
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
- /* $Id$ */
+ /**************************************************************************\
+ * phpGroupWare - E-Mail *
+ * http://www.phpgroupware.org *
+ * -------------------------------------------- *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU General Public License as published by the *
+ * Free Software Foundation; either version 2 of the License, or (at your *
+ * option) any later version. *
+ \**************************************************************************/
+ /* $Id$ */
+
+/* TODO Update for new contacts back end
$d1 = strtolower(substr(PHPGW_APP_INC,0,3));
if($d1 == 'htt' || $d1 == 'ftp' )
{
echo "Failed attempt to break in via an old Security
Hole!<br>\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
+ $prev_currentapp = $GLOBALS['phpgw_info']['flags']['currentapp'];
+ $GLOBALS['phpgw_info']['flags']['currentapp'] = 'addressbook';
+
+ echo 'addressbook/inc/hook_home.inc.php called';
+
if ($GLOBALS['phpgw_info']['user']['apps']['addressbook']
&&
$GLOBALS['phpgw_info']['user']['preferences']['addressbook']['mainscreen_showbirthdays'])
{
+ echo "\n<!-- Birthday info -->\n";
+
$c = CreateObject('phpgwapi.contacts');
- $qfields = array
- (
- 'n_given' => 'n_given',
- 'n_family' => 'n_family',
- 'bday' => 'bday'
+ $qfields = array(
+ 'contact_id' => 'contact_id',
+ 'per_first_name' => 'per_first_name',
+ 'per_last_name' => 'per_last_name',
+ 'per_birthday' => 'per_birthday'
);
$now = time() - ((60 * 60) *
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
$today = $GLOBALS['phpgw']->common->show_date($now,'n/d/');
-
- $bdays =
$c->read(0,15,$qfields,$today,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
-
+
+ $criteria = array('per_birthday' => $today);
+ $bdays = $c->get_persons($qfields, 15, 0, '', '', $criteria);
+ //$bdays =
$c->read(0,15,$qfields,$today,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
+
+ $title = '<font color="#FFFFFF">'.lang('Birthdays').'</font>';
+
+ if ((isset($prev_currentapp))
&& ($prev_currentapp)
&& ($GLOBALS['phpgw_info']['flags']['currentapp'] !=
$prev_currentapp))
{
$GLOBALS['phpgw_info']['flags']['currentapp'] = $prev_currentapp;
}
+ $portalbox = CreateObject('phpgwapi.listbox',
+ Array(
+ 'title' => $title,
+ 'primary' =>
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+ 'secondary' =>
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+ 'tertiary' =>
$GLOBALS['phpgw_info']['theme']['navbar_bg'],
+ 'width' => '100%',
+ 'outerborderwidth' => '0',
+ 'header_background_image' =>
$GLOBALS['phpgw']->common->image($GLOBALS['phpgw']->common->get_tpl_dir('phpgwapi'),'bg_filler')
+ )
+ );
$app_id =
$GLOBALS['phpgw']->applications->name2id('addressbook');
$GLOBALS['portal_order'][] = $app_id;
+ $var = Array(
+ 'up' => Array('url' => '/set_box.php', 'app' =>
$app_id),
+ 'down' => Array('url' => '/set_box.php', 'app' =>
$app_id),
+ 'close' => Array('url' => '/set_box.php', 'app' =>
$app_id),
+ 'question' => Array('url' => '/set_box.php', 'app' =>
$app_id),
+ 'edit' => Array('url' => '/set_box.php', 'app' =>
$app_id)
+ );
+
+ while(list($key,$value) = each($var))
+ {
+ $portalbox->set_controls($key,$value);
+ }
+
+ $portalbox->data = Array();
- $GLOBALS['phpgw']->portalbox->set_params(array('app_id' =>
$app_id,
-
'title' => lang('addressbook')));
while(list($key,$val) = @each($bdays))
{
- if (substr($val['bday'],0,strlen($today)) == $today)
- {
- $GLOBALS['phpgw']->portalbox->data[] = array
- (
- 'text'
=> lang("Today is %1's birthday!", $val['n_given'] . ' ' . $val['n_family']),
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $val['id']),
- 'lang_link_statustext' => lang('show
contact')
- );
- }
+ $portalbox->data[] = array(
+ 'text' => lang("Today is %1's birthday!",
$val['per_first_name'] . ' ' . $val['per_last_name']),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view_person&ab_id='
. $val['contact_id'])
+ );
}
$tomorrow = $GLOBALS['phpgw']->common->show_date($now +
86400,'n/d/');
- $bdays =
$c->read(0,15,$qfields,$tomorrow,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
+ $criteria = array('per_birthday' => $tomorrow);
+ $bdays = $c->get_persons($qfields, 15, 0, '', '', $criteria);
while(list($key,$val) = @each($bdays))
{
- if (substr($val['bday'],0,strlen($tomorrow)) ==
$tomorrow)
- {
- $GLOBALS['phpgw']->portalbox->data[] = array
- (
- 'text'
=> lang("Tomorrow is %1's birthday.", $val['n_given'] . ' ' . $val['n_family']),
- 'link'
=>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='.$val['id']),
- 'lang_link_statustext' => lang('show
contact')
- );
- }
+ $portalbox->data[] = array(
+ 'text' => lang("Tomorrow is %1's
birthday.",$val['per_first_name'] . ' ' . $val['per_last_name']),
+ 'link' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view_person&ab_id='.$val['contact_id'])
+ );
}
- $GLOBALS['phpgw']->portalbox->draw();
+
+ if(count($portalbox->data))
+ {
+ echo $portalbox->draw();
+ }
+
+ //unset($portalbox);
+ echo "\n<!-- Birthday info -->\n";
}
+*/
?>
====================================================
Index: addressbook/inc/hook_admin.inc.php
diff -u addressbook/inc/hook_admin.inc.php:1.14
addressbook/inc/hook_admin.inc.php:1.15
--- addressbook/inc/hook_admin.inc.php:1.14 Wed Apr 23 01:14:44 2003
+++ addressbook/inc/hook_admin.inc.php Fri Dec 31 04:55:24 2004
@@ -2,24 +2,28 @@
/**************************************************************************\
* phpGroupWare
*
* http://www.phpgroupware.org
*
- * Written by coreteam <address@hidden> *
- * -----------------------------------------------------
*
+ * Written by Joseph Engo <address@hidden> *
+ * --------------------------------------------
*
* 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$ */
- {
-// Only Modify the $file variable.....
- $file = Array
- (
- 'Site Configuration' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname='
. $appname),
- 'Edit custom fields' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.index'),
- 'Global Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname='
. $appname . '&global_cats=True')
- );
-//Do not modify below this line
- $GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
- }
+ // $Id$
+ // $Source$
+
+ // Only Modify the $file and $title variables.....
+ $title = $appname;
+ $file = Array(
+ 'Site Configuration' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uiconfig.index&appname='
. $appname),
+ 'Edit custom fields' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uifields.index'),
+ 'Global Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=admin.uicategories.index&appname=addressbook'),
+ 'Communication Types Manager' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_contact_comm_type.view'),
+ 'Communication Descriptions Manager' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_contact_comm_descr.view'),
+ 'Location Manager' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_contact_addr_type.view'),
+ 'Notes Types Manager' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uicatalog_contact_note_type.view')
+ );
+ //Do not modify below this line
+ display_section($appname,$title,$file);
?>
====================================================
Index: addressbook/inc/functions.inc.php
diff -u addressbook/inc/functions.inc.php:1.102
addressbook/inc/functions.inc.php:1.103
--- addressbook/inc/functions.inc.php:1.102 Sat Mar 1 15:44:58 2003
+++ addressbook/inc/functions.inc.php Fri Dec 31 04:55:24 2004
@@ -43,8 +43,6 @@
/* Return a select form element with the categories option dialog in it
*/
function cat_option($cat_id='',$notall=False,$java=True,$multiple=False)
{
- global $phpgw;
-
if ($java)
{
$jselect = ' onChange="this.form.submit();"';
@@ -62,7 +60,7 @@
}
/* Get global and app-specific category listings */
- $cats_link .=
$phpgw->categories->formatted_list('select','all',$cat_id,True);
+ $cats_link .=
$GLOBALS['phpgw']->categories->formated_list('select','all',$cat_id,True);
$cats_link .= '</select>'."\n";
return $cats_link;
}
@@ -134,12 +132,10 @@
function read_custom_fields()
{
- global $phpgw_info;
-
$i = 0; $j = 0;
$fields = array();
- @reset($phpgw_info['user']['preferences']['addressbook']);
- while (list($col,$descr) =
@each($phpgw_info['user']['preferences']['addressbook']))
+
@reset($GLOBALS['phpgw_info']['user']['preferences']['addressbook']);
+ while (list($col,$descr) =
@each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
{
if ( substr($col,0,6) == 'extra_' )
{
@@ -166,17 +162,15 @@
function save_custom_field($old='',$new='')
{
- global $phpgw,$phpgw_info;
-
-
$phpgw->preferences->read_repository($phpgw_info['user']['account_id']);
+
$GLOBALS['phpgw']->preferences->read_repository($GLOBALS['phpgw_info']['user']['account_id']);
if ($old)
{
-
$phpgw->preferences->delete("addressbook","extra_".$old);
+
$GLOBALS['phpgw']->preferences->delete("addressbook","extra_".$old);
}
if($new)
{
- $phpgw->preferences->add("addressbook","extra_".$new);
+
$GLOBALS['phpgw']->preferences->add("addressbook","extra_".$new);
}
- $phpgw->preferences->save_repository(1);
+ $GLOBALS['phpgw']->preferences->save_repository(1);
}
?>
====================================================
Index: addressbook/inc/class.uifields.inc.php
diff -u addressbook/inc/class.uifields.inc.php:1.11
addressbook/inc/class.uifields.inc.php:1.12
--- addressbook/inc/class.uifields.inc.php:1.11 Sun Apr 27 21:12:59 2003
+++ addressbook/inc/class.uifields.inc.php Fri Dec 31 04:55:24 2004
@@ -24,8 +24,8 @@
function uifields()
{
-// $GLOBALS['phpgw']->template =
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
-// $GLOBALS['phpgw']->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $GLOBALS['phpgw']->template =
CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+ $GLOBALS['phpgw']->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
$this->config =
CreateObject('phpgwapi.config','addressbook');
}
@@ -34,9 +34,9 @@
if(!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
$GLOBALS['phpgw']->template->set_file(array(
@@ -80,6 +80,7 @@
$total_records = count($fields);
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
$GLOBALS['phpgw']->template->set_var('left',$GLOBALS['phpgw']->nextmatchs->left('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index'));
$GLOBALS['phpgw']->template->set_var('right',$GLOBALS['phpgw']->nextmatchs->right('/index.php',$start,$total_records,'menuaction=addressbook.uifields.index'));
@@ -98,12 +99,14 @@
$field = $fields[$i]['name'];
$title = $fields[$i]['title'];
+ $apply = $fields[$i]['apply'];
$GLOBALS['phpgw']->template->set_var('cfield',$title);
$params = array(
'menuaction' =>
'addressbook.uifields.edit',
- 'field' => urlencode($field),
+ 'field' => $field,
+ 'apply_for' => $apply,
'start' => $start,
'query' => $query,
'sort' => $sort,
@@ -128,13 +131,14 @@
if(!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
$field =
stripslashes($GLOBALS['HTTP_POST_VARS']['field']);
$field_name =
stripslashes($GLOBALS['HTTP_POST_VARS']['field_name']);
+ $apply_for =
stripslashes($GLOBALS['HTTP_POST_VARS']['apply_for']);
$start = $GLOBALS['HTTP_POST_VARS']['start'];
$query = $GLOBALS['HTTP_POST_VARS']['query'];
$sort = $GLOBALS['HTTP_POST_VARS']['sort'];
@@ -143,7 +147,7 @@
$GLOBALS['phpgw']->template->set_file(array('form' =>
'field_form.tpl'));
$GLOBALS['phpgw']->template->set_block('form','add','addhandle');
$GLOBALS['phpgw']->template->set_block('form','edit','edithandle');
-
+
if($submit)
{
$errorcount = 0;
@@ -161,11 +165,12 @@
if(!$error)
{
-
$this->save_custom_field($field,$field_name);
+
$this->save_custom_field($field,$field_name,$apply_for);
}
}
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
if($errorcount)
{
@@ -187,6 +192,14 @@
$GLOBALS['phpgw']->template->set_var('lang_name',lang('Field name'));
+
$GLOBALS['phpgw']->template->set_var('lang_apply_for',lang('Apply for'));
+
$GLOBALS['phpgw']->template->set_var('lang_persons',lang('Persons'));
+
$GLOBALS['phpgw']->template->set_var('lang_orgs',lang('Organizations'));
+
$GLOBALS['phpgw']->template->set_var('lang_both',lang('Both'));
+
$GLOBALS['phpgw']->template->set_var('checked_both','checked');
+
$GLOBALS['phpgw']->template->set_var('checked_person','');
+ $GLOBALS['phpgw']->template->set_var('checked_org','');
+
$GLOBALS['phpgw']->template->set_var('lang_add',lang('Add'));
$GLOBALS['phpgw']->template->set_var('lang_reset',lang('Clear Form'));
$GLOBALS['phpgw']->template->set_var('lang_done',lang('Done'));
@@ -204,13 +217,15 @@
if(!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
$field =
stripslashes($GLOBALS['HTTP_POST_VARS']['field'] ?
$GLOBALS['HTTP_POST_VARS']['field'] : $GLOBALS['HTTP_GET_VARS']['field']);
- $field_name =
stripslashes($GLOBALS['HTTP_POST_VARS']['field_name']);
+ $field_name = stripslashes(get_var('field_name'));
+ $apply_for = stripslashes(get_var('apply_for'));
+
$start = $GLOBALS['HTTP_POST_VARS']['start'] ?
$GLOBALS['HTTP_POST_VARS']['start'] : $GLOBALS['HTTP_GET_VARS']['start'];
$query = $GLOBALS['HTTP_POST_VARS']['query'] ?
$GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
$sort = $GLOBALS['HTTP_POST_VARS']['sort'] ?
$GLOBALS['HTTP_POST_VARS']['sort'] : $GLOBALS['HTTP_GET_VARS']['sort'];
@@ -240,11 +255,12 @@
if(!$error)
{
-
$this->save_custom_field($field,$field_name);
+
$this->save_custom_field($field,$field_name,$apply_for);
}
}
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
if($errorcount)
{
@@ -266,7 +282,7 @@
else
{
$fields =
$this->read_custom_fields($start,$limit,$field);
- $field =
$GLOBALS['phpgw']->strip_html($fields[0]['title']);
+ $field = $fields[0]['title'];
$fn = $fields[0]['name'];
}
@@ -278,6 +294,28 @@
$GLOBALS['phpgw']->template->set_var('hidden_vars',$hidden_vars);
$GLOBALS['phpgw']->template->set_var('lang_name',lang('Field name'));
+
$GLOBALS['phpgw']->template->set_var('lang_apply_for',lang('Apply for'));
+
$GLOBALS['phpgw']->template->set_var('lang_persons',lang('Persons'));
+
$GLOBALS['phpgw']->template->set_var('lang_orgs',lang('Organizations'));
+
$GLOBALS['phpgw']->template->set_var('lang_both',lang('Both'));
+
+ $GLOBALS['phpgw']->template->set_var('checked_both','');
+
$GLOBALS['phpgw']->template->set_var('checked_person','');
+ $GLOBALS['phpgw']->template->set_var('checked_org','');
+
+ if($apply_for=='person')
+ {
+
$GLOBALS['phpgw']->template->set_var('checked_person','checked');
+ }
+ elseif($apply_for=='org')
+ {
+
$GLOBALS['phpgw']->template->set_var('checked_org','checked');
+ }
+ elseif($apply_for=='both')
+ {
+
$GLOBALS['phpgw']->template->set_var('checked_both','checked');
+ }
+
$GLOBALS['phpgw']->template->set_var('lang_done',lang('Done'));
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
$GLOBALS['phpgw']->template->set_var('lang_delete',lang('Delete'));
@@ -296,13 +334,15 @@
if(!$GLOBALS['phpgw']->acl->check('run',1,'admin'))
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
echo lang('access not permitted');
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
- $field = $GLOBALS['HTTP_POST_VARS']['field'] ?
$GLOBALS['HTTP_POST_VARS']['field'] : $GLOBALS['HTTP_GET_VARS']['field'];
- $field_id = $GLOBALS['HTTP_POST_VARS']['field_id'] ?
$GLOBALS['HTTP_POST_VARS']['field_id'] : $GLOBALS['HTTP_GET_VARS']['field_id'];
+ $field = stripslashes(get_var('field'));
+ $field_name = stripslashes(get_var('field_name'));
+ $apply_for = stripslashes(get_var('apply_for'));
+
$start = $GLOBALS['HTTP_POST_VARS']['start'] ?
$GLOBALS['HTTP_POST_VARS']['start'] : $GLOBALS['HTTP_GET_VARS']['start'];
$query = $GLOBALS['HTTP_POST_VARS']['query'] ?
$GLOBALS['HTTP_POST_VARS']['query'] : $GLOBALS['HTTP_GET_VARS']['query'];
$sort = $GLOBALS['HTTP_POST_VARS']['sort'] ?
$GLOBALS['HTTP_POST_VARS']['sort'] : $GLOBALS['HTTP_GET_VARS']['sort'];
@@ -314,12 +354,13 @@
if($GLOBALS['HTTP_POST_VARS']['confirm'])
{
- $this->save_custom_field($field);
+ $this->save_custom_field($field, '',
$apply_for);
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uifields.index&start=$start&query=$query&sort=$sort"));
}
else
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
$hidden_vars = '<input type="hidden"
name="sort" value="' . $sort . '">' . "\n"
. '<input type="hidden" name="order"
value="' . $order .'">' . "\n"
@@ -350,22 +391,45 @@
}
}
- function read_custom_fields($start=0,$limit=5,$query='')
+ function
read_custom_fields($start=0,$limit=5,$query='',$sort='',$apply='both')
{
$i = 0;
$fields = array();
$this->config->read_repository();
- while(list($name,$descr) =
@each($this->config->config_data['custom_fields']))
+ if($apply=='person')
{
- /*
- if($start < $i)
+ $this->per_custom_fields =
$this->config->config_data['custom_fields'];
+ $all_custom_fields =
$this->config->config_data['custom_fields'];
+ }
+ elseif($apply=='org')
+ {
+ $this->org_custom_fields =
$this->config->config_data['custom_org_fields'];
+ $all_custom_fields =
$this->config->config_data['custom_org_fields'];
+ }
+ elseif($apply=='both')
+ {
+ $this->per_custom_fields =
$this->config->config_data['custom_fields'];
+ $this->org_custom_fields =
$this->config->config_data['custom_org_fields'];
+
+ if($this->per_custom_fields!='' &&
$this->org_custom_fields!='')
{
- continue;
+ $all_custom_fields =
array_merge($this->per_custom_fields,$this->org_custom_fields);
}
- */
-
+ elseif($this->per_custom_fields!='')
+ {
+ $all_custom_fields =
$this->per_custom_fields;
+ }
+ elseif($this->org_custom_fields!='')
+ {
+ $all_custom_fields =
$this->org_custom_fields;
+ }
+ }
+
+ //while(list($name,$descr) =
@each($this->config->config_data['custom_fields']))
+ while(list($name,$descr) = @each($all_custom_fields))
+ {
$test = @strtolower($name);
//if($query &&
!strstr($test,strtolower($query)))
if($query && ($query != $test))
@@ -376,6 +440,7 @@
$fields[$i]['name'] = $name;
$fields[$i]['title'] = $descr;
$fields[$i]['id'] = $i;
+ $fields[$i]['apply'] =
$this->get_apply($name);
/*
if($i >= $limit)
@@ -396,30 +461,137 @@
ksort($fields);
}
@reset($fields);
-
return $fields;
}
- function save_custom_field($old='',$new='')
+ function get_apply($key)
{
- $this->config->read_repository();
-
-
if(!is_array($this->config->config_data['custom_fields']))
+ if((is_array($this->per_custom_fields) &&
is_array($this->org_custom_fields)) &&
+ array_key_exists($key, $this->per_custom_fields) &&
array_key_exists($key, $this->org_custom_fields))
{
- $this->config->config_data['custom_fields'] =
array();
+ return 'both';
}
+ elseif(is_array($this->per_custom_fields) &&
array_key_exists($key, $this->per_custom_fields))
+ {
+ return 'person';
+ }
+ elseif(is_array($this->org_custom_fields) &&
array_key_exists($key, $this->org_custom_fields))
+ {
+ return 'org';
+ }
+ }
- if($old)
+ function save_custom_field($old='',$new='',$apply_for='')
+ {
+ $edit_contacts = False;
+ $this->config->read_repository();
+
+ switch($apply_for)
{
-
unset($this->config->config_data['custom_fields'][$old]);
+ case 'person':
+
if(!is_array($this->config->config_data['custom_fields']))
+ {
+
$this->config->config_data['custom_fields'] = array();
+ }
+
+ if($old)
+ {
+ $edit_contacts = True;
+ $old_field =
$this->config->config_data['custom_fields'][$old];
+ if(!$old_field)
+ {
+ $old_field =
$this->config->config_data['custom_org_fields'][$old];
+ }
+
unset($this->config->config_data['custom_fields'][$old]);
+
unset($this->config->config_data['custom_org_fields'][$old]);
+ }
+ if($new)
+ {
+ $tmp = strtolower(ereg_replace('
','_',$new));
+
$this->config->config_data['custom_fields'][$tmp] = $new;
+ }
+ break;
+ case 'org':
+
if(!is_array($this->config->config_data['custom_org_fields']))
+ {
+
$this->config->config_data['custom_org_fields'] = array();
+ }
+
+ if($old)
+ {
+ $edit_contacts = True;
+ $old_field =
$this->config->config_data['custom_fields'][$old];
+ if(!$old_field)
+ {
+ $old_field =
$this->config->config_data['custom_org_fields'][$old];
+ }
+
unset($this->config->config_data['custom_org_fields'][$old]);
+
unset($this->config->config_data['custom_fields'][$old]);
+ }
+ if($new)
+ {
+ $tmp = strtolower(ereg_replace('
','_',$new));
+
$this->config->config_data['custom_org_fields'][$tmp] = $new;
+ }
+ break;
+ default:
+ $old_field =
$this->config->config_data['custom_fields'][$old];
+ if(!$old_field)
+ {
+ $old_field =
$this->config->config_data['custom_org_fields'][$old];
+ }
+
+
if(!is_array($this->config->config_data['custom_fields']))
+ {
+
$this->config->config_data['custom_fields'] = array();
+ }
+
+ if($old)
+ {
+ $edit_contacts = True;
+
unset($this->config->config_data['custom_fields'][$old]);
+ }
+ if($new)
+ {
+ $tmp = strtolower(ereg_replace('
','_',$new));
+
$this->config->config_data['custom_fields'][$tmp] = $new;
+ }
+
if(!is_array($this->config->config_data['custom_org_fields']))
+ {
+
$this->config->config_data['custom_org_fields'] = array();
+ }
+
+ if($old)
+ {
+ $edit_contacts = True;
+
unset($this->config->config_data['custom_org_fields'][$old]);
+ }
+ if($new)
+ {
+ $tmp = strtolower(ereg_replace('
','_',$new));
+
$this->config->config_data['custom_org_fields'][$tmp] = $new;
+ }
+ break;
}
- if($new)
+
+ if(count($this->config->config_data['custom_fields'])
== 0)
{
- $tmp = strtolower(ereg_replace(' ','_',$new));
-
$this->config->config_data['custom_fields'][$tmp] = $new;
+ $this->config->config_data['custom_fields'] =
'';
}
+
if(count($this->config->config_data['custom_org_fields']) == 0)
+ {
+ $this->config->config_data['custom_org_fields']
= '';
+ }
+
$this->config->save_repository();
+
+ if($edit_contacts)
+ {
+ $contacts = CreateObject('phpgwapi.contacts');
+
$contacts->edit_other_by_owner($GLOBALS['phpgw_info']['server']['addressmaster'],
+ $new, $old_field,
'other_name');
+ }
}
}
?>
====================================================
Index: addressbook/inc/class.uivcard.inc.php
diff -u addressbook/inc/class.uivcard.inc.php:1.10
addressbook/inc/class.uivcard.inc.php:1.11
--- addressbook/inc/class.uivcard.inc.php:1.10 Sat Sep 28 20:01:43 2002
+++ addressbook/inc/class.uivcard.inc.php Fri Dec 31 04:55:24 2004
@@ -26,7 +26,7 @@
'out' => True
);
- var $extrafields = array(
+ var $extrafields = array(
'ophone' => 'ophone',
'address2' => 'address2',
'address3' => 'address3'
@@ -43,13 +43,14 @@
function in()
{
- $action = $GLOBALS['HTTP_POST_VARS']['action'];
+ $action = $_POST['action'] ? $_POST['action'] :
$_GET['action'];
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
- echo '<body bgcolor="' .
$GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
+// echo '<body bgcolor="' .
$GLOBALS['phpgw_info']['theme']['bg_color'] . '">';
- if($action == 'GetFile')
+ if ($action == 'GetFile')
{
echo '<b><center>' . lang('You must select a
vcard. (*.vcf)') . '</b></center><br><br>';
}
@@ -64,50 +65,116 @@
$this->template->set_var('group_option',$group_option);
$this->template->pparse('out','vcardin');
+
+ $GLOBALS['phpgw']->common->phpgw_footer();
}
function out()
{
- $ab_id = get_var('ab_id',array('GET','POST'));
- $nolname = get_var('nolname',array('GET','POST'));
- $nofname = get_var('nofname',array('GET','POST'));
+ $ab_id = $GLOBALS['HTTP_GET_VARS']['ab_id'] ?
$GLOBALS['HTTP_GET_VARS']['ab_id'] : $GLOBALS['HTTP_POST_VARS']['ab_id'];
+ $nolname = $GLOBALS['HTTP_GET_VARS']['nolname'];
+ $nofname = $GLOBALS['HTTP_GET_VARS']['nofname'];
if($nolname || $nofname)
{
$GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
}
if(!$ab_id)
{
Header('Location: ' .
$GLOBALS['phpgw']->link('/addressbook/index.php'));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
- // First, make sure they have permission to this entry
- $check = $this->bo->read_entry(array(
- 'id' => $ab_id,
- 'fields' => array(
- 'owner' => 'owner'
- )
- ));
- $perms =
$this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_READ);
-
- if((!$perms) && ($check[0]['owner'] !=
$GLOBALS['phpgw_info']['user']['account_id']))
+ if(!$this->contacts->check_edit($ab_id))
{
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.get_list'));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ Header("Location: " .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
+
+ // First, make sure they have permission to this entry
+ $fieldlist =
$this->contacts->person_complete_data($ab_id);
+ $type_work =
$this->contacts->search_location_type('work');
+ $type_home =
$this->contacts->search_location_type('home');
+ /*
+ $fields['full_name'] =
$fieldlist['full_name'];
+ bug: $fieldlist['full_name'] contains two spaces between first and last
name, when middle name is empty
+ workaround: calculate the fullname like shown below
+ */
+ $fields['first_name'] =
$fieldlist['first_name'];
+ $fields['last_name'] =
$fieldlist['last_name'];
+ $fields['middle_name'] =
$fieldlist['middle_name'];
+
+ $fields['full_name'] = $fields['first_name']
. ' ';
+ $fields['full_name'] .=
($fields['middle_name'] != '') ? $fields['middle_name'] . ' ' : '';
+ $fields['full_name'] .= $fields['last_name'];
+
+ $fields['prefix'] = $fieldlist['prefix'];
+ $fields['suffix'] = $fieldlist['suffix'];
+ $fields['sound'] = $fieldlist['sound'];
+ $fields['birthday'] =
$fieldlist['birthday'];
+ //$fields['note'] = $fieldlist[''];
+ //$fields['tz'] =
$fieldlist['locations'][$type_work][''];
+ //$fields['geo'] = $fieldlist[''];
+ $fields['pubkey'] = $fieldlist['pubkey'];
+ $fields['org_name'] =
$fieldlist['org_name'];
+ $fields['org_unit'] =
$fieldlist['department'];
+ $fields['title'] = $fieldlist['title'];
+ $fields['adr_one_type'] = 'WORK';
+ $fields['adr_two_type'] = 'HOME';
+ //$fields['tel_prefer'] = $fieldlist[''];
+ $fields['email_type'] = 'INTERNET';
+ $fields['email_home_type'] = 'INTERNET';
+
+ // locations contains a list of loc_id and its date
+ if (isset($fieldlist['locations']) &&
is_array($fieldlist['locations']))
+ {
+ // locations[loc_id][type] is work or home
+ // loc_id is not interested here, but the type
is important!
+ while ( list($loc_id, $loc_data) =
each($fieldlist['locations']) )
+ {
+ $loc_type_id =
$this->contacts->search_location_type($loc_data['type']);
+ switch($loc_type_id)
+ {
+ case $type_work:
+ $adr = 'adr_one_';
+ break;
+ case $type_home:
+ $adr = 'adr_two_';
+ break;
+ default:
+ continue;
+ break;
+ }
+ $fields[$adr.'street'] =
$loc_data['add1'];
+ $fields[$adr.'ext'] =
$loc_data['add2'];
+ $fields[$adr.'locality'] =
$loc_data['city'];
+ $fields[$adr.'region'] =
$loc_data['state'];
+ $fields[$adr.'postalcode'] =
$loc_data['postal_code'];
+ $fields[$adr.'countryname'] =
$loc_data['country'];
+ }
+ }
+
+ $fields['tel_work'] =
$fieldlist['comm_media']['work phone'];
+ $fields['tel_home'] =
$fieldlist['comm_media']['home phone'];
+ $fields['tel_voice'] =
$fieldlist['comm_media']['voice phone'];
+ $fields['tel_work_fax'] =
$fieldlist['comm_media']['work fax'];
+ $fields['tel_home_fax'] =
$fieldlist['comm_media']['home fax'];
+ $fields['tel_msg'] =
$fieldlist['comm_media']['msg phone'];
+ $fields['tel_cell'] =
$fieldlist['comm_media']['mobile (cell) phone'];
+ $fields['tel_pager'] =
$fieldlist['comm_media']['pager'];
+ $fields['tel_bbs'] =
$fieldlist['comm_media']['bbs'];
+ $fields['tel_modem'] =
$fieldlist['comm_media']['modem'];
+ $fields['tel_car'] =
$fieldlist['comm_media']['car phone'];
+ $fields['tel_isdn'] =
$fieldlist['comm_media']['isdn'];
+ $fields['tel_video'] =
$fieldlist['comm_media']['video'];
+ $fields['email'] =
$fieldlist['comm_media']['work email'];
+ $fields['email_home'] =
$fieldlist['comm_media']['home email'];
+ $fields['url'] =
$fieldlist['comm_media']['website'];
- $extrafields = array('address2' => 'address2');
- $qfields = $this->contacts->stock_contact_fields +
$extrafields;
-
- $fieldlist = $this->bo->read_entry(array('id' =>
$ab_id, 'fields' => $qfields));
- $fields = $fieldlist[0];
-
- $email = $fields['email'];
- $emailtype = $fields['email_type'];
+ $email = $fields['email'];
+ $emailtype = $fields['email_type'];
if (!$emailtype)
{
$fields['email_type'] = 'INTERNET';
@@ -118,8 +185,8 @@
{
$fields['email_home_type'] = 'INTERNET';
}
- $firstname = $fields['n_given'];
- $lastname = $fields['n_family'];
+ $firstname = $fields['first_name'];
+ $lastname = $fields['last_name'];
if(!$nolname && !$nofname)
{
@@ -127,49 +194,52 @@
if($lastname == '')
{
/* Run away here. */
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.out&nolname=1&ab_id='
. $ab_id));
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uivcard.out&nolname=1&ab_id=$ab_id"));
}
if($firstname == '')
{
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.out&nofname=1&ab_id='
. $ab_id));
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uivcard.out&nofname=1&ab_id=$ab_id"));
}
if ($email)
{
$fn = explode('@',$email);
- $filename = sprintf('%s.vcf', $fn[0]);
+ $filename = sprintf("%s.vcf", $fn[0]);
}
elseif ($hemail)
{
$fn = explode('@',$hemail);
- $filename = sprintf('%s.vcf', $fn[0]);
+ $filename = sprintf("%s.vcf", $fn[0]);
}
else
{
$fn = strtolower($firstname);
- $filename = sprintf('%s.vcf', $fn);
+ $filename = sprintf("%s.vcf", $fn);
}
// set translation variable
$myexport = $this->vcard->export;
// check that each $fields exists in the export
array and
// set a new array to equal the translation and
original value
- while(list($name,$value) = each($fields))
+ while( list($name,$value) = each($fields) )
{
- if($myexport[$name] && ($value != ''))
+ if ($myexport[$name] && ($value != "") )
{
- //echo
'<br>'.$name.'='.$fields[$name]."\n";
+ //echo
'<br>'.$name."=".$fields[$name]."\n";
$buffer[$myexport[$name]] =
$value;
}
}
// create a vcard from this translated array
$entry = $this->vcard->out($buffer);
+
// print it using browser class for headers
// filename, mimetype, no length, default
nocache True
$this->browser->content_header($filename,'text/x-vcard');
echo $entry;
- $GLOBALS['phpgw']->common->exit;
+ sleep(1);
+ exit;
+ //$GLOBALS['phpgw']->common->exit;
} /* !nolname && !nofname */
if($nofname)
@@ -177,7 +247,8 @@
echo '<br><br><center>';
echo lang("This person's first name was not in
the address book.") .'<br>';
echo lang('Vcards require a first name entry.')
. '<br><br>';
- echo '<a href="' .
$GLOBALS['phpgw']->link('/addressbook/index.php') . '">' . lang('OK') . '</a>';
+ echo '<a href="' .
$GLOBALS['phpgw']->link('/addressbook/index.php',
+
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id")
. '">' . lang('OK') . '</a>';
echo '</center>';
}
@@ -186,9 +257,15 @@
echo '<br><br><center>';
echo lang("This person's last name was not in
the address book.") . '<br>';
echo lang('Vcards require a last name entry.')
. '<br><br>';
- echo '<a href="' .
$GLOBALS['phpgw']->link('/addressbook/index.php') . '">' . lang('OK') . '</a>';
+ echo '<a href="' .
$GLOBALS['phpgw']->link('/addressbook/index.php',
+
"order=$order&start=$start&filter=$filter&query=$query&sort=$sort&cat_id=$cat_id")
. '">' . lang('OK') . '</a>';
echo '</center>';
}
+
+ if($nolname || $nofname)
+ {
+ //$GLOBALS['phpgw']->common->phpgw_footer();
+ }
}
}
?>
====================================================
Index: addressbook/inc/class.soaddressbook.inc.php
diff -u addressbook/inc/class.soaddressbook.inc.php:1.16
addressbook/inc/class.soaddressbook.inc.php:1.17
--- addressbook/inc/class.soaddressbook.inc.php:1.16 Mon May 13 00:43:35 2002
+++ addressbook/inc/class.soaddressbook.inc.php Fri Dec 31 04:55:22 2004
@@ -1,159 +1,1051 @@
<?php
/**************************************************************************\
- * phpGroupWare - addressbook *
+ * phpGroupWare - soaddressbook *
* http://www.phpgroupware.org *
- * Written by Joseph Engo <address@hidden> *
+ * This program is part of the GNU project, see http://www.gnu.org/ *
+ * *
+ * Copyright 2003 Free Software Foundation, Inc. *
+ * *
+ * Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
+ * Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* -------------------------------------------- *
- * This program is free software; you can redistribute it and/or modify it *
+ * Development of this application was funded by http://www.sogrp.com *
+ * -------------------------------------------- *
+ * This program is Free Software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
- /* $Id$ */
+/* $Id$ */
class soaddressbook
{
- var $contacts;
- var $rights;
- var $grants;
- var $owner;
-
- function soaddressbook()
+ function soaddressbook($useacl=True)
{
+ $this->contacts = CreateObject('phpgwapi.contacts');
+
+ if($useacl)
+ {
+ $this->grants =
$GLOBALS['phpgw']->acl->get_grants('addressbook');
+ }
+
if(!isset($GLOBALS['owner']))
{
$GLOBALS['owner'] = 0;
}
- $owner = $GLOBALS['owner'];
- $this->contacts = CreateObject('phpgwapi.contacts');
- $grants = $this->contacts->grants;
- /* _debug_array($GLOBALS['phpgw_info']); */
- /* _debug_array($grants); */
-
- if(!isset($owner) || !$owner)
- {
- $owner =
$GLOBALS['phpgw_info']['user']['account_id'];
- /* echo $owner; */
- $rights = PHPGW_ACL_READ + PHPGW_ACL_ADD +
PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
+ $this->owner = $GLOBALS['owner'];
+
+ if(!isset($this->owner) || !$this->owner)
+ {
+ $this->owner =
$GLOBALS['phpgw_info']['user']['account_id'];
+ /* echo $this->owner; */
+ $this->rights = PHPGW_ACL_READ + PHPGW_ACL_ADD
+ PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
/* echo $rights; */
}
else
{
- if($grants[$owner])
+ if($this->grants[$this->owner])
{
- $rights = $grants[$owner];
- if (!($rights & PHPGW_ACL_READ))
+ $this->rights =
$this->grants[$this->owner];
+ if (!($this->rights & PHPGW_ACL_READ))
{
- $owner =
$GLOBALS['phpgw_info']['user']['account_id'];
- $rights = PHPGW_ACL_READ +
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
+ $this->owner =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->rights = PHPGW_ACL_READ
+ PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE + 16;
}
}
}
- $this->rights = $rights;
- $this->grants = $grants;
- $this->owner = $owner;
+
+ $this->contact_type = $this->contacts->contact_type;
+ $this->comm_descr = $this->contacts->comm_descr;
+ $this->comm_type = $this->contacts->comm_type;
+ $this->addr_type = $this->contacts->addr_type;
+ $this->tab_main_persons =
$this->contacts->get_person_name();
+ $this->tab_main_organizations =
$this->contacts->get_org_name();
+ }
+
+ /*************************************************************\
+ * Retrieve functions section *
+ \*************************************************************/
+
+ /**
+ * This function call to get_persons from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_persons($fields, $start='', $limit='',
$orderby='', $sort='', $criteria='', $token_criteria='')
+ {
+ return $this->contacts->get_persons($fields, $start,
$limit, $orderby, $sort, $criteria, $token_criteria);
+ }
+
+ /**
+ * This function call to get_principal_persons_data from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_principal_persons_data($id, $get_org=True)
+ {
+ return $this->contacts->get_principal_persons_data($id,
PHPGW_SQL_RUN_SQL, $get_org);
+ }
+
+ /**
+ * This function call to get_organizations_by_person from
contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_organizations_by_person($person_id, $criteria='')
+ {
+ return
$this->contacts->get_organizations_by_person($person_id, $criteria);
+ }
+
+ /**
+ * This function call to get_orgs from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_orgs($fields, $start='', $limit='', $orderby='',
$sort='', $criteria='', $token_criteria='')
+ {
+ return $this->contacts->get_orgs($fields, $start,
$limit, $orderby, $sort, $criteria, $token_criteria);
+ }
+
+ /**
+ * This function call to get_principal_organizations_data from
contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_principal_organizations_data($id)
+ {
+ return
$this->contacts->get_principal_organizations_data($id);
+ }
+
+ /**
+ * This function call to get_people_by_organizations from
contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_people_by_organizations($id, $criteria='')
+ {
+ return
$this->contacts->get_people_by_organizations($id, $criteria);
+ }
+
+ /**
+ * This function call to get_comm_contact_data from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_comm_contact_data($contacts, $fields_comms='')
+ {
+ return
$this->contacts->get_comm_contact_data($contacts, $fields_comms);
+ }
+
+ /**
+ * This function call to get_addr_contact_data from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_addr_contact_data($contact_id, $criteria='')
+ {
+ return
$this->contacts->get_addr_contact_data($contact_id, $criteria);
+ }
+
+ /**
+ * This function call to get_others_contact_data from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_others_contact_data($id, $criteria='')
+ {
+ return $this->contacts->get_others_contact_data($id,
$criteria);
+ }
+
+ /**
+ * This function call to get_contact_addr_type from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_addr_type()
+ {
+ return $this->contacts->get_contact_addr_type();
+ }
+
+ /**
+ * This function call to get_contact_comm_descr from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_comm_descr()
+ {
+ return $this->contacts->get_contact_comm_descr();
}
- function read_entries($data)
+ /**
+ * This function call to get_contact_comm_type from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function get_comm_type()
{
- return $this->contacts->read(
- $data['start'],
- $data['limit'],
- $data['fields'],
- $data['query'],
- $data['filter'],
- $data['sort'],
- $data['order'],
- $data['cquery']
- );
+ return $this->contacts->get_contact_comm_type();
}
- function read_entry($id,$fields)
+ /**
+ * This function call to get_count_persons from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_count_persons($criteria='')
{
- if($this->rights & PHPGW_ACL_READ)
+ return $this->contacts->get_count_persons($criteria);
+ }
+
+ /**
+ * This function call to get_count_orgs from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_count_orgs($criteria='')
+ {
+ return $this->contacts->get_count_orgs($criteria);
+ }
+
+ /**
+ * This function call to get_persons_by_cat from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_persons_by_cat($cats)
+ {
+ return $this->contacts->get_persons_by_cat($cats);
+ }
+
+ /**
+ * This function call to get_email from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_email($id)
+ {
+ return $this->contacts->get_email($id);
+ }
+
+ /**
+ * This function call to get_phone from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_phone($id)
+ {
+ return $this->contacts->get_phone($id);
+ }
+
+ /**
+ * This function call to get_sub_cats from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_sub_cats($cat_to_find)
+ {
+ return $this->contacts->get_sub_cats($cat_to_find);
+ }
+
+ /*************************************************************\
+ * Search in catalogs functions section *
+ \*************************************************************/
+
+ /**
+ * This function call to search_location_type_id from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function search_location_type_id($id)
+ {
+ return $this->contacts->search_location_type_id($id);
+ }
+
+ /**
+ * This function call to search_location_type from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_location_type($description)
+ {
+ return
$this->contacts->search_location_type($description);
+ }
+
+ /**
+ * This function call to search_note_type_id from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_note_type_id($id)
+ {
+ return $this->contacts->search_note_type_id($id);
+ }
+
+ /**
+ * This function call to search_note_type from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_note_type($description)
+ {
+ return $this->contacts->search_note_type($description);
+ }
+
+ /**
+ * This function call to search_comm_type_id from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_comm_type_id($id)
+ {
+ return $this->contacts->search_comm_type_id($id);
+ }
+
+ /**
+ * This function call to search_comm_type from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_comm_type($description)
+ {
+ return $this->contacts->search_comm_type($description);
+ }
+
+ /**
+ * This function call to search_comm_descr_id from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_comm_descr_id($id)
+ {
+ return $this->contacts->search_comm_descr_id($id);
+ }
+
+ /**
+ * This function call to search_comm_descr from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_comm_descr($description)
+ {
+ return $this->contacts->search_comm_descr($description);
+ }
+
+ /**
+ * This function call to search_contact_type_id from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function search_contact_type_id($id)
+ {
+ return $this->contacts->search_contact_type_id($id);
+ }
+
+ /**
+ * This function call to search_contact_type from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function search_contact_type($description)
+ {
+ return
$this->contacts->search_contact_type($description);
+ }
+
+ /*************************************************************\
+ * Edit contact section *
+ \*************************************************************/
+
+ function edit_person($person_id, $fields)
+ {
+ $principal['owner'] = $fields['owner'];
+ $principal['access'] =
$fields['tab_person_data']['ispublic'];
+ $preferred_force_addr =
$fields['tab_address']['addr_preferred'];
+
+ if(is_array($fields['tab_cats']['my_cats']))
{
- return
$this->contacts->read_single_entry($id,$fields);
+ foreach($fields['tab_cats']['my_cats'] as $cat)
+ {
+ if($cat)
+ {
+ $cats[] = $cat;
+ }
+ }
}
else
{
- $rtrn = array(0 => array('No access' => 'No
access'));
- return $rtrn;
+ $cats = '';
}
- }
+
+ $principal['cat_id'] = $cats;
+ $person = array_merge($fields['tab_person_data'],
$fields['tab_extra']);
+ $orgs = $fields['edit_orgs'];
+ $orgs['preferred_org'] =
$fields['tab_orgs']['preferred_org'];
+ $queries = $fields['transactions'];
- function read_last_entry($fields)
+ //unset($fields['tab_person_data']);
+ unset($fields['tab_extra']);
+ unset($fields['tab_orgs']);
+ unset($fields['edit_orgs']);
+ unset($fields['tab_cats']);
+ unset($fields['old_my_orgs']);
+ unset($fields['tab_address']);
+ unset($fields['addr_data']);
+ unset($fields['transactions']);
+ //unset($fields['tab_comms']);
+ unset($fields['old_comm']);
+
+ $this->contacts->edit_contact($person_id, $principal,
PHPGW_SQL_RUN_SQL);
+ $this->contacts->edit_person($person_id, $person,
PHPGW_SQL_RUN_SQL);
+ foreach($orgs['delete'] as $org_id)
+ {
+
$this->contacts->delete_org_person_relation($org_id, $person_id,
PHPGW_SQL_RUN_SQL);
+ }
+
+ if($orgs['preferred_org'])
+ {
+ $fields['preferred_address'] =
$this->contacts->get_location_pref_org($orgs['preferred_org']);
+ }
+
+ if(count($orgs['insert'])>0)
+ {
+
$this->contacts->add_orgs_for_person($orgs['insert'],
+
$orgs['preferred_org'],
+
$fields['preferred_address'],
+
$person_id, PHPGW_SQL_RUN_SQL);
+ }
+ else
+ {
+ $data = array('my_preferred' => 'N');
+ $this->contacts->edit_org_person_relation('',
$person_id, $data, PHPGW_SQL_RUN_SQL);
+ $data = array('my_preferred' => 'Y',
+ 'my_addr_id' =>
$fields['preferred_address']);
+
$this->contacts->edit_org_person_relation($orgs['preferred_org'], $person_id,
$data, PHPGW_SQL_RUN_SQL);
+ }
+
+ $comm_preferred = $fields['tab_comms']['preferred'];
+
+ $this->upgrade_comms($fields['edit_comms']['insert'],
+ $fields['edit_comms']['delete'],
+ $fields['edit_comms']['edit'],
+ $fields['comm_data'],
$comm_preferred, $person_id);
+
+ $this->upgrade_others($fields['edit_others']['insert'],
+ $fields['edit_others']['delete'],
+ $fields['edit_others']['edit'],
+
$fields['tab_others']['other_value'], $person_id);
+
+ $this->execute_queries($queries);
+
+ if($preferred_force_addr && $preferred_force_addr!='')
+ {
+ $preferred_force_addr =
$this->get_preferred_location($person_id, $preferred_force_addr);
+
+ $this->contacts->edit_location_by_contact(
+ $person_id,
+ array('addr_preferred' => 'N'),
+ PHPGW_SQL_RUN_SQL);
+
+ $this->contacts->edit_location(
+ $preferred_force_addr,
+ array('addr_preferred' => 'Y'),
+ PHPGW_SQL_RUN_SQL);
+ }
+
+ /* Update the first and last name in accounts */
+ $account_id =
$this->contacts->get_account_id($person_id);
+ if($account_id)
+ {
+ $account =
CreateObject('phpgwapi.accounts',$account_id,'u');
+ $account_data = $account->read_repository();
+ $account_data['account_firstname'] =
$fields['tab_person_data']['per_first_name'];
+ $account_data['account_lastname'] =
$fields['tab_person_data']['per_last_name'];
+ $account->update_data($account_data);
+ $account->save_repository();
+ }
+
+ $this->contacts->finalize_edit($person_id);
+ }
+
+ function edit_org($org_id, $fields)
{
- if($this->rights & PHPGW_ACL_READ)
+ $principal['owner'] = $fields['owner'];
+ $principal['access'] =
$fields['tab_org_data']['ispublic'];
+ $preferred_force_addr =
$fields['tab_address']['addr_preferred'];
+
+ if(is_array($fields['tab_cats']['my_cats']))
{
- return
$this->contacts->read_last_entry($fields);
+ foreach($fields['tab_cats']['my_cats'] as $cat)
+ {
+ if($cat)
+ {
+ $cats[] = $cat;
+ }
+ }
}
else
{
- $rtrn = array(0 => array('No access' => 'No
access'));
- return $rtrn;
+ $cats = '';
+ }
+
+ $principal['cat_id'] = $cats;
+ $org = $fields['tab_org_data'];
+ $persons = $fields['edit_persons'];
+ $queries = $fields['transactions'];
+
+ $this->contacts->edit_contact($org_id, $principal,
PHPGW_SQL_RUN_SQL);
+ $this->contacts->edit_org($org_id, $org,
PHPGW_SQL_RUN_SQL);
+ foreach($persons['delete'] as $person_id)
+ {
+
$this->contacts->delete_org_person_relation($org_id, $person_id,
PHPGW_SQL_RUN_SQL);
}
+
+
$this->contacts->add_people_for_organzation($persons['insert'], $org_id,
PHPGW_SQL_RUN_SQL);
+
+ $this->upgrade_comms($fields['edit_comms']['insert'],
+ $fields['edit_comms']['delete'],
+ $fields['edit_comms']['edit'],
+ $fields['comm_data'], '', $org_id);
+
+ $this->upgrade_others($fields['edit_others']['insert'],
+ $fields['edit_others']['delete'],
+ $fields['edit_others']['edit'],
+
$fields['tab_others']['other_value'], $org_id);
+
+ $this->execute_queries($queries);
+
+ if($preferred_force_addr && $preferred_force_addr!='')
+ {
+ $preferred_force_addr =
$this->get_preferred_location($org_id, $preferred_force_addr);
+
+ $this->contacts->edit_location_by_contact(
+ $org_id,
+ array('addr_preferred' => 'N'),
+ PHPGW_SQL_RUN_SQL);
+
+ $this->contacts->edit_location(
+ $preferred_force_addr,
+ array('addr_preferred' => 'Y'),
+ PHPGW_SQL_RUN_SQL);
+ }
+ }
+
+ function get_preferred_location($contact_id, $preferred_forced)
+ {
+ $addr_tmp =
$this->contacts->get_addr_contact_data($contact_id);
+ if(is_array($addr_tmp))
+ {
+ foreach($addr_tmp as $data)
+ {
+
if($preferred_forced==$data['key_addr_id'])
+ {
+ return $preferred_forced;
+ }
+ else
+ {
+
$locations[$data['key_addr_id']] = $data;
+ }
+ }
+ }
+ ksort($locations);
+ end($locations);
+ return key($locations);
+ }
+
+ /**
+ * This function call to edit_location from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function edit_location($contact_id, $fields)
+ {
+ return $this->contacts->edit_location($contact_id,
$fields);
+ }
+
+ /**
+ * This function call to edit_comms from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function edit_comms($comm_id, $fields,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->edit_comms($comm_id, $fields,
$action);
}
- function add_entry($fields)
+ /**
+ * This function call to edit_other from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function edit_other($contact_id, $fields,
$action=PHPGW_SQL_RETURN_SQL)
{
- $fields['tid'] = trim($fields['tid']);
- if(empty($fields['tid']))
+ return $this->contacts->edit_other($contact_id,
$fields, $action);
+ }
+
+ /**
+ * This function call to edit_comms_by_contact from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function edit_comms_by_contact($id, $data,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->edit_comms_by_contact($id,
$data, $action);
+ }
+
+ /*************************************************************\
+ * Add contact section *
+ \*************************************************************/
+
+ //used
+ function add_person($fields)
+ {
+ $principal = array_merge($fields['tab_person_data'],
$fields['tab_extra']);
+
+ if(!is_array($fields['tab_comms']['comm_data']))
+ {
+ $fields['tab_comms']['comm_data']=array();
+ }
+
+ foreach($fields['tab_comms']['comm_data'] as
$type_descr => $data)
{
- $fields['tid'] = 'n';
+ if($data)
+ {
+ $comms[] = array('comm_descr'
=> $this->contacts->search_comm_descr($type_descr),
+ 'comm_data'
=> $data,
+ 'comm_preferred'
=> ($type_descr==$fields['tab_comms']['preferred']?'Y':'N'));
+ }
}
- if($this->rights & PHPGW_ACL_ADD)
+
+ if(is_array($fields['addr_data']))
{
- $ab_id = $fields['ab_id'];
- $owner = $fields['owner'];
- $access = $fields['access'];
- $cat_id = $fields['cat_id'];
- $tid = $fields['tid'];
- unset($fields['owner']);
- unset($fields['access']);
- unset($fields['cat_id']);
- unset($fields['ab_id']);
- unset($fields['tid']);
+
$fields['addr_data'][$fields['tab_address']['addr_preferred']]['addr_preferred']='Y';
+ $addr = $fields['addr_data'];
+ }
- $id =
$this->contacts->add($owner,$fields,$access,$cat_id,$tid);
+ if(is_array($fields['others_data']))
+ {
+ foreach($fields['others_data'] as $key => $data)
+ {
+
$fields['others_data'][$key]['other_value'] =
$fields['tab_others']['other_value'][$key];
+ }
}
- return $id;
+ $others = $fields['others_data'];
+
+ $orgs = $fields['tab_orgs']['my_orgs'];
+ $principal['preferred_org'] =
$fields['tab_orgs']['preferred_org'];
+ if($fields['tab_orgs']['preferred_org'])
+ {
+ $principal['preferred_address'] =
$this->contacts->get_location_pref_org($principal['preferred_org']);
+ }
+
+ $cats = $fields['tab_cats']['my_cats'];
+
+ $type =
$this->contacts->search_contact_type($this->contacts->get_person_name());
+ $c_id = $this->contacts->add_contact($type, $principal,
$comms, $addr, $cats, $others, $orgs);
+
+ return $c_id;
}
- function get_lastid()
+ //used
+ function add_org($fields)
{
- $entry = $this->contacts->read_last_entry();
- $id = $entry[0]['id'];
- return $id;
+ $principal = $fields['tab_org_data'];
+
+ if(!is_array($fields['tab_comms']['comm_data']))
+ {
+ $fields['tab_comms']['comm_data']=array();
+ }
+
+ foreach($fields['tab_comms']['comm_data'] as
$type_descr => $data)
+ {
+ if($data)
+ {
+ $comms[] = array('comm_descr'
=> $this->contacts->search_comm_descr($type_descr),
+ 'comm_data'
=> $data,
+ 'comm_preferred'
=> ($type_descr==$fields['tab_comms']['preferred']?'Y':'N'));
+ }
+ }
+
+ if(is_array($fields['addr_data']))
+ {
+
$fields['addr_data'][$fields['tab_address']['addr_preferred']]['addr_preferred']='Y';
+ $addr = $fields['addr_data'];
+ }
+
+ if(is_array($fields['others_data']))
+ {
+ foreach($fields['others_data'] as $key => $data)
+ {
+
$fields['others_data'][$key]['other_value'] =
$fields['tab_others']['other_value'][$key];
+ }
+ }
+ $others = $fields['others_data'];
+
+ $persons = $fields['tab_persons']['my_person'];
+
+ $cats = $fields['tab_cats']['my_cats'];
+
+ $type =
$this->contacts->search_contact_type($this->contacts->get_org_name());
+ $c_id = $this->contacts->add_contact($type, $principal,
$comms, $addr, $cats, $others, $persons);
+ return $c_id;
+ }
+
+ /**
+ * This function call to add_others from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function add_others($fields, $contact_id,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->add_others($fields,
$contact_id, $action);
+ }
+
+ /**
+ * This function call to add_communication_media from contact
object
+ * See the documentation in contact objet
+ *
+ */
+ function add_communication_media($fields, $contact_id,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return
$this->contacts->add_communication_media($fields, $contact_id, $action);
+ }
+
+ /**
+ * This function call to add_location from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function add_location($fields, $contact_id)
+ {
+ return $this->contacts->add_location($fields,
$contact_id);
+ }
+
+ function add_contact_with_email($name, $email)
+ {
+ $named = explode(' ', $name);
+ for ($i=count($named);$i>=0;$i--)
+ {
+ $names[$i] = $named[$i];
+ }
+ if ($names[2])
+ {
+ $principal['per_first_name'] = $names[0];
+ $principal['per_middle_name'] = $names[1];
+ $principal['per_last_name'] = $names[2];
+ }
+ else
+ {
+ $principal['per_first_name'] = $names[0];
+ $principal['per_last_name'] = $names[1];
+ }
+
+ $principal['access'] = 'private';
+ $principal['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $comms[] = array('comm_descr' =>
$this->search_comm_descr('work email'),
+ 'comm_data' => $email,
+ 'comm_preferred' => 'Y');
+
+ $type =
$this->contacts->search_contact_type($this->contacts->get_person_name());
+ $c_id = $this->contacts->add_contact($type, $principal,
$comms);
+
+ return $c_id;
+ }
+
+
+ /*************************************************************\
+ * Delete contact section *
+ \*************************************************************/
+
+ /**
+ * This function call to delete from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function delete($contact_id, $contact_type)
+ {
+ return $this->contacts->delete($contact_id,
$contact_type);
+ }
+
+ /**
+ * Delete the specified communication media.
+ *
+ * @param integer|array $id Key of the comm media what you want
+ */
+ function delete_specified_comm($id,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->delete_specified_comm($id,
$action);
+ }
+
+ /**
+ * Delete the specified address.
+ *
+ * @param integer|array $id Key of the address what you want
+ */
+ function delete_specified_location($id,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->delete_specified_location($id,
$action);
+ }
+ /**
+ * Delete the specified others field.
+ *
+ * @param integer|array $id Key of the other field what you want
+ */
+ function delete_specified_other($id,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->delete_specified_other($id,
$action);
+ }
+
+ /**
+ * Delete the specified note.
+ *
+ * @param integer|array $id Key of the note what you want
+ */
+ function delete_specified_note($id,
$action=PHPGW_SQL_RETURN_SQL)
+ {
+ return $this->contacts->delete_specified_note($id,
$action);
+ }
+
+ /*************************************************************\
+ * Misc functions section *
+ \*************************************************************/
+
+ function upgrade_comms($add_comms=array(), $del_comms=array(),
$edit_comms=array(), $data=array(), $comm_preferred='', $contact_id='')
+ {
+ if(!is_array($add_comms))
+ {
+ $add_comms = array();
+ }
+ if(!is_array($del_comms))
+ {
+ $del_comms = array();
+ }
+ if(!is_array($edit_comms))
+ {
+ $edit_comms = array();
+ }
+
+ if(!is_array($data))
+ {
+ $data = array();
+ }
+
+ $this->edit_comms_by_contact($contact_id,
array('comm_preferred'=>'N'), PHPGW_SQL_RUN_SQL);
+ foreach($data as $key => $value)
+ {
+ if(array_key_exists($value['comm_description'],
$del_comms))
+ {
+
$this->delete_specified_comm($value['key_comm_id'], PHPGW_SQL_RUN_SQL);
+ }
+
+ if(array_key_exists($value['comm_description'],
$edit_comms))
+ {
+ if($comm_preferred ==
$value['comm_description'])
+ {
+ $preferred = 'Y';
+ }
+ else
+ {
+ $preferred = 'N';
+ }
+
+ $this->edit_comms($value['key_comm_id'],
+ array('comm_data' =>
$edit_comms[$value['comm_description']],
+
'comm_preferred' => $preferred),
+ PHPGW_SQL_RUN_SQL);
+ }
+ }
+
+ foreach($add_comms as $key => $value)
+ {
+ if($comm_preferred == $key)
+ {
+ $pref = 'Y';
+ }
+ else
+ {
+ $pref = 'N';
+ }
+
+ $fields = array('comm_descr' =>
$this->search_comm_descr($key),
+ 'comm_data' => $value,
+ 'comm_preferred' => $pref);
+
+ $this->add_communication_media($fields,
$contact_id, PHPGW_SQL_RUN_SQL);
+ }
+ $this->unlock();
}
- function update_entry($fields)
+ function upgrade_others($add_others=array(),
$del_others=array(), $edit_others=array(), $data=array(), $contact_id)
{
- if($this->rights & PHPGW_ACL_EDIT)
+ if(!is_array($data))
+ {
+ $data = array();
+ }
+ if(!is_array($edit_others))
{
- $ab_id = $fields['ab_id'];
- $owner = $fields['owner'];
- $access = $fields['access'];
- $cat_id = $fields['cat_id'];
- unset($fields['owner']);
- unset($fields['access']);
- unset($fields['cat_id']);
- unset($fields['ab_id']);
- unset($fields['tid']);
+ $edit_others = array();
+ }
+ if(!is_array($add_others))
+ {
+ $add_others = array();
+ }
+ foreach($data as $key => $value)
+ {
+ if(array_key_exists($key, $edit_others))
+ {
+ $this->edit_other($key,
+ array('other_value'
=> $value),
+ PHPGW_SQL_RUN_SQL);
+ }
+ }
-
$this->contacts->update($ab_id,$owner,$fields,$access,$cat_id);
+ foreach($add_others as $key => $fields)
+ {
+ $fields['other_value'] = $data[$key];
+ $this->add_others($fields, $contact_id,
PHPGW_SQL_RUN_SQL);
}
- return;
+
+ $this->unlock();
}
- function delete_entry($data)
+ /**
+ * Criteria for index primordially
+ *
+ * return string criteria for search.
+ */
+ function criteria_contacts($user, $access, $category, $fields,
$pattern, $show_fields)
{
- if($this->rights & PHPGW_ACL_DELETE)
+ return $this->contacts->criteria_for_index($user,
$access, $category, $fields, $pattern, $show_fields);
+ }
+
+ /**
+ * This function call to get_type_contact from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function get_type_contact($contact_id)
+ {
+ return $this->contacts->get_type_contact($contact_id);
+ }
+
+ /**
+ * This function call to copy_contact from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function copy_contact($contact_id)
+ {
+ return $this->contacts->copy_contact($contact_id);
+ }
+
+ /**
+ * This function call to contact_import from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function contact_import($entry)
+ {
+ return $this->contacts->contact_import($entry);
+ }
+
+ /**
+ * This function call to display_name from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function display_name($column)
+ {
+ return $this->contacts->display_name($column);
+ }
+
+ /**
+ * This function call to execute_queries from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function execute_queries($queries)
+ {
+ return $this->contacts->execute_queries($queries);
+ }
+
+ /**
+ * This function call to unlock_table from contact object
+ * See the documentation in contact objet
+ *
+ */
+ function unlock()
+ {
+ $this->contacts->unlock_table();
+ }
+
+ /*************************************************************\
+ * Check ACL contact section *
+ \*************************************************************/
+
+ /**
+ * Check if the contact has add permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_add($contact_id, $owner_id='')
+ {
+ return $this->contacts->check_add($contact_id,
$owner_id);
+ }
+
+ /**
+ * Check if the contact has edit permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_edit($contact_id, $owner_id='')
+ {
+ return $this->contacts->check_edit($contact_id,
$owner_id);
+ }
+
+ /**
+ * Check if the contact has read permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_read($contact_id, $owner_id='')
+ {
+ return $this->contacts->check_read($contact_id,
$owner_id);
+ }
+
+ /**
+ * Check if the contact has delete permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_delete($contact_id, $owner_id='')
+ {
+ return $this->contacts->check_delete($contact_id,
$owner_id);
+ }
+
+ /*************************************************************\
+ * Preferences functions section *
+ \*************************************************************/
+
+ function read_preferences($contact_type)
+ {
+ $prefs=$GLOBALS['phpgw']->preferences;
+ $prefs=$prefs->data['addressbook'];
+ if($contact_type==$this->tab_main_persons)
{
- $this->contacts->delete($data['id']);
+
+ return unserialize($prefs['person_columns']);
}
- return;
+ elseif($contact_type==$this->tab_main_organizations)
+ {
+ return unserialize($prefs['org_columns']);
+ }
}
+
}
?>
====================================================
Index: addressbook/inc/class.boXport.inc.php
diff -u addressbook/inc/class.boXport.inc.php:1.9
addressbook/inc/class.boXport.inc.php:1.10
--- addressbook/inc/class.boXport.inc.php:1.9 Sat Aug 24 18:04:27 2002
+++ addressbook/inc/class.boXport.inc.php Fri Dec 31 04:55:22 2004
@@ -32,7 +32,7 @@
var $use_session = False;
- function boXport ($session=False)
+ function boXport($session=False)
{
$this->contacts = $GLOBALS['phpgw']->contacts;
$this->so = CreateObject('addressbook.soaddressbook');
@@ -41,25 +41,15 @@
$this->read_sessiondata();
$this->use_session = True;
}
+ global
$start,$limit,$query,$sort,$order,$filter,$cat_id;
- $start = intval(get_var('start',
array('POST','GET')));
- $query = get_var('query', array('POST','GET'));
- $limit = get_var('limit', array('POST','GET'));
- $sort = get_var('sort', array('POST','GET'));
- $order = get_var('order', array('POST','GET'));
- $filter = get_var('filter', array('POST','GET'));
- $cat_id = get_var('fcat_id', array('POST'));
-
- $this->start = (!empty($start) || ($start == '0')) ?
$start : $this->start;
- $this->limit = (!empty($limit) || ($limit == '0')) ?
$limit : $this->limit;
- $this->query = (empty($query) && !empty($this->query))
|| !empty($query) ? $query : $this->query;
- $this->cquery = (empty($cquery) &&
!empty($this->cquery)) || !empty($cquery) ? $cquery : $this->cquery;
- $this->sort = (!empty($sort)) ? $sort : $this->sort;
- $this->order = (!empty($order)) ? $order :
$this->order;
- $this->filter = (!empty($filter) || ($filter == '0')) ?
$filter : $this->filter;
-
- $this->cat_id = (isset($cat_id) && !empty($cat_id)) ?
$cat_id : $this->cat_id;
- $this->cat_id = ($cat_id == '0' || $cat_id == 0 ||
$cat_id == '') ? $cat_id : $this->cat_id;
+ if($start || $start == 0) { $this->start = $start; }
+ if($limit) { $this->limit = $limit; }
+ if($query) { $this->query = $query; }
+ if($sort) { $this->sort = $sort; }
+ if($order) { $this->order = $order; }
+ if($filter) { $this->filter = $filter; }
+ $this->cat_id = $cat_id;
}
function save_sessiondata()
@@ -85,10 +75,7 @@
function read_sessiondata()
{
$data =
$GLOBALS['phpgw']->session->appsession('session_data','addressbook');
- if($this->debug)
- {
- echo '<br>Read:'; _debug_array($data);
- }
+ if($this->debug) { echo '<br>Read:';
_debug_array($data); }
$this->start = $data['start'];
$this->limit = $data['limit'];
@@ -103,23 +90,20 @@
{
include (PHPGW_APP_INC . '/import/' . $conv_type);
- if($private == '')
- {
- $private = 'public';
- }
+ if ($private == '') { $private = 'public'; }
$row = 0;
$buffer = array();
$contacts = new import_conv;
$buffer = $contacts->import_start_file($buffer);
$fp = fopen($tsvfile,'r');
- if($contacts->type == 'csv')
+ if ($contacts->type == 'csv')
{
- while($data = fgetcsv($fp,8000,','))
+ while ($data = fgetcsv($fp,8000,','))
{
$num = count($data);
$row++;
- if($row == 1)
+ if ($row == 1)
{
$header = $data;
/* Changed here to ignore the
header, set to our array
@@ -132,10 +116,10 @@
else
{
$buffer =
$contacts->import_start_record($buffer);
- for($c=0; $c<$num; $c++)
+ for ($c=0; $c<$num; $c++ )
{
//Send name/value pairs
along with the buffer
-
if($contacts->import[$header[$c]] != '' && $data[$c] != '')
+ if
($contacts->import[$header[$c]] != '' && $data[$c] != '')
{
$buffer =
$contacts->import_new_attrib($buffer, $contacts->import[$header[$c]],$data[$c]);
}
@@ -144,25 +128,25 @@
}
}
}
- elseif($contacts->type == 'ldif')
+ elseif ($contacts->type == 'ldif')
{
- while($data = fgets($fp,8000))
+ while ($data = fgets($fp,8000))
{
$url = "";
list($name,$value,$extra) = split(':',
$data);
- if(substr($name,0,2) == 'dn')
+ if (substr($name,0,2) == 'dn')
{
$buffer =
$contacts->import_start_record($buffer);
}
$test = trim($value);
- if($name && !empty($test) && $extra)
+ if ($name && !empty($test) && $extra)
{
// Probable url string
$url = $test;
$value = $extra;
}
- elseif($name && empty($test) && $extra)
+ elseif ($name && empty($test) && $extra)
{
// Probable multiline encoding
$newval =
base64_decode(trim($extra));
@@ -170,15 +154,15 @@
//echo $name.':'.$value;
}
- if($name && $value)
+ if ($name && $value)
{
$test = split(',mail=',$value);
- if($test[1])
+ if ($test[1])
{
$name = "mail";
$value = $test[1];
}
- if($url)
+ if ($url)
{
$name = "homeurl";
$value = $url. ':' .
$value;
@@ -197,100 +181,106 @@
}
else
{
- while($data = fgets($fp,8000))
+ while ($data = fgets($fp,8000))
{
$data = trim($data);
// RB 2001/05/07 added for Lotus
Organizer
- while(substr($data,-1) == '=')
+ while (substr($data,-1) == '=')
{
// '=' at end-of-line --> line
to be continued with next line
$data = substr($data,0,-1) .
trim(fgets($fp,8000));
}
-
if(strstr($data,';ENCODING=QUOTED-PRINTABLE'))
+ if (strstr($data, 'BEGIN:VCARD'))
{
- // RB 2001/05/07 added for
Lotus Organizer
- $data =
quoted_printable_decode(str_replace(';ENCODING=QUOTED-PRINTABLE','',$data));
+ // added for p800 vcards:
problem if vcard starts with "<![CDATA["
+ $data = strstr($data,
'BEGIN:VCARD');
}
list($name,$value) = explode(':',
$data,2); // RB 2001/05/09 to allow ':' in Values (not only in URL's)
- if(strtolower(substr($name,0,5)) ==
'begin')
+ if (strtolower(substr($name,0,5)) ==
'begin')
{
$buffer =
$contacts->import_start_record($buffer);
}
- if($name && $value)
+ elseif (strtolower(substr($name, 0, 3))
== 'end')
+ {
+ $buffer =
$contacts->import_end_record($buffer);
+ }
+ elseif ($name && $value)
{
reset($contacts->import);
- while(list($fname,$fvalue) =
each($contacts->import))
+ while ( list($fname,$fvalue) =
each($contacts->import) )
{
-
if(strstr(strtolower($name), $contacts->import[$fname]))
+ if (
strstr(strtolower($name), $contacts->import[$fname]) )
{
$buffer =
$contacts->import_new_attrib($buffer,$name,$value);
}
}
}
- else
- {
- $buffer =
$contacts->import_end_record($buffer);
- }
}
}
fclose($fp);
+ /* Delete the temp file. */
+ unlink($tsvfile);
+
$buffer =
$contacts->import_end_file($buffer,$private,$fcat_id);
return $buffer;
}
- function export($conv_type,$cat_id='')
+ function
export($conv_type,$cat_id='',$both_types='',$sub_cats='')
{
include (PHPGW_APP_INC . '/export/' . $conv_type);
- $buffer = array();
+
+ $buffer=array();
$contacts = new export_conv;
-
- // Read in user custom fields, if any
- $customfields = array();
- while(list($col,$descr) =
@each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
- {
- if(substr($col,0,6) == 'extra_')
+
+ // Note our use of ===. Simply == would not work as
expected
+ if( strpos($conv_type, 'OpenOffice') === false )
+ {
+ // Read in user custom fields, if any
+ $customfields = array();
+ while (list($col,$descr) =
@each($GLOBALS['phpgw_info']['user']['preferences']['addressbook']))
{
- $field = ereg_replace('extra_','',$col);
- $field = ereg_replace('
','_',$field);
- $customfields[$field] = ucfirst($field);
+ if ( substr($col,0,6) == 'extra_' )
+ {
+ $field =
ereg_replace('extra_','',$col);
+ $field = ereg_replace('
','_',$field);
+ $customfields[$field] =
ucfirst($field);
+ }
}
- }
- $extrafields = array(
- 'ophone' => 'ophone',
- 'address2' => 'address2',
- 'address3' => 'address3'
- );
- if($contacts->type != 'vcard')
- {
- $contacts->qfields =
$contacts->stock_contact_fields;# + $extrafields;# + $customfields;
- }
- if(!empty($cat_id))
- {
- $buffer =
$contacts->export_start_file($buffer,$cat_id);
- }
- else
- {
- $buffer = $contacts->export_start_file($buffer);
- }
+ if (!empty($cat_id))
+ {
+ $buffer =
$contacts->export_start_file($buffer,$cat_id);
+ }
+ else
+ {
+ $buffer =
$contacts->export_start_file($buffer);
+ }
- for($i=0;$i<count($contacts->ids);$i++)
- {
- $buffer =
$contacts->export_start_record($buffer);
- while(list($name,$value) =
each($contacts->currentrecord))
+ for ($i=0;$i<count($contacts->ids);$i++)
{
- $buffer =
$contacts->export_new_attrib($buffer,$name,$value);
+ $buffer =
$contacts->export_start_record($buffer);
+ while( list($name,$value) =
each($contacts->currentrecord) )
+ {
+ $buffer =
$contacts->export_new_attrib($buffer,$name,$value);
+ }
+ $buffer =
$contacts->export_end_record($buffer);
}
- $buffer = $contacts->export_end_record($buffer);
- }
- // Here, buffer becomes a string suitable for printing
- $buffer = $contacts->export_end_file($buffer);
+ // Here, buffer becomes a string suitable for
printing
+ $buffer = $contacts->export_end_file($buffer);
- $tsvfilename =
$GLOBALS['phpgw_info']['server']['temp_dir'] . SEP . $tsvfilename;
+ $tsvfilename =
$GLOBALS['phpgw_info']['server']['temp_dir'] . SEP . $tsvfilename;
+ }
+ else // this is the openoffice section
+ {
+ //echo "<pre>here1 $both_types
$sub_cats</pre>";
+ $tsvfilename =
$contacts->do_it($both_types,$sub_cats);
+ $buffer = $tsvfilename;
+ }
+
return $buffer;
}
}
====================================================
Index: addressbook/inc/class.boaddressbook.inc.php
diff -u addressbook/inc/class.boaddressbook.inc.php:1.25
addressbook/inc/class.boaddressbook.inc.php:1.26
--- addressbook/inc/class.boaddressbook.inc.php:1.25 Tue Jul 1 20:24:00 2003
+++ addressbook/inc/class.boaddressbook.inc.php Fri Dec 31 04:55:22 2004
@@ -1,271 +1,718 @@
<?php
/**************************************************************************\
- * phpGroupWare - addressbook *
+ * phpGroupWare - boaddressbook *
* http://www.phpgroupware.org *
- * Written by Miles Lott <address@hidden> *
+ * This program is part of the GNU project, see http://www.gnu.org/ *
+ * *
+ * Copyright 2003 Free Software Foundation, Inc. *
+ * *
+ * Originally Written by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
+ * Current Maintained by Jonathan Alberto Rivera Gomez - jarg at co.com.mx *
* -------------------------------------------- *
- * This program is free software; you can redistribute it and/or modify it *
+ * Development of this application was funded by http://www.sogrp.com *
+ * -------------------------------------------- *
+ * This program is Free Software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
- /* $Id$ */
+/* $Id$ */
class boaddressbook
{
- var $public_functions = array(
- 'read_entries' => True,
- 'read_entry' => True,
- 'read_last_entry' => True,
- 'add_entry' => True,
- 'add_vcard' => True,
- 'add_email' => True,
- 'update_entry' => True
- );
-
- var $xml_functions = array();
-
- var $soap_functions = array(
- 'read_entries' => array(
- 'in' =>
array('int','int','struct','string','int'),
- 'out' => array('array')
- ),
- 'read_entry' => array(
- 'in' => array('int','struct'),
- 'out' => array('array')
- ),
- 'read_last_entry' => array(
- 'in' => array('struct'),
- 'out' => array('array')
- ),
- 'add_entry' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- ),
- 'update_entry' => array(
- 'in' => array('int','struct'),
- 'out' => array()
- )
- );
-
- var $debug = False;
-
+ var $debug = False;
var $so;
+ var $rights;
+ var $grants;
+ var $comm_type;
+ var $addr_type;
+ var $note_type;
+ var $tab_main_persons;
+ var $tab_main_organizations;
+ var $use_session = False;
var $start;
+ var $limit;
var $query;
var $sort;
var $order;
var $filter;
var $cat_id;
var $total;
+ var $bday_internformat;
+ var $public_functions = array(
+ 'add_vcard' => True // call from
addressbook.uivcard.in to import a vcard
+ );
- var $use_session = False;
-
- function boaddressbook($session=False)
+ function boaddressbook($session=True)
{
$this->so = CreateObject('addressbook.soaddressbook');
$this->rights = $this->so->rights;
$this->grants = $this->so->grants;
-
- if($session)
- {
+ $this->contact_type = $this->so->contact_type;
+ $this->comm_descr = $this->so->comm_descr;
+ $this->comm_type = $this->so->comm_type;
+ $this->addr_type = $this->so->addr_type;
+ $this->note_type = $this->so->note_type;
+ $this->tab_main_persons = $this->so->tab_main_persons;
+ $this->tab_main_organizations =
$this->so->tab_main_organizations;
+ $this->bday_internformat = "Y-m-d"; // use ISO 8601 for
internal bday represantation
+
+ if($session)
+ {
$this->read_sessiondata();
$this->use_session = True;
+ }
+ $this->_set_session_data();
+ }
+
+ //used
+ function save_sessiondata($data)
+ {
+ if ($this->use_session)
+ {
+ if($this->debug) { echo '<br>Save:';
_debug_array($data); }
+
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
}
+ }
- $start = intval(get_var('start',
array('POST','GET')));
- $query = get_var('query', array('POST','GET'));
- $cquery = get_var('cquery', array('GET'));
- $sort = get_var('sort', array('POST','GET'));
- $order = get_var('order', array('POST','GET'));
- $filter = get_var('filter', array('POST','GET'));
- $cat_id = get_var('fcat_id', array('POST'));
-
- $this->start = (!empty($start) || ($start == '0')) ?
$start : $this->start;
- $this->query = (empty($query) && !empty($this->query))
|| !empty($query) ? $query : $this->query;
- $this->cquery = (empty($cquery) &&
!empty($this->cquery)) || !empty($cquery) ? $cquery : $this->cquery;
- $this->sort = (!empty($sort)) ? $sort : $this->sort;
- $this->order = (!empty($order)) ? $order :
$this->order;
- $this->filter = (!empty($filter) || ($filter == '0')) ?
$filter : $this->filter;
+ //used
+ function read_sessiondata()
+ {
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data','addressbook');
+ if($this->debug) { echo '<br>Read:';
_debug_array($data); }
+
+ $this->start = $data['start'];
+ $this->limit = $data['limit'];
+ $this->query = $data['query'];
+ $this->sort = $data['sort'];
+ $this->order = $data['order'];
+ $this->filter = $data['filter'];
+ $this->cat_id = $data['cat_id'];
+ $this->qfield = $data['qfield'];
+ if($this->debug) { echo '<br>read_sessiondata();';
$this->_debug_sqsof(); }
+ }
- $this->cat_id = (isset($cat_id) && !empty($cat_id)) ?
$cat_id : $this->cat_id;
- $this->cat_id = ($cat_id == '0' || $cat_id == 0 ||
$cat_id == '') ? $cat_id : $this->cat_id;
+ function _set_session_data()
+ {
+ /* _debug_array($GLOBALS['HTTP_POST_VARS']); */
+ /* Might change this to '' at the end---> */
+ $_start = get_var('start',Array('GET','POST'));
+ $_query = get_var('query',Array('GET','POST'));
+ $_qfield = get_var('qfield',Array('GET','POST'));
+ $_sort = get_var('sort',Array('GET','POST'));
+ $_order = get_var('order',Array('GET','POST'));
+ $_filter = get_var('filter',Array('GET','POST'));
+ $_cat_id = get_var('cat_id',Array('GET','POST'));
+ $_fcat_id = get_var('fcat_id',Array('GET','POST'));
- if($this->debug)
+ if(!empty($_start) || ($_start == '0') || ($_start ==
0))
{
- $this->_debug_sqsof();
+ if($this->debug) { echo '<br>overriding $start:
"' . $this->start . '" now "' . $_start . '"'; }
+ $this->start = $_start;
+ }
+ if($_limit)
+ {
+ $this->limit = $_limit;
+ }
+ if((empty($_query) && !empty($this->query)) ||
!empty($_query))
+ {
+ if($this->debug) { echo '<br>overriding $query:
"' . $this->query . '" now "' . urldecode(addslashes($_query)) . '"'; }
+ if($this->query !=
urldecode(addslashes($_query)))
+ {
+ $this->start = 0;
+ }
+ $this->query = $_query;
}
- }
- function _debug_sqsof()
+ if(isset($_fcat_id) && $_fcat_id!='')
+ {
+ if($this->debug) { echo '<br>overriding
$cat_id: "' . $this->cat_id . '" now "' . $_fcat_id . '"'; }
+ if($this->cat_id != $_fcat_id)
+ {
+ $this->start = 0;
+ }
+ $this->cat_id = $_fcat_id;
+ }
+
+ if(isset($_sort) && !empty($_sort))
+ {
+ if($this->debug) { echo '<br>overriding $sort:
"' . $this->sort . '" now "' . $_sort . '"'; }
+ $this->sort = $_sort;
+ }
+
+ if(isset($_order) && !empty($_order))
+ {
+ if($this->debug) { echo '<br>overriding $order:
"' . $this->order . '" now "' . $_order . '"'; }
+ $this->order = $_order;
+ }
+
+ if(isset($_filter) && !empty($_filter))
+ {
+ if($this->debug) { echo '<br>overriding
$filter: "' . $this->filter . '" now "' . $_filter . '"'; }
+ if($this->filter != $_filter)
+ {
+ $this->start = 0;
+ }
+ $this->filter = $_filter;
+ }
+
+ if(isset($_qfield) && !empty($_qfield))
+ {
+ $this->qfield = $_qfield;
+ }
+
+ if($this->debug) { $this->_debug_sqsof(); }
+ }
+
+ /*************************************************************\
+ * Person Functions Section *
+ \*************************************************************/
+
+ /**
+ * Call to add_person function in soaddressbook object
+ *
+ * @param array $fields The array with all data of the person
+ * @return integer The person_id of the new person
+ */
+ function add_person($fields)
+ {
+ return $this->so->add_person($fields);
+ }
+
+ /**
+ * Get the principal person data for the psrson_id what you want
+ *
+ * @param integer $person_id The person id what you want to find
+ * @param bolean $get_org Flag for get or not org_data for this
person
+ * @return array The array with all data from person, this also
+ * separate the cats and extra tab
+ */
+ function get_principal_persons_data($person_id, $get_org=True)
+ {
+ $entry =
$this->so->get_principal_persons_data($person_id, $get_org);
+
+ $entry[0]['tab_cats']['my_cats'] = explode(",",
$entry[0]['cat_id']);
+ $entry[0]['tab_extra']['per_suffix'] =
$entry[0]['per_suffix'];
+ $entry[0]['tab_extra']['per_sound'] =
$entry[0]['per_sound'];
+ $entry[0]['tab_extra']['per_initials'] =
$entry[0]['per_initials'];
+ $entry[0]['tab_extra']['per_pubkey'] =
$entry[0]['per_pubkey'];
+
+ unset($entry[0]['cat_id']);
+ unset($entry[0]['per_suffix']);
+ unset($entry[0]['per_sound']);
+ unset($entry[0]['per_initials']);
+ unset($entry[0]['per_pubkey']);
+
+ return $entry[0];
+ }
+
+ /**
+ * Get the organizations for the person what you want
+ *
+ * @param integer $person_i The person id what you want to find
+ * @return array The array with all organizations for this
person,
+ * this also return in this array the preferred organization
+ */
+ function get_orgs_person_data($person_id)
{
- $data = array(
- 'start' => $this->start,
- 'query' => $this->query,
- 'sort' => $this->sort,
- 'order' => $this->order,
- 'filter' => $this->filter,
- 'cat_id' => $this->cat_id,
- 'cquery' => $this->cquery
- );
- echo '<br>BO:';
- _debug_array($data);
+ $entry =
$this->so->get_organizations_by_person($person_id);
+ if($entry)
+ {
+ foreach($entry as $k => $v)
+ {
+ if ($v['my_preferred'] == 'Y')
+ {
+ $entry['preferred_org'] =
$v['my_org_id'];
+ }
+ $entry['my_orgs'][$k] = $v['my_org_id'];
+ }
+ }
+ return $entry;
}
- function list_methods($_type='xmlrpc')
+ /**
+ * Get the the person data what you want
+ *
+ * @param array $fields The fields that you can see from person
+ * @param integer $limit Limit of records that you want
+ * @param integer $ofset Ofset of record that you want start
+ * @param string $orderby The field which you want order
+ * @param string $sort ASC | DESC depending what you want
+ * @param mixed $criteria All criterias what you want
+ * @param mixed $criteria_token same like $criteria but
builded<br>with sql_criteria class, more powerfull
+ * @return array with records
+ */
+ function get_persons($fields, $start='', $limit='',
$orderby='', $sort='', $criteria='', $token_criteria='')
{
- /*
- This handles introspection or discovery by the logged
in client,
- in which case the input might be an array. The
server always calls
- this function to fill the server dispatch map using a
string.
- */
- if(is_array($_type))
- {
- $_type = $_type['type'] ? $_type['type'] :
$_type[0];
- }
- switch($_type)
- {
- case 'xmlrpc':
- $xml_functions = array(
- 'read' => array(
- 'function' =>
'read_entry',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read a single entry by passing the id and fieldlist.')
- ),
- 'add' => array(
- 'function' =>
'add_entry',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Add a single entry by passing the fields.')
- ),
- 'save' => array(
- 'function' =>
'update_entry',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Update a single entry by passing the fields.')
- ),
- 'delete' => array(
- 'function' =>
'delete_entry',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcInt)),
- 'docstring' =>
lang('Delete a single entry by passing the id.')
- ),
- 'read_list' => array(
- 'function' =>
'read_entries',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read a list of entries.')
- ),
- 'list_methods' => array(
- 'function' =>
'list_methods',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcString)),
- 'docstring' =>
lang('Read this list of methods.')
- )
- );
- return $xml_functions;
- break;
- case 'soap':
- return $this->soap_functions;
- break;
- default:
- return array();
- break;
+ $entries = $this->so->get_persons($fields, $start,
$limit, $orderby, $sort, $criteria, $token_criteria);
+ if(is_array($entries))
+ {
+ foreach($entries as $data)
+ {
+ $persons[$data['contact_id']] = $data;
+ }
}
+ else
+ {
+ $persons = array();
+ }
+ $this->total = $this->so->contacts->total_records;
+ return $persons;
}
- function save_sessiondata($data)
+ /**
+ * Edit the person data what you want
+ *
+ * @param integer $person_id The person what you want to edit
+ * @param array $fields The fields that you want
+ * @return
+ */
+ function edit_person($person_id, $fields)
+ {
+ $old_orgs= $fields['old_my_orgs']['my_orgs'];
+ $new_orgs = $fields['tab_orgs']['my_orgs'];
+ $fields['edit_orgs'] = $this->diff_arrays($old_orgs,
$new_orgs);
+
+ $old_comm = $fields['old_comm'];
+ $new_comm = $fields['tab_comms']['comm_data'];
+ $fields['edit_comms'] = $this->diff_arrays($old_comm,
$new_comm, 'keys');
+
+ $old_others = $fields['old_others'];
+ $new_others = $fields['others_data'];
+ $fields['edit_others'] =
$this->diff_arrays($old_others, $new_others, 'keys');
+ return $this->so->edit_person($person_id, $fields);
+ }
+
+ //used
+ function get_count_persons($criteria='')
{
- if($this->use_session)
+ return $this->so->get_count_persons($criteria);
+ }
+
+ /*************************************************************\
+ * Organization Functions Section *
+ \*************************************************************/
+
+ /**
+ * Call to add_org function in soaddressbook object
+ *
+ * @param array $fields The array with all data of the org
+ * @return integer The org_id of the new org
+ */
+ function add_org($fields)
+ {
+ return $this->so->add_org($fields);
+ }
+
+ /**
+ * Get the principal organization data for the org_id what you
want
+ *
+ * @param integer $org_id The organization id what you want to
find
+ * @return array The array with all data from person, this also
+ * separate the cats and extra tab
+ */
+ function get_principal_organizations_data($org_id)
+ {
+ $entry =
$this->so->get_principal_organizations_data($org_id);
+ $entry[0]['tab_cats']['my_cats'] = explode(",",
$entry[0]['cat_id']);
+ unset($entry[0]['cat_id']);
+ return $entry[0];
+ }
+
+ /**
+ * Get the persons for the organization what you want
+ *
+ * @param integer $org_id The org id what you want to find
+ * @return array The array with all persons for this organization
+ */
+ function get_person_orgs_data($org_id)
+ {
+ $entry =
$this->so->get_people_by_organizations($org_id);
+ if($entry)
{
- if($this->debug)
+ foreach($entry as $k => $v)
{
- echo '<br>Save:'; _debug_array($data);
+ $entry['my_person'][$k] =
$v['my_person_id'];
}
-
$GLOBALS['phpgw']->session->appsession('session_data','addressbook',$data);
}
+ return $entry;
}
- function read_sessiondata()
+ /**
+ * Retrieve all organizations data which you specify, this can
use
+ * limit and order.
+ *
+ * @param array $fields The fields that you can see from person
+ * @param integer $limit Limit of records that you want
+ * @param integer $ofset Ofset of record that you want start
+ * @param string $orderby The field which you want order
+ * @param string $sort ASC | DESC depending what you want
+ * @param array $criteria All criterias what you want
+ * @param mixed $criteria_token same like $criteria but
builded<br>with sql_criteria class, more powerfull
+ * @return array with records
+ */
+ function get_orgs($fields, $start='', $limit='', $orderby='',
$sort='', $criteria='', $token_criteria='')
{
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','addressbook');
- if($this->debug)
+ $entries = $this->so->get_orgs($fields, $start,
$limit, $orderby, $sort, $criteria, $token_criteria);
+ if(is_array($entries))
{
- echo '<br>Read:'; _debug_array($data);
+ foreach($entries as $data)
+ {
+ $orgs[$data['contact_id']] = $data;
+ }
}
+ else
+ {
+ $orgs = array();
+ }
+ $this->total = $this->so->contacts->total_records;
+ return $orgs;
+ }
- $this->start = $data['start'];
- $this->query = $data['query'];
- $this->cquery = $data['cquery'];
- $this->sort = $data['sort'];
- $this->order = $data['order'];
- $this->filter = $data['filter'];
- $this->cat_id = $data['cat_id'];
- if($this->debug) { echo '<br>read_sessiondata();';
$this->_debug_sqsof(); }
+ /**
+ * Edit the org data what you want
+ *
+ * @param integer $org_id The org what you want to edit
+ * @param array $fields The fields that you want
+ * @return
+ */
+ function edit_org($org_id, $fields)
+ {
+ $old_person= $fields['old_my_person']['my_person'];
+ $new_person = $fields['tab_persons']['my_person'];
+ $fields['edit_persons'] =
$this->diff_arrays($old_person, $new_person);
+
+ $old_comm = $fields['old_comm'];
+ $new_comm = $fields['tab_comms']['comm_data'];
+ $fields['edit_comms'] = $this->diff_arrays($old_comm,
$new_comm, 'keys');
+
+ $old_others = $fields['old_others'];
+ $new_others = $fields['others_data'];
+ $fields['edit_others'] =
$this->diff_arrays($old_others, $new_others, 'keys');
+
+ return $this->so->edit_org($org_id, $fields);
+ }
+
+ //used
+ function get_count_orgs($criteria='')
+ {
+ return $this->so->get_count_orgs($criteria);
+ }
+
+ /*************************************************************\
+ * Retrive Contact Data Functions Section *
+ \*************************************************************/
+
+ /**
+ * Get the others fields data for this contact
+ *
+ * @param integer $contact_id The contact id what you want to
find
+ * @return array The array with all others data for this contact
+ */
+ function get_others_contact_data($contact_id)
+ {
+ return $this->so->get_others_contact_data($contact_id);
}
- function strip_html($dirty = '')
+ /**
+ * Get the addresses data for this contact
+ *
+ * @param integer $contact_id The contact id what you want to
find
+ * @return array The array with all addresses data for this
contact
+ */
+ function get_addr_contact_data($contact_id, $criteria='')
{
- if($dirty == '')
+ return $this->so->get_addr_contact_data($contact_id,
$criteria);
+ }
+
+ /**
+ * Get the communications media data for this contact
+ *
+ * @param integer $contact_id The contact id what you want to
find
+ * @return array The array with all communications media for
this contact
+ */
+ function get_comm_contact_data($contacts, $fields_comms='',
$simple=False)
+ {
+ $data = $this->so->get_comm_contact_data($contacts,
$fields_comms);
+ if($simple==True)
{
- $dirty = array();
+ return $data;
}
- for($i=0;$i<count($dirty);$i++)
+
+ if(is_array($data))
{
- if(is_array($dirty[$i]))
+ foreach($data as $key => $value)
{
- while(list($name,$value) =
@each($dirty[$i]))
+
$comm_data[$value['comm_contact_id']][$value['comm_description']] =
$value['comm_data'];
+ if($value['comm_preferred']=='Y')
{
- $cleaned[$i][$name] =
$GLOBALS['phpgw']->strip_html($dirty[$i][$name]);
+
$comm_data[$value['comm_contact_id']]['preferred'] = $value['comm_description'];
}
}
- else
- {
- $cleaned[$i] ==
$GLOBALS['phpgw']->strip_html($dirty[$i]);
- }
}
- return $cleaned;
+ else
+ {
+ $comm_data = array();
+ }
+ return $comm_data;
}
- function read_entries($data)
+ //used
+ function get_sub_cats($cat_to_find)
{
- $entries = $this->so->read_entries($data);
- $this->total = $this->so->contacts->total_records;
- if($this->debug)
+ return $this->so->get_sub_cats($cat_to_find);
+ }
+
+ //used
+ function get_persons_by_cat($cats)
+ {
+ return $this->so->get_persons_by_cat($cats);
+ }
+
+ //used
+ function get_type_contact($contact_id)
+ {
+ return $this->so->get_type_contact($contact_id);
+ }
+
+ /*************************************************************\
+ * Others Contacts Actions Functions Section *
+ \*************************************************************/
+
+ //used
+ function delete($contact_id, $contact_type)
+ {
+ return $this->so->delete($contact_id, $contact_type);
+ }
+
+ //used
+ function copy_contact($contact_id)
+ {
+ return $this->so->copy_contact($contact_id);
+ }
+
+ /**
+ * Criteria for index primordially
+ *
+ * return string criteria for search.
+ */
+ function criteria_contacts($access, $category, $field,
$pattern, $show_fields)
+ {
+ if($pattern)
{
- echo '<br>Total records="' . $this->total . '"';
+ switch($field)
+ {
+ case 'person':
+ $fields = array(
+ 'per_full_name',
+ 'per_prefix',
+ 'per_suffix',
+ 'per_birthday',
+ 'per_pubkey',
+ 'per_title',
+ 'per_department',
+ 'per_initials',
+ 'per_sound',
+ 'per_active');
+ break;
+ case 'org':
+ $fields = array('org_name');
+ break;
+ case 'comms':
+ foreach($this->comm_descr as $data)
+ {
+ $comms[] =
$data['comm_description'];
+ }
+ $fields['comm_media'] = $comms;
+ break;
+ case 'location':
+ $fields = array('addr_add1',
+ 'addr_add2',
+ 'addr_add3',
+ 'addr_city',
+ 'addr_state',
+ 'addr_postal_code',
+ 'addr_country');
+ break;
+ case 'other':
+ $fields = array('other_value');
+ break;
+ case 'note':
+ $fields = array('note_text');
+ break;
+ default:
+ $fields = array();
+ }
}
- return $this->strip_html($entries);
+ return
$this->so->criteria_contacts($GLOBALS['phpgw_info']['user']['account_id'],
$access, $category, $fields, $pattern, $show_fields);
}
- function read_entry($data)
+ /**
+ * Delete the specified communication media.
+ *
+ * @param integer|array $id Key of the comm media what you want
+ */
+ function delete_specified_comm($id)
{
- $entry =
$this->so->read_entry($data['id'],$data['fields']);
- return $this->strip_html($entry);
+ return $this->so->delete_specified_comm($id);
}
- function read_last_entry($fields)
+ /**
+ * Delete the specified address.
+ *
+ * @param integer|array $id Key of the address what you want
+ */
+ function delete_specified_location($id)
+ {
+ return $this->so->delete_specified_location($id);
+ }
+ /**
+ * Delete the specified others field.
+ *
+ * @param integer|array $id Key of the other field what you want
+ */
+ function delete_specified_other($id)
{
- $entry = $this->so->read_last_entry($fields);
- return $this->strip_html($entry);
+ return $this->so->delete_specified_other($id);
}
- function add_vcard()
+ /**
+ * Delete the specified note.
+ *
+ * @param integer|array $id Key of the note what you want
+ */
+ function delete_specified_note($id)
+ {
+ return $this->so->delete_specified_note($id);
+ }
+
+ function get_insert_others($contact_id, $fields)
+ {
+ return $this->so->add_others($fields, $contact_id);
+ }
+
+ function get_update_others($contact_id, $fields)
+ {
+ unset($fields['key_other_id']);
+ return $this->so->edit_other($contact_id, $fields);
+ }
+
+ function get_insert_comm($contact_id, $fields)
+ {
+ return $this->so->add_communication_media($fields,
$contact_id);
+ }
+
+ function get_update_comm($contact_id, $fields)
+ {
+ unset($fields['key_comm_id']);
+ return $this->so->edit_comms($contact_id, $fields);
+ }
+
+ function get_insert_addr($contact_id, $fields)
+ {
+ return $this->so->add_location($fields, $contact_id);
+ }
+
+ function get_update_addr($contact_id, $fields)
+ {
+ unset($fields['key_addr_id']);
+ return $this->so->edit_location($contact_id, $fields);
+ }
+
+ /*************************************************************\
+ * Search Functions Section *
+ \*************************************************************/
+
+ //used
+ function search_contact_type_id($id)
+ {
+ return $this->so->search_contact_type_id($id);
+ }
+
+ /**
+ * Search location id in location catalog
+ *
+ * @param integer $id The location id to find
+ * @return string The description of id
+ */
+ function search_location_type_id($id)
{
- $uploadedfile =
$GLOBALS['HTTP_POST_VARS']['uploadedfile'];
+ return $this->so->search_location_type_id($id);
+ }
+
+ /*************************************************************\
+ * Check ACL Functions Section *
+ \*************************************************************/
- if($uploadedfile == 'none' || $uploadedfile == '')
+ /**
+ * Check if the contact has add permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_add($contact_id, $owner_id='')
+ {
+ return $this->so->check_add($contact_id, $owner_id);
+ }
+
+ /**
+ * Check if the contact has edit permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_edit($contact_id, $owner_id='')
+ {
+ return $this->so->check_edit($contact_id, $owner_id);
+ }
+
+ /**
+ * Check if the contact has read permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_read($contact_id, $owner_id='')
+ {
+ return $this->so->check_read($contact_id, $owner_id);
+ }
+
+ /**
+ * Check if the contact has delete permissions.
+ *
+ * @param integer $contact_id The contact_id which you want to
check
+ * @param integer $owner_id The owner_id of the contact which
you want to check
+ */
+ function check_delete($contact_id, $owner_id='')
+ {
+ return $this->so->check_delete($contact_id, $owner_id);
+ }
+
+ /*************************************************************\
+ * Others Functions Section *
+ \*************************************************************/
+
+ //used
+ function add_vcard()
+ {
+ if(!is_array($_FILES['uploadedfile']) ||
($_FILES['uploadedfile']['error'] != UPLOAD_ERR_OK))
{
Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.in&action=GetFile'));
}
else
{
+ $uploadedfile =
$_FILES['uploadedfile']['tmp_name'];
$uploaddir =
$GLOBALS['phpgw_info']['server']['temp_dir'] . SEP;
srand((double)microtime()*1000000);
$random_number = rand(100000000,999999999);
- $newfilename = md5("$uploadedfile,
$uploadedfile_name, "
- . time() . getenv("REMOTE_ADDR") .
$random_number );
+ $newfilename = md5($_FILES['uploadedfile'] .
$_FILES['uploadedfile']['name']
+ . time() . $_SERVER['REMOTE_ADDR'] .
$random_number );
- copy($uploadedfile, $uploaddir . $newfilename);
+ move_uploaded_file($uploadedfile, $uploaddir .
$newfilename);
$ftp = fopen($uploaddir . $newfilename .
'.info','w');
-
fputs($ftp,"$uploadedfile_type\n$uploadedfile_name\n");
+ fputs($ftp,$_FILES['uploadedfile']['type'] .
"\n" . $_FILES['uploadedfile']['name']."\n");
fclose($ftp);
$filename = $uploaddir . $newfilename;
@@ -275,79 +722,39 @@
/* _debug_array($entry);exit; */
$entry['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
$entry['access'] = 'private';
- $entry['tid'] = 'n';
/* _debug_array($entry);exit; */
- $this->so->add_entry($entry);
- $ab_id = $this->get_lastid();
+ $ab_id = $this->so->contact_import($entry);
+
/* Delete the temp file. */
unlink($filename);
unlink($filename . '.info');
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $ab_id));
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view_person&ab_id='
. $ab_id));
+ exit();
}
}
- function add_email()
- {
- $name = $GLOBALS['HTTP_GET_VARS']['name'];
- $referer = $GLOBALS['HTTP_GET_VARS']['referer'];
-
- $named = explode(' ', $name);
- for($i=count($named);$i>=0;$i--)
- {
- $names[$i] = $named[$i];
- }
- if($names[2])
- {
- $fields['n_given'] = $names[0];
- $fields['n_middle'] = $names[1];
- $fields['n_family'] = $names[2];
- }
- else
- {
- $fields['n_given'] = $names[0];
- $fields['n_family'] = $names[1];
- }
- $fields['email'] = $add_email;
- $referer = urlencode($referer);
-
-
$this->so->add_entry($GLOBALS['phpgw_info']['user']['account_id'],$fields,'private','','n');
- $ab_id = $this->get_lastid();
-
- Header('Location: '
- .
$GLOBALS['phpgw']->link('/index.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer"));
- }
-
- function add_entry($fields)
- {
- return $this->so->add_entry($fields);
- }
-
- function get_lastid()
- {
- return $this->so->get_lastid();
- }
-
- function update_entry($fields)
+ //used
+ function add_email($name, $email)
{
- return $this->so->update_entry($fields);
+ return $this->so->add_contact_with_email($name, $email);
}
- function delete_entry($ab_id)
- {
- return $this->so->delete_entry($ab_id);
- }
+ /*************************************************************\
+ * Preferences Functions Section *
+ \*************************************************************/
+ //used
function save_preferences($prefs,$other,$qfields,$fcat_id)
{
$GLOBALS['phpgw']->preferences->read_repository();
- if(is_array($prefs))
+ if (is_array($prefs))
{
/* _debug_array($prefs);exit; */
- while(list($pref,$x) = each($qfields))
+ while (list($pref,$x) = each($qfields))
{
/* echo '<br>checking: ' . $pref . '='
. $prefs[$pref]; */
- if($prefs[$pref] == 'on')
+ if ($prefs[$pref] == 'on')
{
$GLOBALS['phpgw']->preferences->add('addressbook',$pref,'addressbook_on');
}
@@ -361,33 +768,169 @@
if(is_array($other))
{
$GLOBALS['phpgw']->preferences->delete('addressbook','mainscreen_showbirthdays');
- if($other['mainscreen_showbirthdays'])
+ if ($other['mainscreen_showbirthdays'])
{
$GLOBALS['phpgw']->preferences->add('addressbook','mainscreen_showbirthdays',True);
}
$GLOBALS['phpgw']->preferences->delete('addressbook','default_filter');
- if($other['default_filter'])
+ if ($other['default_filter'])
{
$GLOBALS['phpgw']->preferences->add('addressbook','default_filter',$other['default_filter']);
}
$GLOBALS['phpgw']->preferences->delete('addressbook','autosave_category');
- if($other['autosave_category'])
+ if ($other['autosave_category'])
{
-
$GLOBALS['phpgw']->preferences->add('addressbook','autosave_category',True);
+
$GLOBALS['phpgw']->preferences->add('addressbook','autosave_category',True);
}
}
- if($fcat_id)
- {
-
$GLOBALS['phpgw']->preferences->delete('addressbook','default_category');
-
$GLOBALS['phpgw']->preferences->add('addressbook','default_category',$fcat_id);
- }
+
$GLOBALS['phpgw']->preferences->delete('addressbook','default_category');
+
$GLOBALS['phpgw']->preferences->add('addressbook','default_category',$fcat_id);
$GLOBALS['phpgw']->preferences->save_repository(True);
/* _debug_array($prefs);exit; */
Header('Location: ' .
$GLOBALS['phpgw']->link('/preferences/index.php'));
}
+
+ //used
+ function get_preferences_for_organizations()
+ {
+ return
$this->so->read_preferences($this->tab_main_organizations);
+ }
+
+ //used
+ function get_preferences_for_persons()
+ {
+ return
$this->so->read_preferences($this->tab_main_persons);
+
+ }
+
+ //used
+ function get_generic_preferences()
+ {
+ return false;
+ }
+
+ /*************************************************************\
+ * Misc Functions Section *
+ \*************************************************************/
+
+ //used
+ function get_columns_to_display($contact_type)
+ {
+ return $this->so->read_preferences($contact_type);
+ }
+
+ //used
+ function display_name($column)
+ {
+ $newcol = $this->so->display_name($column);
+ return $newcol!='*'?$newcol:$column;
+ }
+
+ //used
+ function execute_queries($queries)
+ {
+ return $this->so->execute_queries($queries);
+ }
+
+ //used
+ function diff_arrays($old_array=array(), $new_array=array(),
$type='values')
+ {
+ if(!is_array($old_array))
+ {
+ $old_array = array();
+ }
+
+ if(!is_array($new_array))
+ {
+ $new_array = array();
+ }
+
+ if($type=='values')
+ {
+ $result['delete'] = array_diff($old_array,
$new_array);
+ $result['insert'] = array_diff($new_array,
$old_array);
+ $result['edit'] = array_intersect($old_array,
$new_array);
+ }
+ elseif($type=='keys')
+ {
+ $bc_old_array = $old_array;
+ $bc_new_array = $new_array;
+
+ $delete = array_diff(array_keys($old_array),
array_keys($new_array));
+ $insert = array_diff(array_keys($new_array),
array_keys($old_array));
+ $edit = array_intersect(array_keys($old_array),
array_keys($new_array));
+
+ foreach($delete as $key)
+ {
+ $result['delete'][$key] =
$bc_old_array[$key];
+ }
+ foreach($insert as $key)
+ {
+ $result['insert'][$key] =
$bc_new_array[$key];
+ }
+ foreach($edit as $key)
+ {
+ $result['edit'][$key] =
$bc_new_array[$key];
+ }
+ }
+
+ return $result;
+ }
+
+ function _debug_sqsof()
+ {
+ $data = array(
+ 'start' => $this->start,
+ 'limit' => $this->limit,
+ 'query' => $this->query,
+ 'sort' => $this->sort,
+ 'order' => $this->order,
+ 'filter' => $this->filter,
+ 'cat_id' => $this->cat_id,
+ 'qfield' => $this->qfield
+ );
+ echo '<br>BO:';
+ _debug_array($data);
+ }
+
+ //used
+ function can_delete($contact_id, $owner='')
+ {
+ if
($this->so->contacts->check_perms($this->grants[$owner],PHPGW_ACL_DELETE) ||
+ $owner ==
$GLOBALS['phpgw_info']['user']['account_id'])
+ {
+ return True;
+ }
+ else
+ {
+ return False;
+ }
+ }
+
+ //used
+ function can_delete_hooks($hook_response)
+ {
+ $negative_apps=false;
+ foreach($hook_response as $application => $response)
+ {
+ if(is_array($response))
+ {
+ if(!$response['can_delete'])
+ {
+
$negative_apps[$application]=$response['reason'];
+ }
+ }
+ }
+ if(!$negative_apps)
+ {
+ return true;
+ }
+
+ $this->negative_responses=$negative_apps;
+ }
}
?>
====================================================
====================================================
Index: addressbook/inc/class.uiaddressbook.inc.php
diff -u addressbook/inc/class.uiaddressbook.inc.php:1.55
addressbook/inc/class.uiaddressbook.inc.php:1.56
--- addressbook/inc/class.uiaddressbook.inc.php:1.55 Wed Jul 2 00:18:11 2003
+++ addressbook/inc/class.uiaddressbook.inc.php Fri Dec 31 04:55:22 2004
@@ -2,8 +2,9 @@
/**************************************************************************\
* phpGroupWare - Addressbook *
* http://www.phpgroupware.org *
- * Written by Joseph Engo <address@hidden> and *
+ * Originally Written by Joseph Engo <address@hidden> and *
* Miles Lott <miloschphpgroupware.org> *
+ * Heavy changes (near rewrite) by Jonathan Alberto Rivera <jarg AT
co.com.mx> *
* -------------------------------------------- *
* 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 *
@@ -13,93 +14,139 @@
/* $Id$ */
+
class uiaddressbook
{
- var $output = '';
+ var $template;
var $contacts;
var $bo;
var $cat;
var $company;
var $prefs;
+ var $abc;
var $debug = False;
var $start;
+ var $limit;
var $query;
var $sort;
var $order;
var $filter;
var $cat_id;
-
+ var $bname;
+ var $template;
+ var $options_data;
+ var $old_tab;
+
+ var $all_orgs_data;
+ var $my_orgs_data;
+
+ var $comm_v;
+ //@param fields_data
+ //@discussion Will hold the data to navigate between the tabs
+ var $fields_data = array();
+ var $entry_data;
+
+// //This are the principal tabs
+// var $tab_main_persons = 'Persons';
+// var $tab_main_organizations = 'Organizations';
+
+ //This are the tabs for each principal tab
+// var $tab_person_data = 'Person Data';
+// var $tab_org_data = 'Org Data';
+// var $tab_orgs = 'Orgs';
+// var $tab_persons = 'Persons';
+// var $tab_cats = 'Categories';
+// var $tab_comms = 'Communications';
+// var $tab_address = 'Address';
+// var $tab_others = 'Others';
+// var $tab_extra = 'More data';
+
+ //Public functions
var $public_functions = array(
- 'index' => True,
- 'view' => True,
- 'add' => True,
- 'addfromremote' => True,
+ 'index' => True,
+ 'view' => True,
+ 'add' => True,
'add_email' => True,
- 'copy' => True,
- 'edit' => True,
+ 'copy' => True,
+ 'edit' => True,
'delete' => True,
- 'preferences' => True,
- 'remote_search' => True
- );
+ 'preferences' => True,
- var $extrafields = array(
- 'ophone' => 'ophone',
- 'address2' => 'address2',
- 'address3' => 'address3'
+ 'add_person' => True,
+ 'add_org' => True,
+ 'edit_person' => True,
+ 'edit_org' => True,
+ 'view_contact' => True,
+ 'view_person' => True,
+ 'view_org' => True,
+ 'copy_person' => True,
+ 'copy_org' => True,
+ 'delete_person' => True,
+ 'delete_org' => True,
+ 'java_script' => True,
+ 'css' => True
);
function uiaddressbook()
{
$GLOBALS['phpgw']->country =
CreateObject('phpgwapi.country');
$GLOBALS['phpgw']->browser =
CreateObject('phpgwapi.browser');
- $GLOBALS['phpgw']->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
- $this->fields = CreateObject('addressbook.uifields');
-
- $this->bo =
CreateObject('addressbook.boaddressbook',True);
- $this->contacts = CreateObject('phpgwapi.contacts');
- $this->cat = CreateObject('phpgwapi.categories');
- $this->company =
CreateObject('phpgwapi.categories','addressbook_company');
- $this->prefs =
$GLOBALS['phpgw_info']['user']['preferences']['addressbook'];
+ $this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
+ $this->custom_fields =
CreateObject('addressbook.uifields');
+ $this->bo =
CreateObject('addressbook.boaddressbook');
+ $this->template =
&$GLOBALS['phpgw']->template;
+ $this->cat =
CreateObject('phpgwapi.categories');
+ $this->company =
CreateObject('phpgwapi.categories','addressbook_company');
+ $this->prefs =
$GLOBALS['phpgw_info']['user']['preferences']['addressbook'];
+
+ $this->contact_type = $this->bo->contact_type;
+ $this->comm_descr = $this->bo->comm_descr;
+ $this->comm_type = $this->bo->comm_type;
+ $this->addr_type = $this->bo->addr_type;
+ $this->note_type = $this->bo->note_type;
+ $this->tab_main_persons =
$this->bo->tab_main_persons;
+ $this->tab_main_organizations =
$this->bo->tab_main_organizations;
+
+ $this->tab_person_data = lang('Person Data');
+ $this->tab_org_data = lang('Org Data');
+ $this->tab_orgs = lang('Orgs');
+ $this->tab_persons = lang('Persons');
+ $this->tab_cats = lang('Categories');
+ $this->tab_comms = lang('Communications');
+ $this->tab_address = lang('Address');
+ $this->tab_others = lang('Others');
+ $this->tab_extra = lang('More data');
$this->_set_sessiondata();
}
-
- function totpl()
- {
- if(@isset($this->output) && !empty($this->output))
- {
-
$GLOBALS['phpgw']->template->set_var('phpgw_body', $this->output,True);
- unset($this->output);
- }
- }
-
+
function _set_sessiondata()
{
$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;
- if($this->debug)
- {
- $this->_debug_sqsof();
- }
+ $this->qfield = $this->bo->qfield;
+
+ if($this->debug) { $this->_debug_sqsof(); }
}
function _debug_sqsof()
{
$data = array(
'start' => $this->start,
+ 'limit' => $this->limit,
'query' => $this->query,
- 'cquery' => $this->cquery,
'sort' => $this->sort,
'order' => $this->order,
'filter' => $this->filter,
- 'cat_id' => $this->cat_id
+ 'cat_id' => $this->cat_id,
+ 'qfield' => $this->qfield
);
echo '<br>UI:';
_debug_array($data);
@@ -110,1715 +157,3221 @@
{
$data = array(
'start' => $this->start,
+ 'limit' => $this->limit,
'query' => $this->query,
- 'cquery' => $this->cquery,
'sort' => $this->sort,
'order' => $this->order,
'filter' => $this->filter,
- 'cat_id' => $this->cat_id
+ 'cat_id' => $this->cat_id,
+ 'qfield' => $this->qfield
);
$this->bo->save_sessiondata($data);
}
- function
formatted_list($name,$list,$id='',$default=False,$java=False)
+ function index()
{
- if($java)
- {
- $jselect = ' onChange="this.form.submit();"';
- }
-
- $select = "\n" .'<select name="' . $name . '"' .
$jselect . ">\n";
- if($default)
+ if(get_var('section'))
{
- $select .= '<option value="">' . lang('Please
Select') . '</option>'."\n";
+ $this->section = get_var('section');
}
- while(list($key,$val) = each($list))
- {
- $select .= '<option value="' . $key . '"';
- if($key == $id && $id != '')
- {
- $select .= ' selected';
- }
- $select .= '>' . $val . '</option>'."\n";
- }
-
- $select .= '</select>'."\n";
- $select .= '<noscript><input type="submit" name="' .
$name . '_select" value="True"></noscript>' . "\n";
-
- 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)
- {
- if($java)
+ else
{
- $jselect = ' onChange="this.form.submit();"';
+ $this->section = $this->tab_main_persons;
}
- /* Setup all and none first */
- $cats_link = "\n" . '<select name="fcat_id' .
($multiple?'[]':'') . '"' . $jselect . ($multiple ? 'multiple size="3"' : '') .
">\n";
- if(!$notall)
+
+ switch ($this->filter)
{
- $cats_link .= '<option value=""';
- if($cat_id == 'all')
- {
- $cats_link .= ' selected';
- }
- $cats_link .= '>' . lang("all") .
'</option>'."\n";
- }
-
- /* Get global and app-specific category listings */
- $cats_link .=
$this->cat->formatted_list('select','all',$cat_id,True);
- $cats_link .= '</select>' . "\n";
- return $cats_link;
- }
-
- function remote_search_option()
- {
- $remote = CreateObject('addressbook.remote');
- $servers = $remote->servers;
- $search_remote = '';
+ case 'yours':
+ $this->access = PHPGW_CONTACTS_MINE;
+ break;
+ case 'private':
+ $this->access = PHPGW_CONTACTS_PRIVATE;
+ break;
+ default:
+ $this->access = PHPGW_CONTACTS_ALL;
+ }
+
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
+
+ $comms_array = array();
+
+ $this->template->set_file(array('addressbook_list_t' =>
'index.tpl'));
+
$this->template->set_block('addressbook_list_t','addressbook_header','addressbook_header');
+
$this->template->set_block('addressbook_list_t','column','column');
+
$this->template->set_block('addressbook_list_t','row','row');
+
$this->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
+
+ $this->template->set_file(array('principal_tabs' =>
'principal_tabs.tpl'));
+
$this->template->set_block('principal_tabs','principal_tab','principal_tab');
+ $this->template->set_block('principal_tabs',
'principal_button', 'principal_button');
- /* show search box and server dropdown */
- while(list($server,$data) = @each($servers))
+ if(!$this->start)
{
- $search_remote .= ' <option value="' .
$server . '"';
- if($server == $this->server)
- {
- $search_remote .= ' selected';
- }
- $search_remote .= '>' . $server . '</option>' .
"\n";
+ $this->start = 0;
}
- return $search_remote;
- }
-
- function remote_search()
- {
-// _debug_array($GLOBALS['HTTP_POST_VARS']);
- $remote =
CreateObject('addressbook.remote',$GLOBALS['HTTP_POST_VARS']['serverid']);
- $entries =
$remote->search($GLOBALS['HTTP_POST_VARS']['remote_query']);
- $this->index($entries);
- }
-
- /* 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'
- );
-
- if($abc[$column])
+
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] &&
+
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
{
- return lang($abc[$column]);
+ $this->limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
- return;
- }
-
- /*
- Former index.php
- */
- function index($entries='')
- {
-
$GLOBALS['phpgw']->template->set_file(array('addressbook_list_t' =>
'index.tpl'));
-
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_header','addressbook_header');
-
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','column','column');
-
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','row','row');
-
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','remsearch','remsearch');
-
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
-
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_alpha','addressbook_alpha');
-
- $aar = explode(',',lang('alphabet'));
- $aar[] = 'all';
- while(list(,$char) = @each($aar))
+ else
{
- if($this->cquery == $char ||
- ($char == 'all' && !$this->cquery))
- {
-
$GLOBALS['phpgw']->template->set_var('charbgcolor','#000000');
-
$GLOBALS['phpgw']->template->set_var('charcolor','#FFFFFF');
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('charbgcolor',$GLOBALS['phpgw_info']['theme']['th_bg']);
-
$GLOBALS['phpgw']->template->set_var('charcolor',$GLOBALS['phpgw_info']['theme']['th_text']);
- }
- if($char == 'all')
- {
-
$GLOBALS['phpgw']->template->set_var('charlink',
-
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index&cquery=')
- );
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('charlink',
-
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index&cquery='
. $char)
- );
- }
-
$GLOBALS['phpgw']->template->set_var('char',$char != 'all' ? strtoupper($char)
: lang('all'));
-
$GLOBALS['phpgw']->template->fp('alphalinks','addressbook_alpha',True);
+ $this->limit = 15;
}
-
- $custom = $this->fields->read_custom_fields();
- $customfields = array();
- while(list($x,$y) = @each($custom))
+
+ if(!isset($this->cat_id))
+ {
+ $this->cat_id =
$this->prefs['default_category'];
+ }
+
+ if($this->cat_id && $this->cat_id!=0)
{
- $customfields[$y['name']] = $y['name'];
- $namedfields[$y['name']] = $y['title'];
+ $category_filter = $this->cat_id;
}
-
- if(!$this->cat_id)
- {
- $this->cat_id =
$this->prefs['default_category'];
- }
- if($this->prefs['autosave_category'])
+ else
{
-
$GLOBALS['phpgw']->preferences->read_repository();
-
$GLOBALS['phpgw']->preferences->delete('addressbook','default_category');
-
$GLOBALS['phpgw']->preferences->add('addressbook','default_category',$this->cat_id);
-
$GLOBALS['phpgw']->preferences->save_repository();
+ $category_filter =
PHPGW_CONTACTS_CATEGORIES_ALL;
}
- /* $qfields = $contacts->stock_contact_fields +
$extrafields + $customfields; */
- /* create column list and the top row of the table
based on user prefs */
- while($column =
each($this->contacts->stock_contact_fields))
- {
- $test = strtolower($column[0]);
- if(isset($this->prefs[$test]) &&
$this->prefs[$test])
- {
- $showcol =
$this->display_name($column[0]);
- $cols .= ' <td height="21">' . "\n";
- $cols .= ' <font size="-1"
face="Arial, Helvetica, sans-serif">';
- $cols .=
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
-
$column[0],$this->order,'/index.php',$showcol,'&menuaction=addressbook.uiaddressbook.index');
- $cols .= "</font>\n </td>";
- $cols .= "\n";
+ $columns_to_display =
$this->bo->get_columns_to_display($this->section);
- /* To be used when displaying the rows
*/
- $columns_to_display[$column[0]] = True;
- }
- }
- /* Setup the columns for non-standard fields, since we
don't allow sorting */
- $nonstd = $this->extrafields + $customfields;
- while($column = each($nonstd))
+ if ($this->section == $this->tab_main_persons)
{
- $test = strtolower($column[1]);
- if(isset($this->prefs[$test]) &&
$this->prefs[$test])
- {
- $showcol =
$this->display_name($column[0]);
- /* This must be a custom field */
- if(!$showcol)
- {
- $showcol =
$namedfields[$column[1]];
- }
- $cols .= ' <td height="21">' . "\n";
- $cols .= ' <font size="-1"
face="Arial, Helvetica, sans-serif">';
- $cols .= $showcol;
- $cols .= "</font>\n </td>";
- $cols .= "\n";
+ //Check if both the main column array and the
comtype subarray
+ //are empty
+ if((!$columns_to_display &&
!is_array($columns_to_display))
+ ||
(count($columns_to_display['comm_types'])<1) && count($columns_to_display) == 1)
+ {
+ $noprefs=lang('Please set your
preferences for this application');
+ // FIXME: Default values here! this is
bad but is something
+ $columns_to_display = array(
+ 'per_first_name' =>
'per_first_name',
+ 'per_last_name' =>
'per_last_name',
+ 'per_department'=>'department',
+ 'per_title'=> 'title',
+ 'addr_add1'=>'address1',
+ 'addr_city'=>'city');
+ }
+ $this->edit_mode = 'edit_person';
+ $this->view_mode = 'view_person';
+ $count_function = 'get_count_persons';
+ $get_data_function = 'get_persons';
+
+
$this->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add_person'));
+
+ $search_obj=array('query' => $this->query,
+ 'search_obj' => array(
+ array('person',
'Person Data'),
+ array('comms',
'Communications Data'),
+ array('location',
'Locations Data'),
+ array('other', 'Other
Data'),
+ //array('note', 'Note
Data'),
+ ));
+ }
+ elseif ($this->section == $this->tab_main_organizations)
+ {
+ if(!$columns_to_display &&
!is_array($columns_to_display))
+ {
+ $noprefs=lang('Please set your
preferences for this application');
+ // FIXME: Default values here! this is
bad but is something
+ $columns_to_display = array(
+ 'org_name' => 'org_name');
+ }
+ $this->edit_mode = 'edit_org';
+ $this->view_mode = 'view_org';
+ $count_function = 'get_count_orgs';
+ $get_data_function = 'get_orgs';
+
+
$this->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add_org'));
+
+ $search_obj=array('query' => $this->query,
+ 'search_obj' => array(
+ array('org',
'Organization Data'),
+ array('comms',
'Communications Data'),
+ array('location',
'Locations Data'),
+ array('other', 'Other
Data'),
+ //array('note', 'Note
Data'),
+ ));
+ }
+
+ $comms_array =
$columns_to_display['comm_types']?$columns_to_display['comm_types']:array();
+ unset($columns_to_display['comm_types']);
+ $fields = array_keys($columns_to_display);
+
+ if(!in_array($this->order, $fields))
+ {
+ $this->order = (($this->section ==
$this->tab_main_organizations)
+ ? 'org_name'
+ : 'last_name');
+ }
+
+ $fields_comms = array_keys($comms_array);
+ $fields['owner']='owner';
+ $fields['contact_id']='contact_id';
+
+ $fields_search = $fields;
+ $fields_search['comm_media'] = $fields_comms;
+
+ $this->query = urldecode(addslashes($this->query));
+
+ //$criteria =
$this->bo->criteria_contacts($this->access, $category_filter, $fields_search,
$this->query);
+ $criteria = $this->bo->criteria_contacts($this->access,
$category_filter, $this->qfield, $this->query, $fields_search);
+ $total_all_persons =
$this->bo->$count_function($criteria);
+ $entries = $this->bo->$get_data_function($fields,
$this->limit, $this->start, $this->order, $this->sort, '', $criteria);
- /* To be used when displaying the rows
*/
- $columns_to_display[$column[0]] = True;
- }
- }
- /* Check if prefs were set, if not, create some
defaults */
- if(!$columns_to_display )
+ if(is_array($entries) && count($entries) > 0)
{
- $columns_to_display = array(
- 'n_given' => 'n_given',
- 'n_family' => 'n_family',
- 'org_name' => 'org_name'
- );
-// $columns_to_display = $columns_to_display +
$customfields;
- /* No prefs,. so cols above may have been set
to '' or a bunch of <td></td> */
- $cols='';
- while($column = each($columns_to_display))
+ if(count($fields_comms) > 0)
{
- $showcol =
$this->display_name($column[0]);
- if(!$showcol)
- {
- $showcol = $column[1];
- }
- $cols .= ' <td height="21">' . "\n";
- $cols .= ' <font size="-1"
face="Arial, Helvetica, sans-serif">';
- $cols .=
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
-
$column[0],$this->order,"/index.php",$showcol,'&menuaction=addressbook.uiaddressbook.index&cat_id='.$this->cat_id);
- $cols .= "</font>\n </td>";
- $cols .= "\n";
+ $this->entries_comm =
$this->bo->get_comm_contact_data(array_keys($entries), $fields_comms);
}
- $noprefs=lang('Please set your preferences for
this application');
- }
-
- if(!$this->start)
- {
- $this->start = 0;
- }
-
-
if($GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] &&
-
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'] > 0)
- {
- $limit =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
}
else
{
- $limit = 30;
- }
-
- /*global $filter; */
- if(empty($this->filter) || !isset($this->filter))
- {
- if($this->prefs['default_filter'])
- {
- $this->filter =
$this->prefs['default_filter'];
- $this->query = '';
- }
- else
- {
- $this->filter = 'none';
- }
+ $entries=array();
}
- /*
- Set qfilter to display entries where tid=n (normal
contact entry),
- else they may be accounts, etc.
- */
- $qfilter = 'tid=n';
- switch($this->filter)
- {
- case 'blank':
- $nosearch = True;
- break;
- case 'none':
- break;
- case 'private':
- $qfilter .= ',access=private'; /* fall
through */
- case 'yours':
- $qfilter .= ',owner=' .
$GLOBALS['phpgw_info']['user']['account_id'];
- break;
- default:
- $qfilter .= ',owner=' . $this->filter;
- }
- if($this->cat_id)
- {
- $qfilter .= ',cat_id='.$this->cat_id;
- }
-
- if(!$userid)
- {
- $userid =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $total_records = $this->bo->total;
+ $cols='';
+ while ($column = @each($columns_to_display))
+ {
+ $showcol = $this->bo->display_name($column[0]);
+
+ if (!$showcol) { $showcol = $column[1]; }
+ $cols .= '<td>';
+ $cols .=
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
+
$column[0],$this->order,"/index.php",$showcol,
+
'&menuaction=addressbook.uiaddressbook.index§ion='.$this->section.'&fcat_id='.$this->cat_id);
+ $cols .= '</td>';
+ $cols .= "\n";
+ }
+ //FIXME: NEeed to determine how are we going to handle
comm types translations
+ while ($column = @each($comms_array))
+ {
+ $showcol = $column[0];
+ $cols .= '<td>';
+ $cols .=
$GLOBALS['phpgw']->nextmatchs->show_sort_order($this->sort,
+
$column[0],$this->order,"/index.php",$showcol,
+
'&menuaction=addressbook.uiaddressbook.index§ion='.$this->section.'&fcat_id='.$this->cat_id);
+ $cols .= '</td>';
+ $cols .= "\n";
}
- if($nosearch && !$this->query && !$entries)
- {
- $entries = array();
- $total_records = 0;
- }
- elseif(!$entries)
+ /* set basic vars and parse the header */
+
//$this->template->set_var('principal_tab',$this->get_principal_tabs($this->section));
+
$this->get_principal_tabs('menuaction=addressbook.uiaddressbook.index§ion='.$this->tab_main_persons,
+
$this->get_class_css($this->tab_main_persons, $this->section),
+ 'principal_persons',
$this->tab_main_persons);
+
$this->get_principal_tabs('menuaction=addressbook.uiaddressbook.index§ion='.$this->tab_main_organizations,
+
$this->get_class_css($this->tab_main_organizations, $this->section),
+ 'principal_orgs',
$this->tab_main_organizations);
+
+ /* global here so nextmatchs accepts our setting of
$query and $filter */
+ $GLOBALS['query'] = $this->query;
+ $GLOBALS['filter'] = $this->filter;
+
+ $search_filter = $this->nextmatchs->show_tpl(
+ '/index.php', $this->start, $total_all_persons,
+
'menuaction=addressbook.uiaddressbook.index§ion='.$this->section,
+ '90%', $GLOBALS['phpgw_info']['theme']['th_bg'],
+
$search_obj,1,True,array('filter'=>$this->filter,'yours'=>1),$this->cat_id);
+ $query = $filter = '';
+
+ if($this->query)
{
- /* read the entry list */
- $entries = $this->bo->read_entries(array(
- 'start' => $this->start,
- 'limit' => $limit,
- 'fields' => $columns_to_display,
- 'filter' => $qfilter,
- 'query' => $this->query,
- 'cquery' => $this->cquery,
- 'sort' => $this->sort,
- 'order' => $this->order
- ));
- $total_records = $this->bo->total;
-
$GLOBALS['phpgw']->template->set_var('lang_view',lang('View'));
+ $lang_showing = lang('%1 was found %2 times in
%3',htmlentities('"'.$this->query.'"'), $total_all_persons,
lang($this->section));
}
else
{
- $total_records = count($entries);
-
$GLOBALS['phpgw']->template->set_var('lang_view',lang('Add'));
- $showadd = True;
- }
-
- $search_filter =
$GLOBALS['phpgw']->nextmatchs->show_tpl('/index.php',
- $this->start,
$total_records,'&menuaction=addressbook.uiaddressbook.index&fcat_id='.$this->cat_id,'75%',
-
$GLOBALS['phpgw_info']['theme']['th_bg'],1,1,1,1,$this->cat_id);
+ //$lang_showing =
$GLOBALS['phpgw']->nextmatchs->show_hits($total_records,$this->start);
+ $lang_showing = lang('%1 - %2 of %3 %4',
+
($total_records!=0)?$this->start+1:$this->start,
+
$this->start+$total_records,$total_all_persons,lang($this->section));
+ }
+
+
+ $this->template->set_var('principal_tabs_inc',
$this->template->fp('out', 'principal_tab'));
+
+
$this->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
+ $this->template->set_var('lang_view',lang('View'));
+ $this->template->set_var('lang_vcard',lang('VCard'));
+ $this->template->set_var('lang_edit',lang('Edit'));
+ $this->template->set_var('lang_owner',lang('Owner'));
+
+ $this->template->set_var('searchreturn',$noprefs . ' '
. $searchreturn);
+ $this->template->set_var('lang_showing',$lang_showing);
+
$this->template->set_var('search_filter',$search_filter);
+ $this->template->set_var('cats',lang('Category'));
+
$this->template->set_var('cats_url',$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$this->section));
+ /*
$this->template->set_var('cats_link',$this->cat_option($this->cat_id)); */
+ $this->template->set_var('lang_cats',lang('Select'));
+//
$this->template->set_var('lang_addressbook',lang('Address book'));
+
$this->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
+
$this->template->set_var('th_font',$GLOBALS['phpgw_info']['theme']['font']);
+
$this->template->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']);
+ $this->template->set_var('lang_add',lang('Add'));
+
$this->template->set_var('lang_cat_cont',lang('Categorize'));
+ $this->template->set_var('cat_cont_url',
$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uicategorize_contacts.index'));
+
+
$this->template->set_var('lang_addvcard',lang('AddVCard'));
+
$this->template->set_var('vcard_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.in'));
+ $this->template->set_var('lang_import',lang('Import
Contacts'));
+
$this->template->set_var('import_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.import'));
+ $this->template->set_var('lang_import_alt',lang('Alt.
CSV Import'));
+
$this->template->set_var('import_alt_url',$GLOBALS['phpgw']->link('/addressbook/csv_import.php'));
+ $this->template->set_var('lang_export',lang('Export
Contacts'));
+
$this->template->set_var('export_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export'));
+
+ $export_vars =
array('get_data_function'=>$get_data_function,
+ 'fields'=>$fields,
+ 'limit'=>$this->limit,
+ 'start'=>$this->start,
+
'order'=>($this->order?$this->order:''),
+
'sort'=>($this->sort?$this->sort:''),
+ 'criteria'=>$criteria,
+ 'fields_comms'=>$fields_comms,
+
'category_filter'=>$category_filter);
+
$GLOBALS['phpgw']->session->appsession('export_vars','addressbook',
$export_vars);
+
+ $this->template->set_var('start',$this->start);
+ $this->template->set_var('sort',$this->sort);
+ $this->template->set_var('order',$this->order);
+ $this->template->set_var('filter',$this->filter);
+ $this->template->set_var('query',$this->query);
+ $this->template->set_var('cat_id',$this->cat_id);
- $lang_showing =
$GLOBALS['phpgw']->nextmatchs->show_hits($total_records,$this->start);
+ $this->template->set_var('qfield',$qfield);
+ $this->template->set_var('cols',$cols);
- /* set basic vars and parse the header */
-
$GLOBALS['phpgw']->template->set_var('font',$GLOBALS['phpgw_info']['theme']['font']);
-
$GLOBALS['phpgw']->template->set_var('row_on',$GLOBALS['phpgw_info']['theme']['row_on']);
-//
$GLOBALS['phpgw']->template->set_var('lang_view',lang('View'));
-
$GLOBALS['phpgw']->template->set_var('lang_vcard',lang('VCard'));
-
$GLOBALS['phpgw']->template->set_var('lang_edit',lang('Edit'));
-
$GLOBALS['phpgw']->template->set_var('lang_owner',lang('Owner'));
-
$GLOBALS['phpgw']->template->set_var('lang_go',lang('Go'));
-
-
$GLOBALS['phpgw']->template->set_var('searchreturn',$noprefs . ' ' .
$searchreturn);
-
$GLOBALS['phpgw']->template->set_var('lang_showing',$lang_showing);
-
$GLOBALS['phpgw']->template->set_var('search_filter',$search_filter);
-
$GLOBALS['phpgw']->template->set_var('cats',lang('Category'));
-
$GLOBALS['phpgw']->template->set_var('cats_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- /*
$GLOBALS['phpgw']->template->set_var('cats_link',$this->cat_option($this->cat_id));
*/
-
$GLOBALS['phpgw']->template->set_var('lang_cats',lang('Select'));
-
$GLOBALS['phpgw']->template->set_var('lang_addressbook',lang('Address book'));
-
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
-
$GLOBALS['phpgw']->template->set_var('th_font',$GLOBALS['phpgw_info']['theme']['font']);
-
$GLOBALS['phpgw']->template->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']);
-
$GLOBALS['phpgw']->template->set_var('lang_add',lang('Add'));
-
$GLOBALS['phpgw']->template->set_var('add_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.add'));
-
$GLOBALS['phpgw']->template->set_var('lang_addvcard',lang('AddVCard'));
-
$GLOBALS['phpgw']->template->set_var('vcard_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.in'));
-
$GLOBALS['phpgw']->template->set_var('lang_import',lang('Import Contacts'));
-
$GLOBALS['phpgw']->template->set_var('import_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.import'));
-
$GLOBALS['phpgw']->template->set_var('lang_import_alt',lang('Alt. CSV Import'));
-
$GLOBALS['phpgw']->template->set_var('import_alt_url',$GLOBALS['phpgw']->link('/addressbook/csv_import.php'));
-
$GLOBALS['phpgw']->template->set_var('lang_export',lang('Export Contacts'));
-
$GLOBALS['phpgw']->template->set_var('export_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiXport.export'));
-
-
$GLOBALS['phpgw']->template->set_var('start',$this->start);
-
$GLOBALS['phpgw']->template->set_var('sort',$this->sort);
-
$GLOBALS['phpgw']->template->set_var('order',$this->order);
-
$GLOBALS['phpgw']->template->set_var('filter',$this->filter);
-
$GLOBALS['phpgw']->template->set_var('query',$this->query);
-
$GLOBALS['phpgw']->template->set_var('cat_id',$this->cat_id);
-
- $GLOBALS['phpgw']->template->set_var('qfield',$qfield);
- $GLOBALS['phpgw']->template->set_var('cols',$cols);
-
-
if(@isset($GLOBALS['phpgw_info']['server']['enable_remote_addressbook']))
- {
-
$GLOBALS['phpgw']->template->set_var('remote_search',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.remote_search'));
-
$GLOBALS['phpgw']->template->set_var('remote_query',$GLOBALS['HTTP_POST_VARS']['remote_query']);
-
$GLOBALS['phpgw']->template->set_var('lang_remote_search',lang('Remote
Search'));
-
$GLOBALS['phpgw']->template->set_var('search_remote',$this->remote_search_option());
-
$GLOBALS['phpgw']->template->fp('remotesearch','remsearch');
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('remotesearch','');
- }
- $this->output .=
$GLOBALS['phpgw']->template->parse('out','addressbook_header');
+ $this->template->pparse('out','addressbook_header');
/* Show the entries */
/* each entry */
- for($i=0;$i<count($entries);$i++)
+
+ $all_cols_to_display = array_merge($columns_to_display,
$comms_array);
+
+ foreach($entries as $entry)
{
-
$GLOBALS['phpgw']->template->set_var('columns','');
+ $this->template->set_var('columns','');
$tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
-
$GLOBALS['phpgw']->template->set_var('row_tr_color',$tr_color);
- $myid = $entries[$i]['id'];
- $myowner = $entries[$i]['owner'];
+
$this->template->set_var('row_tr_color',$tr_color);
+ $myid = $entry['contact_id'];
+ $myowner = $entry['owner'];
/* each entry column */
- @reset($columns_to_display);
- while($column = @each($columns_to_display))
+ @reset($all_cols_to_display);
+ while ($column = @each(($all_cols_to_display)))
{
- $ref = $data = '';
- $coldata = $entries[$i][$column[0]];
- /* echo '<br>coldata="' . $coldata .
'"'; */
- /* Some fields require special
formatting. */
- if($column[0] == 'url')
- {
- if(!empty($coldata) &&
(substr($coldata,0,7) != 'http://'))
- {
- $coldata = 'http://' .
$coldata;
- }
- $ref = '<a href="' . $coldata
. '" target="_new">';
- $data = $coldata . '</a>';
- }
- elseif(($column[0] == 'email') ||
($column[0] == 'email_home'))
- {
-
if($GLOBALS['phpgw_info']['user']['apps']['email'])
+ $ref = $data='';
+ $coldata = $entry[$column[key]];
+ if(in_array($column[key],
$fields_comms))
+ {
+ $data =
$this->get_comm_value($myid, $column[key]);
+ $data = htmlentities($data);
+ if(strpos($column[key],
'email'))
{
- $ref = '<a href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uicompose.compose&to=' .
urlencode($coldata)) . '" target="_new">';
+ if
($GLOBALS['phpgw_info']['user']['apps']['email'])
+ {
+ $ref='<a
href="'.$GLOBALS['phpgw']->link(
+
"/email/compose.php","to="
+ .
urlencode($data))
+ .'"
target="_new">';
+ }
+ else
+ {
+ $ref='<a
href="mailto:'.$data.'">';
+ }
+ $data=$data . '</a>';
}
- else
+ if($column[key]=='website')
{
- $ref = '<a
href="mailto:'.$coldata.'">';
+ if ( !empty($data) &&
(substr($data,0,7) != 'http://') ) { $data = 'http://' . $data; }
+ $ref='<a
href="'.$data.'" target="_new">';
+ $data=$data.'</a>';
}
- $data = $coldata . '</a>';
}
- else /* But these do not */
+ else
{
- $ref = '';
- $data = $coldata;
+ $ref = ''; $data =
htmlentities($coldata);
}
-
$GLOBALS['phpgw']->template->set_var('col_data',$ref . $data);
-
$GLOBALS['phpgw']->template->parse('columns','column',True);
- }
-
- if(!$showadd)
- {
-
$GLOBALS['phpgw']->template->set_var('row_view_link',$GLOBALS['phpgw']->link('/index.php',
-
'menuaction=addressbook.uiaddressbook.view&ab_id=' . $entries[$i]['id']));
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('row_view_link',$GLOBALS['phpgw']->link('/index.php',
-
'menuaction=addressbook.uiaddressbook.addfromremote&fields=' .
urlencode(serialize($entries[$i]))));
-//
$GLOBALS['phpgw']->template->set_var('lang_view',lang('Add'));
- }
-
-
$GLOBALS['phpgw']->template->set_var('row_vcard_link',$GLOBALS['phpgw']->link('/index.php',
-
'menuaction=addressbook.uivcard.out&ab_id='.$entries[$i]['id']));
-
- /* echo '<br>: ' . $contacts->grants[$myowner]
. ' - ' . $myowner; */
-
if($this->contacts->check_perms($this->contacts->grants[$myowner],PHPGW_ACL_EDIT)
||
- $myowner ==
$GLOBALS['phpgw_info']['user']['account_id'])
- {
-
$GLOBALS['phpgw']->template->set_var('row_edit','<a href="' .
$GLOBALS['phpgw']->link('/index.php',
-
'menuaction=addressbook.uiaddressbook.edit&ab_id='.$entries[$i]['id']) . '">' .
lang('Edit') . '</a>');
+
$this->template->set_var('col_data',$ref.$data);
+
$this->template->parse('columns','column',True);
}
+
$this->template->set_var('row_view_link',$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.' . $this->view_mode
+
.'&ab_id='.$entry['contact_id']));
+
$this->template->set_var('row_vcard_link',$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uivcard.out&ab_id='.$entry['contact_id']));
+
+ if($this->bo->check_edit($entry['contact_id'],
$myowner))
+ {
+ $this->template->set_var('row_edit','<a
href="' . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.' . $this->edit_mode
+ .
'&ab_id='.$entry['contact_id']) . '">' . lang('Edit') . '</a>');
+ }
else
{
-
$GLOBALS['phpgw']->template->set_var('row_edit',' ');
+
$this->template->set_var('row_edit',' ');
}
-
$GLOBALS['phpgw']->template->set_var('row_owner',$GLOBALS['phpgw']->accounts->id2name($myowner));
-
-
$GLOBALS['phpgw']->template->parse('rows','row',True);
- $this->output .=
$GLOBALS['phpgw']->template->fp('out','row');
- reset($columns_to_display);
+
$this->template->set_var('row_owner',$GLOBALS['phpgw']->accounts->id2name($myowner));
+ $this->template->parse('rows','row',True);
+ $this->template->pparse('out','row');
}
-
- $this->output .=
$GLOBALS['phpgw']->template->fp('out','addressbook_footer');
+
+ $this->template->pparse('out','addressbook_footer');
$this->save_sessiondata();
- $this->totpl();
+ /* $GLOBALS['phpgw']->common->phpgw_footer(); */
}
- function add_email()
- {
- $name = $GLOBALS['HTTP_POST_VARS']['name'] ?
$GLOBALS['HTTP_POST_VARS']['name'] : $GLOBALS['HTTP_GET_VARS']['name'];
- $referer = $GLOBALS['HTTP_POST_VARS']['referer'] ?
$GLOBALS['HTTP_POST_VARS']['referer'] : $GLOBALS['HTTP_GET_VARS']['referer'];
- $add_email = $GLOBALS['HTTP_POST_VARS']['add_email'] ?
$GLOBALS['HTTP_POST_VARS']['add_email'] :
$GLOBALS['HTTP_GET_VARS']['add_email'];
-
- $named = explode(' ', $name);
- for($i=count($named);$i>=0;$i--)
- {
- $names[$i] = $named[$i];
- }
- if($names[2])
- {
- $fields['n_given'] = $names[0];
- $fields['n_middle'] = $names[1];
- $fields['n_family'] = $names[2];
- }
- else
- {
- $fields['n_given'] = $names[0];
- $fields['n_family'] = $names[1];
- }
- $fields['n_given'] = $fields['n_given'] ?
$fields['n_given'] : ' ';
- $fields['n_family'] = $fields['n_family'] ?
$fields['n_family'] : ' ';
- $fields['fn'] = $fields['n_given'] . ' ' .
$fields['n_family'];
- $fields['email'] = $add_email;
- $fields['access'] = 'private';
- $fields['tid'] = 'n';
- $referer = urlencode($referer);
+ /*************************************************************\
+ * Deprecated functions section *
+ \*************************************************************/
- $fields['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
-// _debug_array($fields);exit;
- $this->bo->add_entry($fields);
- $ab_id = $this->bo->get_lastid();
+ function add()
+ {
+ $this->add_person();
+ }
- Header('Location: '
- .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $ab_id . '&referer=' . $referer));
+ function edit()
+ {
+ $this->edit_person();
}
function copy()
{
- $addnew = $this->bo->read_entry(array('id' =>
$GLOBALS['ab_id'], 'fields' => $this->contacts->stock_contact_fields));
-
- $addnew[0]['note'] .= "\nCopied from " .
$GLOBALS['phpgw']->accounts->id2name($addnew[0]['owner']).", record
#".$addnew[0]['id'].'.';
- $addnew[0]['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
- unset($addnew[0]['id']);
- $fields = $addnew[0];
-
- $ab_id = $this->bo->add_entry($fields);
-
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.edit&ab_id='
. $ab_id));
+ $contact_id = get_var('ab_id');
+ $new_contact_id = $this->bo->copy_contact($contact_id);
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.edit_person&ab_id='.$new_contact_id));
}
- function addfromremote()
+ /*************************************************************\
+ * Person Functions Section *
+ \*************************************************************/
+
+ /**
+ * Add Person Enviromet, this controls all process to add a
person
+ *
+ * @param
+ * @return
+ */
+ function add_person()
{
- $fields = get_var('fields',array('GET'));
- $fields = stripslashes(urldecode($fields));
- $fields = unserialize($fields);
- $fields['note'] = "\nCopied from remote search.";
- $ab_id = $this->bo->add_entry($fields);
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.edit&ab_id='
. $ab_id));
+ //set some variables which will be used
+ $this->mode = 'add';
+ $this->section = $this->tab_main_persons;
+ $this->form_action =
'menuaction=addressbook.uiaddressbook.add_person';
+ $this->form_index =
'menuaction=addressbook.uiaddressbook.index§ion='.$this->section;
+ //get all vars which was send in post or get
+ $this->get_vars();
+
+ //check if is the first time that get into edit
+ if($this->firsttime)
+ {
+ $this->entry = '';
+ $this->clear_tab_session();
+ $this->load_tabs('cache');
+ }
+
+ //validate if add/edit/delete functions would be run
+ $this->managment_functions($this->action);
+
+ //save the old tab data
+
$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
+
+ //if not exist tab selected use as defaul person_data
+ if(!$this->tab)
+ {
+ $this->tab = $this->tab_person_data;
+ }
+
+ //evaluate the submit action
+ switch($this->submit)
+ {
+ case 'save':
+ $fields = $this->get_all_entry();
+
+ $fields['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+ $ab_id = $this->bo->add_person($fields);
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.view_person&ab_id='
+ .$ab_id
.'&referer='.$this->referer));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ break;
+ case 'cancel':
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
$this->form_index));
+ break;
+ case 'delete':
+ break;
+ case 'clear':
+ $this->entry = '';
+ $this->clear_tab_session();
+ //$this->load_tabs();
+ break;
+ }
+
+ //read the current tab information
+ $this->entry = $this->read_tab_session($this->tab);
+
+ //start to draw the add window
+// $GLOBALS['phpgw']->common->phpgw_header();
+// echo parse_navbar();
+
+ //draw the tabs and detail form
+ $this->entry['old_tab'] = $this->tab;
+ $this->main_form($this->entry, $this->section,
$this->tab);
}
- function add()
+ /**
+ * Edit Person Enviromet, this controls all process to edit a
person
+ *
+ * @param
+ * @return
+ */
+ function edit_person()
{
- if($GLOBALS['HTTP_POST_VARS']['submit'])
+ //set some variables which will be used
+ $this->mode = 'edit';
+ $this->section = $this->tab_main_persons;
+ $this->form_action =
'menuaction=addressbook.uiaddressbook.edit_person';
+ $this->form_index =
'menuaction=addressbook.uiaddressbook.index§ion='.$this->section;
+
+ //get all vars which was send in post or get
+ $this->get_vars();
+
+ //check if is the first time that get into edit
+ if($this->firsttime)
{
- $fields = $this->get_form();
+ $this->entry = '';
+ $this->clear_tab_session();
+ $this->load_tabs('db');
+ }
+
+ //validate if add/edit/delete functions would be run
+ $this->managment_functions($this->action);
+
+ //save the old tab data
+
$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
- $referer = urlencode($fields['referer']);
- unset($fields['referer']);
- $fields['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+ //if not exist tab selected use as defaul person_data
+ if(!$this->tab)
+ {
+ $this->tab = $this->tab_person_data;
+ }
- $this->bo->add_entry($fields);
+ //evaluate the submit action
+ switch($this->submit)
+ {
+ case 'save':
+ $fields = $this->get_all_entry();
- $ab_id = $this->bo->get_lastid();
- $GLOBALS['ab_id'] = $ab_id;
-
$GLOBALS['phpgw']->hooks->process('addressbook_save');
+ $fields['owner'] = $this->owner;
+ $this->bo->edit_person($this->contact_id,
$fields);
+
Header('Location: '
- .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $ab_id . '&referer=' . $referer));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.view_person&ab_id='
+
.$this->contact_id .'&referer='.$this->referer));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ break;
+ case 'cancel':
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
$this->form_index));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ break;
+ case 'delete':
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.delete_person&ab_id='.$this->contact_id));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ //$this->delete_person($this->contact_id);
+ break;
+ case 'clear':
+ $this->entry = '';
+ $this->clear_tab_session();
+ break;
}
- $GLOBALS['phpgw']->template->set_file(array('add' =>
'add.tpl'));
+ //read the current tab information
+ $this->entry = $this->read_tab_session($this->tab);
- $custom = $this->fields->read_custom_fields();
- $customfields = array();
- while(list($x,$y) = @each($custom))
+ /* First, make sure they have permission to this entry
*/
+ $this->owner =
$this->entry['owner']?$this->entry['owner']:$this->owner;
+ if(!$this->bo->check_edit($this->contact_id,
$this->owner))
{
- $customfields[$y['name']] = $y['title'];
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php', $this->form_index));
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
-
$this->addressbook_form('','menuaction=addressbook.uiaddressbook.add','Add','',$customfields,$this->cat_id);
+ //start to draw the add window
+// $GLOBALS['phpgw']->common->phpgw_header();
+// echo parse_navbar();
-
$GLOBALS['phpgw']->template->set_var('lang_ok',lang('ok'));
-
$GLOBALS['phpgw']->template->set_var('lang_clear',lang('clear'));
-
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
-
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- $this->output .=
$GLOBALS['phpgw']->template->parse('out','add');
- $this->output .=
$GLOBALS['phpgw']->template->parse('out','add');
- $this->totpl();
- $GLOBALS['phpgw']->hooks->process('addressbook_add');
+ //draw the tabs and detail form
+ $this->entry['old_tab'] = $this->tab;
+ $this->main_form($this->entry, $this->section,
$this->tab);
}
- function edit()
+ /**
+ * Delete persons from db
+ *
+ * @param
+ * @return
+ */
+ function delete_person($person_id='')
{
- if($GLOBALS['HTTP_POST_VARS']['submit'])
+ if($person_id=='')
{
- $_fields = $this->get_form();
- /* _debug_array($_fields);exit; */
- $check = $this->bo->read_entry(array('id' =>
$_fields['ab_id'], 'fields' => array('owner' => 'owner','tid' => 'tid')));
-
- if(($this->contacts->grants[$check[0]['owner']]
& PHPGW_ACL_EDIT) &&
- $check[0]['owner'] !=
$GLOBALS['phpgw_info']['user']['account_id'])
- {
- $userid = $check[0]['owner'];
- }
- else
- {
- $userid =
$GLOBALS['phpgw_info']['user']['account_id'];
- }
- $_fields['owner'] = $userid;
- $referer = urlencode($_fields['referer']);
- unset($_fields['referer']);
-
- $this->bo->update_entry($_fields);
- $GLOBALS['ab_id'] = $_fields['ab_id'];
-
$GLOBALS['phpgw']->hooks->process('addressbook_save');
+ $person_id = get_var('ab_id');
+ }
+ $this->delete_contact($person_id,
$this->tab_main_persons);
+ }
- Header('Location: '
- .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $_fields['ab_id'] . '&referer=' . $referer)
- );
+ /**
+ * Viwe all persons data from db
+ *
+ * @param
+ * @return
+ */
+ function view_person()
+ {
+ $person_id = get_var('ab_id');
+ $referer = get_var('referer');
+ $this->view_contact($person_id,
$this->tab_main_persons, $referer);
+ }
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
- }
+ /**
+ * Copy all data from a person to new person
+ *
+ * @param
+ * @return
+ */
+ function copy_person()
+ {
+ $contact_id = get_var('ab_id');
+ $new_contact_id = $this->bo->copy_contact($contact_id);
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.edit_person&ab_id='.$new_contact_id));
+ }
- /* First, make sure they have permission to this entry
*/
- $check = $this->bo->read_entry(array('id' =>
$GLOBALS['HTTP_GET_VARS']['ab_id'], 'fields' => array('owner' => 'owner','tid'
=> 'tid')));
+ /*************************************************************\
+ * Organizations Functions Section *
+ \*************************************************************/
+
+ /**
+ * Add Organization Enviromet, this controls all process to add
orgs
+ *
+ * @param
+ * @return
+ */
+ function add_org()
+ {
+ //set some variables which will be used
+ $this->mode = 'add';
+ $this->section = $this->tab_main_organizations;
+ $this->form_action =
'menuaction=addressbook.uiaddressbook.add_org';
+ $this->form_index =
'menuaction=addressbook.uiaddressbook.index§ion='.$this->section;
+ //get all vars which was send in post or get
+ $this->get_vars();
-
if(!$this->contacts->check_perms($this->contacts->grants[$check[0]['owner']],PHPGW_ACL_EDIT)
&&
- ($check[0]['owner'] !=
$GLOBALS['phpgw_info']['user']['account_id']))
+ //check if is the first time that get into edit
+ if($this->firsttime)
{
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $this->entry = '';
+ $this->clear_tab_session();
+ $this->load_tabs('cache');
}
- /* Read in user custom fields, if any */
- $custom = $this->fields->read_custom_fields();
- $customfields = array();
- while(list($x,$y) = @each($custom))
+ //validate if add/edit/delete functions would be run
+ $this->managment_functions($this->action);
+
+ //save the old tab data
+
$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
+
+ //if not exist tab selected use as defaul person_data
+ if(!$this->tab)
{
- $customfields[$y['name']] = $y['title'];
+ $this->tab = $this->tab_org_data;
}
- /* merge in extra fields */
- $qfields = $this->contacts->stock_contact_fields +
$this->extrafields + $customfields;
- $fields = $this->bo->read_entry(array('id' =>
$GLOBALS['HTTP_GET_VARS']['ab_id'], 'fields' => $qfields));
+ //evaluate the submit action
+ switch($this->submit)
+ {
+ case 'save':
+ $fields = $this->get_all_entry();
+
+ $fields['tab_person_data']['owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $ab_id = $this->bo->add_org($fields);
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.view_org&ab_id='.$ab_id));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ break;
+ case 'cancel':
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
$this->form_index));
+ break;
+ case 'delete':
+ break;
+ case 'clear':
+ $this->entry = '';
+ $this->clear_tab_session();
+ break;
+ }
+
+ //read the current tab information
+ $this->entry = $this->read_tab_session($this->tab);
+
+ //start to draw the add window
+// $GLOBALS['phpgw']->common->phpgw_header();
+// echo parse_navbar();
+
+ //draw the tabs and detail form
+ $this->entry['old_tab'] = $this->tab;
+ $this->main_form($this->entry, $this->section,
$this->tab);
+ }
+
+ /**
+ * Edit Organization Enviromet, this controls all process to add
orgs
+ *
+ * @param
+ * @return
+ */
+ function edit_org()
+ {
+ //set some variables which will be used
+ $this->mode = 'edit';
+ $this->section = $this->tab_main_organizations;
+ $this->form_action =
'menuaction=addressbook.uiaddressbook.edit_org';
+ $this->form_index =
'menuaction=addressbook.uiaddressbook.index§ion='.$this->section;
+
+ //get all vars which was send in post or get
+ $this->get_vars();
+
+ //check if is the first time that get into edit
+ if($this->firsttime)
+ {
+ $this->entry = '';
+ $this->clear_tab_session();
+ $this->load_tabs('db');
+ }
+
+ //validate if add/edit/delete functions would be run
+ $this->managment_functions($this->action);
+
+ //save the old tab data
+
$this->save_tab_session(stripslashes($this->entry['old_tab']), $this->entry);
+
+ //if not exist tab selected use as defaul person_data
+ if(!$this->tab)
+ {
+ $this->tab = $this->tab_org_data;
+ }
+
+ //evaluate the submit action
+ switch($this->submit)
+ {
+ case 'save':
+ $fields = $this->get_all_entry();
+
+ $fields['owner'] = $this->owner;
-
$this->addressbook_form('edit','menuaction=addressbook.uiaddressbook.edit',lang('Edit'),$fields[0],$customfields);
+ $this->bo->edit_org($this->contact_id, $fields);
- $GLOBALS['phpgw']->template->set_file(array('edit' =>
'edit.tpl'));
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.view_org&ab_id='.$this->contact_id));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ break;
+ case 'cancel':
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
$this->form_index));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ break;
+ case 'delete':
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.delete_org&ab_id='.$this->contact_id));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ //his->delete_person($this->contact_id);
+ break;
+ case 'clear':
+ $this->entry = '';
+ $this->clear_tab_session();
+ $this->load_tabs('db');
+ break;
+ }
+
+ //read the current tab information
+ $this->entry = $this->read_tab_session($this->tab);
-
$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']['theme']['th_bg']);
-
$GLOBALS['phpgw']->template->set_var('ab_id',$GLOBALS['HTTP_GET_VARS']['ab_id']);
-
$GLOBALS['phpgw']->template->set_var('tid',$check[0]['tid']);
-
$GLOBALS['phpgw']->template->set_var('referer',$referer);
-
$GLOBALS['phpgw']->template->set_var('lang_ok',lang('ok'));
-
$GLOBALS['phpgw']->template->set_var('lang_clear',lang('clear'));
-
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
-
$GLOBALS['phpgw']->template->set_var('lang_submit',lang('submit'));
-
$GLOBALS['phpgw']->template->set_var('cancel_link','<form method="POST"
action="'
- .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')
. '">');
+ /* First, make sure they have permission to this entry
*/
+ $this->owner =
$this->entry['owner']?$this->entry['owner']:$this->owner;
+ if(!$this->bo->check_edit($this->contact_id,
$this->owner))
+ {
+ Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php', $this->form_index));
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
- if(($this->contacts->grants[$check[0]['owner']] &
PHPGW_ACL_DELETE) ||
- $check[0]['owner'] ==
$GLOBALS['phpgw_info']['user']['account_id'])
+ //start to draw the add window
+// $GLOBALS['phpgw']->common->phpgw_header();
+// echo parse_navbar();
+
+ //draw the tabs and detail form
+ $this->entry['old_tab'] = $this->tab;
+ $this->main_form($this->entry, $this->section,
$this->tab);
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
+
+ /**
+ * Delete Organization
+ *
+ * @param
+ * @return
+ */
+ function delete_org($org_id='')
+ {
+ if($org_id=='')
{
-
$GLOBALS['phpgw']->template->set_var('delete_link','<form method="POST"
action="'.$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete')
. '">');
-
$GLOBALS['phpgw']->template->set_var('delete_button','<input type="submit"
name="delete" value="' . lang('Delete') . '">');
+ $org_id = get_var('ab_id');
}
+ $this->delete_contact($org_id,
$this->tab_main_organizations);
+ }
- $this->output .=
$GLOBALS['phpgw']->template->fp('out','edit');
- $this->totpl();
- $GLOBALS['phpgw']->hooks->process('addressbook_edit');
+ /**
+ * View Organization
+ *
+ * @param
+ * @return
+ */
+ function view_org()
+ {
+ $org_id = get_var('ab_id');
+ $referer = get_var('referer');
+ $this->view_contact($org_id,
$this->tab_main_organizations, $referer);
}
- function delete()
+ /**
+ * Copy Organization
+ *
+ * @param
+ * @return
+ */
+ function copy_org()
{
- $ab_id = $GLOBALS['HTTP_POST_VARS']['entry']['ab_id'] ?
$GLOBALS['HTTP_POST_VARS']['entry']['ab_id'] :
$GLOBALS['HTTP_POST_VARS']['ab_id'];
- $confirm = $GLOBALS['HTTP_GET_VARS']['confirm'] ?
$GLOBALS['HTTP_GET_VARS']['confirm'] :$GLOBALS['HTTP_POST_VARS']['confirm'];
- if(!$ab_id)
- {
- $ab_id = $GLOBALS['HTTP_GET_VARS']['ab_id'];
// else plain Link in delete does not work
- }
- if(!$ab_id)
- {
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- }
+ $contact_id = get_var('ab_id');
+ $new_contact_id = $this->bo->copy_contact($contact_id);
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.edit_org&ab_id='.$new_contact_id));
+ }
+
+ /*************************************************************\
+ * Drawing Windows Functions Section
*
+ \*************************************************************/
+
+ /**
+ * Start to draw the html screens
+ *
+ * @param
+ * @return
+ */
+ function main_form($fields, $section, $form_tab)
+ {
+ $this->jscal = CreateObject('phpgwapi.jscalendar');
// before phpgw_header() !!!
- $check = $this->bo->read_entry(array('id' => $ab_id,
'fields' => array('owner' => 'owner','tid' => 'tid')));
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
- if(!(($this->contacts->grants[$check[0]['owner']] &
PHPGW_ACL_DELETE) ||
- $check[0]['owner'] ==
$GLOBALS['phpgw_info']['user']['account_id']))
+ //print 'fields:<br>';
+ $js_submit = '';
+ $fields['owner'] =
$fields['owner']?$fields['owner']:$this->owner;
+ if ($this->bo->check_delete($this->contact_id))
{
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ $delete = '<input type="submit" name="delete"
value="' . lang('Delete') . '">';
}
- $GLOBALS['phpgw']->template->set_file(array('delete' =>
'delete.tpl'));
+ $this->template->set_file(array('form' => 'form.tpl'));
+
+ $this->template->set_file(array('tabs' => 'tab.tpl'));
+ $this->template->set_block('tabs','tab','tab');
+ $this->template->set_block('tabs', 'button', 'button');
- if($confirm != 'true')
+ if ($this->mode == 'add')
{
-
$GLOBALS['phpgw']->template->set_var('lang_sure',lang('Are you sure you want to
delete this entry ?'));
-
$GLOBALS['phpgw']->template->set_var('no_link',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
-
$GLOBALS['phpgw']->template->set_var('lang_no',lang('NO'));
-
$GLOBALS['phpgw']->template->set_var('yes_link',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.delete&ab_id='
. $ab_id . '&confirm=true'));
-
$GLOBALS['phpgw']->template->set_var('lang_yes',lang('YES'));
- $this->output .=
$GLOBALS['phpgw']->template->parse('out','delete');
+
$this->template->set_file(array('principal_tabs' => 'principal_tabs.tpl'));
+
$this->template->set_block('principal_tabs','principal_tab','principal_tab');
+ $this->template->set_block('principal_tabs',
'principal_button', 'principal_button');
+
$this->get_principal_tabs('menuaction=addressbook.uiaddressbook.add_person',
+
$this->get_class_css($this->tab_main_persons, $this->section),
+ 'principal_persons',
$this->tab_main_persons);
+
$this->get_principal_tabs('menuaction=addressbook.uiaddressbook.add_org',
+
$this->get_class_css($this->tab_main_organizations, $this->section),
+ 'principal_orgs',
$this->tab_main_organizations);
+
+ $this->template->set_var('principal_tabs_inc',
$this->template->fp('out', 'principal_tab'));
}
else
{
- $this->bo->delete_entry(array('id' => $ab_id));
- @Header('Location: ' .
$GLOBALS['phpgw']->link('/addressbook/index.php','menuaction=addressbook.uiaddressbook.index'));
+ $this->template->set_var('principal_tabs_inc',
'');
}
- $this->totpl();
+
+ $this->template->set_var('old_tab_name',
'entry[old_tab]');
+ $this->template->set_var('old_tab', $fields['old_tab']);
+ $this->template->set_var('referer', $this->referer);
+ $this->template->set_var('ab_id', $this->contact_id);
+ $this->template->set_var('owner', $this->owner);
+ $this->template->set_var('record_name',
$this->record_name);
+
+ switch ($form_tab)
+ {
+ case $this->tab_orgs:
+ $this->template->set_var('onsubjs',
+
'onsubmit="process_list(\'entry[all_orgs][]\',
+
\'entry[my_orgs][]\')"');
+ break;
+ case $this->tab_cats:
+ $this->template->set_var('onsubjs',
+
'onsubmit="process_list(\'entry[all_cats][]\',
+
\'entry[my_cats][]\')"');
+ break;
+ case $this->tab_persons:
+ $this->template->set_var('onsubjs',
+
'onsubmit="process_list(\'entry[all_person][]\',
+
\'entry[my_person][]\')"');
+ break;
+ default:
+ $this->template->set_var('onsubjs', '');
+ }
+
+ switch ($section)
+ {
+ case $this->tab_main_persons:
+ if (!$form_tab)
+ {
+ $form_tab=$this->tab_person_data;
+ }
+
+ $this->template->set_var('action',
$GLOBALS['phpgw']->link('/index.php',
+ $this->form_action));
+ $this->get_tabs('bname',
$this->tab_person_data, $this->get_class_css($this->tab_person_data,
$form_tab));
+ $this->get_tabs('bname', $this->tab_orgs,
$this->get_class_css($this->tab_orgs, $form_tab));
+ $this->get_tabs('bname', $this->tab_cats,
$this->get_class_css($this->tab_cats, $form_tab));
+ $this->get_tabs('bname', $this->tab_comms,
$this->get_class_css($this->tab_comms, $form_tab));
+ $this->get_tabs('bname', $this->tab_address,
$this->get_class_css($this->tab_address, $form_tab));
+ $this->get_tabs('bname', $this->tab_others,
$this->get_class_css($this->tab_others, $form_tab));
+ $this->get_tabs('bname', $this->tab_extra,
$this->get_class_css($this->tab_extra, $form_tab));
+ break;
+ case $this->tab_main_organizations:
+ if (!$form_tab)
+ {
+ $form_tab=$this->tab_org_data;
+ }
+ $this->template->set_var('action',
$GLOBALS['phpgw']->link('/index.php',
+ $this->form_action));
+ $this->get_tabs('bname', $this->tab_org_data,
$this->get_class_css($this->tab_org_data, $form_tab));
+ $this->get_tabs('bname', $this->tab_persons,
$this->get_class_css($this->tab_persons, $form_tab));
+ $this->get_tabs('bname', $this->tab_cats,
$this->get_class_css($this->tab_cats, $form_tab));
+ $this->get_tabs('bname', $this->tab_comms,
$this->get_class_css($this->tab_comms, $form_tab));
+ $this->get_tabs('bname', $this->tab_address,
$this->get_class_css($this->tab_address, $form_tab));
+ $this->get_tabs('bname', $this->tab_others,
$this->get_class_css($this->tab_others, $form_tab));
+ break;
+ default:
+ $this->template->set_var('action',
$GLOBALS['phpgw']->link('/index.php',
+ $this->form_action));
+ $this->get_tabs('bname',
$this->tab_person_data, $this->get_class_css($this->tab_person_data,
$form_tab));
+ $this->get_tabs('bname', $this->tab_orgs,
$this->get_class_css($this->tab_orgs, $form_tab));
+ $this->get_tabs('bname', $this->tab_cats,
$this->get_class_css($this->tab_cats, $form_tab));
+ $this->get_tabs('bname', $this->tab_comms,
$this->get_class_css($this->tab_comms, $form_tab));
+ $this->get_tabs('bname', $this->tab_address,
$this->get_class_css($this->tab_address, $form_tab));
+ $this->get_tabs('bname', $this->tab_others,
$this->get_class_css($this->tab_others, $form_tab));
+ $this->get_tabs('bname', $this->tab_extra,
$this->get_class_css($this->tab_extra, $form_tab));
+ }
+
+ $this->template->set_var('tab',
$this->template->fp('out', 'tab'));
+ $this->template->set_var('current_tab_body',
$this->current_body($form_tab,$fields,$section));
+ $this->template->set_var('control_buttons',
$this->get_action_buttons($js_submit, $delete));
+
+ $this->template->pparse('out', 'form');
}
- function view()
+ /**
+ * Get the screen from the selected tab
+ *
+ * @param
+ * @return
+ */
+ function current_body($form_section,$fields, $section)
{
- $ab_id = $GLOBALS['HTTP_GET_VARS']['ab_id'];
- $submit = $GLOBALS['HTTP_POST_VARS']['submit'];
- $referer = $GLOBALS['HTTP_GET_VARS']['referer'];
-
- /* First, make sure they have permission to this entry
*/
- $check = $this->bo->read_entry(array('id' => $ab_id,
'fields' => array('owner' => 'owner','tid' => 'tid')));
-
- $tmp = $check[0]['owner'];
- $perms =
$this->contacts->check_perms($this->contacts->grants[$tmp],PHPGW_ACL_READ);
-
- if((!$perms) && ($check[0]['owner'] !=
$GLOBALS['phpgw_info']['user']['account_id']))
- {
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
- }
-
- if(!$ab_id)
+ switch ($form_section)
{
- Header('Location: ' .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
- $GLOBALS['phpgw_info']['flags']['nodisplay'] =
True;
- exit;
+ case $this->tab_person_data:
+ return $this->person_form($fields);
+ break;
+ case $this->tab_extra:
+ return $this->person_extra($fields);
+ break;
+ case $this->tab_org_data:
+ return $this->org_form($fields);
+ break;
+ case $this->tab_orgs:
+ $my_orgs_name='entry[my_orgs][]';
+ $all_orgs_name='entry[all_orgs][]';
+ $defaul_orgs_name='entry[preferred_org]';
+
+ $fields_to_search=array('contact_id',
'org_name');
+ $this->get_orgs($fields_to_search,
$fields['my_orgs']);
+
+ return
$this->many_actions_form($this->tab_orgs, $all_orgs_name,
+ $my_orgs_name, $defaul_orgs_name,
'all_orgs_data',
+ 'my_orgs_data', 'my_orgs_array',
$fields['preferred_org'],
+ $section, $fields);
+
+ break;
+ case $this->tab_cats:
+ $my_cats_name='entry[my_cats][]';
+ $all_cats_name='entry[all_cats][]';
+ //$defaul_cats_name='entry[current_cats]';
+
+ $fields_to_search=array('cat_id', 'cat_name');
+ $this->get_cats($fields_to_search,
$fields['my_cats']);
+
+ return
$this->many_actions_form($this->tab_cats, $all_cats_name,
+ $my_cats_name, '', 'all_cats_data',
+ 'my_cats_data', 'my_cats_array', '',
+ $section, $fields);
+ break;
+ case $this->tab_persons:
+ $my_person_name='entry[my_person][]';
+ $all_person_name='entry[all_person][]';
+ //$defaul_person_name='entry[current_person]';
+
+ $fields_to_search=array('contact_id',
'per_full_name');
+ $this->get_persons($fields_to_search,
$fields['my_person']);
+
+ return
$this->many_actions_form($this->tab_persons, $all_person_name,
+ $my_person_name, '', 'all_person_data',
+ 'my_person_data', 'my_person_array', '',
+ $section, $fields);
+ break;
+ case $this->tab_comms:
+ return $this->comm_form($fields);
+ break;
+ case $this->tab_address:
+ return $this->address_form($fields);
+ break;
+ case $this->tab_others:
+ return $this->others_form($fields);
+ //return $this->custom_fields_form($fields);
+ break;
+ default:
+ return $this->person_form($fields);
}
+ }
- $GLOBALS['phpgw']->template->set_file(array('view_t' =>
'view.tpl'));
-
$GLOBALS['phpgw']->template->set_block('view_t','view_header','view_header');
-
$GLOBALS['phpgw']->template->set_block('view_t','view_row','view_row');
-
$GLOBALS['phpgw']->template->set_block('view_t','view_footer','view_footer');
-
$GLOBALS['phpgw']->template->set_block('view_t','view_buttons','view_buttons');
-
- $custom = $this->fields->read_custom_fields();
- $customfields = array();
- while(list($x,$y) = @each($custom))
+ /**
+ * Draw the principal persons data tab window
+ *
+ * @param
+ * @return
+ */
+ function person_form($fields)
+ {
+ $userformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ if($userformat != $this->bo->bday_internformat)
{
- $customfields[$y['name']] = $y['title'];
+ $datetime = CreateObject("phpgwapi.datetime");
+ $fields['per_birthday'] =
$datetime->convertDate($fields['per_birthday'], $this->bo->bday_internformat,
$userformat);
}
-
- /* _debug_array($this->prefs); */
- while(list($column,$x) =
each($this->contacts->stock_contact_fields))
+ $bday =
$this->jscal->input('entry[per_birthday]',$fields['per_birthday']);
+
+ if ($fields['ispublic']=='private')
{
- if(isset($this->prefs[$column]) &&
$this->prefs[$column])
- {
- $columns_to_display[$column] = True;
- $colname[$column] = $column;
- }
+ $access_check = '<input type="checkbox"
name="entry[access]" checked>';
}
-
- /* No prefs? */
- if(!$columns_to_display )
+ else
{
- $columns_to_display = array(
- 'n_given' => 'n_given',
- 'n_family' => 'n_family',
- 'org_name' => 'org_name',
- 'tel_work' => 'tel_work',
- 'tel_home' => 'tel_home',
- 'email' => 'email',
- 'email_home' => 'email_home'
- );
- while($column = each($columns_to_display))
- {
- $colname[$column[0]] = $column[1];
- }
- $noprefs = ' - ' . lang('Please set your
preferences for this application');
+ $access_check = '<input type="checkbox"
name="entry[access]">';
}
- /* merge in extra fields */
- $qfields = $this->contacts->stock_contact_fields +
$this->extrafields + $customfields;
+ $this->form_start();
+ $this->template->set_var('lang_general_data',
lang('General Data'));
- $fields = $this->bo->read_entry(array('id' => $ab_id,
'fields' => $qfields));
+ $this->set_form_fields(array(1 => array('Prefix',
'entry[per_prefix]', $fields['per_prefix']),
+ 2 => array('Email',
'entry[email]', $fields['email']),
+ 3 => array('First Name',
'entry[per_first_name]', $fields['per_first_name']),
+ 4 => array('Phone',
'entry[wphone]', $fields['wphone']),
+ 5 => array('Last Name',
'entry[per_last_name]', $fields['per_last_name']),
+ 6 => array('Title',
'entry[per_title]', $fields['per_title']),
+ 7 => array('Middle Name',
'entry[per_middle_name]', $fields['per_middle_name']),
+ 8 => array('Department',
'entry[per_department]', $fields['per_department']),
+ 9 => array('Private',
$access_check, 'special'),
+ 10 => array('Birthday',
$bday, 'special')));
- $record_owner = $fields[0]['owner'];
+ $this->form_end();
+ return $this->template->fp('out',
'tab_body_general_data');
+ }
- if($fields[0]['access'] == 'private')
+ /**
+ * Draw the principal organizations data tab window
+ *
+ * @param
+ * @return
+ */
+ function org_form($fields)
+ {
+ if ($fields['ispublic']=='private')
{
- $access_check = lang('private');
+ $access_check = '<input type="checkbox"
name="entry[access]" checked>';
}
else
{
- $access_check = lang('public');
+ $access_check = '<input type="checkbox"
name="entry[access]">';
}
-
$GLOBALS['phpgw']->template->set_var('lang_viewpref',lang('Address book -
view') . $noprefs);
+ $this->form_start();
+
+ $this->template->set_var('lang_general_data',
lang('Organizations Data'));
+
+ $this->set_form_fields(array(1 => array('Name',
'entry[org_name]', $fields['org_name']),
+ 2 => array('Phone',
'entry[wphone]', $fields['wphone']),
+ 3 => array('Private',
$access_check, 'special'),
+ 4 =>
array('','','special')));
+ $this->form_end();
+ return $this->template->fp('out',
'tab_body_general_data');
+ }
- unset($qfields['email_type']); // noone is
useing that any more
- unset($qfields['privat_email_type']);
+ /**
+ * Draw the comunications media tab window
+ *
+ * @param
+ * @return
+ */
+ function comm_form($fields)
+ {
+ $this->form_start();
+
+ $this->template->set_var('lang_general_data',
lang('Communication Data for').' '.$this->record_name);
+
+ $types_data = array('data1' => array('type' => 'data',
+ 'field' =>
'comm_description'),
+ 'text1' => array('type' => 'text',
+ 'name' =>
'entry[comm_data]',
+ 'field' =>
'comm_description',
+ 'value' =>
'comm_data'),
+ 'radio1'=> array('type' => 'radio',
+ 'name' =>
'entry[preferred]',
+ 'field' =>
'preferred',
+ 'value' =>
'comm_description'));
+ foreach($this->comm_descr as $key => $value)
+ {
+ $this->array_data[] = array('comm_description'
=> $value['comm_description'],
+ 'comm_data' =>
$fields['comm_data'][$value['comm_description']],
+ 'preferred' =>
($fields['preferred'] == $value['comm_description'])?'Y':'N');
+ }
+
+ $this->template->set_var('detail_fields',
$this->get_detail_form('comm',
+ array('Description',
'Value','Preferred'),
+ 'array_data',
$types_data, 'key_comm_id', False));
+
+ $this->form_end();
+ return $this->template->fp('out',
'tab_body_general_data');
+ }
+
+ /**
+ * Draw the address tab window
+ *
+ * @param
+ * @return
+ */
+ function address_form($fields)
+ {
+ $addresstype='<select
name="entry[tmp_data][addr][addr_type]">'
+ .
$this->get_addr_type($fields[tmp_data][addr][addr_type]) . '</select>';
+ $addr_preferred = '<input type="hidden"
name="entry[tmp_data][addr][addr_preferred]" value="'
+ .$fields[tmp_data][addr][addr_preferred].'">';
+
+
+ $key_addr_id_name='entry[tmp_data][addr][key_addr_id]';
+ $key_addr_id=$fields[tmp_data][addr]['key_addr_id'];
+
+ $this->form_start();
+
+ $this->template->set_var('lang_general_data',
lang('Address Data for').' '.$this->record_name);
+
+ $this->template->set_var('current_id_name',
$key_addr_id_name);
+ $this->template->set_var('current_id', $key_addr_id);
+ $this->template->set_var('current_action_name',
'entry[tmp_data][addr][action]');
+ $this->template->set_var('current_action',
$fields[tmp_data][addr]['action']);
+
+ $this->set_form_fields(array(1 => array('Address 1',
'entry[tmp_data][addr][addr_add1]',
+
$fields['tmp_data']['addr']['addr_add1']),
+ 2 => array('State',
'entry[tmp_data][addr][addr_state]',
+
$fields[tmp_data]['addr']['addr_state']),
+ 3 => array('Address 2',
'entry[tmp_data][addr][addr_add2]',
+
$fields[tmp_data]['addr']['addr_add2']),
+ 4 => array('Postal Code',
'entry[tmp_data][addr][addr_postal_code]',
+
$fields[tmp_data]['addr']['addr_postal_code']),
+ 5 => array('City',
'entry[tmp_data][addr][addr_city]',
+
$fields[tmp_data]['addr']['addr_city']),
+ 6 => array('Country',
'entry[tmp_data][addr][addr_country]',
+
$fields[tmp_data]['addr']['addr_country']),
+ 7 => array(lang('Type'),
$addresstype, 'special'),
+ 8 => array('',
$addr_preferred, 'special')));
+
+ $types_data = array('data1' => array('type' => 'data',
+ 'field' =>
'addr_description'),
+ 'data2' => array('type' => 'data',
+ 'field' =>
'addr_add1'),
+ 'radio1'=> array('type' => 'radio',
+ 'name' =>
'entry[addr_preferred]',
+ 'field' =>
'addr_preferred',
+ 'value' =>
'key_addr_id'),
+ 'link1' => array('type' => 'link',
+ 'mode' => 'edit',
+ 'key' =>
'key_addr_id',
+ 'action'=>
'addr_edit_row',
+ 'extra' =>
'&owner='.$this->owner.'&ab_id='.$this->contact_id.'&record_name='.$this->record_name),
+ 'link2' => array('type' => 'link',
+ 'mode' =>
'delete',
+ 'key' =>
'key_addr_id',
+ 'action'=>
'addr_del_row',
+ 'extra' =>
'&owner='.$this->owner.'&ab_id='.$this->contact_id.'&record_name='.$this->record_name));
+ $this->array_data =
$this->read_tab_session('addr_data');
+ //var_export($fields);
+ //var_export($this->array_data);
+ if(isset($this->array_data[$fields['addr_preferred']]))
+ {
+
$this->array_data[$fields['addr_preferred']]['addr_preferred'] = 'Y';
+ }
+
+ $this->template->set_var('detail_fields',
$this->get_detail_form('address',
+ array('Type',
'Address', 'Preferred', 'Edit','Delete'),
+ 'array_data',
$types_data, 'key_addr_id'));
+ $this->form_end();
+ return $this->template->fp('out',
'tab_body_general_data');
+ }
+
+ /**
+ * This function draw the others tab screen
+ *
+ * @param array $fields The array with all data for show
+ * in this screen
+ * @return mixed The others screen whit all data
+ */
+ function others_form($fields)
+ {
+ //preparate vars to use, this are the html form objects
+ $other_descr='<input type="text" name="'
+ . 'entry[tmp_data][others][other_name]'
+ . '" value="'
+ . $fields[tmp_data][others]['other_name'] .
'">';
+ $other_value='<input type="text" name="'
+ .'entry[tmp_data][others][other_value]'
+ .'" value="'
+ . $fields[tmp_data][others]['other_value'] .
'">';
+
+
$key_other_id_name='entry[tmp_data][others][key_other_id]';
+ $key_other_id=$fields[tmp_data][others]['key_other_id'];
+
+ //start the form
+ $this->form_start();
+
+ //set values
+ $this->template->set_var('lang_general_data',
lang('Other Data for').' '.$this->record_name);
+
+ $this->template->set_var('current_id_name',
$key_other_id_name);
+ $this->template->set_var('current_id', $key_other_id);
+ $this->template->set_var('current_action_name',
'entry[tmp_data][others][action]');
+ $this->template->set_var('current_action',
$fields[tmp_data][others]['action']);
+
+ //send to draw the html objects
+ $this->set_form_fields(array(1 => array('Description',
$other_descr, 'special'),
+ 2 => array('Value',
$other_value, 'special')));
+
+ //specified what html objects and data you want in the
detail
+ $types_data = array('data1' => array('type' => 'data',
+ 'field' =>
'other_name'),
+ 'text1' => array('type' => 'text',
+ 'name' =>
'entry[other_value]',
+ 'field' =>
'key_other_id',
+ 'value' =>
'other_value'),
+ 'link1' => array('type' => 'link',
+ 'mode' =>
'delete',
+ 'key' =>
'key_other_id',
+ 'action'=>
'other_del_row',
+ 'extra' =>
'&owner='.$this->owner.'&ab_id='.$this->contact_id.'&record_name='.$this->record_name));
+ //$this->array_data = $fields['others'];
+ $this->array_data =
$this->read_tab_session('others_data');
+ $custom_fields = $this->get_custom_fields();
+
+ foreach($custom_fields as $data)
+ {
+
$this->entry['tmp_data']['others']['other_name'] = $data['title'];
+
$this->entry['tmp_data']['others']['other_value'] = '';
+
$this->entry['tmp_data']['others']['key_other_id'] = '';
+
$this->entry['tmp_data']['others']['other_owner'] =
$GLOBALS['phpgw_info']['server']['addressmaster'];
+ $this->add_general('others');
+ }
+ $this->array_data =
$this->read_tab_session('others_data');
+
+ if(is_array($fields['other_value']))
+ {
+ foreach($fields['other_value'] as $key => $data)
+ {
+ $this->array_data[$key]['other_value']
= $data;
+ }
+ }
+
+ //draw the detail form
+ //$this->template->set_var('custom_fields',
$this->custom_fields_form($fields));
+ $this->template->set_var('detail_fields',
$this->get_detail_form('other',
+ array('Description',
'Value','Delete'),
+ 'array_data',
$types_data, 'key_other_id'));
+
+ $this->form_end();
+ return $this->template->fp('out',
'tab_body_general_data');
+ }
+
+ function get_custom_fields()
+ {
+ if($this->section == $this->tab_main_persons)
+ {
+ $custom_fields =
$this->custom_fields->read_custom_fields(0,0,'','','person');
+ }
+ elseif($this->section == $this->tab_main_organizations)
+ {
+ $custom_fields =
$this->custom_fields->read_custom_fields(0,0,'','','org');
+ }
+ return $custom_fields;
+ }
+
+ /**
+ * This function draw the extra person data tab screen
+ *
+ * @param array $fields The array with all data for show
+ * in this screen
+ * @return mixed The extra tab screen whit all data
+ */
+ function person_extra($fields)
+ {
+ $sound='<input type="text" name="entry[per_sound]"
value="'
+ . $fields['per_sound'] .'">';
+ $pubkey='<input type="textarea"
name="entry[per_pubkey]" value="'
+ . $fields['per_pubkey'] . '">';
+
+ $this->form_start();
+ $this->template->set_var('lang_general_data',
lang('Person extra fields for').' '.$this->record_name);
+
+ $this->set_form_fields(array(1 => array('Suffix',
'entry[per_suffix]', $fields['per_suffix']),
+ 2 => array('Initials',
'entry[per_initials]', $fields['per_initials']),
+ 3 => array('Sound',
$sound, 'special'),
+ 4 => array('Public Key',
$pubkey, 'special')));
+
+ $this->form_end();
+
+ return $this->template->fp('out',
'tab_body_general_data');
+ }
+
+
+ /**
+ * This function draw the tab screen what is used for categories,
+ * Persons from an Organization and Organizations from a Person
+ *
+ * @param
+ * @return
+ */
+ function many_actions_form($option, $all_data_name,
$my_data_name, $defaul_data_name, $all_opts,
+ $my_opts, $my_opts_array, $selected,
$section, $fields)
+ {
+ if($section == $this->tab_main_persons)
+ {
+ $owner_title = 'Person';
+ $owner_value = $this->record_name;
+ }
+
+ if($section == $this->tab_main_organizations)
+ {
+ $owner_title = 'Org';
+ $owner_value = $this->record_name;
+
+ }
+
+ $all_data = '<select multiple size="5" name="'
+ . $all_data_name
+ . '" style="width:220">'
+ . $this->$all_opts . '</select>';
+
+ $my_data = '<select multiple size="5" name="'
+ . $my_data_name
+ . '" style="width:220">'
+ . $this->$my_opts . '</select>';
+
+ $defaul_data_cbo = '<select name="'
+ . $defaul_data_name
+ . '" style="width:150">'
+ . $this->get_my_option_selected($my_opts_array,
$selected) . '</select>';
+
+ $this->template->set_file(array('person_action' =>
'many_actions.tpl'));
+ $this->template->set_block('person_action',
'many_actions', 'many_actions');
+
+ if ($option==$this->tab_orgs)
+ {
+ $option_label = 'Organizations';
+ $this->template->set_var('lang_defaul',
lang('Default ' . $option_label) . ':');
+ $this->template->set_var('options',
$defaul_data_cbo);
+ }
+ elseif($option==$this->tab_persons)
+ {
+ $option_label = 'Persons';
+ }
+ elseif($option==$this->tab_cats)
+ {
+ $option_label = 'Categories';
+ }
+
+
+ $this->template->set_var('lang_general_data',
lang($option_label.' Data for').' '.$this->record_name);
+ $this->template->set_var('lang_title_left', lang('All '
. $option_label));
+ $this->template->set_var('person', $owner_value);
+
+ $this->template->set_var('lang_person',
lang($owner_title). ' ');
+ $this->template->set_var('lang_title_rigth',
lang('Current ' . $option_label));
+
+ $this->template->set_var('options_left', $all_data);
+ $this->template->set_var('options_rigth', $my_data);
+
+ $this->template->set_var('my_opt', $my_data_name);
+ $this->template->set_var('all_opt', $all_data_name);
+ $this->template->set_var('current_opt',
$defaul_data_name);
+
+ $this->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
+ $this->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
+ $this->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
+ $this->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
+
$this->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
+
+ return $this->template->fp('out', 'many_actions');
+ }
+
+ /**
+ * Draw the detail form, this form is as show in comms, addr and
othes windows
+ *
+ * @param string $tab The name which identify the section
+ * @param array $headers Array with all headers which you want
to show in the form
+ * @param string $array_name The array name from you want to
show data
+ * @param array $objs_data Array with all properties of all data
which you want to show
+ * @param string $idx The index name (for edit mode use)
+ * @param boolean $button Flag for indicate if you want draw the
Add button
+ * @return string All the detail form html code in the template
+ */
+ function get_detail_form($tab, $headers, $array_name,
$objs_data, $idx, $button=True)
+ {
+ $this->template->set_file(array('detail_data' =>
'body_detail.tpl'));
+
$this->template->set_block('detail_data','detail_body','detail_body');
+
$this->template->set_block('detail_data','input_detail_row','input_detail_row');
+
$this->template->set_block('detail_data','input_detail_data','input_detail_data');
+
+ $add_button = '<input type="submit" name="'. $tab
.'_add_row" value="'.lang('Add').'">';
+
+ if($button)
+ {
+ $this->template->set_var('caption_detail',
$title);
+ $this->template->set_var('add_button',
$add_button);
+ }
+ else
+ {
+ $this->template->set_var('caption_detail', '');
+ $this->template->set_var('add_button', '');
+ }
+
+ $this->template->set_var('row_bgc',
$GLOBALS['phpgw_info']['theme']['th_bg']);
+ $tr_color = $GLOBALS['phpgw_info']['theme']['row_on'];
+
+ $cols='';
+ foreach($headers as $head)
+ {
+ $cols .= '<td>' . lang($head) . '</td>';
+ }
+
+ $this->template->set_var('input_cols', $cols);
+
+ $this->template->fp('input_detail',
'input_detail_data', True);
+ $this->template->fp('detail_body_set',
'input_detail_row');
+
+ if (is_array($this->$array_name))
+ {
+ foreach($this->$array_name as $k => $v)
+ {
+ $id = $v[$idx];
+ $this->array_value = $v;
- @reset($qfields);
- while(list($column,$null) = @each($qfields))
- {
- if($this->display_name($colname[$column]))
- {
-
$GLOBALS['phpgw']->template->set_var('display_col',$this->display_name($colname[$column]));
- }
- elseif($this->display_name($column))
- {
-
$GLOBALS['phpgw']->template->set_var('display_col',$this->display_name($column));
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('display_col',ucfirst($column));
- }
- $ref = $data = '';
- if($fields[0][$column])
- {
$tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
-
$GLOBALS['phpgw']->template->set_var('th_bg',$tr_color);
- $coldata = $fields[0][$column];
- /* Some fields require special
formatting. */
- if(($column == 'note' || $column ==
'pubkey') && $coldata)
+ $this->template->set_var('row_bgc',
$tr_color);
+
+ $cols='';
+ reset($objs_data);
+ foreach($objs_data as $type =>
$properties)
+ {
+ $cols .= '<td>' .
$this->get_column_data($properties) . '</td>';
+ }
+
+ $this->template->set_var('input_cols',
$cols);
+
+ $this->template->fp('input_detail',
'input_detail_data', True);
+ $this->template->fp('detail_body_set',
'input_detail_row');
+ }
+ }
+
+ $this->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
+ $this->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
+ $this->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
+ $this->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
+
$this->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
+ return $this->template->fp('out', 'detail_body');
+ }
+
+ /**
+ * This function initialize the template for draw the tabs
windows
+ *
+ * @param
+ * @return
+ */
+ function form_start()
+ {
+ $this->template->set_file(array('person_data' =>
'current_tab_body.tpl'));
+
$this->template->set_block('person_data','tab_body_general_data','general_data');
+
$this->template->set_block('person_data','input_data','input_data');
+
$this->template->set_block('person_data','input_data_col','input_data_col');
+
$this->template->set_block('person_data','other_data','other_data');
+
$this->template->set_block('person_data','input_other_data','input_other_data');
+ }
+
+ /**
+ * This function end the template for draw the tabs windows
+ *
+ * @param
+ * @return
+ */
+ function form_end()
+ {
+ $this->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
+ $this->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
+ $this->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
+ $this->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
+
$this->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
+ }
+
+ /**
+ * Get the principal tabs (Persons and Organizations)
+ *
+ * @param
+ * @return
+ */
+ function get_principal_tabs($action, $class_css, $name, $value)
+ {
+
+ $button = array('principal_action' =>
$GLOBALS['phpgw']->link('/index.php',$action),
+ 'principal_class_css' => $class_css,
+ 'principal_name' => $name,
+ 'principal_value' =>
lang($value));
+ $this->template->set_var($button);
+ $this->template->parse('principal_buttons',
'principal_button', True);
+ }
+
+ /**
+ * Get the tabs
+ *
+ * @param
+ * @return
+ */
+ function get_tabs($button_name, $button_caption, $class_css)
+ {
+ $button = array('class_css' => $class_css,
+ 'button_name' => $button_name,
+ 'button_caption'=> $button_caption);
+ $this->template->set_var($button);
+ $this->template->parse('buttons', 'button', True);
+ }
+
+ /**
+ * Get the correct css for the tab
+ *
+ * @param
+ * @return
+ */
+ function get_class_css($tab, $current_tab)
+ {
+ if ($tab == $current_tab)
+ {
+ return 'button_style_sel';
+ }
+ else
+ {
+ return 'button_style';
+ }
+ }
+
+ /**
+ * Strip slashes from all elements of array
+ *
+ * @param array $data The array with all data what you want
+ * @return array The same array with stripslashes
+ */
+ function stripslashes_from_array($data=array())
+ {
+ if(is_array($data))
+ {
+ foreach($data as $key => $value)
+ {
+ if(is_array($value))
{
- $datarray = explode
("\n",$coldata);
- if($datarray[1])
- {
- while(list($key,$info)
= each ($datarray))
- {
- if($key)
- {
- $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;
- }
- }
- $data .= '</tr>';
- }
- else
- {
- $data = $coldata;
- }
+ $record[$key] =
$this->stripslashes_from_array($value);
}
- elseif ($column == 'url' && $coldata)
+ else
{
- $ref = '<a href="' . $coldata .
'" target="_new">';
- $data = $coldata . '</a>';
+ $record[$key] =
stripslashes($value);
}
- elseif((($column == 'email') ||
($column == 'email_home')) && $coldata)
+ }
+ }
+ return $record;
+ }
+
+ function addslashes_from_array($data=array())
+ {
+ if(is_array($data))
+ {
+ foreach($data as $key => $value)
+ {
+ if(is_array($value))
{
-
if($GLOBALS['phpgw_info']['user']['apps']['email'])
- {
- $ref = '<a href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=email.uicompose.compose&to=' .
urlencode($coldata)) . '" target="_new">';
- }
- else
+ $record[$key] =
$this->addslashes_from_array($value);
+ }
+ else
+ {
+ $record[$key] =
addslashes($value);
+ }
+ }
+ }
+ return $record;
+ }
+
+ /*************************************************************\
+ * Management tabs sessions functions *
+ \*************************************************************/
+
+ /**
+ * Get all the variables which are in post or get
+ *
+ * @param integer|Array $contact_id id of the contact or array
of the same
+ * @param integer $action PHPGW_SQL_RETURN_SQL |
PHPGW_SQL_RUN_SQL depending what we want
+ * @return Array|string Array with records or string with sql
query
+ */
+ function get_vars()
+ {
+ if(get_var('principal_persons',array('get','post')))
+ {
+ $this->submit = 'clear';
+ }
+
+
if(get_var('principal_organizations',array('get','post')))
+ {
+ $this->submit = 'clear';
+ }
+
+
if(!get_var('principal_organizations',array('get','post')) && !get_var('bname',
array('post', 'get')))
+ {
+ $this->firsttime = true;
+ }
+ else
+ {
+ $this->firsttime = false;
+ }
+
+ if(!get_var('principal_persons',array('get','post')) &&
!get_var('bname', array('post', 'get')))
+ {
+ $this->firsttime = true;
+ }
+ else
+ {
+ $this->firsttime = false;
+ }
+
+ //set submit action
+ if(get_var('submit',array('get','post')))
+ {
+ $this->submit = 'save';
+ $this->firsttime = false;
+ }
+ elseif(get_var('cancel',array('get','post')))
+ {
+ $this->submit = 'cancel';
+ $this->firsttime = false;
+ }
+ elseif(get_var('delete',array('get','post')))
+ {
+ $this->submit = 'delete';
+ $this->firsttime = false;
+ }
+
+ //set add/edit/delete action
+ if(get_var('address_add_row', array('get','post')))
+ {
+ $this->action = 'add_addr';
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('other_add_row', array('get','post')))
+ {
+ $this->action = 'add_other';
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('comm_edit_row', array('get','post')) >=
'0')
+ {
+ $this->action = 'edit_comm';
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('comm_del_row', array('get','post')) >=
'0')
+ {
+ $this->action = 'delete_comm';
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('addr_edit_row', array('get','post')) >=
'0')
+ {
+ $this->action = 'edit_addr';
+ $this->addr_edit_row = get_var('addr_edit_row',
array('get','post'));
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('addr_del_row', array('get','post')) >=
'0')
+ {
+ $this->action = 'delete_addr';
+ $this->addr_del_row = get_var('addr_del_row',
array('get','post'));
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('other_edit_row', array('get','post'))
>= '0')
+ {
+ $this->action = 'edit_other';
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+ elseif(get_var('other_del_row', array('get','post')) >=
'0')
+ {
+ $this->action = 'delete_other';
+ $this->other_del_row = get_var('other_del_row',
array('get','post'));
+ $this->submit = 'none';
+ $this->firsttime = false;
+ }
+
+ $_tab = get_var('bname', array('post', 'get'));
+ $this->tab = stripslashes($_tab);
+ $this->entry = get_var('entry', array('post','get'));
+
+ $this->contact_id = get_var('ab_id',
array('post','get'));
+ $this->owner = get_var('owner', array('post','get'));
+ $this->referer = get_var('referer',
array('post','get'));
+ $this->record_name =
htmlentities(get_var('record_name', array('post','get')));
+ }
+
+ /**
+ * Read the data of the correct tab in session variables
+ * or database.
+ *
+ * @param string $tab The tab name what you want to read
+ * @param boolean $load Flag for use if you want read from
+ * session variable
+ * @return array The array with all data from the tab what
+ * you specified
+ */
+ function read_tab_session($tab)
+ {
+ $load_vars =
$GLOBALS['phpgw']->session->appsession('load_vars', 'addressbook');
+ switch ($tab)
+ {
+ case $this->tab_person_data:
+ if($load_vars[$this->tab_person_data]=='db')
+ {
+ $entry =
$this->bo->get_principal_persons_data($this->contact_id, False);
+ $entry['ispublic'] = $entry['access'];
+
$this->save_tab_session($this->tab_cats, $entry['tab_cats']);
+
$this->save_tab_session($this->tab_extra, $entry['tab_extra']);
+ unset($entry['tab_cats']);
+ unset($entry['tab_extra']);
+ $load_vars[$this->tab_person_data] =
'cache';
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_person_data', 'addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ $comms =
$this->read_tab_session($this->tab_comms);
+ $entry['email'] = $comms['comm_data']['work
email'];
+ $entry['wphone'] = $comms['comm_data']['work
phone'];
+ //$this->record_name = $entry['per_full_name'];
+ break;
+ case $this->tab_orgs:
+ if($load_vars[$this->tab_orgs]=='db')
+ {
+ $entry =
$this->bo->get_orgs_person_data($this->contact_id);
+ $old_my_orgs = $entry;
+
$GLOBALS['phpgw']->session->appsession('old_my_orgs','addressbook',$old_my_orgs);
+ $load_vars[$this->tab_orgs] = 'cache';
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_orgs', 'addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ break;
+ case $this->tab_cats:
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_cats', 'addressbook');
+ $entry = $this->stripslashes_from_array($entry);
+ break;
+ case $this->tab_comms:
+ if($load_vars[$this->tab_comms]=='db')
+ {
+ $data =
$this->bo->get_comm_contact_data($this->contact_id,'',True);
+ foreach($data as $key => $value)
+ {
+
$entry['comm_data'][$value['comm_description']] = $value['comm_data'];
+
if($value['comm_preferred']=='Y')
{
- $ref = '<a
href="mailto:'.$coldata.'">';
+ $entry['preferred'] =
$value['comm_description'];
}
- $data = $coldata.'</a>';
}
- elseif ($column == 'bday')
+
$GLOBALS['phpgw']->session->appsession('comm_data','addressbook',$data);
+
$GLOBALS['phpgw']->session->appsession('old_comm','addressbook',$entry['comm_data']);
+ $load_vars[$this->tab_comms] = 'cache';
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_comms', 'addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ break;
+ case $this->tab_address:
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_address', 'addressbook');
+ $entry = $this->stripslashes_from_array($entry);
+ break;
+ case $this->tab_others:
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_others', 'addressbook');
+ $entry = $this->stripslashes_from_array($entry);
+ break;
+ case $this->tab_extra:
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_extra', 'addressbook');
+ $entry = $this->stripslashes_from_array($entry);
+ break;
+ case $this->tab_org_data:
+ if($load_vars[$this->tab_org_data] == 'db')
+ {
+ $entry =
$this->bo->get_principal_organizations_data($this->contact_id);
+ $entry['ispublic'] = $entry['access'];
+
$this->save_tab_session($this->tab_cats, $entry['tab_cats']);
+ unset($entry['tab_cats']);
+ $load_vars[$this->tab_org_data] =
'cache';
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_org_data', 'addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ $comms =
$this->read_tab_session($this->tab_comms);
+ $entry['wphone'] = $comms['comm_data']['work
phone'];
+ //$this->record_name = $entry['org_name'];
+ break;
+ case $this->tab_persons:
+ if($load_vars[$this->tab_persons] == 'db')
+ {
+ $entry =
$this->bo->get_person_orgs_data($this->contact_id);
+ $load_vars[$this->tab_persons] =
'cache';
+ $old_my_person = $entry;
+
$GLOBALS['phpgw']->session->appsession('old_my_person','addressbook',$old_my_person);
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('tab_persons', 'addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ break;
+ case 'others_data':
+ if($load_vars['others_data'] == 'db')
+ {
+ $data =
$this->bo->get_others_contact_data($this->contact_id);
+ if(!is_array($data))
{
- list($month,$day,$year) =
explode('/',$coldata);
- $data =
$GLOBALS['phpgw']->common->dateformatorder($year,$month,$day,True);
+ $data = array();
}
- else
+ foreach($data as $key => $value)
{
- /* But these do not */
- $ref = ''; $data = $coldata;
+ $entry[$value['key_other_id']]
= $value;
}
-
- if(!$data)
+
$GLOBALS['phpgw']->session->appsession('old_others','addressbook',$entry);
+ $this->save_tab_session('others_data',
$entry);
+ $load_vars['others_data'] = 'cache';
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('others_data','addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ //$this->save_tab_session('others_data',
$entry);
+ break;
+ case 'addr_data':
+ if($load_vars['addr_data'] == 'db')
+ {
+ $data =
$this->bo->get_addr_contact_data($this->contact_id);
+ if(!is_array($data))
{
-
$GLOBALS['phpgw']->template->set_var('ref_data',' ');
+ $data = array();
}
- else
+ foreach($data as $key => $value)
{
-
$GLOBALS['phpgw']->template->set_var('ref_data',$ref . $data);
+ $entry[$value['key_addr_id']] =
$value;
}
-
$GLOBALS['phpgw']->template->parse('cols','view_row',True);
+ $this->save_tab_session('addr_data',
$entry);
+ $load_vars['addr_data'] = 'cache';
+ }
+ else
+ {
+ $entry =
$GLOBALS['phpgw']->session->appsession('addr_data','addressbook');
+ $entry =
$this->stripslashes_from_array($entry);
+ }
+ break;
+ }
+
$GLOBALS['phpgw']->session->appsession('load_vars','addressbook', $load_vars);
+ //$record = $this->htmlentities_from_array($entry);
+ $record = $entry;
+ return $record;
+ }
+
+ /**
+ * Save the data of the correct tab
+ *
+ * @param string $tab The tab name what you want to save
+ * @param array $entry The tab data what you want to save
+ * @return mixed The data saved in correct session variable
+ */
+ function save_tab_session($tab, $entry)
+ {
+ switch ($tab)
+ {
+ case $this->tab_person_data:
+ $entry_name = 'tab_person_data';
+
+ //get emain and phone info from comms var
+ $comms =
$this->read_tab_session($this->tab_comms);
+ $comms['comm_data']['work email'] =
$entry['email'];
+ $comms['comm_data']['work phone'] =
$entry['wphone'];
+ $comms['preferred'] =
$comms['preferred']?$comms['preferred']:'work email';
+
+ $this->save_tab_session($this->tab_comms,
$comms);
+ unset($entry['email']);
+ unset($entry['wphone']);
+
+ //mini hack for save access check box
+ if(isset($entry['access']))
+ {
+ $entry['ispublic'] = 'private';
+ $entry['access'] = 'private';
+ }
+ else
+ {
+ $entry['ispublic'] = 'public';
+ $entry['access'] = 'public';
+ }
+
+ $userformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ if($userformat != $this->bo->bday_internformat)
+ {
+ $datetime =
CreateObject("phpgwapi.datetime");
+ $entry['per_birthday'] =
$datetime->convertDate($entry['per_birthday'], $userformat,
$this->bo->bday_internformat);
+ }
+
+ $this->record_name =
htmlentities(stripslashes($entry['per_first_name'].
+ ($entry['per_middle_name']?'
'.$entry['per_middle_name']:'').
+ ($entry['per_last_name']?'
'.$entry['per_last_name']:'')));
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case $this->tab_orgs:
+ $entry_name = 'tab_orgs';
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case $this->tab_cats:
+ $entry_name = 'tab_cats';
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case $this->tab_comms:
+ $entry_name = 'tab_comms';
+ $entry['comm_data'] =
$this->save_simple_array($entry['comm_data']);
+ $entry_data = $entry;
+ break;
+ case $this->tab_address:
+ $entry_name = 'tab_address';
+ if($entry['addr_preferred'] &&
$entry['addr_preferred']!='')
+ {
+ $this->addr_data =
$this->read_tab_session('addr_data');
+
$this->addr_data[$entry['addr_preferred']]['addr_preferred'] =
$this->set_addr_preferred('addr_data', 'Y');
+ $this->save_tab_session('addr_data',
$this->addr_data);
+ unset($this->addr_data);
+ }
+
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case $this->tab_others:
+ $entry_name = 'tab_others';
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case $this->tab_extra:
+ $entry_name = 'tab_extra';
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case $this->tab_org_data:
+ $entry_name = 'tab_org_data';
+
+ //get emain and phone info from comms var
+ $comms =
$this->read_tab_session($this->tab_comms);
+ $comms['comm_data']['work phone'] =
$entry['wphone'];
+ $comms['preferred'] =
$comms['preferred']?$comms['preferred']:'work email';
+ $this->save_tab_session($this->tab_comms,
$comms);
+ unset($entry['wphone']);
+
+ //mini hack for save access check box
+ if(isset($entry['access']))
+ {
+ $entry['ispublic'] = 'private';
+ $entry['access'] = 'private';
+ }
+ else
+ {
+ $entry['ispublic'] = 'public';
+ $entry['access'] = 'public';
+ }
+ //$entry_data =
$this->save_simple_array($entry);
+ $this->record_name =
htmlentities($entry['org_name']);
+ $entry_data = $entry;
+ break;
+ case $this->tab_persons:
+ $entry_name = 'tab_persons';
+ //$entry_data =
$this->save_simple_array($entry);
+ $entry_data = $entry;
+ break;
+ case 'others_data':
+ $entry_name = 'others_data';
+ $entry = $this->addslashes_from_array($entry);
+ $entry_data = $entry;
+ break;
+ case 'addr_data':
+ $entry_name = 'addr_data';
+ $entry = $this->addslashes_from_array($entry);
+ $entry_data = $entry;
+ break;
+ }
+
+
$GLOBALS['phpgw']->session->appsession($entry_name,'addressbook', $entry_data);
+ }
+
+ /**
+ * Clear all session variables which have tabs data
+ *
+ * @param string $tab The tab name what you want to clear or
nothing
+ * if you want clear all tabs
+ * @return mixed The variable what you specified clear or all
tabs variables
+ */
+ function clear_tab_session($tab='')
+ {
+ $tabs_data = array('tab_person_data',
+ 'tab_orgs',
+ 'tab_cats',
+ 'tab_comms',
+ 'tab_address',
+ 'tab_others',
+ 'tab_extra',
+ 'tab_org_data',
+ 'tab_persons',
+
+ 'others_data',
+ 'addr_data',
+ 'comm_data',
+
+ 'load_vars',
+ 'transactions',
+
+ 'old_my_orgs',
+ 'old_my_person',
+ 'old_comm',
+ 'old_others');
+
+ if($tab!='')
+ {
+ $GLOBALS['phpgw']->session->appsession($tab,
'addressbook', NULL);
+ }
+ else
+ {
+ foreach($tabs_data as $tab)
+ {
+
$GLOBALS['phpgw']->session->appsession($tab, 'addressbook', '');
+ }
+ }
+ }
+
+ /**
+ * Initialize the load_vars array with all tabs asigment the
value
+ *
+ * @param string $from The value cache|db depending where you
can read the
+ * tab data, this is cache in add mode and db in edit mode.
+ * @return array The array with all tabs name and correct value
for read data
+ */
+ function load_tabs($from='cache')
+ {
+ $tabs_data = array($this->tab_person_data,
+ $this->tab_orgs,
+ $this->tab_cats,
+ $this->tab_comms,
+ $this->tab_address,
+ $this->tab_others,
+ $this->tab_extra,
+ $this->tab_org_data,
+ $this->tab_persons,
+
+ 'others_data',
+ 'addr_data');
+ // $load_vars =
$GLOBALS['phpgw']->session->appsession('load_vars', 'addressbook');
+ foreach($tabs_data as $tab)
+ {
+ $load_vars[$tab] = $from;
+ }
+
$GLOBALS['phpgw']->session->appsession('load_vars','addressbook', $load_vars);
+ }
+
+ /**
+ * Get all data from all tabs
+ *
+ * @param Array $data Array with all data what you want to save
+ * @return Array Array with all data which are not empty
+ */
+ function get_all_entry()
+ {
+ $tabs_data = array('tab_person_data',
+ 'tab_orgs',
+ 'tab_cats',
+ 'tab_comms',
+ 'tab_address',
+ 'tab_others',
+ 'tab_extra',
+ 'tab_org_data',
+ 'tab_persons',
+
+ 'others_data',
+ 'addr_data',
+ 'comm_data',
+
+ 'transactions',
+
+ 'old_my_orgs',
+ 'old_my_person',
+ 'old_comm',
+ 'old_others');
+ foreach($tabs_data as $tab)
+ {
+ $fields[$tab] =
$GLOBALS['phpgw']->session->appsession($tab, 'addressbook');
+ $record[$tab] =
$this->stripslashes_from_array($fields[$tab]);
+ }
+ return $record;
+ }
+
+ /**
+ * Save in array all data if this are not empty
+ *
+ * @param Array $data Array with all data what you want to save
+ * @return Array Array with all data which are not empty
+ */
+ function save_simple_array($data=array())
+ {
+ foreach($data as $key => $value)
+ {
+ if($value!='')
+ {
+ $new_data[$key] = $value;
+ }
+ }
+ return $new_data;
+ }
+
+
+ /*************************************************************\
+ * Management functions for catalogs *
+ \*************************************************************/
+
+ /**
+ * Run management functions, this functions only are called from
+ * address and others tabs and are used for add/delete/update
+ * the records of this tabs
+ *
+ * @param string $action The action which will be executed
+ * @return mixed The correct action
+ */
+ function managment_functions($action)
+ {
+ switch($action)
+ {
+ case 'add_addr':
+ $this->add_address();
+ break;
+ case 'edit_addr':
+ $this->edit_address();
+ break;
+ case 'delete_addr':
+ $this->delete_address();
+ break;
+ case 'add_other':
+ $this->add_other();
+ break;
+ case 'edit_other':
+ $this->edit_other();
+ break;
+ case 'delete_other':
+ $this->delete_other();
+ break;
+ }
+ }
+
+ /**
+ * Add and update an address in address array
+ *
+ * @param array $this->entry This array contain all data to
insert in array
+ * @return mixed The record inserted in addr data array
+ */
+ function add_address()
+ {
+ $this->tab = $this->tab_address;
+ $this->entry['tmp_data']['addr']['addr_description'] =
$this->bo->search_location_type_id(
+ $this->entry['tmp_data']['addr']['addr_type']);
+ $this->add_general('addr');
+ $this->entry['old_tab'] = $this->tab_address;
+ }
+
+ /**
+ * Return data from the address what you want to edit to temp
array which
+ * are display in html form, also remove this from the address
array
+ *
+ * @param integer $this->addr_edit_row This is the address id
what you want to edit
+ * @return mixed The $this->entry['tmp_data']['addr'] array with
the data what you want to edit
+ */
+ function edit_address()
+ {
+ $this->tab = $this->tab_address;
+ //FIXME: if a record is in edit mode return this to
general array, consider this data
+ // are send for post and in this moment the form was
send in get
+ $addr_data =
$GLOBALS['phpgw']->session->appsession('addr_data','addressbook');
+ $this->entry['tmp_data']['addr'] =
$addr_data[$this->addr_edit_row];
+ unset($addr_data[$this->addr_edit_row]);
+
if($this->entry['tmp_data']['addr']['addr_preferred']=='Y')
+ {
+ if(count($addr_data)>0)
+ {
+ reset($addr_data);
+
$addr_data[key($addr_data)]['addr_preferred'] = 'Y';
+ }
+ }
+
+
$GLOBALS['phpgw']->session->appsession('addr_data','addressbook', $addr_data);
+ $this->entry['old_tab'] = $this->tab_address;
+ }
+
+ function delete_address()
+ {
+ $this->tab = $this->tab_address;
+ $addr_data =
$GLOBALS['phpgw']->session->appsession('addr_data','addressbook');
+ $pref =
$addr_data[$this->addr_del_row]['addr_preferred'];
+ unset($addr_data[$this->addr_del_row]);
+
+ if(count($addr_data)==0)
+ {
+
$GLOBALS['phpgw']->session->appsession('addr_data','addressbook', '');
+ }
+ else
+ {
+ if($pref=='Y')
+ {
+ reset($addr_data);
+
$addr_data[key($addr_data)]['addr_preferred'] = 'Y';
+ }
+
+
$GLOBALS['phpgw']->session->appsession('addr_data','addressbook', $addr_data);
+ }
+
+ $this->entry['old_tab'] = $this->tab_address;
+
+ if($this->mode == 'edit')
+ {
+ $key_action = $this->addr_del_row . 'delete' .
'addr';
+ $trans =
$this->bo->delete_specified_location($this->addr_del_row);
+ $this->save_trans_actions($key_action, $trans);
+ }
+ }
+
+ function add_other()
+ {
+ $this->tab = $this->tab_others;
+ $this->add_general('others');
+ $this->entry['old_tab'] = $this->tab_others;
+ }
+
+ function delete_other()
+ {
+ $this->tab = $this->tab_others;
+ $others_data =
$GLOBALS['phpgw']->session->appsession('others_data','addressbook');
+ unset($others_data[$this->other_del_row]);
+
+ if(count($others_data)==0)
+ {
+
$GLOBALS['phpgw']->session->appsession('others_data','addressbook', '');
+ }
+ else
+ {
+
$GLOBALS['phpgw']->session->appsession('others_data','addressbook',
$others_data);
+ }
+
+ $this->entry['old_tab'] = $this->tab_others;
+
+ if($this->mode == 'edit')
+ {
+ $key_action = $this->other_del_row . 'delete' .
'others';
+ $trans =
$this->bo->delete_specified_other($this->other_del_row);
+ $this->save_trans_actions($key_action, $trans);
+ }
+ }
+
+ /**
+ * Insert or update one element to correct array
+ *
+ * @param string $tab_section The section what you
+ * want to add elements, for example others, addr.
+ * @return mixed The elemet from entry in the array
+ */
+ function add_general($tab_section)
+ {
+ if($tab_section=='others')
+ {
+ $key_tab_id = 'key_other_id';
+ $tab_data = 'others_data';
+ }
+ elseif($tab_section=='addr')
+ {
+ $key_tab_id = 'key_addr_id';
+ $tab_data = 'addr_data';
+ }
+
+ $this->entry_data = $this->read_tab_session($tab_data);
+ if(is_array($this->entry_data))
+ {
+ ksort($this->entry_data);
+ end($this->entry_data);
+ $key_id = key($this->entry_data);
+ }
+
+ $add_data = $this->entry['tmp_data'][$tab_section];
+
+ if($add_data['action'] == 'insert')
+ {
+ $get_query = 'get_insert_'.$tab_section;
+ $add_data['action'] = 'insert';
+ $key_id = $add_data[$key_tab_id];
+ }
+ else
+ {
+ if(!$add_data[$key_tab_id] ||
$add_data[$key_tab_id]=='')
+ {
+ $key_id = $key_id +1;
+ $get_query = 'get_insert_'.$tab_section;
+ $add_data['action'] = 'insert';
+ }
+ else
+ {
+ $key_id = $add_data[$key_tab_id];
+ $get_query = 'get_update_'.$tab_section;
+ $add_data['action'] = 'update';
+ }
+ }
+ $add_data[$key_tab_id] = $key_id;
+ $key_action = $add_data[$key_tab_id] .
$add_data['action'] . $tab_section;
+
+ if($tab_section=='others')
+ {
+ if(!$add_data['other_owner'])
+ {
+ $add_data['other_owner'] =
$GLOBALS['phpgw_info']['user']['account_id'];
}
}
- /* Following cleans up view_row, since we were only
using it to fill {cols} */
- $GLOBALS['phpgw']->template->set_var('view_row','');
-
- $fields['cat_id'] = is_array($this->cat_id) ?
implode(',',$this->cat_id) : $this->cat_id;
+
+ if($tab_section=='addr')
+ {
+ $add_data['addr_preferred'] =
$this->set_addr_preferred('entry_data', $add_data['addr_preferred']);
+ }
+ //var_export($add_data);
- $cats = explode(',',$fields[0]['cat_id']);
- if($cats[1])
+ if($tab_section=='others')
{
- while(list($key,$contactscat) = each($cats))
+ $exist_name = False;
+ if(!is_array($this->entry_data))
{
- if($contactscat)
+ $this->entry_data = array();
+ }
+
+ foreach($this->entry_data as $key => $data)
+ {
+ if($data['other_name'] ==
$add_data['other_name'])
{
- $catinfo =
$this->cat->return_single(intval($contactscat));
- $catname .= $catinfo[0]['name']
. '; ';
+ $exist_name = True;
}
}
- if(!$this->cat_id)
+ if($exist_name==False)
{
- $this->cat_id = $cats[0];
+ //$add_data['other_name'] =
addslashes($add_data['other_name']);
+ $this->entry_data[$key_id] = $add_data;
}
}
else
{
- $fields[0]['cat_id'] =
ereg_replace(',','',$fields[0]['cat_id']);
- $catinfo =
$this->cat->return_single(intval($fields[0]['cat_id']));
- $catname = $catinfo[0]['name'];
- if(!$this->cat_id)
- {
- $this->cat_id = $fields[0]['cat_id'];
- }
- }
-
- if(!$catname)
- {
- $catname = lang('none');
+ $exist_name==False;
+ $this->entry_data[$key_id] = $add_data;
}
+
+ //var_export($this->entry_data);
+ $this->save_tab_session($tab_data, $this->entry_data);
- /* These are in the footer */
-
$GLOBALS['phpgw']->template->set_var('lang_owner',lang('Record owner'));
-
$GLOBALS['phpgw']->template->set_var('owner',$GLOBALS['phpgw']->common->grab_owner_name($record_owner));
-
$GLOBALS['phpgw']->template->set_var('lang_access',lang('Record access'));
-
$GLOBALS['phpgw']->template->set_var('access',$access_check);
-
$GLOBALS['phpgw']->template->set_var('lang_category',lang('Category'));
-
$GLOBALS['phpgw']->template->set_var('catname',$catname);
-
- if(($this->contacts->grants[$record_owner] &
PHPGW_ACL_EDIT) ||
- ($record_owner ==
$GLOBALS['phpgw_info']['user']['account_id']))
+ //if is edit mode make a query and save this in stock
which will be executed in save
+ if($this->mode == 'edit' && $exist_name==False &&
$tab_section!='others')
{
- $extra_vars = array('cd' => 16,'query' =>
$this->query,'cat_id' => $this->cat_id);
-
- if($referer)
+ if($get_query == 'get_insert_'.$tab_section)
{
- $extra_vars += array('referer' =>
urlencode($referer));
+ $trans =
$this->bo->$get_query($this->contact_id,
+
$this->entry_data[$key_id]);
}
-
-
$GLOBALS['phpgw']->template->set_var('edit_button',$this->html_1button_form('edit','Edit',
-
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.edit&ab_id='
.$ab_id)));
+ elseif($get_query == 'get_update_'.$tab_section)
+ {
+ $trans = $this->bo->$get_query($key_id,
+
$this->entry_data[$key_id]);
+ }
+ $this->save_trans_actions($key_action, $trans);
}
-
$GLOBALS['phpgw']->template->set_var('copy_button',$this->html_1button_form('submit','copy',
-
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.copy&ab_id='
. $fields[0]['id'])));
+
+ unset($this->entry);
+ unset($add_data);
+ unset($this->entry_data);
+ }
- if($fields[0]['n_family'] && $fields[0]['n_given'])
+ function set_addr_preferred($entry_data, $preferred)
+ {
+ if($preferred == 'Y')
{
-
$GLOBALS['phpgw']->template->set_var('vcard_button',$this->html_1button_form('VCardForm','VCard',
-
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uivcard.out&ab_id='
.$ab_id)));
+ //var_export($this->$entry_data);
+ if(!is_array($this->$entry_data))
+ {
+ $this->$entry_data=array();
+ }
+ foreach($this->$entry_data as $key => $value)
+ {
+
$this->{$entry_data}[$key]['addr_preferred'] = 'N';
+ }
+ //var_export($this->$entry_data);
+ return 'Y';
}
else
{
-
$GLOBALS['phpgw']->template->set_var('vcard_button',lang('no vcard'));
+ if(is_array($this->$entry_data))
+ {
+ foreach($this->$entry_data as $key =>
$value)
+ {
+
if($value['addr_preferred']=='Y')
+ {
+ return 'N';
+ }
+ }
+ }
+ return 'Y';
}
-
-
$GLOBALS['phpgw']->template->set_var('done_button',$this->html_1button_form('DoneForm','Done',
- $referer ? $referer :
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index')));
-
$GLOBALS['phpgw']->template->set_var('access_link',$access_link);
-
- $this->output .=
$GLOBALS['phpgw']->template->fp('out','view_t');
- $this->totpl();
-
- $GLOBALS['phpgw']->hooks->process(array(
- 'location' => 'addressbook_view',
- 'ab_id' => $ab_id
- ));
}
+
- function html_1button_form($name,$lang,$link)
+ /**
+ * Save the stock of queries for management functions
+ *
+ * @param string $key_action This is the identifier of the query,
+ * this key is composed for record_id-action-section
+ * @param string $trans This is the query string which you want
to save
+ * @return array The array with all queries
+ */
+ function save_trans_actions($key_action, $trans)
{
- $html = '<form method="POST" action="' . $link . '">'
. "\n";
- $html .= '<input type="submit" name="' . $name .'"
value="' . lang($lang) . '">' . "\n";
- $html .= '</form>' . "\n";
- return $html;
+ //$transactions =
$GLOBALS['phpgw']->session->appsession('transactions','addressbook');
+ $transactions[$key_action] = $trans;
+
$GLOBALS['phpgw']->session->appsession('transactions','addressbook',
$transactions);
}
+
+
- function preferences()
+ function delete_contact($contact_id='', $contact_type='')
{
- $submit = $GLOBALS['HTTP_POST_VARS']['submit'];
- $prefs = $GLOBALS['HTTP_POST_VARS']['prefs'];
- $other = $GLOBALS['HTTP_POST_VARS']['other'];
- $fcat_id = $GLOBALS['HTTP_POST_VARS']['fcat_id'];
+ $confirm = get_var('confirm');
+ $contact_type =
$contact_type?$contact_type:$this->bo->search_contact_type_id(
+ $this->bo->get_type_contact($contact_id));
- /* _debug_array($this->prefs); */
- $custom = $this->fields->read_custom_fields();
- $customfields = array();
- while(list($x,$y) = @each($custom))
+ if($contact_type == $this->tab_main_persons)
{
- $customfields[$y['name']] = $y['name'];
+ $type = 'person';
+ $this->section = $this->tab_main_persons;
+ $data =
$this->bo->get_principal_persons_data($contact_id, False);
}
-
- $qfields = $this->contacts->stock_contact_fields +
$this->extrafields + $customfields;
-
- if($submit)
+ elseif($contact_type == $this->tab_main_organizations)
{
- $totalerrors = 0;
- if(!count($prefs))
- {
- $errors[$totalerrors++] = lang('You
must select at least 1 column to display');
- }
- if(!$totalerrors)
- {
- @reset($qfields);
-
$this->bo->save_preferences($prefs,$other,$qfields,$fcat_id);
- }
+ $type = 'org';
+ $this->section = $this->tab_main_organizations;
+ $data =
$this->bo->get_principal_organizations_data($contact_id);
}
- if($totalerrors)
+ $owner = $data['owner'];
+
+ if(!$this->bo->can_delete($contact_id, $owner))
{
- echo '<p><center>' .
$GLOBALS['phpgw']->common->error_list($errors) . '</center>';
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$contact_type));
}
+ //LEX: Calling the delete_addressbook hook to make
+ //shure we are allowed to delete this contacts by the
+ //other applications
+
+ $response= $GLOBALS['phpgw']->hooks->process(array(
+ 'location' =>
'delete_addressbook',
+ 'contact_id' =>
$contact_id )
+ );
+
+ if(!$this->bo->can_delete_hooks($response))
+ {
+
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
+ (count($this->bo->negative_responses) >1) ?
$plur='s' : $plur='';
+
$this->template->set_file(array('cant_delete_apps' =>
+ 'cannot_delete.tpl')
+ );
+
+ $this->template->set_var('lang_maynot_delete',
+ lang("The following
application(s) have
+ requested for
this contact to be
+ protected from
deletion:")
+ );
+
$this->template->set_var('lang_application',lang('applications'));
+
$this->template->set_var('lang_reason',lang('reason'));
+
$this->template->set_var('lang_go_back',lang('Go back'));
+ $this->template->set_var('link_go_back',
+
$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$contact_type));
+ $this->template->set_block('cant_delete_apps',
+ 'apps',
+ 'apps_l');
+ foreach($this->bo->negative_responses as
$appname => $reason)
+ {
+
$this->template->set_var('appname',$appname);
+
$this->template->set_var('reason',$reason);
+
$this->template->parse('apps_l','apps',True);
+ }
+
+
$this->template->pparse('out','cant_delete_apps');
+ $GLOBALS['phpgw']->common->phpgw_exit();
+
+ return;
+ }
+
+ $this->template->set_file(array('delete' =>
'delete.tpl'));
+
+ if ($confirm != 'true')
+ {
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
+ $this->template->set_var('lang_sure',lang('Are
you sure you want to delete this entry ?'));
+
$this->template->set_var('no_link',$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$contact_type));
+ $this->template->set_var('lang_no',lang('NO'));
+
$this->template->set_var('yes_link',$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.delete_' . $type . '&ab_id='
+ . $contact_id .
'&confirm=true'));
+
$this->template->set_var('lang_yes',lang('YES'));
+ $this->template->pparse('out','delete');
+ }
+ else
+ {
+ $this->bo->delete($contact_id, $contact_type);
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$contact_type));
+ }
-
$GLOBALS['phpgw']->template->set_file(array('preferences' =>
'preferences.tpl'));
-
-
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.preferences'));
-
- $i = 0; $j = 0;
- $tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+ }
+
+ function view_contact($contact_id='', $contact_type='',
$referer='')
+ {
+ $contact_id = (empty($contact_id))? get_var('ab_id') :
$contact_id;
+ $contact_type =
$contact_type?$contact_type:$this->bo->search_contact_type_id(
+ $this->bo->get_type_contact($contact_id));
+ $referer = ($referer=='')?get_var('referer'):$referer;
+ $referer = urldecode($referer);
- while(list($col, $descr) = each($qfields))
+ if($contact_type == $this->tab_main_persons)
{
- /* echo '<br>test: $col - $i $j - ' .
count($abc); */
- $i++; $j++;
- $showcol = $this->display_name($col);
- if(!$showcol)
+ $type = 'person';
+ $contacts =
$this->bo->get_principal_persons_data($contact_id);
+ $userformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ if($userformat != $this->bo->bday_internformat)
{
- $showcol = $col;
- }
- /* yank the *'s prior to testing for a valid
column description */
- $coltest = ereg_replace('\*','',$showcol);
- if($coltest)
- {
-
$GLOBALS['phpgw']->template->set_var($col,$showcol);
-
if($GLOBALS['phpgw_info']['user']['preferences']['addressbook'][$col])
- {
-
$GLOBALS['phpgw']->template->set_var($col.'_checked',' checked');
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var($col.'_checked','');
- }
+ $datetime =
CreateObject("phpgwapi.datetime");
+ $contacts['per_birthday'] =
$datetime->convertDate($contacts['per_birthday'], $this->bo->bday_internformat,
$userformat);
}
}
+ elseif($contact_type == $this->tab_main_organizations)
+ {
+ $type = 'org';
+ $contacts =
$this->bo->get_principal_organizations_data($contact_id);
+ }
- if($customfields)
+ if(isset($contacts['tab_extra']) &&
is_array($contacts['tab_extra']))
{
- $custom_var = '
- <tr>
- <td><font color="#000000" face="">'.lang('Custom').'
'.lang('Fields').':</font></td>
- <td></td>
- <td></td>
- </tr>
-';
- while(list($cf) = each($customfields))
+ foreach($contacts['tab_extra'] as $key =>
$value)
{
- $tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
- $custom_var .= "\n" . '<tr bgcolor="' .
$tr_color . '">' . "\n";
- $custom_var .= ' <td><input
type="checkbox" name="prefs['
- . strtolower($cf) . ']"'
- . ($this->prefs[$cf] ? '
checked' : '')
- . '>' . $cf . '</option></td>'
. "\n"
- . '</tr>' . "\n";
+ $contacts[$key] = $value;
}
-
$GLOBALS['phpgw']->template->set_var('custom_fields',$custom_var);
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('custom_fields','');
}
- $tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
-
$GLOBALS['phpgw']->template->set_var(tr_color,$tr_color);
-
$GLOBALS['phpgw']->template->set_var('lang_showbirthday',lang('show birthday
reminders on main screen'));
+ $owner=$contacts['owner'];
+ $cats=$contacts['tab_cats']['my_cats'];
+ $access=$contacts['access'];
+
+ unset($contacts['tab_cats']);
+ unset($contacts['tab_extra']);
- if($this->prefs['mainscreen_showbirthdays'])
+ if(!$this->bo->check_read($contact_id, $owner))
{
-
$GLOBALS['phpgw']->template->set_var('show_birthday',' checked');
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$contact_type));
}
- else
+
+ foreach($cats as $key => $cat_id)
{
-
$GLOBALS['phpgw']->template->set_var('show_birthday','');
+ if($cat_id)
+ {
+ $catinfo =
$this->cat->return_single(intval($cat_id));
+ $catname .= $catinfo[0]['name'] . '; ';
+ }
}
- $list = array(
- '' => lang('All'),
- 'private' => lang('Private'),
- 'blank' => lang('Blank')
- );
-
$GLOBALS['phpgw']->template->set_var('lang_default_filter',lang('Default
Filter'));
-
$GLOBALS['phpgw']->template->set_var('filter_select',$this->formatted_list('other[default_filter]',$list,$this->prefs['default_filter']));
+ unset($contacts['contact_id']);
+ unset($contacts['cat_id']);
+ unset($contacts['access']);
+ unset($contacts['owner']);
+ unset($contacts['email']);
+ unset($contacts['wphone']);
+ unset($contacts['load']);
+ unset($contacts['my_cats']);
+
+ $comms = $this->bo->get_comm_contact_data($contact_id);
-
$GLOBALS['phpgw']->template->set_var('lang_autosave',lang('Autosave default
category'));
- if($this->prefs['autosave_category'])
+ if(is_array($comms[$contact_id]))
{
-
$GLOBALS['phpgw']->template->set_var('autosave',' checked');
+ $contacts = $contacts + $comms[$contact_id];
+ $comms_media[] =
array_keys($comms[$contact_id]);
}
else
{
-
$GLOBALS['phpgw']->template->set_var('autosave','');
- }
-
$GLOBALS['phpgw']->template->set_var('lang_defaultcat',lang('Default
Category'));
-
$GLOBALS['phpgw']->template->set_var('cat_select',$this->cat_option($this->prefs['default_category']));
-
$GLOBALS['phpgw']->template->set_var('lang_abprefs',lang('Addressbook').'
'.lang('Preferences'));
-
$GLOBALS['phpgw']->template->set_var('lang_fields',lang('Fields to show in
address list'));
-
$GLOBALS['phpgw']->template->set_var('lang_personal',lang('Personal'));
-
$GLOBALS['phpgw']->template->set_var('lang_business',lang('Business'));
-
$GLOBALS['phpgw']->template->set_var('lang_home',lang('Home'));
-
$GLOBALS['phpgw']->template->set_var('lang_phones',lang('Extra').'
'.lang('Phone Numbers'));
-
$GLOBALS['phpgw']->template->set_var('lang_other',lang('Other').'
'.lang('Fields'));
-
$GLOBALS['phpgw']->template->set_var('lang_otherprefs',lang('Other').'
'.lang('Preferences'));
-
$GLOBALS['phpgw']->template->set_var('lang_submit',lang('submit'));
- $GLOBALS['phpgw']->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
-
$GLOBALS['phpgw']->template->set_var('th_text',$GLOBALS['phpgw_info']['theme']['th_text']);
- $GLOBALS['phpgw']->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
-
$GLOBALS['phpgw']->template->set_var('row_off',$GLOBALS['phpgw_info']['theme']['row_off']);
-
- $this->output .=
$GLOBALS['phpgw']->template->parse('out','preferences');
- $this->totpl();
- }
-
- function get_form()
- {
- $entry = $GLOBALS['HTTP_POST_VARS']['entry'];
- $fcat_id = $GLOBALS['HTTP_POST_VARS']['fcat_id'];
- $referer = $entry['referer'] ? $entry['referer'] :
$GLOBALS['HTTP_GET_VARS']['referer'];
- $referer = $referer ? $referer :
$GLOBALS['HTTP_POST_VARS']['referer'];
-
- $test = @unserialize(rawurldecode($entry));
- if($test && ($test != $entry))
- {
- $entry = $test;
+ $comms_media[0] = array();
}
- /* _debug_array($entry); exit; */
+
+
+ $addr = $this->bo->get_addr_contact_data($contact_id,
array('addr_pref_val'=>'Y'));
- if(!$entry['bday_month'] && !$entry['bday_day'] &&
!$entry['bday_year'])
- {
- $fields['bday'] = '';
- }
- else
+ unset($addr[0]['contact_id']);
+ unset($addr[0]['key_addr_id']);
+ unset($addr[0]['addr_type']);
+ unset($addr[0]['addr_preferred']);
+ unset($addr[0]['addr_description']);
+ unset($addr[0]['addr_contact_id']);
+
+ $contacts = array_merge($contacts, $addr[0]);
+
+ $others =
$this->bo->get_others_contact_data($contact_id);
+ if(is_array($others))
{
- $bday_day = $entry['bday_day'];
- if(strlen($bday_day) == 1)
+ foreach($others as $key => $other_data)
{
- $bday_day = '0' . $entry['bday_day'];
+ $contacts[$other_data['other_name']] =
$other_data['other_value'];
}
- $fields['bday'] = $entry['bday_month'] . '/' .
$bday_day . '/' . $entry['bday_year'];
}
- $fields['url'] = $entry['url'] == 'http://' ? '' :
$entry['url'];
+ $this->template->set_file(array('view_t' =>
'view.tpl'));
+
$this->template->set_block('view_t','view_header','view_header');
+
$this->template->set_block('view_t','view_row','view_row');
+
$this->template->set_block('view_t','view_footer','view_footer');
+
$this->template->set_block('view_t','view_buttons','view_buttons');
+ $GLOBALS['phpgw']->common->phpgw_header();
+ echo parse_navbar();
- $fields['org_name'] =
$entry['company'];
- $fields['org_unit'] =
$entry['department'];
- $fields['n_given'] =
$entry['firstname'];
- $fields['n_family'] =
$entry['lastname'];
- $fields['n_middle'] =
$entry['middle'];
- $fields['n_prefix'] =
$entry['prefix'];
- $fields['n_suffix'] =
$entry['suffix'];
- if($entry['prefix']) { $pspc = ' '; }
- if($entry['middle']) { $mspc = ' '; } else { $nspc = '
'; }
- if($entry['suffix']) { $sspc = ' '; }
- $fields['fn'] =
$entry['prefix'].$pspc.$entry['firstname'].$nspc.$mspc.$entry['middle'].$mspc.$entry['lastname'].$sspc.$entry['suffix'];
- $fields['email'] =
$entry['email'];
- $fields['email_type'] =
$entry['email_type'];
- $fields['email_home'] =
$entry['hemail'];
- $fields['email_home_type'] =
$entry['hemail_type'];
- $fields['title'] =
$entry['title'];
- $fields['tel_work'] =
$entry['wphone'];
- $fields['tel_home'] =
$entry['hphone'];
- $fields['tel_fax'] =
$entry['fax'];
- $fields['tel_pager'] =
$entry['pager'];
- $fields['tel_cell'] =
$entry['mphone'];
- $fields['tel_msg'] =
$entry['msgphone'];
- $fields['tel_car'] =
$entry['carphone'];
- $fields['tel_video'] =
$entry['vidphone'];
- $fields['tel_isdn'] =
$entry['isdnphone'];
- $fields['adr_one_street'] =
$entry['bstreet'];
- $fields['adr_one_locality'] =
$entry['bcity'];
- $fields['adr_one_region'] =
$entry['bstate'];
- $fields['adr_one_postalcode'] = $entry['bzip'];
- $fields['adr_one_countryname'] = $entry['bcountry'];
+ $this->template->set_var('lang_viewpref',lang('Address
book - view'));
+
+ $tr_color = $GLOBALS['phpgw_info']['theme']['row_on'];
- if($entry['one_dom'])
+ foreach($contacts as $field => $data)
{
- $typea .= 'dom;';
+ $data = htmlentities($data);
+ $ref='';
+ if(!is_numeric($field) && $data!='')
+ {
+ $tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+
$this->template->set_var('th_bg',$tr_color);
+ if(in_array($field, $comms_media[0]))
+ {
+
$this->template->set_var('display_col',lang($field));
+ if(strpos($field, 'email'))
+ {
+ if
($GLOBALS['phpgw_info']['user']['apps']['email'])
+ {
+ $ref='<a
href="'.$GLOBALS['phpgw']->link(
+
"/email/compose.php","to="
+ .
urlencode($data))
+ .'"
target="_new">';
+ }
+ else
+ {
+ $ref='<a
href="mailto:'.$data.'">';
+ }
+ $data=$data . '</a>';
+ }
+ if($field=='website')
+ {
+ if ( !empty($data) &&
(substr($data,0,7) != 'http://') )
+ {
+ $data =
'http://' . $data;
+ }
+ $ref='<a
href="'.$data.'" target="_new">';
+ $data=$data.'</a>';
+ }
+ }
+ else
+ {
+
$this->template->set_var('display_col',$this->bo->display_name($field));
+ }
+
+
$this->template->set_var('ref_data',$ref.$data);
+
$this->template->parse('cols','view_row',True);
+ }
}
- if($entry['one_intl'])
+ /* Following cleans up view_row, since we were only
using it to fill {cols} */
+ $this->template->set_var('view_row','');
+
+ /* These are in the footer */
+ $this->template->set_var('lang_owner',lang('Record
owner'));
+ if($owner ==
$GLOBALS['phpgw_info']['server']['addressmaster'])
{
- $typea .= 'intl;';
+ $this->template->set_var('owner',
'addressmaster');
}
- if($entry['one_parcel'])
+ else
{
- $typea .= 'parcel;';
+
$this->template->set_var('owner',$GLOBALS['phpgw']->common->grab_owner_name($owner));
}
- if($entry['one_postal'])
- {
- $typea .= 'postal;';
+ $this->template->set_var('lang_access',lang('Record
access'));
+ $this->template->set_var('access',$access);
+
$this->template->set_var('lang_category',lang('Category'));
+ $this->template->set_var('catname',$catname);
+ if($this->bo->check_edit($contact_id))
+ {
+
$this->template->set_var('edit_button',$this->html_1button_form('edit','Edit',
+ $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.edit_'. $type
+ . '&ab_id='
.$contact_id)));
}
- $fields['adr_one_type'] = substr($typea,0,-1);
-
- $fields['address2'] =
$entry['address2'];
- $fields['address3'] =
$entry['address3'];
-
- $fields['adr_two_street'] =
$entry['hstreet'];
- $fields['adr_two_locality'] =
$entry['hcity'];
- $fields['adr_two_region'] =
$entry['hstate'];
- $fields['adr_two_postalcode'] = $entry['hzip'];
- $fields['adr_two_countryname'] = $entry['hcountry'];
-
- if($entry['two_dom'])
+ else
{
- $typeb .= 'dom;';
+ $this->template->set_var('edit_button', '');
}
- if($entry['two_intl'])
- {
- $typeb .= 'intl;';
+
+
$this->template->set_var('copy_button',$this->html_1button_form('submit','copy',
+
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.copy_'
. $type
+ . '&ab_id=' .
$contact_id)));
+
+ if ($contacts['per_first_name'] &&
$contacts['per_last_name'])
+ {
+
$this->template->set_var('vcard_button',$this->html_1button_form('VCardForm','VCard',
+ $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uivcard.out&ab_id=' .$contact_id)));
}
- if($entry['two_parcel'])
+ else
{
- $typeb .= 'parcel;';
+
$this->template->set_var('vcard_button',lang('no vcard'));
}
- if($entry['two_postal'])
+
+
$this->template->set_var('done_button',$this->html_1button_form('DoneForm','Done',
+ $referer ? $referer :
$GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.index§ion='.$contact_type)));
+ $this->template->set_var('access_link',$access_link);
+
+ $this->template->pparse('out','view_t');
+
+ if($contact_type == $this->tab_main_persons)
{
- $typeb .= 'postal;';
+ $GLOBALS['phpgw']->hooks->process(array(
+
'location' => 'addressbook_view',
+
'ab_id' => $contact_id));
}
- $fields['adr_two_type'] = substr($typeb,0,-1);
+ }
+
+ function get_comm_value($contact_id, $column)
+ {
+ return $this->entries_comm[$contact_id][$column];
+ }
- $custom = $this->fields->read_custom_fields();
- while(list($name,$val) = @each($custom))
- {
- @$fields[$name] = $entry[$val];
+ 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 get_action_buttons($js_submit='', $delete)
+ {
+ $this->template->set_file(array('add' => 'add.tpl'));
+ $this->template->set_var('lang_save',lang('Save'));
+ $this->template->set_var('lang_cancel',lang('Cancel'));
+ $this->template->set_var('lang_delete', $delete);
+ $this->template->set_var('js_submit', $js_submit);
+ return $this->template->parse('out','add');
+ }
+
+ function get_column_data($properties=array())
+ {
+ switch($properties['type'])
+ {
+ case 'data':
+ $column_data =
htmlentities($this->array_value[$properties['field']]);
+ break;
+ case 'text':
+ $column_data = '<input type="text" '
+ .'name="' . $properties['name'] . '[' .
$this->array_value[$properties['field']] . ']" '
+ .'value="' .
$this->array_value[$properties['value']] . '">';
+ break;
+ case 'radio':
+
if($this->array_value[$properties['field']]=='Y'){$checked='checked';}
+ $column_data = '<input type="radio" name="' .
$properties['name']
+ .'" value="' .
htmlentities($this->array_value[$properties['value']]) . '"'. $checked . '>';
+ break;
+ case 'link':
+ $link = $GLOBALS['phpgw']->link('/index.php',
$this->form_action)
+ . '&'. $properties['action'] . '=' .
$this->array_value[$properties['key']] . $properties['extra'];
+ $column_data = '<a
href="'.$link.'">'.lang($properties['mode']).'</a>';
+ break;
}
+ return $column_data;
+ }
+
+ function set_form_fields($form_fields)
+ {
+ $tr_color = $GLOBALS['phpgw_info']['theme']['row_on'];
- $fields['ophone'] = $entry['ophone'];
- $fields['tz'] = $entry['timezone'];
- $fields['pubkey'] = $entry['pubkey'];
- $fields['note'] = $entry['notes'];
- $fields['label'] = $entry['label'];
+ ksort($form_fields, SORT_NUMERIC);
- if($entry['access'] == True)
+ foreach($form_fields as $key => $row)
+ {
+ $this->template->set_var('row_bgc', $tr_color);
+ if($row[2] == 'special')
+ {
+ if(($key % 2) == 0)
+ {
+
$this->set_row_other_input($row[0],$row[1],2);
+ $tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+
$this->template->fp('input_other_fields_cols', 'other_data', True);
+
$this->template->fp('other_fields', 'input_other_data');
+ }
+ else
+ {
+
$this->set_row_other_input($row[0],$row[1],1);
+ }
+ }
+ else
+ {
+ if(($key % 2) == 0)
+ {
+
$this->set_row_input($row[0],$row[1],$row[2],2);
+ $tr_color =
$GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+
$this->template->fp('input_fields_cols', 'input_data_col', True);
+
$this->template->fp('input_fields', 'input_data');
+ }
+ else
+ {
+
$this->set_row_input($row[0],$row[1],$row[2],1);
+ }
+ }
+ }
+ }
+
+ function set_row_input($field_name, $input_name, $input_value,
$col)
+ {
+ if ($col==1)
{
- $fields['access'] = 'private';
+ $this->template->set_var('field_name_one',
lang($field_name));
+ $this->template->set_var('input_name_one',
$input_name);
+ $this->template->set_var('input_value_one',
$input_value);
}
else
{
- $fields['access'] = 'public';
+ $this->template->set_var('field_name_two',
lang($field_name));
+ $this->template->set_var('input_name_two',
$input_name);
+ $this->template->set_var('input_value_two',
$input_value);
}
+ }
- if(is_array($fcat_id))
+ function set_row_other_input($field_name, $field_value, $col)
+ {
+ if ($col==1)
{
- $fields['cat_id'] = count($fcat_id) > 1 ?
','.implode(',',$fcat_id).',' : $fcat_id[0];
+ $this->template->set_var('field_other_name1',
lang($field_name));
+ $this->template->set_var('value_other_name1',
$field_value);
}
else
{
- $fields['cat_id'] = $fcat_id;
- }
-
- $fields['ab_id'] = $entry['ab_id'];
- $fields['tid'] = $entry['tid'];
- if(!$fields['tid'])
- {
- $fields['tid'] = 'n';
+ $this->template->set_var('field_other_name2',
lang($field_name));
+ $this->template->set_var('value_other_name2',
$field_value);
}
+ }
- $fields['referer'] = $referer;
- /* _debug_array($fields);exit; */
- return $fields;
- } /* end get_form() */
-
- /* Following used for add/edit */
- function
addressbook_form($format,$action,$title='',$fields='',$customfields='',$cat_id='')
+ function get_persons($fields_to_search, $current_person)
{
- $referer = $GLOBALS['HTTP_GET_VARS']['referer'] ?
$GLOBALS['HTTP_GET_VARS']['referer'] : $GLOBALS['HTTP_POST_VARS']['referer'];
-
- $GLOBALS['phpgw']->template->set_file(array('form' =>
'form.tpl'));
+ $criteria =
$this->bo->criteria_contacts(PHPGW_CONTACTS_ALL,PHPGW_CONTACTS_CATEGORIES_ALL,array(),'',$fields_to_search);
+ $persons =
$this->bo->get_persons($fields_to_search,'','','first_name','','',$criteria);
- if(($GLOBALS['phpgw_info']['server']['countrylist'] ==
'user_choice' &&
-
$GLOBALS['phpgw_info']['user']['preferences']['common']['countrylist'] ==
'use_select') ||
-
($GLOBALS['phpgw_info']['server']['countrylist'] == 'force_select'))
+ if ($persons)
{
- $countrylist = True;
+ foreach ($persons as $k => $v)
+ {
+ if (is_array($current_person) &&
in_array($v['contact_id'], $current_person))
+ {
+ $this->my_person_data .=
'<option value="' . $v['contact_id'] . '">'
+
.$v['per_full_name'].'</option>';
+
$this->my_person_array[$v['contact_id']] = $v['per_first_name'];
+ }
+ else
+ {
+ $this->all_person_data .=
'<option value="' . $v['contact_id'] . '">'
+
.$v['per_full_name'].'</option>';
+ }
+ }
}
+ }
- $email = $fields['email'];
- $emailtype = $fields['email_type'];
- $hemail = $fields['email_home'];
- $hemailtype = $fields['email_home_type'];
- $firstname = $fields['n_given'];
- $middle = $fields['n_middle'];
- $prefix = $fields['n_prefix'];
- $suffix = $fields['n_suffix'];
- $lastname = $fields['n_family'];
- $title = $fields['title'];
- $wphone = $fields['tel_work'];
- $hphone = $fields['tel_home'];
- $fax = $fields['tel_fax'];
- $pager = $fields['tel_pager'];
- $mphone = $fields['tel_cell'];
- $ophone = $fields['ophone'];
- $msgphone = $fields['tel_msg'];
- $isdnphone = $fields['tel_isdn'];
- $carphone = $fields['tel_car'];
- $vidphone = $fields['tel_video'];
- $preferred = $fields['tel_prefer'];
-
- $bstreet = $fields['adr_one_street'];
- $address2 = $fields['address2'];
- $address3 = $fields['address3'];
- $bcity = $fields['adr_one_locality'];
- $bstate = $fields['adr_one_region'];
- $bzip = $fields['adr_one_postalcode'];
- $bcountry = $fields['adr_one_countryname'];
- $one_dom = $fields['one_dom'];
- $one_intl = $fields['one_intl'];
- $one_parcel = $fields['one_parcel'];
- $one_postal = $fields['one_postal'];
-
- $hstreet = $fields['adr_two_street'];
- $hcity = $fields['adr_two_locality'];
- $hstate = $fields['adr_two_region'];
- $hzip = $fields['adr_two_postalcode'];
- $hcountry = $fields['adr_two_countryname'];
- $btype = $fields['adr_two_type'];
- $two_dom = $fields['two_dom'];
- $two_intl = $fields['two_intl'];
- $two_parcel = $fields['two_parcel'];
- $two_postal = $fields['two_postal'];
-
- $timezone = $fields['tz'];
- $bday = $fields['bday'];
- $notes = stripslashes($fields['note']);
- $label = stripslashes($fields['label']);
- $company = $fields['org_name'];
- $department = $fields['org_unit'];
- $url = $fields['url'];
- $pubkey = $fields['pubkey'];
- $access = $fields['access'];
- if(!$cat_id)
+ function get_orgs($fields_to_search, $current_orgs)
+ {
+ $criteria =
$this->bo->criteria_contacts(PHPGW_CONTACTS_ALL,PHPGW_CONTACTS_CATEGORIES_ALL,array(),'',$fields_to_search);
+ $orgs =
$this->bo->get_orgs($fields_to_search,'','','org_name','','',$criteria);
+ if ($orgs)
{
- $cat_id = $fields['cat_id'];
+ foreach ($orgs as $k => $v)
+ {
+ if (is_array($current_orgs) &&
in_array($v['contact_id'], $current_orgs))
+ {
+ $this->my_orgs_data .= '<option
value="' . $v['contact_id'] . '">'
+
.$v['org_name'].'</option>';
+
$this->my_orgs_array[$v['contact_id']] = $v['org_name'];
+ }
+ else
+ {
+ $this->all_orgs_data .=
'<option value="' . $v['contact_id'] . '">'
+
.$v['org_name'].'</option>';
+ }
+ }
}
- $cats_link = $this->cat_option($cat_id,True,False,True);
+ }
- if($access == 'private')
- {
- $access_check = ' checked';
- }
- else
+ function get_cats($fields_to_search, $current_cats)
+ {
+ $cats =
$this->cat->return_array('all',$start,False,$query,$sort,$order,True);
+ if ($cats)
{
- $access_check = '';
+ foreach ($cats as $k => $v)
+ {
+ if (is_array($current_cats) &&
in_array($v['id'], $current_cats))
+ {
+ $this->my_cats_data .= '<option
value="' . $v['id'] . '">'
+ .$v['name'].'</option>';
+ $this->my_cats_array[$v['id']]
= $v['name'];
+ }
+ else
+ {
+ $this->all_cats_data .=
'<option value="' . $v['id'] . '">'
+ .$v['name'].'</option>';
+ }
+ }
}
+ }
- if($customfields)
- {
- while(list($name,$value) = each($customfields))
+ function java_script()
+ {
+ $tmp= '
+ <SCRIPT LANGUAGE="JavaScript">
+ function move(fboxname, tboxname, sboxname, cboxname) {
+ var arrFbox = new Array();
+ var arrTbox = new Array();
+ var arrLookup = new Array();
+ var i;
+
+ fbox = document.body_form.elements[fboxname];
+ tbox = document.body_form.elements[tboxname];
+
+ for (i = 0; i < tbox.options.length; i++)
{
- $value = ereg_replace('_',' ',$value);
- $custom .= '
- <tr bgcolor="' . $GLOBALS['phpgw_info']['theme']['row_off'] . '">
- <td> </td>
- <td><font color="' . $GLOBALS['phpgw_info']['theme']['th_text'] . '"
face="" size="-1">'.$value.':</font></td>
- <td colspan="3"><INPUT size="30" name="entry[' . $name . ']" value="' .
$fields[$name] . '"></td>
- </tr>
-';
+ arrLookup[tbox.options[i].text] =
tbox.options[i].value;
+ arrTbox[i] = tbox.options[i].text;
}
- }
-
- if($format != "view")
- {
- /* Preferred phone number radio buttons */
- $pref[0] = '<font size="-2">';
- $pref[1] = '(' . lang('pref') . ')</font>';
- while(list($name,$val) =
each($this->contacts->tel_types))
+ var fLength = 0;
+ var tLength = arrTbox.length;
+ for(i = 0; i < fbox.options.length; i++)
{
- $str[$name] = "\n".' <input
type="radio" name="entry[tel_prefer]" value="'.$name.'"';
- if($name == $preferred)
+ arrLookup[fbox.options[i].text] =
fbox.options[i].value;
+ if (fbox.options[i].selected &&
fbox.options[i].value != "")
+ {
+ arrTbox[tLength] =
fbox.options[i].text;
+ tLength++;
+ }
+ else
{
- $str[$name] .= ' checked';
+ arrFbox[fLength] =
fbox.options[i].text;
+ fLength++;
}
- $str[$name] .= '>';
- $str[$name] =
$pref[0].$str[$name].$pref[1];
-
$GLOBALS['phpgw']->template->set_var("pref_".$name,$str[$name]);
}
+ arrFbox.sort();
+ arrTbox.sort();
+ fbox.length = 0;
+ tbox.length = 0;
+
+ var c;
+ for(c = 0; c < arrFbox.length; c++)
+ {
+ var no = new Option();
+ no.value = arrLookup[arrFbox[c]];
+ no.text = arrFbox[c];
+ fbox[c] = no;
+ }
+ for(c = 0; c < arrTbox.length; c++)
+ {
+ var no = new Option();
+ no.value = arrLookup[arrTbox[c]];
+ no.text = arrTbox[c];
+ tbox[c] = no;
+ }
+
+ move_cbo(sboxname, cboxname);
+ }
- if(strlen($bday) > 2)
+ function move_cbo(sboxname, cboxname) {
+ sbox = document.body_form.elements[sboxname];
+ cbox = document.body_form.elements[cboxname];
+ if(sbox.length > 0)
{
- list( $month, $day, $year ) = split(
'/', $bday );
- $temp_month[$month] = ' selected';
- $bday_month = '<select
name="entry[bday_month]">'
- . '<option value=""' .
$temp_month[0] . '>' . '</option>'
- . '<option value="1"' .
$temp_month[1] . '>' . lang('january') . '</option>'
- . '<option value="2"' .
$temp_month[2] . '>' . lang('february') . '</option>'
- . '<option value="3"' .
$temp_month[3] . '>' . lang('march') . '</option>'
- . '<option value="4"' .
$temp_month[4] . '>' . lang('april') . '</option>'
- . '<option value="5"' .
$temp_month[5] . '>' . lang('may') . '</option>'
- . '<option value="6"' .
$temp_month[6] . '>' . lang('june') . '</option>'
- . '<option value="7"' .
$temp_month[7] . '>' . lang('july') . '</option>'
- . '<option value="8"' .
$temp_month[8] . '>' . lang('august') . '</option>'
- . '<option value="9"' .
$temp_month[9] . '>' . lang('september') . '</option>'
- . '<option value="10"' .
$temp_month[10] . '>' . lang('october') . '</option>'
- . '<option value="11"' .
$temp_month[11] . '>' . lang('november') . '</option>'
- . '<option value="12"' .
$temp_month[12] . '>' . lang('december') . '</option>'
- . '</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">';
+ sel_opt =
sbox.options[sbox.selectedIndex].text;
}
else
{
- $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">';
- }
-
- $time_zone = '<select name="entry[timezone]">'
. "\n";
- for($i = -23; $i<24; $i++)
+ sel_opt="";
+ }
+ sbox.length = 0;
+ for(c = 0; c < cbox.length; c++)
{
- $time_zone .= '<option value="' . $i .
'"';
- if($i == $timezone)
+ var no = new Option();
+ no.value = cbox[c].value;
+ no.text = cbox[c].text;
+ if(no.text == sel_opt)
{
- $time_zone .= ' selected';
+ i = c;
}
- if($i < 1)
+ sbox[c] = no;
+ }
+ if(i>0)
+ {
+ sbox.options[i].selected = true;
+ }
+ }
+
+ function process_list(allboxname, myboxname) {
+ mybox = document.body_form.elements[myboxname];
+ for(c = 0; c < mybox.options.length; c++)
+ {
+ mybox.options[c].selected = true;
+ }
+ }
+
+ function showHide(sDiv)
+ {
+ var oDiv = document.getElementById(sDiv);
+ if (oDiv)
+ oDiv.style.display = oDiv.style.display
== "none" ? "" : "none";
+ }
+ </script>';
+ return $tmp;
+ }
+
+ function css()
+ {
+ $tmp = 'input[type="submit"].button_style,
input[type="button"].button_style {
+ color: #555;
+ margin-left: 1px;
+ margin-right: 1px;
+
+ background-color: #ddd;
+ border:1px #888 solid;
+ border-bottom-width: 0px;
+ padding: 1px;
+ width: 85px;
+ }
+
+ input[type="submit"].button_style_sel,
input[type="button"].button_style_sel {
+ color: #555;
+ margin-left: 1px;
+ margin-right: 1px;
+
+ /*background-color: #e5e5e5;*/
+ border:1px #888 solid;
+ border-bottom-width: 0px;
+ padding: 1px;
+ width: 85px;
+ }
+
+ input[type="submit"]:hover.button_style,
input[type="button"]:hover.button_style {
+ background-color: #eee;
+ color: #36c;
+ }
+
+ input[type="submit"]:active.button_style,
input[type="button"]:active.button_style {
+ background-color: #eee;
+ color: #9ac;
+ }';
+ return $tmp;
+ }
+
+ function get_comm_descr($comm_selected, $type='')
+ {
+ if(is_array($this->comm_descr))
+ {
+ foreach($this->comm_descr as $key => $value)
+ {
+ if ($value['comm_descr_id'] ==
$comm_selected)
{
- $time_zone .= '>' . $i .
'</option>' . "\n";
+ $comm_descr .= '<option
value="' . $value['comm_descr_id'] . '" selected>'
+ .
$value['comm_description'] . '</option>';
+ $comm_description =
$value['comm_description'];
}
else
{
- $time_zone .= '>+' . $i .
'</option>' . "\n";
+ $comm_descr .= '<option
value="' . $value['comm_descr_id'] . '">'
+ .
$value['comm_description'] . '</option>';
}
}
- $time_zone .= '</select>' . "\n";
-
- $email_type = '<select name=entry[email_type]>';
- while($type =
each($this->contacts->email_types))
+ if ($type=='text')
{
- $email_type .= '<option value="' .
$type[0] . '"';
- if($type[0] == $emailtype)
- {
- $email_type .= ' selected';
- }
- $email_type .= '>' . $type[1] .
'</option>';
+ return $comm_description;
+ }
+ else
+ {
+ return $comm_descr;
}
- $email_type .= '</select>';
+ }
+ }
- reset($this->contacts->email_types);
- $hemail_type = '<select
name=entry[hemail_type]>';
- while($type =
each($this->contacts->email_types))
+ function get_addr_type($selected, $type='')
+ {
+ if(is_array($this->addr_type))
+ {
+ foreach($this->addr_type as $key => $value)
{
- $hemail_type .= '<option value="' .
$type[0] . '"';
- if($type[0] == $hemailtype)
+ if ($value['addr_type_id'] == $selected)
{
- $hemail_type .= ' selected';
+ $addr_type .= '<option value="'
. $value['addr_type_id'] . '" selected>'
+ .
$value['addr_description'] . '</option>';
+ $addr_description =
$value['addr_description'];
+ }
+ else
+ {
+ $addr_type .= '<option value="'
. $value['addr_type_id'] . '">'
+ .
$value['addr_description'] . '</option>';
}
- $hemail_type .= '>' . $type[1] .
'</option>';
}
- $hemail_type .= '</select>';
-
- reset($this->contacts->adr_types);
- while(list($type,$val) =
each($this->contacts->adr_types))
+ if ($type=='text')
{
- $badrtype .= "\n".'<INPUT
type="checkbox" name="entry[one_'.$type.']"';
- $ot = 'one_'.$type;
- eval("
- if (\$$ot=='on') {
- \$badrtype .= '
value=\"on\" checked';
- }
- ");
- $badrtype .= '>'.$val;
+ return $addr_description;
+ }
+ else
+ {
+ return $addr_type;
}
+ }
+ }
- reset($this->contacts->adr_types);
- while(list($type,$val) =
each($this->contacts->adr_types))
+ function get_my_option_selected($my_opt_array, $selected)
+ {
+ if (is_array($this->$my_opt_array))
+ {
+ foreach($this->$my_opt_array as $key => $value)
{
- $hadrtype .= "\n".'<INPUT
type="checkbox" name="entry[two_'.$type.']"';
- $tt = 'two_'.$type;
- eval("
- if (\$$tt=='on') {
- \$hadrtype .= '
value=\"on\" checked';
- }
- ");
- $hadrtype .= '>'.$val;
+ if ($key == $selected)
+ {
+ $my_opt .= '<option value="' .
$key . '" selected>'
+ . $value . '</option>';
+ }
+ else
+ {
+ $my_opt .= '<option value="' .
$key . '">'
+ . $value . '</option>';
+ }
}
+ }
+ return $my_opt;
+ }
- $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>';
- }
- else
- {
- $notes = '<form><TEXTAREA cols="60"
name="entry[notes]" rows="4">'
- . $notes . '</TEXTAREA></form>';
- if($bday == '//')
- {
- $bday = '';
- }
- }
-
- if($action)
- {
- echo '<FORM action="' .
$GLOBALS['phpgw']->link('/index.php', $action .
'&referer='.urlencode($referer)).'" method="post">';
- }
-
- if(!ereg('^http://',$url))
- {
- $url = 'http://' . $url;
- }
-
- $birthday =
$GLOBALS['phpgw']->common->dateformatorder($bday_year,$bday_month,$bday_day)
- . '<font face="'.$theme["font"].'"
size="-2">(e.g. 1969)</font>';
- if($format == 'edit')
- {
- $create .= '<tr bgcolor="' .
$GLOBALS['phpgw_info']['theme']['th_bg'] . '"><td colspan="2"><font size="-1">'
. lang("Created by") . ':</font></td>'
- . '<td colspan="3"><font size="-1">'
- .
$GLOBALS['phpgw']->common->grab_owner_name($fields["owner"]);
- }
- else
- {
- $create .= '';
- }
-
-
$GLOBALS['phpgw']->template->set_var('lang_home',lang('Home'));
-
$GLOBALS['phpgw']->template->set_var('lang_business',lang('Business'));
-
$GLOBALS['phpgw']->template->set_var('lang_personal',lang('Personal'));
-
-
$GLOBALS['phpgw']->template->set_var('lang_lastname',lang('Last Name'));
-
$GLOBALS['phpgw']->template->set_var('lastname',$lastname);
-
$GLOBALS['phpgw']->template->set_var('lang_firstname',lang('First Name'));
-
$GLOBALS['phpgw']->template->set_var('firstname',$firstname);
-
$GLOBALS['phpgw']->template->set_var('lang_middle',lang('Middle Name'));
- $GLOBALS['phpgw']->template->set_var('middle',$middle);
-
$GLOBALS['phpgw']->template->set_var('lang_prefix',lang('Prefix'));
- $GLOBALS['phpgw']->template->set_var('prefix',$prefix);
-
$GLOBALS['phpgw']->template->set_var('lang_suffix',lang('Suffix'));
- $GLOBALS['phpgw']->template->set_var('suffix',$suffix);
-
$GLOBALS['phpgw']->template->set_var('lang_birthday',lang('Birthday'));
-
$GLOBALS['phpgw']->template->set_var('birthday',$birthday);
-
-
$GLOBALS['phpgw']->template->set_var('lang_company',lang('Company Name'));
-
$GLOBALS['phpgw']->template->set_var('company',$company);
-
$GLOBALS['phpgw']->template->set_var('lang_department',lang('Department'));
-
$GLOBALS['phpgw']->template->set_var('department',$department);
-
$GLOBALS['phpgw']->template->set_var('lang_title',lang('Title'));
- $GLOBALS['phpgw']->template->set_var('title',$title);
-
$GLOBALS['phpgw']->template->set_var('lang_email',lang('Business Email'));
- $GLOBALS['phpgw']->template->set_var('email',$email);
-
$GLOBALS['phpgw']->template->set_var('lang_email_type',lang('Business EMail
Type'));
-
$GLOBALS['phpgw']->template->set_var('email_type',$email_type);
-
$GLOBALS['phpgw']->template->set_var('lang_url',lang('URL'));
- $GLOBALS['phpgw']->template->set_var('url',$url);
-
$GLOBALS['phpgw']->template->set_var('lang_timezone',lang('time zone offset'));
-
$GLOBALS['phpgw']->template->set_var('timezone',$time_zone);
-
$GLOBALS['phpgw']->template->set_var('lang_fax',lang('Business Fax'));
- $GLOBALS['phpgw']->template->set_var('fax',$fax);
-
$GLOBALS['phpgw']->template->set_var('lang_wphone',lang('Business Phone'));
- $GLOBALS['phpgw']->template->set_var('wphone',$wphone);
-
$GLOBALS['phpgw']->template->set_var('lang_pager',lang('Pager'));
- $GLOBALS['phpgw']->template->set_var('pager',$pager);
-
$GLOBALS['phpgw']->template->set_var('lang_mphone',lang('Cell Phone'));
- $GLOBALS['phpgw']->template->set_var('mphone',$mphone);
-
$GLOBALS['phpgw']->template->set_var('lang_msgphone',lang('Message Phone'));
-
$GLOBALS['phpgw']->template->set_var('msgphone',$msgphone);
-
$GLOBALS['phpgw']->template->set_var('lang_isdnphone',lang('ISDN Phone'));
-
$GLOBALS['phpgw']->template->set_var('isdnphone',$isdnphone);
-
$GLOBALS['phpgw']->template->set_var('lang_carphone',lang('Car Phone'));
-
$GLOBALS['phpgw']->template->set_var('carphone',$carphone);
-
$GLOBALS['phpgw']->template->set_var('lang_vidphone',lang('Video Phone'));
-
$GLOBALS['phpgw']->template->set_var('vidphone',$vidphone);
-
-
$GLOBALS['phpgw']->template->set_var('lang_ophone',lang('Other Number'));
- $GLOBALS['phpgw']->template->set_var('ophone',$ophone);
-
$GLOBALS['phpgw']->template->set_var('lang_bstreet',lang('Business Street'));
-
$GLOBALS['phpgw']->template->set_var('bstreet',$bstreet);
-
$GLOBALS['phpgw']->template->set_var('lang_address2',lang('Address Line 2'));
-
$GLOBALS['phpgw']->template->set_var('address2',$address2);
-
$GLOBALS['phpgw']->template->set_var('lang_address3',lang('Address Line 3'));
-
$GLOBALS['phpgw']->template->set_var('address3',$address3);
-
$GLOBALS['phpgw']->template->set_var('lang_bcity',lang('Business City'));
- $GLOBALS['phpgw']->template->set_var('bcity',$bcity);
-
$GLOBALS['phpgw']->template->set_var('lang_bstate',lang('Business State'));
- $GLOBALS['phpgw']->template->set_var('bstate',$bstate);
-
$GLOBALS['phpgw']->template->set_var('lang_bzip',lang('Business Zip Code'));
- $GLOBALS['phpgw']->template->set_var('bzip',$bzip);
-
$GLOBALS['phpgw']->template->set_var('lang_bcountry',lang('Business Country'));
-
$GLOBALS['phpgw']->template->set_var('bcountry',$bcountry);
- if($countrylist)
- {
-
$GLOBALS['phpgw']->template->set_var('bcountry',$GLOBALS['phpgw']->country->form_select($bcountry,'entry[bcountry]'));
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('bcountry','<input name="entry[bcountry]"
value="' . $bcountry . '">');
- }
-
$GLOBALS['phpgw']->template->set_var('lang_badrtype',lang('Address Type'));
-
$GLOBALS['phpgw']->template->set_var('badrtype',$badrtype);
-
-
$GLOBALS['phpgw']->template->set_var('lang_hphone',lang('Home Phone'));
- $GLOBALS['phpgw']->template->set_var('hphone',$hphone);
-
$GLOBALS['phpgw']->template->set_var('lang_hemail',lang('Home Email'));
- $GLOBALS['phpgw']->template->set_var('hemail',$hemail);
-
$GLOBALS['phpgw']->template->set_var('lang_hemail_type',lang('Home EMail
Type'));
-
$GLOBALS['phpgw']->template->set_var('hemail_type',$hemail_type);
-
$GLOBALS['phpgw']->template->set_var('lang_hstreet',lang('Home Street'));
-
$GLOBALS['phpgw']->template->set_var('hstreet',$hstreet);
-
$GLOBALS['phpgw']->template->set_var('lang_hcity',lang('Home City'));
- $GLOBALS['phpgw']->template->set_var('hcity',$hcity);
-
$GLOBALS['phpgw']->template->set_var('lang_hstate',lang('Home State'));
- $GLOBALS['phpgw']->template->set_var('hstate',$hstate);
-
$GLOBALS['phpgw']->template->set_var('lang_hzip',lang('Home Zip Code'));
- $GLOBALS['phpgw']->template->set_var('hzip',$hzip);
-
$GLOBALS['phpgw']->template->set_var('lang_hcountry',lang('Home Country'));
- if($countrylist)
- {
-
$GLOBALS['phpgw']->template->set_var('hcountry',$GLOBALS['phpgw']->country->form_select($hcountry,'entry[hcountry]'));
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('hcountry','<input name="entry[hcountry]"
value="' . $hcountry . '">');
- }
-
$GLOBALS['phpgw']->template->set_var('lang_hadrtype',lang('Address Type'));
-
$GLOBALS['phpgw']->template->set_var('hadrtype',$hadrtype);
-
- $GLOBALS['phpgw']->template->set_var('create',$create);
-
$GLOBALS['phpgw']->template->set_var('lang_notes',lang('notes'));
- $GLOBALS['phpgw']->template->set_var('notes',$notes);
-
$GLOBALS['phpgw']->template->set_var('lang_label',lang('label'));
- $GLOBALS['phpgw']->template->set_var('label',$label);
-
$GLOBALS['phpgw']->template->set_var('lang_pubkey',lang('Public Key'));
- $GLOBALS['phpgw']->template->set_var('pubkey',$pubkey);
-
$GLOBALS['phpgw']->template->set_var('access_check',$access_check);
-
-
$GLOBALS['phpgw']->template->set_var('lang_private',lang('Private'));
-
-
$GLOBALS['phpgw']->template->set_var('lang_cats',lang('Category'));
-
$GLOBALS['phpgw']->template->set_var('cats_link',$cats_link);
- if($customfields)
- {
-
$GLOBALS['phpgw']->template->set_var('lang_custom',lang('Custom Fields').':');
-
$GLOBALS['phpgw']->template->set_var('custom',$custom);
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('lang_custom','');
-
$GLOBALS['phpgw']->template->set_var('custom','');
- }
- $GLOBALS['phpgw']->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
- $GLOBALS['phpgw']->template->set_var('th_text',
$GLOBALS['phpgw_info']['theme']['th_text']);
- $GLOBALS['phpgw']->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
- $GLOBALS['phpgw']->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
-
$GLOBALS['phpgw']->template->set_var('row_text',$GLOBALS['phpgw_info']['theme']['row_text']);
+ function add_email()
+ {
+ $name = get_var('name');
+ $referer = get_var('referer');
+ $email = get_var('add_email');
+
+ $name = urldecode($name);
+ $email = urldecode($email);
+
+ $contact_id = $this->bo->add_email($name, $email);
- $this->output .=
$GLOBALS['phpgw']->template->fp('out','form');
- } /* end form function */
+ Header('Location: '
+ . $GLOBALS['phpgw']->link('/index.php',
+
'menuaction=addressbook.uiaddressbook.view_person&ab_id='
+ . $contact_id . '&referer=' . $referer));
+ }
}
?>
====================================================
Index: addressbook/inc/hook_notifywindow.inc.php
diff -u addressbook/inc/hook_notifywindow.inc.php:1.7
addressbook/inc/hook_notifywindow.inc.php:1.8
--- addressbook/inc/hook_notifywindow.inc.php:1.7 Sun Apr 27 21:12:59 2003
+++ addressbook/inc/hook_notifywindow.inc.php Fri Dec 31 04:55:24 2004
@@ -15,8 +15,7 @@
if($d1 == 'htt' || $d1 == 'ftp' )
{
echo "Failed attempt to break in via an old Security
Hole!<br>\n";
- $GLOBALS['phpgw_info']['flags']['nodisplay'] = True;
- exit;
+ $GLOBALS['phpgw']->common->phpgw_exit();
}
unset($d1);
@@ -30,34 +29,38 @@
$c = CreateObject('phpgwapi.contacts');
$qfields = array(
- 'n_given' => 'n_given',
- 'n_family' => 'n_family',
- 'bday' => 'bday'
+ 'contact_id' => 'contact_id',
+ 'per_first_name' => 'per_first_name',
+ 'per_last_name' => 'per_last_name',
+ 'per_birthday' => 'per_birthday'
);
$now = time() - ((60 * 60) *
intval($GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
$today = $GLOBALS['phpgw']->common->show_date($now,'n/d/');
// echo $today."\n";
- $bdays =
$c->read(0,15,$qfields,$today,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
-
+ //$bdays =
$c->read(0,15,$qfields,$today,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
+ $criteria = array('per_birthday' => $today);
+ $bdays = $c->get_persons($qfields, 15, 0, '', '', $criteria);
while(list($key,$val) = @each($bdays))
{
$tmp = '<a href="'
- .
$GLOBALS['phpgw']->link('/.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $val['id']) . '">'
- . $val['n_given'] . ' ' . $val['n_family'] .
'</a>';
+ .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view_person&ab_id='
. $val['contact_id']) . '">'
+ . $val['per_first_name'] . ' ' .
$val['per_last_name'] . '</a>';
echo '<tr><td align="left">' . lang("Today is %1's
birthday!", $tmp) . "</td></tr>\n";
}
$tomorrow = $GLOBALS['phpgw']->common->show_date($now +
86400,'n/d/');
// echo $tomorrow."\n";
- $bdays =
$c->read(0,15,$qfields,$tomorrow,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
+ $criteria = array('per_birthday' => $tomorrow);
+ $bdays = $c->get_persons($qfields, 15, 0, '', '', $criteria);
+ //$bdays =
$c->read(0,15,$qfields,$tomorrow,'tid=n','','',$GLOBALS['phpgw_info']['user']['account_id']);
while(list($key,$val) = @each($bdays))
{
$tmp = '<a href="'
- .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id='
. $val['id']) . '">'
- . $val['n_given'] . ' ' . $val['n_family'] .
'</a>';
+ .
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view_person&ab_id='
. $val['contact_id']) . '">'
+ . $val['per_first_name'] . ' ' .
$val['per_last_name'] . '</a>';
echo '<tr><td align="left">' . lang("Tomorrow is %1's
birthday.", $tmp) . "</td></tr>\n";
}
echo "\n<!-- Birthday info -->\n";
====================================================
Index: addressbook/inc/hook_preferences.inc.php
diff -u addressbook/inc/hook_preferences.inc.php:1.21
addressbook/inc/hook_preferences.inc.php:1.22
--- addressbook/inc/hook_preferences.inc.php:1.21 Sat Jan 12 04:15:15 2002
+++ addressbook/inc/hook_preferences.inc.php Fri Dec 31 04:55:24 2004
@@ -15,7 +15,7 @@
// Only Modify the $file and $title variables.....
$title = $appname;
$file = Array(
- 'Preferences' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.preferences'),
+ 'Preferences' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'addressbook.uiaddressbook_prefs.index')),
'Grant Access' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uiaclprefs.index&acl_app='.$appname),
'Edit Categories' =>
$GLOBALS['phpgw']->link('/index.php','menuaction=preferences.uicategories.index&cats_app='.$appname
. '&cats_level=True&global_cats=True')
);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] addressbook/inc class.uicatalog_contact_addr_type.inc.php, 1.2 class.uicatalog_contact_comm_descr.inc.php, 1.2 class.uicatalog_contact_comm_type.inc.php, 1.2 class.uiaddressbook_prefs.inc.php, 1.2 class.socatalog_contact_comm_descr.inc.php, 1.2 class.socatalog_contact_comm_type.inc.php, 1.2 class.socatalog_contact_note_type.inc.php, 1.2 class.uicatalog_contact_note_type.inc.php, 1.2 class.uicategorize_contacts.inc.php, 1.2 class.widget_lists.inc.php, 1.2 class.socatalog_contact_addr_type.inc.php, 1.2 arr.php, 1.2 class.addressbook_importer.inc.php, 1.2 class.catalog_manager.inc.php, 1.2 class.ipc_addressbook.inc.php, 1.2 class.bocatalog_contact_note_type.inc.php, 1.2 class.bocatalog_contact_comm_type.inc.php, 1.2 class.boaddressbook_prefs.inc.php, 1.2 class.bocatalog_contact_addr_type.inc.php, 1.2 class.bocatalog_contact_comm_descr.inc.php, 1.2 hook_manual.inc.php, 1.6 hook_sidebox_menu.inc.php, 1.2 class.uiXport.inc.php, 1.20 hook_config_validate.inc.php, 1.2 hook_deleteaccount.inc.php, 1.6 hook_home.inc.php, 1.23 hook_admin.inc.php, 1.15 functions.inc.php, 1.103 class.uifields.inc.php, 1.12 class.uivcard.inc.php, 1.11 class.soaddressbook.inc.php, 1.17 class.boXport.inc.php, 1.10 class.boaddressbook.inc.php, 1.26 class.pdb.inc.php, 1.4 class.uiaddressbook.inc.php, 1.56 hook_notifywindow.inc.php, 1.8 hook_preferences.inc.php, 1.22,
skwashd <=