/** * @param ObjectiveInterface $objective * @param UserInterface $user * @return bool */ protected function isCreateEditDeleteGrantedForProgramYearObjective($objective, $user) { /* @var ProgramYearInterface $programYear */ $programYear = $objective->getProgramYears()->first(); // there should ever only be one // Code below has been copy/pasted straight out of ProgramYearVoter::isGranted(). // TODO: consolidate. [ST 2015/08/05] if ($programYear->isLocked() || $programYear->isArchived()) { return false; } 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()); }
/** * @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()); }
/** * @param Registry $em * @param string $class * @param FormFactoryInterface $formFactory */ public function __construct(Registry $em, $class, FormFactoryInterface $formFactory) { $this->formFactory = $formFactory; parent::__construct($em, $class); }