Merge junction permissions with global permissions if they are disabled.
@param array $GlobalPermissions
@return void
497346
protected function _MergeDisabledPermissions(&$GlobalPermissions) {
		// Get the default permissions for junctions that are disabled.
		$DisabledPermissions = C('Garden.Permissions.Disabled');
		if(!$DisabledPermissions)
			return;

		$DisabledIn = array();
		foreach($DisabledPermissions as $JunctionTable => $Disabled) {
			if($Disabled)
				$DisabledIn[] = $JunctionTable;
		}

		if(!$DisabledIn)
			return;

		$DisabledData = $this->SQL
			->Select('*')
			->From('Permission p')
			->Where('p.RoleID', 0)
			->WhereIn('p.JunctionTable', $DisabledIn)
			->Get()->ResultArray();

		$DefaultRow =& $GlobalPermissions[0];

		// Loop through each row and add it's default definition to the global permissions.
		foreach($DisabledData as $PermissionRow) {
			foreach($PermissionRow as $ColumnName => $Value) {
				if(in_array($ColumnName, array('PermissionID', 'RoleID', 'JunctionTable', 'JunctionColumn', 'JunctionID')))
					continue;

				if($Value & 2) {
					$Setting = $Value | GetValue($ColumnName, $DefaultRow, 0);
					SetValue($ColumnName, $DefaultRow, $Setting);
				}
			}
		}
	}
954851
public function attachPermission($permission, array $options = [])
    {
        if (! is_array($permission)) {
            if ($this->existPermission($permission->name)) {
                return;
            }
        }

        $this->permissions()->attach($permission, [
            'value'   => array_get($options, 'value', true),
            'expires' => array_get($options, 'expires', null),
        ]);
    }
1091706
public void setLoadPermissions(java.util.Collection<LoadPermission> loadPermissions) {
        if (loadPermissions == null) {
            this.loadPermissions = null;
            return;
        }

        this.loadPermissions = new com.amazonaws.internal.SdkInternalList<LoadPermission>(loadPermissions);
    }
522371
public function setGlobalMergeVars(array $vars){
        $this->global_merge_vars = array();
        foreach($vars as $name => $content){
            $this->addGlobalMergeVar($name, $content);
        }
        return $this;
    }
933415
def set_global_permissions(self, global_permissions):
        
        content = self._serialize.body(global_permissions, '[GlobalPermission]')
        response = self._send(http_method='PATCH',
                              location_id='a74419ef-b477-43df-8758-3cd1cd5f56c6',
                              version='5.0-preview.1',
                              content=content)
        return self._deserialize('[GlobalPermission]', self._unwrap_collection(response))
870263
protected function setPermissions($permissions)
    {
        foreach ($permissions as $action => $permission) {
            $this->setPermission($action, $permission);
        }
    }
906536
public void deleteGlobalPermission(DbSession dbSession, int userId, String permission, String organizationUuid) {
    mapper(dbSession).deleteGlobalPermission(userId, permission, organizationUuid);
  }
1136071
private function preloadPermissionsOfSharingRoles(array $objects): void
    {
        if (!$this->hasIdentityRoleable()) {
            return;
        }

        $subjects = $this->buildMapSubject($objects);

        foreach ($subjects as $id => $subject) {
            if (!isset($this->cacheRoleSharing[$id])
                    && isset($this->cacheSubjectSharing[$id]['sharings'])) {
                $this->buildCacheRoleSharing($this->cacheSubjectSharing[$id]['sharings'], $id);
            }
        }
    }
819559
protected function convertPermissions(array &$permissions) {
    $all_permissions = $this->getAllPermissions();

    foreach ($all_permissions as $name => $definition) {
      $key = array_search($definition['title'], $permissions);
      if (FALSE !== $key) {
        $permissions[$key] = $name;
      }
    }
  }
205364
public function eachPermission(array $permissions, callable $callback)
    {
        $permissions = array_flatten($permissions);

        foreach ($permissions as $permission) {
            if ($permission = $this->preparePermission($permission)) {
                $callback($permission);    
            }
        }
    }
1121963
public function onAddPermissions(AddPermissionsEventInterface $event)
    {
        $permissionTree = ['routes' => []];
        foreach ($this->router->getRouteCollection()->getIterator() as $name => $route) {
            if (!($route instanceof RouteInterface)) {
                continue;
            }

            $permissions = $route->getPermissions();
            if (is_null($permissions)) {
                continue;
            }

            $permissionTree['routes'][$name] = $permissions;
        }
        $event->insertTree($permissionTree);
    }
452056
private function mapPermissions(array $userPermission, array $permissions, callable $reduce)
    {
        foreach ($permissions as $attribute => $value) {
            if (!isset($userPermission[$attribute])) {
                $userPermission[$attribute] = false;
            }

            $userPermission[$attribute] = $reduce($userPermission[$attribute], $value);
        }

        return $userPermission;
    }
666208
public function setPermissionsAttribute($permissions)
    {
        $module = lcfirst($this->attributes['name']);

        $roles = array();

        //prefix the permission with the module name ex: user.create
        foreach ($permissions as $key => $value)
        {
            $roles[] = $module . '.' . $value;
        }

        $this->attributes['permissions'] = ( ! empty($roles)) ? json_encode($roles) : '';
    }
50072
public function detachPermission(...$permissions)
    {
        $this->eachPermission($permissions, function($permission) {
            if ($this->hasDirectPermission($permission)) {
                $this->permissions()->detach($permission->id);
            }
        });

        return $this;
    }
1080245
private function restrictPermissions(array $userPermission, array $permissions)
    {
        return $this->mapPermissions($userPermission, $permissions, function($permission1, $permission2) {
            return $permission1 && $permission2;
        });
    }
1149794
@Override
	public void mergePermissions(AccessControl from, AccessControl to)
	{
		if (from == null || to == null)
			return;

		List<Permission> otherPermissions = from.getPermissions();

		if (otherPermissions == null)
			return;

		boolean changeNegative = from.isNegative() != to.isNegative();

		if (changeNegative)
			throw new SecurityException(
			"Cannot change or mixed different negative property for ACL from:" + from + " to ACL:" + to
			+ "  permission must be either all negative or all positive for a principal");

		Iterator<Permission> i = otherPermissions.iterator();

		while (i.hasNext())
		{

			to.addPermission(i.next());
		}
	}
672386
public function setExtensionGlobals(array $globals)
    {
        foreach ($globals as $key => $value) {
            $this->globals[$key] = $value;
        }
    }