Handle calendar upload.

This commit is contained in:
Maxime Delorme 2007-05-05 11:40:08 +12:00 committed by Andrew McMillan
parent bd54b86ecf
commit 46555cb26e

View File

@ -35,6 +35,17 @@
$c->page_title = $user->Get("user_no"). " - " . $user->Get("fullname");
}
}
if ( $_FILES['ics_file']['name'] && $_POST['path_ics'] ) {
$ics = file_get_contents($_FILES['ics_file']['tmp_name']);
$ics = trim($ics);
$path_ics = $_POST['path_ics'];
if ( substr($path_ics,-1,1) != '/' ) $path_ics .= '/'; // ensure that we target a collection
if ( substr($path_ics,0,1) != '/' ) $path_ics = '/'.$path_ics; // ensure that we target a collection
}
else {
unset($ics);
}
}
else {
/**
@ -50,12 +61,38 @@
if ( $session->AllowedTo("Admin") )
$user_menu->AddOption(translate("New User"),"$c->base_url/user.php?create",translate("Add a new user"), false, 10);
if ( $user->user_no > 0 && $user->AllowedTo('update') ) {
$user_menu->AddOption(translate("View"),"$c->base_url/user.php?user_no=$user->user_no",translate("View this user record") );
$user_menu->AddOption(translate("Edit"),"$c->base_url/user.php?edit=1&user_no=$user->user_no",translate("Edit this user record"), $user->EditMode );
if ( $user->user_no > 0 ) {
if ( $user->AllowedTo('update') ) {
$user_menu->AddOption( translate($user->EditMode?"View":"Edit")." ".$user->Values->fullname, "$c->base_url/user.php?user_no=$user->user_no".($user->EditMode?"":"&edit=1"), translate(($user->EditMode?"View":"Edit")." this user record"), true, 900 );
}
else {
$user_menu->AddOption( translate("View")." ".$user->Values->fullname, "$c->base_url/user.php?user_no=$user->user_no", translate("View this user record"), true, 900 );
}
}
include("page-header.php");
echo $user->Render($c->page_title);
include("page-footer.php");
?>
if ( $ics !='' ) {
/**
* If the user has uploaded a .ics file as a calendar, we fake this out
* as if it were a "PUT" request against a collection. This is something
* of a hack, especially since it doesn't provide quality feedback to the
* user about what is happening. It works though :-)
*
* TODO: Extract the important code from caldav-PUT-collection.php into a
* function which can be included here and shared. That way we can perhaps
* show the user a useful error message, if needed.
*/
include('check_UTF8.php');
if ( check_string($ics) ) {
$_SERVER['REQUEST_METHOD'] = 'PUT';
$_SERVER['PATH_INFO'] = "/".$user->Get("username").$path_ics;
require_once("CalDAVRequest.php");
$request = new CalDAVRequest();
$request->raw_post = $ics;
include_once("caldav-PUT.php");
}
}
?>