Add Acl permission with guest role in SimplePage unpublished

Hi,
Im using SiplePage plugin to create some page. I’d like to add the persmission showUnpublished to role guest, or to any limited access role but this deosn’t work. (omeka 2.5.1 with GuestUser Plugin).
The goal is to have some private pages accessible only when user are logged in…
I also try to add a role directly in Acl.php file and the permision in SimplePage plugin but with no effect (error 404 invalid url)…
I thought playing with published/unpublished page would be easy but I’m still unable to put te right permission…
Thanks for your help.

Sassy

In the file SimplePagesPlugin.php, add an acl rule (or use a specific plugin for a better maintenance) at the last of the method hookDefineAcl():

        $acl->allow('guest', 'SimplePages_Page', 'show-unpublished');

Thanks for the reply .
That exactly what I had try : I install the plugin GuestUser, I create a user with the role “guest”. In the plugin SimplePage,I added this line, at the end of the methode hookDefineAcl() but I had this error " exception ‘Zend_Acl_Role_Registry_Exception’ with message ‘Role ‘guest’ not found’ in (…)/omeka/application/libraries/Zend/Acl/Role/Registry.php:132
Stack trace:(…)omeka/application/libraries/Zend/Acl.php(627): Zend_Acl_Role_Registry->get(‘guest’)

Is it something else to do ? It is as if omeka doesn’t recognize the new guest role of GuestUser plugin.

That’s probably exactly what’s happening. SimplePages is getting loaded before GuestUser, so the ACL doesn’t know about the new role.

I think a workaround is to add the following to SimplePages plugin.ini file:

required_plugins="GuestUser"

Pretty sure that’ll force Omeka to load GuestUser before SimplePages, but haven’t tried it myself yet.

Thank you very much for your answer.
I’d like to include the GuestUser plugin and you gave me a nice way to do so !
I haven’t the same error any more But it’s not working either …
What I try is : put a link in a simple page towards an unpublished page.
With super user the link is ok
With a guest user I have a 404 with the log as follow

Any idea to read unpublished page with a guest user ?
Thanks again

omeka error :
exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Invalid controller specified (cahier-pdagogique-2)’ in (…)/omeka/application/libraries/Zend/Controller/Dispatcher/Standard.php:248
Stack trace:
#0 (…)/omeka/application/libraries/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 (…)/omeka/application/libraries/Zend/Application/Bootstrap/Bootstrap.php(105): Zend_Controller_Front->dispatch()
#2 (…)/omeka/application/libraries/Zend/Application.php(384): Zend_Application_Bootstrap_Bootstrap->run()
#3 (…)/omeka/application/libraries/Omeka/Application.php(77): Zend_Application->run()
#4 (…)/omeka/index.php(23): Omeka_Application->run()
#5 {main…

Try to create another plugin with the two others as requirements and with just the hook hookDefineAcl().

Thanks !

I have never create a plugin so far …
Is there any other solution ??? (more simple ?)

If I try to create one, can I just produce a plugin.ini whith the requirements and a Plugin.php with the hook you precise ? without any other files ?

OK, I did it , code my firste plugin … but same result.
I tested the requirement of both plugin : they have to be activated so I can activate my new plugin.
here the code of the plugin :

/**

  • Guest View Unpublished SimplePages plugin.
    /
    class GuestViewUnpubPlugin extends Omeka_Plugin_AbstractPlugin
    {
    /
    *

    • @var array Hooks for the plugin.
      */
      protected $_hooks = array(‘define_acl’);

    /**

    • Define the ACL.

    • @param Omeka_Acl
      */
      public function hookDefineAcl($args)
      {
      $acl = $args[‘acl’];

      $acl->allow(‘guest’, ‘SimplePages_Page’, ‘show-unpublished’);
      }
      }

What else can I do to be able to have access to the url of my unpublished pages ?
Thanks in advance ,
Sassy

A simpler approach might be to move where you add Daniel’s code to SimplePages. Instead of putting it at then end of the hookDefineAcl() method, put it right above this line:

$acl->deny(null, 'SimplePages_Page', 'show-unpublished');

Chances are the ACL gets to the deny statement and follows that rule to deny access, without ever getting to the added allow rule. So, putting the allow above the deny might do the trick. (Zend ACL is often a little weird to work out).

I think I have tried it already but I tried it again , insert the line allow before the line deny… same result …

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.