- a few buxfixes

- new view dialog
This commit is contained in:
Cornelius Weiß 2005-11-11 20:50:12 +00:00
parent b51c7496e6
commit cda193ba66
6 changed files with 183 additions and 20 deletions

View File

@ -17,7 +17,7 @@ require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.socontacts.inc.php');
/**
* General business object of the adressbook
*
* @package adressbook
* @package addressbook
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @copyright (c) 2005 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
@ -124,8 +124,7 @@ class bocontacts extends socontacts
// last modified
$contact['last_mod'] = time();
// only owner can set access status
$contact['access'] = $contact['owner'] == $this->user ? (!empty($contact['access']) ? $contact['access'] : 'public') : 'public';
$contact['private'] = $contact['owner'] == $this->user ? $contact['private'] : 0;
$contact['access'] = $contact['owner'] == $this->user ? ($contact['private'] ? 'private': 'public') : $contact['access'];
// convert bithdate format
$tmp_bday = $contact['bday'];
$contact['bday'] = $contact['bday'] ? date('m/d/Y',$contact['bday']) : '';
@ -135,12 +134,19 @@ class bocontacts extends socontacts
($contact['n_middle'] ? ' '.$contact['n_middle'] : '').
($contact['n_family'] ? ' '.$contact['n_family'] : '').
($contact['n_suffix'] ? ' '.$contact['n_suffix'] : '');
// for some bad historical reasons we mainfileds saved in cf :-(((
$data['#ophone'] = $data['ophone']; unset($data['ophone']);
$data['#address2'] = $data['address2']; unset($data['address2']);
$data['#address3'] = $data['address3']; unset($data['address3']);
$error_nr = parent::save($contact);
//reconvert bday as we are dealing with references
$contact['bday'] = $tmp_bday;
// for some bad historical reasons we mainfileds saved in cf :-(((
$data['ophone'] = $data['#ophone']; unset($data['#ophone']);
$data['address2'] = $data['#address2']; unset($data['#address2']);
$data['address3'] = $data['#address3']; unset($data['#address3']);
$contact['msg'] = $error_nr ?
lang('Something went wrong by saving this contact. Errorcode %1',$error_nr) :
lang('Contact saved');
@ -173,8 +179,11 @@ class bocontacts extends socontacts
list($m,$d,$y) = explode('/',$data['bday']);
$data['bday'] = strpos($data['bday'],'/') ? mktime(0,0,0,$m,$d,$y) : '';
// convert access into private for historical reasons
$data['private'] = $data['access'] == 'private' ? 1 : $data['private'];
$data['access'] = $data['private'] ? 'private' : 'public';
$data['private'] = $data['access'] == 'private' ? 1 : 0;
// for some bad historical reasons we mainfileds saved in cf :-(((
$data['ophone'] = $data['#ophone']; unset($data['#ophone']);
$data['address2'] = $data['#address2']; unset($data['#address2']);
$data['address3'] = $data['#address3']; unset($data['#address3']);
return $data;
}

View File

@ -19,7 +19,7 @@ require_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.contacts.inc.php');
* This makes it compatible with vars and parameters of so_sql
* Maybe one day this becomes a generalized ldap storage object :-)
*
* @package contacts
* @package addressbook
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
*/
class so_ldap extends contacts

View File

@ -598,8 +598,8 @@
$actions = '<a href="'
. $GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'addressbook.uiaddressbook.view',
'ab_id' => $entries[$i]['id']
'menuaction' => 'addressbook.uicontacts.view',
'contact_id' => $entries[$i]['id'],
))
. '"><img src="'
. $GLOBALS['egw']->common->image('addressbook','view')

View File

@ -17,7 +17,7 @@ require_once(EGW_INCLUDE_ROOT.'/addressbook/inc/class.bocontacts.inc.php');
/**
* General user interface object of the adressbook
*
* @package adressbook
* @package addressbook
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
* @copyright (c) 2005 by Cornelius Weiss <egw@von-und-zu-weiss.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
@ -27,6 +27,7 @@ class uicontacts extends bocontacts
var $public_functions = array(
'search' => True,
'edit' => True,
'view' => True,
);
function uicontacts($contact_app='addressbook')
@ -50,6 +51,11 @@ class uicontacts extends bocontacts
}
/**
*
* @param int $_GET['contact_id'] contact_id manly for popup use
* @param bool $_GET['makecp'] ture if you want do copy the contact given by $_GET['contact_id']
*/
function edit($content='')
{
if (is_array($content))
@ -80,17 +86,20 @@ class uicontacts extends bocontacts
{
$content = array();
$content_id = $_GET['contact_id'] ? $_GET['contact_id'] : 0;
$view = $_GET['view'];// == 1 ? true : false;
if ($content_id != 0)
{
$content = $this->read($content_id);
}
if($_GET['makecp']) unset($content['id']);
}
//_debug_array($content);
$no_button['button[delete]'] = !$this->check_perms(EGW_ACL_DELETE,$content);
$no_button['button[copy]'] = true;
$no_button['button[edit]'] = !$view;
$readonlys['button[delete]'] = !$this->check_perms(EGW_ACL_DELETE,$content);
$readonlys['button[copy]'] = true;
$readonlys['button[edit]'] = true;
$preserv = array(
'id' => $content['id'],
'lid' => $content['lid'],
@ -98,6 +107,7 @@ class uicontacts extends bocontacts
'owner' => $content['owner'],
'fn' => $content['fn'],
'geo' => $content['geo'],
'access' => $content['access'],
);
for($i = -23; $i<=23; $i++) $tz[$i] = ($i > 0 ? '+' : '').$i;
@ -105,7 +115,136 @@ class uicontacts extends bocontacts
$content['tz'] = $content['tz'] ? $content['tz'] : 0;
$this->tmpl->read('addressbook.edit');
return $this->tmpl->exec('addressbook.uicontacts.edit',$content,$sel_options,$no_button,$preserv,2);
return $this->tmpl->exec('addressbook.uicontacts.edit',$content,$sel_options,$readonlys,$preserv, 2);
}
function view($content='')
{
if(is_array($content))
{
if (isset($content['button']['vcard']))
{
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uivcard.out&ab_id=' .$content['id']);
}
elseif (isset($content['button']['cancel']))
{
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uiaddressbook.index');
}
elseif (isset($content['button']['delete']))
{
if(!$this->delete($content))
{
$content['msg'] = lang('Something wen\'t wrong by deleting this contact');
}
else
{
$GLOBALS['egw']->redirect_link('/index.php','menuaction=addressbook.uiaddressbook.index');
}
}
}
else
{
$contact_id = $_GET['contact_id'];
if(!$contact_id) return false;
$content = $this->read($contact_id);
}
$content['view'] = true;
// privat
foreach(array(
'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',
) as $field => $name)
{
if($content[$field] == '') continue;
$content['personal_entries'][] = array(
'field' => $name,
'value' => $content[$field],
);
}
// tel numbers
foreach(array(
'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',
'ophone' => 'other phone',
'tel_prefer' => 'preferred phone',
) as $field => $name)
{
if($content[$field] == '') continue;
$content['phone_entries'][] = array(
'field' => $name,
'value' => $content[$field],
);
}
// organisation
foreach(array(
'adr_one_street' => 'business street',
'address2' => 'address line 2',
'address3' => 'address line 3',
'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',
) as $field => $name)
{
if($content[$field] == '') continue;
$content['organisation_entries'][] = array(
'field' => $name,
'value' => $content[$field],
);
}
// emails
foreach(array(
'email' => 'business email',
'email_home' => 'home email',
) as $field => $name)
{
if($content[$field] == '') continue;
$content['email_entries'][] = array(
'field' => $name,
'value' => $content[$field],
);
}
//urls
foreach(array(
'url' => 'url'
) as $field => $name)
{
if($content[$field] == '') continue;
$content['url_entries'][] = array(
'field' => $name,
'value' => $content[$field],
);
}
if($content['tz'] == '') $content['tz'] = 0;
$readonlys['button[delete]'] = !$this->check_perms(EGW_ACL_DELETE,$content);
$readonlys['button[private]'] = $content['private'] == 1 ? false :true;
$this->tmpl->read('addressbook.view');
$this->tmpl->exec('addressbook.uicontacts.view',$content,$sel_options,$readonlys,array('id' => $content['id']));
$GLOBALS['egw']->hooks->process(array(
'location' => 'addressbook_view',
'ab_id' => $content['id']
));
}
function search($content='')
@ -183,7 +322,7 @@ class uicontacts extends bocontacts
$sel_options['tz'] = $tz + array('' => lang('doesn\'t matter'));
$this->tmpl->read('addressbook.search');
return $this->tmpl->exec('addressbook.uicontacts.search',$content,$sel_options,$no_button,$preserv);
return $this->tmpl->exec('addressbook.uicontacts.search',$content,$sel_options,$readonlys,$preserv);
}
function js()
@ -226,4 +365,4 @@ class uicontacts extends bocontacts
</script>';
}
}
}

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 1015 B