From: Michael M Slusarz Date: Wed, 11 Aug 2010 22:26:02 +0000 (-0600) Subject: Clean up delete.php script X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8266fff3af355ca63e771cbce84e333201535912;p=horde.git Clean up delete.php script Fix obtaining URL for redirect, since Horde_Util::getFormData() only uses the default if the parameter is NULL (here, URL might be the empty string). --- diff --git a/turba/delete.php b/turba/delete.php index f2931d000..0ea481e59 100644 --- a/turba/delete.php +++ b/turba/delete.php @@ -7,7 +7,10 @@ * See the enclosed file LICENSE for license information (ASL). If you * did not receive this file, see http://www.horde.org/licenses/asl.php. * - * @author Chuck Hagenbuch + * @author Chuck Hagenbuch + * @category Horde + * @license http://www.horde.org/licenses/asl.php ASL + * @package Turba */ require_once dirname(__FILE__) . '/lib/Application.php'; @@ -19,19 +22,24 @@ $driver = Turba_Driver::singleton($source); if ($conf['documents']['type'] != 'none') { $object = $driver->getObject($key); - if (is_a($object, 'PEAR_Error')) { + if ($object instanceof PEAR_Error) { $notification->push($object->getMessage(), 'horde.error'); Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } - if (is_a($deleted = $object->deleteFiles(), 'PEAR_Error')) { + + $deleted = $object->deleteFiles(); + if ($deleted instanceof PEAR_Error) { $notification->push($deleted, 'horde.error'); Horde::applicationUrl($prefs->getValue('initial_page'), true)->redirect(); } } -if (!is_a($result = $driver->delete($key), 'PEAR_Error')) { - header('Location: ' . Horde_Util::getFormData('url', Horde::url($prefs->getValue('initial_page'), true))); - exit; +$result = $driver->delete($key); +if (!($result instanceof PEAR_Error)) { + $url = ($url = Horde_Util::getFormData('url')) + ? new Horde_Url($url) + : Horde::applicationUrl($prefs->getValue('initial_page'), true); + $url->redirect(); } $notification->push(sprintf(_("There was an error deleting this contact: %s"), $result->getMessage()), 'horde.error');