]> andersk Git - moira.git/commitdiff
Warn user before letting them rename a list to someone's username.
authordanw <danw>
Tue, 17 Jun 1997 20:11:20 +0000 (20:11 +0000)
committerdanw <danw>
Tue, 17 Jun 1997 20:11:20 +0000 (20:11 +0000)
clients/moira/lists.c

index 448128eba43547e76b8586d39bb65c8727190f47..7a7e6c4dc44ba1e23e64a86d5c5f50e0253f18a1 100644 (file)
@@ -285,11 +285,34 @@ Bool junk;
 {
     register int stat;
     char ** args;
+    struct qelem *elem = NULL;
     
     if ((args = AskListInfo(info, TRUE)) == NULL) {
        Put_message("Aborted.");
        return;
     }
+
+    /*
+     * If the new list name is less than 8 characters, make sure it doesn't
+     * collide with a username.
+     */
+    if ((strlen(args[2]) <= 8) &&
+       do_mr_query("get_user_account_by_login", 1, args + 1,
+                   StoreInfo, (char *) &elem) != MR_NO_MATCH) {
+           char buf[256];
+
+           sprintf(buf, "\nA user by the name `%s' already exists in the database.",
+                   args[1]);
+           Put_message(buf);
+           Loop(QueueTop(elem), FreeInfo);
+           FreeQueue(elem);
+           if (YesNoQuestion("Do you still want to rename this list to that name",
+                             FALSE) != TRUE) {
+               Put_message("List ** NOT ** Updated.");
+               return;
+           }
+    }
+    
     if ( (stat = do_mr_query("update_list", CountArgs(args), args, 
                           Scream, (char *) NULL)) != MR_SUCCESS) {
        com_err(program_name, stat, " in UpdateList."); 
@@ -380,8 +403,12 @@ char **argv;
      */
     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.");
+                   StoreInfo, (char *) &elem) != MR_NO_MATCH) {
+           char buf[256];
+
+           sprintf(buf, "\nA user by the name `%s' already exists in the database.",
+                   argv[1]);
+           Put_message(buf);
            Loop(QueueTop(elem), FreeInfo);
            FreeQueue(elem);
            if (YesNoQuestion("Crate a list with the same name",
This page took 0.11421 seconds and 5 git commands to generate.