4 * Automaticalyl copies the contents of a "New User Greetings" room to the
5 * inbox of any new user upon account creation.
10 * Name of the New User Greetings room.
12 #define NEWUSERGREETINGS "New User Greetings"
23 #include <sys/types.h>
25 #if TIME_WITH_SYS_TIME
26 # include <sys/time.h>
30 # include <sys/time.h>
41 #include "citserver.h"
51 #include "ctdl_module.h"
55 extern struct CitContext *ContextList;
59 * Copy the contents of the New User Greetings> room to the user's Mail> room.
61 void CopyNewUserGreetings(void) {
62 struct cdbdata *cdbfr;
65 char mailboxname[ROOMNAMELEN];
68 /* Only do this for new users. */
69 if (CC->user.timescalled != 1) return;
71 /* This user's mailbox. */
72 MailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
74 /* Go to the source room ... bail out silently if it's not there,
75 * or if it's not private.
77 if (getroom(&CC->room, NEWUSERGREETINGS) != 0) return;
78 if (! CC->room.QRflags & QR_PRIVATE ) return;
80 cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
83 msglist = malloc(cdbfr->len);
84 memcpy(msglist, cdbfr->ptr, cdbfr->len);
85 num_msgs = cdbfr->len / sizeof(long);
90 CtdlSaveMsgPointersInRoom(mailboxname, msglist, num_msgs, 1, NULL);
93 /* Now free the memory we used, and go away. */
94 if (msglist != NULL) free(msglist);
98 CTDL_MODULE_INIT(newuser)
102 CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
105 /* return our Subversion id for the Log */