2000-08-18 05:24:22 +02:00
|
|
|
<?php
|
2001-02-10 13:56:49 +01:00
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - addressbook *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* Written by Joseph Engo <jengo@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. *
|
|
|
|
\**************************************************************************/
|
2000-08-18 05:24:22 +02:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
/* $Id$ */
|
2000-08-18 05:24:22 +02:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$phpgw_info['flags'] = array(
|
|
|
|
'noheader' => True,
|
|
|
|
'nonavbar' => True,
|
|
|
|
'currentapp' => 'addressbook',
|
|
|
|
'enable_contacts_class' => True,
|
|
|
|
'enable_nextmatchs_class' => True
|
2001-03-24 15:55:33 +01:00
|
|
|
);
|
2001-02-02 02:34:22 +01:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
include('../header.inc.php');
|
2000-09-18 22:00:25 +02:00
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
$this = CreateObject("phpgwapi.contacts");
|
2001-02-12 14:57:59 +01:00
|
|
|
|
2001-03-24 15:55:33 +01:00
|
|
|
// First, make sure they have permission to this entry
|
|
|
|
$check = addressbook_read_entry($ab_id,array('owner' => 'owner'));
|
2001-04-03 02:46:00 +02:00
|
|
|
$perms = $this->check_perms($this->grants[$check[0]['owner']],PHPGW_ACL_READ);
|
2001-03-24 15:55:33 +01:00
|
|
|
|
2001-04-03 02:46:00 +02:00
|
|
|
if ( (!$perms) && ($check[0]['owner'] != $phpgw_info['user']['account_id']) )
|
2001-03-24 15:55:33 +01:00
|
|
|
{
|
2001-03-25 07:41:06 +02:00
|
|
|
Header("Location: "
|
|
|
|
. $phpgw->link('/addressbook/index.php',"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id"));
|
2001-03-24 15:55:33 +01:00
|
|
|
$phpgw->common->phpgw_exit();
|
|
|
|
}
|
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
if (!$ab_id)
|
|
|
|
{
|
|
|
|
Header("Location: " . $phpgw->link('/addressbook/index.php'));
|
|
|
|
}
|
|
|
|
elseif (!$submit && $ab_id)
|
|
|
|
{
|
2001-03-24 15:55:33 +01:00
|
|
|
$phpgw->common->phpgw_header();
|
|
|
|
echo parse_navbar();
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
2001-01-14 04:29:39 +01:00
|
|
|
|
2001-05-10 14:21:16 +02:00
|
|
|
$t = new Template(PHPGW_APP_TPL);
|
2001-05-10 14:45:40 +02:00
|
|
|
$t->set_file(array('view_t' => 'view.tpl'));
|
|
|
|
$t->set_block('view_t','view_header','view_header');
|
|
|
|
$t->set_block('view_t','view_row','view_row');
|
|
|
|
$t->set_block('view_t','view_footer','view_footer');
|
|
|
|
$t->set_block('view_t','view_buttons','view_buttons');
|
2001-03-24 15:55:33 +01:00
|
|
|
|
2001-04-28 06:08:49 +02:00
|
|
|
$customfields = array();
|
2001-05-06 18:15:43 +02:00
|
|
|
while (list($col,$descr) = @each($phpgw_info['user']['preferences']['addressbook']))
|
|
|
|
{
|
|
|
|
if ( substr($col,0,6) == 'extra_' )
|
|
|
|
{
|
2001-04-28 06:08:49 +02:00
|
|
|
$field = ereg_replace('extra_','',$col);
|
|
|
|
$field = ereg_replace(' ','_',$field);
|
|
|
|
$customfields[$field] = ucfirst($field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
while ($column = each($this->stock_contact_fields))
|
|
|
|
{
|
|
|
|
if (isset($phpgw_info['user']['preferences']['addressbook'][$column[0]]) &&
|
|
|
|
$phpgw_info['user']['preferences']['addressbook'][$column[0]])
|
|
|
|
{
|
2001-02-10 13:56:49 +01:00
|
|
|
$columns_to_display[$column[0]] = True;
|
2001-03-22 03:56:03 +01:00
|
|
|
$colname[$column[0]] = $column[0];
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
|
|
|
}
|
2001-03-13 17:19:05 +01:00
|
|
|
|
|
|
|
// No prefs?
|
2001-05-06 18:15:43 +02:00
|
|
|
if (!$columns_to_display )
|
|
|
|
{
|
2001-03-13 17:19:05 +01:00
|
|
|
$columns_to_display = array(
|
2001-05-06 18:15:43 +02:00
|
|
|
'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'
|
2001-03-13 17:19:05 +01:00
|
|
|
);
|
2001-05-06 18:15:43 +02:00
|
|
|
while ($column = each($columns_to_display))
|
|
|
|
{
|
2001-03-13 17:19:05 +01:00
|
|
|
$colname[$column[0]] = $column[1];
|
|
|
|
}
|
2001-05-06 18:15:43 +02:00
|
|
|
$noprefs = " - " . lang('Please set your preferences for this app');
|
2001-03-13 17:19:05 +01:00
|
|
|
}
|
|
|
|
|
2001-02-10 13:56:49 +01:00
|
|
|
// merge in extra fields
|
2001-03-16 02:31:25 +01:00
|
|
|
$extrafields = array(
|
2001-05-06 18:15:43 +02:00
|
|
|
'ophone' => 'ophone',
|
|
|
|
'address2' => 'address2',
|
|
|
|
'address3' => 'address3'
|
2001-02-11 04:23:58 +01:00
|
|
|
);
|
2001-04-28 06:08:49 +02:00
|
|
|
$qfields = $this->stock_contact_fields + $extrafields + $customfields;
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$fields = addressbook_read_entry($ab_id,$qfields);
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$record_owner = $fields[0]['owner'];
|
2001-02-12 14:57:59 +01:00
|
|
|
|
2001-04-28 05:52:21 +02:00
|
|
|
if ($fields[0]["access"] == 'private')
|
|
|
|
{
|
2001-03-24 15:55:33 +01:00
|
|
|
$access_check = lang('private');
|
2001-04-28 05:52:21 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-03-24 15:55:33 +01:00
|
|
|
$access_check = lang('public');
|
|
|
|
}
|
|
|
|
|
2001-04-28 05:18:36 +02:00
|
|
|
$t->set_var('lang_viewpref',lang("Address book - view") . $noprefs);
|
2001-02-19 13:14:25 +01:00
|
|
|
|
2001-04-28 06:18:24 +02:00
|
|
|
@reset($qfields);
|
2001-05-06 18:15:43 +02:00
|
|
|
while (list($column,$null) = @each($qfields)) // each entry column
|
|
|
|
{
|
2001-04-28 05:52:21 +02:00
|
|
|
if(display_name($colname[$column]))
|
|
|
|
{
|
|
|
|
$t->set_var('display_col',display_name($colname[$column]));
|
|
|
|
}
|
2001-04-28 06:08:49 +02:00
|
|
|
elseif(display_name($column))
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
|
|
|
$t->set_var('display_col',display_name($column));
|
|
|
|
}
|
2001-04-28 06:08:49 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var('display_col',ucfirst($column));
|
|
|
|
}
|
2001-04-28 05:52:21 +02:00
|
|
|
$ref = $data = "";
|
2001-04-28 06:36:35 +02:00
|
|
|
if ($fields[0][$column])
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
2001-05-05 05:20:47 +02:00
|
|
|
$tr_color = $phpgw->nextmatchs->alternate_row_color($tr_color);
|
|
|
|
$t->set_var('th_bg',$tr_color);
|
2001-04-28 06:36:35 +02:00
|
|
|
$coldata = $fields[0][$column];
|
2001-05-06 18:15:43 +02:00
|
|
|
// Some fields require special formatting.
|
2001-04-28 06:36:35 +02:00
|
|
|
if ( ($column == "note" || $column == "label" || $column == "pubkey") && $coldata )
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
2001-04-28 06:36:35 +02:00
|
|
|
$datarray = explode ("\n",$coldata);
|
|
|
|
if ($datarray[1])
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
2001-04-28 06:36:35 +02:00
|
|
|
while (list($key,$info) = each ($datarray))
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
2001-04-28 06:36:35 +02:00
|
|
|
if ($key)
|
|
|
|
{
|
2001-05-05 05:20:47 +02:00
|
|
|
$data .= '</td></tr><tr bgcolor="'.$tr_color.'"><td width="30%"> </td><td width="70%">' .$info;
|
2001-04-28 06:36:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // First row, don't close td/tr
|
|
|
|
$data .= $info;
|
|
|
|
}
|
2001-04-28 05:52:21 +02:00
|
|
|
}
|
2001-04-28 06:36:35 +02:00
|
|
|
$data .= "</tr>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$data = $coldata;
|
2001-04-28 05:52:21 +02:00
|
|
|
}
|
|
|
|
}
|
2001-04-28 06:36:35 +02:00
|
|
|
elseif ($column == "url" && $coldata)
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
2001-04-28 06:36:35 +02:00
|
|
|
$ref = '<a href="' . $coldata . '" target="_new">';
|
|
|
|
$data = $coldata . '</a>';
|
2001-04-28 05:52:21 +02:00
|
|
|
}
|
2001-04-28 06:36:35 +02:00
|
|
|
elseif ( (($column == "email") || ($column == "email_home")) && $coldata)
|
2001-04-28 05:52:21 +02:00
|
|
|
{
|
2001-04-28 06:36:35 +02:00
|
|
|
if ($phpgw_info["user"]["apps"]["email"])
|
|
|
|
{
|
|
|
|
$ref='<a href="' . $phpgw->link("/email/compose.php","to="
|
|
|
|
. urlencode($coldata)) . '" target="_new">';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$ref = '<a href="mailto:'.$coldata.'">';
|
|
|
|
}
|
|
|
|
$data = $coldata."</a>";
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
2001-04-28 05:52:21 +02:00
|
|
|
else
|
2001-04-28 06:36:35 +02:00
|
|
|
{ // But these do not
|
|
|
|
$ref = ""; $data = $coldata;
|
2001-04-28 05:52:21 +02:00
|
|
|
}
|
|
|
|
|
2001-04-28 06:36:35 +02:00
|
|
|
if (!$data)
|
|
|
|
{
|
|
|
|
$t->set_var('ref_data'," ");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$t->set_var('ref_data',$ref . $data);
|
|
|
|
}
|
2001-05-06 18:15:43 +02:00
|
|
|
$t->parse('cols','view_row',True);
|
2001-02-10 13:56:49 +01:00
|
|
|
}
|
2001-02-14 01:56:07 +01:00
|
|
|
}
|
2000-11-12 12:35:51 +01:00
|
|
|
|
2001-03-25 07:41:06 +02:00
|
|
|
$cat = CreateObject('phpgwapi.categories');
|
2001-05-06 18:15:43 +02:00
|
|
|
$catinfo = $cat->return_single($fields[0]['cat_id']);
|
|
|
|
$catname = $catinfo[0]['name'];
|
2001-03-29 12:45:29 +02:00
|
|
|
if ($fields[0]['cat_id']) { $cat_id = $fields[0]['cat_id']; }
|
2001-03-29 11:15:27 +02:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$cat->app_name = 'phpgw';
|
2001-03-29 11:15:27 +02:00
|
|
|
$catinfo = $cat->return_single($fields[0]['cat_id']);
|
2001-05-06 18:15:43 +02:00
|
|
|
$catname .= $catinfo[0]['name'];
|
2001-03-29 12:45:29 +02:00
|
|
|
if ($fields[0]['cat_id']) { $cat_id = $fields[0]['cat_id']; }
|
2001-03-29 11:15:27 +02:00
|
|
|
|
2001-03-25 11:18:14 +02:00
|
|
|
if (!$catname) { $catname = lang('none'); }
|
2001-03-25 07:41:06 +02:00
|
|
|
|
2001-04-28 05:52:21 +02:00
|
|
|
// These are in the footer
|
2001-05-06 18:15:43 +02:00
|
|
|
$t->set_var('lang_owner',lang('Record owner'));
|
2001-04-28 05:18:36 +02:00
|
|
|
$t->set_var('owner',$phpgw->common->grab_owner_name($record_owner));
|
|
|
|
$t->set_var('lang_access',lang("Record access"));
|
|
|
|
$t->set_var('access',$access_check);
|
2001-05-06 18:15:43 +02:00
|
|
|
$t->set_var('lang_category',lang('Category'));
|
2001-04-28 05:18:36 +02:00
|
|
|
$t->set_var('catname',$catname);
|
2001-02-14 01:56:07 +01:00
|
|
|
|
2001-03-18 00:52:36 +01:00
|
|
|
$sfields = rawurlencode(serialize($fields[0]));
|
2001-03-18 09:49:30 +01:00
|
|
|
|
2001-03-29 12:45:29 +02:00
|
|
|
if (($this->grants[$record_owner] & PHPGW_ACL_EDIT) || ($record_owner == $phpgw_info['user']['account_id']))
|
2001-03-29 09:53:14 +02:00
|
|
|
{
|
2001-04-14 16:58:29 +02:00
|
|
|
if ($referer)
|
|
|
|
{
|
2001-04-28 06:46:32 +02:00
|
|
|
$t->set_var('edit_link','<form method="POST" action="'
|
|
|
|
. $phpgw->link("/addressbook/edit.php",'referer=' . urlencode($referer),
|
|
|
|
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id").'">');
|
2001-04-14 16:58:29 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-28 06:46:32 +02:00
|
|
|
$t->set_var('edit_link','<form method="POST" action="'
|
|
|
|
. $phpgw->link("/addressbook/edit.php",
|
|
|
|
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query&cat_id=$cat_id").'">');
|
2001-04-14 16:58:29 +02:00
|
|
|
}
|
2001-03-29 09:53:14 +02:00
|
|
|
$t->set_var('edit_button','<input type="submit" name="edit" value="' . lang('Edit') . '">');
|
2001-03-18 09:49:30 +01:00
|
|
|
}
|
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$copylink = '<form method="POST" action="' . $phpgw->link("/addressbook/add.php").'">';
|
2001-04-28 06:46:32 +02:00
|
|
|
if ($fields[0]['n_family'] && $fields[0]['n_given'])
|
|
|
|
{
|
|
|
|
$vcardlink = '<form method="POST" action="' . $phpgw->link("/addressbook/vcardout.php").'">';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$vcardlink = lang('no').' '.lang('vcard');
|
|
|
|
}
|
2001-04-14 16:58:29 +02:00
|
|
|
if ($referer)
|
|
|
|
{
|
|
|
|
$referer = ereg_replace('/phpgroupware','',$referer);
|
2001-05-06 18:15:43 +02:00
|
|
|
$donelink = '<form method="POST" action="'
|
2001-04-28 06:46:32 +02:00
|
|
|
. $phpgw->link($referer,
|
|
|
|
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query").'">';
|
2001-04-14 16:58:29 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-05-06 18:15:43 +02:00
|
|
|
$donelink = '<form method="POST" action="'
|
2001-04-28 06:46:32 +02:00
|
|
|
. $phpgw->link("/addressbook/index.php",
|
|
|
|
"cd=16&order=$order&sort=$sort&filter=$filter&start=$start&query=$query").'">';
|
2001-04-14 16:58:29 +02:00
|
|
|
}
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$t->set_var('access_link',$access_link);
|
|
|
|
$t->set_var('ab_id',$ab_id);
|
|
|
|
$t->set_var('sort',$sort);
|
|
|
|
$t->set_var('order',$order);
|
|
|
|
$t->set_var('filter',$filter);
|
|
|
|
$t->set_var('start',$start);
|
|
|
|
$t->set_var('cat_id',$cat_id);
|
2001-04-28 05:18:36 +02:00
|
|
|
|
2001-05-06 18:15:43 +02:00
|
|
|
$t->set_var('lang_ok',lang('ok'));
|
|
|
|
$t->set_var('lang_done',lang('done'));
|
|
|
|
$t->set_var('lang_copy',lang('copy'));
|
|
|
|
$t->set_var('copy_fields',$sfields);
|
|
|
|
$t->set_var('lang_submit',lang('submit'));
|
|
|
|
$t->set_var('lang_vcard',lang('vcard'));
|
|
|
|
$t->set_var('done_link',$donelink);
|
|
|
|
$t->set_var('copy_link',$copylink);
|
|
|
|
$t->set_var('vcard_link',$vcardlink);
|
2001-02-12 14:57:59 +01:00
|
|
|
|
2001-05-10 14:45:40 +02:00
|
|
|
$t->pfp('out','view_t');
|
2001-03-16 02:31:25 +01:00
|
|
|
|
2001-02-14 01:56:07 +01:00
|
|
|
$phpgw->common->phpgw_footer();
|
2000-09-29 07:24:18 +02:00
|
|
|
?>
|