Welcome to Geeklog, Anonymous Sunday, October 06 2024 @ 10:04 pm EDT

Geeklog Forums

Return the group a user must belongs to access an item


Status: offline

::Ben

Forum User
Full Member
Registered: 01/14/05
Posts: 1569
Location:la rochelle, France
Hello,

The scenario: We have an item witch can be only read by "my_private" group and we want to display the group the user must belongs to access this item

Text Formatted Code

// Ensure user has the rights to access this item
if (!SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'],
            $A['perm_group'], $A['perm_members'], $A['perm_anon']) == 3) {
    $display .= COM_startBlock ($LANG_LOGIN[1], '',
                                COM_getBlockTemplate ('_msg_block', 'header'));
    $login = new Template($_CONF['path_layout'] . 'submit');
    $login->set_file (array ('login'=>'submitloginrequired.thtml'));
    $login->set_var ( 'xhtml', XHTML );
        if ($A['perm_members'] == 2) {
        $login->set_var ('login_message', $LANG_LOGIN[2]);
        } else {
            $login->set_var ('login_message', $LANG_MY_PLUGIN_1['you_must_belong_to'] . ' ' . SEC_getGroupDropdown($A['group_id'], $access = ''));
            //You could also provide a link to your group registration page
        }
    $login->set_var ('site_url', $_CONF['site_url']);
    $login->set_var ('site_admin_url', $_CONF['site_admin_url']);
    $login->set_var ('layout_url', $_CONF['layout_url']);
    $login->set_var ('lang_login', $LANG_LOGIN[3]);
    $login->set_var ('lang_newuser', $LANG_LOGIN[4]);
    $login->parse ('output', 'login');
    $display .= $login->finish ($login->get_var('output'));
    $display .= COM_endBlock (COM_getBlockTemplate ('_msg_block', 'footer'));
} else {
        //display item
}
echo $display;
 

::Ben

Edit : Todo Check if the user is yet log in.
I'm available to customise your themes or plugins for your Geeklog CMS
 Quote

All times are EDT. The time is now 10:04 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content