From: Michael J. Rubinsky Date: Thu, 13 Jan 2011 17:23:35 +0000 (-0500) Subject: Catch exceptions, get rid of last bit of PEAR_Error checks X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=4a8b189fd293b3220d67a33931e62baa9725bf4f;p=horde.git Catch exceptions, get rid of last bit of PEAR_Error checks --- diff --git a/hermes/lib/Admin.php b/hermes/lib/Admin.php index 9be88af27..c42b9b5a6 100644 --- a/hermes/lib/Admin.php +++ b/hermes/lib/Admin.php @@ -135,16 +135,18 @@ class EditClientStep1Form extends Horde_Form { { parent::Horde_Form($vars, 'editclientstep1form'); - $clients = Hermes::listClients(); - if (is_a($clients, 'PEAR_Error')) { + try { + $clients = Hermes::listClients(); + if (count($clients)) { + $subtype = 'enum'; + $type_params = array($clients); + } else { + $subtype = 'invalid'; + $type_params = array(_("There are no clients to edit")); + } + } catch (Hermes_Exception $e) { $subtype = 'invalid'; $type_params = array($clients->getMessage()); - } elseif (count($clients)) { - $subtype = 'enum'; - $type_params = array($clients); - } else { - $subtype = 'invalid'; - $type_params = array(_("There are no clients to edit")); } $this->addVariable(_("Client Name"), 'client', $subtype, true, false, null, $type_params); diff --git a/hermes/lib/Driver/sql.php b/hermes/lib/Driver/sql.php index 08d592474..803a4d17a 100644 --- a/hermes/lib/Driver/sql.php +++ b/hermes/lib/Driver/sql.php @@ -533,8 +533,6 @@ class Hermes_Driver_Sql extends Hermes_Driver } $deliverables = array(); - //$row = $result->fetchRow(DB_FETCHMODE_ASSOC); - //while (!empty($row) && !is_a($row, 'PEAR_Error')) { foreach ($rows as $row) { $deliverable = array('id' => $row['deliverable_id'], 'client_id' => $row['client_id'], diff --git a/hermes/lib/Form/JobType/Add.php b/hermes/lib/Form/JobType/Add.php new file mode 100644 index 000000000..008176fbc --- /dev/null +++ b/hermes/lib/Form/JobType/Add.php @@ -0,0 +1,23 @@ + + */ +class Hermes_Form_JobType_Add extends Horde_Form +{ + public function __construct(&$vars) + { + parent::Horde_Form($vars, 'addjobtypeform'); + $this->addVariable(_("Job Type"), 'name', 'text', true); + $var = &$this->addVariable(_("Enabled?"), 'enabled', 'boolean', false); + $var->setDefault(true); + $var = &$this->addVariable(_("Billable?"), 'billable', 'boolean', false); + $var->setDefault(true); + $this->addVariable(_("Hourly Rate"), 'rate', 'number', false); + } + +} \ No newline at end of file diff --git a/hermes/lib/Form/JobType/Edit/Step1.php b/hermes/lib/Form/JobType/Edit/Step1.php new file mode 100644 index 000000000..7fd0ba752 --- /dev/null +++ b/hermes/lib/Form/JobType/Edit/Step1.php @@ -0,0 +1,39 @@ + + */ +class Hermes_Form_JobType_Edit_Step1 extends Horde_Form +{ + public function __construct(&$vars) + { + parent::Horde_Form($vars, 'editjobtypestep1form'); + + $values = array(); + try { + $jobtypes = $GLOBALS['injector']->getInstance('Hermes_Driver')->listJobTypes(); + foreach ($jobtypes as $id => $jobtype) { + $values[$id] = $jobtype['name']; + if (empty($jobtype['enabled'])) { + $values[$id] .= _(" (DISABLED)"); + } + } + } catch (Hermes_Exception $e) {} + + if ($values) { + $subtype = 'enum'; + $type_params = array($values); + } else { + $subtype = 'invalid'; + $type_params = array(_("There are no job types to edit")); + } + + $this->addVariable(_("JobType Name"), 'jobtype', $subtype, true, false, null, $type_params); + } + +} \ No newline at end of file diff --git a/hermes/lib/Table.php b/hermes/lib/Table.php index c8e9c2db4..0ce71a5c0 100644 --- a/hermes/lib/Table.php +++ b/hermes/lib/Table.php @@ -23,6 +23,11 @@ class Hermes_Table extends Horde_Core_Ui_Widget */ protected $_formVars = array(); + /** + * + * @return array + * @throws Hermes_Exception + */ public function getMetaData() { if (is_null($this->_metaData)) { @@ -30,9 +35,7 @@ class Hermes_Table extends Horde_Core_Ui_Widget $args = array($name, $this->_config['params']); $this->_metaData = $GLOBALS['registry']->callByPackage( $app, 'getTableMetaData', $args); - if (is_a($this->_metaData, 'PEAR_Error')) { - return $this->_metaData; - } + // We need to make vars for the columns. foreach ($this->_metaData['sections'] as $secname => $section) { @@ -79,14 +82,12 @@ class Hermes_Table extends Horde_Core_Ui_Widget * Returns the largest column count of any section, taking into account * 'colspan' attributes. * - * @return mixed number of columns or PEAR_Error + * @return integer number of columns + * @throws Hermes_Exception */ public function getColumnCount() { $res = $this->getMetaData(); - if (is_a($res, 'PEAR_Error')) { - return $res; - } $colcount = 0; foreach ($this->_metaData['sections'] as $section) { $sec_colcount = 0; @@ -112,9 +113,10 @@ class Hermes_Table extends Horde_Core_Ui_Widget { global $notification; - $result = $this->getMetaData(); - if (is_a($result, 'PEAR_Error')) { - $notification->push($result, 'horde.error'); + try { + $result = $this->getMetaData(); + } catch (Hermes_Exception $e) { + $notification->push($e->getMessage(), 'horde.error'); return false; } @@ -163,9 +165,10 @@ class Hermes_Table extends Horde_Core_Ui_Widget $html .= ''; // Display data. - $data = $this->_getData(); - if (is_a($data, 'PEAR_Error')) { - $notification->push($data, 'horde.error'); + try { + $data = $this->_getData(); + } catch (Hermes_Exception $e) { + $notification->push($e, 'horde.error'); $data = array(); }