Return an updated context
with the permissions of $suIds (a list of user IDs) added.
195323
public static function suContext( $ctx, array $suIds, $pmm ) {
		$currentUserId = self::contextUserId($ctx);
		$includesCurrentUserId = false;
		$addsOtherUserIds = false;
		foreach( $suIds as $suId ) {
			if( $currentUserId === $suId ) {
				$includesCurrentUserId = true;
				// Ha ha ha, nothing to do!
			} else {
				$addsOtherUserIds = true;
			}
		}

		if( $addsOtherUserIds ) {
			throw new Exception("sudoContext not actually implemented in the not-already-the-current-user case. 🐮");
		}
		
		switch( $pmm ) {
		case EarthIT_CMIPREST_RESTAction_SudoAction::PMM_ADD:
			break;
		case EarthIT_CMIPREST_RESTAction_SudoAction::PMM_REPLACE:
			if( !$includesCurrentUserId ) {
				throw new Exception("sudoContext can't remove the current user ID from the context. 🐮");
			}
			break;
		default:
			throw new Exception("Unsupported permission merge mode: $pmm");
		}
		return $ctx;
	}
39783
def _get_user_cached_perms(self):
        
        if not self.user:
            return {}, {}
        group_pks = set(self.user.groups.values_list(
            'pk',
            flat=True,
        ))
        perms = Permission.objects.filter(
            Q(user__pk=self.user.pk) | Q(group__pk__in=group_pks),
        )
        user_permissions = {}
        group_permissions = {}
        for perm in perms:
            if perm.user_id == self.user.pk:
                user_permissions[(
                    perm.object_id,
                    perm.content_type_id,
                    perm.codename,
                    perm.approved,
                )] = True
            # If the user has the permission do for something, but perm.user !=
            # self.user then by definition that permission came from the
            # group.
            else:
                group_permissions[(
                    perm.object_id,
                    perm.content_type_id,
                    perm.codename,
                    perm.approved,
                )] = True
        return user_permissions, group_permissions
889675
def get_owner_ids_value(self, obj):
        """"""
        return [
            user.pk
            for user in get_users_with_permission(obj, get_full_perm('owner', obj))
        ]
275462
private static List<String> getDeniedPermissions(PermissionChecker checker, Source source, String... permissions) {
        List<String> deniedList = new ArrayList<>(1);
        for (String permission : permissions) {
            if (!checker.hasPermission(source.getContext(), permission)) {
                deniedList.add(permission);
            }
        }
        return deniedList;
    }
522228
def _update_request_context_with_user(self, user=None):
        ''''''

        ctx = _request_ctx_stack.top
        ctx.user = self.anonymous_user() if user is None else user
517066
def update(self, request, pk=None, parent_lookup_organization=None):
        ''''''
        user = get_object_or_404(User, pk=pk)
        org = get_object_or_404(
            SeedOrganization, pk=parent_lookup_organization)
        self.check_object_permissions(request, org)
        org.users.add(user)
        return Response(status=status.HTTP_204_NO_CONTENT)
1106697
def user_context(self, worker_ctx, exc_info):
        
        user = {}
        for key in worker_ctx.context_data:
            for matcher in self.user_type_context_keys:
                if re.search(matcher, key):
                    user[key] = worker_ctx.context_data[key]
                    break

        self.client.user_context(user)
968122
def context_id(self):
        """"""
        if not self._context_id:
            self._context_id = self._get_context_id()
            self.update_options(context_id=self._context_id)

        return self._context_id
814593
private void modify(Set<Permission> permissions, IResource resource, String user, String op) throws RequestExecutionException
    {
        process(String.format("UPDATE %s.%s SET permissions = permissions %s {%s} WHERE username = '%s' AND resource = '%s'",
                              Auth.AUTH_KS,
                              PERMISSIONS_CF,
                              op,
                              "'" + StringUtils.join(permissions, "','") + "'",
                              escape(user),
                              escape(resource.getName())));
    }
1058263
def get(context, request, username=None):
    
    user_ids = []

    # Don't allow anonymous users to query a user other than themselves
    if api.is_anonymous():
        username = "current"

    # query all users if no username was given
    if username is None:
        user_ids = api.get_member_ids()
    elif username == "current":
        current_user = api.get_current_user()
        user_ids = [current_user.getId()]
    else:
        user_ids = [username]

    # Prepare batch
    size = req.get_batch_size()
    start = req.get_batch_start()
    batch = api.make_batch(user_ids, size, start)

    # get the user info for the user ids in the current batch
    users = map(get_user_info, batch.get_batch())

    return {
        "pagesize": batch.get_pagesize(),
        "next": batch.make_next_url(),
        "previous": batch.make_prev_url(),
        "page": batch.get_pagenumber(),
        "pages": batch.get_numpages(),
        "count": batch.get_sequence_length(),
        "items": users,
    }
429437
def edit_shares(self, id, user_ids): # pylint: disable=invalid-name,redefined-builtin
        
        return self.service.edit_shares(self.base, id, user_ids)
1367881
def get_permissions(self):
        """"""
        permissions = set()
        permissions.update(self.resource_manager.get_permissions())
        for f in self.resource_manager.filters:
            permissions.update(f.get_permissions())
        for a in self.resource_manager.actions:
            permissions.update(a.get_permissions())
        return permissions
1349424
def compute_extension_rights(self, ids):
        
        content = self._serialize.body(ids, '[str]')
        response = self._send(http_method='POST',
                              location_id='5f1dbe21-f748-47c7-b5fd-3770c8bc2c08',
                              version='5.0-preview.1',
                              content=content)
        return self._deserialize('{bool}', self._unwrap_collection(response))
1208761
def _get_context_id(self):
        """"""

        from furious.context import get_current_context

        context_id = self._options.get('context_id')

        if context_id:
            return context_id

        try:
            context = get_current_context()
        except errors.NotInContextError:
            context = None
            self.update_options(context_id=None)

        if context:
            context_id = context.id
            self.update_options(context_id=context_id)

        return context_id
809331
function setCachedMountContext(blockchain_id, datastore_context) {

   let userData = getUserData();
   if (!userData.datastore_contexts) {
      userData.datastore_contexts = {};
   }

   userData.datastore_contexts[blockchain_id] = datastore_context;
   setUserData(userData);
}
1362678
function getCachedMountContext(blockchain_id) {

   let userData = getUserData();
   if (!userData.datastore_contexts) {
      console.log("No datastore contexts defined");
      return null;
   }

   if (!userData.datastore_contexts[blockchain_id]) {
      console.log(`No datastore contexts for ${blockchain_id}`);
      return null;
   }

   let ctx = userData.datastore_contexts[blockchain_id];
   if (!ctx) {
      console.log(`Null datastore context for ${blockchain_id}`);
      return null;
   }

   return ctx;
}
1060388
public static function get_contexts_for_userid(int $userid) : \core_privacy\local\request\contextlist {
        $contextlist = new \core_privacy\local\request\contextlist();

        // Always add the user context so we're sure we're not dodging user keys, besides it's not costly to do so.
        $contextlist->add_user_context($userid);

        return $contextlist;
    }