Accidentally merged the configdb branch into master. Reverting.
[citadel.git] / citadel / modules / expire / expire_policy.c
index 260a49830829a064ea2d2b8c7a15016cc47f8dca..bc4b772a72c1c28626a7b743d864d82ca8dcdbcb 100644 (file)
@@ -1,7 +1,14 @@
 /* 
- * $Id$
+ * Functions which manage expire policy for rooms
+ * Copyright (c) 1987-2012 by the citadel.org team
  *
- * Functions which manage policy for rooms (such as message expiry)
+ * 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 distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  */
 
 #include "sysdep.h"
 #include "room_ops.h"
 #include "sysdep_decls.h"
 #include "support.h"
-#include "user_ops.h"
 #include "msgbase.h"
 #include "citserver.h"
 
 #include "ctdl_module.h"
+#include "user_ops.h"
 
 /*
  * Retrieve the applicable expire policy for a specific room
@@ -85,17 +92,21 @@ void cmd_gpex(char *argbuf) {
        char which[128];
 
        extract_token(which, argbuf, 0, '|', sizeof which);
-       if (!strcasecmp(which, strof(room))) {
+       if (!strcasecmp(which, strof(roompolicy))||
+           !strcasecmp(which, "room")) { /* Deprecated version */
                memcpy(&exp, &CC->room.QRep, sizeof(struct ExpirePolicy));
        }
-       else if (!strcasecmp(which, strof(floorpolicy))) {
+       else if (!strcasecmp(which, strof(floorpolicy))||
+                !strcasecmp(which, "floor")) { /* Deprecated version */
                fl = CtdlGetCachedFloor(CC->room.QRfloor);
                memcpy(&exp, &fl->f_ep, sizeof(struct ExpirePolicy));
        }
-       else if (!strcasecmp(which, strof(mailboxespolicy))) {
+       else if (!strcasecmp(which, strof(mailboxespolicy))||
+                !strcasecmp(which, "mailboxes")) {/* Deprecated version */
                memcpy(&exp, &config.c_mbxep, sizeof(struct ExpirePolicy));
        }
-       else if (!strcasecmp(which, strof(sitepolicy))) {
+       else if (!strcasecmp(which, strof(sitepolicy))||
+                !strcasecmp(which, "site")) {/* Deprecated version */
                memcpy(&exp, &config.c_ep, sizeof(struct ExpirePolicy));
        }
        else {
@@ -125,26 +136,33 @@ void cmd_spex(char *argbuf) {
                return;
        }
 
-       if (!strcasecmp(which, "room")) {
+       if (    (!strcasecmp(which, strof(roompolicy)))
+               || (!strcasecmp(which, "room"))
+       ) {
                if (!is_room_aide()) {
-                       cprintf("%d Higher access required.\n",
-                               ERROR + HIGHER_ACCESS_REQUIRED);
+                       cprintf("%d Higher access required.\n", ERROR + HIGHER_ACCESS_REQUIRED);
                        return;
                }
                CtdlGetRoomLock(&CC->room, CC->room.QRname);
                memcpy(&CC->room.QRep, &exp, sizeof(struct ExpirePolicy));
                CtdlPutRoomLock(&CC->room);
-               cprintf("%d Room expire policy has been updated.\n", CIT_OK);
+               cprintf("%d Room expire policy for '%s' has been updated.\n", CIT_OK, CC->room.QRname);
+               syslog(LOG_DEBUG, "Room: %s , Policy: %d , Value: %d",
+                       CC->room.QRname,
+                       exp.expire_mode,
+                       exp.expire_value
+               );
                return;
        }
 
        if (CC->user.axlevel < AxAideU) {
-               cprintf("%d Higher access required.\n",
-                       ERROR + HIGHER_ACCESS_REQUIRED);
+               cprintf("%d Higher access required.\n", ERROR + HIGHER_ACCESS_REQUIRED);
                return;
        }
 
-       if (!strcasecmp(which, strof(floorpolicy))) {
+       if (    (!strcasecmp(which, strof(floorpolicy)))
+               || (!strcasecmp(which, "floor"))
+       ) {
                lgetfloor(&flbuf, CC->room.QRfloor);
                memcpy(&flbuf.f_ep, &exp, sizeof(struct ExpirePolicy));
                lputfloor(&flbuf, CC->room.QRfloor);
@@ -152,15 +170,18 @@ void cmd_spex(char *argbuf) {
                return;
        }
 
-       else if (!strcasecmp(which, strof(mailboxespolicy))) {
+       else if (       (!strcasecmp(which, strof(mailboxespolicy)))
+                       || (!strcasecmp(which, "mailboxes"))
+               ) {
                memcpy(&config.c_mbxep, &exp, sizeof(struct ExpirePolicy));
                put_config();
-               cprintf("%d Default expire policy for mailboxes set.\n",
-                       CIT_OK);
+               cprintf("%d Default expire policy for mailboxes set.\n", CIT_OK);
                return;
        }
 
-       else if (!strcasecmp(which, strof(sitepolicy))) {
+       else if (       (!strcasecmp(which, strof(sitepolicy)))
+                       || (!strcasecmp(which, "site"))
+               ) {
                if (exp.expire_mode == EXPIRE_NEXTLEVEL) {
                        cprintf("%d Invalid policy (no higher level)\n",
                                ERROR + ILLEGAL_VALUE);
@@ -172,10 +193,5 @@ void cmd_spex(char *argbuf) {
                return;
        }
 
-       else {
-               cprintf("%d Invalid keyword \"%s\"\n", ERROR + ILLEGAL_VALUE, which);
-               return;
-       }
-
+       cprintf("%d Invalid keyword '%s'\n", ERROR + ILLEGAL_VALUE, which);
 }
-