]> source.dussan.org Git - nextcloud-server.git/commitdiff
Merge branch 'master' into calendar_import
authorGeorg Ehrke <dev@georgswebsite.de>
Sat, 21 Jul 2012 15:37:10 +0000 (17:37 +0200)
committerGeorg Ehrke <dev@georgswebsite.de>
Sat, 21 Jul 2012 15:37:10 +0000 (17:37 +0200)
1  2 
apps/calendar/ajax/import/import.php
apps/calendar/appinfo/app.php

index cbb4b55056959dffef5410a4a892b4a93d2c2e7a,38008af4a9dd512d920bd6474c01c2ff8a63c649..b1dfc464d009044f814b54288b507e430c09dd07
@@@ -5,41 -5,34 +5,42 @@@
   * later.
   * See the COPYING-README file.
   */
 -//check for calendar rights or create new one
 -ob_start();
 -
  OCP\JSON::checkLoggedIn();
  OCP\App::checkAppEnabled('calendar');
+ OCP\JSON::callCheck();
  session_write_close();
 -
 -$nl="\r\n";
 -$comps = array('VEVENT'=>true, 'VTODO'=>true, 'VJOURNAL'=>true);
 -
 -global $progresskey;
 -$progresskey = 'calendar.import-' . $_POST['progresskey'];
 -
 -if (isset($_POST['progress']) && $_POST['progress']) {
 -      echo OC_Cache::get($progresskey);
 -      die;
 +if (isset($_POST['progresskey']) && isset($_POST['getprogress'])) {
 +      echo OCP\JSON::success(array('percent'=>OC_Cache::get($_POST['progresskey'])));
 +      exit;
  }
 -
 -function writeProgress($pct) {
 -      global $progresskey;
 -      OC_Cache::set($progresskey, $pct, 300);
 -}
 -writeProgress('10');
  $file = OC_Filesystem::file_get_contents($_POST['path'] . '/' . $_POST['file']);
 +if(!$file){
 +      OCP\JSON::error(array('error'=>'404'));
 +}
 +$import = new OC_Calendar_Import($file);
 +$import->setUserID(OCP\User::getUser());
 +$import->setTimeZone(OC_Calendar_App::$tz);
 +$import->enableProgressCache();
 +$import->setProgresskey($_POST['progresskey']);
 +if(!$import->isValid()){
 +      OCP\JSON::error(array('error'=>'notvalid'));
 +      exit;
 +}
 +$newcal = false;
  if($_POST['method'] == 'new'){
 -      $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), $_POST['calname']);
 -      OC_Calendar_Calendar::setCalendarActive($id, 1);
 +      $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser());
 +      foreach($calendars as $calendar){
 +              if($calendar['displayname'] == $_POST['calname']){
 +                      $id = $calendar['id'];
 +                      $newcal = false;
 +                      break;
 +              }
 +              $newcal = true;
 +      }
 +      if($newcal){
 +              $id = OC_Calendar_Calendar::addCalendar(OCP\USER::getUser(), strip_tags($_POST['calname']),'VEVENT,VTODO,VJOURNAL',null,0,strip_tags($_POST['calcolor']));
 +              OC_Calendar_Calendar::setCalendarActive($id, 1);
 +      }
  }else{
        $calendar = OC_Calendar_App::getCalendar($_POST['id']);
        if($calendar['userid'] != OCP\USER::getUser()){
@@@ -147,4 -120,4 +148,4 @@@ foreach($uids as $uid) 
  writeProgress('100');
  sleep(3);
  OC_Cache::remove($progresskey);
- OCP\JSON::success();*/
 -OCP\JSON::success();
++OCP\JSON::success();*/
index 09b18ed397be2f0aaa67c12c3fae53817a08940f,c8fccc326c33cd68810d11cf999792a2598c2531..4fdba29126285dc07a23ef300b119a8958e7e3f5
@@@ -9,8 -9,8 +9,9 @@@ OC::$CLASSPATH['OC_Calendar_Repeat'] = 
  OC::$CLASSPATH['OC_Calendar_Share'] = 'apps/calendar/lib/share.php';
  OC::$CLASSPATH['OC_Search_Provider_Calendar'] = 'apps/calendar/lib/search.php';
  OC::$CLASSPATH['OC_Calendar_Export'] = 'apps/calendar/lib/export.php';
 +OC::$CLASSPATH['OC_Calendar_Import'] = 'apps/calendar/lib/import.php';
  //General Hooks
+ OCP\Util::connectHook('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'createUser');
  OCP\Util::connectHook('OC_User', 'post_deleteUser', 'OC_Calendar_Hooks', 'deleteUser');
  //Repeating Events Hooks
  OCP\Util::connectHook('OC_Calendar', 'addEvent', 'OC_Calendar_Repeat', 'generate');