]> code.citadel.org Git - citadel.git/commitdiff
* Added support for a "New User Greetings" room. See docs/install.txt
authorArt Cancro <ajc@citadel.org>
Thu, 21 Nov 2002 05:38:14 +0000 (05:38 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 21 Nov 2002 05:38:14 +0000 (05:38 +0000)
citadel/ChangeLog
citadel/Makefile.in
citadel/docs/install.txt
citadel/serv_calendar.c
citadel/serv_newuser.c [new file with mode: 0644]
citadel/user_ops.c

index 1f802ec7034451e55866245da94a81e44ee74be0..dd19388638eed0d67dc6c322ec38923840733a41 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 601.69  2002/11/21 05:38:13  ajc
+ * Added support for a "New User Greetings" room.  See docs/install.txt
+
  Revision 601.68  2002/11/15 11:24:40  error
  * serv_rwho.c: cmd_rwho(): move logged_in from param 8 to param 11
    (see RWHO in techdoc/session.txt)
@@ -4221,3 +4224,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 6e65f962de3f2ea4274bc5b5f427c282a9bc0236..bde78f4cd36aed526e88c5f362904a4b3ebde585 100644 (file)
@@ -35,6 +35,7 @@ SERV_MODULES=modules/libchat.la modules/libvcard.la \
        modules/libnetwork.la \
        modules/liblistsub.la \
        modules/libnetfilter.la \
+       modules/libnewuser.la \
        modules/libpas2.la \
        modules/libinetcfg.la \
        modules/librwho.la \
@@ -82,7 +83,7 @@ SOURCES=aidepost.c citadel.c citmail.c citserver.c client_chat.c \
        logging.c messages.c msgbase.c msgform.c serv_spam.c \
        policy.c readlog.c migratenet.c screen.c serv_mrtg.c \
        room_ops.c rooms.c routines.c routines2.c serv_chat.c serv_crypto.c \
-       serv_test.c setup.c snprintf.c stats.c serv_vcard.c \
+       serv_test.c setup.c snprintf.c stats.c serv_vcard.c serv_newuser.c \
        support.c sysdep.c tools.c user_ops.c userlist.c serv_expire.c \
        whobbs.c sendcommand.c mime_parser.c base64.c getutline.c \
        auth.c chkpwd.c html.c vcard.c serv_upgrade.c serv_vandelay.c \
@@ -192,6 +193,9 @@ modules/liblistsub.la: serv_listsub.lo $(LIBTOOL) libcitserver.la
 modules/libnetfilter.la: serv_netfilter.lo $(LIBTOOL) libcitserver.la
        $(LTSHARE) -o libnetfilter.la ../serv_netfilter.lo ../libcitserver.la
 
+modules/libnewuser.la: serv_newuser.lo $(LIBTOOL) libcitserver.la
+       $(LTSHARE) -o libnewuser.la ../serv_newuser.lo ../libcitserver.la
+
 modules/libupgrade.la: serv_upgrade.lo $(LIBTOOL) libcitserver.la
        $(LTSHARE) -o libupgrade.la ../serv_upgrade.lo ../libcitserver.la
 
index eb6ef5010dd0a1b4ff2236d177e925c776a17f90..3af011b50775d75d2589f02b9004eec9fd7b4f43 100644 (file)
@@ -334,8 +334,27 @@ user account to be created will automatically be set to access level 6
 (Aide).  This overcomes some obvious logistical problems - normally, Aide
 access is given by another Aide, but since there aren't any on your system
 yet, this isn't possible.
+ WELCOMING NEW USERS
+   Sometimes you might decide that you want a welcome message (or several
+different messages) automatically mailed to new users upon their first login.
+Now there is a way to do this.  If you create a room called
+"New User Greetings", and it is a *private* room (invitation-only probably
+makes the most sense), any messages you enter into that room will automatically
+be delivered to all new users upon registration.
+   You can put anything you want there: a welcome message, system policies,
+special information, etc.  You can also put as many messages there as you
+want to (although it really doesn't make sense to clutter new users' mailboxes
+with lots of junk).
+   Don't worry about wasting disk space, either.  Citadel has a single-instance
+message store, so all the new users are actually looking at the same copy of
+the message on disk.
+     
     
-   
  SPACE FOR ADDING YOUR OWN FEATURES (doors)
  
    *** PLEASE TAKE NOTE!! ***   This function really represents the "old"
index 2ffeae7d8b213b715c91b8695e98d221c75546ca..350b8abdb5defb03b3b1e94cfefebd20a444b3ee 100644 (file)
@@ -116,6 +116,8 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
        char attendee_string[SIZ];
        icalproperty *organizer = NULL;
        char organizer_string[SIZ];
+       icalproperty *summary = NULL;
+       char summary_string[SIZ];
        icalproperty *me_attend = NULL;
        struct recptypes *recp = NULL;
        icalparameter *partstat = NULL;
@@ -125,6 +127,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
        struct recptypes *valid = NULL;
 
        strcpy(organizer_string, "");
+       strcpy(summary_string, "Calendar item");
 
        if (request == NULL) {
                lprintf(3, "ERROR: trying to reply to NULL event?\n");
@@ -204,6 +207,18 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
                } else {
                        strcpy(organizer_string, "");
                }
+
+               /* Extract the summary string -- we'll use it as the
+                * message subject for the reply
+                */
+               summary = icalcomponent_get_first_property(vevent, ICAL_SUMMARY_PROPERTY);
+               if (summary != NULL) {
+                       if (icalproperty_get_summary(summary)) {
+                               strcpy(summary_string,
+                                       icalproperty_get_summary(summary) );
+                       }
+               }
+
        }
 
        /* Now generate the reply message and send it out. */
@@ -220,7 +235,9 @@ void ical_send_a_reply(icalcomponent *request, char *action) {
 
                msg = CtdlMakeMessage(&CC->usersupp, organizer_string,
                        CC->quickroom.QRname, 0, FMT_RFC822,
-                       "", "FIXME subject", reply_message_text);
+                       "",
+                       summary_string,         /* Use summary for subject */
+                       reply_message_text);
        
                if (msg != NULL) {
                        valid = validate_recipients(organizer_string);
diff --git a/citadel/serv_newuser.c b/citadel/serv_newuser.c
new file mode 100644 (file)
index 0000000..b2f27ea
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * $Id$
+ *
+ * A skeleton module to test the dynamic loader.
+ *
+ */
+
+/*
+ * Name of the New User Greetings room.
+ */
+#define NEWUSERGREETINGS       "New User Greetings"
+
+
+#include "sysdep.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <pwd.h>
+#include <errno.h>
+#include <sys/types.h>
+
+#if TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# if HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#include <sys/wait.h>
+#include <string.h>
+#include <limits.h>
+#include "citadel.h"
+#include "server.h"
+#include "sysdep_decls.h"
+#include "citserver.h"
+#include "support.h"
+#include "config.h"
+#include "dynloader.h"
+#include "room_ops.h"
+#include "user_ops.h"
+#include "policy.h"
+#include "database.h"
+#include "msgbase.h"
+
+extern struct CitContext *ContextList;
+
+
+/*
+ * Copy the contents of the New User Greetings> room to the user's Mail> room.
+ */
+void CopyNewUserGreetings(void) {
+       struct cdbdata *cdbfr;
+       long *msglist = NULL;
+       int num_msgs = 0;
+       int i;
+       char mailboxname[ROOMNAMELEN];
+
+
+       /* Only do this for new users. */
+       if (CC->usersupp.timescalled != 1) return;
+
+       /* This user's mailbox. */
+       MailboxName(mailboxname, sizeof mailboxname, &CC->usersupp, 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;
+
+       cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->quickroom.QRnumber, sizeof(long));
+
+       if (cdbfr != NULL) {
+               msglist = mallok(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);
+               }
+       }
+
+       /* Now free the memory we used, and go away. */
+       if (msglist != NULL) phree(msglist);
+}
+
+
+char *Dynamic_Module_Init(void)
+{
+   CtdlRegisterSessionHook(CopyNewUserGreetings, EVT_LOGIN);
+   return "$Id$";
+}
index 4e0146df8a809673c59c151e89daa9abce3473f7..2215f58e027da3dff571caf09925df51cfa130b3 100644 (file)
@@ -403,15 +403,15 @@ void session_startup(void)
        }
        lputuser(&CC->usersupp);
 
-       /* Run any startup routines registered by loadable modules */
-       PerformSessionHooks(EVT_LOGIN);
-
        /* Create any personal rooms required by the system.
         * (Technically, MAILROOM should be there already, but just in case...)
         */
        create_room(MAILROOM, 4, "", 0, 1, 0);
        create_room(SENTITEMS, 4, "", 0, 1, 0);
 
+       /* Run any startup routines registered by loadable modules */
+       PerformSessionHooks(EVT_LOGIN);
+
        /* Enter the lobby */
        usergoto(config.c_baseroom, 0, 0, NULL, NULL);