views:

70

answers:

1

First sorry about the woffle as I'm not sure how best to describe this. Basically I am not sure how I can get param in the bootstrap before the controller is loaded, but here is the long winded version...

I have got an acl class storing all my default resources in. All my page/post content is a database and I want the admin the ability to choose who which role the page would become available.

I know it is possible just to loop through the database table and add them all in at once, but I am concerned that this is a drain on resources. I have it working whereby my access check plugin can call a dynamic permission function, but I need to get the parameter of the current page ID and it's permission to set it before the controller is loaded.

Does that make sense or am I worry over nothing and I should just get the resources of all the pages at once?

thanks in advance for reading my garble!!

+1  A: 

I've actually managed to find out what I need by actually reading the zend manual! DOH!

I simply needed to use to the $request->getParams() which would allow me to get post id from the url

Then I could set the permission with the following method

Below goes in the access check pluging

$params =  $request->getParams();    
$this->_acl->setDynamicPermissions($params['post_id']);

And then this in the Acl class

 public function setDynamicPermissions($id) {

    $id             = (int)$id;
    $page_id        =  "page-" . $id;

    $post           = new Model_DbTable_Post();
    $restriction    = $post->getPostRestriction($id);


    $this->add(new Zend_Acl_Resource($page_id));
    $this->allow($restriction, $page_id);

}
Timmeh