Editing of account email addresses using the new server commands in WebCit-classic.
authorArt Cancro <ajc@citadel.org>
Mon, 10 Jul 2017 03:34:01 +0000 (23:34 -0400)
committerArt Cancro <ajc@citadel.org>
Mon, 10 Jul 2017 03:34:01 +0000 (23:34 -0400)
This completes the transition.

webcit/crypto.c
webcit/ical_dezonify.c
webcit/static/t/aide/edituser/detailview.html
webcit/tcp_sockets.c
webcit/useredit.c
webcit/webserver.c

index 6925dfa8f362eccce3bab46133b8eb85fa3ee369..427b4d93e7268dadb52c5f97e25b746e30a4f809 100644 (file)
@@ -85,7 +85,7 @@ void init_ssl(void)
                for (a = 0; a < CRYPTO_num_locks(); a++) {
                        SSLCritters[a] = malloc(sizeof(pthread_mutex_t));
                        if (!SSLCritters[a]) {
-                               syslog(LOG_EMERG,
+                               syslog(LOG_ERR,
                                        "citserver: can't allocate memory!!\n");
                                /** Nothing's been initialized, just die */
                                ShutDownWebcit();
index 935ae74dcaa8fc9bfeefd432564e932ae18290d5..537bcc3e15770937187811de6e987baa6918767d 100644 (file)
@@ -28,7 +28,7 @@ icaltimezone *get_default_icaltimezone(void) {
                 zone = icaltimezone_get_utc_timezone();
        }
        if (!zone) {
-               syslog(LOG_EMERG, "Unable to load UTC time zone!\n");
+               syslog(LOG_ERR, "Unable to load UTC time zone!\n");
        }
         return zone;
 }
index a8da87fd65ef5dabc1fbe8bb0f10810e4d58ec7a..b5695ddd8f89e1d5a8ef0cd2ae0076c7d8579cb2 100644 (file)
             <td><?_("Permission to send Internet mail")></td>
             <td><input type="checkbox" name="inetmail" value="yes" <?%("COND:USERLIST:FLAG:USE_INTERNET", 1, 1, 1, "checked", "")>></td>
           </tr>
+          <tr>
+            <td><?_("Primary Internet e-mail address")></td>
+            <td><input type="text" name="primaryemail" value="<?USERLIST:PRIMARYEMAIL("X")>" maxlength="63"></td>
+          </tr>
+          <tr>
+            <td><?_("Internet e-mail aliases")></td>
+            <td><input type="text" name="otheremails" value="<?USERLIST:OTHEREMAILS("X")>" maxlength="512"></td>
+          </tr>
           <tr>
             <td><?_("Number of logins")></td>
             <td><input type="text" name="timescalled" value="<?USERLIST:NLOGONS>" maxlength="6"></td>
index 2f969242ec6df4e98ebc971e61fb0fafd6fa89d7..f8705872ca938cc76892d9c20064aecafe77dd9d 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2017 by the citadel.org team
  *
  * This program is open source software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License, version 3.
@@ -293,12 +293,12 @@ void FlushReadBuf (void)
                pche = pch + len;
                if (WCC->ReadPos != pche)
                {
-                       syslog(LOG_EMERG,
+                       syslog(LOG_ERR,
                                "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", 
                                (long)(pche - WCC->ReadPos),
                                pche
                        );
-                       syslog(LOG_EMERG
+                       syslog(LOG_ERR
                                "--------------------------------------------------------------------------------\n"
                                "Whole buf: [%s]\n"
                                "--------------------------------------------------------------------------------\n", 
@@ -901,13 +901,13 @@ retry:
        }
 
        if (b < 0) {
-               syslog(LOG_EMERG, "Can't bind: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Can't bind: %s\n", strerror(errno));
                close(s);
                return (-WC_EXIT_BIND);
        }
 
        if (listen(s, queue_len) < 0) {
-               syslog(LOG_EMERG, "Can't listen: %s\n", strerror(errno));
+               syslog(LOG_ERR, "Can't listen: %s\n", strerror(errno));
                close(s);
                return (-WC_EXIT_BIND);
        }
index e0ac08f01d263be1b35b21657be84b568b14ed56..af6a022760fe7e9400ac3580b535244961d47698 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996-2012 by the citadel.org team
+ * Copyright (c) 1996-2017 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
  * modify it under the terms of the GNU General Public License, version 3.
@@ -40,6 +40,10 @@ typedef struct _UserListEntry {
        unsigned int Flags;
        int DaysTillPurge;
        int HasBio;
+
+       StrBuf *PrimaryEmail;
+       StrBuf *OtherEmails;
+
 } UserListEntry;
 
 
@@ -53,6 +57,8 @@ UserListEntry* NewUserListOneEntry(StrBuf *SerializedUser, const char *Pos)
        ul = (UserListEntry*) malloc(sizeof(UserListEntry));
        ul->UserName = NewStrBuf();
        ul->Passvoid = NewStrBuf();
+       ul->PrimaryEmail = NewStrBuf();
+       ul->OtherEmails = NewStrBuf();
 
        StrBufExtract_NextToken(ul->UserName,               SerializedUser, &Pos, '|');
        StrBufExtract_NextToken(ul->Passvoid,               SerializedUser, &Pos, '|');
@@ -72,6 +78,8 @@ void DeleteUserListEntry(void *vUserList)
        if (!ul) return;
        FreeStrBuf(&ul->UserName);
        FreeStrBuf(&ul->Passvoid);
+       FreeStrBuf(&ul->PrimaryEmail);
+       FreeStrBuf(&ul->OtherEmails);
        free(ul);
 }
 
@@ -86,6 +94,8 @@ UserListEntry* NewUserListEntry(StrBuf *SerializedUserList)
        ul = (UserListEntry*) malloc(sizeof(UserListEntry));
        ul->UserName = NewStrBuf();
        ul->Passvoid = NewStrBuf();
+       ul->PrimaryEmail = NewStrBuf();
+       ul->OtherEmails = NewStrBuf();
 
        StrBufExtract_NextToken(ul->UserName,    SerializedUserList, &Pos, '|');
        ul->AccessLevel = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
@@ -302,9 +312,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
                        Done = 0;
                        while (!Done) {
                        len = StrBuf_ServGetln(Buf);
-                       if ((len <0) || 
-                           ((len == 3) &&
-                            !strcmp(ChrPtr(Buf), "000")))
+                       if ((len <0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000")))
                        {
                                Done = 1;
                                break;
@@ -340,6 +348,18 @@ void tmplput_USERLIST_Password(StrBuf *Target, WCTemplputParams *TP)
        StrBufAppendTemplate(Target, TP, ul->Passvoid, 0);
 }
 
+void tmplput_USERLIST_PrimaryEmail(StrBuf *Target, WCTemplputParams *TP)
+{
+       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+       StrBufAppendTemplate(Target, TP, ul->PrimaryEmail, 0);
+}
+
+void tmplput_USERLIST_OtherEmails(StrBuf *Target, WCTemplputParams *TP)
+{
+       UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+       StrBufAppendTemplate(Target, TP, ul->OtherEmails, 0);
+}
+
 void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, WCTemplputParams *TP)
 {
        UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
@@ -643,6 +663,7 @@ void display_edituser(const char *supplied_username, int is_new) {
        UserListEntry* UL;
        StrBuf *Buf;
        char username[256];
+       int i = 0;
 
        if (supplied_username != NULL) {
                safestrncpy(username, supplied_username, sizeof username);
@@ -669,6 +690,24 @@ void display_edituser(const char *supplied_username, int is_new) {
                        delete_user(username);
                }
                else if (UL != NULL) {
+
+                       serv_printf("AGEA %s", username);
+                       StrBuf_ServGetln(Buf);
+                       if (GetServerStatusMsg(Buf, NULL, 1, 2) == 1) {
+                               while(StrBuf_ServGetln(Buf) , strcmp(ChrPtr(Buf), "000")) {
+                                       if (i == 0) {
+                                               StrBufAppendPrintf(UL->PrimaryEmail, "%s", ChrPtr(Buf));
+                                       }
+                                       if (i > 1) {
+                                               StrBufAppendPrintf(UL->OtherEmails, ",");
+                                       }
+                                       if (i > 0) {
+                                               StrBufAppendPrintf(UL->OtherEmails, "%s", ChrPtr(Buf));
+                                       }
+                                       ++i;
+                               }
+                       }
+
                        WCTemplputParams SubTP;
                        memset(&SubTP, 0, sizeof(WCTemplputParams));
                        SubTP.Filter.ContextType = CTX_USERLIST;
@@ -716,6 +755,7 @@ void edituser(void) {
                        }
                }
 
+               /* Send the new account parameters */
                serv_printf("ASUP %s|%s|%d|%s|%s|%s|%s|%s|%s|",
                        username,
                        bstr("password"),
@@ -729,6 +769,36 @@ void edituser(void) {
                );
                StrBuf_ServGetln(Buf);
                GetServerStatusMsg(Buf, NULL, 1, 2);
+
+               /* Send the new email addresses.  First make up a delimited list... */
+               char all_the_emails[512];
+               snprintf(all_the_emails, sizeof all_the_emails, "%s,%s", bstr("primaryemail"), bstr("otheremails"));
+
+               /* Replace any commas, semicolons, or spaces with newlines */
+               char *pos;
+               for (pos=all_the_emails; *pos!=0; ++pos) {
+                       if ((*pos == ',') || (*pos == ';') || (*pos == ' ')) *pos = '\n' ;
+               }
+
+               /* Remove any naughty inappropriate whitespace */
+               striplt(all_the_emails);
+               while (pos = strstr(all_the_emails, "\n,"), (pos != NULL)) {
+                       strcpy(pos, pos+1);
+               }
+               while (pos = strstr(all_the_emails, ",\n"), (pos != NULL)) {
+                       strcpy(pos+1, pos+2);
+               }
+               while (pos = strstr(all_the_emails, "\n\n"), (pos != NULL)) {
+                       strcpy(pos+1, pos+2);
+               }
+
+               /* Now send it to the server. */
+               serv_printf("ASEA %s", username);
+               StrBuf_ServGetln(Buf);
+               if (GetServerStatusMsg(Buf, NULL, 1, 2) == 4) {
+                       serv_printf("%s\n000", all_the_emails);
+               }
+
                FreeStrBuf(&Buf);
        }
 
@@ -830,7 +900,8 @@ InitModule_USEREDIT
        RegisterNamespace("USERLIST:LASTLOGON:NO",  0, 0, tmplput_USERLIST_LastLogonNo, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:NLOGONS",       0, 0, tmplput_USERLIST_nLogons, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:NPOSTS",        0, 0, tmplput_USERLIST_nPosts, NULL, CTX_USERLIST);
-                                                   
+       RegisterNamespace("USERLIST:PRIMARYEMAIL",  0, 1, tmplput_USERLIST_PrimaryEmail, NULL, CTX_USERLIST);
+       RegisterNamespace("USERLIST:OTHEREMAILS",   0, 1, tmplput_USERLIST_OtherEmails, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:FLAGS",         0, 0, tmplput_USERLIST_Flags, NULL, CTX_USERLIST);
        RegisterNamespace("USERLIST:DAYSTILLPURGE", 0, 0, tmplput_USERLIST_DaysTillPurge, NULL, CTX_USERLIST);
 
index 0ea5e3fe896b54e1902520e967e00836cfa505f3..e0e6e403bb4389eb750cd211973934d6d50a025e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996-2016 by the citadel.org team
+ * Copyright (c) 1996-2017 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
  * modify it under the terms of the GNU General Public License version 3.
@@ -234,7 +234,7 @@ int main(int argc, char **argv)
 
        /* Tell 'em who's in da house */
        syslog(LOG_NOTICE, "%s", PACKAGE_STRING);
-       syslog(LOG_NOTICE, "Copyright (C) 1996-2016 by the citadel.org team");
+       syslog(LOG_NOTICE, "Copyright (C) 1996-2017 by the citadel.org team");
        syslog(LOG_NOTICE, " ");
        syslog(LOG_NOTICE, "This program is open source software: you can redistribute it and/or");
        syslog(LOG_NOTICE, "modify it under the terms of the GNU General Public License, version 3.");
@@ -283,7 +283,7 @@ int main(int argc, char **argv)
         * wcsession struct to which the thread is currently bound.
         */
        if (pthread_key_create(&MyConKey, NULL) != 0) {
-               syslog(LOG_EMERG, "Can't create TSD key: %s", strerror(errno));
+               syslog(LOG_ERR, "Can't create TSD key: %s", strerror(errno));
        }
        InitialiseSemaphores();
 
@@ -295,7 +295,7 @@ int main(int argc, char **argv)
         */
 #ifdef HAVE_OPENSSL
        if (pthread_key_create(&ThreadSSL, NULL) != 0) {
-               syslog(LOG_EMERG, "Can't create TSD key: %s", strerror(errno));
+               syslog(LOG_ERR, "Can't create TSD key: %s", strerror(errno));
        }
 #endif