From e10d2f46503add70e9e19c1cb9f2aa9fa072d2e3 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 29 May 2001 13:06:04 +0000 Subject: [PATCH] cat_id now just the number for a single entry, multiple entrys are separated as well as surounded by ',' empty stay empty --- addressbook/add.php | 10 ++++++---- addressbook/edit.php | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addressbook/add.php b/addressbook/add.php index 1fdd365e07..9743cb5a7a 100755 --- a/addressbook/add.php +++ b/addressbook/add.php @@ -196,12 +196,14 @@ $fields['access'] = 'public'; } - if ($fields['cat_id']) + if (is_array($cat_id)) { - $fields['cat_id'] = is_array($cat_id) ? implode(',',$cat_id) : $cat_id; - // make sure commas surround each value - $fields['cat_id'] = ',' . $fields['cat_id'] . ','; + $fields['cat_id'] = count($cat_id) > 1 ? ','.implode(',',$cat_id).',' : $cat_id[0]; } + else + { + $fields['cat_id'] = $cat_id; + } addressbook_add_entry($phpgw_info['user']['account_id'],$fields,$fields['access'],$fields['cat_id']); $ab_id = addressbook_get_lastid(); diff --git a/addressbook/edit.php b/addressbook/edit.php index 33f8008b0d..392a4372a5 100755 --- a/addressbook/edit.php +++ b/addressbook/edit.php @@ -204,12 +204,14 @@ $fields['access'] = 'public'; } - if ($fields['cat_id']) + if (is_array($cat_id)) { - $fields['cat_id'] = is_array($cat_id) ? implode(',',$cat_id) : $cat_id; - // make sure commas surround each value - $fields['cat_id'] = ',' . $fields['cat_id'] . ','; + $fields['cat_id'] = count($cat_id) > 1 ? ','.implode(',',$cat_id).',' : $cat_id[0]; } + else + { + $fields['cat_id'] = $cat_id; + } if (($this->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $phpgw_info['user']['account_id']) {