Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / cmd_global_staff.c
1 /* cmd_global_staff.c - NeonServ v5.3
2  * Copyright (C) 2011-2012  Philipp Kreil (pk910)
3  * 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License 
15  * along with this program. If not, see <http://www.gnu.org/licenses/>. 
16  */
17
18 #include "cmd_global.h"
19
20 /*
21 * no arguments
22 */
23
24 CMD_BIND(global_cmd_staff) {
25     MYSQL_RES *res, *res2;
26     MYSQL_ROW row, row2;
27     printf_mysql_query("SELECT `rank_id`, `rank_name` FROM `support_ranks` ORDER BY `rank_order` ASC");
28     res = mysql_use();
29     while ((row = mysql_fetch_row(res)) != NULL) {
30         printf_mysql_query("SELECT `user_user`, `user_god` FROM `users` WHERE `user_rank` = '%s'", row[0]);
31         res2 = mysql_use();
32         if(mysql_num_rows(res2)) {
33             reply(getTextBot(), user, "\002%s\002", row[1]);
34             while ((row2 = mysql_fetch_row(res2)) != NULL) {
35                 if(strcmp(row2[1], "0")) {
36                     //god enabled - show nicks
37                     char loggedinBuf[MAXLEN];
38                     int loggedinPos = 0;
39                     struct UserNode *cuser;
40                     for(cuser = getUsersWithAuth(row2[0], NULL); cuser; cuser = getUsersWithAuth(row2[0], cuser)) {
41                         loggedinPos += sprintf(loggedinBuf+loggedinPos, (loggedinPos ? ", %s" : "%s"), cuser->nick);
42                     }
43                     if(loggedinPos)
44                         reply(getTextBot(), user, "  %s (%s: %s)", row2[0], get_language_string(user, "NS_STAFF_LOGGEDIN"), loggedinBuf);
45                     else
46                         reply(getTextBot(), user, "  %s", row2[0]);
47                 } else
48                     reply(getTextBot(), user, "  %s", row2[0]);
49             }
50         }
51     }
52 }