Merge branch 'configdb' of ssh://git.citadel.org/appl/gitroot/citadel
[citadel.git] / citadel / modules / vcard / serv_vcard.c
index 202c806e9d756b72451d26578fb1ab6e4766fdd7..a86127fb42ad58f529e3e427eb0d2d45eb96eddc 100644 (file)
@@ -2,7 +2,7 @@
  * A server-side module for Citadel which supports address book information
  * using the standard vCard format.
  * 
  * A server-side module for Citadel which supports address book information
  * using the standard vCard format.
  * 
- * Copyright (c) 1999-2012 by the citadel.org team
+ * Copyright (c) 1999-2015 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.
  *
  * 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.
  * set global flag calling for an aide to validate new users
  */
 void set_mm_valid(void) {
  * set global flag calling for an aide to validate new users
  */
 void set_mm_valid(void) {
+       int flags = 0;
+
        begin_critical_section(S_CONTROL);
        begin_critical_section(S_CONTROL);
-       get_control();
-       CitControl.MMflags = CitControl.MMflags | MM_VALID ;
-       put_control();
+       flags = CtdlGetConfigInt("MMflags");
+       flags = flags | MM_VALID ;
+       CtdlSetConfigInt("MMflags", flags);
        end_critical_section(S_CONTROL);
 }
 
        end_critical_section(S_CONTROL);
 }
 
@@ -385,7 +387,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
 
        /* If users cannot create their own accounts, they cannot re-register either. */
        if ( (yes_my_citadel_config) &&
 
        /* If users cannot create their own accounts, they cannot re-register either. */
        if ( (yes_my_citadel_config) &&
-            (config.c_disable_newu) &&
+            (CtdlGetConfigInt("c_disable_newu")) &&
             (CCC->user.axlevel < AxAideU) &&
             (CCC->vcard_updated_by_ldap==0) )
        {
             (CCC->user.axlevel < AxAideU) &&
             (CCC->vcard_updated_by_ldap==0) )
        {
@@ -433,7 +435,7 @@ int vcard_upload_beforesave(struct CtdlMessage *msg, recptypes *recp) {
        /* Insert or replace RFC2739-compliant free/busy URL */
        if (yes_my_citadel_config) {
                sprintf(buf, "http://%s/%s.vfb",
        /* Insert or replace RFC2739-compliant free/busy URL */
        if (yes_my_citadel_config) {
                sprintf(buf, "http://%s/%s.vfb",
-                       config.c_fqdn,
+                       CtdlGetConfigStr("c_fqdn"),
                        usbuf.fullname);
                for (i=0; buf[i]; ++i) {
                        if (buf[i] == ' ') buf[i] = '_';
                        usbuf.fullname);
                for (i=0; buf[i]; ++i) {
                        if (buf[i] == ' ') buf[i] = '_';
@@ -723,7 +725,7 @@ void cmd_regi(char *argbuf) {
        }
 
        /* If users cannot create their own accounts, they cannot re-register either. */
        }
 
        /* If users cannot create their own accounts, they cannot re-register either. */
-       if ( (config.c_disable_newu) && (CCC->user.axlevel < AxAideU) ) {
+       if ( (CtdlGetConfigInt("c_disable_newu")) && (CCC->user.axlevel < AxAideU) ) {
                cprintf("%d Self-service registration is not allowed here.\n",
                        ERROR + HIGHER_ACCESS_REQUIRED);
        }
                cprintf("%d Self-service registration is not allowed here.\n",
                        ERROR + HIGHER_ACCESS_REQUIRED);
        }
@@ -865,7 +867,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
 
 #ifdef HAVE_GETPWUID_R
        /* If using host auth mode, we add an email address based on the login */
 
 #ifdef HAVE_GETPWUID_R
        /* If using host auth mode, we add an email address based on the login */
-       if (config.c_auth_mode == AUTHMODE_HOST) {
+       if (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_HOST) {
                struct passwd pwd;
                char pwd_buffer[SIZ];
                
                struct passwd pwd;
                char pwd_buffer[SIZ];
                
@@ -876,7 +878,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
                syslog(LOG_DEBUG, "Searching for uid %d", usbuf->uid);
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, &result) == 0) {
 #endif // HAVE_GETPWUID_R
                syslog(LOG_DEBUG, "Searching for uid %d", usbuf->uid);
                if (getpwuid_r(usbuf->uid, &pwd, pwd_buffer, sizeof pwd_buffer, &result) == 0) {
 #endif // HAVE_GETPWUID_R
-                       snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, config.c_fqdn);
+                       snprintf(buf, sizeof buf, "%s@%s", pwd.pw_name, CtdlGetConfigStr("c_fqdn"));
                        vcard_add_prop(v, "email;internet", buf);
                        need_default_vcard=0;
                }
                        vcard_add_prop(v, "email;internet", buf);
                        need_default_vcard=0;
                }
@@ -889,7 +891,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
-       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
             //uid_t ldap_uid;
            int found_user;
             char ldap_cn[512];
             //uid_t ldap_uid;
            int found_user;
             char ldap_cn[512];
@@ -907,7 +909,7 @@ void vcard_newuser(struct ctdluser *usbuf) {
 #endif
        if (need_default_vcard!=0) {
          /* Everyone gets an email address based on their display name */
 #endif
        if (need_default_vcard!=0) {
          /* Everyone gets an email address based on their display name */
-         snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, config.c_fqdn);
+         snprintf(buf, sizeof buf, "%s@%s", usbuf->fullname, CtdlGetConfigStr("c_fqdn"));
          for (i=0; buf[i]; ++i) {
                if (buf[i] == ' ') buf[i] = '_';
          }
          for (i=0; buf[i]; ++i) {
                if (buf[i] == ' ') buf[i] = '_';
          }
@@ -938,7 +940,7 @@ void vcard_purge(struct ctdluser *usbuf) {
        msg->cm_format_type = 0;
        CM_SetField(msg, eAuthor, usbuf->fullname, strlen(usbuf->fullname));
        CM_SetField(msg, eOriginalRoom, HKEY(ADDRESS_BOOK_ROOM));
        msg->cm_format_type = 0;
        CM_SetField(msg, eAuthor, usbuf->fullname, strlen(usbuf->fullname));
        CM_SetField(msg, eOriginalRoom, HKEY(ADDRESS_BOOK_ROOM));
-       CM_SetField(msg, eNodeName, CFG_KEY(c_nodename));
+       CM_SetField(msg, eNodeName, CtdlGetConfigStr("c_nodename"), strlen(CtdlGetConfigStr("c_nodename")));
        CM_SetField(msg, eMesageText, HKEY("Purge this vCard\n"));
 
        len = snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
        CM_SetField(msg, eMesageText, HKEY("Purge this vCard\n"));
 
        len = snprintf(buf, sizeof buf, VCARD_EXT_FORMAT,
@@ -1281,7 +1283,7 @@ void vcard_session_login_hook(void) {
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
         * Is this an LDAP session?  If so, copy various LDAP attributes from the directory entry
         * into the user's vCard.
         */
-       if ((config.c_auth_mode == AUTHMODE_LDAP) || (config.c_auth_mode == AUTHMODE_LDAP_AD)) {
+       if ((CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP) || (CtdlGetConfigInt("c_auth_mode") == AUTHMODE_LDAP_AD)) {
                v = vcard_get_user(&CCC->user);
                if (v) {
                        if (Ctdl_LDAP_to_vCard(CCC->ldap_dn, v)) {
                v = vcard_get_user(&CCC->user);
                if (v) {
                        if (Ctdl_LDAP_to_vCard(CCC->ldap_dn, v)) {
@@ -1553,7 +1555,7 @@ CTDL_MODULE_INIT(vcard)
                }
 
                /* for postfix tcpdict */
                }
 
                /* for postfix tcpdict */
-               CtdlRegisterServiceHook(config.c_pftcpdict_port,        /* Postfix */
+               CtdlRegisterServiceHook(CtdlGetConfigInt("c_pftcpdict_port"),   /* Postfix */
                                        NULL,
                                        check_get_greeting,
                                        check_get,
                                        NULL,
                                        check_get_greeting,
                                        check_get,