/* Registry. */
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('babel', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('babel', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
// Registry
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('chora', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('chora', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
define('CHORA_TEMPLATES', $registry->get('templates'));
'assign' => _("Assign Existing"));
$action = &Horde_Form_Action::factory('reload');
-
+
$select = &$this->addVariable(_("Contact Information"), 'chooseContact', 'enum', true, false, null, array($addOrPick, true));
$select->setAction($action);
$select->setOption('trackchange', true);
if ($vars->get('chooseContact') == 'create') {
- $turbaform = $GLOBALS['registry']->call('contacts/getAddClientForm', array(&$vars));
- if (is_a($turbaform, 'PEAR_Error')) {
- Horde::logMessage($addform, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $turbaform = $GLOBALS['registry']->call('contacts/getAddClientForm', array(&$vars));
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
$notification->push(_("An internal error has occurred. Details have beenlogged for the administrator."));
$addform = null;
}
$select->setOption('trackchange', true);
if ($vars->get('chooseQueue') == 'create') {
- $whupsform = $GLOBALS['registry']->call('tickets/getAddQueueForm', array(&$vars));
- if (is_a($whupsform, 'PEAR_Error')) {
- Horde::logMessage($addform, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $whupsform = $GLOBALS['registry']->call('tickets/getAddQueueForm', array(&$vars));
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
$notification->push(_("An internal error has occurred. Details have been logged for the administrator."));
$addform = null;
}
* need, and sets up objects that all scripts use.
*
* @author Ben Klang <ben@alkaloid.net>
- *
+ *
*/
// Check for a prior definition of HORDE_BASE (perhaps by an auto_prepend_file
// Registry.
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('crumb', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('crumb', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
@define('CRUMB_TEMPLATES', $registry->get('templates'));
$registry = Horde_Registry::singleton();
}
-if (is_a(($pushed = $registry->pushApp('fima', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('fima', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
@define('FIMA_TEMPLATES', $registry->get('templates'));
if (Horde_Util::getFormData('submitbutton') == _("Delete all current comments")) {
- $result = $registry->call('forums/deleteForum', array('folks', Horde_Auth::getAuth()));
- if ($result instanceof PEAR_Error) {
- $notification->push($result);
- } else {
+ try {
+ $registry->call('forums/deleteForum', array('folks', Horde_Auth::getAuth()));
$result = $folks_driver->updateComments(Horde_Auth::getAuth(), true);
if ($result instanceof PEAR_Error) {
$notification->push($result);
} else {
$notification->push(_("Comments deleted successfuly"), 'horde.success');
}
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
}
-
} else {
// Update forum status
$info = array('author' => Horde_Auth::getAuth(),
'forum_name' => Horde_Auth::getAuth(),
'forum_moderated' => ($profile['user_comments'] == 'moderate'));
- $result = $registry->call('forums/saveFrom', array('folks', '', $info));
- if ($result instanceof PEAR_Error) {
- $notification->push($result);
+ try {
+ $registry->call('forums/saveFrom', array('folks', '', $info));
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
}
}
if ($profile['user_comments'] == 'moderate') {
echo '<br />';
- $result = $registry->call('forums/moderateForm', array('folks'));
- if ($result instanceof PEAR_Error) {
- echo $result->getMessage();
- } else {
- echo $result;
+ try {
+ echo $registry->call('forums/moderateForm', array('folks'));
+ } catch (Horde_Exception $e) {
+ echo $e->getMessage();
}
}
$form->addVariable(_("Homepage"), 'user_url', 'text', false);
if ($registry->hasMethod('video/listVideos')) {
- $result = $registry->call('video/listVideos', array(array('author' => Horde_Auth::getAuth()), 0, 100));
- if ($result instanceof PEAR_Error) {
- $notification->push($result);
- } else {
+ try {
+ $result = $registry->call('video/listVideos', array(array('author' => Horde_Auth::getAuth()), 0, 100));
$videos = array();
foreach ($result as $video_id => $video) {
$videos[$video_id] = $video['video_title'] . ' - ' . Folks::format_date($video['video_created']);
}
$video_link = '<a href="' . $registry->link('video/edit') . '">' . _("Upload a new video") . '</a>';
$form->addVariable(_("Video"), 'user_video', 'enum', false, false, $video_link, array($videos, _("--- Select ---")));
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
}
}
}
// Load horde central block
-$block = $registry->call('horde/blockContent', array('horde', 'fb_summary'));
-if ($block instanceof PEAR_Error) {
- $notification->push($block);
+try {
+ $block = $registry->call('horde/blockContent', array('horde', 'fb_summary'));
+} catch (Horde_Exception $e) {
+ $notification->push($e);
header('Location: ' . Horde::applicationUrl('user.php'));
exit;
}
echo $block;
-require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
+require $registry->get('templates', 'horde') . '/common-footer.inc';
* @param string $userId User ID for which to check
*
* @return boolean Whether or not $userId already exists.
+ * @throws Horde_Exception
*/
public function exists($userId)
{
. '<thead><tr><th>' . _("Title") . '</th>'
. '<th>' . _("User") . '</th></tr></thead>';
- $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
- array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
- 'folks', 0, $this->_params['limit']));
- if ($threads instanceof PEAR_Error) {
- return $threads->getMessage();
+ try {
+ $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
+ array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
+ 'folks', 0, $this->_params['limit']));
+ } catch (Horde_Exception $e) {
+ return $e->getMessage();
}
$url = Folks::getUrlFor('user', Horde_Auth::getAuth());
$GLOBALS['cache']->set($cache_key, $html);
return $html;
}
-}
\ No newline at end of file
+}
// Delete comments
if ($registry->hasMethod('forums/deleteForum')) {
- $comments = $registry->call('forums/deleteForum', array('folks', $user));
- if ($comments instanceof PEAR_Error) {
- return $comments;
- }
+ $registry->call('forums/deleteForum', array('folks', $user));
}
// Delete user
public function notifyFriends($user, $subject, $body, $attachments = array())
{
$friends = $GLOBALS['registry']->call('users/getFriends');
- if ($friends instanceof PEAR_Error) {
- return $friends;
- }
-
return $this->notify($friends, $subject, $body, $attachments);
}
}
public function notifyFriends($user, $subject, $body, $attachments = array())
{
$friends = $GLOBALS['registry']->call('users/getFriends');
- if ($friends instanceof PEAR_Error) {
- return $friends;
- }
-
return $this->notify($friends, $subject, $body, $attachments);
}
}
'user_email' => $this->_getUserFromAddr()));
$ticket_id = $registry->call('tickets/addTicket', array($info));
- if ($ticket_id instanceof PEAR_Error) {
- return $ticket_id;
- }
if (empty($attachments) ||
!$registry->hasMethod('tickets/addAttachment')) {
array('ticket_id' => $ticket_id,
'name' => $attachment['name'],
'data' => file_get_contents($attachment['file'])));
- if ($result instanceof PEAR_Error) {
- return $result;
- }
}
return true;
// Registry.
$registry = Horde_Registry::singleton();
-if (($pushed = $registry->pushApp('folks', !defined('AUTH_HANDLER'))) instanceof PEAR_Error) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('folks', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
define('FOLKS_TEMPLATES', $registry->get('templates'));
echo '<h1 class="header">' . $title . '</h1>';
foreach ($apps as $app => $name) {
- $page = $registry->getInitialPage($app);
- if ($page instanceof PEAR_Error) {
- continue;
- }
- echo '<div class="appService">' .
- '<a href="' . $page . '">' .
- '<img src="' . $registry->getImageDir($app) . '/'. $app . '.png" /> ' .
- $name .
- '</a></div>';
-}
\ No newline at end of file
+ try {
+ $page = $registry->getInitialPage($app);
+ echo '<div class="appService">' .
+ '<a href="' . $page . '">' .
+ '<img src="' . $registry->getImageDir($app) . '/'. $app . '.png" /> ' .
+ $name .
+ '</a></div>';
+ } catch (Horde_Exception $e) {}
+}
// Get rid of the trailing @ (when no host is included in
// the email address).
$address = str_replace('@>', '>', $address);
- $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
- if (is_a($mail_link, 'PEAR_Error')) {
+ try {
+ $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
+ } catch (Horde_Exception $e) {
$mail_link = 'mailto:' . urlencode($address);
}
if (!empty($select_id) &&
$registry->hasMethod('files/selectlistResults') &&
$registry->hasMethod('files/returnFromSelectlist')) {
- $filelist = $registry->call('files/selectlistResults', array($select_id));
- if ($filelist && !is_a($filelist, 'PEAR_Error')) {
- $i = 0;
- foreach ($filelist as $val) {
- $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
- if ($data && !is_a($data, 'PEAR_Error')) {
- $part = new Horde_Mime_Part();
- $part->setName(reset($val));
- $part->setContents($data);
- try {
- $imp_compose->addMIMEPartAttachment($part);
- } catch (IMP_Compose_Exception $e) {
- $notification->push($e, 'horde.error');
+ try {
+ $filelist = $registry->call('files/selectlistResults', array($select_id));
+ if ($filelist) {
+ $i = 0;
+ foreach ($filelist as $val) {
+ $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
+ if ($data) {
+ $part = new Horde_Mime_Part();
+ $part->setName(reset($val));
+ $part->setContents($data);
+ try {
+ $imp_compose->addMIMEPartAttachment($part);
+ } catch (IMP_Compose_Exception $e) {
+ $notification->push($e, 'horde.error');
+ }
}
}
}
- }
+ } catch (Horde_Exception $e) {}
}
break;
}
if ($_SESSION['imp']['file_upload']) {
$localeinfo = Horde_Nls::getLocaleInfo();
- if ($GLOBALS['registry']->hasMethod('files/selectlistLink')) {
- $res = $GLOBALS['registry']->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true));
- $t->set('selectlistlink', (is_a($res, 'PEAR_Error')) ? null : $res);
+ try {
+ $t->set('selectlistlink', $GLOBALS['registry']->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true)));
+ } catch (Horde_Exception $e) {
+ $t->set('selectlistlink', null);
}
$t->set('maxattachsize', !$imp_compose->maxAttachmentSize());
if (!$t->get('maxattachsize')) {
foreach ($r_array as $recipient) {
$emails[] = $recipient['mailbox'] . '@' . $recipient['host'];
}
- $results = $registry->call('contacts/search', array($emails, array($abook), array($abook => array('email'))));
+
+ try {
+ $results = $registry->call('contacts/search', array($emails, array($abook), array($abook => array('email'))));
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e);
+ $notification->push(_("Could not save recipients."));
+ return;
+ }
foreach ($r_array as $recipient) {
/* Skip email addresses that already exist in the add_source. */
}
$name = Horde_Mime::decode($name);
- $result = $registry->call('contacts/import', array(array('name' => $name, 'email' => $recipient['mailbox'] . '@' . $recipient['host']), 'array', $abook));
- if (is_a($result, 'PEAR_Error')) {
- if ($result->getCode() == 'horde.error') {
- $notification->push($result, $result->getCode());
- }
- } else {
+ try {
+ $registry->call('contacts/import', array(array('name' => $name, 'email' => $recipient['mailbox'] . '@' . $recipient['host']), 'array', $abook));
$notification->push(sprintf(_("Entry \"%s\" was successfully added to the address book"), $name), 'horde.success');
+ } catch (Horde_Exception $e) {
+ if ($e->getCode() == 'horde.error') {
+ $notification->push($e, $e->getCode());
+ }
}
}
}
return;
}
- $vcard = $GLOBALS['registry']->call('contacts/ownVCard');
- if (is_a($vcard, 'PEAR_Error')) {
- throw new IMP_Compose_Exception($vcard);
+ try {
+ $vcard = $GLOBALS['registry']->call('contacts/ownVCard');
+ } catch (Horde_Exception $e) {
+ throw new IMP_Compose_Exception($e);
}
$part = new Horde_Mime_Part();
static public function getAddressList($search = '')
{
$sparams = IMP_Compose::getAddressSearchParams();
- $res = $GLOBALS['registry']->call('contacts/search', array($search, $sparams['sources'], $sparams['fields'], true));
- if (is_a($res, 'PEAR_Error')) {
- Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $res = $GLOBALS['registry']->call('contacts/search', array($search, $sparams['sources'], $sparams['fields'], true));
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
return array();
- } elseif (!count($res)) {
+ }
+
+ if (!count($res)) {
return array();
}
} catch (Horde_Exception $e) {}
/* Add key to the user's address book. */
- $result = $GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source')));
- if (is_a($result, 'PEAR_Error')) {
- throw new Horde_Exception($result);
- }
+ $GLOBALS['registry']->call('contacts/addField', array($sig['email'], $sig['name'], self::PUBKEY_FIELD, $public_key, $GLOBALS['prefs']->getValue('add_source')));
}
return $key_info;
/* Try retrieving by e-mail only first. */
$params = IMP_Compose::getAddressSearchParams();
- $result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
-
- /* TODO: Retrieve by ID. */
+ try {
+ $result = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
+ } catch (Horde_Exception $e) {
+ /* TODO: Retrieve by ID. */
- /* See if the address points to the user's public key. */
- if (is_a($result, 'PEAR_Error')) {
+ /* See if the address points to the user's public key. */
require_once 'Horde/Identity.php';
$identity = Identity::singleton(array('imp', 'imp'));
$personal_pubkey = $this->getPersonalPublicKey();
if (!empty($personal_pubkey) && $identity->hasAddress($address)) {
$result = $personal_pubkey;
- }
- }
-
- /* Try retrieving via a PGP public keyserver. */
- if (empty($options['noserver']) && is_a($result, 'PEAR_Error')) {
- try {
- $result = $this->getFromPublicKeyserver($keyid, $address);
-
- /* If there is a cache driver configured and a cache object
- * exists, store the retrieved public key in the cache. */
- if (is_object($cache)) {
- $cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600);
+ } elseif (empty($options['noserver'])) {
+ try {
+ $result = $this->getFromPublicKeyserver($keyid, $address);
+
+ /* If there is a cache driver configured and a cache
+ * object exists, store the retrieved public key in the
+ * cache. */
+ if (is_object($cache)) {
+ $cache->set("PGPpublicKey_" . $address . $keyid, $result, 3600);
+ }
+ } catch (Horde_Exception $e) {
+ /* Return now, if no public key found at all. */
+ Horde::logMessage('PGPpublicKey: ' . $e->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address));
}
- } catch (Horde_Exception $e) {}
- }
-
- /* Return now, if no public key found at all. */
- if (is_a($result, 'PEAR_Error')) {
- Horde::logMessage('PGPpublicKey: ' . $result->getMessage(), __FILE__, __LINE__, PEAR_LOG_DEBUG);
- throw new Horde_Exception(sprintf(_("Could not retrieve public key for %s."), $address));
+ } else {
+ $result = '';
+ }
}
/* If more than one public key is returned, just return the first in
return array();
}
- $res = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
- if (is_a($res, 'PEAR_Error')) {
- throw new Horde_Exception($res);
- }
-
- return $res;
+ return $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
}
/**
public function deletePublicKey($email)
{
$params = IMP_Compose::getAddressSearchParams();
- $res = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
- if (is_a($res, 'PEAR_Error')) {
- throw new Horde_Exception($res);
- }
-
- return $res;
+ return $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
}
/**
throw new Horde_Exception(_("Not a valid public key."));
}
- $result = $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
- if (is_a($result, 'PEAR_Error')) {
- throw new Horde_Exception($result);
- }
+ $GLOBALS['registry']->call('contacts/addField', array($email, $name, self::PUBKEY_FIELD, $cert, $GLOBALS['prefs']->getValue('add_source')));
}
/**
public function getPublicKey($address)
{
$params = IMP_Compose::getAddressSearchParams();
- $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
- /* See if the address points to the user's public key. */
- if (is_a($key, 'PEAR_Error')) {
+ try {
+ $key = $GLOBALS['registry']->call('contacts/getField', array($address, self::PUBKEY_FIELD, $params['sources'], false, true));
+ } catch (Horde_Exception $e) {
+ /* See if the address points to the user's public key. */
require_once 'Horde/Identity.php';
$identity = Identity::singleton(array('imp', 'imp'));
$personal_pubkey = $this->getPersonalPublicKey();
if (!empty($personal_pubkey) && $identity->hasAddress($address)) {
return $personal_pubkey;
}
- throw new Horde_Exception($key);
+
+ throw $e;
}
/* If more than one public key is returned, just return the first in
if (empty($params['sources'])) {
return array();
}
- $result = $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
- if (is_a($result, 'PEAR_Error')) {
- throw new Horde_Exception($result);
- }
-
- return $result;
+ return $GLOBALS['registry']->call('contacts/getAllAttributeValues', array(self::PUBKEY_FIELD, $params['sources']));
}
/**
public function deletePublicKey($email)
{
$params = IMP_Compose::getAddressSearchParams();
- $result = $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
- if (is_a($result, 'PEAR_Error')) {
- throw new Horde_Exception($result);
- }
+ $GLOBALS['registry']->call('contacts/deleteField', array($email, self::PUBKEY_FIELD, $params['sources']));
}
/**
* Runs the filters if they are able to be applied manually.
*
* @param string $mbox The mailbox to apply the filters to.
+ * @throws Horde_Exception
*/
public function filter($mbox)
{
* notification message?
*
* @return boolean True if the messages(s) were deleted.
+ * @throws Horde_Exception
*/
public function blacklistMessage($indices, $show_link = true)
{
* notification message?
*
* @return boolean True if the messages(s) were whitelisted.
+ * @throws Horde_Exception
*/
public function whitelistMessage($indices, $show_link = true)
{
* notification message?
*
* @return boolean True on success.
+ * @throws Horde_Exception
*/
protected function _processBWlist($indices, $descrip, $reg1, $reg2, $link)
{
$newName = $newAddress;
}
- $result = $registry->call('contacts/import',
- array(array('name' => $newName, 'email' => $newAddress),
- 'array', $prefs->getValue('add_source')));
- if ($result instanceof PEAR_Error) {
- throw new Horde_Exception($result);
- }
+ $result = $registry->call('contacts/import', array(array('name' => $newName, 'email' => $newAddress), 'array', $prefs->getValue('add_source')));
$contact_link = $registry->link('contacts/show', array('uid' => $result, 'source' => $prefs->getValue('add_source')));
/* Add the list of editable tasklists to the list. */
if (!empty($options['inc_tasklists']) &&
!empty($_SESSION['imp']['tasklistavail'])) {
- $tasklists = $GLOBALS['registry']->call('tasks/listTasklists',
- array(false, PERMS_EDIT));
+ try {
+ $tasklists = $GLOBALS['registry']->call('tasks/listTasklists', array(false, PERMS_EDIT));
- if (!$tasklists instanceof PEAR_Error && count($tasklists)) {
- $text .= '<option value="" disabled="disabled"> </option><option value="" disabled="disabled">- - ' . _("Task Lists") . ' - -</option>' . "\n";
+ if (count($tasklists)) {
+ $text .= '<option value="" disabled="disabled"> </option><option value="" disabled="disabled">- - ' . _("Task Lists") . ' - -</option>' . "\n";
- foreach ($tasklists as $id => $tasklist) {
- $text .= sprintf('<option value="%s">%s</option>%s',
- '_tasklist_' . $id,
- Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
- "\n");
+ foreach ($tasklists as $id => $tasklist) {
+ $text .= sprintf('<option value="%s">%s</option>%s',
+ '_tasklist_' . $id,
+ Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
+ "\n");
+ }
}
- }
+ } catch (Horde_Exception $e) {}
}
/* Add the list of editable notepads to the list. */
if (!empty($options['inc_notepads']) &&
!empty($_SESSION['imp']['notepadavail'])) {
- $notepads = $GLOBALS['registry']->call('notes/listNotepads',
- array(false, PERMS_EDIT));
-
- if (!$notepads instanceof PEAR_Error && count($notepads)) {
- $text .= '<option value="" disabled="disabled"> </option><option value="" disabled="disabled">- - ' . _("Notepads") . ' - -</option>' . "\n";
-
- foreach ($notepads as $id => $notepad) {
- $text .= sprintf('<option value="%s">%s</option>%s',
- '_notepad_' . $id,
- Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
- "\n");
+ try {
+ $notepads = $GLOBALS['registry']->call('notes/listNotepads', array(false, PERMS_EDIT));
+ if (count($notepads)) {
+ $text .= '<option value="" disabled="disabled"> </option><option value="" disabled="disabled">- - ' . _("Notepads") . ' - -</option>' . "\n";
+
+ foreach ($notepads as $id => $notepad) {
+ $text .= sprintf('<option value="%s">%s</option>%s',
+ '_notepad_' . $id,
+ Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)),
+ "\n");
+ }
}
- }
+ } catch (Horde_Exception $e) {}
}
return $text;
* created.
* @param string $action Either 'copy' or 'move'.
* @param mixed $indices See IMP::parseIndicesList().
- * @param string $type The object type to create, defaults to task.
+ * @param string $type The object type to create ('note' or 'task').
*
* @return boolean True if successful, false if not.
*/
$vTodo->setAttribute('PRIORITY', '3');
/* Get the list of editable tasklists. */
- $lists = $registry->call('tasks/listTasklists',
- array(false, PERMS_EDIT));
+ try {
+ $lists = $registry->call('tasks/listTasklists', array(false, PERMS_EDIT));
+ } catch (Horde_Exception $e) {
+ $lists = null;
+ $notification->push($e, $e->getCode());
+ }
/* Attempt to add the new vTodo item to the requested
* tasklist. */
- $res = $registry->call('tasks/import',
- array($vTodo, 'text/calendar', $list));
+ try {
+ $res = $registry->call('tasks/import', array($vTodo, 'text/calendar', $list));
+ } catch (Horde_Exception $e) {
+ $res = null;
+ $notification->push($e, $e->getCode());
+ }
break;
case 'note':
$vNote->setAttribute('BODY', $subject . "\n". $body);
/* Get the list of editable notepads. */
- $lists = $registry->call('notes/listNotepads',
- array(false, PERMS_EDIT));
+ try {
+ $lists = $registry->call('notes/listNotepads', array(false, PERMS_EDIT));
+ } catch (Horde_Exception $e) {
+ $lists = null;
+ $notification->push($e, $e->getCode());
+ }
/* Attempt to add the new vNote item to the requested
* notepad. */
- $res = $registry->call('notes/import',
- array($vNote, 'text/x-vnote', $list));
+ try {
+ $res = $registry->call('notes/import', array($vNote, 'text/x-vnote', $list));
+ } catch (Horde_Exception $e) {
+ $res = null;
+ $notification->push($e, $e->getCode());
+ }
break;
}
- if (is_a($res, 'PEAR_Error')) {
- $notification->push($res, $res->getCode());
- } elseif (!$res) {
- switch ($type) {
- case 'task':
- $notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
- break;
-
- case 'note':
- $notification->push(_("An unknown error occured while creating the new note."), 'horde.error');
- break;
- }
- } else {
- $name = '"' . htmlspecialchars($subject) . '"';
-
- /* Attempt to convert the object name into a hyperlink. */
- switch ($type) {
- case 'task':
- $link = $registry->link('tasks/show',
- array('uid' => $res));
- break;
- case 'note':
- if ($registry->hasMethod('notes/show')) {
- $link = $registry->link('notes/show',
- array('uid' => $res));
- } else {
- $link = false;
+ if (!is_null($res)) {
+ if (!$res) {
+ switch ($type) {
+ case 'task':
+ $notification->push(_("An unknown error occured while creating the new task."), 'horde.error');
+ break;
+
+ case 'note':
+ $notification->push(_("An unknown error occured while creating the new note."), 'horde.error');
+ break;
}
- break;
- }
- if ($link && !is_a($link, 'PEAR_Error')) {
- $name = sprintf('<a href="%s">%s</a>',
- Horde::url($link),
- $name);
+ } elseif (!is_null($lists)) {
+ $name = '"' . htmlspecialchars($subject) . '"';
+
+ /* Attempt to convert the object name into a
+ * hyperlink. */
+ try {
+ switch ($type) {
+ case 'task':
+ $link = $registry->link('tasks/show', array('uid' => $res));
+ break;
+
+ case 'note':
+ $link = $registry->hasMethod('notes/show')
+ ? $registry->link('notes/show', array('uid' => $res))
+ : false;
+ break;
+ }
+
+ if ($link) {
+ $name = sprintf('<a href="%s">%s</a>', Horde::url($link), $name);
+ }
+
+ $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
+ } catch (Horde_Exception $e) {}
}
-
- $notification->push(sprintf(_("%s was successfully added to \"%s\"."), $name, htmlspecialchars($lists[$list]->get('name'))), 'horde.success', array('content.raw'));
}
}
}
$headers = $this->_params['contents']->getHeaderOb();
/* Try to get back a result from the search. */
- $res = $GLOBALS['registry']->call('contacts/getField', array(Horde_Mime_Address::bareAddress($headers->getValue('from')), '__key', $params['sources'], false, true));
- return is_a($res, 'PEAR_Error') ? false : count($res);
+ try {
+ $res = $GLOBALS['registry']->call('contacts/getField', array(Horde_Mime_Address::bareAddress($headers->getValue('from')), '__key', $params['sources'], false, true));
+ return count($res);
+ } catch (Horde_Exception $e) {
+ return false;
+ }
}
}
// vEvent cancellation.
if ($registry->hasMethod('calendar/delete')) {
$guid = $components[$key]->getAttribute('UID');
- $event = $registry->call('calendar/delete', array('guid' => $guid));
- if (is_a($event, 'PEAR_Error')) {
- $msgs[] = array('error', _("There was an error deleting the event:") . ' ' . $event->getMessage());
- } else {
+ try {
+ $registry->call('calendar/delete', array('guid' => $guid));
$msgs[] = array('success', _("Event successfully deleted."));
+ } catch (Horde_Exception $e) {
+ $msgs[] = array('error', _("There was an error deleting the event:") . ' ' . $e->getMessage());
}
} else {
$msgs[] = array('warning', _("This action is not supported."));
case 'update':
// vEvent reply.
if ($registry->hasMethod('calendar/updateAttendee')) {
- $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $params[0]->getFromAddress()));
- if (is_a($event, 'PEAR_Error')) {
- $msgs[] = array('error', _("There was an error updating the event:") . ' ' . $event->getMessage());
- } else {
+ try {
+ $event = $registry->call('calendar/updateAttendee', array('response' => $components[$key], 'sender' => $params[0]->getFromAddress()));
$msgs[] = array('success', _("Respondent Status Updated."));
+ } catch (Horde_Exception $e) {
+ $msgs[] = array('error', _("There was an error updating the event:") . ' ' . $e->getMessage());
}
} else {
$msgs[] = array('warning', _("This action is not supported."));
$handled = false;
$guid = $components[$key]->getAttribute('UID');
// Check if this is an update.
- if ($registry->hasMethod('calendar/export') &&
- !is_a($registry->call('calendar/export', array($guid, 'text/calendar')), 'PEAR_Error')) {
+ try {
+ $registry->call('calendar/export', array($guid, 'text/calendar');
+
// Try to update in calendar.
if ($registry->hasMethod('calendar/replace')) {
- $result = $registry->call('calendar/replace', array('uid' => $guid, 'content' => $components[$key], 'contentType' => $this->mime_part->getType()));
- if (is_a($result, 'PEAR_Error')) {
- // Could be a missing permission.
- $msgs[] = array('warning', _("There was an error updating the event:") . ' ' . $result->getMessage() . '. ' . _("Trying to import the event instead."));
- } else {
+ try {
+ $registry->call('calendar/replace', array('uid' => $guid, 'content' => $components[$key], 'contentType' => $this->mime_part->getType()));
$handled = true;
$url = Horde::url($registry->link('calendar/show', array('uid' => $guid)));
$msgs[] = array('success', _("The event was updated in your calendar.") .
' ' . Horde::link($url, _("View event"), null, '_blank') . Horde::img('mime/icalendar.png', _("View event"), null, $registry->getImageDir('horde')) . '</a>');
+ } catch (Horde_Exception $e) {}
+ // Could be a missing permission.
+ $msgs[] = array('warning', _("There was an error updating the event:") . ' ' . $e->getMessage() . '. ' . _("Trying to import the event instead."));
}
}
- }
+ } catch (Horde_Exception $e) {}
+
if (!$handled && $registry->hasMethod('calendar/import')) {
// Import into calendar.
$handled = true;
- $guid = $registry->call('calendar/import', array('content' => $components[$key], 'contentType' => $this->mime_part->getType()));
- if (is_a($guid, 'PEAR_Error')) {
- $msgs[] = array('error', _("There was an error importing the event:") . ' ' . $guid->getMessage());
- } else {
+ try {
+ $guid = $registry->call('calendar/import', array('content' => $components[$key], 'contentType' => $this->mime_part->getType()));
$url = Horde::url($registry->link('calendar/show', array('uid' => $guid)));
$msgs[] = array('success', _("The event was added to your calendar.") .
' ' . Horde::link($url, _("View event"), null, '_blank') . Horde::img('mime/icalendar.png', _("View event"), null, $registry->getImageDir('horde')) . '</a>');
+ } catch (Horde_Exception $e) {
+ $msgs[] = array('error', _("There was an error importing the event:") . ' ' . $e->getMessage());
}
}
if (!$handled) {
case 'vFreebusy':
// Import into Kronolith.
if ($registry->hasMethod('calendar/import_vfreebusy')) {
- $res = $registry->call('calendar/import_vfreebusy', array($components[$key]));
- if (is_a($res, 'PEAR_Error')) {
- $msgs[] = array('error', _("There was an error importing user's free/busy information:") . ' ' . $res->getMessage());
- } else {
+ try {
+ $registry->call('calendar/import_vfreebusy', array($components[$key]));
$msgs[] = array('success', _("The user's free/busy information was sucessfully stored."));
+ } catch (Horde_Exception $e) {
+ $msgs[] = array('error', _("There was an error importing user's free/busy information:") . ' ' . $e->getMessage());
}
} else {
$msgs[] = array('warning', _("This action is not supported."));
case 'vTodo':
// Import into Nag.
if ($registry->hasMethod('tasks/import')) {
- $guid = $registry->call('tasks/import', array($components[$key], $this->mime_part->getType()));
- if (is_a($guid, 'PEAR_Error')) {
- $msgs[] = array('error', _("There was an error importing the task:") . ' ' . $guid->getMessage());
- } else {
+ try {
+ $guid = $registry->call('tasks/import', array($components[$key], $this->mime_part->getType()));
$url = Horde::url($registry->link('tasks/show', array('uid' => $guid)));
$msgs[] = array('success', _("The task has been added to your tasklist.") .
' ' . Horde::link($url, _("View task"), null, '_blank') . Horde::img('mime/icalendar.png', _("View task"), null, $registry->getImageDir('horde')) . '</a>');
+ } catch (Horde_Exception $e) {
+ $msgs[] = array('error', _("There was an error importing the task:") . ' ' . $e->getMessage());
}
} else {
$msgs[] = array('warning', _("This action is not supported."));
case 'REQUEST':
// Check if this is an update.
- if ($registry->hasMethod('calendar/export') &&
- !is_a($registry->call('calendar/export', array($vevent->getAttribute('UID'), 'text/calendar')), 'PEAR_Error')) {
+ try {
+ $registry->call('calendar/export', array($vevent->getAttribute('UID'), 'text/calendar'));
$is_update = true;
$desc = _("%s wants to notify you about changes of \"%s\".");
- } else {
+ } catch (Horde_Exception $e) {
$is_update = false;
// Check that you are one of the attendees here.
}
if ($registry->hasMethod('calendar/getFbCalendars') &&
- $registry->hasMethod('calendar/listEvents') &&
- !is_a($calendars = $registry->call('calendar/getFbCalendars'), 'PEAR_Error')) {
-
- $vevent_allDay = true;
- $vevent_start = new Horde_Date($start);
- $vevent_end = new Horde_Date($end);
- // Check if it's an all-day event.
- if (is_array($start)) {
- $vevent_end = $vevent_end->sub(1);
- } else {
- $vevent_allDay = false;
- $time_span_start = new Horde_Date($start);
- $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60);
- $time_span_end = new Horde_Date($end);
- $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60);
- }
- $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false));
-
- if (!is_a($events, 'PEAR_Error') && count($events)) {
- $html .= '<h2 class="smallheader">' . _("Possible Conflicts") . '</h2><table id="itipconflicts">';
- // TODO: Check if there are too many events to show.
- foreach ($events as $calendar) {
- foreach ($calendar as $event) {
- if ($vevent_allDay || $event->isAllDay()) {
- $html .= '<tr class="itipcollision">';
- } else {
- if ($event->end->compareDateTime($time_span_start) <= -1 ||
- $event->start->compareDateTime($time_span_end) >= 1) {
- continue;
- }
- if ($event->end->compareDateTime($vevent_start) <= -1 ||
- $event->start->compareDateTime($vevent_end) >= 1) {
- $html .= '<tr class="itipnearcollision">';
- } else {
+ $registry->hasMethod('calendar/listEvents')) {
+ try {
+ $calendars = $registry->call('calendar/getFbCalendars');
+
+ $vevent_allDay = true;
+ $vevent_start = new Horde_Date($start);
+ $vevent_end = new Horde_Date($end);
+ // Check if it's an all-day event.
+ if (is_array($start)) {
+ $vevent_end = $vevent_end->sub(1);
+ } else {
+ $vevent_allDay = false;
+ $time_span_start = new Horde_Date($start);
+ $time_span_start = $time_span_start->sub($prefs->getValue('conflict_interval') * 60);
+ $time_span_end = new Horde_Date($end);
+ $time_span_end = $time_span_end->add($prefs->getValue('conflict_interval') * 60);
+ }
+ $events = $registry->call('calendar/listEvents', array($start, $vevent_end, $calendars, false));
+
+ if (count($events)) {
+ $html .= '<h2 class="smallheader">' . _("Possible Conflicts") . '</h2><table id="itipconflicts">';
+ // TODO: Check if there are too many events to show.
+ foreach ($events as $calendar) {
+ foreach ($calendar as $event) {
+ if ($vevent_allDay || $event->isAllDay()) {
$html .= '<tr class="itipcollision">';
+ } else {
+ if ($event->end->compareDateTime($time_span_start) <= -1 ||
+ $event->start->compareDateTime($time_span_end) >= 1) {
+ continue;
+ }
+ if ($event->end->compareDateTime($vevent_start) <= -1 ||
+ $event->start->compareDateTime($vevent_end) >= 1) {
+ $html .= '<tr class="itipnearcollision">';
+ } else {
+ $html .= '<tr class="itipcollision">';
+ }
}
- }
- $html .= '<td>'. $event->getTitle() . '</td><td>'
- . $event->getTimeRange() . '</td></tr>';
+ $html .= '<td>'. $event->getTitle() . '</td><td>'
+ . $event->getTimeRange() . '</td></tr>';
+ }
}
+ $html .= '</table>';
}
- $html .= '</table>';
- }
+ } catch (Horde_Exception $e) {}
}
if ($_SESSION['imp']['view'] != 'imp') {
$sess['file_upload'] = $GLOBALS['browser']->allowFileUploads();
/* Is the 'mail/canApplyFilters' API call available? */
- if ($registry->hasMethod('mail/canApplyFilters') &&
- $registry->call('mail/canApplyFilters')) {
- $sess['filteravail'] = true;
- }
+ try {
+ if ($registry->call('mail/canApplyFilters')) {
+ $sess['filteravail'] = true;
+ }
+ } catch (Horde_Exception $e) {}
/* Is the 'tasks/listTasklists' call available? */
if ($conf['tasklist']['use_tasklist'] &&
// and login pages, since those are handled below and need to fall through
// to IMP-specific code.
$compose_page = Horde_Util::nonInputVar('compose_page');
-if (is_a(($pushed = $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('imp', !(defined('AUTH_HANDLER') || $compose_page));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
if (!defined('IMP_TEMPLATES')) {
}
/* Make sure we have an active IMAP stream. */
-if (!$GLOBALS['registry']->call('mail/server')) {
+try {
+ $res = $GLOBALS['registry']->call('mail/server');
+} catch (Horde_Exception $e) {
+ $res = false;
+}
+
+if (!$res) {
header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('redirect.php'), 'url', Horde::selfUrl(true)));
exit;
}
if ($imp_auth) {
Horde_Auth::clearAuth();
@session_destroy();
- Horde::setupSessionHandler();
+ $registry->setupSessionHandler();
@session_start();
}
if (Horde_Auth::getProvider() == 'imp') {
/* Destroy any existing session on login and make sure to use a new
* session ID, to avoid session fixation issues. */
- Horde::getCleanSession();
+ $registry->getCleanSession();
}
if (IMP_Session::createSession($imapuser, $pass, Horde_Util::getFormData('server_key', IMP_Session::getAutoLoginServer()))) {
'data' => $mime_part->getContents(),
'type' => $mime_part->getType()
);
- $res = $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data));
- if (is_a($res, 'PEAR_Error')) {
- $notification->push($res, 'horde.error');
+ try {
+ $registry->call('images/saveImage', array(null, Horde_Util::getFormData('gallery'), $image_data));
+ } catch (Horde_Exception $e) {
+ $notification->push($e, 'horde.error');
break;
}
Horde_Util::closeWindowJS();
<?php
if ($registry->hasMethod('contacts/sources')) {
$search = IMP_Compose::getAddressSearchParams();
- $readable = $registry->call('contacts/sources');
- $writeable = $registry->call('contacts/sources', true);
+ try {
+ $readable = $registry->call('contacts/sources');
+ } catch (Horde_Exception $e) {
+ $readable = null;
+ }
+ try {
+ $writeable = $registry->call('contacts/sources', true);
+ } catch (Horde_Exception $e) {
+ $writeable = null;
+ }
$nbReadSources = count(array_keys($readable));
$nbWriteSources = count(array_keys($writeable));
}
$readSelect = '';
- if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+ if (is_array($readable)) {
foreach (array_diff(array_keys($readable), $search['sources']) as $source) {
$readSelect .= '<option value="' . $source . '">' . $readable[$source] . "</option>\n";
}
}
- if (!is_a($writeable, 'PEAR_Error') && is_array($writeable)) {
+ if (is_array($writeable)) {
$writeSelect = '<option value="">' . _("None") . '</option>' . "\n";
$writeSource = '';
foreach ($writeable as $source => $name) {
}
$search_fields = array();
- if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+ if (is_array($readable)) {
foreach (array_keys($readable) as $source) {
- $search_fields[$source] = $registry->call('contacts/fields', $source);
+ try {
+ $search_fields[$source] = $registry->call('contacts/fields', $source);
+ } catch (Horde_Exception $e) {}
}
}
{
global $conf, $registry;
- if (!empty($conf['rules']['usefolderapi']) &&
- $registry->hasMethod('mail/folderlist')) {
- $mailboxes = $registry->call('mail/folderlist');
- if (!is_a($mailboxes, 'PEAR_Error')) {
+ if (!empty($conf['rules']['usefolderapi'])) {
+ try {
+ $mailboxes = $registry->call('mail/folderlist');
$createfolder = $registry->hasMethod('mail/createFolder');
$text = '<select id="' . $tagname . '" name="' . $tagname . '"';
$text .= '</select>';
return $text;
- }
+ } catch (Horde_Exception $e) {}
}
return '<input id="' . $tagname . '" name="' . $tagname . '" size="40" value="' . $value . '" />';
*
* @param string $folder The name of the folder to create.
*
- * @return boolean True on success, false if not created, PEAR_Error on
- * failure.
+ * @return boolean True on success, false if not created. PEAR_Error on
+ * @throws Horde_Exception
*/
static public function createFolder($folder)
{
// Registry.
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('ingo', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('ingo', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
// Create a new folder if requested.
if ($vars->get('actionID') == 'create_folder') {
- $result = Ingo::createFolder($vars->get('new_folder_name'));
- if (is_string($result)) {
- $spam->setSpamFolder($result);
- } else {
- $success = false;
- if (is_a($result, 'PEAR_Error')) {
- $notification->push($result->getMessage());
+ try {
+ $result = Ingo::createFolder($vars->get('new_folder_name'));
+ if ($result) {
+ $spam->setSpamFolder($result);
+ } else {
+ $success = false;
}
+ } catch (Horde_Exception $e) {
+ $success = false;
+ $notification->push($e->getMessage());
}
} else {
$spam->setSpamFolder($vars->get('folder'));
// Registry.
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('jeta', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('jeta', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
// Registry.
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('kastalia', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('kastalia', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
//################### </MANUELLER ANMELDE CHECK (WENN base.php NICHT INCLUDIERT WIRD)> ###################
// Registry.
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('kastalia', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('kastalia', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
@define('KASTALIA_TEMPLATES', $registry->get('templates'));
*/
$this->_path = $registry->get('webroot', 'koward') . '/' . $args[0];
- if (is_a(($pushed = $registry->pushApp('koward', false)), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+ try {
+ $registry->pushApp('koward', false);
+ } catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
echo 'Perission denied!';
exit;
}
}
}
- if (is_a(($pushed = $registry->pushApp('koward',
- empty($this->auth_handler)
- || $this->auth_handler != $this->params[':action'])), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+ try {
+ $registry->pushApp('koward',
+ empty($this->auth_handler)
+ || $this->auth_handler != $this->params[':action']);
+ } catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login')));
exit;
}
{
global $registry;
- if (is_a(($pushed = $registry->pushApp('koward',
- empty($this->auth_handler)
- || $this->auth_handler != $this->params[':action'])), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+ try {
+ $registry->pushApp('koward',
+ empty($this->auth_handler)
+ || $this->auth_handler != $this->params[':action']);
+ } catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
header('Location: ' . $this->urlFor(array('controller' => 'index', 'action' => 'login')));
exit;
}
if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
/* Destroy any existing session on login and make sure to use a
* new session ID, to avoid session fixation issues. */
- Horde::getCleanSession();
+ $GLOBALS['registry']->getCleanSession();
if ($this->koward->auth->authenticate(Horde_Util::getPost('horde_user'),
array('password' => Horde_Util::getPost('horde_pass')))) {
$entry = sprintf('Login success for %s [%s] to Horde',
* toJson() method?
*
* @return array Events in the given time range.
+ * @throws Horde_Exception
*/
public function listEvents($startDate = null, $endDate = null,
$showRecurrence = false, $hasAlarm = false,
}
$eventsList = $this->_params['registry']->call($this->api . '/listTimeObjects', array(array($category), $startDate, $endDate));
- if (is_a($eventsList, 'PEAR_Error')) {
- return $eventsList;
- }
if (is_null($startDate)) {
$startDate = new Horde_Date(array('mday' => 1,
* @param string $email The email address to look for.
*
* @return mixed The url on success or false on failure.
+ * @throws Horde_Exception
*/
function getUrl($email)
{
$result = $GLOBALS['registry']->call('contacts/getField',
array($email, 'freebusyUrl', $sources, true, true));
- if (is_a($result, 'PEAR_Error')) {
- return $result;
- } elseif (is_array($result)) {
+ if (is_array($result)) {
return array_shift($result);
- } else {
- return $result;
}
+
+ return $result;
}
}
}
}
- $res = $GLOBALS['registry']->call('contacts/search', array($search, $src, $fields, true));
- if (is_a($res, 'PEAR_Error') || !count($res)) {
- Horde::logMessage($res, __FILE__, __LINE__, PEAR_LOG_ERR);
+ try {
+ $res = $GLOBALS['registry']->call('contacts/search', array($search, $src, $fields, true));
+ } catch (Horde_Exception $e) {
+ Horde::logMessage($e, __FILE__, __LINE__, PEAR_LOG_ERR);
+ return array();
+ }
+
+ if (!count($res)) {
return array();
}
$apis = array_unique($GLOBALS['registry']->listAPIs());
foreach ($apis as $api) {
if ($GLOBALS['registry']->hasMethod($api . '/listTimeObjects')) {
- $categories = $GLOBALS['registry']->call($api . '/listTimeObjectCategories');
- if (is_a($categories, 'PEAR_Error') || !count($categories)) {
+ try {
+ $categories = $GLOBALS['registry']->call($api . '/listTimeObjectCategories');
+ } catch (Horde_Exception $e) {
+ continue;
+ }
+
+ if (!count($categories)) {
continue;
}
$registry = Horde_Registry::singleton();
}
-if (is_a(($pushed = $registry->pushApp('kronolith', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('kronolith', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
define('KRONOLITH_TEMPLATES', $registry->get('templates'));
Horde_Auth::setAuth($user, array());
// Import data.
-$result = $registry->call('calendar/import',
- array($ical, 'text/calendar', $cal));
-if (is_a($result, 'PEAR_Error')) {
- $cli->fatal($result->toString());
+try {
+ $result = $registry->call('calendar/import', array($ical, 'text/calendar', $cal));
+} catch (Horde_Exception $e) {
+ $cli->fatal($e->toString());
}
$cli->message('Imported successfully ' . count($result) . ' events', 'cli.success');
<?php
if ($registry->hasMethod('contacts/sources')) {
$selected = explode("\t", $prefs->getValue('search_sources'));
- $readable = $registry->call('contacts/sources');
- $writeable = $registry->call('contacts/sources', true);
+ try {
+ $readable = $registry->call('contacts/sources');
+ } catch (Horde_Exception $e) {
+ $readable = null;
+ }
+ try {
+ $writeable = $registry->call('contacts/sources', true);
+ } catch (Horde_Exception $e) {
+ $writeable = null;
+ }
$nbReadSources = count(array_keys($readable));
$nbWriteSources = count(array_keys($writeable));
}
$readSelect = '';
- if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+ if (is_array($readable)) {
foreach (array_diff(array_keys($readable), $selected) as $source) {
$readSelect .= '<option value="' . $source . '">' . $readable[$source] . "</option>\n";
}
}
- if (!is_a($writeable, 'PEAR_Error') && is_array($writeable)) {
+ if (is_array($writeable)) {
$writeSelect = '<option value="">' . _("None") . '</option>' . "\n";
$writeSource = '';
foreach ($writeable as $source => $name) {
}
$search_fields = array();
- if (!is_a($readable, 'PEAR_Error') && is_array($readable)) {
+ if (is_array($readable)) {
foreach (array_keys($readable) as $source) {
- $search_fields[$source] = $registry->call('contacts/fields', $source);
+ try {
+ $search_fields[$source] = $registry->call('contacts/fields', $source);
+ } catch (Horde_Exception $e) {}
}
}
foreach ($registry->listAPIs() as $api) {
if ($registry->hasMethod($api . '/getSellingForm')) {
$apis[$api] = array();
- $articles = $registry->call($api . '/listCostObjects');
- if ($articles instanceof PEAR_Error) {
- $notification->push($articles);
- } elseif (!empty($articles)) {
- foreach ($articles[0]['objects'] as $item) {
- $apis[$api][$item['id']] = $item['name'];
+ try {
+ $articles = $registry->call($api . '/listCostObjects');
+ if (!empty($articles)) {
+ foreach ($articles[0]['objects'] as $item) {
+ $apis[$api][$item['id']] = $item['name'];
+ }
}
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
}
}
}
// Do we have a gallery?
if (empty($info['gallery'])) {
$abbr = Horde_String::substr(strip_tags($info['body'][$default_lang]['content']), 0, $conf['preview']['list_content']);
- $result = $registry->call('images/createGallery',
- array(null,
- array('name' => $info['body'][$default_lang]['title'],
- 'desc' => $abbr)));
- if ($result instanceof PEAR_Error) {
- $notification->push(_("There was an error creating gallery: ") . $result->getMessage(), 'horde.warning');
- } else {
+ try {
+ $result = $registry->call('images/createGallery',
+ array(null,
+ array('name' => $info['body'][$default_lang]['title'],
+ 'desc' => $abbr)));
$info['gallery'] = $result;
+ } catch (Horde_Exception $e) {
+ $notification->push(_("There was an error creating gallery: ") . $e->getMessage(), 'horde.warning');
}
}
if (!empty($info['gallery'])) {
$news->write_db->query('UPDATE ' . $news->prefix . ' SET gallery = ? WHERE id = ?', array($info['gallery'], $id));
foreach ($images_uploaded as $i) {
- $result = $registry->call('images/saveImage',
+ try {
+ $registry->call('images/saveImage',
array(null, $info['gallery'],
array('filename' => $info['picture_' . $i]['file'],
'description' => $info['caption_' . ($i == 0 ? $i . '_' . $default_lang: $i)],
'type' => $info['picture_' . $i]['type'],
'data' => file_get_contents($info['picture_' . $i]['file']))));
- if ($result instanceof PEAR_Error) {
- $notification->push(_("There was an error with the uploaded image: ") . $result->getMessage(), 'horde.warning');
+ } catch (Horde_Exception $e) {
+ $notification->push(_("There was an error with the uploaded image: ") . $e->getMessage(), 'horde.warning');
}
}
}
}
}
if ($image['gallery']) {
- $result = $registry->call('images/removeGallery', array(null, $image['gallery']));
- if ($result instanceof PEAR_Error) {
- $notification->push($result);
+ try {
+ $registry->call('images/removeGallery', array(null, $image['gallery']));
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
}
}
// Delete forum
if ($registry->hasMethod('forums/deleteForum')) {
- $comments = $registry->call('forums/deleteForum', array('news', $id));
- if ($comments instanceof PEAR_Error) {
- $notification->push($comments);
+ try {
+ $registry->call('forums/deleteForum', array('news', $id));
+ } catch (Horde_Exception $e) {
+ $notification->push($e);
}
}
. '<thead><tr><th>' . _("Title") . '</th>'
. '<th>' . _("User") . '</th></tr></thead>';
- $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
- array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
- 'news', 0, $this->_params['limit']));
- if ($threads instanceof PEAR_Error) {
- return $threads->getMessage();
+ try {
+ $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
+ array(Horde_Auth::getAuth(), 'message_timestamp', 1, false,
+ 'news', 0, $this->_params['limit']));
+ } catch (Horde_Exception $e) {
+ return $e->getMessage();
}
foreach ($threads as $message) {
$GLOBALS['cache']->set($cache_key, $html);
return $html;
}
-}
\ No newline at end of file
+}
$params = array(0, 'message_timestamp', 1, false, 'news', null, 0, $limit);
$threads = $registry->call('forums/getThreads', $params);
- if ($threads instanceof PEAR_Error) {
- return $threads;
- }
foreach ($threads as $id => $message) {
- $news_id = $registry->call('forums/getForumName', array('news', $message['forum_id']));
- if ($news_id instanceof PEAR_Error) {
+ try {
+ $news_id = $registry->call('forums/getForumName', array('news', $message['forum_id']));
+ } catch (Horde_Exception $e) {
unset($threads[$id]);
continue;
}
// Registry.
$registry = Horde_Registry::singleton();
-if (($pushed = $registry->pushApp('news', !defined('AUTH_HANDLER'))) instanceof PEAR_Error) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('news', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
define('NEWS_TEMPLATES', $registry->get('templates'));
$vNote->setAttribute('BODY', $body);
/* Attempt to add the new vNote item to the requested notepad. */
-$res = $registry->call('notes/import', array($vNote, 'text/x-vnote'));
-
-if ($res instanceof PEAR_Error) {
- $notification->push($res);
- header('Location: ' . News::getUrlFor('news', $id));
- exit;
-} else {
+try {
+ $registry->call('notes/import', array($vNote, 'text/x-vnote'));
$notification->push(_("News sucessfuly added to you notes."), 'horde.success');
header('Location: ' . $registry->getInitialPage('mnemo'));
- exit;
+} catch (Horde_Exception $e) {
+ $notification->push($e);
+ header('Location: ' . News::getUrlFor('news', $id));
}
array('message_subject' => $row['title']), $conf['comments']['comment_template']);
$comments = $registry->call('forums/doComments', $params);
- if ($comments instanceof PEAR_Error) {
- return $comments;
- }
if (!empty($comments['threads'])) {
echo $comments['threads'];
// schedul
if ($row['selling']) {
$item = explode('|', $row['selling']);
- $sell_from = $registry->call($item[0] . '/getSellingForm', $item[1]);
- if ($sell_from instanceof PEAR_Error) {
- echo $sell_from->getMessage();
- } else {
- echo $sell_from;
+ try {
+ echo $registry->call($item[0] . '/getSellingForm', $item[1]);
+ } catch (Horde_Exception $e) {
+ echo $e->getMessage();
}
}
$this->_vars->set('contact_list_create', true);
}
}
- $this->addVariable(_("Name"), 'contact_list', 'text', false,
+ $this->addVariable(_("Name"), 'contact_list', 'text', false,
$conf['addresses']['contact_list'] == 'auto' || $prefs->getValue('contact_list') == 'auto' ? true : false, _("The substitutions %c, %g or %s will be replaced automatically by the class, grade respectively semester name."));
if (!$this->_vars->exists('contact_list')) {
$contactlist = $conf['addresses']['contact_list'] == 'auto' ? $conf['addresses']['contact_list_name'] : $prefs->getValue('contact_list_name');
if ($createlist) {
$apiargs = array(
'content' => array(
- '__type' => 'Group',
+ '__type' => 'Group',
'__members' => serialize($this->_vars->get('students')),
- 'name' => Skoli_School::parseContactListName($this->_vars->get('contact_list'), $this->_vars, true),
+ 'name' => Skoli_School::parseContactListName($this->_vars->get('contact_list'), $this->_vars, true),
),
'contentType' => 'array',
'source' => $this->_vars->get('address_book')
);
- $result = $registry->call('contacts/import', $apiargs);
- if ($result === false || is_a($result, 'PEAR_Error')) {
+
+ try {
+ $registry->call('contacts/import', $apiargs);
+ } catch (Horde_Exception $e) {
$notification->push(sprintf(_("Couldn't create the contact list \"%s\"."), $this->_vars->get('contact_list')), 'horde.warning');
}
}
return PEAR::raiseError(sprintf(_("Error loading the school \"%s\" from template."), $schoolName));
} else {
$this->school = self::$schools[$schoolName];
- }
+ }
}
/**
unset($marksformat['custom']);
}
$form->addVariable(_(ucfirst($property)), $property, 'enum', true, true, null, array($marksformat, _("Choose:")));
- } else {
+ } else {
require_once 'Horde/Form/Action.php';
if ($form->_vars->exists($property) && !isset($marksformat[$form->_vars->get($property)])) {
$form->_vars->set($property . '_custom', $form->_vars->get($property));
* This function will also sort the resulting list, if requested.
*
* @param array $classes An array of classes to display, a
- * single classname or null/empty to
+ * single classname or null/empty to
* display classes $GLOBALS['display_classes'].
* @param string $sortby_student The field by which to sort
* (SKOLI_SORT_PRIORITY, SKOLI_SORT_NAME
'source' => $addressbook,
'objectId' => $id
);
- $result = $registry->call('contacts/getContact', $apiargs);
- if ($result === false || is_a($result, 'PEAR_Error')) {
+ try {
+ $student = $registry->call('contacts/getContact', $apiargs);
+ } catch (Horde_Exception $e) {
$notification->push(sprintf(_("Couldn't create the contact list \"%s\"."), $this->_vars->get('contact_list')), 'horde.info');
- } else {
- $student = $result;
}
return $student;
}
// Registry.
$registry = Horde_Registry::singleton();
-if (is_a(($pushed = $registry->pushApp('skoli', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('skoli', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
$conf = &$GLOBALS['conf'];
@define('SKOLI_TEMPLATES', $registry->get('templates'));
$registry = Horde_Registry::singleton();
}
-if (is_a(($pushed = $registry->pushApp('timeobjects', !defined('AUTH_HANDLER'))), 'PEAR_Error')) {
- if ($pushed->getCode() == 'permission_denied') {
+try {
+ $registry->pushApp('timeobjects', !defined('AUTH_HANDLER'));
+} catch (Horde_Exception $e) {
+ if ($e->getCode() == 'permission_denied') {
Horde::authenticationFailureRedirect();
}
- Horde::fatal($pushed, __FILE__, __LINE__, false);
+ Horde::fatal($e, __FILE__, __LINE__, false);
}
if (!defined('TIMEOBJECTS_BASE')) {