public function Propfind(&$arResources, $siteId, $account, $arPath, $id = null) { $request = $this->groupdav->GetRequest(); $currentPrincipal = $request->GetPrincipal(); if (!$this->CheckPrivileges('DAV::read', $currentPrincipal, 0)) { return '403 Forbidden'; } $requestDocument = $request->GetXmlDocument(); if ($requestDocument->GetRoot() && $requestDocument->GetRoot()->GetTag() != 'propfind') { return '501 Not Implemented'; } if (!is_null($arPath) && count($arPath) > 0) { if (isset($arPath[1])) { $u = CDavAccount::GetAccountByName($arPath[1]); $account = array($u["TYPE"], $u["ID"]); } switch ($arPath[0]) { case 'user': $res = $this->PropfindUsers($arResources, $siteId, $account, $arPath, $id, $request->GetDepth()); break; case 'group': $res = $this->PropfindGroups($arResources, $siteId, $account, $arPath, $id, $request->GetDepth()); break; default: return '404 Not Found'; } } else { $res = $this->PropfindPrincipals($arResources, $siteId); } if ($res !== true) { return $res; } return true; }
private function ParsePath($path) { $path = trim($path, "/"); if (strlen($path) <= 0) { $siteId = $this->request->GetSiteId(); $this->response->SetEncoding($siteId); return array("site" => $siteId, "account" => null, "accountPrefix" => "/" . $siteId, "application" => null, "path" => null, "id" => null); } $arParts = explode('/', trim($path, "/")); // /ru/admin/calendar/25/1.ics // /ru/group-7/calendar/43/4.ics // /ru/calendar/12/48/3.ics $part = array_shift($arParts); $arSite = null; try { $dbSite = CSite::GetList($o, $b, array("LID" => $part, "ACTIVE" => "Y")); if (!($arSite = $dbSite->Fetch())) { $arSite = null; } } catch (Exception $e) { $arSite = null; } $site = null; if (!is_null($arSite)) { $site = $arSite["ID"]; $part = array_shift($arParts); } if (is_null($site)) { $site = $this->request->GetSiteId(); } $this->response->SetEncoding($site); try { $arAccount = CDavAccount::GetAccountByName($part); if (!$arAccount) { $arAccount = CDavAccount::GetAccountByName(urldecode($part)); } } catch (Exception $e) { $arAccount = null; } $account = null; $accountPrefix = "/" . $site; if (!is_null($arAccount)) { $account = array($arAccount["TYPE"], $arAccount["ID"]); $accountPrefix .= '/' . $part; $part = array_shift($arParts); } $application = $part; $arPath = array(); $id = null; while (count($arParts) > 0) { $part = array_shift($arParts); if (count($arParts) > 0 || strcasecmp(".ics", substr($part, -4)) && strcasecmp(".vcf", substr($part, -4))) { $arPath[] = $part; } else { $id = substr($part, 0, -4); } } return array("site" => $site, "account" => $account, "accountPrefix" => $accountPrefix, "application" => $application, "path" => $arPath, "id" => $id); }