4 * Automatically copies the contents of a "New User Greetings" room to the
5 * inbox of any new user upon account creation.
7 * Copyright (c) 1987-2010 by the citadel.org team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 * Name of the New User Greetings room.
27 #define NEWUSERGREETINGS "New User Greetings"
38 #include <sys/types.h>
40 #if TIME_WITH_SYS_TIME
41 # include <sys/time.h>
45 # include <sys/time.h>
55 #include "ctdl_module.h"
59 #include "citserver.h"
72 * Copy the contents of the New User Greetings> room to the user's Mail> room.
74 void CopyNewUserGreetings(void) {
75 struct cdbdata *cdbfr;
78 char mailboxname[ROOMNAMELEN];
81 /* Only do this for new users. */
82 if (CC->user.timescalled != 1) return;
84 /* This user's mailbox. */
85 CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
87 /* Go to the source room ... bail out silently if it's not there,
88 * or if it's not private.
90 if (CtdlGetRoom(&CC->room, NEWUSERGREETINGS) != 0) return;
91 if ((CC->room.QRflags & QR_PRIVATE) == 0) return;
93 cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
96 msglist = malloc(cdbfr->len);
97 memcpy(msglist, cdbfr->ptr, cdbfr->len);
98 num_msgs = cdbfr->len / sizeof(long);
103 CtdlSaveMsgPointersInRoom(mailboxname, msglist, num_msgs, 1, NULL, 0);
106 /* Now free the memory we used, and go away. */
107 if (msglist != NULL) free(msglist);
111 CTDL_MODULE_INIT(newuser)
115 CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
118 /* return our Subversion id for the Log */