More H4 conversions
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Sep 2010 18:08:38 +0000 (12:08 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 1 Sep 2010 18:09:10 +0000 (12:09 -0600)
horde/admin/groups.php
horde/admin/setup/config.php
horde/admin/setup/diff.php
horde/admin/sqlshell.php
horde/admin/user.php
horde/lib/Block/cloud.php
horde/lib/Prefs/Ui.php
horde/services/problem.php

index 4000ee7..830b373 100644 (file)
@@ -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 . '</a>';
+        $add_link = Horde::link($add->copy()->add('cid', $id), _("Add a new group")) . $add_img . '</a>';
 
         $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 . '</a>';
-        $delete_link = Horde::link(Horde_Util::addParameter($delete, 'cid', $id), sprintf(_("Delete \"%s\""), $name)) . $delete_img . '</a>';
+        $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 . '</a>';
+        $delete_link = Horde::link($delete->copy()->add('cid', $id), sprintf(_("Delete \"%s\""), $name)) . $delete_img . '</a>';
 
         $tree->addNode(
             $id,
index 25d6617..91880ec 100644 (file)
@@ -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") . '</a>';
 }
 $template->set('diff_popup', $diff_link, true);
index 0aaa88b..cc99f09 100644 (file)
@@ -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. */
index b9cadca..9f1a22f 100644 (file)
@@ -58,7 +58,7 @@ if (isset($result)) {
 
     echo '<h1 class="header">' . _("Results") . '</h1><br />';
 
-    if (is_a($result, 'PEAR_Error')) {
+    if ($result instanceof PEAR_Error) {
         echo '<pre class="text">'; var_dump($result); echo '</pre>';
     } else {
         if (is_object($result)) {
index d85db6e..c4a16a3 100644 (file)
@@ -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;
index fab6d04..da97866 100644 (file)
@@ -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) {}
             }
         }
 
index 2b7b2ce..f0b8ac0 100644 (file)
@@ -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']);
index c2b0978..73f5cf3 100644 (file)
@@ -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) {