1
tdickson
group permissions
  • 2005/12/19 22:07

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


I am working on a local intrantet and what I would like is to write a page in PHP using if statements that show certain pages depending on what group the user is logged onto.

Let say we have group 1, 2, and 3

I want one link on the main menu that links to a PHP based page that says if group1 include group1.html, if group2 include group2.html, and if group3 include group3.html

the html pages will be changed weekly so I would like to use the include commands.

Is there a module that does this kind of work? or more importantly... is there a group call I can use? such as the <{if $block.admin}>?

thanks for any help you could shed

2
Dave_L
Re: group permissions
  • 2005/12/19 22:47

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7



3
tdickson
Re: group permissions
  • 2005/12/19 23:38

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


Thanks dave,
I'm still confused on how to identify the group.

I endup with the same results as user 123456
1 User is not in the group


What is the correct syntax to use here?
if ($in_group) {
echo "User is in the group\n";
} else {
echo "User is not in the group\n";
}

if I am calling up group 1 how would it look?
or group2?

4
Dave_L
Re: group permissions
  • 2005/12/20 16:33

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I'm not clear on what you want the code to do.

5
tdickson
Re: group permissions
  • 2005/12/22 4:34

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


well that is the code you gave me.


what I want to do is something along these lines:

Quote:

if ($GROUPID OR NAME) { include XOOPS_ROOT_PATH.'FILE TO INCLUDE'; }

elseif ($ANOTHER GROUPID) { include this file...; }

etc... etc..


else { include default file; }





I ended up getting it to work in a round about way.
I downloaded a module for dummy purposes... in this case CJ-content. This made a link in my menu. I then added blocks to display on that module according to the group they are in. IE group 1 views block 1, group 2 views block 2, and so on. And I left the content of CJ-content blank so that all that shows up when you click on that link is the block I designated for that group. It works really good, it just is a really weird way of doing it. If I could do it with something like above it would be a lot better.

6
jegelstaff
Re: group permissions

Quote:

tdickson wrote:

What is the correct syntax to use here?
if ($in_group) {
echo "User is in the group\n";
} else {
echo "User is not in the group\n";
}

if I am calling up group 1 how would it look?
for group2?


Well, here's Dave's code from that other post:

// needed if inside a function
global $xoopsUser$xoopsModule;

// true if current user has admin-right for current module
$is_admin is_object($xoopsUser) and is_object($xoopsModule) and $xoopsUser->isAdmin($xoopsModule->getVar('mid'));

// array of IDs of groups to which current user belongs
$member_handler =& xoops_gethandler('member');
$group_ids =& is_object($xoopsUser) ? $member_handler->getGroupsByUser($xoopsUser->getVar('uid')) : array();

// true if current user is in group ID #17
$in_group in_array(17$group_ids);


So therefore, for group 2, the code you'd need plus your conditional would be something like this:

// array of IDs of groups to which current user belongs
$member_handler =& xoops_gethandler('member');
$group_ids =& is_object($xoopsUser) ? $member_handler->getGroupsByUser($xoopsUser->getVar('uid')) : array();

if (
in_array(2$group_ids)) {
   echo 
"User is in group 2n";
} else {
   echo 
"User is not in group 2n";
}


Does that help? If you're not new to PHP, then that probably doesn't help and the problem/question is deeper than it appears.

--Julian
Technical Architect - Freeform Solutions
Formulize - custom registration forms, ad hoc forms and reports

7
tdickson
Re: group permissions
  • 2005/12/22 18:45

  • tdickson

  • Just popping in

  • Posts: 26

  • Since: 2005/9/26


actually it does make more sense... thanks
I'll try it out and see if I can get it working
(it just took a little perspective twisting )

8
johntrot
Re: group permissions
  • 2006/2/20 0:25

  • johntrot

  • Just popping in

  • Posts: 56

  • Since: 2005/4/7 2


I simply want to allow different groups (sales, homeoffice, northoffice, exec, delivery, etc.) access to different files in different directories based on their login group names. The following is used for admin in the user menu, but where do I get the name or number of the 14 plus custom groups (still in design) I have designed so that I can place them in the main or user menu. By doing it this way the files are visiable only to the group they belong to and no one else knows they exist.

<{if $block.admin}>
<{$block.lang_adminmenu}>
Mailing List Admin
View Driver Bonus
<{/if}>

These files come from seperate subdirectories I have installed in the root directory of the site and are not modules as such. They all use different MySQL db's or tables, but I don't have the expertise to code them into different modules.
john b

Login

Who's Online

234 user(s) are online (165 user(s) are browsing Support Forums)


Members: 0


Guests: 234


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits