gunnar: server/patches/horde-webmail/1.2.0/tg t_kronolith_HK_GW_AnonymousiCalDownload.diff, NONE, 1.1.2.1 series, 1.5.2.3.2.2, 1.5.2.3.2.3
cvs at kolab.org
cvs at kolab.org
Thu May 28 16:26:38 CEST 2009
Author: gunnar
Update of /kolabrepository/server/patches/horde-webmail/1.2.0/tg
In directory doto:/tmp/cvs-serv16622/patches/horde-webmail/1.2.0/tg
Modified Files:
Tag: suc_branch
series
Added Files:
Tag: suc_branch
t_kronolith_HK_GW_AnonymousiCalDownload.diff
Log Message:
Added functionality for anonymous
ics (iCal data) download.
--- NEW FILE: t_kronolith_HK_GW_AnonymousiCalDownload.diff ---
From: Gunnar Wrobel <p at rdus.de>
Subject: [PATCH] t/kronolith/HK/GW/AnonymousiCalDownload
This patch allows anonymous access via kronolith/ics_kolab.php by
using a proxy user that needs to be given access to user calendars
that should be exported anonymously.
STATUS: HACK
Signed-off-by: Gunnar Wrobel <p at rdus.de>
---
horde-webmail/config/kolab.php | 4 ++
horde-webmail/kronolith/ics_kolab.php | 95 +++++++++++++++++++++++++++++++++
2 files changed, 99 insertions(+), 0 deletions(-)
diff --git a/horde-webmail/config/kolab.php b/horde-webmail/config/kolab.php
index ed41da4..118788a 100644
--- a/horde-webmail/config/kolab.php
+++ b/horde-webmail/config/kolab.php
@@ -35,6 +35,10 @@ $conf['kolab']['imap']['server'] = 'localhost';
/* Primary mail domain of your Kolab server */
$conf['kolab']['imap']['maildomain'] = 'example.com';
+/* Credentials for a proxy user to allow quasi anonymous ICS access via kronolith/ics_kolab.php */
+//$conf['ics']['default_user'] = '';
+//$conf['ics']['default_pass'] = '';
+
if (file_exists(dirname(__FILE__) . '/kolab.local.php')) {
require(dirname(__FILE__) . '/kolab.local.php');
}
diff --git a/horde-webmail/kronolith/ics_kolab.php b/horde-webmail/kronolith/ics_kolab.php
new file mode 100644
index 0000000..bb26d64
--- /dev/null
+++ b/horde-webmail/kronolith/ics_kolab.php
@@ -0,0 +1,95 @@
+<?php
+/**
+ * $Horde: kronolith/ics.php,v 1.5.2.10 2008/01/10 16:16:49 jan Exp $
+ *
+ * Copyright 1999-2008 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Chuck Hagenbuch <chuck at horde.org>
+ */
+
+ at define('AUTH_HANDLER', true);
+ at define('HORDE_BASE', dirname(__FILE__) . '/..');
+require_once HORDE_BASE . '/lib/base.php';
+
+// We want to always generate UTF-8 iCalendar data.
+NLS::setCharset('UTF-8');
+
+// Determine which calendar to export.
+$calendar = Util::getFormData('c');
+if (empty($calendar) && !empty($_SERVER['PATH_INFO'])) {
+ $calendar = basename($_SERVER['PATH_INFO']);
+}
+
+// Authenticate.
+$auth = &Auth::singleton($conf['auth']['driver']);
+if (!isset($_SERVER['PHP_AUTH_USER'])) {
+ if (isset($conf['ics']['default_user'])
+ && isset($conf['ics']['default_pass'])) {
+ $user = $conf['ics']['default_user'];
+ $pass = $conf['ics']['default_pass'];
+ }
+} else {
+ $user = $_SERVER['PHP_AUTH_USER'];
+ $pass = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;
+}
+
+if (!isset($user) || !$auth->authenticate($user, array('password' => $pass))) {
+ header('WWW-Authenticate: Basic realm="Kronolith iCalendar Interface"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo '401 Unauthorized';
+ exit;
+}
+
+ at define('KRONOLITH_BASE', dirname(__FILE__));
+require_once KRONOLITH_BASE . '/lib/base.php';
+require_once 'Horde/Cache.php';
+require_once 'Horde/iCalendar.php';
+
+$share = $kronolith_shares->getShare($calendar);
+if (is_a($share, 'PEAR_Error')) {
+ header('HTTP/1.0 400 Bad Request');
+ echo '400 Bad Request';
+ exit;
+}
+
+if (!$share->hasPermission(Auth::getAuth(), PERMS_READ)) {
+ header('WWW-Authenticate: Basic realm="Kronolith iCalendar Interface"');
+ header('HTTP/1.0 401 Unauthorized');
+ echo '401 Unauthorized';
+ exit;
+}
+
+$cache = &Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
+$key = 'kronolith.ics.' . $calendar;
+
+$ics = $cache->get($key, 360);
+if (!$ics) {
+ $kronolith_driver->open(urlencode($calendar));
+ $events = $kronolith_driver->listEvents();
+
+ $iCal = new Horde_iCalendar();
+ $iCal->setAttribute('X-WR-CALNAME', String::convertCharset($share->get('name'), NLS::getCharset(), 'utf-8'));
+
+ foreach ($events as $id) {
+ $event = &$kronolith_driver->getEvent($id);
+ if (is_a($event, 'PEAR_Error')) {
+ continue;
+ }
+ $iCal->addComponent($event->toiCalendar($iCal));
+ }
+
+ $ics = $iCal->exportvCalendar();
+ $cache->set($key, $ics);
+}
+
+$browser->downloadHeaders($calendar . '.ics',
+ 'text/calendar; charset=' . NLS::getCharset(),
+ true,
+ strlen($ics));
+echo $ics;
+
+Auth::clearAuth();
+ at session_destroy();
--
tg: (b5749f0..) t/kronolith/HK/GW/AnonymousiCalDownload (depends on: t/dimp/H/GW/AclView)
--
TOPGIT patch commit log
=======================
commit 0df1aefd621efbe8a2d7e306fbc79dace5760280
Author: Gunnar Wrobel <p at rdus.de>
Date: Thu May 28 12:42:44 2009 +0200
First version of the anonymous ics download patch.
Index: series
===================================================================
RCS file: /kolabrepository/server/patches/horde-webmail/1.2.0/tg/Attic/series,v
retrieving revision 1.5.2.3.2.2
retrieving revision 1.5.2.3.2.3
diff -u -d -r1.5.2.3.2.2 -r1.5.2.3.2.3
--- series 23 Apr 2009 12:05:10 -0000 1.5.2.3.2.2
+++ series 28 May 2009 14:26:36 -0000 1.5.2.3.2.3
@@ -70,3 +70,4 @@
t_Kolab__Format_HK_GW_HandleEmptyXmlParserReturn.diff -p1
t_pear_HK_GW_AddNetLDAP2.diff -p1
t_Kolab__Server_HK_GW_MappableAttributes.diff -p1
+t_kronolith_HK_GW_AnonymousiCalDownload.diff -p1
More information about the commits
mailing list