forked from CollaboraOnline/collabora-drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from donquixote/group-unpublished-permissions
Update group mapping with unpublished permissions
- Loading branch information
Showing
14 changed files
with
370 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Provide views data for collabora_online.module. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
modules/collabora_online_group/src/Plugin/Group/RelationHandler/CollaboraAccessControl.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Drupal\collabora_online_group\Plugin\Group\RelationHandler; | ||
|
||
use Drupal\Core\Access\AccessResultInterface; | ||
use Drupal\Core\Entity\EntityInterface; | ||
use Drupal\Core\Session\AccountInterface; | ||
use Drupal\group\Plugin\Group\RelationHandler\AccessControlInterface; | ||
use Drupal\group\Plugin\Group\RelationHandler\AccessControlTrait; | ||
use Drupal\group\Plugin\Group\RelationHandlerDefault\AccessControl; | ||
|
||
/** | ||
* Provides access control for collabora group. | ||
*/ | ||
class CollaboraAccessControl extends AccessControl { | ||
|
||
use AccessControlTrait; | ||
|
||
/** | ||
* Constructs a new CollaboraAccessControl. | ||
* | ||
* @param \Drupal\group\Plugin\Group\RelationHandler\AccessControlInterface $parent | ||
* The default access control. | ||
*/ | ||
public function __construct(AccessControlInterface $parent) { | ||
$this->parent = $parent; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function entityAccess(EntityInterface $entity, $operation, AccountInterface $account, $return_as_object = FALSE): AccessResultInterface|bool { | ||
// Add support for unpublished operation: preview in collabora. | ||
$check_published = $operation === 'preview in collabora' && $this->implementsPublishedInterface; | ||
|
||
if ($check_published && !$entity->isPublished()) { | ||
$operation .= ' unpublished'; | ||
} | ||
|
||
return $this->parent->entityAccess($entity, $operation, $account, $return_as_object); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.