From 997d80d40674ccb0e13aaa02ce3d275f6647f941 Mon Sep 17 00:00:00 2001 From: tomas Date: Thu, 20 Jan 2005 00:48:49 +0000 Subject: [PATCH] method isMemberOf added --- livesupport/modules/alib/var/subj.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/livesupport/modules/alib/var/subj.php b/livesupport/modules/alib/var/subj.php index 72d9e03f7..ccc891657 100644 --- a/livesupport/modules/alib/var/subj.php +++ b/livesupport/modules/alib/var/subj.php @@ -23,7 +23,7 @@ Author : $Author: tomas $ - Version : $Revision: 1.3 $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/alib/var/subj.php,v $ ------------------------------------------------------------------------------*/ @@ -39,7 +39,7 @@ define('ALIBERR_BADSMEMB', 21); * (allow adding users to groups or groups to groups) * * @author $Author: tomas $ - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @see ObjClasses * @see Alib */ @@ -275,6 +275,24 @@ class Subjects extends ObjClasses{ WHERE m.uid=s.id AND m.mid is null AND m.gid='$gid'"); } + /** + * Return true if uid is [id]direct member of gid + * + * @param uid int, local user id + * @param gid int, local group id + * @return boolean + */ + function isMemberOf($uid, $gid) + { + $res = $this->dbc->getOne(" + SELECT count(*)as cnt + FROM {$this->smembTable} + WHERE uid='$uid' AND gid='$gid' + "); + if(PEAR::isError($res)) return $res; + return (intval($res) > 0); + } + /* ==================================================== "private" methods */ /**