Esempio n. 1
0
 public function SetCurrentEncoding($siteId = null)
 {
     $this->encoding = CDav::GetCharset($siteId);
     if (is_null($this->encoding) || empty($this->encoding)) {
         $this->encoding = "utf-8";
     }
 }
Esempio n. 2
0
 public function SetEncoding($siteId)
 {
     $encoding = CDav::GetCharset($siteId);
     if (is_null($encoding) || empty($encoding)) {
         $encoding = "utf-8";
     }
     $this->encoding = strtolower($encoding);
 }
Esempio n. 3
0
 public function __construct($request)
 {
     ini_set("display_errors", 0);
     $this->request = $request;
     $cs = CDav::GetCharset();
     if (is_null($cs) || empty($cs)) {
         $cs = "utf-8";
     }
     /** @var CDavRequest $request */
     $request = $this->request;
     $this->response = new CDavResponse($request->GetParameter('REQUEST_URI'), $cs);
 }
Esempio n. 4
0
 public function Put($id, $siteId, $account, $arPath)
 {
     $calendarId = $this->GetCalendarId($siteId, $account, $arPath);
     if ($calendarId == null) {
         return '404 Not Found';
     }
     CDav::Report("CDavCalendarHandler::Put", "calendarId", $calendarId);
     $request = $this->groupdav->GetRequest();
     $oldEvent = $this->GetEntry('PUT', $id, $calendarId);
     if (!is_null($oldEvent) && !is_array($oldEvent)) {
         return $oldEvent;
     }
     $charset = "utf-8";
     $arContentParameters = $request->GetContentParameters();
     //CDav::Report("CDavCalendarHandler::Put", "arContentParameters", $arContentParameters);
     if (!empty($arContentParameters['CONTENT_TYPE'])) {
         $arContentType = explode(';', $arContentParameters['CONTENT_TYPE']);
         if (count($arContentType) > 1) {
             array_shift($arContentType);
             foreach ($arContentType as $attribute) {
                 $attribute = trim($attribute);
                 list($key, $value) = explode('=', $attribute);
                 if (strtolower($key) == 'charset') {
                     $charset = strtolower($value);
                 }
             }
         }
     }
     $content = $request->GetRequestBody();
     $content = htmlspecialcharsback($content);
     //CDav::Report("CDavCalendarHandler::Put", "content", $content);
     if (is_array($oldEvent)) {
         $eventId = $oldEvent['ID'];
     } else {
         // Search the same event without ID
         $eventId = 0;
     }
     $cs = CDav::GetCharset($siteId);
     if (is_null($cs) || empty($cs)) {
         $cs = "utf-8";
     }
     $content = $GLOBALS["APPLICATION"]->ConvertCharset($content, $charset, $cs);
     CDav::Report("CDavCalendarHandler::Put", "content (converted " . $charset . " -> " . $cs . ")", $content);
     $cal = new CDavICalendar($content, $siteId);
     $arEvents = $cal->GetComponents('VTIMEZONE', false);
     if (count($arEvents) <= 0) {
         return '404 Not Found';
     }
     $arFields = $this->ConvertICalToArray($arEvents[0], $cal);
     if ($eventId > 0) {
         $arFields['ID'] = $eventId;
     } else {
         $arFields['CREATED_BY'] = $arFields['MODIFIED_BY'];
     }
     if (isset($arFields['DAV_XML_ID'])) {
         $arFields['XML_ID'] = $arFields['DAV_XML_ID'];
     }
     CDav::Report("CDavCalendarHandler::Put", "arFields", $arFields);
     $eventId = CCalendar::ModifyEvent($calendarId, $arFields);
     if (is_bool($eventId)) {
         return $eventId;
     }
     if (!is_numeric($eventId)) {
         return false;
     }
     //header('ETag: '.$this->GetETag($calendarId, $xmlId));
     //$path = preg_replace('|(.*)/[^/]*|', '\1/', $request->GetPath());
     //header('Location: '.$request->GetBaseUri().$path.$this->GetPath($xmlId));
     return "201 Created";
 }
Esempio n. 5
0
 public function Put($id, $siteId, $account, $arPath)
 {
     $collectionId = $this->GetCollectionId($siteId, $account, $arPath);
     if ($collectionId == null) {
         return '404 Not Found';
     }
     $request = $this->groupdav->GetRequest();
     $oldCard = $this->GetEntry('PUT', $id, $collectionId);
     if (!is_null($oldCard) && !is_array($oldCard)) {
         return $oldCard;
     }
     $charset = "utf-8";
     $arContentParameters = $request->GetContentParameters();
     if (!empty($arContentParameters['CONTENT_TYPE'])) {
         $arContentType = explode(';', $arContentParameters['CONTENT_TYPE']);
         if (count($arContentType) > 1) {
             array_shift($arContentType);
             foreach ($arContentType as $attribute) {
                 $attribute = trim($attribute);
                 list($key, $value) = explode('=', $attribute);
                 if (strtolower($key) == 'charset') {
                     $charset = strtolower($value);
                 }
             }
         }
     }
     $content = $request->GetRequestBody();
     $content = htmlspecialcharsback($content);
     if (is_array($oldCard)) {
         $contactId = $oldCard['ID'];
     } else {
         $contactId = 0;
     }
     $cs = CDav::GetCharset($siteId);
     if (is_null($cs) || empty($cs)) {
         $cs = "utf-8";
     }
     $content = $GLOBALS["APPLICATION"]->ConvertCharset($content, $charset, $cs);
     // Create record
     return "201 Created";
 }