public function Propfind(&$arResources, $siteId, $account, $arPath, $id = null) { $calendarId = $this->GetCalendarId($siteId, $account, $arPath); if ($calendarId == null) { return '404 Not Found'; } $request = $this->groupdav->GetRequest(); $currentPrincipal = $request->GetPrincipal(); if (!$this->CheckPrivileges('urn:ietf:params:xml:ns:caldav:read-free-busy', $currentPrincipal, $calendarId)) { return '403 Forbidden'; } $requestDocument = $request->GetXmlDocument(); $path = CDav::CheckIfRightSlashAdded($request->GetPath()); if (!isset($calendarId[0], $calendarId[1])) { $arCalendarList = CCalendar::GetCalendarList($calendarId, array('skipExchange' => true)); foreach ($arCalendarList as $calendar) { $resource = new CDavResource($path . $calendar["ID"] . "/"); $this->GetCalendarProperties($resource, $siteId, $account, array($calendar["ID"]), 0); $arResources[] = $resource; } return true; } $bCalendarData = count($requestDocument->GetPath('/*/DAV::allprop')) > 0; if (!$bCalendarData || $requestDocument->GetRoot()->GetXmlns() != CDavGroupDav::CALDAV) { $arProp = $requestDocument->GetPath('/*/DAV::prop/*'); foreach ($arProp as $prop) { if ($prop->GetTag() == 'calendar-data') { $bCalendarData = true; break; } } } $arFilter = array('DATE_START' => ConvertTimeStamp(time() - 93 * 24 * 3600, "FULL"), 'DATE_END' => ConvertTimeStamp(time() + 365 * 24 * 3600, "FULL")); if (($id || $requestDocument->GetRoot() && $requestDocument->GetRoot()->GetTag() != 'propfind') && !$this->PrepareFilters($arFilter, $requestDocument, $id)) { return false; } if ($calendarId[0] > 0) { $arEvents = CCalendar::GetDavCalendarEventsList($calendarId, $arFilter); foreach ($arEvents as $event) { if (!$this->CheckPrivileges('DAV::read', $currentPrincipal, $calendarId)) { $this->ClearPrivateData($event); } $resource = new CDavResource($path . $this->GetPath($event)); $resource->AddProperty('getetag', $this->GetETag($calendarId, $event)); $resource->AddProperty('getcontenttype', $request->GetAgent() != 'kde' ? 'text/calendar; charset=utf-8; component=VEVENT' : 'text/calendar'); $resource->AddProperty('getlastmodified', MakeTimeStamp($event['TIMESTAMP_X'])); $resource->AddProperty('resourcetype', ''); if ($bCalendarData) { $content = $this->GetICalContent($event, $siteId); $resource->AddProperty('getcontentlength', strlen($content)); $resource->AddProperty('calendar-data', $content, CDavGroupDav::CALDAV); } else { $resource->AddProperty('getcontentlength', ""); } $arResources[] = $resource; } } return true; }
public function Propfind(&$arResources, $siteId, $account, $arPath, $id = null) { $collectionId = $this->GetCollectionId($siteId, $account, $arPath); if ($collectionId == null) { return '404 Not Found'; } $request = $this->groupdav->GetRequest(); $currentPrincipal = $request->GetPrincipal(); if (!$this->CheckPrivileges('DAV:read', $currentPrincipal, $collectionId)) { return '403 Forbidden'; } $requestDocument = $request->GetXmlDocument(); $path = CDav::CheckIfRightSlashAdded($request->GetPath()); $bAddressData = count($requestDocument->GetPath('/*/DAV::allprop')) > 0; if (!$bAddressData || $requestDocument->GetRoot()->GetXmlns() != CDavGroupDav::CARDDAV) { $arProp = $requestDocument->GetPath('/*/DAV::prop/*'); foreach ($arProp as $prop) { if ($prop->GetTag() == 'address-data') { $bAddressData = true; break; } } } $arFilter = array(); if (($id || $requestDocument->GetRoot() && $requestDocument->GetRoot()->GetTag() != 'propfind') && !$this->PrepareFilters($arFilter, $requestDocument, $id)) { return false; } $arContacts = CDavAccount::GetAddressbookContactsList($collectionId, $arFilter); foreach ($arContacts as $contact) { $resource = new CDavResource($path . $this->GetPath($contact)); $resource->AddProperty('getetag', $this->GetETag($collectionId, $contact)); $resource->AddProperty('getcontenttype', 'text/vcard'); $resource->AddProperty('getlastmodified', MakeTimeStamp($contact['TIMESTAMP_X'])); $resource->AddProperty('resourcetype', ''); if ($bAddressData) { $content = $this->GetVCardContent($contact); $resource->AddProperty('getcontentlength', strlen($content)); $resource->AddProperty('address-data', $content, CDavGroupDav::CARDDAV); } else { $resource->AddProperty('getcontentlength', ""); } $arResources[] = $resource; } return true; }
protected function PROPFIND(&$arResources, $method = 'PROPFIND') { $arResources = array(); $arRequestPath = self::ParsePath($this->request->GetPath()); $accountPrefixPath = CDav::CheckIfRightSlashAdded($arRequestPath["accountPrefix"]); $requestDocument = $this->request->GetXmlDocument(); $application = $arRequestPath["application"]; if (!$application) { if (!$arRequestPath["account"]) { $arRequestPath["account"] = array("user", $this->request->GetPrincipal()->Id()); } $arAccount = CDavAccount::GetAccountById($arRequestPath["account"]); $resource = new CDavResource($accountPrefixPath); $resource->AddProperty('resourcetype', array('collection', '')); $this->GetCollectionProperties($resource, $arRequestPath["site"], $arRequestPath["account"], $arRequestPath["path"]); foreach ($this->arApplications as $app) { if (($handler = $this->GetApplicationHandler($app)) && method_exists($handler, 'GetCollectionProperties')) { $handler->GetCollectionProperties($resource, $arRequestPath["site"], $arRequestPath["account"], null, $arRequestPath["path"], 0); } } $arResources[] = $resource; if ($this->request->GetDepth()) { if (strlen($accountPrefixPath) == 1) { $resource = new CDavResource('/principals/'); $resource->AddProperty('displayname', GetMessage("DAV_PRINCIPALS")); $resource->AddProperty('resourcetype', array('principals', '')); $resource->AddProperty('current-user-principal', array('href', $this->request->GetPrincipalUrl())); $arResources[] = $resource; } foreach ($this->arApplications as $app) { if (($handler = $this->GetApplicationHandler($app)) && method_exists($handler, 'GetHomeCollectionUrl')) { $resourcePath = $handler->GetHomeCollectionUrl($arRequestPath["site"], $arRequestPath["account"], $arRequestPath["path"]); } else { $resourcePath = $accountPrefixPath . $app; } $resource = new CDavResource($resourcePath); $this->GetCollectionProperties($resource, $arRequestPath["site"], $arRequestPath["account"], $arRequestPath["path"]); if (method_exists($handler, 'GetCollectionProperties')) { $handler->GetCollectionProperties($resource, $arRequestPath["site"], $arRequestPath["account"], $app, $arRequestPath["path"], 0); } $resource->AddProperty('getetag', $app); $arResources[] = $resource; } } return true; } if ($handler = $this->GetApplicationHandler($application)) { if ($application != "principals" && $method != 'REPORT' && $arRequestPath["id"] == null) { $resource = new CDavResource($this->request->GetPath()); $this->GetCollectionProperties($resource, $arRequestPath["site"], $arRequestPath["account"], $arRequestPath["path"]); if (method_exists($handler, 'GetCollectionProperties')) { $handler->GetCollectionProperties($resource, $arRequestPath["site"], $arRequestPath["account"], $application, $arRequestPath["path"], $application == 'addressbook' && $this->request->GetAgent() == 'kde' ? BX_GW_SKIP_EXTRA_TYPES : 0); } $arResources[] = $resource; if ($this->request->GetDepth() == 0) { return true; } } return $handler->Propfind($arResources, $arRequestPath["site"], $arRequestPath["account"], $arRequestPath["path"], $arRequestPath["id"]); } return '501 Not Implemented'; }
protected function AddGroup(&$arResources, $siteId, $arGroup) { $request = $this->groupdav->GetRequest(); $resource = new CDavResource('/principals/group/' . $arGroup['CODE'] . '/'); $resource->AddProperty('displayname', $arGroup["NAME"]); $resource->AddProperty('getetag', $this->GetETag($arGroup)); $resource->AddProperty('resourcetype', array(array('principal', '', CDavGroupDav::DAV))); $resource->AddProperty('alternate-URI-set', ''); $resource->AddProperty('calendar-home-set', array(array('href', $request->GetBaseUri() . "/" . $siteId . "/" . $arGroup["CODE"] . "/calendar/")), CDavGroupDav::CALDAV); $resource->AddProperty('record-type', 'group', CDavGroupDav::CALENDARSERVER); $resource->AddProperty('calendar-user-type', 'GROUP', CDavGroupDav::CALDAV); //$resource->AddProperty('group-member-set', $memberships); $arResources[] = $resource; }
/** * @param $path * @param File|Folder|Object $object * @return CDavResource */ protected function getResourceByObject($path, BaseObject $object) { $isFolder = $object instanceof Folder; $resource = new CDavResource($path . ($isFolder && substr($path, -1, 1) != "/" ? "/" : "")); $resource->AddProperty('name', $object->getName()); if ($object instanceof File) { $resource->AddProperty('getcontentlength', $object->getSize()); } $resource->AddProperty('creationdate', $object->getCreateTime()->getTimestamp()); $resource->AddProperty('getlastmodified', $object->getUpdateTime()->getTimestamp()); $resource->AddProperty('iscollection', $isFolder ? '1' : '0'); if ($isFolder) { $resource->AddProperty('resourcetype', array('collection', '')); $resource->AddProperty('getcontenttype', 'httpd/unix-directory'); } else { $resource->AddProperty('getcontenttype', ''); $resource->AddProperty('isreadonly', ''); $resource->AddProperty('ishidden', ''); $resource->AddProperty('resourcetype', ''); } $resource->AddProperty("supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>"); return $resource; }
/** * @param $path * @param File|Folder|Object $object * @return CDavResource */ protected function getResourceByObject($path, BaseObject $object) { $isFolder = $object instanceof Folder; $resource = new CDavResource($path . ($isFolder && substr($path, -1, 1) != "/" ? "/" : "")); $resource->AddProperty('name', $object->getName()); if ($object instanceof File) { $resource->AddProperty('getcontentlength', $object->getSize()); } $resource->AddProperty('creationdate', $object->getCreateTime()->getTimestamp()); $resource->AddProperty('getlastmodified', $object->getUpdateTime()->getTimestamp()); $resource->AddProperty('iscollection', $isFolder ? '1' : '0'); $resource->AddProperty('Win32CreationTime', $object->getCreateTime()->getTimestamp(), "urn:schemas-microsoft-com:"); $resource->AddProperty('Win32LastModifiedTime', $object->getUpdateTime()->getTimestamp(), "urn:schemas-microsoft-com:"); if ($isFolder) { $resource->AddProperty('resourcetype', array('collection', '')); $resource->AddProperty('getcontenttype', 'httpd/unix-directory'); } else { $resource->AddProperty('getcontenttype', ''); $resource->AddProperty('isreadonly', ''); $resource->AddProperty('ishidden', ''); $resource->AddProperty('resourcetype', ''); } $resource->AddProperty("supportedlock", "<D:lockentry><D:lockscope><D:exclusive/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry><D:lockentry><D:lockscope><D:shared/></D:lockscope><D:locktype><D:write/></D:locktype></D:lockentry>"); /* <D:response xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"> <D:href>/docs/shared/%D0%97%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B8</D:href> <D:propstat> <D:prop> <D:resourcetype><D:collection/></D:resourcetype> <D:getcontenttype>httpd/unix-directory</D:getcontenttype> <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:37:25Z</D:creationdate> <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:37:25 GMT</D:getlastmodified> <D:iscollection/> <D:supportedlock><D:lockentry> <D:lockscope><D:exclusive/></D:lockscope> <D:locktype><D:write/></D:locktype> </D:lockentry> <D:lockentry> <D:lockscope><D:shared/></D:lockscope> <D:locktype><D:write/></D:locktype> </D:lockentry></D:supportedlock> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> <D:response xmlns:ns0="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"> <D:href>/docs/shared/%D0%90%D0%BD%D0%BA%D0%B5%D1%82%D0%B0.docx</D:href> <D:propstat> <D:prop> <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:26:30Z</D:creationdate> <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:26:31 GMT</D:getlastmodified> <D:creationdate ns0:dt="dateTime.tz">2014-05-12T08:26:30Z</D:creationdate> <D:getlastmodified ns0:dt="dateTime.rfc1123">Mon, 12 May 2014 08:26:31 GMT</D:getlastmodified> <D:getcontenttype/> <D:getcontentlength>86838</D:getcontentlength> <D:isreadonly>false</D:isreadonly> <D:ishidden>false</D:ishidden> <D:iscollection>0</D:iscollection> <D:resourcetype/> <D:supportedlock><D:lockentry> <D:lockscope><D:exclusive/></D:lockscope> <D:locktype><D:write/></D:locktype> </D:lockentry> <D:lockentry> <D:lockscope><D:shared/></D:lockscope> <D:locktype><D:write/></D:locktype> </D:lockentry></D:supportedlock> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> </D:response> */ return $resource; }