pax_global_header 0000666 0000000 0000000 00000000064 12056172473 0014521 g ustar 00root root 0000000 0000000 52 comment=54ac530b4307a6c0c31be3c1758665eef326b299
php-horde-notification-2.0.1/ 0000775 0000000 0000000 00000000000 12056172473 0016073 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/ 0000775 0000000 0000000 00000000000 12056172473 0022276 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/doc/ 0000775 0000000 0000000 00000000000 12056172473 0023043 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/doc/Horde/ 0000775 0000000 0000000 00000000000 12056172473 0024104 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/doc/Horde/Notification/ 0000775 0000000 0000000 00000000000 12056172473 0026532 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/doc/Horde/Notification/COPYING 0000664 0000000 0000000 00000057646 12056172473 0027607 0 ustar 00root root 0000000 0000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/ 0000775 0000000 0000000 00000000000 12056172473 0023044 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/ 0000775 0000000 0000000 00000000000 12056172473 0024105 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification.php 0000664 0000000 0000000 00000002571 12056172473 0027251 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification
{
/**
* Horde_Notification instances.
*
* @var Horde_Notification
*/
static protected $_instances = array();
/**
* Returns a reference to the global notification handler, only
* creating it if it doesn't already exist.
*
* This method must be invoked as:
* $notification = Horde_Notification::singleton([$stack]);
*
* @param string $stack The name of the message stack to use.
*
* return Horde_Notification_Handler The Horde Notification handler.
*/
static public function singleton($stack = 'horde_notification_stacks')
{
if (!isset(self::$_instances[$stack])) {
self::$_instances[$stack] = new Horde_Notification_Handler(new Horde_Notification_Storage_Session($stack));
}
return self::$_instances[$stack];
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/ 0000775 0000000 0000000 00000000000 12056172473 0026533 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Event.php 0000664 0000000 0000000 00000005122 12056172473 0030325 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Event
{
/**
* The message being passed.
*
* @var string
*/
public $message = '';
/**
* The flags for this message.
*
* @var array
*/
public $flags = array();
/**
* The message type.
*
* @var string
*/
public $type;
/**
* Constructor.
*
* @param mixed $data Message: either a string or an Exception or
* PEAR_Error object.
* @param string $type The event type.
* @param array $flags The flag array.
*/
public function __construct($data, $type = null, array $flags = array())
{
$this->flags = $flags;
$this->type = empty($type)
? 'status'
: $type;
if ($data instanceof PEAR_Error) {
// DEPRECATED
if (($userinfo = $data->getUserInfo()) &&
is_array($userinfo)) {
$userinfo_elts = array();
foreach ($userinfo as $userinfo_elt) {
if (is_scalar($userinfo_elt)) {
$userinfo_elts[] = $userinfo_elt;
} elseif (is_object($userinfo_elt)) {
if (is_callable(array($userinfo_elt, '__toString'))) {
$userinfo_elts[] = $userinfo_elt->__toString();
} elseif (is_callable(array($userinfo_elt, 'getMessage'))) {
$userinfo_elts[] = $userinfo_elt->getMessage();
}
}
}
$this->message = $data->getMessage() . ' : ' . implode(', ', $userinfo_elts);
} else {
$this->message = $data->getMessage();
}
} elseif ($data instanceof Exception) {
// Exception
$this->message = $data->getMessage();
} else {
// String or object
$this->message = strval($data);
}
}
/**
* String representation of this object.
*
* @return string String representation.
*/
public function __toString()
{
return $this->message;
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Event/ 0000775 0000000 0000000 00000000000 12056172473 0027614 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Event/Status.php 0000664 0000000 0000000 00000001751 12056172473 0031614 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Event_Status extends Horde_Notification_Event
{
/**
* Charset of the message.
*
* @var string
*/
public $charset = null;
/**
* String representation of this object.
*
* @return string String representation.
*/
public function __toString()
{
$text = $this->message;
if (!in_array('content.raw', $this->flags)) {
$text = htmlspecialchars($text, ENT_COMPAT, $this->charset);
}
return $text;
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Exception.php 0000664 0000000 0000000 00000000670 12056172473 0031205 0 ustar 00root root 0000000 0000000
* @category Horde
* @package Notification
*/
class Horde_Notification_Exception extends Horde_Exception_Wrapped
{
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Handler.php 0000664 0000000 0000000 00000030522 12056172473 0030623 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Handler
{
/**
* Decorators.
*
* @var array
*/
protected $_decorators = array();
/**
* Forces immediate attachment of a notification to a listener.
*
* @var boolean
*/
protected $_forceAttach = false;
/**
* Additional handle definitions.
*
* @var array
*/
protected $_handles = array(
'default' => array(
'*' => 'Horde_Notification_Event'
)
);
/**
* Hash containing all attached listener objects.
*
* @var array
*/
protected $_listeners = array();
/**
* The storage location where we store the messages.
*
* @var Horde_Notification_Storage
*/
protected $_storage;
/**
* Initialize the notification system.
*
* @param Horde_Notification_Storage $storage The storage object to use.
*/
public function __construct(Horde_Notification_Storage_Interface $storage)
{
$this->_storage = $storage;
}
/**
* Registers a listener with the notification object and includes
* the necessary library file dynamically.
*
* @param string $listener The name of the listener to attach. These
* names must be unique; further listeners with
* the same name will be ignored.
* @param array $params A hash containing any additional configuration
* or connection parameters a listener driver
* might need.
* @param string $class The class name from which the driver was
* instantiated if not the default one. If given
* you have to include the library file
* containing this class yourself. This is useful
* if you want the listener driver to be
* overriden by an application's implementation
*
* @return Horde_Notification_Listener The listener object.
* @throws Horde_Exception
*/
public function attach($listener, $params = null, $class = null)
{
if ($ob = $this->getListener($listener)) {
return $ob;
}
if (is_null($class)) {
$class = 'Horde_Notification_Listener_' . Horde_String::ucfirst(Horde_String::lower($listener));
}
if (class_exists($class)) {
$this->_listeners[$listener] = new $class($params);
if (!$this->_storage->exists($listener)) {
$this->_storage->set($listener, array());
}
$this->_addTypes($listener);
return $this->_listeners[$listener];
}
throw new Horde_Exception(sprintf('Notification listener %s not found.', $class));
}
/**
* Remove a listener from the notification list.
*
* @param string $listner The name of the listener to detach.
*
* @throws Horde_Exception
*/
public function detach($listener)
{
if ($ob = $this->getListener($listener)) {
unset($this->_listeners[$ob->getName()]);
$this->_storage->clear($ob->getName());
} else {
throw new Horde_Exception(sprintf('Notification listener %s not found.', $listener));
}
}
/**
* Clear any notification events that may exist in a listener.
*
* @param string $listener The name of the listener to flush. If null,
* clears all unattached events.
*/
public function clear($listener = null)
{
if (is_null($listener)) {
$this->_storage->clear('_unattached');
} elseif ($ob = $this->getListener($listener)) {
$this->_storage->clear($ob->getName());
}
}
/**
* Returns the current Listener object for a given listener type.
*
* @param string $type The listener type.
*
* @return mixed A Horde_Notification_Listener object, or null if
* $type listener is not attached.
*/
public function get($type)
{
foreach ($this->_listeners as $listener) {
if ($listener->handles($type)) {
return $listener;
}
}
return null;
}
/**
* Returns a listener object given a listener name.
*
* @param string $listener The listener name.
*
* @return mixed Either a Horde_Notification_Listener or null.
*/
public function getListener($listener)
{
$listener = Horde_String::lower(basename($listener));
return empty($this->_listeners[$listener])
? null
: $this->_listeners[$listener];
}
/**
* Adds a type handler to a given Listener.
* To change the default listener, use the following:
*
* $ob->addType('default', '*', $classname);
*
*
* @param string $listener The listener name.
* @param string $type The listener type.
* @param string $class The Event class to use.
*/
public function addType($listener, $type, $class)
{
$this->_handles[$listener][$type] = $class;
if (isset($this->_listeners[$listener])) {
$this->_addTypes($listener);
}
}
/**
* Adds any additional listener types to a given Listener.
*
* @param string $listener The listener name.
*/
protected function _addTypes($listener)
{
if (isset($this->_handles[$listener])) {
foreach ($this->_handles[$listener] as $type => $class) {
$this->_listeners[$listener]->addType($type, $class);
}
}
}
/**
* Add a decorator.
*
* @param Horde_Notification_Handler_Decorator_Base $decorator The
* Decorator
* object.
*/
public function addDecorator(Horde_Notification_Handler_Decorator_Base $decorator)
{
$this->_decorators[] = $decorator;
}
/**
* Add an event to the Horde message stack.
*
* @param mixed $event Horde_Notification_Event object or message
* string.
* @param integer $type The type of message.
* @param array $flags Array of optional flags that will be passed to
* the registered listeners.
* @param array $options Additional options:
*
* 'immediate' - (boolean) If true, immediately tries to attach to a
* listener. If no listener exists for this type, the
* message will be dropped.
* DEFAULT: false (message will be attached to available
* handler at the time notify() is called).
*
*/
public function push($event, $type = null, array $flags = array(),
$options = array())
{
if ($event instanceof Horde_Notification_Event) {
$event->flags = $flags;
$event->type = $type;
} else {
$class = (!is_null($type) && ($listener = $this->get($type)))
? $listener->handles($type)
: $this->_handles['default']['*'];
/* Transparently create a Horde_Notification_Event object. */
$event = new $class($event, $type, $flags);
}
foreach ($this->_decorators as $decorator) {
$decorator->push($event, $options);
}
if (!$this->_forceAttach && empty($options['immediate'])) {
$this->_storage->push('_unattached', $event);
} else {
if ($listener = $this->get($event->type)) {
$this->_storage->push($listener->getName(), $event);
}
}
}
/**
* Passes the message stack to all listeners and asks them to
* handle their messages.
*
* @param array $options An array containing display options for the
* listeners. Any options not contained in this
* list will be passed to the listeners.
*
* listeners - (array) The list of listeners to notify.
* raw - (boolean) If true, does not call the listener's notify()
* function.
*
*/
public function notify(array $options = array())
{
/* Convert the 'listeners' option into the format expected by the
* notification handler. */
if (!isset($options['listeners'])) {
$listeners = array_keys($this->_listeners);
} elseif (!is_array($options['listeners'])) {
$listeners = array($options['listeners']);
} else {
$listeners = $options['listeners'];
}
$events = array();
$unattached = $this->_storage->exists('_unattached')
? $this->_storage->get('_unattached')
: array();
/* Pass the message stack to all listeners and asks them to handle
* their messages. */
foreach ($listeners as $listener) {
$listener = Horde_String::lower($listener);
if (isset($this->_listeners[$listener])) {
$instance = $this->_listeners[$listener];
$name = $instance->getName();
foreach (array_keys($unattached) as $val) {
if ($unattached[$val] instanceof Horde_Notification_Event
&& $instance->handles($unattached[$val]->type)) {
$this->_storage->push($name, $unattached[$val]);
unset($unattached[$val]);
}
}
foreach ($this->_decorators as $decorator) {
$this->_forceAttach = true;
try {
$decorator->notify($this, $instance);
} catch (Horde_Notification_Exception $e) {
$this->push($e);
}
$this->_forceAttach = false;
}
if (!$this->_storage->exists($name)) {
continue;
}
$tmp = $this->_storage->get($name);
if (empty($options['raw'])) {
$instance->notify($tmp, $options);
}
$this->_storage->clear($name);
$events = array_merge($events, $tmp);
}
}
if (empty($unattached)) {
$this->_storage->clear('_unattached');
} else {
$this->_storage->set('_unattached', $unattached);
}
return $events;
}
/**
* Return the number of notification messages in the stack.
*
* @author David Ulevitch
*
* @param string $my_listener The name of the listener.
*
* @return integer The number of messages in the stack.
*/
public function count($my_listener = null)
{
$count = 0;
if (!is_null($my_listener)) {
if ($ob = $this->get($my_listener)) {
$count = count($this->_storage->get($ob->getName()));
if ($this->_storage->exists('_unattached')) {
foreach ($this->_storage->get('_unattached') as $val) {
if ($ob->handles($val->type)) {
++$count;
}
}
}
}
} else {
if ($this->_storage->exists('_unattached')) {
$count = count($this->_storage->get('_unattached'));
}
foreach ($this->_listeners as $val) {
if ($this->_storage->exists($val->getName())) {
$count += count($this->_storage->get($val->getName()));
}
}
}
return $count;
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Handler/ 0000775 0000000 0000000 00000000000 12056172473 0030110 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Handler/Decorator/ 0000775 0000000 0000000 00000000000 12056172473 0032032 5 ustar 00root root 0000000 0000000 Alarm.php 0000664 0000000 0000000 00000003640 12056172473 0033523 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Handler/Decorator
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Handler_Decorator_Alarm
extends Horde_Notification_Handler_Decorator_Base
{
/**
* A Horde_Alarm instance.
*
* @var Horde_Core_Factory_Alarm
*/
protected $_alarm;
/**
* The current user.
*
* @var string
*/
protected $_user;
/**
* Initialize the notification system, set up any needed session
* variables, etc.
*
* @param object $alarm An alarm factory that implements create().
* @param string $user The current username.
*/
public function __construct($alarm, $user)
{
$this->_alarm = $alarm;
$this->_user = $user;
}
/**
* Listeners are handling their messages.
*
* @param Horde_Notification_Handler $handler The base handler object.
* @param Horde_Notification_Listener $listener The Listener object that
* is handling its messages.
*
* @throws Horde_Notification_Exception
*/
public function notify(Horde_Notification_Handler $handler,
Horde_Notification_Listener $listener)
{
if ($listener instanceof Horde_Notification_Listener_Status) {
try {
// TODO: Use $handler
$this->_alarm->create()->notify($this->_user);
} catch (Horde_Alarm_Exception $e) {
throw new Horde_Notification_Exception($e);
}
}
}
}
Base.php 0000664 0000000 0000000 00000002656 12056172473 0033347 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Handler/Decorator
* @author Michael Slusarz
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Handler_Decorator_Base
{
/**
* Event is being added to the Horde message stack.
*
* @param Horde_Notification_Event $event Event object.
* @param array $options Additional options (see
* Horde_Notification_Handler for
* details).
*/
public function push(Horde_Notification_Event $event, $options)
{
}
/**
* Listeners are handling their messages.
*
* @param Horde_Notification_Handler $handler The base handler object.
* @param Horde_Notification_Listener $listener The Listener object that
* is handling its messages.
*
* @throws Horde_Notification_Exception
*/
public function notify(Horde_Notification_Handler $handler,
Horde_Notification_Listener $listener)
{
}
}
Log.php 0000664 0000000 0000000 00000003002 12056172473 0033200 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Handler/Decorator
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Handler_Decorator_Log
extends Horde_Notification_Handler_Decorator_Base
{
/**
* The log handler.
*
* @var object
*/
private $_logger;
/**
* Constructor.
*
* @param object $logger The log handler. The provided instance is
* required to implement the debug() function. You
* should be able to use a common Logger here (PEAR
* Log, Horde_Log_Logger, or Zend_Log).
*/
public function __construct($logger)
{
$this->_logger = $logger;
}
/**
* Event is being added to the Horde message stack.
*
* @param Horde_Notification_Event $event Event object.
* @param array $options Additional options (see
* Horde_Notification_Handler for
* details).
*/
public function push(Horde_Notification_Event $event, $options)
{
$this->_logger->debug($event->message);
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Listener.php 0000664 0000000 0000000 00000004474 12056172473 0031042 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
abstract class Horde_Notification_Listener
{
/**
* The base type of this listener.
*
* @var string
*/
protected $_name;
/**
* Array of message types that this listener handles.
* Key is the type, value is the default class name of the Event type to
* use.
*
* @var array
*/
protected $_handles = array();
/**
* Does this listener handle a certain type of message?
*
* @param string $type The message type in question.
*
* @return mixed False if this listener does not handle, the default
* event class if it does handle the type.
*/
public function handles($type)
{
if (isset($this->_handles[$type])) {
return $this->_handles[$type];
}
/* Search for '*' entries. */
foreach (array_keys($this->_handles) as $key) {
if ((substr($key, -1) == '*') &&
(strpos($type, substr($key, 0, -1)) === 0)) {
return $this->_handles[$key];
}
}
return false;
}
/**
* Adds message type handler.
*
* @param string $type The type identifier.
* @param string $class A classname.
*/
public function addType($type, $class)
{
$this->_handles[$type] = $class;
}
/**
* Return a unique identifier for this listener.
*
* @return string Unique id.
*/
public function getName()
{
return $this->_name;
}
/**
* Outputs the status line, sends emails, pages, etc., if there
* are any messages on this listener's message stack.
*
* @param array $events The list of events to handle.
* @param array $options An array of options.
*/
abstract public function notify($events, $options = array());
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Listener/ 0000775 0000000 0000000 00000000000 12056172473 0030320 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Listener/Audio.php 0000664 0000000 0000000 00000002365 12056172473 0032100 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Listener_Audio extends Horde_Notification_Listener
{
/**
* Constructor.
*/
public function __construct()
{
$this->_handles['audio'] = 'Horde_Notification_Event';
$this->_name = 'audio';
}
/**
* Outputs the embedded audio code if there are any messages on the
* 'audio' message stack.
*
* @param array $events The list of events to handle.
* @param array $options An array of options (not used).
*/
public function notify($events, $options = array())
{
foreach ($events as $event) {
echo '';
}
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Listener/Status.php 0000664 0000000 0000000 00000002427 12056172473 0032321 0 ustar 00root root 0000000 0000000
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Notification
*/
class Horde_Notification_Listener_Status extends Horde_Notification_Listener
{
/**
* Constructor.
*/
public function __construct()
{
$this->_handles['status'] = 'Horde_Notification_Event_Status';
$this->_name = 'status';
}
/**
* Outputs the status line if there are any messages on the 'status'
* message stack.
*
* @param array $events The list of events to handle.
* @param array $options An array of options. Not used.
*/
public function notify($events, $options = array())
{
if (!count($events)) {
return;
}
echo '
';
foreach ($events as $event) {
echo '
' . $event . '
';
}
echo '
';
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Storage/ 0000775 0000000 0000000 00000000000 12056172473 0030137 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Storage/Interface.php 0000664 0000000 0000000 00000003767 12056172473 0032565 0 ustar 00root root 0000000 0000000
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* An interface describing a storage location for notification messages.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
interface Horde_Notification_Storage_Interface
{
/**
* Return the given stack from the notification store.
*
* @param string $key The key for the data.
*
* @return mixed The notification data stored for the given key.
*/
public function get($key);
/**
* Set the given stack in the notification store.
*
* @param string $key The key for the data.
* @param mixed $value The data.
*/
public function set($key, $value);
/**
* Is the given stack present in the notification store?
*
* @param string $key The key of the data.
*
* @return boolean True if the element is set, false otherwise.
*/
public function exists($key);
/**
* Unset the given stack in the notification store.
*
* @param string $key The key of the data.
*/
public function clear($key);
/**
* Store a new event.
*
* @param string $listener The event will be stored for
* this listener.
* @param Horde_Notification_Event $event The event to store.
*/
public function push($listener, Horde_Notification_Event $event);
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Storage/Object.php 0000664 0000000 0000000 00000004700 12056172473 0032057 0 ustar 00root root 0000000 0000000
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* A class that stores notifications in an object.
*
* Copyright 2010-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Jan Schneider
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Storage_Object
implements Horde_Notification_Storage_Interface
{
/**
* Holds the notifications pushed into this storage object.
*
* @var array
*/
public $notifications = array();
/**
* Return the given stack from the notification store.
*
* @param string $key The key for the data.
*
* @return mixed The notification data stored for the given key.
*/
public function get($key)
{
return $this->notifications[$key];
}
/**
* Set the given stack in the notification store.
*
* @param string $key The key for the data.
* @param mixed $value The data.
*/
public function set($key, $value)
{
$this->notifications[$key] = $value;
}
/**
* Is the given stack present in the notification store?
*
* @param string $key The key of the data.
*
* @return boolean True if the element is set, false otherwise.
*/
public function exists($key)
{
return isset($this->notifications[$key]);
}
/**
* Unset the given stack in the notification store.
*
* @param string $key The key of the data.
*/
public function clear($key)
{
unset($this->notifications[$key]);
}
/**
* Store a new event for the given listener stack.
*
* @param string $listener The event will be stored for
* this listener.
* @param Horde_Notification_Event $event The event to store.
*/
public function push($listener, Horde_Notification_Event $event)
{
$this->notifications[$listener][] = $event;
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/lib/Horde/Notification/Storage/Session.php 0000664 0000000 0000000 00000005603 12056172473 0032277 0 ustar 00root root 0000000 0000000
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* A class that stores notifications in the session.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Storage_Session
implements Horde_Notification_Storage_Interface
{
/**
* The stack name.
*
* @var string
*/
protected $_stack;
/**
* Constructor.
*
* @param string $stack The name of the notification stack.
*/
public function __construct($stack)
{
$this->_stack = $stack;
/* Make sure the message stack is registered in the session. */
if (!isset($_SESSION[$this->_stack])) {
$_SESSION[$this->_stack] = array();
}
}
/**
* Return the given stack from the notification store.
*
* @param string $key The key for the data.
*
* @return mixed The notification data stored for the given key.
*/
public function get($key)
{
return $_SESSION[$this->_stack][$key];
}
/**
* Set the given stack in the notification store.
*
* @param string $key The key for the data.
* @param mixed $value The data.
*/
public function set($key, $value)
{
$_SESSION[$this->_stack][$key] = $value;
}
/**
* Is the given stack present in the notification store?
*
* @param string $key The key of the data.
*
* @return boolean True if the element is set, false otherwise.
*/
public function exists($key)
{
return isset($_SESSION[$this->_stack][$key]);
}
/**
* Unset the given stack in the notification store.
*
* @param string $key The key of the data.
*/
public function clear($key)
{
unset($_SESSION[$this->_stack][$key]);
}
/**
* Store a new event for the given listener stack.
*
* @param string $listener The event will be stored for
* this listener.
* @param Horde_Notification_Event $event The event to store.
*/
public function push($listener, Horde_Notification_Event $event)
{
/* No need to serialize() ourselves - PHP's session handling does
* this automatically. */
$_SESSION[$this->_stack][$listener][] = $event;
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/ 0000775 0000000 0000000 00000000000 12056172473 0023255 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/ 0000775 0000000 0000000 00000000000 12056172473 0024316 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/ 0000775 0000000 0000000 00000000000 12056172473 0026744 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/AllTests.php 0000664 0000000 0000000 00000000132 12056172473 0031204 0 ustar 00root root 0000000 0000000 run();
php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Autoload.php 0000664 0000000 0000000 00000000506 12056172473 0031226 0 ustar 00root root 0000000 0000000
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/** Needed for PEAR_Error. */
@require_once 'PEAR.php';
php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/ 0000775 0000000 0000000 00000000000 12056172473 0030011 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/ 0000775 0000000 0000000 00000000000 12056172473 0032437 5 ustar 00root root 0000000 0000000 0000775 0000000 0000000 00000000000 12056172473 0033441 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Event StatusTest.php 0000664 0000000 0000000 00000002466 12056172473 0036305 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Event
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the status event class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_Event_StatusTest extends Horde_Test_Case
{
public function testMethodTostringHasResultTheTextOfTheEvent()
{
$event = new Horde_Notification_Event_Status('test');
$event->charset = 'ISO-8859-1';
$this->assertEquals('<b>test</b>', (string) $event);
}
public function testMethodTostringHasUnescapedResultIfContentRawFlagIsSet()
{
$event = new Horde_Notification_Event_Status('test', null, array('content.raw'));
$this->assertEquals('test', (string) $event);
}
}
EventTest.php 0000664 0000000 0000000 00000002657 12056172473 0035024 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the basic event class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_EventTest extends Horde_Test_Case
{
public function testMethodConstructHasPostconditionThatTheGivenMessageWasSavedIfItWasNotNull()
{
$event = new Horde_Notification_Event('test');
$this->assertEquals('test', $event->message);
}
public function testMethodGetmessageHasResultStringTheStoredMessage()
{
$event = new Horde_Notification_Event('');
$event->message = 'test';
$this->assertEquals('test', $event->message);
}
public function testMethodGetmessageHasResultStringEmptyIfNoMessageWasStored()
{
$event = new Horde_Notification_Event('');
$this->assertEquals('', $event->message);
}
}
0000775 0000000 0000000 00000000000 12056172473 0033735 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Handler 0000775 0000000 0000000 00000000000 12056172473 0035657 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Handler/Decorator AlarmTest.php 0000664 0000000 0000000 00000003071 12056172473 0040265 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Handler/Decorator
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the alarm notification handler class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_Handler_Decorator_AlarmTest
extends Horde_Test_Case
{
public function setUp()
{
$this->markTestIncomplete('Currently broken');
if (!class_exists('Horde_Alarm')) {
$this->markTestSkipped('The Horde_Alarm package is not installed!');
}
$this->alarm = $this->getMockForAbstractClass('Horde_Alarm');
$this->alarm_handler = new Horde_Notification_Handler_Decorator_Alarm(
$this->alarm, null
);
}
public function testMethodNotifyHasPostconditionThatTheAlarmSystemGotNotifiedIfTheStatusListenerShouldBeNotified()
{
$this->alarm->expects($this->once())
->method('notify')
->with('');
$this->alarm_handler->notify(array('listeners' => array('status')));
}
}
HordelogTest.php 0000664 0000000 0000000 00000002014 12056172473 0040770 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Handler/Decorator
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the notification handler class that logs to the horde log.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_Handler_Decorator_HordelogTest
extends Horde_Test_Case
{
public function testNoneAvailable()
{
// No tests
$this->markTestIncomplete('No tests available.');
}
}
LogTest.php 0000664 0000000 0000000 00000003035 12056172473 0037752 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Handler/Decorator
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the logging notification handler class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_Handler_Decorator_LogTest
extends Horde_Test_Case
{
public function setUp()
{
if (!class_exists('Horde_Log_Logger')) {
$this->markTestSkipped('The Horde_Log package is not installed!');
}
$this->logger = $this->getMock('Horde_Log_Logger');
$this->log = new Horde_Notification_Handler_Decorator_Log(
$this->logger
);
}
public function testMethodPushHasPostconditionThattheEventGotLoggedIfTheEventWasAnError()
{
$exception = new Horde_Notification_Event(new Exception('test'));
$this->logger->expects($this->once())
->method('__call')
->with('debug', $this->isType('array'));
$this->log->push($exception, array());
}
}
HandlerTest.php 0000664 0000000 0000000 00000022372 12056172473 0035314 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the basic notification handler class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_HandlerTest extends Horde_Test_Case
{
public function setUp()
{
$this->storage = new Horde_Notification_Storage_Session('test');
$this->handler = new Horde_Notification_Handler($this->storage);
}
public function tearDown()
{
unset($_SESSION);
}
public function testMethodAttachHasResultNotificationlistener()
{
$this->assertInstanceOf(
'Horde_Notification_Listener_Audio',
$this->handler->attach('audio')
);
}
public function testMethodAttachHasResultNotificationlistenerTheSameListenerAsBeforeIfThisListenerHasAlreadyBeenAttached()
{
$listener = $this->handler->attach('audio');
$this->assertSame($listener, $this->handler->attach('audio'));
}
public function testMethodAttachHasResultNotificationlistenerClassAsSpecifiedInParameterClass()
{
$this->assertInstanceOf(
'Horde_Notification_Listener_Audio',
$this->handler->attach(
'MyAudio', array(), 'Horde_Notification_Listener_Audio'
)
);
}
public function testMethodAttachHasPostconditionThatTheListenerGotInitializedWithTheProvidedParmeters()
{
$listener = $this->handler->attach('dummy', array('test'));
$this->assertEquals(array('test'), $listener->params);
}
public function testMethodAttachHasPostconditionThatTheListenerStackGotInitializedAsArray()
{
$this->handler->attach('audio');
$this->assertEquals(array(), $_SESSION['test']['audio']);
}
public function testMethodAttachThrowsExceptionIfTheListenerTypeIsUnknown()
{
try {
$this->handler->attach('MyAudio');
$this->fail('No exception!');
} catch (Horde_Exception $e) {
$this->assertEquals(
'Notification listener Horde_Notification_Listener_Myaudio not found.',
$e->getMessage()
);
}
}
public function testMethodDetachHasPostconditionThatTheListenerStackGotUnset()
{
$this->handler->attach('audio');
$this->handler->detach('audio');
$this->assertFalse(isset($_SESSION['test']['audio']));
}
public function testMethodDetachThrowsExceptionIfTheListenerIsUnset()
{
try {
$this->handler->detach('MyAudio');
$this->fail('No exception!');
} catch (Horde_Exception $e) {
$this->assertEquals(
'Notification listener MyAudio not found.',
$e->getMessage()
);
}
}
public function testMethodClearHasPostconditionThatTheStorageOfTheSpecifiedListenerWasCleared()
{
$storage = $this->getMock('Horde_Notification_Storage_Interface');
$storage->expects($this->once())
->method('clear')
->with('dummy');
$handler = new Horde_Notification_Handler($storage);
$handler->attach('dummy');
$handler->clear('dummy');
}
public function testMethodClearHasPostconditionThatAllUnattachedEventsHaveBeenClearedFromStorageIfNoListenerWasSpecified()
{
$storage = $this->getMock('Horde_Notification_Storage_Interface');
$storage->expects($this->once())
->method('clear')
->with('_unattached');
$handler = new Horde_Notification_Handler($storage);
$handler->clear();
}
public function testMethodGetHasResultNullIfTheSpecifiedListenerIsNotAttached()
{
$this->assertNull($this->handler->get('not attached'));
}
public function testMethodAddtypeHasPostconditionThatTheSpecifiedListenerHandlesTheGivenMessageType()
{
$this->handler->attach('dummy');
$this->handler->addType('dummy', 'newtype', 'NewType');
$this->assertEquals('NewType', $this->handler->getListener('dummy')->handles('newtype'));
}
public function testMethodAdddecoratorHasPostconditionThatTheGivenDecoratorWasAddedToTheHandlerAndReceivesPushCalls()
{
$decorator = $this->getMock('Horde_Notification_Handler_Decorator_Base');
$decorator->expects($this->once())
->method('push')
->with($this->isInstanceOf('Horde_Notification_Event'));
$event = new Horde_Notification_Event('test');
$this->handler->attach('audio');
$this->handler->addDecorator($decorator);
$this->handler->push($event, 'audio');
}
public function testMethodAdddecoratorHasPostconditionThatTheGivenDecoratorWasAddedToTheHandlerAndReceivesNotifyCalls()
{
$decorator = $this->getMock('Horde_Notification_Handler_Decorator_Base');
$decorator->expects($this->once())
->method('notify');
$this->handler->attach('audio');
$this->handler->addDecorator($decorator);
$this->handler->notify();
}
public function testMethodPushHasPostconditionThatTheEventGotSavedInAllAttachedListenerStacksHandlingTheEvent()
{
$event = new Horde_Notification_Event('test');
$this->handler->attach('audio');
$this->handler->push('test', 'audio', array(), array('immediate' => true));
$result = array_shift($_SESSION['test']['audio']);
$this->assertNotNull($result);
$this->assertInstanceOf('Horde_Notification_Event', $result);
$this->assertEquals(array(), $result->flags);
$this->assertEquals('audio', $result->type);
}
public function testMethodPushHasPostconditionThatAnExceptionGetsMarkedAsTypeStatusIfTheTypeWasUnset()
{
$this->handler->attach('dummy');
$this->handler->push(new Exception('test'), null, array(), array('immediate' => true));
$result = array_shift($_SESSION['test']['dummy']);
$this->assertNotNull($result);
$this->assertInstanceOf('Horde_Notification_Event', $result);
$this->assertEquals(array(), $result->flags);
$this->assertEquals('status', $result->type);
}
public function testMethodPushHasPostconditionThatEventsWithoutTypeGetMarkedAsTypeStatus()
{
$this->handler->attach('dummy');
$this->handler->push('test', null, array(), array('immediate' => true));
$result = array_shift($_SESSION['test']['dummy']);
$this->assertNotNull($result);
$this->assertInstanceOf('Horde_Notification_Event', $result);
$this->assertEquals(array(), $result->flags);
$this->assertEquals('status', $result->type);
}
public function testMethodNotifyHasPostconditionThatAllListenersWereNotified()
{
$dummy = $this->handler->attach('dummy');
$this->handler->push('test', 'dummy');
$this->handler->notify();
$result = array_shift($dummy->events);
$this->assertNotNull($result);
$this->assertInstanceOf('Horde_Notification_Event', $result);
$this->assertEquals(array(), $result->flags);
$this->assertEquals('dummy', $result->type);
}
public function testMethodNotifyHasPostconditionThatTheSpecifiedListenersWereNotified()
{
$dummy = $this->handler->attach('dummy');
$this->handler->push('test', 'dummy');
$this->handler->notify(array('listeners' => 'dummy'));
$result = array_shift($dummy->events);
$this->assertNotNull($result);
$this->assertInstanceOf('Horde_Notification_Event', $result);
$this->assertEquals(array(), $result->flags);
$this->assertEquals('dummy', $result->type);
}
public function testMethodCountHasResultTheTotalNumberOfEventsInTheStack()
{
$this->handler->attach('audio');
$this->handler->attach('dummy');
$this->handler->push('test', 'audio');
$this->handler->push('test', 'dummy');
$this->assertEquals(2, $this->handler->count());
}
public function testMethodCountHasResultTheEventNumberForASpecificListenerIfTheListenerHasBeenSpecified()
{
$this->handler->attach('audio');
$this->handler->attach('dummy');
$this->handler->push('test', 'audio');
$this->assertEquals(1, $this->handler->count('audio'));
}
}
class Horde_Notification_Listener_Dummy extends Horde_Notification_Listener
{
public $events;
public $params;
public function __construct($params)
{
$this->params = $params;
$this->_name = 'dummy';
$this->_handles = array(
'dummy' => 'Horde_Notification_Event',
'status' => 'Horde_Notification_Event'
);
}
public function notify($events, $options = array())
{
$this->events = $events;
}
}
0000775 0000000 0000000 00000000000 12056172473 0034145 5 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Listener AudioTest.php 0000664 0000000 0000000 00000003135 12056172473 0036561 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Listener
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the audio listener class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_Listener_AudioTest extends Horde_Test_Case
{
public function testMethodHandleHasEventClassForAudioMessages()
{
$listener = new Horde_Notification_Listener_Audio();
$this->assertEquals('Horde_Notification_Event', $listener->handles('audio'));
}
public function testMethodGetnameHasResultStringAudio()
{
$listener = new Horde_Notification_Listener_Audio();
$this->assertEquals('audio', $listener->getName());
}
public function testMethodNotifyHasOutputEventMessage()
{
$listener = new Horde_Notification_Listener_Audio();
$event = new Horde_Notification_Event('test');
$messages = array($event);
$this->expectOutputString(
''
);
$listener->notify($messages);
}
}
StatusTest.php 0000664 0000000 0000000 00000003506 12056172473 0037005 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification/Listener
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the status listener class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_Listener_StatusTest extends Horde_Test_Case
{
public function testMethodHandleHasEventClassForHordeMessages()
{
$listener = new Horde_Notification_Listener_Status();
$this->assertEquals('Horde_Notification_Event_Status', $listener->handles('status'));
}
public function testMethodGetnameHasResultStringStatus()
{
$listener = new Horde_Notification_Listener_Status();
$this->assertEquals('status', $listener->getName());
}
public function testMethodNotifyHasNoOutputIfTheMessageStackIsEmpty()
{
$listener = new Horde_Notification_Listener_Status();
$messages = array();
$listener->notify($messages);
}
public function testMethodNotifyHasOutputEventMessagesEmbeddedInUlElement()
{
$listener = new Horde_Notification_Listener_Status();
$event = new Horde_Notification_Event('test');
$messages = array($event);
$this->expectOutputString(
'
test
'
);
$listener->notify($messages);
}
}
ListenerTest.php 0000664 0000000 0000000 00000004123 12056172473 0035516 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class/Notification
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the basic listener class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_Notification_ListenerTest extends Horde_Test_Case
{
public function setUp()
{
if (!class_exists('PEAR_Error')) {
$this->markTestSkipped('The PEAR_Error class is not available!');
}
}
public function testMethodHandleHasResultBooleanFalse()
{
$listener = new Horde_Notification_Listener_Mock();
$this->assertFalse($listener->handles('test'));
}
public function testMethodHandleHasEventClassName()
{
$listener = new Horde_Notification_Listener_Mock();
$this->assertEquals('Horde_Notification_Event', $listener->handles('mock'));
}
public function testMethodHandleHasEventClassNameIfItMatchesAsteriskExpression()
{
$listener = new Horde_Notification_Listener_Mock();
$listener->addType('t*', 'Test_Event');
$this->assertEquals('Test_Event', $listener->handles('test'));
}
public function testMethodGetnameHasResultStringTheNameOfTheListener()
{
$listener = new Horde_Notification_Listener_Mock();
$this->assertEquals('mock', $listener->getName());
}
}
class Horde_Notification_Listener_Mock extends Horde_Notification_Listener
{
protected $_handles = array('mock' => 'Horde_Notification_Event');
protected $_name = 'mock';
public function notify($events, $options = array())
{
}
}
NotificationTest.php 0000664 0000000 0000000 00000003172 12056172473 0033734 0 ustar 00root root 0000000 0000000 php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/Class
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
/**
* Test the notification class.
*
* Copyright 2009-2012 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @category Horde
* @package Notification
* @author Gunnar Wrobel
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @link http://pear.horde.org/index.php?package=Notification
*/
class Horde_Notification_Class_NotificationTest extends Horde_Test_Case
{
public function tearDown()
{
unset($_SESSION);
}
public function testMethodSingletonReturnsAlwaysTheSameInstanceForTheSameStackName()
{
$notification1 = Horde_Notification::singleton('test');
$notification2 = Horde_Notification::singleton('test');
$this->assertSame($notification1, $notification2);
}
public function testMethodConstructHasPostconditionThatTheSessionStackGotInitializedAsArray()
{
$notification = Horde_Notification_Instance::newInstance('test');
$this->assertEquals(array(), $_SESSION['test']);
}
}
class Horde_Notification_Instance extends Horde_Notification
{
static public function newInstance($stack)
{
$storage = new Horde_Notification_Storage_Session($stack);
return new Horde_Notification_Handler($storage);
}
}
php-horde-notification-2.0.1/Horde_Notification-2.0.1/test/Horde/Notification/bootstrap.php 0000664 0000000 0000000 00000000143 12056172473 0031470 0 ustar 00root root 0000000 0000000
../../../lib
php-horde-notification-2.0.1/package.xml 0000664 0000000 0000000 00000033613 12056172473 0020216 0 ustar 00root root 0000000 0000000
Horde_Notificationpear.horde.orgHorde Notification SystemA library implementing a subject-observer pattern for raising and showing messages of different types and to different listeners.Jan Schneiderjanjan@horde.orgyes2012-11-192.0.11.0.0stablestableLGPL-2.1
* [mms] Use new Horde_Test layout.
5.3.01.7.0Horde_Exceptionpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Utilpear.horde.org2.0.03.0.0alpha13.0.0alpha1gettextHorde_Alarmpear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Nlspear.horde.org2.0.03.0.0alpha13.0.0alpha1Horde_Testpear.horde.org2.1.03.0.0alpha13.0.0alpha10.0.10.0.1alphaalpha2003-07-05LGPL-2.1
Initial release as a PEAR package
2006-05-080.0.20.0.2alphaalphaLGPL-2.1
Converted to package.xml 2.0 for pear.horde.org
1.0.0alpha11.0.0alphaalpha2011-03-08LGPL-2.1
* First alpha release for Horde 4.
* Removed javascript listener.
* Added unit tests.
* Added Horde_Notification::replace().
1.0.0beta11.0.0betabeta2011-03-16LGPL-2.1
* First beta release for Horde 4.
1.0.0RC11.0.0betabeta2011-03-22LGPL-2.1
* First release candidate for Horde 4.
1.0.0RC21.0.0betabeta2011-03-29LGPL-2.1
* Second release candidate for Horde 4.
1.0.01.0.0stablestable2011-04-06LGPL-2.1
* First stable release for Horde 4.
* [mms] Fixed decorator notify() behavior.
1.0.11.0.0stablestable2011-11-22LGPL-2.1
* [jan] Fix tests to work with PHPUnit 3.6.
2.0.0alpha11.0.0alphastable2012-07-05LGPL-2.1
* First alpha release for Horde 5.
2.0.0beta11.0.0betastable2012-07-19LGPL-2.1
* First beta release for Horde 5.
2.0.01.0.0stablestable2012-10-30LGPL-2.1
* First stable release for Horde 5.
2.0.11.0.0stablestable2012-11-19LGPL-2.1
* [mms] Use new Horde_Test layout.