Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
*phprbac.sqlite3*
*Doxygen*
*phpdoc*
index.php
index.php
.idea/
22 changes: 21 additions & 1 deletion PhpRbac/src/PhpRbac/core/lib/rbac.php
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,27 @@ function allRoles($UserID = null)
WHERE TRel.UserID=?", $UserID );
}

/**
/**
* @param null $UserID
* @return array|int|null
* @throws RbacRoleNotFoundException
* @throws RbacUserNotProvidedException
*/
function allPermissions($UserID = null)
{
if ($UserID === null)
throw new \RbacUserNotProvidedException ("\$UserID is a required argument.");

$Role = Jf::sql ( "SELECT RoleID FROM {$this->tablePrefix()}userroles as ur , {$this->tablePrefix()}roles as r WHERE ur.roleid = r.id and UserID=? limit 1", $UserID );
if (!$Role)
throw new \RbacRoleNotFoundException("User`s Role not found.");
else
$permissions = Jf::sql ( "SELECT R.* FROM {$this->tablePrefix()}rolepermissions as RP ,{$this->tablePrefix()}permissions as P WHERE roleID=? and RP.PermissionID = P.ID", $Role['RoleID'] );
return $permissions ? $permissions : array();

}

/**
* Return count of roles assigned to a user
*
* @param integer $UserID
Expand Down