function testGet()
 {
     $children = $this->calendar->getChildren();
     $this->assertTrue($children[0] instanceof Sabre_CalDAV_CalendarObject);
     $obj = $children[0];
     $expected = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Apple Inc.//iCal 4.0.1//EN\nCALSCALE:GREGORIAN\nBEGIN:VTIMEZONE\nTZID:Asia/Seoul\nBEGIN:DAYLIGHT\nTZOFFSETFROM:+0900\nRRULE:FREQ=YEARLY;UNTIL=19880507T150000Z;BYMONTH=5;BYDAY=2SU\nDTSTART:19870510T000000\nTZNAME:GMT+09:00\nTZOFFSETTO:+1000\nEND:DAYLIGHT\nBEGIN:STANDARD\nTZOFFSETFROM:+1000\nDTSTART:19881009T000000\nTZNAME:GMT+09:00\nTZOFFSETTO:+0900\nEND:STANDARD\nEND:VTIMEZONE\nBEGIN:VEVENT\nCREATED:20100225T154229Z\nUID:39A6B5ED-DD51-4AFE-A683-C35EE3749627\nTRANSP:TRANSPARENT\nSUMMARY:Something here\nDTSTAMP:20100228T130202Z\nDTSTART;TZID=Asia/Seoul:20100223T060000\nDTEND;TZID=Asia/Seoul:20100223T070000\nATTENDEE;PARTSTAT=NEEDS-ACTION:mailto:lisa@example.com\nSEQUENCE:2\nEND:VEVENT\nEND:VCALENDAR";
     $this->assertEquals($expected, $obj->get());
 }
 /**
  * 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;
 }
 function testGetSupportedPrivilegesSet()
 {
     $result = $this->calendar->getSupportedPrivilegeSet();
     $this->assertEquals('{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}read-free-busy', $result['aggregates'][0]['aggregates'][2]['privilege']);
 }
/**
 * @param Sabre_DAV_Server $server
 * @param Sabre_CalDAV_Calendar $calendar
 * @param string $calendarobject_uri
 * @param string $with_privilege
 * @return null|Sabre\VObject\Component\VCalendar
 */
function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobject_uri, $with_privilege = "")
{
    $obj = $calendar->getChild($calendarobject_uri);
    if ($with_privilege == "") {
        $with_privilege = DAV_ACL_READ;
    }
    $a = get_app();
    $uri = "/calendars/" . strtolower($a->user["nickname"]) . "/" . $calendar->getName() . "/" . $calendarobject_uri;
    /** @var Sabre_DAVACL_Plugin $aclplugin  */
    $aclplugin = $server->getPlugin("acl");
    if (!$aclplugin->checkPrivileges($uri, $with_privilege, Sabre_DAVACL_Plugin::R_PARENT, false)) {
        return null;
    }
    $data = $obj->get();
    $vObject = Sabre\VObject\Reader::read($data);
    return $vObject;
}
Example #5
0
 function testCreateFileNoSupportedComponents()
 {
     $file = fopen('php://memory', 'r+');
     fwrite($file, Sabre_CalDAV_TestUtil::getTestCalendarData());
     rewind($file);
     $calendar = new Sabre_CalDAV_Calendar($this->principalBackend, $this->backend, $this->calendars[1]);
     $calendar->createFile('hello', $file);
     $file = $calendar->getChild('hello');
     $this->assertTrue($file instanceof Sabre_CalDAV_CalendarObject);
 }