本文整理匯總了PHP中Sabre\DAV\INode::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP INode::getName方法的具體用法?PHP INode::getName怎麽用?PHP INode::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sabre\DAV\INode
的用法示例。
在下文中一共展示了INode::getName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeGetProperties
/**
* beforeGetProperties
*
* This method handler is invoked before any after properties for a
* resource are fetched. This allows us to add in any CalDAV specific
* properties.
*
* @param string $path
* @param \Sabre\DAV\INode $node
* @param array $requestedProperties
* @param array $returnedProperties
* @return void
*/
public function beforeGetProperties($path, \Sabre\DAV\INode $node, &$requestedProperties, &$returnedProperties)
{
if ($node instanceof \Sabre\DAVACL\IPrincipal) {
// dropbox-home-URL property
$scheduleProp = '{' . \Sabre\CalDAV\Plugin::NS_CALENDARSERVER . '}dropbox-home-URL';
if (in_array($scheduleProp, $requestedProperties)) {
$principalId = $node->getName();
$dropboxPath = \Sabre\CalDAV\Plugin::CALENDAR_ROOT . '/' . $principalId . '/dropbox';
unset($requestedProperties[array_search($scheduleProp, $requestedProperties)]);
$returnedProperties[200][$scheduleProp] = new \Sabre\DAV\Property\Href($dropboxPath);
}
}
}
開發者ID:ingoratsdorf,項目名稱:Tine-2.0-Open-Source-Groupware-and-CRM,代碼行數:26,代碼來源:PluginManagedAttachments.php
示例2: copyNode
/**
* copyNode
*
* @param INode $source
* @param ICollection $destinationParent
* @param string $destinationName
* @return void
*/
protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null)
{
if (!$destinationName) {
$destinationName = $source->getName();
}
if ($source instanceof IFile) {
$data = $source->get();
// If the body was a string, we need to convert it to a stream
if (is_string($data)) {
$stream = fopen('php://temp', 'r+');
fwrite($stream, $data);
rewind($stream);
$data = $stream;
}
$destinationParent->createFile($destinationName, $data);
$destination = $destinationParent->getChild($destinationName);
} elseif ($source instanceof ICollection) {
$destinationParent->createDirectory($destinationName);
$destination = $destinationParent->getChild($destinationName);
foreach ($source->getChildren() as $child) {
$this->copyNode($child, $destination);
}
}
if ($source instanceof IProperties && $destination instanceof IProperties) {
$props = $source->getProperties([]);
$propPatch = new PropPatch($props);
$destination->propPatch($propPatch);
$propPatch->commit();
}
}
示例3: beforeGetProperties
/**
* Adds all CardDAV-specific properties
*
* @param string $path
* @param DAV\INode $node
* @param array $requestedProperties
* @param array $returnedProperties
* @return void
*/
public function beforeGetProperties($path, DAV\INode $node, array &$requestedProperties, array &$returnedProperties)
{
if ($node instanceof DAVACL\IPrincipal) {
// calendar-home-set property
$addHome = '{' . self::NS_CARDDAV . '}addressbook-home-set';
if (in_array($addHome, $requestedProperties)) {
$principalId = $node->getName();
$addressbookHomePath = self::ADDRESSBOOK_ROOT . '/' . $principalId . '/';
unset($requestedProperties[array_search($addHome, $requestedProperties)]);
$returnedProperties[200][$addHome] = new DAV\Property\Href($addressbookHomePath);
}
$directories = '{' . self::NS_CARDDAV . '}directory-gateway';
if ($this->directories && in_array($directories, $requestedProperties)) {
unset($requestedProperties[array_search($directories, $requestedProperties)]);
$returnedProperties[200][$directories] = new DAV\Property\HrefList($this->directories);
}
}
if ($node instanceof ICard) {
// The address-data property is not supposed to be a 'real'
// property, but in large chunks of the spec it does act as such.
// Therefore we simply expose it as a property.
$addressDataProp = '{' . self::NS_CARDDAV . '}address-data';
if (in_array($addressDataProp, $requestedProperties)) {
unset($requestedProperties[$addressDataProp]);
$val = $node->get();
if (is_resource($val)) {
$val = stream_get_contents($val);
}
$returnedProperties[200][$addressDataProp] = $val;
}
}
if ($node instanceof UserAddressBooks) {
$meCardProp = '{http://calendarserver.org/ns/}me-card';
if (in_array($meCardProp, $requestedProperties)) {
$props = $this->server->getProperties($node->getOwner(), array('{http://sabredav.org/ns}vcard-url'));
if (isset($props['{http://sabredav.org/ns}vcard-url'])) {
$returnedProperties[200][$meCardProp] = new DAV\Property\Href($props['{http://sabredav.org/ns}vcard-url']);
$pos = array_search($meCardProp, $requestedProperties);
unset($requestedProperties[$pos]);
}
}
}
}
示例4: beforeGetProperties
/**
* beforeGetProperties
*
* This method handler is invoked before any after properties for a
* resource are fetched. This allows us to add in any CalDAV specific
* properties.
*
* @param string $path
* @param DAV\INode $node
* @param array $requestedProperties
* @param array $returnedProperties
* @return void
*/
public function beforeGetProperties($path, DAV\INode $node, &$requestedProperties, &$returnedProperties)
{
if ($node instanceof DAVACL\IPrincipal) {
// calendar-home-set property
$calHome = '{' . self::NS_CALDAV . '}calendar-home-set';
if (in_array($calHome, $requestedProperties)) {
$principalId = $node->getName();
$calendarHomePath = self::CALENDAR_ROOT . '/' . $principalId . '/';
unset($requestedProperties[array_search($calHome, $requestedProperties)]);
$returnedProperties[200][$calHome] = new DAV\Property\Href($calendarHomePath);
}
// schedule-outbox-URL property
$scheduleProp = '{' . self::NS_CALDAV . '}schedule-outbox-URL';
if (in_array($scheduleProp, $requestedProperties)) {
$principalId = $node->getName();
$outboxPath = self::CALENDAR_ROOT . '/' . $principalId . '/outbox';
unset($requestedProperties[array_search($scheduleProp, $requestedProperties)]);
$returnedProperties[200][$scheduleProp] = new DAV\Property\Href($outboxPath);
}
// calendar-user-address-set property
$calProp = '{' . self::NS_CALDAV . '}calendar-user-address-set';
if (in_array($calProp, $requestedProperties)) {
$addresses = $node->getAlternateUriSet();
$addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/';
unset($requestedProperties[array_search($calProp, $requestedProperties)]);
$returnedProperties[200][$calProp] = new DAV\Property\HrefList($addresses, false);
}
// These two properties are shortcuts for ical to easily find
// other principals this principal has access to.
$propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
$propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
if (in_array($propRead, $requestedProperties) || in_array($propWrite, $requestedProperties)) {
$aclPlugin = $this->server->getPlugin('acl');
$membership = $aclPlugin->getPrincipalMembership($path);
$readList = array();
$writeList = array();
foreach ($membership as $group) {
$groupNode = $this->server->tree->getNodeForPath($group);
// If the node is either ap proxy-read or proxy-write
// group, we grab the parent principal and add it to the
// list.
if ($groupNode instanceof Principal\IProxyRead) {
list($readList[]) = DAV\URLUtil::splitPath($group);
}
if ($groupNode instanceof Principal\IProxyWrite) {
list($writeList[]) = DAV\URLUtil::splitPath($group);
}
}
if (in_array($propRead, $requestedProperties)) {
unset($requestedProperties[$propRead]);
$returnedProperties[200][$propRead] = new DAV\Property\HrefList($readList);
}
if (in_array($propWrite, $requestedProperties)) {
unset($requestedProperties[$propWrite]);
$returnedProperties[200][$propWrite] = new DAV\Property\HrefList($writeList);
}
}
// notification-URL property
$notificationUrl = '{' . self::NS_CALENDARSERVER . '}notification-URL';
if (($index = array_search($notificationUrl, $requestedProperties)) !== false) {
$principalId = $node->getName();
$calendarHomePath = 'calendars/' . $principalId . '/notifications/';
unset($requestedProperties[$index]);
$returnedProperties[200][$notificationUrl] = new DAV\Property\Href($calendarHomePath);
}
}
// instanceof IPrincipal
if ($node instanceof Notifications\INode) {
$propertyName = '{' . self::NS_CALENDARSERVER . '}notificationtype';
if (($index = array_search($propertyName, $requestedProperties)) !== false) {
$returnedProperties[200][$propertyName] = $node->getNotificationType();
unset($requestedProperties[$index]);
}
}
// instanceof Notifications_INode
if ($node instanceof ICalendarObject) {
// The calendar-data property is not supposed to be a 'real'
// property, but in large chunks of the spec it does act as such.
// Therefore we simply expose it as a property.
$calDataProp = '{' . Plugin::NS_CALDAV . '}calendar-data';
if (in_array($calDataProp, $requestedProperties)) {
unset($requestedProperties[$calDataProp]);
$val = $node->get();
if (is_resource($val)) {
$val = stream_get_contents($val);
}
// Taking out \r to not screw up the xml output
//.........這裏部分代碼省略.........
示例5: propFind
/**
* PropFind
*
* This method handler is invoked before any after properties for a
* resource are fetched. This allows us to add in any CalDAV specific
* properties.
*
* @param DAV\PropFind $propFind
* @param DAV\INode $node
* @return void
*/
function propFind(DAV\PropFind $propFind, DAV\INode $node)
{
$ns = '{' . self::NS_CALDAV . '}';
if ($node instanceof ICalendarContainer) {
$propFind->handle($ns . 'max-resource-size', $this->maxResourceSize);
$propFind->handle($ns . 'supported-calendar-data', function () {
return new Property\SupportedCalendarData();
});
$propFind->handle($ns . 'supported-collation-set', function () {
return new Property\SupportedCollationSet();
});
}
if ($node instanceof DAVACL\IPrincipal) {
$principalUrl = $node->getPrincipalUrl();
$propFind->handle('{' . self::NS_CALDAV . '}calendar-home-set', function () use($principalUrl) {
$calendarHomePath = $this->getCalendarHomeForPrincipal($principalUrl) . '/';
return new DAV\Property\Href($calendarHomePath);
});
// The calendar-user-address-set property is basically mapped to
// the {DAV:}alternate-URI-set property.
$propFind->handle('{' . self::NS_CALDAV . '}calendar-user-address-set', function () use($node) {
$addresses = $node->getAlternateUriSet();
$addresses[] = $this->server->getBaseUri() . $node->getPrincipalUrl() . '/';
return new HrefList($addresses, false);
});
// For some reason somebody thought it was a good idea to add
// another one of these properties. We're supporting it too.
$propFind->handle('{' . self::NS_CALENDARSERVER . '}email-address-set', function () use($node) {
$addresses = $node->getAlternateUriSet();
$emails = [];
foreach ($addresses as $address) {
if (substr($address, 0, 7) === 'mailto:') {
$emails[] = substr($address, 7);
}
}
return new Property\EmailAddressSet($emails);
});
// These two properties are shortcuts for ical to easily find
// other principals this principal has access to.
$propRead = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-read-for';
$propWrite = '{' . self::NS_CALENDARSERVER . '}calendar-proxy-write-for';
if ($propFind->getStatus($propRead) === 404 || $propFind->getStatus($propWrite) === 404) {
$aclPlugin = $this->server->getPlugin('acl');
$membership = $aclPlugin->getPrincipalMembership($propFind->getPath());
$readList = [];
$writeList = [];
foreach ($membership as $group) {
$groupNode = $this->server->tree->getNodeForPath($group);
// If the node is either ap proxy-read or proxy-write
// group, we grab the parent principal and add it to the
// list.
if ($groupNode instanceof Principal\IProxyRead) {
list($readList[]) = URLUtil::splitPath($group);
}
if ($groupNode instanceof Principal\IProxyWrite) {
list($writeList[]) = URLUtil::splitPath($group);
}
}
$propFind->set($propRead, new HrefList($readList));
$propFind->set($propWrite, new HrefList($writeList));
}
// notification-URL property
$propFind->handle('{' . self::NS_CALENDARSERVER . '}notification-URL', function () use($node, $principalUrl) {
$principalId = $node->getName();
$notificationPath = $this->getCalendarHomeForPrincipal($principalUrl) . '/notifications/';
return new DAV\Property\Href($notificationPath);
});
}
// instanceof IPrincipal
if ($node instanceof Notifications\INode) {
$propFind->handle('{' . self::NS_CALENDARSERVER . '}notificationtype', [$node, 'getNotificationType']);
}
// instanceof Notifications_INode
if ($node instanceof ICalendarObject) {
// The calendar-data property is not supposed to be a 'real'
// property, but in large chunks of the spec it does act as such.
// Therefore we simply expose it as a property.
$propFind->handle('{' . Plugin::NS_CALDAV . '}calendar-data', function () use($node) {
$val = $node->get();
if (is_resource($val)) {
$val = stream_get_contents($val);
}
// Taking out \r to not screw up the xml output
return str_replace("\r", "", $val);
});
}
}
示例6: propFind
/**
* This method handler is invoked during fetching of properties.
*
* We use this event to add calendar-auto-schedule-specific properties.
*
* @param PropFind $propFind
* @param INode $node
* @return void
*/
function propFind(PropFind $propFind, INode $node)
{
if (!$node instanceof DAVACL\IPrincipal) {
return;
}
$caldavPlugin = $this->server->getPlugin('caldav');
$principalUrl = $node->getPrincipalUrl();
// schedule-outbox-URL property
$propFind->handle('{' . self::NS_CALDAV . '}schedule-outbox-URL', function () use($principalUrl, $caldavPlugin) {
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
$outboxPath = $calendarHomePath . '/outbox/';
return new Href($outboxPath);
});
// schedule-inbox-URL property
$propFind->handle('{' . self::NS_CALDAV . '}schedule-inbox-URL', function () use($principalUrl, $caldavPlugin) {
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
$inboxPath = $calendarHomePath . '/inbox/';
return new Href($inboxPath);
});
$propFind->handle('{' . self::NS_CALDAV . '}schedule-default-calendar-URL', function () use($principalUrl, $caldavPlugin) {
// We don't support customizing this property yet, so in the
// meantime we just grab the first calendar in the home-set.
$calendarHomePath = $caldavPlugin->getCalendarHomeForPrincipal($principalUrl);
$nodes = $this->server->tree->getNodeForPath($calendarHomePath)->getChildren();
foreach ($nodes as $node) {
if ($node instanceof ICalendar) {
return new Href($calendarHomePath . '/' . $node->getName());
}
}
});
// The server currently reports every principal to be of type
// 'INDIVIDUAL'
$propFind->handle('{' . self::NS_CALDAV . '}calendar-user-type', function () {
return 'INDIVIDUAL';
});
}