Use injector to get notification object
authorMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 16 Feb 2010 16:56:05 +0000 (11:56 -0500)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Tue, 16 Feb 2010 16:56:05 +0000 (11:56 -0500)
ansel/lib/View/Image.php
ansel/lib/View/List.php
ansel/lib/View/Results.php

index b552f56..976b7de 100644 (file)
@@ -30,7 +30,7 @@ class Ansel_View_Image extends Ansel_View_Base
     public function __construct($params = array())
     {
         parent::__construct($params);
-
+        
         /* Get the Ansel_Image */
         $image = &$GLOBALS['ansel_storage']->getImage($params['image_id']);
 
index 55a27c3..459b5c4 100644 (file)
@@ -43,10 +43,13 @@ class Ansel_View_List extends Ansel_View_Base
      */
     public function __construct($params = array())
     {
-        global $prefs, $ansel_storage, $notification;
+        global $prefs, $ansel_storage;
 
         parent::__construct($params);
 
+        /* Notifications */
+        $notification = $GLOBALS['injector']->getInstance('Horde_Notification');
+
         // We'll need this in the template.
         $this->_sortBy = !empty($this->_params['sort']) ? $this->_params['sort'] : 'name';
         $this->_sortDir = isset($this->_params['sort_dir']) ? $this->_params['sort_dir'] : 0;
@@ -186,7 +189,7 @@ class Ansel_View_List extends Ansel_View_Base
      */
     public function html()
     {
-        global $conf, $prefs, $registry, $ansel_storage, $notification;
+        global $conf, $prefs, $registry, $ansel_storage;
 
         $vars = Horde_Variables::getDefaultVariables();
         if (!empty($this->_params['page'])) {
index 1567d52..2e78fe2 100644 (file)
@@ -34,6 +34,8 @@ class Ansel_View_Results extends Ansel_View_Base
     {
         global $prefs, $conf, $ansel_storage;
 
+        $notification = $GLOBALS['injector']->getInstance('Horde_Notification');
+
         $this->_owner = Horde_Util::getFormData('owner', null);
         $this->_search = Ansel_Tags::getSearch(null, $this->_owner);
         $this->_page = Horde_Util::getFormData('page', 0);
@@ -61,18 +63,16 @@ class Ansel_View_Results extends Ansel_View_Base
                  $img = $ansel_storage->getImage($image);
                  $gallery = $ansel_storage->getgallery($img->gallery);
                  if (!$gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::DELETE)) {
-                     $GLOBALS['notification']->push(
+                     $notification->push(
                         sprintf(_("Access denied deleting photos from \"%s\"."), $image),
                                 'horde.error');
                  } else {
                      $result = $gallery->removeImage($image);
                     if (is_a($result, 'PEAR_Error')) {
-                        $GLOBALS['notification']->push(
-                            sprintf(_("There was a problem deleting photos: %s"),
-                                    $result->getMessage()), 'horde.error');
+                        $notification->push(
+                            sprintf(_("There was a problem deleting photos: %s"), $result->getMessage()), 'horde.error');
                     } else {
-                        $GLOBALS['notification']->push(_("Deleted the photo."),
-                                                       'horde.success');
+                        $notification->push(_("Deleted the photo."), 'horde.success');
                         Ansel_Tags::clearCache();
                     }
                  }
@@ -97,8 +97,7 @@ class Ansel_View_Results extends Ansel_View_Base
             if ($images && $newGallery) {
                 $newGallery = $ansel_storage->getGallery($newGallery);
                 if (is_a($newGallery, 'PEAR_Error')) {
-                    $GLOBALS['notification']->push(_("Bad input."),
-                                                   'horde.error');
+                    $notification->push(_("Bad input."), 'horde.error');
                 } else {
                     // Group by gallery first, then process in bulk by gallery.
                     $galleries = array();
@@ -110,9 +109,9 @@ class Ansel_View_Results extends Ansel_View_Base
                         $gallery = $ansel_storage->getGallery($gallery_id);
                         $result = $gallery->moveImagesTo($images, $newGallery);
                         if (is_a($result, 'PEAR_Error')) {
-                            $GLOBALS['notification']->push($result, 'horde.error');
+                            $notification->push($result, 'horde.error');
                         } else {
-                            $GLOBALS['notification']->push(
+                            $notification->push(
                                 sprintf(ngettext("Moved %d photo from \"%s\" to \"%s\"",
                                                  "Moved %d photos from \"%s\" to \"%s\"",
                                                  count($images)),
@@ -145,8 +144,7 @@ class Ansel_View_Results extends Ansel_View_Base
             if ($images && $newGallery) {
                 $newGallery = $ansel_storage->getGallery($newGallery);
                 if (is_a($newGallery, 'PEAR_Error')) {
-                    $GLOBALS['notification']->push(_("Bad input."),
-                                                   'horde.error');
+                    $notification->push(_("Bad input."), 'horde.error');
                 } else {
                     // Group by gallery first, then process in bulk by gallery.
                     $galleries = array();
@@ -158,10 +156,9 @@ class Ansel_View_Results extends Ansel_View_Base
                         $gallery = $ansel_storage->getGallery($gallery_id);
                         $result = $gallery->copyImagesTo($images, $newGallery);
                         if (is_a($result, 'PEAR_Error')) {
-                            $GLOBALS['notification']->push($result,
-                                                           'horde.error');
+                            $notification->push($result, 'horde.error');
                         } else {
-                            $GLOBALS['notification']->push(
+                            $notification->push(
                                 sprintf(ngettext("Copied %d photo from %s to %s",
                                                  "Copied %d photos from %s to %s",
                                                  count($images)),