feature request for Bulk Registration feature

27 views
Skip to first unread message

LV

unread,
Oct 4, 2016, 7:21:04 AM10/4/16
to Poweradmin
It would be awesome if Bulk Registration feature can also delete any zones that current exist
A checkbox that to enables "delete existing zones" would allow for this flexibility

easily doable ?

LV

unread,
Oct 5, 2016, 3:03:08 AM10/5/16
to Poweradmin
I added the following to do what I need.

--- bulk_registration.php_orig 2016-10-04 10:56:53.273634166 -0400
+++ bulk_registration.php       2016-10-04 11:05:22.410641223 -0400
@@ -74,9 +74,10 @@
         if (!is_valid_hostname_fqdn($domain, 0)) {
             error($domain . ' failed - ' . ERR_DNS_HOSTNAME);
         } elseif (domain_exists($domain)) {
-            error($domain . " failed - " . ERR_DOMAIN_EXISTS);
-            $error = true;
-        } elseif (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
+            $zid=get_zone_id_from_name($domain);
+          delete_domain($zid);
+        }
+        if (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
             success("<a href=\"edit.php?id=" . get_zone_id_from_name($domain) . "\">" . $domain . " - " . SUC_ZONE_ADD . '</a>');
         }
     }

LV

unread,
Oct 5, 2016, 3:03:18 AM10/5/16
to Poweradmin
I added the checkbox function as well for completeness


--- bulk_registration.php_orig 2016-10-04 10:56:53.273634166 -0400
+++ bulk_registration.php       2016-10-05 00:25:51.454306853 -0400
@@ -62,6 +62,8 @@
     $zone_template = "none";
 }

+$overwrite = ($_POST['overwrite'] == "true" ? true : false);
+
 /*
   Check user permissions
  */
@@ -74,9 +76,16 @@
         if (!is_valid_hostname_fqdn($domain, 0)) {
             error($domain . ' failed - ' . ERR_DNS_HOSTNAME);
         } elseif (domain_exists($domain)) {
-            error($domain . " failed - " . ERR_DOMAIN_EXISTS);
-            $error = true;
-        } elseif (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
+            if ($overwrite) {
+               $zid=get_zone_id_from_name($domain);
+             delete_domain($zid);
+            } else {
+               error($domain . " failed - " . ERR_DOMAIN_EXISTS);
+               $error = true;
+               continue;
+            }
+        }
+       if (add_domain($domain, $owner, $dom_type, '', $zone_template)) {
             success("<a href=\"edit.php?id=" . get_zone_id_from_name($domain) . "\">" . $domain . " - " . SUC_ZONE_ADD . '</a>');
         }
     }
@@ -136,7 +145,12 @@
     echo "         </select>\n";
     echo "        </td>\n";
     echo "       </tr>\n";
-
+    echo "       <tr>\n";
+    echo "        <td class=\"n\">" . _('Overwrite Existing Zones') . ":</td>\n";
+    echo "        <td class=\"n\">\n";
+    echo "         <input type=\"checkbox\" class=\"input\" name=\"overwrite\" value=\"true\"" . ($overwrite ? "checked=\"checked\"" : "") . ">\n";
+    echo "        </td>\n";
+    echo "       </tr>\n";
     echo "       <tr>\n";
     echo "        <td class=\"n\">" . _('Zones') . ":</td>\n";
     echo "        <td class=\"n\">\n";




On Tuesday, October 4, 2016 at 4:21:04 AM UTC-7, LV wrote:
Reply all
Reply to author
Forward
0 new messages