get('type') === 'Post' && $user->id === $entity->get('createdById')) { return true; } return false; } public function checkEntityCreate(EntityUser $user, Entity $entity, $data) { if ($entity->get('parentId') && $entity->get('parentType')) { $parent = $this->getEntityManager()->getEntity($entity->get('parentType'), $entity->get('parentId')); if ($parent) { if ($this->getAclManager()->checkEntity($user, $parent, 'stream')) { return true; } } return false; } return true; } public function checkEntityEdit(EntityUser $user, Entity $entity, $data) { if ($user->isAdmin()) { return true; } if ($this->checkEntity($user, $entity, $data, 'edit')) { if ($this->checkIsOwner($user, $entity)) { $createdAt = $entity->get('createdAt'); if ($createdAt) { $noteEditThresholdPeriod = '-' . $this->getConfig()->get('noteEditThresholdPeriod', $this->editThresholdPeriod); $dt = new \DateTime(); $dt->modify($noteEditThresholdPeriod); try { if ($dt->format('U') > (new \DateTime($createdAt))->format('U')) { return false; } } catch (\Exception $e) { return false; } } } return true; } return false; } public function checkEntityDelete(EntityUser $user, Entity $entity, $data) { if ($user->isAdmin()) { return true; } if ($this->checkEntity($user, $entity, $data, 'delete')) { if ($this->checkIsOwner($user, $entity)) { $createdAt = $entity->get('createdAt'); if ($createdAt) { $deleteThresholdPeriod = '-' . $this->getConfig()->get('noteDeleteThresholdPeriod', $this->deleteThresholdPeriod); $dt = new \DateTime(); $dt->modify($deleteThresholdPeriod); try { if ($dt->format('U') > (new \DateTime($createdAt))->format('U')) { return false; } } catch (\Exception $e) { return false; } } } return true; } return false; } }