Removed the old CtdlSaveMsgPointerInRoom() API. Everything now
[citadel.git] / citadel / serv_newuser.c
index b2f27eae6f40179253a417f6107b4f3ce825144e..da223f59fb6b1d9cf41d89c7c46eecd9bc1841b6 100644 (file)
@@ -1,7 +1,8 @@
 /*
  * $Id$
  *
- * A skeleton module to test the dynamic loader.
+ * Automaticalyl copies the contents of a "New User Greetings" room to the
+ * inbox of any new user upon account creation.
  *
  */
 
@@ -41,7 +42,7 @@
 #include "citserver.h"
 #include "support.h"
 #include "config.h"
-#include "dynloader.h"
+#include "serv_extensions.h"
 #include "room_ops.h"
 #include "user_ops.h"
 #include "policy.h"
@@ -63,38 +64,36 @@ void CopyNewUserGreetings(void) {
 
 
        /* Only do this for new users. */
-       if (CC->usersupp.timescalled != 1) return;
+       if (CC->user.timescalled != 1) return;
 
        /* This user's mailbox. */
-       MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, MAILROOM);
+       MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
 
        /* Go to the source room ... bail out silently if it's not there,
         * or if it's not private.
         */
-       if (getroom(&CC->quickroom, NEWUSERGREETINGS) != 0) return;
-       if (! CC->quickroom.QRflags & QR_PRIVATE ) return;
+       if (getroom(&CC->room, NEWUSERGREETINGS) != 0) return;
+       if (! CC->room.QRflags & QR_PRIVATE ) return;
 
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->quickroom.QRnumber, sizeof(long));
+       cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
 
        if (cdbfr != NULL) {
-               msglist = mallok(cdbfr->len);
+               msglist = malloc(cdbfr->len);
                memcpy(msglist, cdbfr->ptr, cdbfr->len);
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
        }
 
        if (num_msgs > 0) {
-               for (i = 0; i < num_msgs; ++i) {
-                       CtdlCopyMsgToRoom(msglist[i], mailboxname);
-               }
+               CtdlCopyMsgsToRoom(msglist, num_msgs, mailboxname);
        }
 
        /* Now free the memory we used, and go away. */
-       if (msglist != NULL) phree(msglist);
+       if (msglist != NULL) free(msglist);
 }
 
 
-char *Dynamic_Module_Init(void)
+char *serv_newuser_init(void)
 {
    CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
    return "$Id$";