From 4acc0e41a75bd00f6390bd14cc4a87960ce84cbf Mon Sep 17 00:00:00 2001
From: Miles Lott <milosch@alumni.egroupware.org>
Date: Mon, 28 May 2001 23:11:10 +0000
Subject: [PATCH] Try to fix cats issue with pgsql

---
 addressbook/add.php  | 9 ++++++---
 addressbook/edit.php | 9 ++++++---
 addressbook/view.php | 1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/addressbook/add.php b/addressbook/add.php
index da760fe4ac..1fdd365e07 100755
--- a/addressbook/add.php
+++ b/addressbook/add.php
@@ -196,9 +196,12 @@
 			$fields['access'] = 'public';
 		}
 
-		$fields['cat_id'] = is_array($cat_id) ? implode(',',$cat_id) : $cat_id;
-		// make sure commas surround each value
-		$fields['cat_id'] = ',' . $fields['cat_id'] . ',';
+		if ($fields['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'] . ',';
+		}
 
 		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 e71007c52b..33f8008b0d 100755
--- a/addressbook/edit.php
+++ b/addressbook/edit.php
@@ -204,9 +204,12 @@
 			$fields['access'] = 'public';
 		}
 
-		$fields['cat_id'] = is_array($cat_id) ? implode(',',$cat_id) : $cat_id;
-		// make sure commas surround each value
-		$fields['cat_id'] = ',' . $fields['cat_id'] . ',';
+		if ($fields['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'] . ',';
+		}
 
 		if (($this->grants[$check[0]['owner']] & PHPGW_ACL_EDIT) && $check[0]['owner'] != $phpgw_info['user']['account_id'])
 		{
diff --git a/addressbook/view.php b/addressbook/view.php
index 07626f7c77..181d3ffa98 100755
--- a/addressbook/view.php
+++ b/addressbook/view.php
@@ -218,6 +218,7 @@
 	}
 	else
 	{
+		$fields[0]['cat_id'] = ereg_replace(',','',$fields[0]['cat_id']);
 		$catinfo = $cat->return_single($fields[0]['cat_id']);
 		$catname = $catinfo[0]['name'];
 		if (!$cat_id)