本文整理汇总了PHP中OC_Calendar_Calendar::addCalendarFromDAVData方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Calendar_Calendar::addCalendarFromDAVData方法的具体用法?PHP OC_Calendar_Calendar::addCalendarFromDAVData怎么用?PHP OC_Calendar_Calendar::addCalendarFromDAVData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Calendar_Calendar
的用法示例。
在下文中一共展示了OC_Calendar_Calendar::addCalendarFromDAVData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCalendar
/**
* Creates a new calendar for a principal.
*
* If the creation was a success, an id must be returned that can be used to reference
* this calendar in other methods, such as updateCalendar
*
* @param string $principalUri
* @param string $calendarUri
* @param array $properties
* @return mixed
*/
public function createCalendar($principalUri, $calendarUri, array $properties)
{
$fieldNames = array('principaluri', 'uri', 'ctag');
$values = array(':principaluri' => $principalUri, ':uri' => $calendarUri, ':ctag' => 1);
// Default value
$sccs = '{urn:ietf:params:xml:ns:caldav}supported-calendar-component-set';
$fieldNames[] = 'components';
if (!isset($properties[$sccs])) {
$values[':components'] = 'VEVENT,VTODO';
} else {
if (!$properties[$sccs] instanceof \Sabre\CalDAV\Property\SupportedCalendarComponentSet) {
throw new \Sabre\DAV\Exception('The ' . $sccs . ' property must be of type: \\Sabre\\CalDAV\\Property\\SupportedCalendarComponentSet');
}
$values[':components'] = implode(',', $properties[$sccs]->getValue());
}
foreach ($this->propertyMap as $xmlName => $dbName) {
if (isset($properties[$xmlName])) {
$myValue = $properties[$xmlName];
$values[':' . $dbName] = $properties[$xmlName];
$fieldNames[] = $dbName;
}
}
if (!isset($newValues['displayname'])) {
$newValues['displayname'] = 'unnamed';
}
if (!isset($newValues['components'])) {
$newValues['components'] = 'VEVENT,VTODO';
}
if (!isset($newValues['timezone'])) {
$newValues['timezone'] = null;
}
if (!isset($newValues['calendarorder'])) {
$newValues['calendarorder'] = 0;
}
if (!isset($newValues['calendarcolor'])) {
$newValues['calendarcolor'] = null;
}
if (!is_null($newValues['calendarcolor']) && strlen($newValues['calendarcolor']) == 9) {
$newValues['calendarcolor'] = substr($newValues['calendarcolor'], 0, 7);
}
return OC_Calendar_Calendar::addCalendarFromDAVData($principalUri, $calendarUri, $newValues['displayname'], $newValues['components'], $newValues['timezone'], $newValues['calendarorder'], $newValues['calendarcolor']);
}