From ffb758d15760d0fb57a88c336f9a3ae932c61c0f Mon Sep 17 00:00:00 2001 From: Ben Klang Date: Sat, 2 Jan 2010 12:26:54 -0500 Subject: [PATCH] Beatnik: Convert Horde_Exception to Beatnik_Exception --- beatnik/lib/Beatnik.php | 2 +- beatnik/lib/Driver.php | 10 +++++----- beatnik/lib/Driver/ldap2dns.php | 30 +++++++++++++++--------------- beatnik/lib/Driver/pdnsgsql.php | 12 ++++++------ beatnik/lib/Exception.php | 1 + 5 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 beatnik/lib/Exception.php diff --git a/beatnik/lib/Beatnik.php b/beatnik/lib/Beatnik.php index a0b385b0d..03c55d5dd 100644 --- a/beatnik/lib/Beatnik.php +++ b/beatnik/lib/Beatnik.php @@ -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.")); } } diff --git a/beatnik/lib/Driver.php b/beatnik/lib/Driver.php index 3962da608..ccfcf2a03 100644 --- a/beatnik/lib/Driver.php +++ b/beatnik/lib/Driver.php @@ -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.')); } } diff --git a/beatnik/lib/Driver/ldap2dns.php b/beatnik/lib/Driver/ldap2dns.php index 8e18f7aa7..a85d3ffaf 100644 --- a/beatnik/lib/Driver/ldap2dns.php +++ b/beatnik/lib/Driver/ldap2dns.php @@ -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; diff --git a/beatnik/lib/Driver/pdnsgsql.php b/beatnik/lib/Driver/pdnsgsql.php index e5fcda99b..ae990dfb1 100644 --- a/beatnik/lib/Driver/pdnsgsql.php +++ b/beatnik/lib/Driver/pdnsgsql.php @@ -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 index 000000000..56ff59ecc --- /dev/null +++ b/beatnik/lib/Exception.php @@ -0,0 +1 @@ +class Beatnik_Exception extends Horde_Exception {} \ No newline at end of file -- 2.11.0