Some PEAR_Error checks are left for the PEAR DB library. Everything else should be handled using PHP5 exceptions.
if ($form->validate($vars)) {
if (Horde_Util::getFormData('submitbutton') == _("Autogenerate")) {
- $result = Beatnik::autogenerate($vars);
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($zonedata, 'horde.error');
- header('Location:' . Horde::applicationUrl('listzones.php'));
- exit;
- }
+ try {
+ $result = Beatnik::autogenerate($vars);
+ } catch (Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
+ header('Location:' . Horde::applicationUrl('listzones.php'));
+ exit;
+ }
} else {
$notification->push(_("Autogeneration not performed"), 'horde.warning');
}
$form->setSubmitted(true);
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
- $result = $beatnik_driver->saveRecord($info);
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
- } else {
- $notification->push(sprintf(_('Zone serial for %s incremented.'), $domain['zonename']), 'horde.success');
+ try {
+ $result = $beatnik_driver->saveRecord($info);
+ } catch (Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
}
+ $notification->push(sprintf(_('Zone serial for %s incremented.'), $domain['zonename']), 'horde.success');
} else {
$notification->push(sprintf(_("Unable to construct valid SOA for %s. Not incrementing serial."), $domain['zonename']), 'horde.error');
}
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
if (Horde_Util::getFormData('submitbutton') == _("Delete")) {
- $result = $beatnik_driver->deleteRecord($info);
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
+ try {
+ $result = $beatnik_driver->deleteRecord($info);
+ } catch (Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('viewzone.php'), $info));
+ exit;
+ }
+ $notification->push(_("Record deleted"), 'horde.success');
+ if ($info['rectype'] == 'soa') {
+ header('Location: ' . Horde::applicationUrl('listzones.php'));
} else {
- $notification->push(_("Record deleted"), 'horde.success');
- if ($info['rectype'] == 'soa') {
- header('Location: ' . Horde::applicationUrl('listzones.php'));
- } else {
- header('Location: ' . Horde::applicationUrl('viewzone.php'));
- }
+ header('Location: ' . Horde::applicationUrl('viewzone.php'));
}
} else {
$notification->push(_("Record not deleted"), 'horde.warning');
if ($form->validate($vars)) {
$form->getInfo($vars, $info);
- $result = $beatnik_driver->saveRecord($info);
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
+ try {
+ $result = $beatnik_driver->saveRecord($info);
+ } catch (Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
+ }
+
+ $notification->push('Record data saved.', 'horde.success');
+
+ // Check to see if this is a new domain
+ $edit = $vars->get('id');
+ if ($info['rectype'] == 'soa' && !$edit) {
+ // if added a soa redirect to the autogeneration page
+ $url = Horde_Util::addParameter(Horde::applicationUrl('autogenerate.php'),
+ array('rectype' => 'soa', 'curdomain' => $info['zonename']), false, false);
} else {
- $notification->push('Record data saved.', 'horde.success');
-
- // Check to see if this is a new domain
- $edit = $vars->get('id');
- if ($info['rectype'] == 'soa' && !$edit) {
- // if added a soa redirect to the autogeneration page
- $url = Horde_Util::addParameter(Horde::applicationUrl('autogenerate.php'),
- array('rectype' => 'soa', 'curdomain' => $info['zonename']), false, false);
- } else {
- $url = Horde::applicationUrl('viewzone.php');
- }
+ $url = Horde::applicationUrl('viewzone.php');
}
header('Location: ' . $url);
return true;
} else {
// Somebody sent something they should not have...
- return PEAR::raiseError(_("Unable to determine if domain needs committing: invalid parameter."));
+ throw new Horde_Exception(_("Unable to determine if domain needs committing: invalid parameter."));
}
}
require BEATNIK_BASE . '/config/autogenerate.php';
$template = $templates[$vars->get('template')];
- $zonedata = $GLOBALS['beatnik_driver']->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
- if (is_a($zonedata, 'PEAR_Error')) {
- return $zonedata;
+ try {
+ $zonedata = $GLOBALS['beatnik_driver']->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e);
}
foreach ($template['types'] as $rectype => $definitions) {
switch($definitions['replace']) {
case 'all':
foreach ($zonedata[$rectype] as $record) {
+ try {
$result = $GLOBALS['beatnik_driver']->deleteRecord($record);
- if (is_a($result, 'PEAR_Error')) {
- $GLOBALS['notification']->push($result);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e);
}
}
break;
// hostname matches
foreach ($definitions['records'] as $Trecord) {
if ($record['hostname'] == $Trecord['hostname']) {
- $result = $GLOBALS['beatnik_driver']->deleteRecord($record);
- if (is_a($result, 'PEAR_Error')) {
- $GLOBALS['notification']->push($result);
+ try {
+ $result = $GLOBALS['beatnik_driver']->deleteRecord($record);
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e);
}
}
}
$GLOBALS['notification']->push(_("Skipping existing identical record"));
continue;
}
- $result = $GLOBALS['beatnik_driver']->saveRecord(array_merge($defaults, $info));
- if (is_a($result, 'PEAR_Error')) {
+ try {
+ $result = $GLOBALS['beatnik_driver']->saveRecord(array_merge($defaults, $info));
+ } catch (Exception $e) {
$GLOBALS['notification']->push($result->getMessage() . ': ' . $result->getDebugInfo(), 'horde.error');
- } else {
- $GLOBALS['notification']->push(sprintf(_('Record added: %s/%s'), $rectype, $info['hostname']), 'horde.success');
}
+ $GLOBALS['notification']->push(sprintf(_('Record added: %s/%s'), $rectype, $info['hostname']), 'horde.success');
}
}
return true;
*/
function getDomains($perms = Horde_Perms::SHOW)
{
- $domains = $this->_getDomains();
- if (is_a($domains, 'PEAR_Error')) {
- $GLOBALS['notification']->push($domains->getMessage() . ': ' . $domains->getDebugInfo(), 'horde.warning');
+ try {
+ $domains = $this->_getDomains();
+ } catch (Exception $e) {
+ $GLOBALS['notification']->push($e->getMessage(), 'horde.warning');
return array();
}
*
* @param string $domain Domain for which to return SOA information
*
- * @return mixed Array of SOA information for domain or PEAR_Error
- * on failure.
+ * @return mixed Array of SOA information for domain
*/
function getDomain($domainname)
{
return $domain;
}
}
- return PEAR::raiseError(sprintf(_("Unable to read requested domain %s"), $domainname));
+ throw new Horde_Exception(sprintf(_("Unable to read requested domain %s"), $domainname));
}
/**
*/
function recordExists($record, $rectype)
{
- $zonedata = $this->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
- if (is_a($zonedata, 'PEAR_Error')) {
- $notification->push($zonedata, 'horde.error');
+ try {
+ $zonedata = $this->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
+ } catch (Exception $e) {
+ $notification->push($e, 'horde.error');
header('Location:' . Horde::applicationUrl('listzones.php'));
exit;
}
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)) {
- return PEAR::raiseError(_('You do not have permission to create new domains.'));
+ throw new Horde_Exception(_('You do not have permission to create new domains.'));
}
// Create a dummy old domain for comparison purposes
if ($info['rectype'] == 'soa') {
$node = 'beatnik:domains:' . $info['zonename'];
if (!Beatnik::hasPermission($node, Horde_Perms::EDIT, 1)) {
- return PEAR::raiseError(_('You do not have permssion to edit the SOA of this zone.'));
+ throw new Horde_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)) {
- return PEAR::raiseError(_('You do not have permssion to edit this record.'));
+ throw new Horde_Exception(_('You do not have permssion to edit this record.'));
}
}
}
// FIXME: Modify saveRecord() to return the new (possibly changed) ID of the
// record and then use that ID to update permissions
$return = $this->_saveRecord($info);
-
$oldsoa =& $_SESSION['beatnik']['curdomain'];
-
- if (is_a($return, 'PEAR_Error')) {
- return $return;
+ if ($info['rectype'] == 'soa' &&
+ ($oldsoa['serial'] < $info['serial'])) {
+ // Clear the commit flag (if set)
+ Beatnik::needCommit($oldsoa['zonename'], false);
} else {
- if ($info['rectype'] == 'soa' &&
- ($oldsoa['serial'] < $info['serial'])) {
- // Clear the commit flag (if set)
- Beatnik::needCommit($oldsoa['zonename'], false);
- } else {
- Beatnik::needCommit($oldsoa['zonename'], true);
- }
+ Beatnik::needCommit($oldsoa['zonename'], true);
}
// Check to see if an SOA was just added or updated.
*
* @param array $info Reference to array of record information for deletion
*
- * @return boolean true on success, PEAR::raiseError on error
+ * @return boolean true on success
*/
function deleteRecord(&$info)
{
$return = $this->_deleteRecord($info);
-
$oldsoa =& $_SESSION['beatnik']['curdomain'];
- if (is_a($return, 'PEAR_Error')) {
- return $return;
- } else {
- // No need to commit if the whole zone is gone
- if ($info['rectype'] != 'soa') {
- Beatnik::needCommit($oldsoa['zonename'], true);
- }
+ // No need to commit if the whole zone is gone
+ if ($info['rectype'] != 'soa') {
+ Beatnik::needCommit($oldsoa['zonename'], true);
}
}
if (class_exists($class)) {
return new $class($params);
} else {
- return PEAR::raiseError(_('Driver not found.'));
+ throw new Horde_Exception(_('Driver not found.'));
}
}
"(objectClass=dnszone)");
if ($res === false) {
- return PEAR::raiseError("Unable to locate any DNS zones " .
+ throw new Horde_Exception("Unable to locate any DNS zones " .
"underneath ".$this->_params['basedn']);
}
$res = ldap_get_entries($this->_LDAP, $res);
if ($res === false) {
- return PEAR::raiseError(sprintf(_("Unable to retrieve data from LDAP results: %s"), @ldap_error($this->_LDAP)));
+ throw new Horde_Exception(sprintf(_("Unable to retrieve data from LDAP results: %s"), @ldap_error($this->_LDAP)));
}
$fields = Beatnik::getRecFields('soa');
$res = @ldap_list($this->_LDAP, $dn, '(objectClass=dnsrrset)');
if ($res === false) {
- return PEAR::raiseError("Unable to locate any DNS data for $domain");
+ throw new Horde_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) {
- return PEAR::raiseError(sprintf(_("Internal error: %s"), @ldap_error($this->_LDAP)));
+ throw new Horde_Exception(sprintf(_("Internal error: %s"), @ldap_error($this->_LDAP)));
}
$i = 0;
*
* @param array $info Reference to array of record information for deletion
*
- * @return boolean true on success, PEAR::raiseError on error
+ * @return boolean true on success
*/
function _deleteRecord(&$info)
{
// Ensure we have a record ID before continuing
if (!isset($info['id'])) {
- return PEAR::raiseError(_("Unable to delete record: No record ID specified."));
+ throw new Horde_Exception(_("Unable to delete record: No record ID specified."));
}
// Attribute used to identify objects
$suffix = $dnattr . '=' . $_SESSION['beatnik']['curdomain']['zonename'] . ',' . $this->_params['basedn'];
if ($info['rectype'] == 'soa') {
// FIXME: Add recursion
- return PEAR::raiseError(_("Unsupported recursive delete."));
+ throw new Horde_Exception(_("Unsupported recursive delete."));
$domain = $this->cleanDNString($info['zonename']);
$dn = $suffix;
$res = @ldap_delete($this->_LDAP, $dn);
if ($res === false) {
- return PEAR::raiseError(sprintf(_("Unable to delete record. Reason: %s"), @ldap_error($this->_LDAP)));
+ throw new Horde_Exception(sprintf(_("Unable to delete record. Reason: %s"), @ldap_error($this->_LDAP)));
}
return true;
}
* @param array $info Array from Horde_Form with record data
*
* @return mixed The new or modified record ID on success;
- * PEAR_Error on error
*/
function _saveRecord($info)
{
}
if (!$rdata) {
- return PEAR::raiseError(_("Invalid record type specified."));
+ throw new Horde_Exception(_("Invalid record type specified."));
}
$recfields = Beatnik::getRecFields($rectype);
if (!isset($entry[$key]) && $fdata['required']) {
// No value available but required field
- return PEAR::raiseError(sprintf(_("Missing required field %s to save record."), $fdata['name']));
+ throw new Horde_Exception(sprintf(_("Missing required field %s to save record."), $fdata['name']));
}
// Construct an ID for this object as a tuple of its data.
// We have an old DN but it doesn't match the new DN.
// Need to rename the old object
if ($rectype == 'soa') {
- return PEAR::raiseError(_("Unsupported operation: cannot rename a domain."));
+ throw new Horde_Exception(_("Unsupported operation: cannot rename a domain."));
}
$res = @ldap_rename($this->_LDAP, $oldRDN . ',' . $suffix,
$dn, $suffix, true);
if ($res === false) {
- return PEAR::raiseError(sprintf(_("Unable to rename old object. Reason: %s"), @ldap_error($this->_LDAP)));
+ throw new Horde_Exception(sprintf(_("Unable to rename old object. Reason: %s"), @ldap_error($this->_LDAP)));
}
}
// Modify the existing record
$res = @ldap_mod_replace($this->_LDAP, $dn, $entry);
if ($res === false) {
- return PEAR::raiseError(sprintf(_("Unable to modify record. Reason: %s"), @ldap_error($this->_LDAP)));
+ throw new Horde_Exception(sprintf(_("Unable to modify record. Reason: %s"), @ldap_error($this->_LDAP)));
}
} else {
}
$res = @ldap_add($this->_LDAP, $dn, $entry);
if ($res === false) {
- return PEAR::raiseError(sprintf(_("Unable to add record to LDAP. Reason: %s"), @ldap_error($this->_LDAP)));
+ throw new Horde_Exception(sprintf(_("Unable to add record to LDAP. Reason: %s"), @ldap_error($this->_LDAP)));
}
}
}
$res = ldap_set_option($this->_LDAP, LDAP_OPT_PROTOCOL_VERSION, $this->_params['version']);
if ($res === false) {
- return PEAR::raiseError("Unable to set LDAP protocol version");
+ throw new Horde_Exception("Unable to set LDAP protocol version");
}
$res = ldap_bind($this->_LDAP, $this->_params['binddn'], $this->_params['password']);
if ($res === false) {
- return PEAR::raiseError("Unable to bind to the LDAP server. Check authentication credentials.");
+ throw new Horde_Exception("Unable to bind to the LDAP server. Check authentication credentials.");
}
$this->_connected = true;
*/
function _getDomains()
{
- if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("Internal database error. Details have been logged for the administrator."));
- }
+ $this->_connect();
$query = 'SELECT d.id, d.name AS name, r.content AS content, ' .
'r.ttl AS ttl FROM ' . $this->_params['domains_table'] .
$domainlist = $this->_db->getAll($query, null, DB_FETCHMODE_ASSOC);
if (is_a($domainlist, 'PEAR_Error')) {
Horde::logMessage($domainlist, __FILE__, __LINE__, PEAR_LOG_ERR);
- return array();
+ throw new Horde_Exception(_("Error getting domain list. Details have been logged for the administrator."));
}
$results = array();
*/
function getDomain($domainname)
{
- if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("Internal database error. Details have been logged for the administrator."));
- }
+ $this->_connect();
$query = 'SELECT d.id AS id, d.name AS name, r.content AS content, ' .
'r.ttl AS ttl FROM ' . $this->_params['domains_table'] .
$result = $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);
if (is_a($result, 'PEAR_Error')) {
Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("An error occurred while searching the database. Details have been logged for the administrator."), __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);
}
if (count($result) != 1) {
- return PEAR::raiseError(_("Too many domains matched that name. Contact your administrator."));
+ throw new Horde_Exception(_("Too many domains matched that name. Contact your administrator."));
}
$info = $result[0];
$soa = explode(' ', $info['content']);
if (count($soa) != 7) {
Horde::logMessage(sprintf('Invalid SOA found for %s, skipping.', $info['name']), __FILE__, __LINE__, PEAR_LOG_WARN);
- return PEAR::raiseError(_("Corrupt SOA found for zone. Contact your administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
+ throw new Horde_Exception(_("Corrupt SOA found for zone. Contact your administrator."), __FILE__, __LINE__, PEAR_LOG_ERR);
}
$ret = array();
*/
function getRecords($domain)
{
- if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("Internal database error. Details have been logged for the administrator."));
- }
+ $this->_connect();
$zonedata = array();
$result = $this->_db->getAll($query, $values, DB_FETCHMODE_ASSOC);
if (is_a($result, 'PEAR_Error')) {
Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("An error occurred while searching the database. Details have been logged for the administrator."), __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);
}
foreach ($result as $rec) {
*
* @param array $info Array of record data
*
- * @return boolean true on success, PEAR::raiseError on error
+ * @return boolean true on success
*/
function _saveRecord($info)
{
- if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("Internal database error. Details have been logged for the administrator."));
- }
+ $this->_connect();
$change_date = time();
$domain_id = $_SESSION['beatnik']['curdomain']['id'];
*/
function _deleteRecord($data)
{
- if (is_a(($result = $this->_connect()), 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return PEAR::raiseError(_("Internal database error. Details have been logged for the administrator."));
- }
+ $this->_connect();
- return PEAR::raiseError(_("Not implemented."));
+ throw new Horde_Exception(_("Not implemented."));
}
/**
return true;
}
- $result = Horde_Util::assertDriverConfig($this->_params, array('phptype'),
- 'PowerDNS Generic SQL',
- array('driver' => 'pdnsgsql'));
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage($result, __FILE__, __LINE__, PEAR_LOG_ERR);
- return $result;
+ try {
+ $result = Horde_Util::assertDriverConfig($this->_params, array('phptype'),
+ 'PowerDNS Generic SQL',
+ array('driver' => 'pdnsgsql'));
+ } catch (Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
+ throw $e;
}
if (!isset($this->_params['domains_table'])) {
*
* @param array $info Array of record data
*
- * @return boolean true on success, PEAR::raiseError on error
+ * @return boolean true on success
*/
function _saveRecord($info)
{
require_once BEATNIK_BASE . '/lib/Beatnik.php';
require_once BEATNIK_BASE . '/lib/Driver.php';
-$GLOBALS['beatnik_driver'] = Beatnik_Driver::factory();
-if (is_a($GLOBALS['beatnik_driver'], 'PEAR_Error')) {
- Horde::fatal($GLOBALS['beatnik_driver'], __FILE__, __LINE__);
+try {
+ $GLOBALS['beatnik_driver'] = Beatnik_Driver::factory();
+} catch (Exception $e) {
+ Horde::fatal($e, __FILE__, __LINE__);
}
// Get a list of domains to work with
// Jump to new domain
if (Horde_Util::getFormData('curdomain') !== null && !empty($domains)) {
- $domain = $GLOBALS['beatnik_driver']->getDomain(Horde_Util::getFormData('curdomain'));
- if (is_a($domain, 'PEAR_Error')) {
- $notification->push($domain->getMessage() . ': ' . $domain->getDebugInfo(), 'horde.error');
+ try {
+ $domain = $GLOBALS['beatnik_driver']->getDomain(Horde_Util::getFormData('curdomain'));
+ } catch (Exception $e) {
+ $notification->push($e->getMessage(), 'horde.error');
$domain = $domains[0];
}
// We accept the user name on the command-line.
require_once 'Console/Getopt.php';
-$ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'h:u:p:t:r',
+try {
+ Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'h:u:p:t:r',
array('help', 'username=', 'password=', 'type=', 'rpc='));
-
-if (is_a($ret, 'PEAR_Error')) {
+} catch (Exception $e) {
$error = _("Couldn't read command-line options.");
Horde::logMessage($error, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$cli->fatal($error);
// We will fetch data from RPC
if (!empty($rpc)) {
-
- require_once 'Horde/RPC.php';
- $domains = Horde_RPC::request('xmlrpc', $rpc,
- 'dns.getDomains',
- array(),
- array('user' => $username,
- 'pass' => $password));
- if (is_a($result, 'PEAR_Error')) {
- $cli->fatal($domains);
+ try {
+ $domains = Horde_RPC::request('xmlrpc', $rpc, 'dns.getDomains', array(),
+ array('user' => $username,
+ 'pass' => $password));
+ } catch (Exception $e) {
+ $cli->fatal($e);
}
// Login to horde if username & password are set and load module.
} elseif (!empty($username) && !empty($password)) {
- require_once HORDE_BASE . '/lib/base.php';
+ require_once HORDE_BASE . '/lib/base.php';
$auth = &Horde_Auth::singleton($conf['auth']['driver']);
if (!$auth->authenticate($username, array('password' => $password))) {
$error = _("Login is incorrect.");
if (empty($GLOBALS['rpc'])) {
$result = $GLOBALS['beatnik_driver']->getRecords($domain);
} else {
+ try {
$result = Horde_RPC::request('xmlrpc', $GLOBALS['rpc'],
- 'dns.getRecords',
- array($domain),
- array('user' => $GLOBALS['username'],
- 'pass' => $GLOBALS['password']));
+ 'dns.getRecords',
+ array($domain),
+ array('user' => $GLOBALS['username'],
+ 'pass' => $GLOBALS['password']));
+ } catch (Exception $e) {
+ $GLOBALS['cli']->fatal($e);
+ }
}
- if (is_a($result, 'PEAR_Error')) {
- $GLOBALS['cli']->fatal($result);
- } else {
- return $result;
- }
+ return $result;
}
/**
require_once BEATNIK_BASE . '/lib/base.php';
require_once BEATNIK_BASE . '/lib/Beatnik.php';
-$zonedata = $beatnik_driver->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
-if (is_a($zonedata, 'PEAR_Error')) {
- $notification->push($zonedata, 'horde.error');
+try {
+ $zonedata = $beatnik_driver->getRecords($_SESSION['beatnik']['curdomain']['zonename']);
+} catch (Exception $e) {
+ $notification->push($e, 'horde.error');
header('Location:' . Horde::applicationUrl('listzones.php'));
exit;
}