/** * Handles access to the event add form through RDF entity pages. * * Access is granted to moderators and group members that have the permission * to create event articles inside of their group, which in practice means * this is granted to collection and solution facilitators. * * @param \Drupal\rdf_entity\RdfInterface $rdf_entity * The RDF entity for which the event entity is created. * * @return \Drupal\Core\Access\AccessResult * The access result object. */ public function createEventAccess(RdfInterface $rdf_entity) { if (!in_array($rdf_entity->bundle(), ['collection', 'solution'])) { return AccessResult::forbidden(); } $user = $this->currentUser(); // Grant access if the user is a moderator. if (in_array('moderator', $user->getRoles())) { return AccessResult::allowed()->addCacheContexts(['user.roles']); } // Grant access depending on whether the user has permission to create an // event node entity according to their OG role. return $this->ogAccess->userAccessGroupContentEntityOperation('create', $rdf_entity, $this->createEventEntity($rdf_entity), $user); }
/** * Handles access to the custom page add form through collection pages. * * Access is granted to moderators and group members that have the permission * to create custom pages inside of their group, which in practice means this * is granted to collection and solution facilitators. * * @param \Drupal\rdf_entity\RdfInterface $rdf_entity * The RDF entity for which the custom page is created. * * @return \Drupal\Core\Access\AccessResult * The access result object. */ public function createCustomPageAccess(RdfInterface $rdf_entity) { $user = $this->currentUser(); // Grant access if the user is a moderator. if (in_array('moderator', $user->getRoles())) { return AccessResult::allowed()->addCacheContexts(['user.roles']); } // Grant access depending on whether the user has permission to create a // custom page according to their OG role. return $this->ogAccess->userAccessGroupContentEntityOperation('create', $rdf_entity, $this->createNewCustomPage($rdf_entity), $user); }
/** * Handles access to the news add form through RDF entity pages. * * Access is granted to moderators and group members that have the permission * to create news articles inside of their group, which in practice means this * is granted to collection and solution facilitators. * * @todo Depending on the 'eLibrary creation' setting, members should be able * to create news. * @todo If a collection is open non-members should be able to create news. * * @see https://webgate.ec.europa.eu/CITnet/jira/browse/ISAICP-2654 * @see https://webgate.ec.europa.eu/CITnet/jira/browse/ISAICP-2445 * * @param \Drupal\rdf_entity\RdfInterface $rdf_entity * The RDF entity for which the news entity is created. * * @return \Drupal\Core\Access\AccessResult * The access result object. */ public function createNewsAccess(RdfInterface $rdf_entity) { // @todo Add also 'solution' when a workflow for news will be in place. if (!in_array($rdf_entity->bundle(), ['collection'])) { return AccessResult::forbidden(); } $user = $this->currentUser(); // Grant access if the user is a moderator. if (in_array('moderator', $user->getRoles())) { return AccessResult::allowed()->addCacheContexts(['user.roles']); } // Grant access depending on whether the user has permission to create a // custom page according to their OG role. return $this->ogAccess->userAccessGroupContentEntityOperation('create', $rdf_entity, $this->createNewsEntity($rdf_entity), $user); }
/** * Handles access to the distribution add form through solution pages. * * @param \Drupal\rdf_entity\RdfInterface $rdf_entity * The asset release RDF entity for which the distribution is created. * * @return \Drupal\Core\Access\AccessResult * The access result object. */ public function createAssetDistributionAccess(RdfInterface $rdf_entity) { // Create a new distribution entity in order to check permissions on it. $distribution = $this->createNewAssetDistribution($rdf_entity); return $this->ogAccess->userAccessEntity('create', $distribution); }
/** * Handles access to the asset_release add form through solution pages. * * @param \Drupal\rdf_entity\RdfInterface $rdf_entity * The RDF entity for which the custom page is created. * * @return \Drupal\Core\Access\AccessResult * The access result object. */ public function createAssetReleaseAccess(RdfInterface $rdf_entity) { return $this->ogAccess->userAccessEntity('create', $this->createNewAssetRelease($rdf_entity), $this->currentUser()); }