39 public function get(
int $entityId,
string $feature,
string $operation,
int $userId = 0,
string $entityType = SONET_ENTITY_GROUP): bool
45 || !in_array($entityType, [ SONET_ENTITY_GROUP, SONET_ENTITY_USER ],
true)
51 $storageKey = $this->getStorageKey($userId, $entityType, $feature, $operation);
53 if (!isset($this->storage[$storageKey][$entityId]))
55 $this->
load([$entityId], $feature, $operation, $userId, $entityType);
58 if (!isset($this->storage[$storageKey][$entityId]))
63 return $this->storage[$storageKey][$entityId];
74 public function load(array $entityIdList,
string $feature,
string $operation,
int $userId = 0,
string $entityType = SONET_ENTITY_GROUP): self
80 || !in_array($entityType, [ SONET_ENTITY_GROUP, SONET_ENTITY_USER ],
true)
86 $storageKey = $this->getStorageKey($userId, $entityType, $feature, $operation);
88 if (!isset($this->storage[$storageKey]))
90 $this->storage[$storageKey] = [];
93 $entityIdList = array_diff(array_unique($entityIdList), array_keys($this->storage[$storageKey]));
94 if (empty($entityIdList))
99 $permissionData = \CSocNetFeaturesPerms::canPerformOperation($userId, $entityType, $entityIdList, $feature, $operation);
100 if (!is_array($permissionData))
105 foreach ($entityIdList as $id)
107 $this->storage[$storageKey][$id] =
false;
110 foreach ($permissionData as $id => $hasAccess)
112 $this->storage[$storageKey][$id] = $hasAccess;
120 return implode(
' ', [ (
string)$userId, $entityType, $feature, $operation ]);