]> code.citadel.org Git - citadel.git/blobdiff - citadel/room_ops.c
* WHOK: ommit empty lines.
[citadel.git] / citadel / room_ops.c
index 83d68a3475afe609a1aab40e2bbe9107e8d2fabf..68eeb36385971435d6f9e2accc12de4f29cd7d04 100644 (file)
@@ -52,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)) {
@@ -60,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)) {
@@ -125,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;
@@ -135,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;
                        }
@@ -671,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);
@@ -709,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);
@@ -778,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);
@@ -817,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);
@@ -856,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);
@@ -1077,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);
@@ -1170,9 +1177,10 @@ void cmd_whok(char *cmdbuf)
                cdb_free(cdbus);
 
                CtdlRoomAccess(&CC->room, &temp, &ra, NULL);
-               if ((CC->room.QRflags & QR_INUSE)
-                   && (ra & UA_KNOWN)
-                   )
+               if ((!IsEmptyStr(temp.fullname)) && 
+                   (CC->room.QRflags & QR_INUSE) &&
+                   (ra & UA_KNOWN)
+                       )
                        cprintf("%s\n", temp.fullname);
        }
        cprintf("000\n");