improved table_end
[NeonServV5.git] / cmd_neonserv_users.c
index a87aca55d6ee4be60d8636c0fbddd9a959812ba9..f9a7173d4ef7d8605187582e56edc606016e49e7 100644 (file)
@@ -53,7 +53,7 @@ static void neonserv_cmd_users_async1(struct ClientSocket *client, struct Client
     char seenstr[MAXLEN];
     struct Table *table;
     struct ChanUser *chanuser;
-    printf_mysql_query("SELECT `chanuser_access`, `user_user`, `chanuser_seen`, `chanuser_flags` FROM `chanusers` LEFT JOIN `users` ON `chanuser_uid` = `user_id` WHERE `chanuser_cid` = '%d'", chan->channel_id);
+    printf_mysql_query("SELECT `chanuser_access`, `user_user`, `chanuser_seen`, `chanuser_flags` FROM `chanusers` LEFT JOIN `users` ON `chanuser_uid` = `user_id` WHERE `chanuser_cid` = '%d' ORDER BY `chanuser_access` DESC, `user_user` ASC", chan->channel_id);
     res = mysql_use();
     table = table_init(4, mysql_num_rows(res) + 1, 0);
     if(usermask)
@@ -68,7 +68,7 @@ static void neonserv_cmd_users_async1(struct ClientSocket *client, struct Client
     table_add(table, content);
     while ((row = mysql_fetch_row(res)) != NULL) {
         caccess = atoi(row[0]);
-        if((!usermask || match(usermask, row[1])) && caccess >= min_access && caccess <= max_access) {
+        if((!usermask || !match(usermask, row[1])) && caccess >= min_access && caccess <= max_access) {
             content[0] = row[0];
             content[1] = row[1];
             is_here = 0;
@@ -103,8 +103,8 @@ static void neonserv_cmd_users_async1(struct ClientSocket *client, struct Client
     if(!content_count)
         reply(textclient, user, "NS_TABLE_NONE");
     if(usermask || min_access != 1 || max_access != 500)
-        reply(textclient, user, (table->length == 2 ? "NS_USERS_COUNT_MATCH_1" : "NS_USERS_COUNT_MATCH"), table->length - 1, chan->name, min_access, max_access, content_count);
+        reply(textclient, user, (table->length == 2 ? "NS_USERS_COUNT_MATCH_1" : "NS_USERS_COUNT_MATCH"), table->length - 1, chan->name, content_count);
     else
-        reply(textclient, user, (table->length == 2 ? "NS_USERS_COUNT_1" : "NS_USERS_COUNT"), table->length - 1, chan->name, min_access, max_access);
+        reply(textclient, user, (table->length == 2 ? "NS_USERS_COUNT_1" : "NS_USERS_COUNT"), table->length - 1, chan->name);
     table_free(table);
 }