changed cmd_users output
[NeonServV5.git] / DBHelper.c
index ce43cc025699f779d03c8c09b967afe0b61b94ad..7d22a816f2805e79f56f71de1d3050b0a852d8f0 100644 (file)
@@ -56,15 +56,25 @@ int getChannelAccess(struct UserNode *user, struct ChanNode *chan, int override)
     return 0;
 }
 
+char *getChanDefault(char *channel_setting) {
+    MYSQL_RES *res;
+    MYSQL_ROW row;
+    printf_mysql_query("SELECT `%s` FROM `channels` WHERE `channel_name` = 'defaults'", channel_setting);
+    res = mysql_use();
+    if ((row = mysql_fetch_row(res)) == NULL) return "";
+    return row[0];
+}
+
 int checkChannelAccess(struct UserNode *user, struct ChanNode *chan, char *channel_setting, int allow_override, int allow_501) {
     loadChannelSettings(chan);
     if(!(chan->flags & CHANFLAG_CHAN_REGISTERED)) return 0;
+    if((user->flags & USERFLAG_ISIRCOP)) return 1;
     MYSQL_RES *res;
     MYSQL_ROW row;
     printf_mysql_query("SELECT `%s` FROM `channels` WHERE `channel_id` = '%d'", channel_setting, chan->channel_id);
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) == NULL) return 0;
-    int require_access = atoi(row[0]);
+    int require_access = atoi((row[0] ? row[0] : getChanDefault(channel_setting)));
     if(require_access == 0) return 1;
     if(!(user->flags & USERFLAG_ISAUTHED)) return 0;
     int caccess = 0;