Commit 094b126246fa1618c9d2bb2c3d3e9d2c1d351c96

Authored by michael
1 parent 6290e300

modified lookupGroup to return an array of groupIDs

added arrayToString (not really the right place for it, suggestions?)


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@202 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 24 additions and 13 deletions
lib/lookup.inc
... ... @@ -14,15 +14,11 @@
14 14 /**
15 15 * Performs an id field lookup on the specified table.
16 16 *
17   - * @param $tableName
18   - * the name of table to perform the id lookup.
19   - * @param $fieldName
20   - * the db field to return.
21   - * @param $fieldValue
22   - * the value to perform the lookup for
  17 + * @param $tableName the name of table to perform the id lookup.
  18 + * @param $fieldName the db field to return.
  19 + * @param $fieldValue the value to perform the lookup for
23 20 * @return the id of the row in the db with $fieldName=$fieldValue
24 21 */
25   -
26 22 function lookupID($tableName, $fieldName, $fieldValue){
27 23 $sql = new Owl_DB();
28 24 $query = "select id from $tableName where $fieldName = '$fieldValue'";
... ... @@ -40,14 +36,29 @@ function lookupID($tableName, $fieldName, $fieldValue){
40 36 }
41 37 }
42 38  
43   -function lookupGroupID($userid) {
  39 +/**
  40 + * Retrieves the groups that the user is a member of
  41 + *
  42 + * @param $userID the user to lookup groups for
  43 + * @return an array containing the groupsIDs the user is a member of
  44 + */
  45 +function lookupGroupIDs($userID) {
44 46 global $default;
  47 + $groupIDs = array();
45 48 $sql = new Owl_DB;
46   - $sql->query("select group_id from $default->owl_groups_users_table where user_id = '$userid'");
47   - while($sql->next_record())
48   - {
49   - $groupid = $sql->f("group_id");
50   - return $groupid;
  49 + $sql->query("select group_id from $default->owl_groups_users_table where user_id = '$userID'");
  50 + while($sql->next_record()) {
  51 + $groupIDs[] = $sql->f("group_id");
51 52 }
  53 + return $groupIDs;
  54 +}
  55 +
  56 +
  57 +function arrayToString($array) {
  58 + ob_start();
  59 + print_r($array);
  60 + $arrToStr = ob_get_contents();
  61 + ob_end_clean();
  62 + return $arrToStr;
52 63 }
53 64 ?>
... ...