Use Horde_Vfs injector; don't call Horde::fatal() directly
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 12 Aug 2010 19:30:40 +0000 (13:30 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 12 Aug 2010 19:48:20 +0000 (13:48 -0600)
whups/view.php

index 7e9063c..71fd7a5 100644 (file)
@@ -21,27 +21,28 @@ if (empty($id)) {
     exit;
 }
 $details = $whups_driver->getTicketDetails($id);
-if (is_a($details, 'PEAR_Error')) {
+if ($details instanceof PEAR_Error) {
     if ($details->code === 0) {
         // No permissions to this ticket.
         Horde::url($registry->get('webroot', 'horde') . '/login.php', true)
             ->add('url', Horde::selfUrl(true))
             ->redirect();
     } else {
-        Horde::fatal($details->getMessage(), __FILE__, __LINE__);
+        throw new Horde_Exception($details);
     }
 }
 
 // Check permissions on this ticket.
 if (!count(Whups::permissionsFilter($whups_driver->getHistory($id), 'comment', Horde_Perms::READ))) {
-    Horde::fatal(sprintf(_("You are not allowed to view ticket %d."), $id), __FILE__, __LINE__);
+    throw new Horde_Exception(sprintf(_("You are not allowed to view ticket %d."), $id));
 }
 
-if (empty($conf['vfs']['type'])) {
-    Horde::fatal(_("The VFS backend needs to be configured to enable attachment uploads."), __FILE__, __LINE__);
+try {
+    $injector->getInstance('Horde_Vfs')->getVfs('whups');
+} catch (Horde_Exception $e) {
+    throw new Horde_Exception(_("The VFS backend needs to be configured to enable attachment uploads."));
 }
 
-$vfs = VFS::factory($conf['vfs']['type'], Horde::getDriverConfig('vfs'));
 try {
     $data = $vfs->read(WHUPS_VFS_ATTACH_PATH . '/' . $id, $filename);
 } catch (VFS_Exception $e) {