/** * @param int $contextId * @param string $username * @param string $cabin */ protected function getPermissionsDataForUser(int $contextId, string $username, string $cabin) { $perm_bp = $this->blueprint('Permissions'); $user_bp = $this->blueprint('UserAccounts'); if (IDE_HACKS) { $db = \Airship\get_database(); $perm_bp = new Permissions($db); $user_bp = new UserAccounts($db); } $user = $user_bp->getUserByUsername($username, true); if (empty($user)) { \Airship\json_response(['status' => 'ERROR', 'message' => \__('There is no user with that username in the system')]); } $userPerms = $perm_bp->getUserPerms($user['userid'], $contextId); $actions = $perm_bp->getActionNames($cabin); $perms = []; foreach ($actions as $action) { $perms[$action] = \in_array($action, $userPerms); } \Airship\json_response(['status' => 'OK', 'message' => $this->lensRender('perms/user', ['user' => $user, 'actions' => $actions, 'perms' => $perms])]); }