plugins/SpecialGroups.php
changeset 326 ab66d6d1f1f4
parent 322 5f1cd51bf1be
child 334 c72b545f1304
child 447 a9a3789ce02d
equal deleted inserted replaced
314:474f8be55943 326:ab66d6d1f1f4
     2 /*
     2 /*
     3 Plugin Name: Group control panel
     3 Plugin Name: Group control panel
     4 Plugin URI: http://enanocms.org/
     4 Plugin URI: http://enanocms.org/
     5 Description: Provides group moderators and site administrators with the ability to control who is part of their groups. 
     5 Description: Provides group moderators and site administrators with the ability to control who is part of their groups. 
     6 Author: Dan Fuhry
     6 Author: Dan Fuhry
     7 Version: 1.0.2
     7 Version: 1.0.3
     8 Author URI: http://enanocms.org/
     8 Author URI: http://enanocms.org/
     9 */
     9 */
    10 
    10 
    11 /*
    11 /*
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    13  * Version 1.0.2
    13  * Version 1.0.3
    14  * Copyright (C) 2007 Dan Fuhry
    14  * Copyright (C) 2007 Dan Fuhry
    15  *
    15  *
    16  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    16  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    17  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    17  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    18  *
    18  *
    57     }
    57     }
    58     $row = $db->fetchrow();
    58     $row = $db->fetchrow();
    59     $db->free_result();
    59     $db->free_result();
    60     $members = array();
    60     $members = array();
    61     $pending = array();
    61     $pending = array();
    62     $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending,COUNT(c.comment_id)
    62     $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending,COUNT(c.comment_id) AS num_comments
    63                            FROM '.table_prefix.'users AS u
    63                            FROM '.table_prefix.'users AS u
    64                            LEFT JOIN '.table_prefix.'group_members AS m
    64                            LEFT JOIN '.table_prefix.'group_members AS m
    65                              ON ( m.user_id = u.user_id )
    65                              ON ( m.user_id = u.user_id )
    66                            LEFT JOIN '.table_prefix.'comments AS c
    66                            LEFT JOIN '.table_prefix.'comments AS c
    67                              ON ( c.name = u.username )
    67                              ON ( c.name = u.username )
    68                            WHERE m.group_id=' . $gid . '
    68                            WHERE m.group_id=' . $gid . '
    69                            GROUP BY u.user_id
    69                            GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,m.pending
    70                            ORDER BY m.is_mod DESC,u.username ASC;');
    70                            ORDER BY m.is_mod DESC,u.username ASC;');
    71     if ( !$q )
    71     if ( !$q )
    72     {
    72     {
    73       $db->_die('SpecialGroups.php, line ' . __LINE__);
    73       $db->_die('SpecialGroups.php, line ' . __LINE__);
    74     }
    74     }
   198           $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES(' . intval($_POST['group_id']) . ', ' . $uid . ', ' . $mod . ');');
   198           $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id,is_mod) VALUES(' . intval($_POST['group_id']) . ', ' . $uid . ', ' . $mod . ');');
   199           if (!$q)
   199           if (!$q)
   200             $db->_die('SpecialGroups.php, line ' . __LINE__);
   200             $db->_die('SpecialGroups.php, line ' . __LINE__);
   201           echo '<div class="info-box">The user "' . $username . '" has been added to this usergroup.</div>';
   201           echo '<div class="info-box">The user "' . $username . '" has been added to this usergroup.</div>';
   202           
   202           
   203           $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id)
   203           $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id) AS num_comments
   204                                  FROM '.table_prefix.'users AS u
   204                                  FROM '.table_prefix.'users AS u
   205                                  LEFT JOIN '.table_prefix.'group_members AS m
   205                                  LEFT JOIN '.table_prefix.'group_members AS m
   206                                    ON ( m.user_id = u.user_id )
   206                                    ON ( m.user_id = u.user_id )
   207                                  LEFT JOIN '.table_prefix.'comments AS c
   207                                  LEFT JOIN '.table_prefix.'comments AS c
   208                                    ON ( c.name = u.username )
   208                                    ON ( c.name = u.username )
   209                                  WHERE m.group_id=' . $gid . '
   209                                  WHERE m.group_id=' . $gid . '
   210                                    AND m.pending!=1
   210                                    AND m.pending!=1
   211                                    AND u.user_id=' . $uid . '
   211                                    AND u.user_id=' . $uid . '
   212                                  GROUP BY u.user_id
   212                                  GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod
   213                                  ORDER BY m.is_mod DESC,u.username ASC
   213                                  ORDER BY m.is_mod DESC,u.username ASC
   214                                  LIMIT 1;');
   214                                  LIMIT 1;');
   215           if ( !$q )
   215           if ( !$q )
   216             $db->_die('SpecialGroups.php, line ' . __LINE__);
   216             $db->_die('SpecialGroups.php, line ' . __LINE__);
   217           
   217           
   265       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES(' . $gid . ', ' . $session->user_id . ');');
   265       $q = $db->sql_query('INSERT INTO '.table_prefix.'group_members(group_id,user_id) VALUES(' . $gid . ', ' . $session->user_id . ');');
   266       if (!$q)
   266       if (!$q)
   267         $db->_die('SpecialGroups.php, line ' . __LINE__);
   267         $db->_die('SpecialGroups.php, line ' . __LINE__);
   268       echo '<div class="info-box">You have been added to this group.</div>';
   268       echo '<div class="info-box">You have been added to this group.</div>';
   269       
   269       
   270       $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id)
   270       $q = $db->sql_query('SELECT u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod,COUNT(c.comment_id) AS num_comments
   271                              FROM '.table_prefix.'users AS u
   271                              FROM '.table_prefix.'users AS u
   272                              LEFT JOIN '.table_prefix.'group_members AS m
   272                              LEFT JOIN '.table_prefix.'group_members AS m
   273                                ON ( m.user_id = u.user_id )
   273                                ON ( m.user_id = u.user_id )
   274                              LEFT JOIN '.table_prefix.'comments AS c
   274                              LEFT JOIN '.table_prefix.'comments AS c
   275                                ON ( c.name = u.username )
   275                                ON ( c.name = u.username )
   276                              WHERE m.group_id=' . $gid . '
   276                              WHERE m.group_id=' . $gid . '
   277                                AND m.pending!=1
   277                                AND m.pending!=1
   278                                AND u.user_id=' . $session->user_id . '
   278                                AND u.user_id=' . $session->user_id . '
   279                              GROUP BY u.user_id
   279                              GROUP BY u.user_id,u.username,u.email,u.reg_time,m.member_id,m.user_id,m.is_mod
   280                              ORDER BY m.is_mod DESC,u.username ASC
   280                              ORDER BY m.is_mod DESC,u.username ASC
   281                              LIMIT 1;');
   281                              LIMIT 1;');
   282       if ( !$q )
   282       if ( !$q )
   283         $db->_die('SpecialGroups.php, line ' . __LINE__);
   283         $db->_die('SpecialGroups.php, line ' . __LINE__);
   284       
   284       
   368         
   368         
   369         echo "<tr>
   369         echo "<tr>
   370                 <td class='{$cls}'>{$member['username']}</td>
   370                 <td class='{$cls}'>{$member['username']}</td>
   371                 <td class='{$cls}'>{$addy}</td>
   371                 <td class='{$cls}'>{$addy}</td>
   372                 <td class='{$cls}'>{$date}</td>
   372                 <td class='{$cls}'>{$date}</td>
   373                 <td class='{$cls}'>{$member['COUNT(c.comment_id)']}</td>
   373                 <td class='{$cls}'>{$member['num_comments']}</td>
   374                 <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='with_user[{$member['member_id']}]' /></td>
   374                 <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='with_user[{$member['member_id']}]' /></td>
   375               </tr>";
   375               </tr>";
   376       }
   376       }
   377       echo '</table>
   377       echo '</table>
   378             </div>
   378             </div>
   416       
   416       
   417       echo "<tr>
   417       echo "<tr>
   418               <td class='{$cls}'>{$member['username']}</td>
   418               <td class='{$cls}'>{$member['username']}</td>
   419               <td class='{$cls}'>{$addy}</td>
   419               <td class='{$cls}'>{$addy}</td>
   420               <td class='{$cls}'>{$date}</td>
   420               <td class='{$cls}'>{$date}</td>
   421               <td class='{$cls}'>{$member['COUNT(c.comment_id)']}</td>
   421               <td class='{$cls}'>{$member['num_comments']}</td>
   422               " . ( ( $can_do_admin_stuff ) ? "
   422               " . ( ( $can_do_admin_stuff ) ? "
   423               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   423               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   424               " : '' ) . "
   424               " : '' ) . "
   425             </tr>";
   425             </tr>";
   426     }
   426     }
   440       
   440       
   441       echo "<tr>
   441       echo "<tr>
   442               <td class='{$cls}'>{$member['username']}</td>
   442               <td class='{$cls}'>{$member['username']}</td>
   443               <td class='{$cls}'>{$addy}</td>
   443               <td class='{$cls}'>{$addy}</td>
   444               <td class='{$cls}'>{$date}</td>
   444               <td class='{$cls}'>{$date}</td>
   445               <td class='{$cls}'>{$member['COUNT(c.comment_id)']}</td>
   445               <td class='{$cls}'>{$member['num_comments']}</td>
   446               " . ( ( $can_do_admin_stuff ) ? "
   446               " . ( ( $can_do_admin_stuff ) ? "
   447               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   447               <td class='{$cls}' style='text-align: center;'><input type='checkbox' name='del_user[{$member['member_id']}]' /></td>
   448               " : '' ) . "
   448               " : '' ) . "
   449             </tr>";
   449             </tr>";
   450     }
   450     }