WIP: Epic/permissions 28
MR for insight into everything that has changed for permissions
0/10 threads resolved
changed milestone to %Permission #review
added Sprint::09/25 - Oldfashioned Owl Squad::Green scoped labels
mentioned in epic &28
added MR::Requires Changes scoped label
108 if ($item && Di::_()->get('Features\Manager')->has('permissions')) { 109 if ($item instanceof FeedSyncEntity && $item->getEntity()) { 110 $entity = $item->getEntity(); 111 } else { 112 $entity = $item; 113 } 114 115 /** @var Manager $permissionsManager */ 116 $permissionsManager = Di::_()->get('Permissions\Manager'); 117 $permissions = $permissionsManager->getList([ 118 'user_guid' => Session::getLoggedinUser(), 119 'entities' => [$entity], 120 ]); 121 122 if ($item instanceof FeedSyncEntity) { 123 $exported['entity']['permissions'] = $permissions->exportPermission($entity->getGuid()); - Owner
Why are we calling this
exportPermission()
and not justexport()
?
100 105 101 106 $exported = $item->export(...$this->exportArgs); 102 107 108 if ($item && Di::_()->get('Features\Manager')->has('permissions')) { 109 if ($item instanceof FeedSyncEntity && $item->getEntity()) { 110 $entity = $item->getEntity(); 111 } else { 112 $entity = $item; 113 } 114 115 /** @var Manager $permissionsManager */ 116 $permissionsManager = Di::_()->get('Permissions\Manager'); 117 $permissions = $permissionsManager->getList([ - Owner
Why are using a list function for a single entity?
220 $entities[$k]['guid'] = (string) $entities[$k]['guid']; //javascript doesn't like long numbers.. 221 if (isset($entities[$k]['ownerObj']['guid'])) { 222 $entities[$k]['ownerObj']['guid'] = (string) $entity->ownerObj['guid']; 223 } 224 foreach ($exceptions as $exception) { 225 $entities[$k][$exception] = $entity->$exception; 226 } 215 $entities[$k] = Factory::export($entity, $exceptions, $exportContext, $includePermissions); 227 216 } 228 217 return $entities; 229 218 } 219 220 /** 221 * Exports a single entity, called by exportable for arrays 222 */ 223 public static function export($entity, $exceptions = false, $exportContext=false, $includePermissions = true) - Owner
Theres now a lot going on the API factory that I think warrants a refactor from statics to objects.
36 41 /** @var int */ 37 42 protected $timestamp; 38 43 44 /** @var int */ 45 protected $accessId; 46 39 47 /** @var string */ 40 48 protected $urn; 41 49 42 50 /** @var Entity */ 43 51 protected $entity; 44 52 53 public function setEntity($entity) - Owner
Code doc and type needed
50 69 { 51 70 return [ 52 71 'guid' => (string) $this->guid, 53 'owner_guid' => (string) $this->ownerGuid, 72 'owner_guid' => (string) $this->ownerGuid, 73 'access_id' => $this->accessId, - Owner
force as int?
37 public function __construct(User $user = null, Roles $roles = null, EntitiesBuilder $entitiesBuilder = null) 38 38 { 39 39 $this->entitiesBuilder = $entitiesBuilder ?: Di::_()->get('EntitiesBuilder'); 40 40 $this->roles = $roles ?: new Roles(); 41 41 $this->user = $user; 42 $this->isAdmin = $user->isAdmin(); 43 $this->isBanned = $user->isBanned(); 44 42 $this->groups = []; 45 43 $this->channels = []; 46 44 $this->entities = []; 45 $this->roles = $roles ?: new Roles(); 46 $this->user = $user; 47 if ($this->user) { 48 $this->isAdmin = $user->isAdmin(); 49 $this->isBanned = $user->isBanned(); 50 $this->channels[$user->getGuid()] = $user; - Owner
where is $channels var instantiated?
72 77 public function calculate(array $entities = []): void 73 78 { 74 79 foreach ($entities as $entity) { 75 $this->entities[$entity->getGUID()] = $this->getRoleForEntity($entity); 80 if ($entity) { 81 $this->entities[$entity->getGuid()] = $this->getRoleForEntity($entity); 82 } 76 83 } 77 84 } 78 85 79 86 private function getRoleForEntity($entity): Role - Owner
code doc needed
119 150 return $export; 120 151 } 121 152 153 /** 154 * Export the exact permissions for a calculated entity only 155 * 156 * @return array serialized individual permission for an entity 157 */ 158 public function exportPermission($guid): array - Owner
I'm having trouble with this function name, its not clear how it is different from
export()
function.
1446 1446 PRIMARY KEY (receiver_guid, time_sent) 1447 1447 ) WITH CLUSTERING ORDER BY (time_sent desc); 1448 1448 1449 CREATE TABLE minds.moderation_reports ( - Owner
Do we want this in this MR?
21 21 * @property-read string $enabled 22 22 */ 23 23 abstract class ElggEntity extends ElggData implements 24 Importable // Allow import of data - Owner
I can't tell what has been changed in this file.