Backend\Modules\Users\Engine\Model::getModuleGroupsRightsActions PHP Method

getModuleGroupsRightsActions() public static method

Get all module action combinations a user has access to
public static getModuleGroupsRightsActions ( integer $userId ) : array
$userId integer The id of the user
return array
    public static function getModuleGroupsRightsActions($userId)
    {
        return (array) BackendModel::get('database')->getRecords('SELECT a.module, a.action
            FROM groups AS g
                INNER JOIN users_groups AS u ON u.group_id = g.id
                INNER JOIN groups_rights_modules AS m ON m.group_id = g.id
                INNER JOIN groups_rights_actions AS a ON a.group_id = g.id
                    AND m.module = a.module
            WHERE m.module = ?
            GROUP BY a.module, a.action', $userId);
    }

Usage Example

Beispiel #1
0
 private function getAllowedAction($module)
 {
     if (BackendAuthentication::isAllowedAction('Index', $module)) {
         return 'Index';
     }
     $allowedAction = false;
     $groupsRightsActions = BackendUsersModel::getModuleGroupsRightsActions($module);
     foreach ($groupsRightsActions as $groupsRightsAction) {
         $isAllowedAction = BackendAuthentication::isAllowedAction($groupsRightsAction['action'], $module);
         if ($isAllowedAction) {
             $allowedAction = $groupsRightsAction['action'];
             break;
         }
     }
     return $allowedAction;
 }