Beatnik: Convert Horde_Exception to Beatnik_Exception
authorBen Klang <ben@alkaloid.net>
Sat, 2 Jan 2010 17:26:54 +0000 (12:26 -0500)
committerBen Klang <ben@alkaloid.net>
Sat, 2 Jan 2010 17:26:54 +0000 (12:26 -0500)
beatnik/lib/Beatnik.php
beatnik/lib/Driver.php
beatnik/lib/Driver/ldap2dns.php
beatnik/lib/Driver/pdnsgsql.php
beatnik/lib/Exception.php [new file with mode: 0644]

index a0b385b..03c55d5 100644 (file)
@@ -425,7 +425,7 @@ class Beatnik {
             return true;
         } else {
             // Somebody sent something they should not have...
-            throw new Horde_Exception(_("Unable to determine if domain needs committing: invalid parameter."));
+            throw new Beatnik_Exception(_("Unable to determine if domain needs committing: invalid parameter."));
         }
     }
 
index 3962da6..ccfcf2a 100644 (file)
@@ -102,7 +102,7 @@ class Beatnik_Driver {
                 return $domain;
             }
         }
-        throw new Horde_Exception(sprintf(_("Unable to read requested domain %s"), $domainname));
+        throw new Beatnik_Exception(sprintf(_("Unable to read requested domain %s"), $domainname));
     }
 
     /**
@@ -202,7 +202,7 @@ class Beatnik_Driver {
         if ($info['rectype'] == 'soa' && $info['zonename'] != $_SESSION['beatnik']['curdomain']['zonename']) {
             // Make sure the user has permissions to add domains
             if (!Beatnik::hasPermission('beatnik:domains', Horde_Perms::EDIT)) {
-                throw new Horde_Exception(_('You do not have permission to create new domains.'));
+                throw new Beatnik_Exception(_('You do not have permission to create new domains.'));
             }
 
             // Create a dummy old domain for comparison purposes
@@ -215,12 +215,12 @@ class Beatnik_Driver {
             if ($info['rectype'] == 'soa') {
                 $node = 'beatnik:domains:' . $info['zonename'];
                 if (!Beatnik::hasPermission($node, Horde_Perms::EDIT, 1)) {
-                    throw new Horde_Exception(_('You do not have permssion to edit the SOA of this zone.'));
+                    throw new Beatnik_Exception(_('You do not have permssion to edit the SOA of this zone.'));
                 }
             } else {
                 $node = 'beatnik:domains:' . $_SESSION['beatnik']['curdomain']['zonename'] . ':' . $info['id'];
                 if (!Beatnik::hasPermission($node, Horde_Perms::EDIT, 2)) {
-                    throw new Horde_Exception(_('You do not have permssion to edit this record.'));
+                    throw new Beatnik_Exception(_('You do not have permssion to edit this record.'));
                 }
             }
         }
@@ -310,7 +310,7 @@ class Beatnik_Driver {
         if (class_exists($class)) {
             return new $class($params);
         } else {
-            throw new Horde_Exception(_('Driver not found.'));
+            throw new Beatnik_Exception(_('Driver not found.'));
         }
     }
 
index 8e18f7a..a85d3ff 100644 (file)
@@ -134,14 +134,14 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
             "(objectClass=dnszone)");
 
         if ($res === false) {
-            throw new Horde_Exception("Unable to locate any DNS zones " .
+            throw new Beatnik_Exception("Unable to locate any DNS zones " .
             "underneath ".$this->_params['basedn']);
         }
 
         $res = ldap_get_entries($this->_LDAP, $res);
 
         if ($res === false) {
-            throw new Horde_Exception(sprintf(_("Unable to retrieve data from LDAP results: %s"), @ldap_error($this->_LDAP)));
+            throw new Beatnik_Exception(sprintf(_("Unable to retrieve data from LDAP results: %s"), @ldap_error($this->_LDAP)));
         }
 
         $fields = Beatnik::getRecFields('soa');
@@ -234,14 +234,14 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
         $res = @ldap_list($this->_LDAP, $dn, '(objectClass=dnsrrset)');
 
         if ($res === false) {
-            throw new Horde_Exception("Unable to locate any DNS data for $domain");
+            throw new Beatnik_Exception("Unable to locate any DNS data for $domain");
         }
 
         # FIXME Cache these results
         $zonedata = array();
         $res = @ldap_get_entries($this->_LDAP, $res);
         if ($res === false) {
-            throw new Horde_Exception(sprintf(_("Internal error: %s"), @ldap_error($this->_LDAP)));
+            throw new Beatnik_Exception(sprintf(_("Internal error: %s"), @ldap_error($this->_LDAP)));
         }
 
         $i = 0;
@@ -295,7 +295,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
     {
         // Ensure we have a record ID before continuing
         if (!isset($info['id'])) {
-            throw new Horde_Exception(_("Unable to delete record: No record ID specified."));
+            throw new Beatnik_Exception(_("Unable to delete record: No record ID specified."));
         }
 
         // Attribute used to identify objects
@@ -304,7 +304,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
         $suffix = $dnattr . '=' . $_SESSION['beatnik']['curdomain']['zonename'] . ',' . $this->_params['basedn'];
         if ($info['rectype'] == 'soa') {
             // FIXME: Add recursion
-            throw new Horde_Exception(_("Unsupported recursive delete."));
+            throw new Beatnik_Exception(_("Unsupported recursive delete."));
 
             $domain = $this->cleanDNString($info['zonename']);
             $dn = $suffix;
@@ -316,7 +316,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
 
         $res = @ldap_delete($this->_LDAP, $dn);
         if ($res === false) {
-            throw new Horde_Exception(sprintf(_("Unable to delete record.  Reason: %s"), @ldap_error($this->_LDAP)));
+            throw new Beatnik_Exception(sprintf(_("Unable to delete record.  Reason: %s"), @ldap_error($this->_LDAP)));
         }
         return true;
     }
@@ -343,7 +343,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
         }
 
         if (!$rdata) {
-            throw new Horde_Exception(_("Invalid record type specified."));
+            throw new Beatnik_Exception(_("Invalid record type specified."));
         }
 
         $recfields = Beatnik::getRecFields($rectype);
@@ -394,7 +394,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
 
             if (!isset($entry[$key]) && $fdata['required']) {
                 // No value available but required field
-                throw new Horde_Exception(sprintf(_("Missing required field %s to save record."), $fdata['name']));
+                throw new Beatnik_Exception(sprintf(_("Missing required field %s to save record."), $fdata['name']));
             }
 
             // Construct an ID for this object as a tuple of its data.
@@ -431,12 +431,12 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
                 // We have an old DN but it doesn't match the new DN.
                 // Need to rename the old object
                 if ($rectype == 'soa') {
-                    throw new Horde_Exception(_("Unsupported operation: cannot rename a domain."));
+                    throw new Beatnik_Exception(_("Unsupported operation: cannot rename a domain."));
                 }
                 $res = @ldap_rename($this->_LDAP, $oldRDN . ',' . $suffix,
                     $dn, $suffix, true);
                 if ($res === false) {
-                    throw new Horde_Exception(sprintf(_("Unable to rename old object.  Reason: %s"), @ldap_error($this->_LDAP)));
+                    throw new Beatnik_Exception(sprintf(_("Unable to rename old object.  Reason: %s"), @ldap_error($this->_LDAP)));
                 }
             }
 
@@ -446,7 +446,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
             // Modify the existing record
             $res = @ldap_mod_replace($this->_LDAP, $dn, $entry);
             if ($res === false) {
-                throw new Horde_Exception(sprintf(_("Unable to modify record.  Reason: %s"), @ldap_error($this->_LDAP)));
+                throw new Beatnik_Exception(sprintf(_("Unable to modify record.  Reason: %s"), @ldap_error($this->_LDAP)));
             }
 
         } else {
@@ -463,7 +463,7 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
             }
             $res = @ldap_add($this->_LDAP, $dn, $entry);
             if ($res === false) {
-                throw new Horde_Exception(sprintf(_("Unable to add record to LDAP. Reason: %s"), @ldap_error($this->_LDAP)));
+                throw new Beatnik_Exception(sprintf(_("Unable to add record to LDAP. Reason: %s"), @ldap_error($this->_LDAP)));
             }
         }
 
@@ -509,11 +509,11 @@ class Beatnik_Driver_ldap2dns extends Beatnik_Driver
             }
             $res = ldap_set_option($this->_LDAP, LDAP_OPT_PROTOCOL_VERSION, $this->_params['version']);
             if ($res === false) {
-                throw new Horde_Exception("Unable to set LDAP protocol version");
+                throw new Beatnik_Exception("Unable to set LDAP protocol version");
             }
             $res = ldap_bind($this->_LDAP, $this->_params['binddn'], $this->_params['password']);
             if ($res === false) {
-                throw new Horde_Exception("Unable to bind to the LDAP server. Check authentication credentials.");
+                throw new Beatnik_Exception("Unable to bind to the LDAP server. Check authentication credentials.");
             }
 
             $this->_connected = true;
index e5fcda9..ae990df 100644 (file)
@@ -75,7 +75,7 @@ class Beatnik_Driver_pdnsgsql extends Beatnik_Driver
         $domainlist =  $this->_db->getAll($query, null, DB_FETCHMODE_ASSOC);
         if (is_a($domainlist, 'PEAR_Error')) {
             Horde::logMessage($domainlist, __FILE__, __LINE__, PEAR_LOG_ERR);
-            throw new Horde_Exception(_("Error getting domain list.  Details have been logged for the administrator."));
+            throw new Beatnik_Exception(_("Error getting domain list.  Details have been logged for the administrator."));
         }
 
         $results = array();
@@ -123,11 +123,11 @@ class Beatnik_Driver_pdnsgsql extends Beatnik_Driver
         $result =  $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);
         if (is_a($result, 'PEAR_Error')) {
             Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
-            throw new Horde_Exception(_("An error occurred while searching the database.  Details have been logged for the administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
+            throw new Beatnik_Exception(_("An error occurred while searching the database.  Details have been logged for the administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
         }
 
         if (count($result) != 1) {
-            throw new Horde_Exception(_("Too many domains matched that name.  Contact your administrator."));
+            throw new Beatnik_Exception(_("Too many domains matched that name.  Contact your administrator."));
         }
 
         $info = $result[0];
@@ -135,7 +135,7 @@ class Beatnik_Driver_pdnsgsql extends Beatnik_Driver
         $soa = explode(' ', $info['content']);
         if (count($soa) != 7) {
             Horde::logMessage(sprintf('Invalid SOA found for %s, skipping.', $info['name']), __FILE__, __LINE__, PEAR_LOG_WARN);
-            throw new Horde_Exception(_("Corrupt SOA found for zone.  Contact your administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
+            throw new Beatnik_Exception(_("Corrupt SOA found for zone.  Contact your administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
         }
 
         $ret = array();
@@ -177,7 +177,7 @@ class Beatnik_Driver_pdnsgsql extends Beatnik_Driver
         $result = $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);
         if (is_a($result, 'PEAR_Error')) {
             Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
-            throw new Horde_Exception(_("An error occurred while searching the database.  Details have been logged for the administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
+            throw new Beatnik_Exception(_("An error occurred while searching the database.  Details have been logged for the administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
         }
 
         foreach ($result as $rec) {
@@ -404,7 +404,7 @@ class Beatnik_Driver_pdnsgsql extends Beatnik_Driver
     {
         $this->_connect();
 
-        throw new Horde_Exception(_("Not implemented."));
+        throw new Beatnik_Exception(_("Not implemented."));
     }
 
     /**
diff --git a/beatnik/lib/Exception.php b/beatnik/lib/Exception.php
new file mode 100644 (file)
index 0000000..56ff59e
--- /dev/null
@@ -0,0 +1 @@
+class Beatnik_Exception extends Horde_Exception {}
\ No newline at end of file