From e87f4c1514064db45f1eeb748c7d71781b3943ef Mon Sep 17 00:00:00 2001
From: Ralf Becker <ralfbecker@outdoor-training.de>
Date: Thu, 9 Aug 2012 09:03:11 +0000
Subject: [PATCH] cast accounts->members(hips) to array, to cope without PHP
 warnings for not (longer) existing accounts

---
 phpgwapi/inc/class.uiaccountsel.inc.php | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/phpgwapi/inc/class.uiaccountsel.inc.php b/phpgwapi/inc/class.uiaccountsel.inc.php
index ec3a26bf8e..d9c59a2569 100644
--- a/phpgwapi/inc/class.uiaccountsel.inc.php
+++ b/phpgwapi/inc/class.uiaccountsel.inc.php
@@ -150,12 +150,12 @@ class uiaccountsel
 				}
 				else
 				{
-					$memberships = $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
+					$memberships = (array)$this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
 				}
 				$select = count($selected) && !isset($selected[0]) ? array_keys($selected) : $selected;
 				foreach($memberships as $gid)
 				{
-					foreach($this->accounts->members($gid,true) as $member)
+					foreach((array)$this->accounts->members($gid,true) as $member)
 					{
 						if (!in_array($member,$select)) $select[] = $member;
 					}
@@ -164,7 +164,7 @@ class uiaccountsel
 				{
 					if ($account_sel == 'primary_group')
 					{
-						$memberships = $this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
+						$memberships = (array)$this->accounts->memberships($GLOBALS['egw_info']['user']['account_id'],true);
 					}
 					$select = array_merge($select,$memberships);
 				}
@@ -178,6 +178,7 @@ class uiaccountsel
 						'type' => $use,
 						'app' => $app,
 					));
+					//error_log(__METHOD__."() account_selection='$this->account_selection', accounts->search(array('type'=>'$use', 'app' => '$app')) returns ".array2string($select));
 				}
 				// make sure everything in $selected is also in $select, as in the other account-selection methods
 				if ($selected && ($missing = array_diff_key($selected,$select)))
@@ -270,6 +271,7 @@ class uiaccountsel
 			$select2 += $select;
 			$select =& $select2; unset($select2);
 		}
+		//error_log(__METHOD__."(..., use='$use', ...) account_selection='$this->account_selection', select=".array2string($select));
 
 		if ($nohtml)
 		{