Exemple #1
0
 /**
  * @param CourseInterface $course
  * @param UserInterface $user
  * @return bool
  */
 protected function isWriteGranted($course, $user)
 {
     // grant CREATE/EDIT/DELETE privileges if at least one of the following
     // statements is true:
     // 1. the user's primary school is the course's owning school
     //    and the user has at least one of the 'Faculty', 'Course Director' and 'Developer' roles.
     // 2. the user has WRITE rights on the course's owning school via the permissions system
     //    and the user has at least one of the 'Faculty', 'Course Director' and 'Developer' roles.
     // 3. the user has WRITE rights on the course via the permissions system
     return $this->userHasRole($user, ['Faculty', 'Course Director', 'Developer']) && ($this->schoolsAreIdentical($course->getSchool(), $user->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $course->getSchool())) || $this->permissionManager->userHasWritePermissionToCourse($user, $course);
 }
Exemple #2
0
 /**
  * @param ObjectiveInterface $objective
  * @param UserInterface $user
  * @return bool
  */
 protected function isCreateEditDeleteGrantedForCourseObjective($objective, $user)
 {
     /* @var CourseInterface $course */
     $course = $objective->getCourses()->first();
     // there should ever only be one
     // Code below has been copy/pasted straight out of CourseVoter::isGranted().
     // TODO: consolidate. [ST 2015/08/05]
     // HALT!
     // deny DELETE and CREATE privileges if the owning course is locked or archived.
     if ($course->isArchived() || $course->isLocked()) {
         return false;
     }
     return $this->userHasRole($user, ['Faculty', 'Course Director', 'Developer']) && ($this->schoolsAreIdentical($course->getSchool(), $user->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $course->getSchool())) || $this->permissionManager->userHasWritePermissionToCourse($user, $course);
 }
Exemple #3
0
 /**
  * @param PublishEventInterface $event
  * @param UserInterface $user
  * @return bool
  *
  * @see CourseVoter::isGranted()
  */
 protected function isCreateGrantedForSessionPublishEvent($event, $user)
 {
     $session = $this->sessionManager->findSessionBy(['id' => $event->getTableRowId()]);
     if (empty($session)) {
         return false;
     }
     $course = $session->getCourse();
     // copied and pasted from CourseManager::isGranted()
     // TODO: consolidate [ST 2015/08/05]
     // HALT!
     // deny DELETE and CREATE privileges if the owning course is locked or archived.
     if ($course->isArchived() || $course->isLocked()) {
         return false;
     }
     return $this->userHasRole($user, ['Faculty', 'Course Director', 'Developer']) && ($this->schoolsAreIdentical($course->getSchool(), $user->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $course->getSchool())) || $this->permissionManager->userHasWritePermissionToCourse($user, $course);
 }