/** * @param string $attribute * @param SessionLearningMaterialInterface $material * @param TokenInterface $token * @return bool */ protected function voteOnAttribute($attribute, $material, TokenInterface $token) { $session = $material->getSession(); if (!$session) { return false; } // grant perms based on the owning session $granted = parent::voteOnAttribute($attribute, $session, $token); // prevent access if associated LM is in draft, and the current user has no elevated privileges. if ($granted && self::VIEW === $attribute) { $granted = $this->userHasRole($token->getUser(), ['Faculty', 'Course Director', 'Developer']) || LearningMaterialStatusInterface::IN_DRAFT !== $material->getLearningMaterial()->getStatus()->getId(); } return $granted; }
/** * @param string $attribute * @param SessionLearningMaterialInterface $material * @param UserInterface|null $user * @return bool */ protected function isGranted($attribute, $material, $user = null) { // grant perms based on the owning session return parent::isGranted($attribute, $material->getSession(), $user); }