Beispiel #1
0
 /**
  * Deletes the calendar.
  *
  * @return void
  */
 public function delete()
 {
     $sTenantPrincipalUri = \Afterlogic\DAV\Utils::getTenantPrincipalUri($this->principalInfo['uri']);
     if ($sTenantPrincipalUri !== $this->calendarInfo['principaluri']) {
         $this->caldavBackend->updateShares($this->calendarInfo['id'], array(), array(basename($this->principalInfo['uri'])));
     }
 }
Beispiel #2
0
 protected function getSharedCalendarsForUser($sPrincipalUri, $bSharedToAll = false)
 {
     $aCalendars = array();
     $sTenantPrincipalUri = null;
     if (!$sPrincipalUri) {
         return $aCalendars;
     }
     if ($sPrincipalUri) {
         if ($bSharedToAll) {
             $sTenantPrincipalUri = $sPrincipalUri;
             $sPrincipalUri = \Afterlogic\DAV\Utils::getTenantPrincipalUri($sPrincipalUri);
         }
         $sFields = $this->getCalendarFields();
         $sShareFields = implode(', ', $this->sharesProperties);
         $oStmt = $this->pdo->prepare("SELECT " . $sShareFields . " FROM " . $this->calendarSharesTableName . " WHERE principaluri = ?");
         $oStmt->execute(array($sPrincipalUri));
         $aRows = $oStmt->fetchAll(\PDO::FETCH_ASSOC);
         foreach ($aRows as $aRow) {
             // get the original calendar
             $oCalStmt = $this->pdo->prepare("SELECT " . $sFields . " FROM " . $this->calendarTableName . " WHERE id = ? ORDER BY id ASC LIMIT 1");
             $oCalStmt->execute(array($aRow['calendarid']));
             while ($calRow = $oCalStmt->fetch(\PDO::FETCH_ASSOC)) {
                 $aComponents = isset($aRows['components']) ? explode(',', $aRows['components']) : array();
                 $aCalendar = array('id' => $calRow['id'], 'uri' => $calRow['uri'], 'principaluri' => $bSharedToAll ? $sTenantPrincipalUri : $sPrincipalUri, '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new \Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet($aComponents), '{' . \Sabre\CalDAV\Plugin::NS_CALDAV . '}schedule-calendar-transp' => new \Sabre\CalDAV\Xml\Property\ScheduleCalendarTransp($calRow['transparent'] ? 'transparent' : 'opaque'));
                 // some specific properies for shared calendars
                 $aCalendar['{http://calendarserver.org/ns/}shared-url'] = $calRow['uri'];
                 $aCalendar['{http://sabredav.org/ns}owner-principal'] = $calRow['principaluri'];
                 $aCalendar['{http://sabredav.org/ns}read-only'] = $aRow['readonly'];
                 $aCalendar['{http://calendarserver.org/ns/}summary'] = $aRow['summary'];
                 foreach ($this->propertyMap as $xmlName => $dbName) {
                     if ($xmlName == '{DAV:}displayname') {
                         $aCalendar[$xmlName] = $calRow['displayname'];
                         //$aRow['displayname'] == null ? $calRow['displayname'] : $aRow['displayname'];
                     } elseif ($xmlName == '{http://apple.com/ns/ical/}calendar-color') {
                         $aCalendar[$xmlName] = $aRow['color'] == null ? $calRow['calendarcolor'] : $aRow['color'];
                     } else {
                         $aCalendar[$xmlName] = $calRow[$dbName];
                     }
                 }
                 $aCalendars[$aCalendar['id']] = $aCalendar;
             }
         }
     }
     return $aCalendars;
 }