]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
Allow MSGS command to operate in guest mode.
[citadel.git] / citadel / room_ops.c
index 25d335220fd1eb5d4de9b82155873e84dbd58cd3..053971a6043e5677a3ca3b1224540c69179dd6ca 100644 (file)
@@ -1,6 +1,4 @@
 /* 
- * $Id$
- * 
  * Server functions which perform operations on room objects.
  *
  */
@@ -54,6 +52,16 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
 {
        int retval = 0;
        visit vbuf;
+       int is_me = 0;
+       int is_guest = 0;
+
+       if (userbuf == &CC->user) {
+               is_me = 1;
+       }
+
+       if ((is_me) && (config.c_guest_logins) && (!CC->logged_in)) {
+               is_guest = 1;
+       }
 
        /* for internal programs, always do everything */
        if (((CC->internal_pgm)) && (roombuf->QRflags & QR_INUSE)) {
@@ -62,8 +70,20 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                goto SKIP_EVERYTHING;
        }
 
+       /* If guest mode is enabled, always grant access to the Lobby */
+       if ((is_guest) && (!strcasecmp(roombuf->QRname, BASEROOM))) {
+               retval = (UA_KNOWN | UA_GOTOALLOWED);
+               vbuf.v_view = 0;
+               goto SKIP_EVERYTHING;
+       }
+
        /* Locate any applicable user/room relationships */
-       CtdlGetRelationship(&vbuf, userbuf, roombuf);
+       if (is_guest) {
+               memset(&vbuf, 0, sizeof vbuf);
+       }
+       else {
+               CtdlGetRelationship(&vbuf, userbuf, roombuf);
+       }
 
        /* Force the properties of the Aide room */
        if (!strcasecmp(roombuf->QRname, config.c_aideroom)) {
@@ -127,8 +147,8 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                 * - It is a read-only room
                 */
                int post_allowed = 1;
-               if (CC->user.axlevel < AxProbU) post_allowed = 0;
-               if ((CC->user.axlevel < AxNetU) && (CC->room.QRflags & QR_NETWORK)) post_allowed = 0;
+               if (userbuf->axlevel < AxProbU) post_allowed = 0;
+               if ((userbuf->axlevel < AxNetU) && (roombuf->QRflags & QR_NETWORK)) post_allowed = 0;
                if (roombuf->QRflags & QR_READONLY) post_allowed = 0;
                if (post_allowed) {
                        retval = retval | UA_POSTALLOWED;
@@ -137,7 +157,7 @@ void CtdlRoomAccess(struct ctdlroom *roombuf, struct ctdluser *userbuf,
                /* If "collaborative deletion" is active for this room, any user who can post
                 * is also allowed to delete
                 */
-               if (CC->room.QRflags2 & QR2_COLLABDEL) {
+               if (roombuf->QRflags2 & QR2_COLLABDEL) {
                        if (retval & UA_POSTALLOWED) {
                                retval = retval | UA_DELETEALLOWED;
                        }
@@ -673,12 +693,9 @@ void cmd_lrms(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
-       if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
-               return;
-       }
+       CtdlGetUser(&CC->user, CC->curr_user);
        cprintf("%d Accessible rooms:\n", LISTING_FOLLOWS);
 
        CtdlForEachRoom(cmd_lrms_backend, &FloorBeingSearched);
@@ -711,12 +728,9 @@ void cmd_lkra(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
-       if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
-               return;
-       }
+       CtdlGetUser(&CC->user, CC->curr_user);
        cprintf("%d Known rooms:\n", LISTING_FOLLOWS);
 
        CtdlForEachRoom(cmd_lkra_backend, &FloorBeingSearched);
@@ -780,12 +794,9 @@ void cmd_lkrn(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
-       if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
-               return;
-       }
+       CtdlGetUser(&CC->user, CC->curr_user);
        cprintf("%d Rooms w/ new msgs:\n", LISTING_FOLLOWS);
 
        CtdlForEachRoom(cmd_lkrn_backend, &FloorBeingSearched);
@@ -819,12 +830,9 @@ void cmd_lkro(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
-       if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
-               return;
-       }
+       CtdlGetUser(&CC->user, CC->curr_user);
        cprintf("%d Rooms w/o new msgs:\n", LISTING_FOLLOWS);
 
        CtdlForEachRoom(cmd_lkro_backend, &FloorBeingSearched);
@@ -858,12 +866,9 @@ void cmd_lzrm(char *argbuf)
        if (!IsEmptyStr(argbuf))
                FloorBeingSearched = extract_int(argbuf, 0);
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
        
-       if (CtdlGetUser(&CC->user, CC->curr_user)) {
-               cprintf("%d Can't locate user!\n", ERROR + INTERNAL_ERROR);
-               return;
-       }
+       CtdlGetUser(&CC->user, CC->curr_user);
        cprintf("%d Zapped rooms:\n", LISTING_FOLLOWS);
 
        CtdlForEachRoom(cmd_lzrm_backend, &FloorBeingSearched);
@@ -1079,7 +1084,7 @@ void cmd_goto(char *gargs)
        char password[32];
        int transiently = 0;
 
-       if (CtdlAccessCheck(ac_logged_in)) return;
+       if (CtdlAccessCheck(ac_logged_in_or_guest)) return;
 
        extract_token(towhere, gargs, 0, '|', sizeof towhere);
        extract_token(password, gargs, 1, '|', sizeof password);
@@ -2264,5 +2269,5 @@ CTDL_MODULE_INIT(room_ops)
                CtdlRegisterProtoHook(cmd_eflr, "EFLR", "Autoconverted. TODO: document me.");
        }
         /* return our Subversion id for the Log */
-       return "$Id$";
+       return "room_ops";
 }