Go Back   Pligg CMS Forum > Pligg Help > General Help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-04-2007, 09:26 PM
New Pligger
 
Join Date: Aug 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] rights/access according to user level?

there are several user levels that get created in the db with a pligg install... any regular user that registers is considered to have a user level of 'normal' which gives the user rights to submit, vote, comment, etc..

if i wanted to create a site where i want to have only special users be able to do functions like submission how would i turn this off for all levels except that level and admin/god levels?

what files/database tables/fields are a good place to look.. line numbers would be really helpful... thanks guy :)
Reply With Quote
  #2 (permalink)  
Old 01-05-2007, 04:04 PM
New Pligger
 
Join Date: Aug 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
any ideas? basically i want to only restrict the submission process to a certain user level. thanks :)
Reply With Quote
  #3 (permalink)  
Old 01-05-2007, 04:56 PM
lokapujya's Avatar
New Pligger
 
Join Date: Dec 2006
Location: Boston
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to lokapujya
A quick way would be to try removing the "Submit a New Story" button for all users that are not God/Admin or the special level. If that is the only way to get to Submit page, it should work. You have to find the code that creates the side bar.
Take a look at
\PLIGG\templates\digitalnature\sidebar_modules\mis c_links_1.tpl

Try putting an if statement around the line that creates the "submit a new story". Something like:
if($current_user->user_level == "admin" or $current_user->user_level == "god"){
}

If you get that working, then you can make it more robust so that it is configurable per group -- but, that is more difficult.
Reply With Quote
  #4 (permalink)  
Old 01-09-2007, 10:19 PM
New Pligger
 
Join Date: Aug 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
thanks,

What I've found is that its better to just restrict access to the page for any user of a non admins / [any predefined user level] users

you can eliminate the link in the tpl file by doing a check but the submit.php page can still be accessed....


I have found some code in admin_index.php that seems to do the check im trying to perform:

PHP Code:
force_authentication();

    
$amIgod 0;
    
$amIgod $amIgod checklevel('god');
    
$main_smarty->assign('amIgod'$amIgod);

    
$canIhaveAccess 0;
    
$canIhaveAccess $canIhaveAccess checklevel('god');
    
$canIhaveAccess $canIhaveAccess checklevel('admin');
    
    
$main_smarty->assign('isAdmin'$canIhaveAccess); 


This code seems to decide whether the given user is of level admin or god

How and where would I add this code in the submit.php file to do the same check and allow only admins/gods/ my custom user level users to access submit.php

thanks! :)
Reply With Quote
  #5 (permalink)  
Old 07-26-2007, 06:19 AM
liotier's Avatar
Casual Pligger
Pligg Version: Slightly modified 9.8.2
Pligg Template: Slightly modified Yget from 9.8.2
 
Join Date: Jul 2007
Location: Paris La Défense, France
Posts: 71
Thanks: 7
Thanked 11 Times in 8 Posts
Stevux was on the right track. I followed his lead and found a nice way to restrict submission to admin and god users.

In submit.php around line 56 you'll find this important switch statement :

PHP Code:
switch ($phase) {
   case 
0:
      
do_submit0();
      break;
   case 
1:
      
do_submit1();
      break;
   case 
2:
      
do_submit2();
      break;
   case 
3:
      
do_submit3();
      break;

Restricting access to phase zero seemed to me to be the best way so I added the restriction code to the above statement. It works just as advertised and the resulting code is as follows :

PHP Code:
switch ($phase) {
   case 
0:
      
$canIhaveAccess 0;
      
$canIhaveAccess $canIhaveAccess checklevel('god');
      
$canIhaveAccess $canIhaveAccess checklevel('admin');
      if(
$canIhaveAccess == 1)
      {
         
do_submit0();
      }
      else
      {
         echo 
'Only admins and god can post. I you know who to ask you may request admin status so that you can post';
      }
      break;
   case 
1:
      
do_submit1();
      break;
   case 
2:
      
do_submit2();
      break;
   case 
3:
      
do_submit3();
      break;

I am not sure that the core Pligg developers intended this previously clean switch statement to be hacked like that, but it works for me.

A further step would be to make this restriction code conditional and to make the condition a user-configurable parameter in /admin_config.php so that god can choose at which user level submissions are allowed. I am sure that many site operators would appreciate this feature.
__________________
Jean-Marc Liotier
Reply With Quote
The Following User Says Thank You to liotier For This Useful Post:
Reply

Thread Tools
Display Modes
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 Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit Antispam Addon v 0.1 AnAlienHolakres3 Pligg Modules 24 11-23-2008 09:49 AM
[SOLVED] Warning (User Management) Partyman General Help 2 09-03-2008 02:14 AM
god account now cannot change User Level Rayden General Help 16 10-29-2007 12:40 PM
access right of admin level user OnlyBlue General Help 4 08-12-2007 08:53 PM
Need help resetting user level and email WatchDog General Help 4 08-22-2006 01:22 PM


Search Engine Friendly URLs by vBSEO 3.2.0