Plugin GuestUser

116 views
Skip to first unread message

PBC

unread,
Oct 10, 2014, 4:15:23 AM10/10/14
to omek...@googlegroups.com
I am in Omeka 2.1.4. I would like to use GuestUser to let 'guest' users access to metadata only, but not to archives (images). I understand this is possible by developing a plugin based on GuestUser plugin. Any advise please? 

For instance, in Berlin/items/browse.php, how can I ask for 'guest users' and differentiate users to show images or not? What is the best approach to ask for GuestUser to determine if some data is shown or not?. Is there a better solution to have some control on level of access to digital objects?. Many thanks.  

Anurag Spatzenegger

unread,
Oct 10, 2014, 7:37:09 AM10/10/14
to omek...@googlegroups.com
Hello,

You should be able to achieve your functionality without creating your own plugin, by simply relying on Omeka's native ACL in conjunction with the GuestUser plugin.

If I understand you correctly, you are trying to do the following:
  • Visitor (not logged in) : no access to metadata / no images
  • Guest user (logged in) : access to metadata / no images
  • Higher User Role : access to metadata + images

To test if any user is logged in, you can use the following example in your view (items/browse.php) :

<?php  $user = current_user();
    if(!$user) : ?>
        <p>You need to be registered to view the content.</p>   
    <?php else : ?>
       
   
    <p>Visible content for all logged in users</p>   
    <?php endif; ?>


To further restrict the output of content, you can utilize the is_allowed() function. For example, you can expand the above code to something like :

<?php  $user = current_user();
    if(!$user) : ?>
        <p>You need to be registered to view the content.</p>   
    <?php else : ?>       
        <?php if(is_allowed('Items', 'view')) : ?>
            <p>Visible content for elevated user roles (Researcher, Contributor, Admin, Super)</p>       
        <?php endif ;?>
        <p>Visible content for all logged in users</p>
<?php endif; ?>


You can find a brief description of the is_allowed function here - http://omeka.readthedocs.org/en/latest/Reference/libraries/globals/is_allowed.html?highlight=is_allowed#is_allowed. Browsing existing plugins, as well as the Omeka core can give you plenty of examples of how this function is being used.

All the best,

Anurag


On 10/10/14, 4:15 AM, PBC wrote:
I am in Omeka 2.1.4. I would like to use GuestUser to let 'guest' users access to metadata only, but not to archives (images). I understand this is possible by developing a plugin based on GuestUser plugin. Any advise please? 

For instance, in Berlin/items/browse.php, how can I ask for 'guest users' and differentiate users to show images or not? What is the best approach to ask for GuestUser to determine if some data is shown or not?. Is there a better solution to have some control on level of access to digital objects?. Many thanks.  
--
You received this message because you are subscribed to the Google Groups "Omeka Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omeka-dev+...@googlegroups.com.
To post to this group, send email to omek...@googlegroups.com.
Visit this group at http://groups.google.com/group/omeka-dev.
For more options, visit https://groups.google.com/d/optout.

PBC

unread,
Oct 12, 2014, 12:44:08 PM10/12/14
to omek...@googlegroups.com
Hi Anurag,

Many thanks for your quick support. Exactly what we needed. One more question, is it possible to ask directly the connected user role (i.e. Guest, Researcher, Contributor, Admin, Super)? Best regards.

Anurag Spatzenegger

unread,
Oct 15, 2014, 11:35:34 AM10/15/14
to omek...@googlegroups.com
Sure. If you assume that $user = current_user(); , then $user->role gives your the current user role. You can use this to adjust your view accordingly. You can see Omeka's default user role permission set at http://omeka.org/codex/User_Roles

All the best,

Anurag

Jeronimo Reguera

unread,
Oct 20, 2014, 7:57:12 AM10/20/14
to omek...@googlegroups.com
Many thanks, Anurag. Is it possible to define a user role for access only to one collection not all the repository?

--
You received this message because you are subscribed to a topic in the Google Groups "Omeka Dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/omeka-dev/L9upcLGQTsI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to omeka-dev+...@googlegroups.com.

Anurag Spatzenegger

unread,
Oct 20, 2014, 1:10:51 PM10/20/14
to omek...@googlegroups.com
If by define user role you mean create a completely new one, than that might be a bit tricky, as they are built into the Omeka core.

But if instead you want to display a specific collection to users of particular user role, then you would have to modify all relevant view files and implement your tests. The minimum number of files to change are:
  • collections/browse.php
  • collections/show.php
  • items/browse.php
  • items/show.php
There may be more, such as for search results, featured items, etc.

Keep in mind, that just by making a collection or an item private you already exclude visitors, guest users, as well as specific users from accessing the item / collection - see description of user role permissions at the Omeka website. Some user roles only have the permission to view items / collections they created when the status is set to private.

All the best,

Anurag

Amanda Shuman

unread,
Mar 28, 2017, 12:13:33 PM3/28/17
to Omeka Dev
Hi - this is really helpful as I think it's similar to what we're trying to do now. My only question is -- did this work for you and would you do the same thing in the current version of Omeka? While files does one have to change - and would this be done in the plug-in file itself now or just within the theme/items/show.php? Basically what we want is to restrict access to viewing items (anywhere) only to those logged in to the site, i.e. they will only be able to see the homepage until logged in. 

Thanks!
Amanda
Reply all
Reply to author
Forward
0 new messages