CtdlCheckExpress() now accepts a session context.
[citadel.git] / citadel / server / room_ops.c
index f61e1f12668b96577fa1c1cef0aafea63dba8821..d6288c9871b65db59537e0dd8c83493d40c00773 100644 (file)
@@ -1,6 +1,6 @@
 // Server functions which perform operations on room objects.
 //
-// Copyright (c) 1987-2023 by the citadel.org team
+// Copyright (c) 1987-2024 by the citadel.org team
 //
 // This program is open source software; you can redistribute it and/or modify
 // it under the terms of the GNU General Public License, version 3.
@@ -212,14 +212,12 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf, int *res
                        retval = retval | UA_REPLYALLOWED;
                }
 
-               // If "collaborative deletion" is active for this room, any user who can post
-               // is also allowed to delete
+               // If "collaborative deletion" is active for this room, any user who can post is also allowed to delete
                if (roombuf->QRflags2 & QR2_COLLABDEL) {
                        if (retval & UA_POSTALLOWED) {
                                retval = retval | UA_DELETEALLOWED;
                        }
                }
-
        }
 
        // Check to see if the user has forgotten this room
@@ -341,7 +339,9 @@ int CtdlGetRoom(struct ctdlroom *qrbuf, const char *room_name) {
 int CtdlGetRoomLock(struct ctdlroom *qrbuf, const char *room_name) {
        register int retval;
        retval = CtdlGetRoom(qrbuf, room_name);
-       if (retval == 0) begin_critical_section(S_ROOMS);
+       if (retval == 0) {
+               begin_critical_section(S_ROOMS);
+       }
        return(retval);
 }
 
@@ -383,6 +383,7 @@ void b_deleteroom(char *room_name) {
 void CtdlPutRoomLock(struct ctdlroom *qrbuf) {
        CtdlPutRoom(qrbuf);
        end_critical_section(S_ROOMS);
+       //syslog(LOG_ERR, "\033[32mCtdlGetRoomLock(%p) released\033[0m", CC);
 }
 
 
@@ -468,7 +469,7 @@ struct floor *CtdlGetCachedFloor(int floor_num) {
                for (i=0; i<MAXFLOORS; ++i) {
                        floorcache[floor_num] = NULL;
                }
-       initialized = 1;
+               initialized = 1;
        }
        if (floorcache[floor_num] == NULL) {
                fetch_new = 1;
@@ -500,9 +501,7 @@ void CtdlPutFloor(struct floor *flbuf, int floor_num) {
                memcpy(floorcache[floor_num], flbuf, sizeof(struct floor));
        }
        end_critical_section(S_FLOORCACHE);
-
-       cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
-                 flbuf, sizeof(struct floor));
+       cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int), flbuf, sizeof(struct floor));
 }
 
 
@@ -757,7 +756,7 @@ void CtdlUserGoto(char *where, int display_result, int transiently, int *retmsgs
 
        if (display_result) {
                cprintf("%d%c%s|%d|%d|%d|%d|%ld|%ld|%d|%d|%d|%d|%d|%d|%d|%d|%ld|\n",
-                       CIT_OK, CtdlCheckExpress(),
+                       CIT_OK, CtdlCheckExpress(CC),
                        truncated_roomname,
                        (int)new_messages,
                        (int)total_messages,
@@ -886,17 +885,6 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
                qrbuf.QRfloor = new_floor;
                CtdlPutRoom(&qrbuf);
 
-               begin_critical_section(S_CONFIG);
-       
-               // If baseroom/aideroom name changes, update config
-               if (!strncasecmp(old_name, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)) {
-                       CtdlSetConfigStr("c_baseroom", new_name);
-               }
-               if (!strncasecmp(old_name, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN)) {
-                       CtdlSetConfigStr("c_aideroom", new_name);
-               }
-       
-               end_critical_section(S_CONFIG);
        
                // If the room name changed, then there are now two room
                // records, so we have to delete the old one.
@@ -909,6 +897,16 @@ int CtdlRenameRoom(char *old_name, char *new_name, int new_floor) {
 
        end_critical_section(S_ROOMS);
 
+       // If baseroom/aideroom name changes, update config
+       begin_critical_section(S_CONFIG);
+       if (!strncasecmp(old_name, CtdlGetConfigStr("c_baseroom"), ROOMNAMELEN)) {
+               CtdlSetConfigStr("c_baseroom", new_name);
+       }
+       if (!strncasecmp(old_name, CtdlGetConfigStr("c_aideroom"), ROOMNAMELEN)) {
+               CtdlSetConfigStr("c_aideroom", new_name);
+       }
+       end_critical_section(S_CONFIG);
+
        // Adjust the floor reference counts if necessary
        if (new_floor != old_floor) {
                lgetfloor(&flbuf, old_floor);