コード例 #1
0
ファイル: EventTest.php プロジェクト: Kervinou/OBM
  public function testVcalendarGetSingleEventByExtId(){
    // lmartin should get the event he owns (the 4)
    $GLOBALS['obm']['uid'] = 9;
    $GLOBALS['obm']['domain_id'] = 3;
    OBM_Acl::initialize();
    $writerOBM = new Vcalendar_Writer_OBM();
    $eventData = $writerOBM->getEventByExtId("double");
    $this->assertEquals(4, $eventData->Record["event_id"]);

    // ytouzet should get the event he has rights on (the 4)
    $GLOBALS['obm']['uid'] = 10;
    $writerOBM = new Vcalendar_Writer_OBM();
    $eventData = $writerOBM->getEventByExtId("double");
    $this->assertEquals(4, $eventData->Record["event_id"]);

    // adupont should get the event which he participates (the 3)
    $GLOBALS['obm']['uid'] = 8;
    $writerOBM = new Vcalendar_Writer_OBM();
    $eventData = $writerOBM->getEventByExtId("double");
    $this->assertEquals(3, $eventData->Record["event_id"]);

    // someone without write rights, not owner nor participant should get the first event with "double" ext_id
    $GLOBALS['obm']['uid'] = 11;
    $writerOBM = new Vcalendar_Writer_OBM();
    $eventData = $writerOBM->getEventByExtId("double");
    $this->assertEquals(2, $eventData->Record["event_id"]);

    // With a single event matching an ext id, getEventByExtId should return this single event
    $GLOBALS['obm']['uid'] = 9;
    $writerOBM = new Vcalendar_Writer_OBM();
    $eventData = $writerOBM->getEventByExtId("single");
    $this->assertEquals(5, $eventData->Record["event_id"]);
  }
コード例 #2
0
ファイル: Backup.php プロジェクト: Kervinou/OBM
 /**
  * Perform the import of the vcalendar
  */
 private function user_vcalendar_import($fd, $user_id)
 {
     include_once 'php/calendar/calendar_query.inc';
     include_once 'php/calendar/event_observer.php';
     include_once 'obminclude/lib/Solr/Document.php';
     include_once 'obminclude/of/of_indexingService.inc';
     include_once 'obminclude/of/vcalendar/Utils.php';
     include_once 'obminclude/of/vcalendar/writer/OBM.php';
     include_once 'obminclude/of/vcalendar/reader/ICS.php';
     $remember_uid = $GLOBALS['obm']['uid'];
     $GLOBALS['obm']['uid'] = $user_id;
     // some kind of sudo $user_id
     //reset calendar
     run_query_calendar_reset($user_id, array('delete_meeting' => true));
     //restore calendar
     $reader = new Vcalendar_Reader_ICS($fd);
     $document = $reader->getDocument();
     $writer = new Vcalendar_Writer_OBM(true);
     $writer->writeDocument($document);
     $document->destroy();
     $GLOBALS['obm']['uid'] = $remember_uid;
 }