From 094b126246fa1618c9d2bb2c3d3e9d2c1d351c96 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 15 Jan 2003 09:10:18 +0000 Subject: [PATCH] modified lookupGroup to return an array of groupIDs added arrayToString (not really the right place for it, suggestions?) --- lib/lookup.inc | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/lib/lookup.inc b/lib/lookup.inc index 70e986d..926f785 100644 --- a/lib/lookup.inc +++ b/lib/lookup.inc @@ -14,15 +14,11 @@ /** * Performs an id field lookup on the specified table. * - * @param $tableName - * the name of table to perform the id lookup. - * @param $fieldName - * the db field to return. - * @param $fieldValue - * the value to perform the lookup for + * @param $tableName the name of table to perform the id lookup. + * @param $fieldName the db field to return. + * @param $fieldValue the value to perform the lookup for * @return the id of the row in the db with $fieldName=$fieldValue */ - function lookupID($tableName, $fieldName, $fieldValue){ $sql = new Owl_DB(); $query = "select id from $tableName where $fieldName = '$fieldValue'"; @@ -40,14 +36,29 @@ function lookupID($tableName, $fieldName, $fieldValue){ } } -function lookupGroupID($userid) { +/** + * Retrieves the groups that the user is a member of + * + * @param $userID the user to lookup groups for + * @return an array containing the groupsIDs the user is a member of + */ +function lookupGroupIDs($userID) { global $default; + $groupIDs = array(); $sql = new Owl_DB; - $sql->query("select group_id from $default->owl_groups_users_table where user_id = '$userid'"); - while($sql->next_record()) - { - $groupid = $sql->f("group_id"); - return $groupid; + $sql->query("select group_id from $default->owl_groups_users_table where user_id = '$userID'"); + while($sql->next_record()) { + $groupIDs[] = $sql->f("group_id"); } + return $groupIDs; +} + + +function arrayToString($array) { + ob_start(); + print_r($array); + $arrToStr = ob_get_contents(); + ob_end_clean(); + return $arrToStr; } ?> -- libgit2 0.21.4