View Single Post
  #5 (permalink)  
Old 07-26-2007, 06:19 AM
liotier's Avatar
liotier liotier is offline
Casual Pligger
 
Join Date: Jul 2007
Location: Paris La Défense, France
Posts: 70
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.
Reply With Quote