예제 #1
0
 /**
  * @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;
 }
예제 #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);
 }
예제 #3
0
 /**
  * @JMS\VirtualProperty
  * @JMS\SerializedName("id")
  *
  * @return string
  */
 public function getId()
 {
     return $this->session->getId();
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function deleteSession(SessionInterface $session)
 {
     $session->setDeleted(true);
     $this->updateSession($session);
 }
예제 #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);
     }
 }