#!/usr/bin/env php readonly_webdav_collections = false; // Override any active default. dbg_error_log('load-collection',':Write: Loaded %d bytes from %s', strlen($ics), $source ); if ( !check_string($ics) ) { $ics = force_utf8($ics); if ( !check_string($ics) ) { printf( "The source file '%s' contains some non-UTF-8 characters.\n", $source ); exit(1); } } class FakeSession { var $user_no; var $principal_id; var $username; var $email; var $dav_name; var $principal; var $logged_in; function __construct($user_no = null) { if ( empty($user_no) ) { $this->user_no = -1; $this->principal_id = -1; $this->logged_in = false; return; } $this->user_no = $user_no; $principal = new Principal('user_no',$user_no); // Assign each field in the selected record to the object foreach( $principal AS $k => $v ) { $this->{$k} = $v; } $this->username = $principal->username(); $this->principal_id = $principal->principal_id(); $this->email = $principal->email(); $this->dav_name = $principal->dav_name(); $this->principal = $principal; $this->logged_in = true; } function AllowedTo($do_something) { return $this->logged_in; } } $session = new FakeSession(); $dest = new DAVResource($target); $session = new FakeSession($dest->user_no()); if ( $mode == 'append' && ! $dest->Exists() ) { printf( "The target '%s' does not exist.\n", $target ); exit(1); } if ( ! $dest->IsCollection() ) { printf( "The target '%s' is not a collection.\n", $target ); exit(1); } $user_no = $dest->user_no(); $username = $session->username; param_to_global('mode'); include_once('caldav-PUT-functions.php'); controlRequestContainer( $session->username, $dest->user_no(), $target, false, ($dest->IsPublic() ? true : false)); import_collection( $ics, $dest->user_no(), $target, $session->user_no, ($mode == 'append') ); printf(translate('Calendar "%s" was loaded from file.') . "\n", $target);