plugins/SpecialGroups.php
changeset 322 5f1cd51bf1be
parent 317 f8356d9c3481
child 334 c72b545f1304
child 447 a9a3789ce02d
equal deleted inserted replaced
320:112debff64bd 322:5f1cd51bf1be
    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     }