Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1720864
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
88 KB
Subscribers
None
View Options
diff --git a/action/ajax.php b/action/ajax.php
--- a/action/ajax.php
+++ b/action/ajax.php
@@ -1,163 +1,164 @@
<?php
/**
* DokuWiki DAVCal PlugIn - Ajax component
*/
if(!defined('DOKU_INC')) die();
class action_plugin_davcal_ajax extends DokuWiki_Action_Plugin {
/**
* @var helper_plugin_davcal
*/
private $hlp = null;
function __construct() {
$this->hlp =& plugin_load('helper','davcal');
}
function register(Doku_Event_Handler $controller) {
$controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown');
}
function handle_ajax_call_unknown(&$event, $param) {
if($event->data != 'plugin_davcal') return;
$event->preventDefault();
$event->stopPropagation();
global $INPUT;
$action = trim($INPUT->post->str('action'));
$id = trim($INPUT->post->str('id'));
$page = trim($INPUT->post->str('page'));
$params = $INPUT->post->arr('params');
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
$user = $_SERVER['REMOTE_USER'];
else
$user = null;
$write = false;
$multi = false;
$data = array();
$data['result'] = false;
$data['html'] = $this->getLang('unknown_error');
// Check if we have access to the calendar ($id is given by parameters,
// that's not necessarily the page we come from)
$acl = auth_quickaclcheck($id);
if($acl > AUTH_READ)
{
$write = true;
}
// Retrieve the calendar pages based on the meta data
$calendarPages = $this->hlp->getCalendarPagesByMeta($page);
if($calendarPages === false)
{
$calendarPages = array($page);
}
if(count($calendarPages) > 1)
$multi = true;
// Parse the requested action
switch($action)
{
// Add a new Event
case 'newEvent':
if($write)
{
$data['result'] = true;
$data['html'] = $this->getLang('event_added');
$this->hlp->addCalendarEntryToCalendarForPage($id, $user, $params);
}
else
{
$data['result'] = false;
$data['html'] = $this->getLang('no_permission');
}
break;
// Retrieve existing Events
case 'getEvents':
$startDate = $INPUT->post->str('start');
$endDate = $INPUT->post->str('end');
$timezone = $INPUT->post->str('timezone');
$data = array();
foreach($calendarPages as $calPage)
{
$data = array_merge($data, $this->hlp->getEventsWithinDateRange($calPage,
$user, $startDate, $endDate, $timezone));
}
break;
// Edit an event
case 'editEvent':
if($write)
{
$data['result'] = true;
$data['html'] = $this->getLang('event_edited');
$this->hlp->editCalendarEntryForPage($id, $user, $params);
}
else
{
$data['result'] = false;
$data['html'] = $this->getLang('no_permission');
}
break;
// Delete an Event
case 'deleteEvent':
if($write)
{
$data['result'] = true;
$data['html'] = $this->getLang('event_deleted');
$this->hlp->deleteCalendarEntryForPage($id, $params);
}
else
{
$data['result'] = false;
$data['html'] = $this->getLang('no_permission');
}
break;
// Get personal settings
case 'getSettings':
$data['result'] = true;
$data['settings'] = $this->hlp->getPersonalSettings($user);
$data['settings']['multi'] = $multi;
$data['settings']['calids'] = $this->hlp->getCalendarMapForIDs($calendarPages);
$data['settings']['readonly'] = !$write;
$data['settings']['syncurl'] = $this->hlp->getSyncUrlForPage($page, $user);
$data['settings']['privateurl'] = $this->hlp->getPrivateURLForPage($page);
$data['settings']['meta'] = $this->hlp->getCalendarMetaForPage($page);
break;
// Save personal settings
case 'saveSettings':
$settings = array();
$settings['weeknumbers'] = $params['weeknumbers'];
$settings['timezone'] = $params['timezone'];
$settings['workweek'] = $params['workweek'];
$settings['monday'] = $params['monday'];
+ $settings['timeformat'] = $params['timeformat'];
if($this->hlp->savePersonalSettings($settings, $user))
{
$data['result'] = true;
$data['html'] = $this->getLang('settings_saved');
}
else
{
$data['result'] = false;
$data['html'] = $this->getLang('error_saving');
}
break;
}
// If we are still here, JSON output is requested
//json library of DokuWiki
require_once DOKU_INC . 'inc/JSON.php';
$json = new JSON();
//set content type
header('Content-Type: application/json');
echo $json->encode($data);
}
}
\ No newline at end of file
diff --git a/conf/default.php b/conf/default.php
--- a/conf/default.php
+++ b/conf/default.php
@@ -1,14 +1,15 @@
<?php
/**
* Default settings for the davcal plugin
*
* @author Andreas Boehler <dev@aboehler.at>
*/
$conf['hide_settings'] = 0;
$conf['disable_ics'] = 1;
$conf['disable_sync'] = 1;
$conf['monday'] = 0;
$conf['timezone'] = 'local';
$conf['workweek'] = 0;
$conf['weeknumbers'] = 0;
+$conf['timeformat'] = 'lang';
diff --git a/conf/metadata.php b/conf/metadata.php
--- a/conf/metadata.php
+++ b/conf/metadata.php
@@ -1,15 +1,16 @@
<?php
/**
* Options for the datapopup plugin
*
* @author Andreas Boehler <dev@aboehler.at>
*/
$meta['hide_settings'] = array('onoff');
$meta['disable_sync'] = array('onoff');
$meta['disable_ics'] = array('onoff');
$meta['monday'] = array('onoff');
$meta['timezone'] = array('string');
+$meta['timeformat'] = array('multichoice', '_choices' => array('lang', '24h', '12h'));
$meta['workweek'] = array('onoff');
$meta['weeknumbers'] = array('onoff');
diff --git a/helper.php b/helper.php
--- a/helper.php
+++ b/helper.php
@@ -1,1125 +1,1126 @@
<?php
/**
* Helper Class for the DAVCal plugin
* This helper does the actual work.
*
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
class helper_plugin_davcal extends DokuWiki_Plugin {
protected $sqlite = null;
protected $cachedValues = array();
/**
* Constructor to load the configuration and the SQLite plugin
*/
public function helper_plugin_davcal() {
$this->sqlite =& plugin_load('helper', 'sqlite');
global $conf;
if($conf['allowdebug'])
dbglog('---- DAVCAL helper.php init');
if(!$this->sqlite)
{
if($conf['allowdebug'])
dbglog('This plugin requires the sqlite plugin. Please install it.');
msg('This plugin requires the sqlite plugin. Please install it.');
return;
}
if(!$this->sqlite->init('davcal', DOKU_PLUGIN.'davcal/db/'))
{
if($conf['allowdebug'])
dbglog('Error initialising the SQLite DB for DAVCal');
return;
}
}
/**
* Retrieve meta data for a given page
*
* @param string $id optional The page ID
* @return array The metadata
*/
private function getMeta($id = null) {
global $ID;
global $INFO;
if ($id === null) $id = $ID;
if($ID === $id && $INFO['meta']) {
$meta = $INFO['meta'];
} else {
$meta = p_get_metadata($id);
}
return $meta;
}
/**
* Retrieve the meta data for a given page
*
* @param string $id optional The page ID
* @return array with meta data
*/
public function getCalendarMetaForPage($id = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
$meta = $this->getMeta($id);
if(isset($meta['plugin_davcal']))
return $meta['plugin_davcal'];
else
return array();
}
/**
* Get all calendar pages used by a given page
* based on the stored metadata
*
* @param string $id optional The page id
* @return mixed The pages as array or false
*/
public function getCalendarPagesByMeta($id = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
$meta = $this->getCalendarMetaForPage($id);
if(isset($meta['id']))
return array_keys($meta['id']);
return false;
}
/**
* Get a list of calendar names/pages/ids/colors
* for an array of page ids
*
* @param array $calendarPages The calendar pages to retrieve
* @return array The list
*/
public function getCalendarMapForIDs($calendarPages)
{
$data = array();
foreach($calendarPages as $page)
{
$calid = $this->getCalendarIdForPage($page);
if($calid !== false)
{
$settings = $this->getCalendarSettings($calid);
$name = $settings['displayname'];
$color = $settings['calendarcolor'];
$data[] = array('name' => $name, 'page' => $page, 'calid' => $calid,
'color' => $color);
}
}
return $data;
}
/**
* Get the saved calendar color for a given page.
*
* @param string $id optional The page ID
* @return mixed The color on success, otherwise false
*/
public function getCalendarColorForPage($id = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
$calid = $this->getCalendarIdForPage($id);
if($calid === false)
return false;
return $this->getCalendarColorForCalendar($calid);
}
/**
* Get the saved calendar color for a given calendar ID.
*
* @param string $id optional The calendar ID
* @return mixed The color on success, otherwise false
*/
public function getCalendarColorForCalendar($calid)
{
if(isset($this->cachedValues['calendarcolor'][$calid]))
return $this->cachedValues['calendarcolor'][$calid];
$row = $this->getCalendarSettings($calid);
if(!isset($row['calendarcolor']))
return false;
$color = $row['calendarcolor'];
$this->cachedValues['calendarcolor'][$calid] = $color;
return $color;
}
/**
* Set the calendar color for a given page.
*
* @param string $color The color definition
* @param string $id optional The page ID
* @return boolean True on success, otherwise false
*/
public function setCalendarColorForPage($color, $id = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
$calid = $this->getCalendarIdForPage($id);
if($calid === false)
return false;
$query = "UPDATE calendars SET calendarcolor=".$this->sqlite->quote_string($color).
" WHERE id=".$this->sqlite->quote_string($calid);
$res = $this->sqlite->query($query);
if($res !== false)
{
$this->cachedValues['calendarcolor'][$calid] = $color;
return true;
}
return false;
}
/**
* Set the calendar name and description for a given page with a given
* page id.
* If the calendar doesn't exist, the calendar is created!
*
* @param string $name The name of the new calendar
* @param string $description The description of the new calendar
* @param string $id (optional) The ID of the page
* @param string $userid The userid of the creating user
*
* @return boolean True on success, otherwise false.
*/
public function setCalendarNameForPage($name, $description, $id = null, $userid = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
if(is_null($userid))
{
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
{
$userid = $_SERVER['REMOTE_USER'];
}
else
{
$userid = uniqid('davcal-');
}
}
$calid = $this->getCalendarIdForPage($id);
if($calid === false)
return $this->createCalendarForPage($name, $description, $id, $userid);
$query = "UPDATE calendars SET displayname=".$this->sqlite->quote_string($name).", ".
"description=".$this->sqlite->quote_string($description)." WHERE ".
"id=".$this->sqlite->quote_string($calid);
$res = $this->sqlite->query($query);
if($res !== false)
return true;
return false;
}
/**
* Save the personal settings to the SQLite database 'calendarsettings'.
*
* @param array $settings The settings array to store
* @param string $userid (optional) The userid to store
*
* @param boolean True on success, otherwise false
*/
public function savePersonalSettings($settings, $userid = null)
{
if(is_null($userid))
{
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
{
$userid = $_SERVER['REMOTE_USER'];
}
else
{
return false;
}
}
$this->sqlite->query("BEGIN TRANSACTION");
$query = "DELETE FROM calendarsettings WHERE userid=".$this->sqlite->quote_string($userid);
$this->sqlite->query($query);
foreach($settings as $key => $value)
{
$query = "INSERT INTO calendarsettings (userid, key, value) VALUES (".
$this->sqlite->quote_string($userid).", ".
$this->sqlite->quote_string($key).", ".
$this->sqlite->quote_string($value).")";
$res = $this->sqlite->query($query);
if($res === false)
return false;
}
$this->sqlite->query("COMMIT TRANSACTION");
$this->cachedValues['settings'][$userid] = $settings;
return true;
}
/**
* Retrieve the settings array for a given user id.
* Some sane defaults are returned, currently:
*
* timezone => local
* weeknumbers => 0
* workweek => 0
*
* @param string $userid (optional) The user id to retrieve
*
* @return array The settings array
*/
public function getPersonalSettings($userid = null)
{
// Some sane default settings
$settings = array(
'timezone' => $this->getConf('timezone'),
'weeknumbers' => $this->getConf('weeknumbers'),
'workweek' => $this->getConf('workweek'),
- 'monday' => $this->getConf('monday')
+ 'monday' => $this->getConf('monday'),
+ 'timeformat' => $this->getConf('timeformat')
);
if(is_null($userid))
{
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
{
$userid = $_SERVER['REMOTE_USER'];
}
else
{
return $settings;
}
}
if(isset($this->cachedValues['settings'][$userid]))
return $this->cachedValues['settings'][$userid];
$query = "SELECT key, value FROM calendarsettings WHERE userid=".$this->sqlite->quote_string($userid);
$res = $this->sqlite->query($query);
$arr = $this->sqlite->res2arr($res);
foreach($arr as $row)
{
$settings[$row['key']] = $row['value'];
}
$this->cachedValues['settings'][$userid] = $settings;
return $settings;
}
/**
* Retrieve the calendar ID based on a page ID from the SQLite table
* 'pagetocalendarmapping'.
*
* @param string $id (optional) The page ID to retrieve the corresponding calendar
*
* @return mixed the ID on success, otherwise false
*/
public function getCalendarIdForPage($id = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
if(isset($this->cachedValues['calid'][$id]))
return $this->cachedValues['calid'][$id];
$query = "SELECT calid FROM pagetocalendarmapping WHERE page=".$this->sqlite->quote_string($id);
$res = $this->sqlite->query($query);
$row = $this->sqlite->res2row($res);
if(isset($row['calid']))
{
$calid = $row['calid'];
$this->cachedValues['calid'] = $calid;
return $calid;
}
return false;
}
/**
* Retrieve the complete calendar id to page mapping.
* This is necessary to be able to retrieve a list of
* calendars for a given user and check the access rights.
*
* @return array The mapping array
*/
public function getCalendarIdToPageMapping()
{
$query = "SELECT calid, page FROM pagetocalendarmapping";
$res = $this->sqlite->query($query);
$arr = $this->sqlite->res2arr($res);
return $arr;
}
/**
* Retrieve all calendar IDs a given user has access to.
* The user is specified by the principalUri, so the
* user name is actually split from the URI component.
*
* Access rights are checked against DokuWiki's ACL
* and applied accordingly.
*
* @param string $principalUri The principal URI to work on
*
* @return array An associative array of calendar IDs
*/
public function getCalendarIdsForUser($principalUri)
{
global $auth;
$user = explode('/', $principalUri);
$user = end($user);
$mapping = $this->getCalendarIdToPageMapping();
$calids = array();
$ud = $auth->getUserData($user);
$groups = $ud['grps'];
foreach($mapping as $row)
{
$id = $row['calid'];
$page = $row['page'];
$acl = auth_aclcheck($page, $user, $groups);
if($acl >= AUTH_READ)
{
$write = $acl > AUTH_READ;
$calids[$id] = array('readonly' => !$write);
}
}
return $calids;
}
/**
* Create a new calendar for a given page ID and set name and description
* accordingly. Also update the pagetocalendarmapping table on success.
*
* @param string $name The calendar's name
* @param string $description The calendar's description
* @param string $id (optional) The page ID to work on
* @param string $userid (optional) The user ID that created the calendar
*
* @return boolean True on success, otherwise false
*/
public function createCalendarForPage($name, $description, $id = null, $userid = null)
{
if(is_null($id))
{
global $ID;
$id = $ID;
}
if(is_null($userid))
{
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
{
$userid = $_SERVER['REMOTE_USER'];
}
else
{
$userid = uniqid('davcal-');
}
}
$values = array('principals/'.$userid,
$name,
str_replace(array('/', ' ', ':'), '_', $id),
$description,
'VEVENT,VTODO',
0,
1);
$query = "INSERT INTO calendars (principaluri, displayname, uri, description, components, transparent, synctoken) VALUES (".$this->sqlite->quote_and_join($values, ',').");";
$res = $this->sqlite->query($query);
if($res === false)
return false;
// Get the new calendar ID
$query = "SELECT id FROM calendars WHERE principaluri=".$this->sqlite->quote_string($values[0])." AND ".
"displayname=".$this->sqlite->quote_string($values[1])." AND ".
"uri=".$this->sqlite->quote_string($values[2])." AND ".
"description=".$this->sqlite->quote_string($values[3]);
$res = $this->sqlite->query($query);
$row = $this->sqlite->res2row($res);
// Update the pagetocalendarmapping table with the new calendar ID
if(isset($row['id']))
{
$values = array($id, $row['id']);
$query = "INSERT INTO pagetocalendarmapping (page, calid) VALUES (".$this->sqlite->quote_and_join($values, ',').")";
$res = $this->sqlite->query($query);
return ($res !== false);
}
return false;
}
/**
* Add a new iCal entry for a given page, i.e. a given calendar.
*
* The parameter array needs to contain
* detectedtz => The timezone as detected by the browser
* currenttz => The timezone in use by the calendar
* eventfrom => The event's start date
* eventfromtime => The event's start time
* eventto => The event's end date
* eventtotime => The event's end time
* eventname => The event's name
* eventdescription => The event's description
*
* @param string $id The page ID to work on
* @param string $user The user who created the calendar
* @param string $params A parameter array with values to create
*
* @return boolean True on success, otherwise false
*/
public function addCalendarEntryToCalendarForPage($id, $user, $params)
{
if($params['currenttz'] !== '' && $params['currenttz'] !== 'local')
$timezone = new \DateTimeZone($params['currenttz']);
elseif($params['currenttz'] === 'local')
$timezone = new \DateTimeZone($params['detectedtz']);
else
$timezone = new \DateTimeZone('UTC');
// Retrieve dates from settings
$startDate = explode('-', $params['eventfrom']);
$startTime = explode(':', $params['eventfromtime']);
$endDate = explode('-', $params['eventto']);
$endTime = explode(':', $params['eventtotime']);
// Load SabreDAV
require_once(DOKU_PLUGIN.'davcal/vendor/autoload.php');
$vcalendar = new \Sabre\VObject\Component\VCalendar();
// Add VCalendar, UID and Event Name
$event = $vcalendar->add('VEVENT');
$uuid = \Sabre\VObject\UUIDUtil::getUUID();
$event->add('UID', $uuid);
$event->summary = $params['eventname'];
// Add a description if requested
$description = $params['eventdescription'];
if($description !== '')
$event->add('DESCRIPTION', $description);
// Add attachments
$attachments = $params['attachments'];
if(!is_null($attachments))
foreach($attachments as $attachment)
$event->add('ATTACH', $attachment);
// Create a timestamp for last modified, created and dtstamp values in UTC
$dtStamp = new \DateTime(null, new \DateTimeZone('UTC'));
$event->add('DTSTAMP', $dtStamp);
$event->add('CREATED', $dtStamp);
$event->add('LAST-MODIFIED', $dtStamp);
// Adjust the start date, based on the given timezone information
$dtStart = new \DateTime();
$dtStart->setTimezone($timezone);
$dtStart->setDate(intval($startDate[0]), intval($startDate[1]), intval($startDate[2]));
// Only add the time values if it's not an allday event
if($params['allday'] != '1')
$dtStart->setTime(intval($startTime[0]), intval($startTime[1]), 0);
// Adjust the end date, based on the given timezone information
$dtEnd = new \DateTime();
$dtEnd->setTimezone($timezone);
$dtEnd->setDate(intval($endDate[0]), intval($endDate[1]), intval($endDate[2]));
// Only add the time values if it's not an allday event
if($params['allday'] != '1')
$dtEnd->setTime(intval($endTime[0]), intval($endTime[1]), 0);
// According to the VCal spec, we need to add a whole day here
if($params['allday'] == '1')
$dtEnd->add(new \DateInterval('P1D'));
// Really add Start and End events
$dtStartEv = $event->add('DTSTART', $dtStart);
$dtEndEv = $event->add('DTEND', $dtEnd);
// Adjust the DATE format for allday events
if($params['allday'] == '1')
{
$dtStartEv['VALUE'] = 'DATE';
$dtEndEv['VALUE'] = 'DATE';
}
// Actually add the values to the database
$calid = $this->getCalendarIdForPage($id);
$uri = uniqid('dokuwiki-').'.ics';
$now = new DateTime();
$eventStr = $vcalendar->serialize();
$values = array($calid,
$uri,
$eventStr,
$now->getTimestamp(),
'VEVENT',
$event->DTSTART->getDateTime()->getTimeStamp(),
$event->DTEND->getDateTime()->getTimeStamp(),
strlen($eventStr),
md5($eventStr),
$uuid
);
$query = "INSERT INTO calendarobjects (calendarid, uri, calendardata, lastmodified, componenttype, firstoccurence, lastoccurence, size, etag, uid) VALUES (".$this->sqlite->quote_and_join($values, ',').")";
$res = $this->sqlite->query($query);
// If successfully, update the sync token database
if($res !== false)
{
$this->updateSyncTokenLog($calid, $uri, 'added');
return true;
}
return false;
}
/**
* Retrieve the calendar settings of a given calendar id
*
* @param string $calid The calendar ID
*
* @return array The calendar settings array
*/
public function getCalendarSettings($calid)
{
$query = "SELECT principaluri, calendarcolor, displayname, uri, description, components, transparent, synctoken FROM calendars WHERE id=".$this->sqlite->quote_string($calid);
$res = $this->sqlite->query($query);
$row = $this->sqlite->res2row($res);
return $row;
}
/**
* Retrieve all events that are within a given date range,
* based on the timezone setting.
*
* There is also support for retrieving recurring events,
* using Sabre's VObject Iterator. Recurring events are represented
* as individual calendar entries with the same UID.
*
* @param string $id The page ID to work with
* @param string $user The user ID to work with
* @param string $startDate The start date as a string
* @param string $endDate The end date as a string
*
* @return array An array containing the calendar entries.
*/
public function getEventsWithinDateRange($id, $user, $startDate, $endDate, $timezone)
{
if($timezone !== '' && $timezone !== 'local')
$timezone = new \DateTimeZone($timezone);
else
$timezone = new \DateTimeZone('UTC');
$data = array();
// Load SabreDAV
require_once(DOKU_PLUGIN.'davcal/vendor/autoload.php');
$calid = $this->getCalendarIdForPage($id);
$color = $this->getCalendarColorForCalendar($calid);
$startTs = new \DateTime($startDate);
$endTs = new \DateTime($endDate);
// Retrieve matching calendar objects
$query = "SELECT calendardata, componenttype, uid FROM calendarobjects WHERE calendarid=".
$this->sqlite->quote_string($calid)." AND firstoccurence < ".
$this->sqlite->quote_string($endTs->getTimestamp())." AND lastoccurence > ".
$this->sqlite->quote_string($startTs->getTimestamp());
$res = $this->sqlite->query($query);
$arr = $this->sqlite->res2arr($res);
// Parse individual calendar entries
foreach($arr as $row)
{
if(isset($row['calendardata']))
{
$entry = array();
$vcal = \Sabre\VObject\Reader::read($row['calendardata']);
$recurrence = $vcal->VEVENT->RRULE;
// If it is a recurring event, pass it through Sabre's EventIterator
if($recurrence != null)
{
$rEvents = new \Sabre\VObject\Recur\EventIterator(array($vcal->VEVENT));
$rEvents->rewind();
$done = false;
while($rEvents->valid() && !$done)
{
$event = $rEvents->getEventObject();
// If we are after the given time range, exit
if(($rEvents->getDtStart()->getTimestamp() > $endTs->getTimestamp()) &&
($rEvents->getDtEnd()->getTimestamp() > $endTs->getTimestamp()))
$done = true;
// If we are before the given time range, continue
if($rEvents->getDtEnd()->getTimestamp() < $startTs->getTimestamp())
{
$rEvents->next();
continue;
}
// If we are within the given time range, parse the event
$data[] = $this->convertIcalDataToEntry($event, $id, $timezone, $row['uid'], $color, true);
$rEvents->next();
}
}
else
$data[] = $this->convertIcalDataToEntry($vcal->VEVENT, $id, $timezone, $row['uid'], $color);
}
}
return $data;
}
/**
* Helper function that parses the iCal data of a VEVENT to a calendar entry.
*
* @param \Sabre\VObject\VEvent $event The event to parse
* @param \DateTimeZone $timezone The timezone object
* @param string $uid The entry's UID
* @param boolean $recurring (optional) Set to true to define a recurring event
*
* @return array The parse calendar entry
*/
private function convertIcalDataToEntry($event, $page, $timezone, $uid, $color, $recurring = false)
{
$entry = array();
$start = $event->DTSTART;
// Parse only if the start date/time is present
if($start !== null)
{
$dtStart = $start->getDateTime();
$dtStart->setTimezone($timezone);
$entry['start'] = $dtStart->format(\DateTime::ATOM);
if($start['VALUE'] == 'DATE')
$entry['allDay'] = true;
else
$entry['allDay'] = false;
}
$end = $event->DTEND;
// Parse onlyl if the end date/time is present
if($end !== null)
{
$dtEnd = $end->getDateTime();
$dtEnd->setTimezone($timezone);
$entry['end'] = $dtEnd->format(\DateTime::ATOM);
}
$description = $event->DESCRIPTION;
if($description !== null)
$entry['description'] = (string)$description;
else
$entry['description'] = '';
$attachments = $event->ATTACH;
if($attachments !== null)
{
$entry['attachments'] = array();
foreach($attachments as $attachment)
$entry['attachments'][] = (string)$attachment;
}
$entry['title'] = (string)$event->summary;
$entry['id'] = $uid;
$entry['page'] = $page;
$entry['color'] = $color;
$entry['recurring'] = $recurring;
return $entry;
}
/**
* Retrieve an event by its UID
*
* @param string $uid The event's UID
*
* @return mixed The table row with the given event
*/
public function getEventWithUid($uid)
{
$query = "SELECT calendardata, calendarid, componenttype, uri FROM calendarobjects WHERE uid=".
$this->sqlite->quote_string($uid);
$res = $this->sqlite->query($query);
$row = $this->sqlite->res2row($res);
return $row;
}
/**
* Retrieve all calendar events for a given calendar ID
*
* @param string $calid The calendar's ID
*
* @return array An array containing all calendar data
*/
public function getAllCalendarEvents($calid)
{
$query = "SELECT calendardata, uid, componenttype, uri FROM calendarobjects WHERE calendarid=".
$this->sqlite->quote_string($calid);
$res = $this->sqlite->query($query);
$arr = $this->sqlite->res2arr($res);
return $arr;
}
/**
* Edit a calendar entry for a page, given by its parameters.
* The params array has the same format as @see addCalendarEntryForPage
*
* @param string $id The page's ID to work on
* @param string $user The user's ID to work on
* @param array $params The parameter array for the edited calendar event
*
* @return boolean True on success, otherwise false
*/
public function editCalendarEntryForPage($id, $user, $params)
{
if($params['currenttz'] !== '' && $params['currenttz'] !== 'local')
$timezone = new \DateTimeZone($params['currenttz']);
elseif($params['currenttz'] === 'local')
$timezone = new \DateTimeZone($params['detectedtz']);
else
$timezone = new \DateTimeZone('UTC');
// Parse dates
$startDate = explode('-', $params['eventfrom']);
$startTime = explode(':', $params['eventfromtime']);
$endDate = explode('-', $params['eventto']);
$endTime = explode(':', $params['eventtotime']);
// Retrieve the existing event based on the UID
$uid = $params['uid'];
$event = $this->getEventWithUid($uid);
// Load SabreDAV
require_once(DOKU_PLUGIN.'davcal/vendor/autoload.php');
if(!isset($event['calendardata']))
return false;
$uri = $event['uri'];
$calid = $event['calendarid'];
// Parse the existing event
$vcal = \Sabre\VObject\Reader::read($event['calendardata']);
$vevent = $vcal->VEVENT;
// Set the new event values
$vevent->summary = $params['eventname'];
$dtStamp = new \DateTime(null, new \DateTimeZone('UTC'));
$description = $params['eventdescription'];
// Remove existing timestamps to overwrite them
$vevent->remove('DESCRIPTION');
$vevent->remove('DTSTAMP');
$vevent->remove('LAST-MODIFIED');
$vevent->remove('ATTACH');
// Add new time stamps and description
$vevent->add('DTSTAMP', $dtStamp);
$vevent->add('LAST-MODIFIED', $dtStamp);
if($description !== '')
$vevent->add('DESCRIPTION', $description);
// Add attachments
$attachments = $params['attachments'];
if(!is_null($attachments))
foreach($attachments as $attachment)
$vevent->add('ATTACH', $attachment);
// Setup DTSTART
$dtStart = new \DateTime();
$dtStart->setTimezone($timezone);
$dtStart->setDate(intval($startDate[0]), intval($startDate[1]), intval($startDate[2]));
if($params['allday'] != '1')
$dtStart->setTime(intval($startTime[0]), intval($startTime[1]), 0);
// Setup DTEND
$dtEnd = new \DateTime();
$dtEnd->setTimezone($timezone);
$dtEnd->setDate(intval($endDate[0]), intval($endDate[1]), intval($endDate[2]));
if($params['allday'] != '1')
$dtEnd->setTime(intval($endTime[0]), intval($endTime[1]), 0);
// According to the VCal spec, we need to add a whole day here
if($params['allday'] == '1')
$dtEnd->add(new \DateInterval('P1D'));
$vevent->remove('DTSTART');
$vevent->remove('DTEND');
$dtStartEv = $vevent->add('DTSTART', $dtStart);
$dtEndEv = $vevent->add('DTEND', $dtEnd);
// Remove the time for allday events
if($params['allday'] == '1')
{
$dtStartEv['VALUE'] = 'DATE';
$dtEndEv['VALUE'] = 'DATE';
}
$now = new DateTime();
$eventStr = $vcal->serialize();
// Actually write to the database
$query = "UPDATE calendarobjects SET calendardata=".$this->sqlite->quote_string($eventStr).
", lastmodified=".$this->sqlite->quote_string($now->getTimestamp()).
", firstoccurence=".$this->sqlite->quote_string($dtStart->getTimestamp()).
", lastoccurence=".$this->sqlite->quote_string($dtEnd->getTimestamp()).
", size=".strlen($eventStr).
", etag=".$this->sqlite->quote_string(md5($eventStr)).
" WHERE uid=".$this->sqlite->quote_string($uid);
$res = $this->sqlite->query($query);
if($res !== false)
{
$this->updateSyncTokenLog($calid, $uri, 'modified');
return true;
}
return false;
}
/**
* Delete a calendar entry for a given page. Actually, the event is removed
* based on the entry's UID, so that page ID is no used.
*
* @param string $id The page's ID (unused)
* @param array $params The parameter array to work with
*
* @return boolean True
*/
public function deleteCalendarEntryForPage($id, $params)
{
$uid = $params['uid'];
$event = $this->getEventWithUid($uid);
$calid = $event['calendarid'];
$uri = $event['uri'];
$query = "DELETE FROM calendarobjects WHERE uid=".$this->sqlite->quote_string($uid);
$res = $this->sqlite->query($query);
if($res !== false)
{
$this->updateSyncTokenLog($calid, $uri, 'deleted');
}
return true;
}
/**
* Retrieve the current sync token for a calendar
*
* @param string $calid The calendar id
*
* @return mixed The synctoken or false
*/
public function getSyncTokenForCalendar($calid)
{
$row = $this->getCalendarSettings($calid);
if(isset($row['synctoken']))
return $row['synctoken'];
return false;
}
/**
* Helper function to convert the operation name to
* an operation code as stored in the database
*
* @param string $operationName The operation name
*
* @return mixed The operation code or false
*/
public function operationNameToOperation($operationName)
{
switch($operationName)
{
case 'added':
return 1;
break;
case 'modified':
return 2;
break;
case 'deleted':
return 3;
break;
}
return false;
}
/**
* Update the sync token log based on the calendar id and the
* operation that was performed.
*
* @param string $calid The calendar ID that was modified
* @param string $uri The calendar URI that was modified
* @param string $operation The operation that was performed
*
* @return boolean True on success, otherwise false
*/
private function updateSyncTokenLog($calid, $uri, $operation)
{
$currentToken = $this->getSyncTokenForCalendar($calid);
$operationCode = $this->operationNameToOperation($operation);
if(($operationCode === false) || ($currentToken === false))
return false;
$values = array($uri,
$currentToken,
$calid,
$operationCode
);
$query = "INSERT INTO calendarchanges (uri, synctoken, calendarid, operation) VALUES(".
$this->sqlite->quote_and_join($values, ',').")";
$res = $this->sqlite->query($query);
if($res === false)
return false;
$currentToken++;
$query = "UPDATE calendars SET synctoken=".$this->sqlite->quote_string($currentToken)." WHERE id=".
$this->sqlite->quote_string($calid);
$res = $this->sqlite->query($query);
return ($res !== false);
}
/**
* Return the sync URL for a given Page, i.e. a calendar
*
* @param string $id The page's ID
* @param string $user (optional) The user's ID
*
* @return mixed The sync url or false
*/
public function getSyncUrlForPage($id, $user = null)
{
if(is_null($userid))
{
if(isset($_SERVER['REMOTE_USER']) && !is_null($_SERVER['REMOTE_USER']))
{
$userid = $_SERVER['REMOTE_USER'];
}
else
{
return false;
}
}
$calid = $this->getCalendarIdForPage($id);
if($calid === false)
return false;
$calsettings = $this->getCalendarSettings($calid);
if(!isset($calsettings['uri']))
return false;
$syncurl = DOKU_URL.'lib/plugins/davcal/calendarserver.php/calendars/'.$user.'/'.$calsettings['uri'];
return $syncurl;
}
/**
* Return the private calendar's URL for a given page
*
* @param string $id the page ID
*
* @return mixed The private URL or false
*/
public function getPrivateURLForPage($id)
{
$calid = $this->getCalendarIdForPage($id);
if($calid === false)
return false;
return $this->getPrivateURLForCalendar($calid);
}
/**
* Return the private calendar's URL for a given calendar ID
*
* @param string $calid The calendar's ID
*
* @return mixed The private URL or false
*/
public function getPrivateURLForCalendar($calid)
{
if(isset($this->cachedValues['privateurl'][$calid]))
return $this->cachedValues['privateurl'][$calid];
$query = "SELECT url FROM calendartoprivateurlmapping WHERE calid=".$this->sqlite->quote_string($calid);
$res = $this->sqlite->query($query);
$row = $this->sqlite->res2row($res);
if(!isset($row['url']))
{
$url = uniqid("dokuwiki-").".ics";
$values = array(
$url,
$calid
);
$query = "INSERT INTO calendartoprivateurlmapping (url, calid) VALUES(".
$this->sqlite->quote_and_join($values, ", ").")";
$res = $this->sqlite->query($query);
if($res === false)
return false;
}
else
{
$url = $row['url'];
}
$url = DOKU_URL.'lib/plugins/davcal/ics.php/'.$url;
$this->cachedValues['privateurl'][$calid] = $url;
return $url;
}
/**
* Retrieve the calendar ID for a given private calendar URL
*
* @param string $url The private URL
*
* @return mixed The calendar ID or false
*/
public function getCalendarForPrivateURL($url)
{
$query = "SELECT calid FROM calendartoprivateurlmapping WHERE url=".$this->sqlite->quote_string($url);
$res = $this->sqlite->query($query);
$row = $this->sqlite->res2row($res);
if(!isset($row['calid']))
return false;
return $row['calid'];
}
/**
* Return a given calendar as ICS feed, i.e. all events in one ICS file.
*
* @param string $caldi The calendar ID to retrieve
*
* @return mixed The calendar events as string or false
*/
public function getCalendarAsICSFeed($calid)
{
$calSettings = $this->getCalendarSettings($calid);
if($calSettings === false)
return false;
$events = $this->getAllCalendarEvents($calid);
if($events === false)
return false;
$out = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//DAVCal//DAVCal for DokuWiki//EN\nCALSCALE:GREGORIAN\nX-WR-CALNAME:";
$out .= $calSettings['displayname']."\n";
foreach($events as $event)
{
$out .= rtrim($event['calendardata']);
$out .= "\n";
}
$out .= "END:VCALENDAR\n";
return $out;
}
/**
* Retrieve a configuration option for the plugin
*
* @param string $key The key to query
* @return mixed The option set, null if not found
*/
public function getConfig($key)
{
return $this->getConf($key);
}
}
diff --git a/lang/de-informal/lang.php b/lang/de-informal/lang.php
--- a/lang/de-informal/lang.php
+++ b/lang/de-informal/lang.php
@@ -1,54 +1,55 @@
<?php
$lang['created_by_davcal'] = 'Erstellt von DAVCal für DokuWiki';
$lang['unknown_error'] = 'Unbekannter Fehler';
$lang['event_added'] = 'Eintrag hinzugefügt';
$lang['event_edited'] = 'Eintrag bearbeitet';
$lang['event_deleted'] = 'Eintrag entfernt';
$lang['no_permission'] = 'Du hast nicht die erforderlichen Rechte, um den Eintrag zu bearbeiten';
$lang['settings'] = 'Einstellungen/Sync';
$lang['settings_saved'] = 'Einstellungen erfolgreich gespeichert';
$lang['error_saving'] = 'Fehler beim Speichern der Einstellungen.';
$lang['local_time'] = 'Lokale Zeit (Browser-basierend)';
$lang['from'] = 'Von';
$lang['to'] = 'Bis';
$lang['at'] = 'Am';
$lang['description'] = 'Beschreibung';
$lang['title'] = 'Titel';
$lang['error_timezone_not_in_list'] = 'Die angegebene Zeitzone wird von PHP nicht unterstützt';
$lang['this_calendar_uses_timezone'] = 'Dieser Kalender wird in der Zeitzone %s angezeigt.';
$lang['js']['create_new_event'] = 'Neuen Eintrag anlegen';
$lang['js']['cancel'] = 'Abbrechen';
$lang['js']['create'] = 'Anlegen';
$lang['js']['save'] = 'Speichern';
$lang['js']['settings'] = 'Einstellungen';
$lang['js']['edit'] = 'Bearbeiten';
$lang['js']['delete'] = 'Löschen';
$lang['js']['edit_event'] = 'Eintrag bearbeiten';
$lang['js']['allday'] = 'Ganzer Tag';
$lang['js']['title'] = 'Titel';
$lang['js']['from'] = 'Von';
$lang['js']['to'] = 'Bis';
$lang['js']['yes'] = 'Ja';
$lang['js']['confirmation'] = 'Bestätigung';
$lang['js']['ok'] = 'OK';
$lang['js']['info'] = 'Info';
$lang['js']['really_delete_this_event'] = 'Diesen Eintrag wirklich löschen?';
$lang['js']['timezone'] = 'Zeitzone';
$lang['js']['weeknumbers'] = 'Wochennummern';
$lang['js']['use_lang_tz'] = 'Zeitzone der Spracheinstellung verwenden';
$lang['js']['only_workweek'] = 'Zeige nur die Arbeitswoche';
$lang['js']['sync_url'] = 'CalDAV URL';
$lang['js']['error_retrieving_data'] = 'Beim Abfragen der Daten vom Kalenderserver ist ein Fehler aufgetreten.';
$lang['js']['start_date_invalid'] = 'Beginnzeit/-datum ist ungültig';
$lang['js']['end_date_invalid'] = 'Endzeit/-datum ist ungültig';
$lang['js']['end_date_before_start_date'] = 'Endzeit/-datum liegt vor Startzeit/-datum';
$lang['js']['end_date_is_same_as_start_date'] = 'Endzeit/-datum ist gleich wie Startzeit/-datum';
$lang['js']['description'] = 'Beschreibung';
$lang['js']['private_url'] = 'Private URL';
$lang['js']['recurring_cant_edit'] = 'Das Bearbeiten wiederkehrender Einträge wird derzeit nicht unterstützt';
$lang['js']['no_permission'] = 'Du hast nicht die erforderlichen Rechte, diesen Kalender zu bearbeiten';
$lang['js']['calendar'] = 'Kalender';
$lang['js']['start_monday'] = 'Die Woche beginnt am Montag';
$lang['js']['nothing_to_show'] = 'Nichts anzuzeigen';
$lang['js']['add_attachment'] = 'Link hinzufügen';
$lang['js']['attachments'] = 'Angehängte Links';
+$lang['js']['language_specific'] = 'Sprachabhängig';
diff --git a/lang/de/lang.php b/lang/de/lang.php
--- a/lang/de/lang.php
+++ b/lang/de/lang.php
@@ -1,54 +1,55 @@
<?php
$lang['created_by_davcal'] = 'Erstellt von DAVCal für DokuWiki';
$lang['unknown_error'] = 'Unbekannter Fehler';
$lang['event_added'] = 'Eintrag hinzugefügt';
$lang['event_edited'] = 'Eintrag bearbeitet';
$lang['event_deleted'] = 'Eintrag entfernt';
$lang['no_permission'] = 'Sie haben nicht die erforderlichen Rechte, um den Eintrag zu bearbeiten';
$lang['settings'] = 'Einstellungen/Sync';
$lang['settings_saved'] = 'Einstellungen erfolgreich gespeichert';
$lang['error_saving'] = 'Fehler beim Speichern der Einstellungen.';
$lang['local_time'] = 'Lokale Zeit (Browser-basierend)';
$lang['from'] = 'Von';
$lang['to'] = 'Bis';
$lang['at'] = 'Am';
$lang['description'] = 'Beschreibung';
$lang['title'] = 'Titel';
$lang['error_timezone_not_in_list'] = 'Die angegebene Zeitzone wird von PHP nicht unterstützt';
$lang['this_calendar_uses_timezone'] = 'Dieser Kalender wird in der Zeitzone %s angezeigt.';
$lang['js']['create_new_event'] = 'Neuen Eintrag anlegen';
$lang['js']['cancel'] = 'Abbrechen';
$lang['js']['create'] = 'Anlegen';
$lang['js']['save'] = 'Speichern';
$lang['js']['settings'] = 'Einstellungen';
$lang['js']['edit'] = 'Bearbeiten';
$lang['js']['delete'] = 'Löschen';
$lang['js']['edit_event'] = 'Eintrag bearbeiten';
$lang['js']['allday'] = 'Ganzer Tag';
$lang['js']['title'] = 'Titel';
$lang['js']['from'] = 'Von';
$lang['js']['to'] = 'Bis';
$lang['js']['yes'] = 'Ja';
$lang['js']['confirmation'] = 'Bestätigung';
$lang['js']['ok'] = 'OK';
$lang['js']['info'] = 'Info';
$lang['js']['really_delete_this_event'] = 'Diesen Eintrag wirklich löschen?';
$lang['js']['timezone'] = 'Zeitzone';
$lang['js']['weeknumbers'] = 'Wochennummern';
$lang['js']['use_lang_tz'] = 'Zeitzone der Spracheinstellung verwenden';
$lang['js']['only_workweek'] = 'Zeige nur die Arbeitswoche';
$lang['js']['sync_url'] = 'CalDAV URL';
$lang['js']['error_retrieving_data'] = 'Beim Abfragen der Daten vom Kalenderserver ist ein Fehler aufgetreten.';
$lang['js']['start_date_invalid'] = 'Beginnzeit/-datum ist ungültig';
$lang['js']['end_date_invalid'] = 'Endzeit/-datum ist ungültig';
$lang['js']['end_date_before_start_date'] = 'Endzeit/-datum liegt vor Startzeit/-datum';
$lang['js']['end_date_is_same_as_start_date'] = 'Endzeit/-datum ist gleich wie Startzeit/-datum';
$lang['js']['description'] = 'Beschreibung';
$lang['js']['private_url'] = 'Private URL';
$lang['js']['recurring_cant_edit'] = 'Das Bearbeiten wiederkehrender Einträge wird derzeit nicht unterstützt';
$lang['js']['no_permission'] = 'Sie haben nicht die erforderlichen Rechte, diesen Kalender zu bearbeiten';
$lang['js']['calendar'] = 'Kalender';
$lang['js']['start_monday'] = 'Die Woche beginnt am Montag';
$lang['js']['nothing_to_show'] = 'Nichts anzuzeigen';
$lang['js']['add_attachment'] = 'Link hinzufügen';
$lang['js']['attachments'] = 'Angehängte Links';
+$lang['js']['language_specific'] = 'Sprachabhängig';
diff --git a/lang/en/lang.php b/lang/en/lang.php
--- a/lang/en/lang.php
+++ b/lang/en/lang.php
@@ -1,54 +1,55 @@
<?php
$lang['created_by_davcal'] = 'Created by DAVCal for DokuWiki';
$lang['unknown_error'] = 'Unknown Error';
$lang['event_added'] = 'Event added';
$lang['event_edited'] = 'Event edited';
$lang['event_deleted'] = 'Event deleted';
$lang['no_permission'] = 'You don\'t have permission to modify this calendar';
$lang['settings'] = 'Settings/Sync';
$lang['settings_saved'] = 'Settings saved successfully';
$lang['error_saving'] = 'Error saving settings.';
$lang['local_time'] = 'Local time (Browser based)';
$lang['from'] = 'From';
$lang['to'] = 'To';
$lang['at'] = 'At';
$lang['description'] = 'Description';
$lang['title'] = 'Title';
$lang['error_timezone_not_in_list'] = 'The desired timezone is not supported by PHP!';
$lang['this_calendar_uses_timezone'] = 'This calendar is shown in the timezone %s.';
$lang['js']['create_new_event'] = 'Create new Event';
$lang['js']['cancel'] = 'Cancel';
$lang['js']['create'] = 'Create';
$lang['js']['save'] = 'Save';
$lang['js']['settings'] = 'Settings';
$lang['js']['edit'] = 'Edit';
$lang['js']['delete'] = 'Delete';
$lang['js']['edit_event'] = 'Edit Event';
$lang['js']['allday'] = 'All Day Event';
$lang['js']['title'] = 'Title';
$lang['js']['from'] = 'From';
$lang['js']['to'] = 'To';
$lang['js']['yes'] = 'Yes';
$lang['js']['confirmation'] = 'Confirmation';
$lang['js']['ok'] = 'OK';
$lang['js']['info'] = 'Info';
$lang['js']['really_delete_this_event'] = 'Really delete this event?';
$lang['js']['timezone'] = 'Timezone';
$lang['js']['weeknumbers'] = 'Week Numbers';
$lang['js']['use_lang_tz'] = 'Use Timezone from language setting';
$lang['js']['only_workweek'] = 'Show only Work Week';
$lang['js']['sync_url'] = 'CalDAV URL';
$lang['js']['error_retrieving_data'] = 'There was an error retrieving data from the calendar server.';
$lang['js']['start_date_invalid'] = 'Start date/time is invalid.';
$lang['js']['end_date_invalid'] = 'End date/time is invalid.';
$lang['js']['end_date_before_start_date'] = 'End date/time is before start date/time.';
$lang['js']['end_date_is_same_as_start_date'] = 'End date/time is equal to start date/time.';
$lang['js']['description'] = 'Description';
$lang['js']['private_url'] = 'Private URL';
$lang['js']['recurring_cant_edit'] = 'Editing recurring events is currently not supported';
$lang['js']['no_permission'] = 'You don\'t have permission to modify this calendar';
$lang['js']['calendar'] = 'Calendar';
$lang['js']['start_monday'] = 'Week starts on Monday';
$lang['js']['nothing_to_show'] = 'Nothing to show';
$lang['js']['add_attachment'] = 'Add link';
$lang['js']['attachments'] = 'Attached links';
+$lang['js']['language_specific'] = 'Language specific';
diff --git a/plugin.info.txt b/plugin.info.txt
--- a/plugin.info.txt
+++ b/plugin.info.txt
@@ -1,7 +1,7 @@
base davcal
author Andreas Boehler
email dev@aboehler.at
-date 2015-11-19
+date 2015-12-07
name Calendar PlugIn with CalDAV sharing support
desc Create one calendar per page and share/subscribe via CalDAV
url http://www.dokuwiki.org/plugin:davcal
diff --git a/script.js b/script.js
--- a/script.js
+++ b/script.js
@@ -1,774 +1,782 @@
/* DOKUWIKI:include_once fullcalendar-2.4.0/moment.js */
/* DOKUWIKI:include_once fullcalendar-2.4.0/fullcalendar.js */
/* DOKUWIKI:include_once fullcalendar-2.4.0/lang/de.js */
/* DOKUWIKI:include_once fullcalendar-2.4.0/lang/en.js */
/* DOKUWIKI:include_once fullcalendar-2.4.0/lang/nl.js */
/* DOKUWIKI:include_once datetimepicker-2.4.5/jquery.datetimepicker.js */
/* DOKUWIKI:include_once jstz.js */
/**
* Initialize the DAVCal script, attaching some event handlers and triggering
* the initial load of the fullcalendar JS
*/
jQuery(function() {
// Redefine functions for using moment.js with datetimepicker
Date.parseDate = function( input, format ){
return moment(input,format).toDate();
};
Date.prototype.dateFormat = function( format ){
return moment(this).format(format);
};
// Attach to event links
var calendarpage = jQuery('#fullCalendar').data('calendarpage');
if(!calendarpage) return;
dw_davcal__modals.page = calendarpage;
jQuery('div.fullCalendarSettings a').each(function() {
var $link = jQuery(this);
var href = $link.attr('href');
if (!href) return;
$link.click(
function(e) {
dw_davcal__modals.showSettingsDialog();
e.preventDefault();
return '';
}
);
}
);
// First, retrieve the current settings.
// Upon success, initialize fullcalendar.
var postArray = { };
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: dw_davcal__modals.page,
page: dw_davcal__modals.page,
action: 'getSettings',
params: postArray
},
function(data)
{
var result = data['result'];
if(result === true)
{
dw_davcal__modals.settings = data['settings'];
- var wknum = false;
var tz = false;
- var we = true;
- var ro = false;
- var firstday = 0;
- var detectedTz = jstz.determine().name();
- dw_davcal__modals.detectedTz = detectedTz;
- if(data['settings']['weeknumbers'] == 1)
- wknum = true;
if(data['settings']['timezone'] !== '')
tz = data['settings']['timezone'];
if(data['settings']['meta']['forcetimezone'] !== 'no')
tz = data['settings']['meta']['forcetimezone'];
- if(data['settings']['workweek'] == 1)
- we = false;
- if(data['settings']['monday'] == 1)
- firstday = 1;
- var defaultView = data['settings']['meta']['view'];
- // The current TZ value holds either the uers's selection or
- // the force timezone value
- dw_davcal__modals.currentTz = (tz === false) ? '' : tz;
- // Initialize the davcal popup
- var res = jQuery('#fullCalendar').fullCalendar({
+ var fcOptions = {
dayClick: function(date, jsEvent, view) {
dw_davcal__modals.showEditEventDialog(date, false);
},
eventClick: function(calEvent, jsEvent, view) {
dw_davcal__modals.showEditEventDialog(calEvent, true);
},
events: {
url: DOKU_BASE + 'lib/exe/ajax.php',
type: 'POST',
data: {
call: 'plugin_davcal',
action: 'getEvents',
id: dw_davcal__modals.page,
page: dw_davcal__modals.page
},
error: function() {
dw_davcal__modals.msg = LANG.plugins.davcal['error_retrieving_data'];
dw_davcal__modals.showDialog(false);
}
},
header: {
left: 'title',
center: 'today prev,next',
right: 'month,agendaWeek,agendaDay'
},
lang: JSINFO.plugin.davcal['language'],
- weekNumbers: wknum,
+ weekNumbers: (data['settings']['weeknumbers'] == 1) ? true : false,
timezone: tz,
- weekends: we,
- firstDay: firstday,
- defaultView: defaultView
- });
+ weekends: (data['settings']['workweek'] == 1) ? false : true,
+ firstDay: (data['settings']['monday'] == 1) ? 1 : 0,
+ defaultView: data['settings']['meta']['view']
+ };
+ if(data['settings']['timeformat'] !== 'lang')
+ {
+ if(data['settings']['timeformat'] == '24h')
+ {
+ fcOptions.timeFormat = 'H:mm';
+ }
+ if(data['settings']['timeformat'] == '12h')
+ {
+ fcOptions.timeFormat = 'h:mmt';
+ }
+ }
+ var detectedTz = jstz.determine().name();
+ dw_davcal__modals.detectedTz = detectedTz;
+ // The current TZ value holds either the uers's selection or
+ // the force timezone value
+ dw_davcal__modals.currentTz = (tz === false) ? '' : tz;
+ // Initialize the davcal popup
+ var res = jQuery('#fullCalendar').fullCalendar(fcOptions);
}
}
);
});
/**
* This holds all modal windows that DAVCal uses.
*/
var dw_davcal__modals = {
$editEventDialog: null,
$dialog: null,
$settingsDialog: null,
$inputDialog: null,
msg: null,
completeCb: null,
action: null,
uid: null,
settings: null,
page: null,
detectedTz: null,
currentTz: null,
/**
* Show the settings dialog
*/
// FIXME: Hide URLs for multi-calendar
showSettingsDialog : function() {
if(dw_davcal__modals.$settingsDialog)
return;
// Dialog buttons are language-dependent and defined here.
// Attach event handlers for save and cancel.
var dialogButtons = {};
if(!JSINFO.plugin.davcal['disable_settings'])
{
dialogButtons[LANG.plugins.davcal['save']] = function() {
var postArray = { };
jQuery("input[class=dw_davcal__settings], select[class=dw_davcal__settings]").each(function() {
if(jQuery(this).attr('type') == 'checkbox')
{
postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
}
else
{
postArray[jQuery(this).prop('name')] = jQuery(this).val();
}
});
jQuery('#dw_davcal__ajaxsettings').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: dw_davcal__modals.page,
page: dw_davcal__modals.page,
action: 'saveSettings',
params: postArray
},
function(data)
{
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcal__ajaxsettings').html(html);
if(result === true)
{
location.reload();
}
}
);
};
}
dialogButtons[LANG.plugins.davcal['cancel']] = function () {
dw_davcal__modals.hideSettingsDialog();
};
var settingsHtml = '<div><table>';
if(JSINFO.plugin.davcal['disable_settings'] && JSINFO.plugin.davcal['disable_sync'] && JSINFO.plugin.davcal['disable_ics'])
{
settingsHtml += LANG.plugins.davcal['nothing_to_show'];
}
if(!JSINFO.plugin.davcal['disable_settings'])
{
settingsHtml += '<tr><td>' + LANG.plugins.davcal['timezone'] + '</td><td><select name="timezone" id="dw_davcal__settings_timezone" class="dw_davcal__settings"></select></td></tr>' +
+ '<tr><td>' + LANG.plugins.davcal['timeformat'] + '</td><td><select name="timeformat" id="dw_davcal__settings_timeformat" class="dw_davcal__settings"></select></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['weeknumbers'] + '</td><td><input type="checkbox" name="weeknumbers" id="dw_davcal__settings_weeknumbers" class="dw_davcal__settings"></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['only_workweek'] + '</td><td><input type="checkbox" name="workweek" id="dw_davcal__settings_workweek" class="dw_davcal__settings"></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['start_monday'] + '</td><td><input type="checkbox" name="monday" id="dw_davcal__settings_monday" class="dw_davcal__settings"></td></tr>';
}
if(!JSINFO.plugin.davcal['disable_sync'])
{
settingsHtml += '<tr id="dw_davcal__settings_syncurl"><td>' + LANG.plugins.davcal['sync_url'] + '</td><td><input type="text" name="syncurl" readonly="readonly" id="dw_davcal__settings_syncurl" class="dw_davcal__text" value="' + dw_davcal__modals.settings['syncurl'] + '"></td></tr>';
}
if(!JSINFO.plugin.davcal['disable_ics'])
{
settingsHtml += '<tr id="dw_davcal__settings_privateurl"><td>' + LANG.plugins.davcal['private_url'] + '</td><td><input type="text" name="privateurl" readonly="readonly" id="dw_davcal__settings_privateurl" class="dw_davcal__text" value="' + dw_davcal__modals.settings['privateurl'] + '"></td></tr>';
}
settingsHtml += '</table>' +
'</div>' +
'<div id="dw_davcal__ajaxsettings"></div>';
dw_davcal__modals.$settingsDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: LANG.plugins.davcal['settings'],
resizable: true,
buttons: dialogButtons,
})
.html(
settingsHtml
)
.parent()
.attr('id','dw_davcal__settings')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__settings').position({
my: "center",
at: "center",
of: window
});
// Initialize current settings
if(!JSINFO.plugin.davcal['disable_settings'])
{
var $tzdropdown = jQuery('#dw_davcal__settings_timezone');
jQuery('#fullCalendarTimezoneList option').each(function() {
jQuery('<option />', {value: jQuery(this).val(),
text: jQuery(this).text()}).appendTo($tzdropdown);
});
+ var $tfdropdown = jQuery('#dw_davcal__settings_timeformat');
+ jQuery('<option />', {value: 'lang', text: LANG.plugins.davcal['language_specific']}).appendTo($tfdropdown);
+ jQuery('<option />', {value: '24h', text: '24h'}).appendTo($tfdropdown);
+ jQuery('<option />', {value: '12h', text: '12h'}).appendTo($tfdropdown);
+
if(dw_davcal__modals.settings)
{
+ jQuery('#dw_davcal__settings_timeformat').val(dw_davcal__modals.settings['timeformat']);
if(dw_davcal__modals.settings['timezone'] !== '')
jQuery('#dw_davcal__settings_timezone').val(dw_davcal__modals.settings['timezone']);
if(dw_davcal__modals.settings['weeknumbers'] == 1)
jQuery('#dw_davcal__settings_weeknumbers').prop('checked', true);
else
jQuery('#dw_davcal__settings_weeknumbers').prop('checked', false);
if(dw_davcal__modals.settings['workweek'] == 1)
jQuery('#dw_davcal__settings_workweek').prop('checked', true);
else
jQuery('#dw_davcal__settings_workweek').prop('checked', false);
if(dw_davcal__modals.settings['monday'] == 1)
jQuery('#dw_davcal__settings_monday').prop('checked', true);
else
jQuery('#dw_davcal__settings_monday').prop('checked', false);
}
}
// attach event handlers
jQuery('#dw_davcal__settings .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideSettingsDialog();
});
},
/**
* Sanity-check our events.
*
* @return boolean false on failure, otherwise true
*/
checkEvents : function() {
// Retrieve dates
var allDay = jQuery('#dw_davcal__allday_edit').prop('checked');
var startDate = moment(jQuery('#dw_davcal__eventfrom_edit').val(), 'YYYY-MM-DD');
var endDate = moment(jQuery('#dw_davcal__eventto_edit').val(), 'YYYY-MM-DD');
// Do the checking
if(!allDay)
{
var startTime = moment.duration(jQuery('#dw_davcal__eventfromtime_edit').val());
var endTime = moment.duration(jQuery('#dw_davcal__eventtotime_edit').val());
startDate.add(startTime);
endDate.add(endTime);
}
if(!startDate.isValid())
{
dw_davcal__modals.msg = LANG.plugins.davcal['start_date_invalid'];
dw_davcal__modals.showDialog(false);
return false;
}
if(!endDate.isValid())
{
dw_davcal__modals.msg = LANG.plugins.davcal['end_date_invalid'];
dw_davcal__modals.showDialog(false);
return false;
}
if(endDate.isBefore(startDate))
{
dw_davcal__modals.msg = LANG.plugins.davcal['end_date_before_start_date'];
dw_davcal__modals.showDialog(false);
return false;
}
if(!allDay && endDate.isSame(startDate))
{
dw_davcal__modals.msg = LANG.plugins.davcal['end_date_is_same_as_start_date'];
dw_davcal__modals.showDialog(false);
return false;
}
return true;
},
/**
* Show the edit event dialog, which is also used to create new events
* @param {Object} event The event to create, that is the date or the calEvent
* @param {Object} edit Whether we edit (true) or create a new event (false)
*/
showEditEventDialog : function(event, edit) {
if(dw_davcal__modals.$editEventDialog)
return;
var readonly = dw_davcal__modals.settings['readonly'];
var title = '';
var dialogButtons = {};
var calEvent = [];
var recurringWarning = '';
// Buttons are dependent on edit or create
// Several possibilities:
//
// 1) Somebody tries to edit, it is not recurring and not readonly -> show
// 2) Somebody tries to edit, it is recurring and not readonly -> message
// 3) Somebody tries to edit, it is readonly -> message
// 4) Somebody tries to create and it is readonly -> message
// 5) Somebody tries to create -> show
if(edit && (event.recurring != true) && (readonly === false))
{
calEvent = event;
title = LANG.plugins.davcal['edit_event'];
dialogButtons[LANG.plugins.davcal['edit']] = function() {
if(!dw_davcal__modals.checkEvents())
return;
var postArray = { };
var attachArr = new Array();
var pageid = dw_davcal__modals.page;
if(dw_davcal__modals.settings['multi'])
{
pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val();
}
jQuery('.dw_davcal__editevent_attachment_link').each(function() {
var attachment = jQuery(this).attr('href');
if(attachment != undefined)
{
attachArr.push(attachment);
}
});
postArray['attachments'] = attachArr;
jQuery("input.dw_davcal__editevent, textarea.dw_davcal__editevent").each(function() {
if(jQuery(this).attr('type') == 'checkbox')
{
postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
}
else
{
postArray[jQuery(this).prop('name')] = jQuery(this).val();
}
});
jQuery('#dw_davcal__ajaxedit').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: pageid,
page: dw_davcal__modals.page,
action: 'editEvent',
params: postArray
},
function(data)
{
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcal__ajaxedit').html(html);
if(result === true)
{
jQuery('#fullCalendar').fullCalendar('refetchEvents');
dw_davcal__modals.hideEditEventDialog();
}
}
);
};
dialogButtons[LANG.plugins.davcal['delete']] = function() {
dw_davcal__modals.action = 'deleteEvent';
dw_davcal__modals.msg = LANG.plugins.davcal['really_delete_this_event'];
dw_davcal__modals.completeCb = function(data) {
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcal__ajaxedit').html(html);
if(result === true)
{
jQuery('#fullCalendar').fullCalendar('refetchEvents');
dw_davcal__modals.hideEditEventDialog();
}
};
dw_davcal__modals.showDialog(true);
};
}
else if(edit && (event.recurring == true) && (readonly === false))
{
calEvent = event;
title = LANG.plugins.davcal['edit_event'];
recurringWarning = LANG.plugins.davcal['recurring_cant_edit'];
}
else if(edit && (readonly === true))
{
calEvent = event;
title = LANG.plugins.davcal['edit_event'];
recurringWarning = LANG.plugins.davcal['no_permission'];
}
else if(readonly === true)
{
calEvent.start = event;
calEvent.end = moment(event);
calEvent.start.hour(12);
calEvent.start.minute(0);
calEvent.end.hour(13);
calEvent.end.minute(0);
calEvent.allDay = false;
calEvent.recurring = false;
calEvent.title = '';
calEvent.description = '';
calEvent.id = '0';
calEvent.page = dw_davcal__modals.page;
title = LANG.plugins.davcal['create_new_event'];
recurringWarning = LANG.plugins.davcal['no_permission'];
}
else
{
calEvent.start = event;
calEvent.end = moment(event);
calEvent.start.hour(12);
calEvent.start.minute(0);
calEvent.end.hour(13);
calEvent.end.minute(0);
calEvent.allDay = false;
calEvent.recurring = false;
calEvent.title = '';
calEvent.description = '';
calEvent.id = '0';
calEvent.page = dw_davcal__modals.settings['calids'][0]['page'];
title = LANG.plugins.davcal['create_new_event'];
dialogButtons[LANG.plugins.davcal['create']] = function() {
if(!dw_davcal__modals.checkEvents())
return;
var postArray = { };
var pageid = dw_davcal__modals.page;
var attachArr = new Array();
if(dw_davcal__modals.settings['multi'])
{
pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val();
}
jQuery("input.dw_davcal__editevent, textarea.dw_davcal__editevent").each(function() {
if(jQuery(this).attr('type') == 'checkbox')
{
postArray[jQuery(this).prop('name')] = jQuery(this).prop('checked') ? 1 : 0;
}
else
{
postArray[jQuery(this).prop('name')] = jQuery(this).val();
}
});
jQuery('.dw_davcal__editevent_attachment_link').each(function() {
var attachment = jQuery(this).attr('href');
if(attachment != undefined)
{
attachArr.push(attachment);
}
});
postArray['attachments'] = attachArr;
jQuery('#dw_davcal__ajaxedit').html('<img src="'+DOKU_BASE+'lib/images/throbber.gif" alt="" width="16" height="16" />');
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: pageid,
page: dw_davcal__modals.page,
action: 'newEvent',
params: postArray
},
function(data)
{
var result = data['result'];
var html = data['html'];
jQuery('#dw_davcal__ajaxedit').html(html);
if(result === true)
{
jQuery('#fullCalendar').fullCalendar('refetchEvents');
dw_davcal__modals.hideEditEventDialog();
}
}
);
};
}
dialogButtons[LANG.plugins.davcal['cancel']] = function() {
dw_davcal__modals.hideEditEventDialog();
};
dw_davcal__modals.uid = calEvent.id;
dw_davcal__modals.$editEventDialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'<div><table>' +
'<tr><td>' + LANG.plugins.davcal['calendar'] + '</td><td><select id="dw_davcal__editevent_calendar"></select></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['title'] + '</td><td><input type="text" id="dw_davcal__eventname_edit" name="eventname" class="dw_davcal__editevent"></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['description'] + '</td><td><textarea name="eventdescription" id="dw_davcal__eventdescription_edit" class="dw_davcal__editevent dw_davcal__text"></textarea></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['from'] + '</td><td><input type="text" name="eventfrom" id="dw_davcal__eventfrom_edit" class="dw_davcal__editevent dw_davcal__date"><input type="text" name="eventfromtime" id="dw_davcal__eventfromtime_edit" class="dw_davcal__editevent dw_davcal__time"></td></tr>' +
'<tr><td>' + LANG.plugins.davcal['to'] + '</td><td><input type="text" name="eventto" id="dw_davcal__eventto_edit" class="dw_davcal__editevent dw_davcal__date"><input type="text" name="eventtotime" id="dw_davcal__eventtotime_edit" class="dw_davcal__editevent dw_davcal__time"></td></tr>' +
'<tr><td colspan="2"><input type="checkbox" name="allday" id="dw_davcal__allday_edit" class="dw_davcal__editevent">' + LANG.plugins.davcal['allday'] + '</td></tr>' +
'<tr><td>' + LANG.plugins.davcal['attachments'] + '</td><td><table id="dw_davcal__editevent_attachments"><tbody><tr><td><input type="text" id="dw_davcal__editevent_attachment" value="http://"></td><td><a href="#" id="dw_davcal__editevent_attach">' + LANG.plugins.davcal['add_attachment'] + '</a></td></tr></tbody></table></td></tr>' +
'</table>' +
recurringWarning +
'<input type="hidden" name="uid" id="dw_davcal__uid_edit" class="dw_davcal__editevent">' +
'<input type="hidden" name="detectedtz" id="dw_davcal__tz_edit" class="dw_davcal__editevent">' +
'<input type="hidden" name="currenttz" id="dw_davcal__currenttz_edit" class="dw_davcal__editevent">' +
'</div>' +
'<div id="dw_davcal__ajaxedit"></div>'
)
.parent()
.attr('id','dw_davcal__edit')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__edit').position({
my: "center",
at: "center",
of: window
});
// Populate calendar dropdown
var $dropdown = jQuery("#dw_davcal__editevent_calendar");
for(var i=0; i<dw_davcal__modals.settings['calids'].length; i++)
{
var sel = '';
if(calEvent.page == dw_davcal__modals.settings['calids'][i]['page'])
sel = ' selected="selected"';
$dropdown.append('<option value="' + dw_davcal__modals.settings['calids'][i]['page'] + '"' + sel + '>' + dw_davcal__modals.settings['calids'][i]['name'] + '</option>');
}
if(edit || (dw_davcal__modals.settings['calids'].length < 1))
{
$dropdown.prop('disabled', true);
}
// Set up existing/predefined values
jQuery('#dw_davcal__tz_edit').val(dw_davcal__modals.detectedTz);
jQuery('#dw_davcal__currenttz_edit').val(dw_davcal__modals.currentTz);
jQuery('#dw_davcal__uid_edit').val(calEvent.id);
jQuery('#dw_davcal__eventname_edit').val(calEvent.title);
jQuery('#dw_davcal__eventfrom_edit').val(calEvent.start.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventfromtime_edit').val(calEvent.start.format('HH:mm'));
jQuery('#dw_davcal__eventdescription_edit').val(calEvent.description);
if(calEvent.attachments && (calEvent.attachments !== null))
{
for(var i=0; i<calEvent.attachments.length; i++)
{
var url = calEvent.attachments[i];
var row = '<tr><td><a href="' + url + '" class="dw_davcal__editevent_attachment_link">' + url + '</a></td><td><a class="deleteLink" href="#">' + LANG.plugins.davcal['delete'] + '</a></td></tr>';
jQuery('#dw_davcal__editevent_attachments > tbody:last').append(row);
}
}
dw_davcal__modals.attachAttachmentDeleteHandlers();
jQuery('#dw_davcal__editevent_attach').on("click", function(e)
{
e.preventDefault();
var url = jQuery('#dw_davcal__editevent_attachment').val();
jQuery('#dw_davcal__editevent_attachment').val('http://');
var row = '<tr><td><a href="' + url + '" class="dw_davcal__editevent_attachment_link">' + url + '</a></td><td><a class="deleteLink" href="#">' + LANG.plugins.davcal['delete'] + '</a></td></tr>';
jQuery('#dw_davcal__editevent_attachments > tbody:last').append(row);
dw_davcal__modals.attachAttachmentDeleteHandlers();
return false;
});
if(calEvent.allDay && (calEvent.end === null))
{
jQuery('#dw_davcal__eventto_edit').val(calEvent.start.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventtotime_edit').val(calEvent.start.format('HH:mm'));
}
else if(calEvent.allDay)
{
endEvent = moment(calEvent.end);
endEvent.subtract(1, 'days');
jQuery('#dw_davcal__eventto_edit').val(endEvent.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventotime_edit').val(endEvent.format('HH:mm'));
}
else
{
jQuery('#dw_davcal__eventto_edit').val(calEvent.end.format('YYYY-MM-DD'));
jQuery('#dw_davcal__eventtotime_edit').val(calEvent.end.format('HH:mm'));
}
jQuery('#dw_davcal__allday_edit').prop('checked', calEvent.allDay);
// attach event handlers
jQuery('#dw_davcal__edit .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideEditEventDialog();
});
jQuery('#dw_davcal__eventfrom_edit').datetimepicker({format:'YYYY-MM-DD',
formatDate:'YYYY-MM-DD',
datepicker: true,
timepicker: false,
});
jQuery('#dw_davcal__eventfromtime_edit').datetimepicker({format:'HH:mm',
formatTime:'HH:mm',
datepicker: false,
timepicker: true,
step: 15});
jQuery('#dw_davcal__eventto_edit').datetimepicker({format:'YYYY-MM-DD',
formatDate:'YYYY-MM-DD',
datepicker: true,
timepicker: false,
});
jQuery('#dw_davcal__eventtotime_edit').datetimepicker({format:'HH:mm',
formatTime:'HH:mm',
datepicker: false,
timepicker: true,
step:15});
jQuery('#dw_davcal__allday_edit').change(function() {
if(jQuery(this).is(":checked"))
{
jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', true);
jQuery('#dw_davcal__eventtotime_edit').prop('readonly', true);
}
else
{
jQuery('#dw_davcal__eventfromtime_edit').prop('readonly', false);
jQuery('#dw_davcal__eventtotime_edit').prop('readonly', false);
}
});
jQuery('#dw_davcal__allday_edit').change();
},
/**
* Attach handles to delete the attachments to all 'delete' links
*/
attachAttachmentDeleteHandlers: function()
{
jQuery("#dw_davcal__editevent_attachments .deleteLink").on("click", function(e)
{
e.preventDefault();
var tr = jQuery(this).closest('tr');
tr.css("background-color", "#FF3700");
tr.fadeOut(400, function()
{
tr.remove();
});
return false;
});
},
/**
* Show an info/confirmation dialog
* @param {Object} confirm Whether a confirmation dialog (true) or an info dialog (false) is requested
*/
showDialog : function(confirm)
{
if(dw_davcal__modals.$confirmDialog)
return;
var dialogButtons = {};
var title = '';
if(confirm)
{
title = LANG.plugins.davcal['confirmation'];
var pageid = dw_davcal__modals.page;
if(dw_davcal__modals.settings['multi'])
{
pageid = jQuery("#dw_davcal__editevent_calendar option:selected").val();
}
dialogButtons[LANG.plugins.davcal['yes']] = function() {
jQuery.post(
DOKU_BASE + 'lib/exe/ajax.php',
{
call: 'plugin_davcal',
id: pageid,
page: dw_davcal__modals.page,
action: dw_davcal__modals.action,
params: {
uid: dw_davcal__modals.uid
}
},
function(data)
{
dw_davcal__modals.completeCb(data);
}
);
dw_davcal__modals.hideDialog();
};
dialogButtons[LANG.plugins.davcal['cancel']] = function() {
dw_davcal__modals.hideDialog();
};
}
else
{
title = LANG.plugins.davcal['info'];
dialogButtons[LANG.plugins.davcal['ok']] = function() {
dw_davcal__modals.hideDialog();
};
}
dw_davcal__modals.$dialog = jQuery(document.createElement('div'))
.dialog({
autoOpen: false,
draggable: true,
title: title,
resizable: true,
buttons: dialogButtons,
})
.html(
'<div>' + dw_davcal__modals.msg + '</div>'
)
.parent()
.attr('id','dw_davcal__confirm')
.show()
.appendTo('.dokuwiki:first');
jQuery('#dw_davcal__confirm').position({
my: "center",
at: "center",
of: window
});
// attach event handlers
jQuery('#dw_davcal__confirm .ui-dialog-titlebar-close').click(function(){
dw_davcal__modals.hideDialog();
});
},
/**
* Hide the edit event dialog
*/
hideEditEventDialog : function() {
dw_davcal__modals.$editEventDialog.empty();
dw_davcal__modals.$editEventDialog.remove();
dw_davcal__modals.$editEventDialog = null;
},
/**
* Hide the confirm/info dialog
*/
hideDialog: function() {
dw_davcal__modals.$dialog.empty();
dw_davcal__modals.$dialog.remove();
dw_davcal__modals.$dialog = null;
},
/**
* Hide the settings dialog
*/
hideSettingsDialog: function() {
dw_davcal__modals.$settingsDialog.empty();
dw_davcal__modals.$settingsDialog.remove();
dw_davcal__modals.$settingsDialog = null;
}
};
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 4:45 AM (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
534934
Default Alt Text
(88 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment