コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function isWriteGranted(ProgramYearInterface $programYear, $user)
 {
     // prevent modifications and deletions of locked or archived program years
     if ($programYear->isLocked() || $programYear->isArchived()) {
         return false;
     }
     return parent::isWriteGranted($programYear, $user);
 }
コード例 #2
0
 /**
  * Checks if a given entity's school (co-)stewards a given program year.
  *
  * @param SchoolEntityInterface $schoolEntity the entity with a school
  * @param ProgramYearInterface $programYear
  * @return bool
  */
 public function schoolIsStewardingProgramYear(SchoolEntityInterface $schoolEntity, ProgramYearInterface $programYear)
 {
     $school = $schoolEntity->getSchool();
     if (!$school instanceof SchoolInterface) {
         return false;
     }
     $criteria = ['programYear' => $programYear->getId()];
     $stewards = $this->findProgramYearStewardsBy($criteria);
     foreach ($stewards as $steward) {
         $stewardingSchool = $steward->getSchool();
         if ($stewardingSchool instanceof SchoolInterface && $school->getId() === $stewardingSchool->getId()) {
             return true;
         }
     }
     return false;
 }
コード例 #3
0
ファイル: ProgramYearSteward.php プロジェクト: Okami-/ilios
 /**
  * @return ProgramYearInterface
  */
 public function getProgramYear()
 {
     if ($this->programYear && !$this->programYear->isDeleted()) {
         return $this->programYear;
     }
     return null;
 }
コード例 #4
0
 /**
  * @param ProgramYearInterface $programYear
  * @param UserInterface $user
  * @return bool
  */
 protected function isWriteGranted(ProgramYearInterface $programYear, $user)
 {
     // the given user is granted CREATE/EDIT/DELETE permissions on the given program year
     // when at least one of the following statements is true
     // 1. The user's primary school is the same as the parent program's owning school
     //    and the user has at least one of 'Course Director' and 'Developer' role.
     // 2. The user has WRITE permissions on the parent program's owning school
     //    and the user has at least one of 'Course Director' and 'Developer' role.
     // 3. The user's primary school matches at least one of the schools owning the
     //    program years' stewarding department,
     //    and the user has at least one of 'Course Director' and 'Developer' role.
     // 4. The user has WRITE permissions on the parent program.
     return $this->userHasRole($user, ['Course Director', 'Developer']) && ($this->schoolsAreIdentical($programYear->getSchool(), $user->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $programYear->getSchool()->getId()) || $this->stewardManager->schoolIsStewardingProgramYear($user, $programYear)) || $this->permissionManager->userHasWritePermissionToProgram($user, $programYear->getProgram());
 }
コード例 #5
0
 /**
  * Creates a new cohort for the new program year.
  * @param ProgramYearInterface $programYear
  */
 protected function createCohort(ProgramYearInterface $programYear)
 {
     $cohortManager = $this->container->get('ilioscore.cohort.manager');
     $program = $programYear->getProgram();
     $graduationYear = $programYear->getStartYear() + $program->getDuration();
     /* @var CohortInterface $cohort */
     $cohort = $cohortManager->create();
     $cohort->setTitle("Class of {$graduationYear}");
     $cohort->setProgramYear($programYear);
     $programYear->setCohort($cohort);
     $cohortManager->update($cohort, false, false);
 }
コード例 #6
0
ファイル: ProgramYearManager.php プロジェクト: Okami-/ilios
 /**
  * {@inheritdoc}
  */
 public function deleteProgramYear(ProgramYearInterface $programYear)
 {
     $programYear->setDeleted(true);
     $this->updateProgramYear($programYear);
 }