]> code.citadel.org Git - citadel.git/blobdiff - citadel/user_ops.c
* fix for above
[citadel.git] / citadel / user_ops.c
index 0f05ceb6fd902c44a7c73419c3381bdc5bdbc5bd..b9cef9627601a018da8a87da14190d309e7387c7 100644 (file)
@@ -81,9 +81,6 @@ int getuser(struct usersupp *usbuf, char name[])
                sizeof(struct usersupp) : cdbus->len));
        cdb_free(cdbus);
 
-       if (usbuf->version < 573) {
-               CC->usersupp.moderation_filter = config.c_default_filter;
-       }
        return (0);
 }
 
@@ -229,6 +226,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) {
@@ -404,7 +407,7 @@ void session_startup(void)
        PerformSessionHooks(EVT_LOGIN);
 
        /* Create any personal rooms required by the system */
-       create_room(SENTITEMS, 4, "", 0, 1);
+       create_room(SENTITEMS, 4, "", 0, 1, 0);
 
        /* Enter the lobby */
        usergoto(BASEROOM, 0, NULL, NULL);
@@ -716,7 +719,6 @@ int create_user(char *newusername, int become_user)
        usbuf.USscreenwidth = 80;
        usbuf.USscreenheight = 24;
        usbuf.lastcall = time(NULL);
-       usbuf.moderation_filter = config.c_default_filter;
 
        /* fetch a new user number */
        usbuf.usernum = get_new_user_number();
@@ -729,13 +731,15 @@ int create_user(char *newusername, int become_user)
        /* add user to userlog */
        putuser(&usbuf);
 
-       /* give the user a private mailbox */
+       /* give the user a private mailbox and a configuration room */
        MailboxName(mailboxname, sizeof mailboxname, &usbuf, MAILROOM);
-       create_room(mailboxname, 5, "", 0, 1);
+       create_room(mailboxname, 5, "", 0, 1, 1);
+       MailboxName(mailboxname, sizeof mailboxname, &usbuf, USERCONFIGROOM);
+       create_room(mailboxname, 5, "", 0, 1, 1);
 
-       /*** Everything below this line can be bypassed if we are administratively
-            creating a user, instead of doing self-service account creation
-        ***/
+       /* Everything below this line can be bypassed if administratively
+          creating a user, instead of doing self-service account creation
+        */
 
        if (become_user) {
                /* Now become the user we just created */
@@ -892,12 +896,11 @@ void cmd_getu(void)
                return;
 
        getuser(&CC->usersupp, CC->curr_user);
-       cprintf("%d %d|%d|%d|%d\n",
+       cprintf("%d %d|%d|%d|\n",
                CIT_OK,
                CC->usersupp.USscreenwidth,
                CC->usersupp.USscreenheight,
-               (CC->usersupp.flags & US_USER_SET),
-               CC->usersupp.moderation_filter
+               (CC->usersupp.flags & US_USER_SET)
            );
 }
 
@@ -906,8 +909,6 @@ void cmd_getu(void)
  */
 void cmd_setu(char *new_parms)
 {
-       int new_mod;
-
        if (CtdlAccessCheck(ac_logged_in))
                return;
 
@@ -922,25 +923,6 @@ void cmd_setu(char *new_parms)
        CC->usersupp.flags = CC->usersupp.flags |
            (extract_int(new_parms, 2) & US_USER_SET);
 
-       if (num_parms(new_parms) >= 4) {
-               new_mod = extract_int(new_parms, 3);
-               lprintf(9, "new_mod extracted to %d\n", new_mod);
-
-               /* Aides cannot set the filter level lower than -100 */
-               if (new_mod < (-100))
-                       new_mod = -100;
-
-               /* Normal users cannot set the filter level lower than -63 */
-               if ((new_mod < (-63)) && (CC->usersupp.axlevel < 6))
-                       new_mod = -63;
-
-               /* Nobody can set the filter level higher than +63 */
-               if (new_mod > 63)
-                       new_mod = 63;
-
-               CC->usersupp.moderation_filter = new_mod;
-               lprintf(9, "new_mod processed to %d\n", new_mod);
-       }
        lputuser(&CC->usersupp);
        cprintf("%d Ok\n", CIT_OK);
 }
@@ -996,6 +978,19 @@ void cmd_seen(char *argbuf) {
 }
 
 
+void cmd_gtsn(char *argbuf) {
+       char buf[SIZ];
+
+       if (CtdlAccessCheck(ac_logged_in)) {
+               return;
+       }
+
+       CtdlGetSeen(buf);
+       cprintf("%d %s\n", CIT_OK, buf);
+}
+
+
+
 /*
  * INVT and KICK commands
  */
@@ -1272,7 +1267,7 @@ void cmd_chek(void)
        }
 
        /* check for mail */
-       mail = NewMailCount();
+       mail = InitialMailCheck();
 
        cprintf("%d %d|%d|%d\n", CIT_OK, mail, regis, vali);
 }
@@ -1378,43 +1373,100 @@ void cmd_asup(char *cmdbuf)
 }
 
 
+
+/*
+ * Check to see if the user who we just sent mail to is logged in.  If yes,
+ * bump the 'new mail' counter for their session.  That enables them to
+ * receive a new mail notification without having to hit the database.
+ */
+void BumpNewMailCounter(long which_user) {
+       struct CitContext *ptr;
+
+       begin_critical_section(S_SESSION_TABLE);
+
+       for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
+               if (ptr->usersupp.usernum == which_user) {
+                       ptr->newmail += 1;
+               }
+       }
+
+       end_critical_section(S_SESSION_TABLE);
+}
+
+
 /*
  * Count the number of new mail messages the user has
  */
 int NewMailCount()
 {
        int num_newmsgs = 0;
-       int a;
-       char mailboxname[ROOMNAMELEN];
-       struct quickroom mailbox;
-       struct visit vbuf;
-       struct cdbdata *cdbfr;
-       long *msglist = NULL;
-       int num_msgs = 0;
 
-       MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, MAILROOM);
-       if (getroom(&mailbox, mailboxname) != 0)
-               return (0);
-       CtdlGetRelationship(&vbuf, &CC->usersupp, &mailbox);
-
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &mailbox.QRnumber, sizeof(long));
-
-       if (cdbfr != NULL) {
-               msglist = mallok(cdbfr->len);
-               memcpy(msglist, cdbfr->ptr, cdbfr->len);
-               num_msgs = cdbfr->len / sizeof(long);
-               cdb_free(cdbfr);
-       }
-       if (num_msgs > 0)
-               for (a = 0; a < num_msgs; ++a) {
-                       if (msglist[a] > 0L) {
-                               if (msglist[a] > vbuf.v_lastseen) {
-                                       ++num_newmsgs;
-                               }
-                       }
-               }
-       if (msglist != NULL)
-               phree(msglist);
+       num_newmsgs = CC->newmail;
+       CC->newmail = 0;
 
        return (num_newmsgs);
 }
+
+
+/*
+ * Count the number of new mail messages the user has
+ */
+int InitialMailCheck()
+{
+        int num_newmsgs = 0;
+        int a;
+        char mailboxname[ROOMNAMELEN];
+        struct quickroom mailbox;
+        struct visit vbuf;
+        struct cdbdata *cdbfr;
+        long *msglist = NULL;
+        int num_msgs = 0;
+
+        MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, MAILROOM);
+        if (getroom(&mailbox, mailboxname) != 0)
+                return (0);
+        CtdlGetRelationship(&vbuf, &CC->usersupp, &mailbox);
+
+        cdbfr = cdb_fetch(CDB_MSGLISTS, &mailbox.QRnumber, sizeof(long));
+
+        if (cdbfr != NULL) {
+                msglist = mallok(cdbfr->len);
+                memcpy(msglist, cdbfr->ptr, cdbfr->len);
+                num_msgs = cdbfr->len / sizeof(long);
+                cdb_free(cdbfr);
+        }
+        if (num_msgs > 0)
+                for (a = 0; a < num_msgs; ++a) {
+                        if (msglist[a] > 0L) {
+                                if (msglist[a] > vbuf.v_lastseen) {
+                                        ++num_newmsgs;
+                                }
+                        }
+                }
+        if (msglist != NULL)
+                phree(msglist);
+
+        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);
+}