home *** CD-ROM | disk | FTP | other *** search
/ PC Basics 53 / PC Basics Issue 53.iso / Software / Internet / Invboard.exe / PC Basics 53 / Invboard / upload / sources / Admin / ad_moderator.php < prev    next >
Encoding:
PHP Script  |  2002-06-12  |  21.8 KB  |  766 lines

  1. <?php
  2.  
  3. /*
  4. +--------------------------------------------------------------------------
  5. |   IBFORUMS v1
  6. |   ========================================
  7. |   by Matthew Mecham and David Baxter
  8. |   (c) 2001,2002 IBForums
  9. |   http://www.ibforums.com
  10. |   ========================================
  11. |   Web: http://www.ibforums.com
  12. |   Email: phpboards@ibforums.com
  13. |   Licence Info: phpib-licence@ibforums.com
  14. +---------------------------------------------------------------------------
  15. |
  16. |   > Admin Category functions
  17. |   > Module written by Matt Mecham
  18. |   > Date started: 1st march 2002
  19. |
  20. |    > Module Version Number: 1.0.0
  21. +--------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25.  
  26. $idx = new ad_mod();
  27.  
  28.  
  29. class ad_mod {
  30.  
  31.     var $base_url;
  32.  
  33.     function ad_mod() {
  34.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  35.  
  36.         switch($IN['code'])
  37.         {
  38.             case 'add':
  39.                 $this->add_one();
  40.                 break;
  41.             case 'add_two':
  42.                 $this->add_two();
  43.                 break;
  44.             case 'add_final':
  45.                 $this->mod_form('add');
  46.                 break;
  47.             case 'doadd':
  48.                 $this->add_mod();
  49.                 break;
  50.                 
  51.             case 'edit':
  52.                 $this->mod_form('edit');
  53.                 break;
  54.                 
  55.             case 'doedit':
  56.                 $this->do_edit();
  57.                 break;
  58.                 
  59.             case 'remove':
  60.                 $this->do_delete();
  61.                 break;
  62.                 
  63.             default:
  64.                 $this->show_list();
  65.                 break;
  66.         }
  67.         
  68.     }
  69.     
  70.     //+---------------------------------------------------------------------------------
  71.     //
  72.     // DELETE MODERATOR
  73.     //
  74.     //+---------------------------------------------------------------------------------
  75.     
  76.     function do_delete()
  77.     {
  78.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  79.         
  80.         if ($IN['mid'] == "")
  81.         {
  82.             $ADMIN->error("You did not choose a valid moderator ID");
  83.         }
  84.             
  85.         $DB->query("DELETE FROM ibf_moderators WHERE mid='".$IN['mid']."'");
  86.         
  87.         $ADMIN->done_screen("Moderator Removed", "Moderator Control", "act=mod" );
  88.         
  89.     }    
  90.     
  91.     
  92.     //+---------------------------------------------------------------------------------
  93.     //
  94.     // EDIT MODERATOR
  95.     //
  96.     //+---------------------------------------------------------------------------------
  97.     
  98.     function do_edit()
  99.     {
  100.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  101.         
  102.         if ($IN['mid'] == "")
  103.         {
  104.             $ADMIN->error("You did not choose a valid moderator ID");
  105.         }
  106.         
  107.         //--------------------------------------
  108.         // Build Mr Hash
  109.         //--------------------------------------
  110.         
  111.         $mr_hash = array( 
  112.                             'forum_id'     => $IN['forum_id'],
  113.                             'edit_post'    => $IN['edit_post'],
  114.                             'edit_topic'   => $IN['edit_topic'],
  115.                             'delete_post'  => $IN['delete_post'],
  116.                             'delete_topic' => $IN['delete_topic'],
  117.                             'view_ip'      => $IN['view_ip'],
  118.                             'open_topic'   => $IN['open_topic'],
  119.                             'close_topic'  => $IN['close_topic'],
  120.                             'mass_move'    => $IN['mass_move'],
  121.                             'mass_prune'   => $IN['mass_prune'],
  122.                             'move_topic'   => $IN['move_topic'],
  123.                             'pin_topic'    => $IN['pin_topic'],
  124.                             'unpin_topic'  => $IN['unpin_topic'],
  125.                             'post_q'       => $IN['post_q'],
  126.                             'topic_q'      => $IN['topic_q'],
  127.                             'allow_warn'   => $IN['allow_warn'],
  128.                             'edit_user'    => $IN['edit_user']
  129.                         );
  130.                         
  131.         
  132.             
  133.         $db_string = $DB->compile_db_update_string( $mr_hash );
  134.             
  135.         $DB->query("UPDATE ibf_moderators SET $db_string WHERE mid='".$IN['mid']."'");
  136.         
  137.         $ADMIN->done_screen("Moderator Edited", "Moderator Control", "act=mod" );
  138.         
  139.     }    
  140.     
  141.     //+---------------------------------------------------------------------------------
  142.     //
  143.     // ADD MODERATOR
  144.     //
  145.     //+---------------------------------------------------------------------------------
  146.     
  147.     function add_mod()
  148.     {
  149.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  150.         
  151.         if ($IN['fid'] == "")
  152.         {
  153.             $ADMIN->error("You did not choose any forums to add this member to");
  154.         }
  155.         
  156.         if ($IN['mem'] == "")
  157.         {
  158.             $ADMIN->error("You did not choose a member to add as a moderator");
  159.         }
  160.         
  161.         $DB->query("SELECT id, name from ibf_members WHERE id='".$IN['mem']."'");
  162.         
  163.         if ( ! $mem = $DB->fetch_row() )
  164.         {
  165.             $ADMIN->error("Could not match that member name so there.");
  166.         }
  167.         
  168.         //--------------------------------------
  169.         // Check for legal forums
  170.         //--------------------------------------
  171.         
  172.         $forum_ids = array();
  173.         
  174.         $DB->query("SELECT id FROM ibf_forums WHERE id IN(".$IN['fid'].")");
  175.         
  176.         while( $i = $DB->fetch_row() )
  177.         {
  178.             $forum_ids[] = $i['id'];
  179.         }
  180.         
  181.         if ( count($forum_ids) == 0)
  182.         {
  183.             $ADMIN->error("We could not match any forums with those IDS");
  184.         }
  185.         
  186.         //--------------------------------------
  187.         // Build Mr Hash
  188.         //--------------------------------------
  189.         
  190.         $mr_hash = array( 
  191.                             'member_name'  => $mem['name'],
  192.                             'member_id'    => $mem['id'],
  193.                             'edit_post'    => $IN['edit_post'],
  194.                             'edit_topic'   => $IN['edit_topic'],
  195.                             'delete_post'  => $IN['delete_post'],
  196.                             'delete_topic' => $IN['delete_topic'],
  197.                             'view_ip'      => $IN['view_ip'],
  198.                             'open_topic'   => $IN['open_topic'],
  199.                             'close_topic'  => $IN['close_topic'],
  200.                             'mass_move'    => $IN['mass_move'],
  201.                             'mass_prune'   => $IN['mass_prune'],
  202.                             'move_topic'   => $IN['move_topic'],
  203.                             'pin_topic'    => $IN['pin_topic'],
  204.                             'unpin_topic'  => $IN['unpin_topic'],
  205.                             'post_q'       => $IN['post_q'],
  206.                             'topic_q'      => $IN['topic_q'],
  207.                             'allow_warn'   => $IN['allow_warn'],
  208.                             'edit_user'    => $IN['edit_user']
  209.                         );
  210.                         
  211.         //--------------------------------------
  212.         // Loopy loopy
  213.         //--------------------------------------
  214.         
  215.         foreach ($forum_ids as $cartman)
  216.         {
  217.             $mr_hash['forum_id'] = $cartman;
  218.             
  219.             $kenny = $DB->compile_db_insert_string( $mr_hash );
  220.             
  221.             $DB->query("INSERT INTO ibf_moderators (" .$kenny['FIELD_NAMES']. ") VALUES (". $kenny['FIELD_VALUES'] .")");
  222.         }
  223.         
  224.         $ADMIN->done_screen("Moderator Added", "Moderator Control", "act=mod" );
  225.         
  226.     }    
  227.     
  228.     //+---------------------------------------------------------------------------------
  229.     //
  230.     // ADD FINAL, display the add / edit form
  231.     //
  232.     //+---------------------------------------------------------------------------------
  233.     
  234.     function mod_form( $type='add' ) {
  235.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  236.         
  237.         if ($type == 'add')
  238.         {
  239.             if ($IN['fid'] == "")
  240.             {
  241.                 $ADMIN->error("You did not choose any forums to add this member to");
  242.             }    
  243.                 
  244.             $mod   = array();
  245.             $names = array();
  246.             
  247.             //--------------------------------------
  248.             
  249.             $DB->query("SELECT name FROM ibf_forums WHERE id IN(".$IN['fid'].")");
  250.             
  251.             while ( $r = $DB->fetch_row() )
  252.             {
  253.                 $names[] = $r['name'];
  254.             }
  255.             
  256.             $thenames = implode( ", ", $names );
  257.             
  258.             //--------------------------------------
  259.             
  260.             $button = "Add this moderator";
  261.             
  262.             $form_code = 'doadd';
  263.             
  264.             if ($IN['MEMBER_ID'] == "")
  265.             {
  266.                 $ADMIN->error("Could not resolve the member id bucko");
  267.             }
  268.             else
  269.             {
  270.                 $DB->query("SELECT name, id FROM ibf_members WHERE id='".$IN['MEMBER_ID']."'");
  271.                 
  272.                 if ( ! $mem = $DB->fetch_row() )
  273.                 {
  274.                     $ADMIN->error("That member ID does not resolve");
  275.                 }
  276.                 
  277.                 $member_id   = $mem['id'];
  278.                 $member_name = $mem['name'];
  279.             }
  280.             
  281.             $ADMIN->page_detail = "Adding a $member_name as a moderator to: $thenames";
  282.             $ADMIN->page_title = "Add a moderator";
  283.             
  284.         }
  285.         else
  286.         {
  287.             if ($IN['mid'] == "")
  288.             {
  289.                 $ADMIN->error("You must choose a valid moderator to edit.");
  290.             }
  291.             
  292.             $button    = "Edit this moderator";
  293.             
  294.             $form_code = "doedit";
  295.             
  296.             $ADMIN->page_title  = "Editing a moderator";
  297.             $ADMIN->page_detail = "Please check the information carefully before submitting the form";
  298.             
  299.             $DB->query("SELECT * from ibf_moderators WHERE mid='".$IN['mid']."'");
  300.             
  301.             if ( ! $mod = $DB->fetch_row() )
  302.             {
  303.                 $ADMIN->error("Could not retrieve that moderators record");
  304.             }
  305.             
  306.             $member_id   = $mod['member_id'];
  307.             $member_name = $mod['member_name'];
  308.         }
  309.         
  310.         
  311.         //+-------------------------------
  312.         
  313.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , $form_code ),
  314.                                                   2 => array( 'act'   , 'mod'      ),
  315.                                                   3 => array( 'mid'   , $mod['mid']),
  316.                                                   4 => array( 'fid'   , $IN['fid'] ),
  317.                                                   5 => array( 'mem'   , $member_id ),
  318.                                          )      );
  319.         
  320.         //+-------------------------------
  321.         
  322.         $SKIN->td_header[] = array( " "  , "40%" );
  323.         $SKIN->td_header[] = array( " "  , "60%" );
  324.         
  325.         //+-------------------------------
  326.         
  327.         $ADMIN->html .= $SKIN->start_table( "General Settings" );
  328.         
  329.         //+-------------------------------
  330.         
  331.         if ($type == 'edit')
  332.         {
  333.             $forums = array();
  334.             
  335.             $DB->query("SELECT id, name FROM ibf_forums ORDER BY position");
  336.             
  337.             while ( $r = $DB->fetch_row() )
  338.             {
  339.                 $forums[] = array( $r['id'], $r['name'] );
  340.             }
  341.             
  342.             $ADMIN->html .= $SKIN->add_td_row( array( "<b>Moderates forum...</b>" ,
  343.                                                   $SKIN->form_dropdown( "forum_id", $forums, $mod['forum_id'] )
  344.                                          )      );
  345.         }
  346.         
  347.         //+-------------------------------
  348.         
  349.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can edit others posts/polls?</b>" ,
  350.                                                   $SKIN->form_yes_no("edit_post", $mod['edit_post'] )
  351.                                          )      );
  352.                                          
  353.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can edit others topic titles?</b>" ,
  354.                                                   $SKIN->form_yes_no("edit_topic", $mod['edit_topic'] )
  355.                                          )      );                                 
  356.                                          
  357.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can delete others posts?</b>" ,
  358.                                                   $SKIN->form_yes_no("delete_post", $mod['delete_post'] )
  359.                                          )      );                                 
  360.                                          
  361.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can delete others topics/polls?</b>" ,
  362.                                                   $SKIN->form_yes_no("delete_topic", $mod['delete_topic'] )
  363.                                          )      );                                 
  364.                                          
  365.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can view posters IP addresses?</b>" ,
  366.                                                   $SKIN->form_yes_no("view_ip", $mod['view_ip'] )
  367.                                          )      );        
  368.                 
  369.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can open locked topics?</b>" ,
  370.                                                   $SKIN->form_yes_no("open_topic", $mod['open_topic'] )
  371.                                          )      );        
  372.         
  373.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can close open topics?</b>" ,
  374.                                                   $SKIN->form_yes_no("close_topic", $mod['close_topic'] )
  375.                                          )      );    
  376.                                              
  377.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can move topics?</b>" ,
  378.                                                   $SKIN->form_yes_no("move_topic", $mod['move_topic'] )
  379.                                          )      );                                 
  380.         
  381.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can pin topics?</b>" ,
  382.                                                   $SKIN->form_yes_no("pin_topic", $mod['pin_topic'] )
  383.                                          )      );
  384.         
  385.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can unpin topics?</b>" ,
  386.                                                   $SKIN->form_yes_no("unpin_topic", $mod['unpin_topic'] )
  387.                                          )      );
  388.                                          
  389.         $ADMIN->html .= $SKIN->end_table();
  390.         
  391.         //+-------------------------------
  392.         
  393.         $SKIN->td_header[] = array( " "  , "40%" );
  394.         $SKIN->td_header[] = array( " "  , "60%" );
  395.         
  396.         //+-------------------------------
  397.         
  398.         $ADMIN->html .= $SKIN->start_table( "Moderator Control Panel Settings" );
  399.         
  400.         //+-------------------------------
  401.                                          
  402.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can mass move topics?</b>" ,
  403.                                                   $SKIN->form_yes_no("mass_move", $mod['mass_move'] )
  404.                                          )      );    
  405.                                          
  406.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can mass prune topics?</b>" ,
  407.                                                   $SKIN->form_yes_no("mass_prune", $mod['mass_prune'] )
  408.                                          )      );
  409.                                                                       
  410.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can manage queued topics?</b>" ,
  411.                                                   $SKIN->form_yes_no("topic_q", $mod['topic_q'] )
  412.                                          )      );                                 
  413.                                              
  414.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can manage queued posts?</b>" ,
  415.                                                   $SKIN->form_yes_no("post_q", $mod['post_q'] )
  416.                                          )      );                                 
  417.                                          
  418.         $ADMIN->html .= $SKIN->end_table();
  419.         
  420.         //+-------------------------------
  421.         
  422.         $SKIN->td_header[] = array( " "  , "40%" );
  423.         $SKIN->td_header[] = array( " "  , "60%" );
  424.         
  425.         //+-------------------------------
  426.         
  427.         $ADMIN->html .= $SKIN->start_table( "Advanced Settings" );
  428.         
  429.         //+-------------------------------
  430.         
  431.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can warn other users?</b>" ,
  432.                                                   $SKIN->form_yes_no("allow_warn", $mod['allow_warn'] )
  433.                                          )      );                                 
  434.                                              
  435.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Can edit user avatars and signatures?</b>" ,
  436.                                                   $SKIN->form_yes_no("edit_user", $mod['edit_user'] )
  437.                                          )      );                                 
  438.                                          
  439.         //+-------------------------------
  440.                                          
  441.         $ADMIN->html .= $SKIN->end_form($button);
  442.                                          
  443.         $ADMIN->html .= $SKIN->end_table();
  444.         
  445.         $ADMIN->output();                                                              
  446.                                          
  447.         
  448.     }
  449.     
  450.     
  451.     //+---------------------------------------------------------------------------------
  452.     //
  453.     // ADD step one: Look up a member
  454.     //
  455.     //+---------------------------------------------------------------------------------
  456.     
  457.     function add_one() {
  458.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  459.         
  460.         //-----------------------------
  461.         // Grab and serialize the input
  462.         //-----------------------------
  463.         
  464.         $fid      = "";
  465.         $fidarray = array();
  466.         
  467.         foreach ($IN as $k => $v)
  468.         {
  469.             if ( preg_match( "/^add_(\d+)$/", $k, $match ) )
  470.             {
  471.                 if ($IN[ $match[0] ])
  472.                 {
  473.                     $fidarray[] = $match[1];
  474.                 }
  475.             }
  476.         }
  477.         
  478.         if ( count($fidarray) < 1 )
  479.         {
  480.             $ADMIN->error("You must select a forum, or forums to add a moderator to. You can do this by checking the checkboxes to the left of the forum name");
  481.         }
  482.         
  483.         $fid = implode( "," ,$fidarray );
  484.         
  485.         $ADMIN->page_title = "Add a moderator";
  486.         
  487.         $ADMIN->page_detail = "Please find a member to moderate the forums you previously selected.";
  488.         
  489.         //+-------------------------------
  490.         
  491.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'add_two' ),
  492.                                                   2 => array( 'act'   , 'mod'     ),
  493.                                                   3 => array( 'fid'   , $fid      ),
  494.                                          )      );
  495.         
  496.         //+-------------------------------
  497.         
  498.         $SKIN->td_header[] = array( " "  , "40%" );
  499.         $SKIN->td_header[] = array( " "  , "60%" );
  500.         
  501.         //+-------------------------------
  502.         
  503.         $ADMIN->html .= $SKIN->start_table( "Search for a member" );
  504.         
  505.                                          
  506.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Enter part or all of the usersname</b>" ,
  507.                                                   $SKIN->form_input( "USER_NAME" )
  508.                                          )      );
  509.                                          
  510.         $ADMIN->html .= $SKIN->end_form("Find Member");
  511.                                          
  512.         $ADMIN->html .= $SKIN->end_table();
  513.         
  514.         $ADMIN->output();
  515.         
  516.         
  517.     }
  518.     
  519.     //+---------------------------------------------------------------------------------
  520.     //
  521.     // REFINE MEMBER SEARCH
  522.     //
  523.     //+---------------------------------------------------------------------------------
  524.     
  525.     function add_two() {
  526.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  527.         
  528.         if ($IN['USER_NAME'] == "")
  529.         {
  530.             $ADMIN->error("You didn't choose a member name to look for!");
  531.         }
  532.         
  533.         $DB->query("SELECT id, name FROM ibf_members WHERE name LIKE '".$IN['USER_NAME']."%'");
  534.         
  535.         if (! $DB->get_num_rows() )
  536.         {
  537.             $ADMIN->error("Sorry, we could not find any members that matched the search string you entered");
  538.         }
  539.         
  540.         $form_array = array();
  541.         
  542.         while ( $r = $DB->fetch_row() )
  543.         {
  544.             $form_array[] = array( $r['id'] , $r['name'] );
  545.         }
  546.         
  547.         
  548.         
  549.         $ADMIN->page_title = "Add a moderator";
  550.         
  551.         $ADMIN->page_detail = "Please select the correct member name from the selection below to add as a moderator to the previously selected forums.";
  552.         
  553.         //+-------------------------------
  554.         
  555.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'add_final' ),
  556.                                                   2 => array( 'act'   , 'mod'    ),
  557.                                                   3 => array( 'fid'   , $IN['fid']),
  558.                                          )      );
  559.         
  560.         //+-------------------------------
  561.         
  562.         $SKIN->td_header[] = array( " "  , "40%" );
  563.         $SKIN->td_header[] = array( " "  , "60%" );
  564.         
  565.         //+-------------------------------
  566.         
  567.         $ADMIN->html .= $SKIN->start_table( "Search for a member" );
  568.         
  569.                                          
  570.         $ADMIN->html .= $SKIN->add_td_row( array( "<b>Choose from the matches...</b>" ,
  571.                                                   $SKIN->form_dropdown( "MEMBER_ID", $form_array )
  572.                                          )      );
  573.                                          
  574.         $ADMIN->html .= $SKIN->end_form("Choose Member");
  575.                                          
  576.         $ADMIN->html .= $SKIN->end_table();
  577.         
  578.         $ADMIN->output();
  579.         
  580.     }
  581.     
  582.     
  583.     //+---------------------------------------------------------------------------------
  584.     //
  585.     // SHOW LIST
  586.     // Renders a complete listing of all the forums and categories w/mods.
  587.     //
  588.     //+---------------------------------------------------------------------------------
  589.     
  590.     function show_list() {
  591.         global $IN, $root_path, $INFO, $DB, $SKIN, $ADMIN, $std, $MEMBER, $GROUP;
  592.         
  593.         $ADMIN->page_title = "Moderator Control Overview";
  594.         $ADMIN->page_detail  = "This section allows you to edit, remove and add new moderators to your forums";
  595.         
  596.         $ADMIN->html .= $SKIN->start_form( array( 1 => array( 'code'  , 'add' ),
  597.                                                   2 => array( 'act'   , 'mod'   ),
  598.                                          )      );
  599.         
  600.         $SKIN->td_header[] = array( "Add"          , "5%" );
  601.         $SKIN->td_header[] = array( "Forum Name"   , "30%" );
  602.         $SKIN->td_header[] = array( "Posts"        , "10%" );
  603.         $SKIN->td_header[] = array( "Topics"       , "10%" );
  604.         $SKIN->td_header[] = array( "Current Moderators"       , "45%" );
  605.         
  606.         $ADMIN->html .= $SKIN->start_table( "Your Categories and Forums" );
  607.         
  608.         //------------------------------------
  609.         
  610.         $cats   = array();
  611.         $forums = array();
  612.         $mods   = array();
  613.         $children = array();
  614.         
  615.         $DB->query("SELECT * from ibf_categories where id > 0 ORDER BY position ASC");
  616.         while ($r = $DB->fetch_row())
  617.         {
  618.             $cats[$r['id']] = $r;
  619.         }
  620.         
  621.         $DB->query("SELECT * from ibf_forums ORDER BY position ASC");
  622.         while ($r = $DB->fetch_row())
  623.         {
  624.             
  625.             if ($r['parent_id'] > 0)
  626.             {
  627.                 $children[ $r['parent_id'] ][] = $r;
  628.             }
  629.             else
  630.             {
  631.                 $forums[] = $r;
  632.             }
  633.             
  634.         }
  635.         
  636.         $DB->query("SELECT * from ibf_moderators");
  637.         while ($r = $DB->fetch_row())
  638.         {
  639.             $mods[] = $r;
  640.         }
  641.         
  642.         //------------------------------------
  643.         
  644.         $last_cat_id = -1;
  645.         
  646.         foreach ($cats as $c)
  647.         {
  648.             
  649.             $ADMIN->html .= $SKIN->add_td_row( array(
  650.                                                        ' ',
  651.                                                        "<a href='{$ADMIN->base_url}&act=cat&code=doeditform&c={$c['id']}'>".$c['name']."</a>",
  652.                                                        ' ',
  653.                                                        ' ',
  654.                                                        ' ',
  655.                                              ), 'catrow'     );
  656.             $last_cat_id = $c['id'];
  657.             
  658.             
  659.             foreach($forums as $r)
  660.             {    
  661.             
  662.                 if ($r['category'] == $last_cat_id)
  663.                 {
  664.                 
  665.                     $mod_string = "";
  666.                     
  667.                     foreach( $mods as $phpid => $data )
  668.                     {
  669.                         if ($data['forum_id'] == $r['id'])
  670.                         {
  671.                             $mod_string .= "<tr>
  672.                                              <td width='60%'>{$data['member_name']}</td>
  673.                                              <td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=remove&mid={$data['mid']}'>Remove</a></td>
  674.                                              <td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=edit&mid={$data['mid']}'>Edit</a></td>
  675.                                             </tr>";
  676.                         }
  677.                     }
  678.                     
  679.                     if ($mod_string != "")
  680.                     {
  681.                         $these_mods = "<table cellpadding='3' cellspacing='0' width='100%' align='center'>".$mod_string."</table>";
  682.                     }
  683.                     else
  684.                     {
  685.                         $these_mods = "<center><i>Unmoderated</i></center>";
  686.                     }
  687.                 
  688.                     if ($r['subwrap'] == 1)
  689.                     {
  690.                     
  691.                         $ADMIN->html .= $SKIN->add_td_row( array(
  692.                                                                    ' ',
  693.                                                                    $c['name'],
  694.                                                                    ' ',
  695.                                                                    ' ',
  696.                                                                    ' ',
  697.                                                          ), 'catrow2'     );
  698.                     }
  699.                     else
  700.                     {
  701.                         $ADMIN->html .= $SKIN->add_td_row( array(
  702.                                                                "<center><input type='checkbox' name='add_{$r['id']}' value='1'></center>",
  703.                                                                "<b>".$r['name']."</b><br>".$r['description'],
  704.                                                                $r['posts'],
  705.                                                                $r['topics'],
  706.                                                                $these_mods
  707.                                                      )      );
  708.                     }
  709.                                                      
  710.                     if ( ( isset($children[ $r['id'] ]) ) and ( count ($children[ $r['id'] ]) > 0 ) )
  711.                     {
  712.                         foreach($children[ $r['id'] ] as $idx => $rd)
  713.                         {
  714.                         
  715.                             $mod_string = "";
  716.                     
  717.                             foreach( $mods as $phpid => $data )
  718.                             {
  719.                                 if ($data['forum_id'] == $rd['id'])
  720.                                 {
  721.                                     $mod_string .= "<tr>
  722.                                                      <td width='60%'>{$data['member_name']}</td>
  723.                                                      <td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=remove&mid={$data['mid']}'>Remove</a></td>
  724.                                                      <td width='20%'><a href='{$ADMIN->base_url}&act=mod&code=edit&mid={$data['mid']}'>Edit</a></td>
  725.                                                     </tr>";
  726.                                 }
  727.                             }
  728.                             
  729.                             if ($mod_string != "")
  730.                             {
  731.                                 $these_mods = "<table cellpadding='3' cellspacing='0' width='100%' align='center'>".$mod_string."</table>";
  732.                             }
  733.                             else
  734.                             {
  735.                                 $these_mods = "<center><i>Unmoderated</i></center>";
  736.                             }
  737.                     
  738.                             $ADMIN->html .= $SKIN->add_td_row( array(
  739.                                                                "<center><input type='checkbox' name='add_{$rd['id']}' value='1'></center>",
  740.                                                                "<b>".$rd['name']."</b><br>".$rd['description'],
  741.                                                                $rd['posts'],
  742.                                                                $rd['topics'],
  743.                                                                $these_mods
  744.                                                      )  ,'subforum'    );
  745.                         }
  746.                     }                     
  747.                 }
  748.             }
  749.         }
  750.         
  751.         $ADMIN->html .= $SKIN->end_form("Add a moderator to the selected forums");
  752.         
  753.         $ADMIN->html .= $SKIN->end_table();
  754.         
  755.         $ADMIN->output();
  756.         
  757.     }
  758.     
  759.     
  760.  
  761.  
  762.     
  763. }
  764.  
  765.  
  766. ?>