\documentclass{article}
\usepackage{ulem}
\pagestyle{headings}
\begin{document}
\part{Horde\_Registry}
\textbf{Colortext: NIThis information is valid for Horde 3 only.Colortext: NI}

Registry usage example:

\begin{verbatim}

require_once HORDE_BASE . 'Horde/Registry.php';

// The Registry has a singleton method that should be used to ensure
// that there is only ever one instance of the Registry during a request.
$registry = &Registry::singleton();

// All applications should put themselves on the application stack when they start running
// This also takes care of reading the application's configuration file.
$registry->pushApp('curapp');

// When an app is finished, pop it off the application stack
// This also returns the global $conf variable to that of the previous application.
$registry->popApp();

// Routines can determine the current app:
$curapp = $registry->getApp();

// Find out if an application allows access for the current user (may be a guest user)
if ($registry->hasPermission('app')) {
    // access allowed
}
\end{verbatim}

Creating the Registry object, one can control how and if a session is started. Note that this only works if calling \texttt{Registry::singleton()} for the first time.

\begin{verbatim}

// Let the registry start a regular session.
$registry = &Registry::singleton();

// Let the registry start a readonly session.
$registry = &Registry::singleton(HORDE_SESSION_READONLY);

// Don't let the registry start a session.
$registry = &Registry::singleton(HORDE_SESSION_NONE);
\end{verbatim}

The Registry lets you generate links to other apps

\begin{verbatim}

require_once HORDE_BASE . 'Horde/Registry.php';
$registry = &Registry::singleton();

// Check to see if the functionality we want is there
if (!$registry->hasMethod('mail/compose')) {
    echo 'no mail/compose method defined';
    exit;
}

// Generate the link
echo $registry->link('mail/compose', array('to' => 'foo@example.com', 'subject' => 'bar'));
\end{verbatim}

The Registry also lets you invoke methods in other applications

\begin{verbatim}

require_once HORDE_BASE . 'Horde/Registry.php';
$registry = &Registry::singleton();

// Check to see if the functionality we want is there
if (!$registry->hasMethod('contacts/search')) {
    echo 'no contacts/search method defined';
    exit;
}

// The contacts/search method takes two arrays; one of names, one of addressbooks
$args = array('sources' => array('myldap'),
              'names' => array('Chuck'),
              'fields' => array('name', 'email'));
$results = $registry->call('contacts/search', $args);

// Using Horde 3.1 and PHP 5, calling API methods is even more elegant:
$results = $registry->contacts->search($args);
\end{verbatim}

\end{document}
