#!/usr/bin/env php */ @define('AUTH_HANDLER', true); @define('HORDE_BASE', dirname(__FILE__) . '/..'); // Do CLI checks and environment setup first. require_once HORDE_BASE . '/lib/core.php'; require_once 'Horde/CLI.php'; // Make sure no one runs this from the web. if (!Horde_CLI::runningFromCLI()) { exit("Must be run from the command line\n"); } // Load the CLI environment - make sure there's no time limit, init some // variables, etc. Horde_CLI::init(); // Include needed libraries. require_once HORDE_BASE . '/lib/base.php'; require_once 'Horde/Alarm.php'; // For kronolith too @define('KRONOLITH_BASE', HORDE_BASE . '/kronolith'); require_once KRONOLITH_BASE . '/lib/base.php'; require_once 'Horde/Cache.php'; require_once 'Horde/iCalendar.php'; // We want to always generate UTF-8 iCalendar data. NLS::setCharset('UTF-8'); $GLOBALS['conf']['log']['priority']=PEAR_LOG_DEBUG; if (array_key_exists(1,$argv)) { $user = $argv[1]; } else { print "usage: ".$argv[0]." username [cal]\n"; exit; } if (array_key_exists(2,$argv)) $calendar = $argv[2]; else $calendar = $user; // Authenticate $auth = &Auth::singleton($conf['auth']['driver']); $auth->setAuth($user, array()); Kronolith::initialize(); $share=$kronolith_shares->getShare($calendar); //print_r($share); $kronolith_driver->open($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(); echo $ics;