Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function efIACUserCanAccessDatabaseGroups(&$user, &$accessGroups, $action) {
- $dbw = wfGetDB(DB_MASTER);
- $allowedGroups = explode(',,', $accessGroups);
- $allowedGroupsString = '';
- foreach($allowedGroups as $group) {
- $group = strtolower($dbw->strencode($group));
- $allowedGroupsString .= "'{$group}',";
- } //foreach
- $allowedGroupsString = substr($allowedGroupsString, 0, -1); //remove trailing comma
- $userName = $dbw->strencode(trim($user->getName()));
- $res = $dbw->query("
- SELECT DISTINCT u.user_name FROM `user` u, `group` g, `user_group` ug
- WHERE LOWER(CONVERT(g.group_name USING utf8)) IN ({$allowedGroupsString}) AND
- u.user_name = '{$userName}' AND
- ug.user_id = u.user_id AND
- ug.group_id = g.group_id"
- );
- if ($res->numRows() == 0) {
- return false;
- } else {
- efIACDebugLog("(efIACUserCanAccessDatabaseGroups)" . "full access granted ");
- return true;
- } //else
- } //efIACUserCanAccessDatabaseGroups
Add Comment
Please, Sign In to add comment