Access level from current page

I'm developing a plugin that shows a facebook share button in content pages.

I just need to show the share button only when the current content has public access level. I think that isn't useful to share content that hasn't public access level.

Can I know if the current page has public access level? How?

  • if the current page is an object of some kind such blog,poll,page etc. you can call

    echo "<b>Access:</b>" . $vars['entity']->access;

    which will show you the access of the entity/object you are looking at. So you could do the following:

    if(($vars['entity']->access == ACCESS_PUBLIC) || ($vars['entity']->access == 0)){

    //show stuff

    }

    that should work for you.

  • @T: access == 0 is private.. r u @ typo ? ;-)

  • oh yeah, my bad. should be a 2 not a 0.

     

     

  • Thank you for your responses, but this doesn't work, so I will explain my problem more.

    I'm using elgg 1.8.0.1 and I'm extending sidebar view with:

    elgg_extend_view('page/elements/sidebar', 'myplugin/extend', 500);

    And I call in my view:

    print_r(array_keys($vars));

    So I always get this when some content is rendered:

    Array ( [0] => content [1] => sidebar [2] => user [3] => config [4] => url )

    But $vars['content'] is html code and no $vars['entity'] is avalaible.

    ¿Maybe can we get the entity through a hook?

  • I noticed a similar "fail" about the always present sidebar RSS feed button. For example, if I link the RSS feed to blog posts of foo user and these posts doesn't have public access level, elgg shows an access error when triying to use this link in a RSS feed reader.

    Is not useless trying to link a RSS feed that doesn't have public content?