Check if a user has write privileges

Permalink
As an admin, I would like to lock down all areas and blocks, except for a few. I think I understand how to do that.

My question is this: Inside of a custom block, How can I check to see if a user has 'edit' permissions for that block?

SkyBlueSofa
 
andrew replied on at Permalink Reply
andrew
In general, there is one way to get "permissions" for something in C5, whether it's a block, page, area, etc...

that's passing the object in question through the Permissions object, and operating on the object you get back.

In a block's template, you'd go:

<?php
$bp = new Permissions($this->block);
if ($bp->canWrite()) {
...
}
?>


$this->block automatically exists in the view template of a block. Try that and hopefully it should work.
andrewsturm replied on at Permalink Reply
How would you reapply permissions to that area if they need to be changed?

$aa = Area::get($newPage, 'Main');
$pp = new Permissions($aa);
$cap = array(1,2,3);
$pp->addBlockTypes = $cap;
//This won't work!
//$ps = $this->loadPermissionSet($pp);
//how do I change the permissions of an area??


I'm creating a new page, setting the user as owner, and would like to set the permissions for the areas in it.

I'm also looking for a way to limit the block types the user can add.

lol, I just noticed this post was from 2008! Hope someone sees this...