Esempio n. 1
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);
 }
Esempio n. 2
0
 /**
  * @param ProgramYearInterface $programYear
  * @param UserInterface $user
  * @return bool
  */
 protected function isWriteGranted($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->getProgram()->getSchool(), $user->getSchool()) || $this->permissionManager->userHasWritePermissionToSchool($user, $programYear->getProgram()->getSchool()) || $this->stewardManager->schoolIsStewardingProgramYear($user, $programYear)) || $this->permissionManager->userHasWritePermissionToProgram($user, $programYear->getProgram());
 }