* Set up the framework for different "views" of a room
[citadel.git] / citadel / user_ops.c
index 9c1ade6fb32d382863c15f4a208ad8483450f895..f5d6bd0069ea3099b7d9840b3da3568c172f5fdb 100644 (file)
@@ -229,6 +229,12 @@ void CtdlGetRelationship(struct visit *vbuf,
                        sizeof(struct visit) : cdbvisit->len));
                cdb_free(cdbvisit);
        }
+       else {
+               /* If this is the first time the user has seen this room,
+                * set the view to be the default for the room.
+                */
+               vbuf->v_view = rel_room->QRdefaultview;
+       }
 
        /* Set v_seen if necessary */
        if (vbuf->v_seen[0] == 0) {
@@ -1420,3 +1426,24 @@ int NewMailCount()
 
        return (num_newmsgs);
 }
+
+
+/*
+ * Set the preferred view for the current user/room combination
+ */
+void cmd_view(char *cmdbuf) {
+       int requested_view;
+       struct visit vbuf;
+
+       if (CtdlAccessCheck(ac_logged_in)) {
+               return;
+       }
+
+       requested_view = extract_int(cmdbuf, 0);
+
+       CtdlGetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+       vbuf.v_view = requested_view;
+       CtdlSetRelationship(&vbuf, &CC->usersupp, &CC->quickroom);
+       
+       cprintf("%d ok\n", CIT_OK);
+}