Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2005, 01:16 PM
gabi gabi is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
Creating different user rights....

Sorry to bother you guys but im only new at coding.

I am trying to change the codes to meet my needs.

My problem is that I am wanting different menus for different user rights.

For instance:

boss=1
admin=2
normal_user=3

Therefore

1 will open boss_admin.php
2 will open admin_menu.php
3 will open normal_user_menu.php

my problem is i dont know how eactly to implement this because in the sentry.php the level is set to anyone less than 10 will open either welcome.php or error.php

and in the log in its calling it again i.e

if ($HTTP_POST_VARS['user'] != ''){

$sentry->checkLogin($HTTP_POST_VARS['user'],$HTTP_POST_VARS['pass'],10,'welcome.php','error.php');

}

do i change this to something like

if ($HTTP_POST_VARS['user'] != '' & $group = 1){

$sentry->checkLogin($HTTP_POST_VARS['user'],$HTTP_POST_VARS['pass'],1,'boss_admin.php','error.php');

}

else if ($HTTP_POST_VARS['user'] != '' & $group = 2){

$sentry->checkLogin($HTTP_POST_VARS['user'],$HTTP_POST_VARS['pass'],2,'admin_menu.php','error.php');

}

etc........

do you see what i am trying to do, I am so lost

Many thanks

( my dissertation is proving to be impossible and this is only the start of it.... )
Reply With Quote
  #2 (permalink)  
Old 03-29-2005, 04:30 PM
petez petez is offline
Registered User
 
Join Date: Sep 2004
Posts: 35
Hey Gabi,
Don't panic

Hopefully I understand the question, please tell me if I've got anything wrong.

Firstly, you need to modify the Sentry to check if someone's of a particular group, and that group only. So, go into Sentry.php, and find the function called checkLogin . You need the line containing the SQL (database) query, it's line 41 and starts "$getUser = $loginConnector->query...". On that line, change:

PHP Code:
AND thegroup <= ".$group.
to

PHP Code:
AND thegroup = ".$group.

Then you need to give it a range of menu pages to go to. Here's something you can try. This function would go into the Sentry.php file:

PHP Code:
function selectMenu($group){

     
// Select menu page depending on group
     
switch ($group){
          case
1:
               
$menuPage = 'boss_admin.php';
               break;
          case
2:
               
$menuPage = 'admin.php';
               break;
          default:
               
$menuPage = 'normal_user_menu.php';
               break;
     }

     return
$menuPage;
}
A brief explanation of what this does - the function is given the user's group number, and then chooses which page to redirect them to.

Then you'd then just need to link this function in to the existing checkLogin() function.

Find the code that says:

PHP Code:
if ($goodRedirect) {
     
header("Location: ".$goodRedirect."?".strip_tags(session_id())) ;
}
And replace with

PHP Code:
$redirect = selectMenu($this->userdata['thegroup']);
header("Location: ".$redirect."?".strip_tags(session_id())) ;
If anything there is confusing, let us know

Peter.
Reply With Quote
  #3 (permalink)  
Old 03-29-2005, 05:38 PM
gabi gabi is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
I LOVE YOU !!!!!!!!!!

That is exactly what I am after I think ............

Lets see if I can do it.........

5 days programming, lets see

Oh your a star....... LEGEND

TRILLION THANKSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS SSSSS
Reply With Quote
  #4 (permalink)  
Old 03-29-2005, 05:44 PM
gabi gabi is offline
Registered User
 
Join Date: Mar 2005
Posts: 11
Post

I see what you have done you have used a case statement, to see what the users group is, from when the user logs in i.e ADMIN = 1.... and you have taken the less than so its actually = to the exact group your looking for.

then not sure about the $redirect ( is $redirect a new variable coz it has not been delared anywhere ) code bit, thats a bit far fetched for me, its selecting the group from the menu, but how does it go to the error.php

Im sorry about this .......

On the log in page this is the code which you provided us with ...

PHP Code:
if ($HTTP_POST_VARS['user'] != ''){

$sentry->checkLogin($HTTP_POST_VARS['user'],$HTTP_POST_VARS['pass'],10,'welcome.php','construction.htm');

}
Do i need to change anything here. Because its still leading to the $goodRedirect and $badRedirect ......

Also the function with the menu that you suggested, do i place that below the checklogin function, reason being that variables have not been stated yet ? Im a bit confused sorry .... ( finally placed it within the checkLogin() function, is that correct, dont look right a function within a function ? )

Last edited by gabi; 03-29-2005 at 07:14 PM.
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 05:38 PM.





Acceptable Use Policy

WebMediaBrands

internet.comMediabistrojusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Shopping | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0