Ejemplo n.º 1
0
 /**
  * Returns a list of ACE's for this node.
  *
  * Each ACE has the following properties:
  *   * 'privilege', a string such as {DAV:}read or {DAV:}write. These are
  *     currently the only supported privileges
  *   * 'principal', a url to the principal who owns the node
  *   * 'protected' (optional), indicating that this ACE is not allowed to
  *      be updated.
  *
  * @return array
  */
 public function getACL()
 {
     // The top-level ACL only contains access information for the true
     // owner of the calendar, so we need to add the information for the
     // sharee.
     $acl = parent::getACL();
     $acl[] = array('privilege' => '{DAV:}read', 'principal' => $this->calendarInfo['principaluri'], 'protected' => true);
     if (!$this->calendarInfo['{http://sabredav.org/ns}read-only']) {
         $acl[] = array('privilege' => '{DAV:}write', 'principal' => $this->calendarInfo['principaluri'], 'protected' => true);
     }
     return $acl;
 }
Ejemplo n.º 2
0
 function propPatch(PropPatch $propPatch)
 {
     $mutations = $propPatch->getMutations();
     // If this is a shared calendar, the user can only change the enabled property, to hide it.
     if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal']) && (sizeof($mutations) !== 1 || !isset($mutations['{http://owncloud.org/ns}calendar-enabled']))) {
         throw new Forbidden();
     }
     parent::propPatch($propPatch);
 }
Ejemplo n.º 3
0
 /**
  * This method returns the ACL's for calendar objects in this calendar.
  * The result of this method automatically gets passed to the
  * calendar-object nodes in the calendar.
  *
  * @return array
  */
 function getChildACL()
 {
     $acl = parent::getChildACL();
     $acl[] = ['privilege' => '{DAV:}read', 'principal' => $this->calendarInfo['principaluri'], 'protected' => true];
     if (!$this->calendarInfo['{http://sabredav.org/ns}read-only']) {
         $acl[] = ['privilege' => '{DAV:}write', 'principal' => $this->calendarInfo['principaluri'], 'protected' => true];
     }
     return $acl;
 }
Ejemplo n.º 4
0
 function delete()
 {
     if (isset($this->calendarInfo['{http://owncloud.org/ns}owner-principal'])) {
         $principal = 'principal:' . parent::getOwner();
         $shares = $this->getShares();
         $shares = array_filter($shares, function ($share) use($principal) {
             return $share['href'] === $principal;
         });
         if (empty($shares)) {
             throw new Forbidden();
         }
         /** @var CalDavBackend $calDavBackend */
         $calDavBackend = $this->caldavBackend;
         $calDavBackend->updateShares($this, [], ['href' => $principal]);
         return;
     }
     parent::delete();
 }
Ejemplo n.º 5
0
 function testGetChangesNoSyncSupport()
 {
     $calendar = new Calendar(new Backend\Mock([], []), []);
     $this->assertNull($calendar->getChanges(1, null));
 }
Ejemplo n.º 6
0
 function testCreateFileNoSupportedComponents()
 {
     $file = fopen('php://memory', 'r+');
     fwrite($file, TestUtil::getTestCalendarData());
     rewind($file);
     $calendar = new Calendar($this->backend, $this->calendars[1]);
     $calendar->createFile('hello', $file);
     $file = $calendar->getChild('hello');
     $this->assertTrue($file instanceof CalendarObject);
 }