[dev] lib/notification.php - new function

steve mailling at gmx.co.uk
Sun Aug 24 23:44:00 PDT 2003


Here is a new patch for the function detach()
I removed also the fatal called.

btw, what do you mean by attach the patch? do you want it in attached file?

diff -u -r1.29 Notification.php
--- Notification.php	19 Jun 2003 18:47:43 -0000	1.29
+++ Notification.php	24 Aug 2003 06:19:59 -0000
@@ -65,6 +65,8 @@
       * Registers a listener with the notification object and includes
       * the necessary library file dynamically.
       *
+     * @access public
+     *
       * @param string $driver          The name of the listener to attach.
       *                                These names must be unique; further
       *                                listeners with the same name will be
@@ -99,11 +101,30 @@
              }
              return $this->_listeners[$listener];
          } else {
-            Horde::fatal(PEAR::raiseError(sprintf(_("Notification listener 
%s not found."), $listener)), __FILE__, __LINE__);
+            return PEAR::raiseError(sprintf(_("Notification listener %s 
not found."), $listener));
          }
      }

      /**
+     * Remove a listener from the notification list
+     *
+     * @access public
+     *
+     * @param string $listner          The name of the listener to detach.
+     */
+    function detach($listener)
+    {
+        $listener = String::lower(basename($listener));
+        if (!array_key_exists($listener, $this->_listeners)) {
+            return PEAR::raiseError(sprintf(_("Notification listener %s 
not found."), $listener));
+        }
+
+        unset($this->_listeners[$listener]);
+        unset($_SESSION['hordeMessageStacks'][$listener]);
+        return true;
+    }
+
+    /**
       * Add an event to the Horde message stack.
       *
       * The event type parameter should begin with 'horde.' unless the
@@ -136,7 +157,8 @@
                  $_SESSION['hordeMessageStacks'][$listener->getName()][] = 
array('type' => $type,
                                                                                  'class' 
=> get_class($event),
                                                                                  'event' 
=> serialize($event));
-            }
+
+			}
          }
      }


***** CVS exited normally with code 1 ***** 



More information about the dev mailing list