2 * Automatically copies the contents of a "New User Greetings" room to the
3 * inbox of any new user upon account creation.
5 * Copyright (c) 1987-2012 by the citadel.org team
7 * This program is open source software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 3.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
23 * Name of the New User Greetings room.
25 #define NEWUSERGREETINGS "New User Greetings"
36 #include <sys/types.h>
38 #if TIME_WITH_SYS_TIME
39 # include <sys/time.h>
43 # include <sys/time.h>
53 #include "ctdl_module.h"
57 #include "citserver.h"
70 * Copy the contents of the New User Greetings> room to the user's Mail> room.
72 void CopyNewUserGreetings(void) {
73 struct cdbdata *cdbfr;
76 char mailboxname[ROOMNAMELEN];
79 /* Only do this for new users. */
80 if (CC->user.timescalled != 1) return;
82 /* This user's mailbox. */
83 CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
85 /* Go to the source room ... bail out silently if it's not there,
86 * or if it's not private.
88 if (CtdlGetRoom(&CC->room, NEWUSERGREETINGS) != 0) return;
89 if ((CC->room.QRflags & QR_PRIVATE) == 0) return;
91 cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
94 msglist = malloc(cdbfr->len);
95 memcpy(msglist, cdbfr->ptr, cdbfr->len);
96 num_msgs = cdbfr->len / sizeof(long);
101 CtdlSaveMsgPointersInRoom(mailboxname, msglist, num_msgs, 1, NULL, 0);
104 /* Now free the memory we used, and go away. */
105 if (msglist != NULL) free(msglist);
109 CTDL_MODULE_INIT(newuser)
113 CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN, PRIO_LOGIN + 1);
116 /* return our module name for the log */