/**
  * @param string $attribute
  * @param SessionInterface $session
  * @param TokenInterface $token
  * @return bool
  */
 protected function voteOnAttribute($attribute, $session, TokenInterface $token)
 {
     $user = $token->getUser();
     if (!$user instanceof UserInterface) {
         return false;
     }
     $course = $session->getCourse();
     switch ($attribute) {
         case self::VIEW:
             return $this->isViewGranted($course->getId(), $course->getSchool()->getId(), $user);
             break;
         case self::CREATE:
         case self::EDIT:
         case self::DELETE:
             // prevent any sort of write operation (create/edit/delete) if the parent course is locked or archived.
             if ($course->isLocked() || $course->isArchived()) {
                 return false;
             }
             return $this->isWriteGranted($course->getId(), $course->getSchool()->getId(), $user);
             break;
     }
     return false;
 }
Beispiel #2
0
 /**
  * @param string $attribute
  * @param SessionInterface $session
  * @param UserInterface|null $user
  * @return bool
  */
 protected function isGranted($attribute, $session, $user = null)
 {
     // grant perms based on the owning course
     return parent::isGranted($attribute, $session->getCourse(), $user);
 }
Beispiel #3
0
 /**
  * @JMS\VirtualProperty
  * @JMS\SerializedName("id")
  *
  * @return string
  */
 public function getId()
 {
     return $this->session->getId();
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function deleteSession(SessionInterface $session)
 {
     $session->setDeleted(true);
     $this->updateSession($session);
 }
Beispiel #5
0
 /**
  * @param SessionInterface     $newSession
  * @param SessionInterface     $origSession
  * @param $daysOffset
  */
 protected function rolloverIlmSession(SessionInterface $newSession, SessionInterface $origSession, $daysOffset)
 {
     /* @var IlmSessionInterface $origIlmSession */
     if ($origIlmSession = $origSession->getIlmSession()) {
         /* @var IlmSessionInterface $newIlmSession */
         $newIlmSession = $this->ilmSessionManager->create();
         $newIlmSession->setHours($origIlmSession->getHours());
         $newSession->setIlmSession($newIlmSession);
         $newDueDate = $this->getAdjustedDate($origIlmSession->getDueDate(), $daysOffset);
         $newIlmSession->setDueDate($newDueDate);
         $this->ilmSessionManager->update($newIlmSession, false, false);
     }
 }