Import calendar to OwnCloud

Posted · Add Comment

Scheduler Forums BirchPress Scheduler Import calendar to OwnCloud

This topic contains 2 replies, has 3 voices, and was last updated by  Stefan 7 years, 5 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7033

    jedrzejs
    Participant

    OwnCloud gives you ability to host your own shared calendar.

    Here is the script to import from BirchPress to OwnCloud.

    <?php  
    define('OWNCLOUD_DIR', '/var/www/html/owncloud');  
     
    require_once(OWNCLOUD_DIR . '/lib/base.php');  
    require_once(OWNCLOUD_DIR . '/apps/calendar/lib/import.php');  
     
    $Import = array(  	
     
    	array(
    		"userid" => "UserName",
    		"displayname" => "CalendarName",
                    "filename" => "http://domain.com/index.php/birchpress/scheduler/icalendar/36253651e2b9834f"
    	),
    );
     
    foreach($Import AS $cal)
    {
    	try {
    		$stmt = OCP\DB::prepare( 'SELECT * FROM <code>*PREFIX*clndr_calendars</code> WHERE <code>userid</code> = ? AND <code>displayname</code> = ?' );
    		$result = $stmt->execute(array($cal["userid"], $cal["displayname"]));
    		$row = $result->fetchRow();
    		$calendar_id = $row['id'];
    		if (!$calendar_id) {
    			echo "No calendar for userid " . $cal["userid"] . " with displayname '" . $cal["displayname"] . "'";
    		}
    	} catch (Exception $e) {
    		echo "DB exception: " . $e;
    	}
     
    	$file = file_get_contents($cal["filename"]);
    	if ($file === FALSE) {
    		echo "Couldn't read file: ".$cal["filename"];
    	}
            $import = new OC_Calendar_Import($file);
     
    	$import->setUserID($cal["userid"]);
    	$import->setTimeZone(OC_Calendar_App::$tz);
    	$import->setCalendarID($calendar_id);
    	$import->setOverwrite(true);
     
    	OC_User::setUserId($cal["userid"]);
     
    	try {
    		$import->import();
    		$count = $import->getCount();
    		echo "Imported ".$count." objects in Calendar ".$cal["displayname"]."(".$cal["userid"].")\n";
    	} catch (Exception $e) {
    		echo "Import failed: " . $e;
    	}
    }
    ?>
    #19088

    Johannes
    Participant

    Hi there,

    to use this code, in which file do I have to copy it?

    Thanks a lot for your help!

    #25049

    Stefan
    Participant

    Same question as johannes!
    And does this force a 2-way sync? Or is there an other way to syncronize with owncloud-calendar?

    I´m hopeful, you can help. Thx in advance.

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘BirchPress Scheduler’ is closed to new topics and replies.

Comments are closed.