added full half-op support
[NeonServV5.git] / src / event_neonserv_join.c
index 84845f3d9266f0626ff7e58c53d6d0e11b66e158..77d5de7519a200df297dbe939b3b691b405e8c03 100644 (file)
@@ -77,13 +77,14 @@ static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanU
     struct ChanNode *chan = chanuser->chan;
     struct UserNode *user = chanuser->user;
     struct ModeBuffer *modeBuf;
+    int with_halfops = get_int_field("General.have_halfop");
     MYSQL_RES *res;
     MYSQL_ROW row, chanuserrow, defaultrow = NULL;
-    printf_mysql_query("SELECT `channel_maxusers`, `channel_greeting`, `channel_usergreeting`, `channel_getop`, `channel_getvoice`, `channel_userinfo`, `channel_dynlimit` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
+    printf_mysql_query("SELECT `channel_maxusers`, `channel_greeting`, `channel_usergreeting`, `channel_getop`, `channel_getvoice`, `channel_userinfo`, `channel_dynlimit`, `channel_gethalfop` FROM `channels` WHERE `channel_id` = '%d'", chan->channel_id);
     res = mysql_use();
     if ((row = mysql_fetch_row(res)) == NULL) return;
-    if(!row[3] || !row[4] || !row[5]) {
-        printf_mysql_query("SELECT `channel_getop`, `channel_getvoice`, `channel_userinfo` FROM `channels` WHERE `channel_name` = 'defaults'");
+    if(!row[3] || !row[4] || !row[5] || (!row[7] && with_halfops)) {
+        printf_mysql_query("SELECT `channel_getop`, `channel_getvoice`, `channel_userinfo`, `channel_gethalfop` FROM `channels` WHERE `channel_name` = 'defaults'");
         res = mysql_use();
         defaultrow = mysql_fetch_row(res);
     }
@@ -143,10 +144,13 @@ static void neonserv_event_join_async1(struct ClientSocket *client, struct ChanU
     //USER RIGHTS
     if(!(userflags & DB_CHANUSER_NOAUTOOP)) {
         int getop = atoi((row[3] ? row[3] : defaultrow[0]));
+        int gethalfop = (with_halfops ? atoi((row[7] ? row[7] : defaultrow[3])) : 0);
         int getvoice = atoi((row[4] ? row[4] : defaultrow[1]));
         modeBuf = initModeBuffer(client, chan);
         if(uaccess >= getop && uaccess != 0) { //we disallow auto op for all users
             modeBufferOp(modeBuf, user->nick);
+        } else if(with_halfops && uaccess >= gethalfop) {
+            modeBufferHalfop(modeBuf, user->nick);
         } else if(uaccess >= getvoice) {
             modeBufferVoice(modeBuf, user->nick);
         }