Commit 51cad51c authored by Nikolay Lobachev's avatar Nikolay Lobachev
Browse files

Issue #3325941: Remove access hook, we will use Access handler from teh group instead.

parent 3a336765
Loading
Loading
Loading
Loading
+0 −66
Original line number Diff line number Diff line
@@ -41,69 +41,3 @@ function group_term_entity_operation(EntityInterface $entity) {
  }
  return $operations;
}

///**
// * Implements hook_ENTITY_TYPE_access().
// *
// * When trying to view, update or delete a term it suffices to have the right to
// * do so in only one group the term belongs to. If you wish to prevent any such
// * action on your own terms, implement hook_taxonomy_term_access() in your
// * module.
// */
//function group_term_taxonomy_term_access(EntityInterface $term, $op, AccountInterface $account) {
//  // We do not care about create access as we have our own wizard for that. Any
//  // operation aside from 'view', 'update' and 'delete' is also unsupported.
//  if (!in_array($op, ['view', 'update', 'delete'])) {
//    return AccessResult::neutral();
//  }
//
//  $plugin_id = 'group_term:' . $term->bundle();
//
//  // Only act if there are group content types for this vocabulary.
//  $group_content_types = GroupRelationshipType::loadByContentPluginId($plugin_id);
//  if (empty($group_content_types)) {
//    return AccessResult::neutral();
//  }
//
//  // Load all the group content for this term.
//  $group_contents = \Drupal::entityTypeManager()
//    ->getStorage('group_content')
//    ->loadByProperties([
//      'type' => array_keys($group_content_types),
//      'entity_id' => $term->id(),
//    ]);
//
//  // If the term does not belong to any group, we have nothing to say.
//  if (empty($group_contents)) {
//    return AccessResult::neutral();
//  }
//
//  // From this point on you need group to allow you to perform the operation.
//  foreach ($group_contents as $group_content) {
//    $group = $group_content->getGroup();
//    switch ($op) {
//      case 'view':
//        if ($group->hasPermission("view $plugin_id entity", $account)) {
//          return AccessResult::allowed();
//        }
//        break;
//
//      case 'update':
//        if ($group->hasPermission("update any $plugin_id entity", $account)) {
//          return AccessResult::allowed();
//        }
//        break;
//
//      case 'delete':
//        if ($group->hasPermission("delete any $plugin_id entity", $account)) {
//          return AccessResult::allowed();
//        }
//        break;
//    }
//  }
//
//  // Instead of outright forbidding access when no group granted it, we return
//  // a neutral access result to play nice with other modules. If the end result
//  // is still neutral, Drupal will deny access anyway.
//  return AccessResult::neutral();
//}