From: Michael M Slusarz Date: Wed, 1 Sep 2010 18:08:38 +0000 (-0600) Subject: More H4 conversions X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b005b542c04e6bac2a9fd3deebcb53302af4607f;p=horde.git More H4 conversions --- diff --git a/horde/admin/groups.php b/horde/admin/groups.php index 4000ee707..830b37397 100644 --- a/horde/admin/groups.php +++ b/horde/admin/groups.php @@ -235,7 +235,7 @@ foreach ($nodes as $id => $node) { $node_params = ($cid == $id) ? array('class' => 'selected') : array(); if ($id == Horde_Group::ROOT) { - $add_link = Horde::link(Horde_Util::addParameter($add, 'cid', $id), _("Add a new group")) . $add_img . ''; + $add_link = Horde::link($add->copy()->add('cid', $id), _("Add a new group")) . $add_img . ''; $base_node_params = array('icon' => strval(Horde_Themes::img('administration.png'))); $tree->addNode( @@ -249,9 +249,9 @@ foreach ($nodes as $id => $node) { ); } else { $name = $groups->getGroupShortName($node); - $node_params['url'] = Horde_Util::addParameter($edit, 'cid', $id); - $add_link = Horde::link(Horde_Util::addParameter($add, 'cid', $id), sprintf(_("Add a child group to \"%s\""), $name)) . $add_img . ''; - $delete_link = Horde::link(Horde_Util::addParameter($delete, 'cid', $id), sprintf(_("Delete \"%s\""), $name)) . $delete_img . ''; + $node_params['url'] = $edit->copy()->add('cid', $id); + $add_link = Horde::link($add->copy()->add('cid', $id), sprintf(_("Add a child group to \"%s\""), $name)) . $add_img . ''; + $delete_link = Horde::link($delete->copy()->add('cid', $id), sprintf(_("Delete \"%s\""), $name)) . $delete_img . ''; $tree->addNode( $id, diff --git a/horde/admin/setup/config.php b/horde/admin/setup/config.php index 25d66179e..91880ec2e 100644 --- a/horde/admin/setup/config.php +++ b/horde/admin/setup/config.php @@ -76,8 +76,7 @@ $template->set('php', htmlspecialchars($php), true); /* Create the link for the diff popup only if stored in session. */ $diff_link = ''; if (!empty($_SESSION['_config'][$app])) { - $url = Horde::url('admin/setup/diff.php', true); - $url = Horde_Util::addParameter($url, 'app', $app, false); + $url = Horde::url('admin/setup/diff.php', true)->add('app', $app); $diff_link = Horde::link('#', '', '', '', Horde::popupJs($url, array('height' => 480, 'width' => 640, 'urlencode' => true)) . 'return false;') . _("show differences") . ''; } $template->set('diff_popup', $diff_link, true); diff --git a/horde/admin/setup/diff.php b/horde/admin/setup/diff.php index 0aaa88b8c..cc99f09eb 100644 --- a/horde/admin/setup/diff.php +++ b/horde/admin/setup/diff.php @@ -44,8 +44,7 @@ $diffs = array(); /* Only bother to do anything if there is any config. */ if (!empty($_SESSION['_config'])) { /* Set up the toggle button for inline/unified. */ - $url = Horde::url('admin/setup/diff.php'); - $url = Horde_Util::addParameter($url, 'render', ($render_type == 'inline') ? 'unified' : 'inline'); + $url = Horde::url('admin/setup/diff.php')->add('render', ($render_type == 'inline') ? 'unified' : 'inline'); if ($app = Horde_Util::getFormData('app')) { /* Handle a single app request. */ diff --git a/horde/admin/sqlshell.php b/horde/admin/sqlshell.php index b9cadcacf..9f1a22fdd 100644 --- a/horde/admin/sqlshell.php +++ b/horde/admin/sqlshell.php @@ -58,7 +58,7 @@ if (isset($result)) { echo '

' . _("Results") . '


'; - if (is_a($result, 'PEAR_Error')) { + if ($result instanceof PEAR_Error) { echo '
'; var_dump($result); echo '
'; } else { if (is_object($result)) { diff --git a/horde/admin/user.php b/horde/admin/user.php index d85db6e4d..c4a16a34c 100644 --- a/horde/admin/user.php +++ b/horde/admin/user.php @@ -49,7 +49,6 @@ if (empty($extra)) { $addForm->addVariable(_("Password"), 'password', 'passwordconfirm', false, false, _("type the password twice to confirm")); } - // Process forms. Use Horde_Util::getPost() instead of Horde_Util::getFormData() // for a lot of the data because we want to actively ignore GET data // in some cases - adding/modifying users - as a security precaution. @@ -79,22 +78,27 @@ case 'add': } } - if (is_a($ret = $auth->addUser($info['user_name'], $credentials), 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem adding \"%s\" to the system: %s"), $info['user_name'], $ret->getMessage()), 'horde.error'); - } else { - if (isset($info['extra'])) { - try { - Horde::callHook('signup_addextra', array($info['user_name'], $info['extra'])); - } catch (Horde_Exception $e) { - $notification->push(sprintf(_("Added \"%s\" to the system, but could not add additional signup information: %s."), $info['user_name'], $e->getMessage()), 'horde.warning'); - } catch (Horde_Exception_HookNotSet $e) {} - } - if (Horde_Util::getFormData('removeQueuedSignup')) { - $signup->removeQueuedSignup($info['user_name']); - } - $notification->push(sprintf(_("Successfully added \"%s\" to the system."), $info['user_name']), 'horde.success'); - $addForm->unsetVars($vars); + try { + $auth->addUser($info['user_name'], $credentials); + } catch (Horde_Auth_Exception $e) { + $notification->push(sprintf(_("There was a problem adding \"%s\" to the system: %s"), $info['user_name'], $e->getMessage()), 'horde.error'); + break; } + + if (isset($info['extra'])) { + try { + Horde::callHook('signup_addextra', array($info['user_name'], $info['extra'])); + } catch (Horde_Exception $e) { + $notification->push(sprintf(_("Added \"%s\" to the system, but could not add additional signup information: %s."), $info['user_name'], $e->getMessage()), 'horde.warning'); + } catch (Horde_Exception_HookNotSet $e) {} + } + + if (Horde_Util::getFormData('removeQueuedSignup')) { + $signup->removeQueuedSignup($info['user_name']); + } + + $notification->push(sprintf(_("Successfully added \"%s\" to the system."), $info['user_name']), 'horde.success'); + $addForm->unsetVars($vars); } } break; @@ -109,10 +113,11 @@ case 'remove': if (empty($f_user_name)) { $notification->push(_("You must specify a username to remove."), 'horde.message'); } elseif (Horde_Util::getFormData('submit') !== _("Cancel")) { - if (is_a($result = $auth->removeUser($f_user_name), 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem removing \"%s\" from the system: ") . $result->getMessage(), $f_user_name), 'horde.error'); - } else { + try { + $auth->removeUser($f_user_name); $notification->push(sprintf(_("Successfully removed \"%s\" from the system."), $f_user_name), 'horde.success'); + } catch (Horde_Auth_Exception $e) { + $notification->push(sprintf(_("There was a problem removing \"%s\" from the system: ") . $e->getMessage(), $f_user_name), 'horde.error'); } } $vars->remove('user_name'); @@ -128,10 +133,11 @@ case 'clear': if (empty($f_user_name)) { $notification->push(_("You must specify a username to clear out."), 'horde.message'); } elseif (Horde_Util::getFormData('submit') !== _("Cancel")) { - if (is_a($result = $auth->removeUserData($f_user_name), 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem clearing data for user \"%s\" from the system: ") . $result->getMessage(), $f_user_name), 'horde.error'); - } else { + try { + $auth->removeUserData($f_user_name); $notification->push(sprintf(_("Successfully cleared data for user \"%s\" from the system."), $f_user_name), 'horde.success'); + } catch (Horde_Auth_Exception $e) { + $notification->push(sprintf(_("There was a problem clearing data for user \"%s\" from the system: ") . $e->getMessage(), $f_user_name), 'horde.error'); } } $vars->remove('user_name'); @@ -148,7 +154,8 @@ case 'update': $fullname = Horde_Util::getPost('user_fullname'); $email = Horde_Util::getPost('user_email'); - $result = false; + $vars->remove('user_name'); + if ($auth->hasCapability('update')) { $user_pass_1 = Horde_Util::getPost('user_pass_1'); $user_pass_2 = Horde_Util::getPost('user_pass_2'); @@ -160,25 +167,21 @@ case 'update': } elseif ($user_pass_1 != $user_pass_2) { $notification->push(_("Passwords must match."), 'horde.error'); } else { - $result = $auth->updateUser($user_name_1, - $user_name_2, - array('password' => $user_pass_1)); + try { + $auth->updateUser($user_name_1, $user_name_2, array('password' => $user_pass_1)); + } catch (Horde_Auth_Exception $e) { + $notification->push(sprintf(_("There was a problem updating \"%s\": %s"), $user_name_1, $e->getMessage()), 'horde.error'); + break; + } } } - if (is_a($result, 'PEAR_Error')) { - $notification->push(sprintf(_("There was a problem updating \"%s\": %s"), - $user_name_1, $result->getMessage()), 'horde.error'); - } else { - $identity = $injector->getInstance('Horde_Prefs_Identity')->getIdentity($user_name_1); - $identity->setValue('fullname', $fullname); - $identity->setValue('from_addr', $email); - $identity->save(); - - $notification->push(sprintf(_("Successfully updated \"%s\""), - $user_name_2), 'horde.success'); - } - $vars->remove('user_name'); + $identity = $injector->getInstance('Horde_Prefs_Identity')->getIdentity($user_name_1); + $identity->setValue('fullname', $fullname); + $identity->setValue('from_addr', $email); + $identity->save(); + + $notification->push(sprintf(_("Successfully updated \"%s\""), $user_name_2), 'horde.success'); break; case 'approve_f': @@ -201,11 +204,11 @@ case 'removequeued_f': break; case 'removequeued': - $result = $signup->removeQueuedSignup(Horde_Util::getFormData('user_name')); - if (is_a($result, 'PEAR_Error')) { - $notification->push($result); - } else { + try { + $signup->removeQueuedSignup(Horde_Util::getFormData('user_name')); $notification->push(sprintf(_("The signup request for \"%s\" has been removed."), Horde_Util::getFormData('user_name'))); + } catch (Horde_Exception $e) { + $notification->push($e); } break; } @@ -248,15 +251,12 @@ if ($auth->hasCapability('list')) { $search_pattern = Horde_Util::getFormData('search_pattern', ''); $users = $auth->listUsers(); - if (is_a($users, 'PEAR_Error')) { - throw new Horde_Exception_Prior($users); - } /* Returns only users that match the specified pattern. */ $users = preg_grep('/' . $search_pattern . '/', $users); sort($users); - $viewurl = Horde_Util::addParameter('admin/user.php', 'search_pattern', $search_pattern); + $viewurl = Horde::url('admin/user.php')->add('search_pattern', $search_pattern); $numitem = count($users); $perpage = 20; diff --git a/horde/lib/Block/cloud.php b/horde/lib/Block/cloud.php index fab6d045c..da97866c7 100644 --- a/horde/lib/Block/cloud.php +++ b/horde/lib/Block/cloud.php @@ -58,10 +58,9 @@ class Horde_Block_Horde_cloud extends Horde_Block $results = array(); foreach ($GLOBALS['registry']->listAPIs() as $api) { if ($GLOBALS['registry']->hasMethod($api . '/listTagInfo')) { - $result = $GLOBALS['registry']->call($api . '/listTagInfo'); - if (!is_a($result, 'PEAR_Error')) { - $results = array_merge($results, $result); - } + try { + $results = array_merge($results, $GLOBALS['registry']->call($api . '/listTagInfo')); + } catch (Horde_Exception $e) {} } } diff --git a/horde/lib/Prefs/Ui.php b/horde/lib/Prefs/Ui.php index 2b7b2ce98..f0b8ac0d9 100644 --- a/horde/lib/Prefs/Ui.php +++ b/horde/lib/Prefs/Ui.php @@ -521,7 +521,8 @@ class Horde_Prefs_Ui /* URL links */ $url = $facebook->auth->getExtendedPermUrl( Horde_Service_Facebook_Auth::EXTEND_PERMS_OFFLINE, - Horde_Util::addParameter(Horde::url('services/facebook.php', true), 'action', 'authsuccess')); + Horde::url('services/facebook.php', true)->add('action', 'authsuccess') + ); $t->set('authUrl', Horde::signQueryString($url)); $t->set('have_session', true); $t->set('user_pic_url', $user_info[0]['pic_with_logo']); diff --git a/horde/services/problem.php b/horde/services/problem.php index c2b09787f..73f5cf30f 100644 --- a/horde/services/problem.php +++ b/horde/services/problem.php @@ -69,23 +69,31 @@ case 'send_problem_report': array('summary' => $subject, 'comment' => $body, 'user_email' => $email)); - $result = $registry->call('tickets/addTicket', array($info)); - if (is_a($result, 'PEAR_Error')) { - $notification->push($result); - } else { - if ($attachment && - $registry->hasMethod('tickets/addAttachment')) { - $result = $registry->call( + + try { + $registry->call('tickets/addTicket', array($info)); + } catch (Horde_Exception $e) { + $notification->push($e); + break; + } + + if ($attachment && + $registry->hasMethod('tickets/addAttachment')) { + try { + $registry->call( 'tickets/addAttachment', - array('ticket_id' => $result, - 'name' => $attachment['name'], - 'data' => file_get_contents($attachment['tmp_name']))); - if (is_a($result, 'PEAR_Error')) { - $notification->push($result); - } + array( + 'ticket_id' => $result, + 'name' => $attachment['name'], + 'data' => file_get_contents($attachment['tmp_name']) + ) + ); + } catch (Horde_Exception $e) { + $notification->push($e); } - _returnToPage(); } + + _returnToPage(); } else { /* Add user's name to the email address if provided. */ if ($name) {