vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   [RELEASE v2.x.x] Moderators Being able to control Accessmasks via MODCP (https://vborg.vbsupport.ru/showthread.php?t=27724)

Ashura 09-23-2001 03:52 AM

I modified merk's version so it should inherit now by using PPN's version for the inheritance. This also changes the ability for Supermods and Admins to do any usergroup without special access required. No guarntees etc yada yada =)

Only real problem I currently see is maybe more than 2 layer inheritence could be an issue.

Here is the updated portion(s):
PHP Code:

if ($action=="editaccess") {
  if(!isset(
$userid)) {
   
$username=$DB_site->query_first("SELECT userid FROM user WHERE username='$user_name'");
   
$userid=$username[userid];
   }
// New addition - Get permissions
  
$perms=getpermissions();
// End New 

-- Remove Merk's // Modify Code section
-- Replace beginning from where that section was to be inserted at until these lines
PHP Code:

  doformfooter("Save Changes");


This is what to replace with:
PHP Code:

// NEW modify
  
$accesslist=$DB_site->query("SELECT * FROM access WHERE userid='$userid'");
  while (
$access=$DB_site->fetch_array($accesslist)) {
    
$accessarray["$access[forumid]"] = $access;
  }

  
$modlist=$DB_site->query("SELECT * FROM moderator WHERE
userid='
$bbuserinfo[userid]'");
  while (
$mod=$DB_site->fetch_array($modlist)) {
    
$modarray["$mod[forumid]"] = $mod;
    
$i++;
  }

  
$forumlist=$DB_site->query("SELECT * from forum ORDER BY forum.title");
  while(
$forum=$DB_site->fetch_array($forumlist)) {
    if ( 
is_array($accessarray["$forum[forumid]"]) ) {
      if (
$accessarray["$forum[forumid]"]['accessmask']==0) {
        
$sel 0;
      } else if (
$accessarray["$forum[forumid]"]['accessmask']==1) {
        
$sel 1;
      } else {
        
$sel = -1;
      }
    } else {
      
$sel = -1;
    }
    if((
$modarray["$forum[forumid]"] || $modarray["$forum[forumid]"] ||
$perms['ismoderator'] && $forum['allowmodaccess']) ||
$perms['cancontrolpanel']) {
    echo 
"<tr class='secondalt'><td nowrap><P>$forum[title]</p></td><td width=100%><p>";
    echo 
"<input type=\"radio\" name=\"accessupdate[".$forum['forumid']."]\" value=\"1\"".iif($sel
==1,"checked","")."> Yes <input type=\"radio\" name=\"accessupdate[".$forum['forumid']."]\" value=
\"0\""
.iif($sel==0,"checked","")."> No <input type=\"radio\" name=\"accessupdate[".$forum['forumid
'
]."]\" value=\"-1\" ".iif($sel==-1,"checked","")."> Default <input type=\"hidden\" name=\"oldcach
e["
.$forum['forumid']."]\" value=\"$sel\">";
    echo 
"</p></td></tr>\n";
  }



DarkReaper 09-23-2001 03:55 AM

Uh...would you mind making those instructions a bit more clear? :)

DarkReaper 09-23-2001 04:03 AM

nm, I'm just tired.

Something's not working right with that.

Forum1
--forum2
----forum3

I have them as a moderator of forum1, but set it so they can't edit permissions for that. They can edit permissions for 2 and 3. It only lets them edit forum1's permissions though...

Ashura 09-23-2001 05:23 AM

Ok updated for what should be complete inheritance and some redundant code removed :)

These are the steps for editing the code pasted from user.php in Merk's instructions (step 5). So just replace step5 with this and inheritance should go through as many children as possible. With some slight changes this would also work for PPN's code too i believe since it suffers from the same problem of not inheriting past the first parent forum.

Find
PHP Code:

if ($action=="editaccess") { 

Add immediately below it
PHP Code:

  if(!isset($userid)) {
   
$username=$DB_site->query_first("SELECT userid FROM user WHERE username='$user_name'");
   
$userid=$username[userid];
   }
  
$user=$DB_site->query_first("SELECT username FROM user WHERE userid='$userid'");

  
$accesslist=$DB_site->query("SELECT * FROM access WHERE userid='$userid'");
  while (
$access=$DB_site->fetch_array($accesslist)) {
    
$accessarray["$access[forumid]"] = $access;
  }
  
$DB_site->free_result($accesslist); 

Find
PHP Code:

doformheader("user","updateaccess");
makehiddencode("userid","$userid"); 

Replace with
PHP Code:

doformheader("modaccessmasks","updateaccess");
makehiddencode("userid","$userid"); 

Edit the html section just after this to your liking if you wish for your moderators.

Find
PHP Code:

  while($forum=$DB_site->fetch_array($forumlist)) {
    echo 
"<tr class='secondalt'><td nowrap><P>$forum[title]</p></td><td width=100%><p>";
    if ( 
is_array($accessarray["$forum[forumid]"]) ) { 

Change too (This makes sure not all forums are displayed just ones they have access too).
PHP Code:

  while($forum=$DB_site->fetch_array($forumlist)) {
    if ( 
is_array($accessarray["$forum[forumid]"]) ) { 

Find
PHP Code:

    echo "<input type=\"radio\" name=\"accessupdate[".$forum['forumid']."]\" value=\"1\"".iif($sel
==1,"checked","")."> Yes <input type=\"radio\" name=\"accessupdate[".$forum['forumid']."]\" value=
\"0\""
.iif($sel==0,"checked","")."> No <input type=\"radio\" name=\"accessupdate[".$forum['forumid
'
]."]\" value=\"-1\" ".iif($sel==-1,"checked","")."> Default <input type=\"hidden\" name=\"oldcach
e["
.$forum['forumid']."]\" value=\"$sel\">";
    echo 
"</p></td></tr>\n";
  } 

Replace with
PHP Code:

    $perms=getpermissions($forumid,-1,-1,$forum[parentlist]);
    if(( 
ismoderator($forum[forumid],"canmoderateposts") ||
$perms['ismoderator'] && $forum['allowmodaccess']) ||
$perms['cancontrolpanel']) {
    echo 
"<tr class='secondalt'><td nowrap><P>$forum[title]</p></td><td width=100%><p>";
    echo 
"<input type=\"radio\" name=\"accessupdate[".$forum['forumid']."]\" value=\"1\"".iif($sel
==1,"checked","")."> Yes <input type=\"radio\" name=\"accessupdate[".$forum['forumid']."]\" value=
\"0\""
.iif($sel==0,"checked","")."> No <input type=\"radio\" name=\"accessupdate[".$forum['forumid
'
]."]\" value=\"-1\" ".iif($sel==-1,"checked","")."> Default <input type=\"hidden\" name=\"oldcach
e["
.$forum['forumid']."]\" value=\"$sel\">";
    echo 
"</p></td></tr>\n";
  }


Find
PHP Code:

echo "<p>User access updated successfully</p>";
$action="modify"

Replace with
PHP Code:

echo "<p>User access updated successfully</p>";
$action="select"

And your done!!

These directions hopefully are more clear

DarkReaper 09-23-2001 05:40 AM

Didn't work...when I ran it I got the blank page...something's not right! :(

Ashura 09-23-2001 05:44 AM

Oh your using PPN's version of the hack :) let me load that up and post the changes for it! =)

DarkReaper 09-23-2001 05:45 AM

No, I'm using merk's....

Ashura 09-23-2001 05:54 AM

Are you logged in as the Admin when accessing the mod panel?

If so you should get a listing of all forums when you click on Edit user (either blank or a specific users name entered in).

If your logged in as a normal Mod, did you set all the forums to allow Moderator access mask modification? This part of it is not inherited the "if they are a moderator" is inherited.

DarkReaper 09-23-2001 05:57 AM

It doesn't matter what I'm logged in as...by blank page I mean the script is broken. There's an error in it somewhere. Check your PM box.

merk 09-23-2001 06:01 AM

Thanks heaps Ashura!

DarkReaper 09-23-2001 06:10 AM

Ok, it almost works now. Inheritence works, but they can edit it on forums they're should be able to.

Forum1
--forum2
----forum3

I have them as a moderator of forum1, but set it so they can't edit permissions for that. They can edit permissions for 2 and 3. It lets them edit permissions for both 1, 2, and 3...

Ashura 09-23-2001 06:22 AM

Oops my bad =)

Change this
PHP Code:

 if(( ismoderator($forum[forumid],"canmoderateposts") ||
$perms['ismoderator'] && $forum['allowmodaccess']) ||
$perms['cancontrolpanel']) 

To
PHP Code:

 if(( (ismoderator($forum[forumid],"canmoderateposts") ||
$perms['ismoderator']) && $forum['allowmodaccess']) ||
$perms['cancontrolpanel']) { 

Needed a set of ()'s around the stuff before the && and that should work for you :)

DarkReaper 09-23-2001 06:25 AM

Works just fine now :)

Would it be possible to have a hierarchial list of all the forums they can modify instead of having them enter the forum id?

Ashura 09-23-2001 06:35 AM

Gimme a few also going to make sure it doesn't allow things we don't want it to do either. =)

merk 09-23-2001 06:43 AM

You mean, get a list of forums for the second form i made?

that gives a list of all the people who have access masks listed?

Tweezy stuff there! :)

Something along the lines of>
PHP Code:

  function getchildren($parentid=-1)
  { global 
$DB_site$bbuserinfo;
  
  
$childquery "SELECT title,forumid,styleid,parentid ";
  
$childquery .= "FROM forum ";
  
$childquery .= "WHERE parentid=$parentid ";
  
$childquery .= "ORDER BY displayorder";
  
$childtemp=$DB_site->query($childquery);
    print(
"<ul>");
    while (
$children=$DB_site->fetch_array($childtemp)) {
        
        
$accesscheckquery="SELECT * FROM moderator WHERE userid=$bbuserinfo[userid] AND forumid=$children[forumid]";
          
$accesstemp=$DB_site->query($accesscheckquery);
          while(
$accesscheck=$DB_site->fetch_array($accesstemp)) {
              
$modcheck[$accesscheck[forumid]]=$accesscheck;
          }
        if(
$modcheck[$children[forumid]][caneditstyles]>=1){ $colour="red"; } else { $colour="blue"; }
        
$canedit=$modcheck[$children[forumid]][caneditstyles];
        print(
"<li><font style=\"color:$colour\">$children[forumid]-$children[title]$children[parentid]--$canedit</font></li>");

        
getchildren($children[forumid]);
    }
      print(
"</ul>");
  } 

I wrote this, to get a list, and if they have caneditstyles=1, show it in red, else blue.

Just adapt the 'while' loop to check to see if they have moderator and the forum is caneditaccess=1

Shouldnt be too hard :)

Ashura 09-23-2001 08:39 AM

Update
- added some more checks just to make sure they have access (just like other mod panel functions do)
- added a check in edit so ONLY admin's can edit access of Super Mods and Admin's (just to be paranoid)
- Added 'forums' list if you hit list forums without a Forum ID

May need some more cleaning up but should work fine

Here is my current version of this file (Pretty sure we can post these as attachments).

Scott MacVicar 09-23-2001 08:40 AM

i released a working version under a different thread, and i sorted the inheritance to be more than one level.

http://vbulletin.com/forum/showthrea...threadid=28654

i also knew what i had done wrong in this version but its too much to fix XD

maverick1236 09-30-2001 04:14 AM

Parse error: parse error in c:\program files\nusphere\apache\htdocs\upload\mod\user.php on line 71

no idea
everything looks ok

??

mcncyo 10-08-2001 08:35 AM

When i try to update a user permssion i get a blank screen and it doesn't update. Does anyone know why this is happenning?

Ashura 10-08-2001 09:25 AM

For which version? Merk's or PPN's :)

mcncyo 10-08-2001 09:28 AM

Merks

merk 10-08-2001 09:49 AM

Somehow mine isnt working properly, even after my tests, i found no errors.

If you can wait about a week, i will have version2 out, which will hopefully work alot better(and the instructions will be alot better)

Ashura 10-08-2001 09:49 AM

Is this using my additions to the hack?

If so, is the user an Admin or Super Mod ( usergroupid 5 or 6)?

Is the account your trying to edit with a Moderator of the forum or any of its parents, Admin, or Super Mod?

Need a bit more to go on here.

Ashura 10-08-2001 09:55 AM

This can happen in forums where you have not enabled the feature for the Forum in the Admin CP. The ability to edit it is not derived from parent forums.

I get a blank page when listing forums and selecting one that I have not explicitly given Mods access to edit.

Zeoran 10-10-2001 06:41 PM

I have a request simliar to this. I need my moderators to be able to change the users profile options (namely user title and group). The default is that they can view it, but they can't change it. Are there any hacks out there that would allow them to edit the information too? I could really use this so I can stop having them have access to the main admin cp panel.

TIA

Scott MacVicar 10-10-2001 09:32 PM

[QUOTE]Originally posted by PPN
i released a working version under a different thread, and i sorted the inheritance to be more than one level.

http://vbulletin.com/forum/showthrea...threadid=28654

i also knew what i had done wrong in this version but its too much to fix XD

merk 10-10-2001 10:52 PM

Quote:

Originally posted by Zeoran
I have a request simliar to this. I need my moderators to be able to change the users profile options (namely user title and group). The default is that they can view it, but they can't change it. Are there any hacks out there that would allow them to edit the information too? I could really use this so I can stop having them have access to the main admin cp panel.

TIA

Try the requests forum.

Zeoran 10-11-2001 09:23 PM

I did... no luck so far. :(

Quote:

Originally posted by merk


Try the requests forum.


dieKetzer 05-07-2002 09:20 AM

Please I hope this works for 2.2.5


All times are GMT. The time now is 04:18 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02071 seconds
  • Memory Usage 1,883KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (16)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (29)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete