4 * Automaticalyl copies the contents of a "New User Greetings" room to the
5 * inbox of any new user upon account creation.
7 * Copyright (c) 1987-2009 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"
73 * Copy the contents of the New User Greetings> room to the user's Mail> room.
75 void CopyNewUserGreetings(void) {
76 struct cdbdata *cdbfr;
79 char mailboxname[ROOMNAMELEN];
82 /* Only do this for new users. */
83 if (CC->user.timescalled != 1) return;
85 /* This user's mailbox. */
86 CtdlMailboxName(mailboxname, sizeof mailboxname, &CC->user, MAILROOM);
88 /* Go to the source room ... bail out silently if it's not there,
89 * or if it's not private.
91 if (CtdlGetRoom(&CC->room, NEWUSERGREETINGS) != 0) return;
92 if (! CC->room.QRflags & QR_PRIVATE ) return;
94 cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
97 msglist = malloc(cdbfr->len);
98 memcpy(msglist, cdbfr->ptr, cdbfr->len);
99 num_msgs = cdbfr->len / sizeof(long);
104 CtdlSaveMsgPointersInRoom(mailboxname, msglist, num_msgs, 1, NULL);
107 /* Now free the memory we used, and go away. */
108 if (msglist != NULL) free(msglist);
112 CTDL_MODULE_INIT(newuser)
116 CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
119 /* return our Subversion id for the Log */