From 5df37c28ff066d10c8580a8aff5dda23e3e6382a Mon Sep 17 00:00:00 2001 From: Miles Lott Date: Mon, 9 Jul 2001 17:35:27 +0000 Subject: [PATCH] Switch to using /index.php --- addressbook/inc/class.boaddressbook.inc.php | 181 +------------ addressbook/inc/class.soaddressbook.inc.php | 8 +- addressbook/inc/class.uiaddressbook.inc.php | 282 +++++++++++++++++--- addressbook/main.php | 48 ---- 4 files changed, 260 insertions(+), 259 deletions(-) delete mode 100644 addressbook/main.php diff --git a/addressbook/inc/class.boaddressbook.inc.php b/addressbook/inc/class.boaddressbook.inc.php index 3cd37f7df1..d7cac55124 100644 --- a/addressbook/inc/class.boaddressbook.inc.php +++ b/addressbook/inc/class.boaddressbook.inc.php @@ -197,9 +197,9 @@ . $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer")); } - function copy_entry() + function copy_entry($ab_id) { - global $phpgw,$phpgw_info,$ab_id; + global $phpgw,$phpgw_info; $addnew = $this->read_entry($ab_id,$this->so->contacts->stock_contact_fields,$phpgw_info['user']['account_id']); @@ -221,22 +221,9 @@ Header("Location: " . $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.edit&ab_id=$ab_id")); } - function add_entry() + function add_entry($userid,$fields) { - global $phpgw,$phpgw_info; - - $fields = $this->get_form(); - - $referer = urlencode($fields['referer']); - unset($fields['referer']); - - $this->so->add_entry($phpgw_info['user']['account_id'],$fields,$fields['access'],$fields['cat_id'],$fields['tid']); - - $ab_id = $this->get_lastid(); - - Header('Location: ' - . $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.view&ab_id=$ab_id&referer=$referer")); - $phpgw->common->phpgw_exit(); + return $this->so->add_entry($userid,$fields); } function get_lastid() @@ -244,165 +231,9 @@ return $this->so->get_lastid(); } - function update_entry() + function update_entry($userid,$fields) { - global $phpgw,$phpgw_info; - - $fields = $this->get_form(); - $check = $this->read_entry($fields['ab_id'],array('owner' => 'owner')); - - if (($this->contacts->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $phpgw_info['user']['account_id']) - { - $userid = $check[0]['owner']; - } - else - { - $userid = $phpgw_info['user']['account_id']; - } - $referer = urlencode($fields['referer']); - unset($fields['referer']); - - $this->so->update_entry($fields['ab_id'],$fields['userid'],$fields,$fields['access'],$fields['cat_id'],$fields['tid']); - - Header("Location: " - . $phpgw->link('/addressbook/main.php',"menuaction=addressbook.uiaddressbook.view&ab_id=" . $fields['ab_id'] . "&referer=$referer")); - $phpgw->common->phpgw_exit(); + return $this->so->update_entry($userid,$fields); } - - function get_form() - { - global $entry; - /* _debug_array($entry); */ - - if (!$entry['bday_month'] && !$entry['bday_day'] && !$entry['bday_year']) - { - $fields['bday'] = ''; - } - else - { - $bday_day = $entry['bday_day']; - if (strlen($bday_day) == 1) - { - $bday_day = '0' . $entry['bday_day']; - } - $fields['bday'] = $entry['bday_month'] . '/' . $bday_day . '/' . $entry['bday_year']; - } - - if ($entry['url'] == 'http://') - { - $fields['url'] = ''; - } - - $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']; - - if($entry['one_dom']) - { - $typea .= 'dom;'; - } - if($entry['one_intl']) - { - $typea .= 'intl;'; - } - if($entry['one_parcel']) - { - $typea .= 'parcel;'; - } - if($entry['one_postal']) - { - $typea .= 'postal;'; - } - $fields['adr_one_type'] = substr($typea,0,-1); - - $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']) - { - $typeb .= 'dom;'; - } - if($entry['two_intl']) - { - $typeb .= 'intl;'; - } - if($entry['two_parcel']) - { - $typeb .= 'parcel;'; - } - if($entry['two_postal']) - { - $typeb .= 'postal;'; - } - $fields['adr_two_type'] = substr($typeb,0,-1); - - while (list($name,$val) = @each($entry['customfields'])) - { - $fields[$name] = $val; - } - - $fields['ophone'] = $entry['ophone']; - $fields['tz'] = $entry['timezone']; - $fields['pubkey'] = $entry['pubkey']; - $fields['note'] = $entry['notes']; - $fields['label'] = $entry['label']; - - if ($entry['access'] == True) - { - $fields['access'] = 'private'; - } - else - { - $fields['access'] = 'public'; - } - - if (is_array($entry['cat_id'])) - { - $fields['cat_id'] = count($entry['cat_id']) > 1 ? ','.implode(',',$entry['cat_id']).',' : $entry['cat_id'][0]; - } - else - { - $fields['cat_id'] = $entry['cat_id']; - } - - $fields['ab_id'] = $entry['ab_id']; - $fields['tid'] = $entry['tid']; - $fields['referer'] = $entry['referer']; - /* _debug_array($fields);exit; */ - return $fields; - } /* end get_form() */ } ?> diff --git a/addressbook/inc/class.soaddressbook.inc.php b/addressbook/inc/class.soaddressbook.inc.php index ceb7c661d0..77679eb126 100644 --- a/addressbook/inc/class.soaddressbook.inc.php +++ b/addressbook/inc/class.soaddressbook.inc.php @@ -59,11 +59,11 @@ } } - function add_entry($userid,$fields,$access='',$cat_id='',$tid='n') + function add_entry($userid,$fields) { if ($this->rights & PHPGW_ACL_ADD) { - $this->contacts->add($userid,$fields,$access,$cat_id,$tid); + $this->contacts->add($userid,$fields,$fields['access'],$fields['cat_id'],$fields['tid']); } return; } @@ -75,11 +75,11 @@ return $ab_id; } - function update_entry($id,$userid,$fields,$access,$cat_id) + function update_entry($userid,$fields) { if ($this->rights & PHPGW_ACL_EDIT) { - $this->contacts->update($id,$userid,$fields,$access,$cat_id); + $this->contacts->update($fields['ab_id'],$userid,$fields,$fields['access'],$fields['cat_id']); } return; } diff --git a/addressbook/inc/class.uiaddressbook.inc.php b/addressbook/inc/class.uiaddressbook.inc.php index e2c5603dc7..4da79fb6b4 100644 --- a/addressbook/inc/class.uiaddressbook.inc.php +++ b/addressbook/inc/class.uiaddressbook.inc.php @@ -37,6 +37,8 @@ 'get_list' => True, 'view' => True, 'add' => True, + 'add_email' => True, + 'copy' => True, 'edit' => True ); @@ -175,7 +177,7 @@ $jselect = ' onChange="this.form.submit();"'; } /* Setup all and none first */ - $cats_link = "\n" .'\n"; if (!$notall) { $cats_link .= '