Commit 9d96f9e6 authored by Clare Lenihan's avatar Clare Lenihan Committed by Clare Lenihan
Browse files

added is_forum_moderator method

parent 0d95e8e9
......@@ -15,5 +15,35 @@ class InteractionForumInstance extends InteractionInstance {
}
/**
* Is a user a moderator of a given forum
*
* @param int $forumid id of forum
* @param int $userid optional id of user, defaults to logged in user
*
* @returns boolean
*/
function is_forum_moderator($forumid, $userid=null) {
if (empty($userid)) {
global $USER;
$userid = $USER->get('id');
}
else if (!is_int($userid)) {
throw new InvalidArgumentException("non integer user id given to is_forum_moderator: $userid");
}
if (!is_int($forumid)) {
throw new InvalidArgumentException("non integer forum id given to is_forum_moderator: $forumid");
}
return record_exists_sql(
'SELECT "user"
FROM {interaction_forum_moderator}
WHERE "user" = ?
AND forum = ?',
array($userid, $forumid)
);
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment