[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] calendar ical.php
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] calendar ical.php |
Date: |
Mon, 05 Jun 2006 12:01:37 +0000 |
CVSROOT: /cvsroot/phpgroupware
Module name: calendar
Changes by: Dave Hall <skwashd> 06/06/05 12:01:37
Modified files:
. : ical.php
Log message:
some stuff we are still working on
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/calendar/ical.php?cvsroot=phpgroupware&r1=1.5&r2=1.6
Patches:
Index: ical.php
===================================================================
RCS file: /cvsroot/phpgroupware/calendar/ical.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- ical.php 18 Nov 2005 11:48:30 -0000 1.5
+++ ical.php 5 Jun 2006 12:01:36 -0000 1.6
@@ -12,15 +12,13 @@
* option) any later version.
*
\**************************************************************************/
- /* $Id: ical.php,v 1.5 2005/11/18 11:48:30 skwashd Exp $ */
+ /* $Id: ical.php,v 1.6 2006/06/05 12:01:36 skwashd Exp $ */
/**
* NOTES:
*
- * This code is experimental - use it at your own risk
- *
* Configuration
- * Change only the following 3 lines
+ * Change only the following 6 lines
* login
* - the login you want to use for the iCal script to establish a session
* - make sure the user exists and has access to NO apps! this user just
establishes a session
@@ -33,7 +31,7 @@
* for single domains and hostname based domain detection leave as is.
*
* prev & adv
- * - change these at your own risk
+ * - how far forwards and back the ical file will list events
*
* exit; comment this line below (so it reads //exit;) to enable this
script
*
@@ -46,20 +44,20 @@
$login = 'user';
$passwd = 'changeme';
- $domain = $_SERVER['SERVER_NAME']; //'default';
+ $domain = $_SERVER['SERVER_NAME']; // if invalid it will default to the
default or first domain
- $prev = 1; // number of previous months
- $adv = 3; // number of months in advance
+ $prev = -1; // number of previous months (-1 unlimited)
+ $adv = -1; // number of months in advance (-1 unlimited)
exit;
// ** DO NOT EDIT BELOW THIS LINE ** //
- if( !( (isset($_GET['user']) && isset($_GET['pass']) ) ||
isset($_SERVER['PHP_AUTH_USER']) ) )
+ if( $_GET['mode'] != 'freebusy' && !( (isset($_GET['user']) &&
isset($_GET['pass']) ) || isset($_SERVER['PHP_AUTH_USER']) ) )
{
header('WWW-Authenticate: Basic realm="phpGW-iCal"');
header('HTTP/1.0 401 Unauthorized');
echo '<p>You must call this script using ';
list($ignore, $url) = explode('//', $_SERVER['PHP_SELF']);
- echo "'webcal://phpgw_user:address@hidden' OR
'webcal://{$url}?user=phpgw_user&pass=password'</p>";
+ echo "'[webcal|http]://phpgw_user:address@hidden' OR
'[webcal|http]://{$url}?user=phpgw_user&pass=password'</p>";
exit;
}
@set_time_limit(0);
@@ -82,21 +80,98 @@
$uid = $GLOBALS['phpgw']->accounts->name2id($login);
- $sessionid = $GLOBALS['phpgw']->session->create($login,$passwd,'text');
+ $sessionid = $GLOBALS['phpgw']->session->create($login, $passwd,
'text');
- $params = array('owner' =>
$GLOBALS['phpgw']->accounts->name2id($login));
+ $params = array('owner' =>
(int)$GLOBALS['phpgw_info']['user']['person_id']);
+ $owner = $params['owner'];
$so = createObject('calendar.socalendar', array('owner' => $uid) );
$export = createObject('calendar.boicalendar');
+ $ical_mode = (isset($_GET['mode']) && strlen($_GET['mode']) ) ?
$_GET['mode'] : 'freebusy';
+
+ switch ( $ical_mode )
+ {
+ case 'export':
+ export_events();
+ break;
+
+ case 'alarms':
+ list_alarms();
+ break;
+
+ case 'freebusy':
+ default:
+ //do nothing for now!
+ }
+
+ $start['d'] = $start['m'] = $start['y'] = 0;
+ if ( $prev <> -1 )
+ {
list($start['d'], $start['m'], $start['y']) = explode('-',
date('d-n-Y', strtotime("-$prev months")));
+ }
+
+ $end['d'] = $end['m'] = $end['y'] = 0;
+ if ( $adv <> -1 )
+ {
list($end['d'], $end['m'], $end['y']) = explode('-', date('d-n-Y',
strtotime("+$adv months")));
+ }
+
$ids = $so->list_events($start['y'], $start['m'], $start['d'],
$end['y'], $end['m'], $end['d']);
+ if ( strtoupper($_SERVER['REQUEST_METHOD']) == 'PUT' )
+ {
+ $putdata = fopen("php://input", "r");
+ $cal_data = "";
+
+ while ($data = fread($putdata, 1024))
+ {
+ $cal_data .= $data;
+ }
+ fclose($putdata);
+
+ $mime_msg = explode("\n",$cal_data);
+ $export->import($mime_msg);
+ }
+ else
+ {
$browser = createObject('phpgwapi.browser');
$browser->content_header($login . '.ics','text/calendar');
- echo $export->export( array('l_event_id' => $ids) );
+ if(isset($_GET['mode']) && $_GET['mode'] == 'alarm')
+ {
+ if(isset($_GET['time']))
+ {
+ $minutes = $_GET['time'];
+ }
+ else
+ {
+ $minutes = 60;
+ }
+
+ // set start list to be now
+ list($start['d'], $start['m'], $start['y']) =
explode('-', date('d-n-Y', strtotime("now")));
+
+ // set end list to be + num minutes, 60 by default
+ // this has granularity of days, use something else
+ list($end['d'], $end['m'], $end['y']) = explode('-',
date('d-n-Y', strtotime("+".$minutes."minutes")));
+
+ //$so->cal->debug=true
+ // $so->list_events is not returning the correct
events, uid is wrong
+ $ids = $so->list_events($start['y'], $start['m'],
$start['d'], $end['y'], $end['m'], $end['d'], $owner );
+
+ // find the appropriate events that have alarms
+ echo $export->export( array('l_event_id' => $ids,
'alarms_only' => true, 'minutes' => $minutes) );
+ }
+ else
+ {
+ list($start['d'], $start['m'], $start['y']) =
explode('-', date('d-n-Y', strtotime("-$prev months")));
+ list($end['d'], $end['m'], $end['y']) = explode('-',
date('d-n-Y', strtotime("+$adv months")));
+ $ids = $so->list_events($start['y'], $start['m'],
$start['d'], $end['y'], $end['m'], $end['d']);
+
+ echo $export->export( array('l_event_id' => $ids) );
+ }
+ }
@$GLOBALS['phpgw']->session->destroy($sessionid,
$GLOBALS['phpgw']->session->kp3);
?>
- [Phpgroupware-cvs] calendar ical.php,
Dave Hall <=