]> andersk Git - moira.git/blobdiff - clients/moira/lists.c
Diane Delgado's changes for a fixed table-locking order
[moira.git] / clients / moira / lists.c
index 69ae34a463075fe8b63dfd4c2f7d14ac35973e68..173c3909b1ca31416f35e4857fe716d7aa680177 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include <stdio.h>
-#include <strings.h>
+#include <string.h>
 #include <moira.h>
 #include <moira_site.h>
 #include <menu.h>
@@ -360,6 +360,7 @@ char **argv;
 {
     static char *info[MAX_ARGS_SIZE], **add_args;
     int status, ret_code = SUB_NORMAL;
+    struct qelem *elem = NULL;
 
     if (!ValidName(argv[1]))
       return(DM_NORMAL);
@@ -373,6 +374,21 @@ char **argv;
        return(SUB_ERROR);
     }
 
+    /*
+     * If the listname is less than 8 characters, make sure it doesn't
+     * collide with a username.
+     */
+    if ((strlen(argv[1]) <= 8) &&
+       do_mr_query("get_user_account_by_login", 1, argv + 1,
+                   StoreInfo, (char *) &elem) == 0) {
+           Put_message("A user by that name already exists in the database.");
+           Loop(QueueTop(elem), FreeInfo);
+           FreeQueue(elem);
+           if (YesNoQuestion("Crate a list with the same name",
+                             FALSE) != TRUE)
+                   return(SUB_ERROR);
+    }
+    
     if ((add_args = AskListInfo(SetDefaults(info,argv[1]), FALSE)) == NULL) {
        Put_message("Aborted.");
        return(SUB_ERROR);
@@ -624,7 +640,7 @@ AddMember()
        return(DM_NORMAL);
 
     if (!strcmp(args[LM_TYPE], "STRING")) {
-       if (p = index(args[LM_MEMBER], '@')) {
+       if (p = strchr(args[LM_MEMBER], '@')) {
            char *host = canonicalize_hostname(strsave(++p));
            mailhubs = GetTypeValues("mailhub");
            for (elem = mailhubs; elem; elem = elem->q_forw) {
@@ -641,7 +657,7 @@ AddMember()
                }
            }
            free(host);
-       } else if (!index(args[LM_MEMBER], '!')) {
+       } else if (!strchr(args[LM_MEMBER], '!')) {
            Put_message("Member which is not a foreign mail address should not be type STRING.");
            return(DM_NORMAL);
        }
@@ -839,57 +855,6 @@ ListByAdministrator()
     return (DM_NORMAL);
 }
 
-/*     Function Name: ListAllGroups
- *     Description: This function lists all visable groups.
- *     Arguments: none.
- *     Returns: DM_NORMAL.
- */
-
-ListAllGroups()
-{
-    register int status;
-    static char * args[] = {
-       "TRUE",                 /* active */
-       "DONTCARE",             /* public */
-       "FALSE",                /* hidden */
-       "DONTCARE",             /* maillist */
-       "TRUE",                 /* group. */
-    };
-
-    if (YesNoQuestion("This query will take a while, Do you wish to continue?",
-                      TRUE) == TRUE )
-       if (status = do_mr_query("qualified_get_lists", 5, args,
-                              Print, (char *) NULL) != 0)
-           com_err(program_name, status, " in ListAllGroups");
-    return (DM_NORMAL);
-}
-
-/*     Function Name: ListAllMailLists
- *     Description: This function lists all visable maillists.
- *     Arguments: none
- *     Returns: DM_NORMAL.
- */
-
-ListAllMailLists()
-{
-    register int status;
-    static char * args[] = {
-       "TRUE",                 /* active */
-       "DONTCARE",             /* public */
-       "FALSE",                /* hidden */
-       "TRUE",                 /* maillist */
-       "DONTCARE",             /* group. */
-    };
-
-    if (YesNoQuestion("This query will take a while. Do you wish to continue?",
-                      TRUE) == TRUE )
-       if (status = do_mr_query("qualified_get_lists", 5, args,
-                              Print, (char *) NULL) != 0)
-           com_err(program_name, status, " in ListAllGroups");
-
-    return (DM_NORMAL);        
-}
-
 /*     Function Name: ListAllPublicMailLists
  *     Description: This function lists all public mailing lists.
  *     Arguments: none
This page took 0.04162 seconds and 4 git commands to generate.