Skip to content

Instantly share code, notes, and snippets.

@hissy
Created April 26, 2015 23:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hissy/7c625b5997783ef40705 to your computer and use it in GitHub Desktop.
Save hissy/7c625b5997783ef40705 to your computer and use it in GitHub Desktop.
#concrete5 Check if the block is private or not
<?php
// for concrete5.6
// libraries/block_view.php
defined('C5_EXECUTE') or die("Access Denied.");
class BlockView extends Concrete5_Library_BlockView {
public function render($obj, $view = 'view', $args = array()) {
$isPrivate = true;
$pk = PermissionKey::getByHandle('view_block');
$pk->setPermissionObject($obj);
$pa = $pk->getPermissionAccessObject();
if (is_object($pa)) {
$pe = GroupPermissionAccessEntity::getOrCreate(Group::getByID(GUEST_GROUP_ID));
$ae = array($pe);
if ($pa->validateAccessEntities($ae)) {
$isPrivate = false;
}
}
if ($isPrivate) {
echo '<div class="private">';
}
parent::render($obj, $view, $args);
if ($isPrivate) {
echo '</div>';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment