Merge branch 'master' of gitorious.org:owncloud/owncloud into ace-editor
This commit is contained in:
commit
45fda6f43e
6 changed files with 158 additions and 87 deletions
20
apps/calendar/ajax/importdialog.php
Normal file
20
apps/calendar/ajax/importdialog.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once('../../../lib/base.php');
|
||||
|
||||
$l10n = new OC_L10N('calendar');
|
||||
|
||||
if(!OC_USER::isLoggedIn()) {
|
||||
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
|
||||
}
|
||||
OC_JSON::checkAppEnabled('calendar');
|
||||
|
||||
$tmpl = new OC_Template('calendar', 'part.import');
|
||||
$tmpl->printpage();
|
||||
?>
|
|
@ -6,6 +6,8 @@ OC::$CLASSPATH['OC_Calendar_Hooks'] = 'apps/calendar/lib/hooks.php';
|
|||
OC::$CLASSPATH['OC_Connector_Sabre_CalDAV'] = 'apps/calendar/lib/connector_sabre.php';
|
||||
OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Calendar_Hooks', 'deleteUser');
|
||||
|
||||
OC_Util::addScript('calendar','loader');
|
||||
|
||||
OC_App::register( array(
|
||||
'order' => 10,
|
||||
'id' => 'calendar',
|
||||
|
|
50
apps/calendar/import.php
Normal file
50
apps/calendar/import.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Copyright (c) 2011 Georg Ehrke <ownclouddev at georgswebsite dot de>
|
||||
* This file is licensed under the Affero General Public License version 3 or
|
||||
* later.
|
||||
* See the COPYING-README file.
|
||||
*/
|
||||
|
||||
require_once ('../../lib/base.php');
|
||||
OC_JSON::checkLoggedIn();
|
||||
OC_Util::checkAppEnabled('calendar');
|
||||
|
||||
if($_GET["import"] == "existing"){
|
||||
$calid = $_GET["calid"];
|
||||
$calendar = OC_Calendar_Calendar::findCalendar($calid);
|
||||
if($calendar['userid'] != OC_User::getUser()){
|
||||
OC_JSON::error();
|
||||
exit;
|
||||
}
|
||||
if($_GET["path"] != ""){
|
||||
$filename = $_GET["path"] . "/" . $_GET["file"];
|
||||
}else{
|
||||
$filename = "/" . $_GET["file"];
|
||||
}
|
||||
}else{
|
||||
$id = OC_Calendar_Calendar::addCalendar(OC_User::getUser(), $_POST['calname'], $_POST['description']);
|
||||
OC_Calendar_Calendar::setCalendarActive($id, 1);
|
||||
$calid = $id;
|
||||
if($_POST["path"] != ""){
|
||||
$filename = $_POST["path"] . "/" . $_POST["file"];
|
||||
}else{
|
||||
$filename = "/" . $_POST["file"];
|
||||
}
|
||||
}
|
||||
$vcalendar = OC_Filesystem::file_get_contents($filename);
|
||||
$vcalendar = explode("BEGIN:VEVENT", $vcalendar);
|
||||
for($i = 1;$i < count($vcalendar);$i++){
|
||||
$vcalendar[$i] = "BEGIN:VEVENT" . $vcalendar[$i];
|
||||
}
|
||||
for($i = 1;$i < count($vcalendar) - 1;$i++){
|
||||
$vcalendar[$i] = $vcalendar[$i] . "END:VCALENDAR";
|
||||
}
|
||||
for($i = 1;$i < count($vcalendar);$i++){
|
||||
$vcalendar[$i] = $vcalendar[0] . $vcalendar[$i];
|
||||
}
|
||||
for($i = 1;$i < count($vcalendar);$i++){
|
||||
OC_Calendar_Object::add($calid, $vcalendar[$i]);
|
||||
}
|
||||
OC_JSON::success();
|
||||
?>
|
16
apps/calendar/js/loader.js
Normal file
16
apps/calendar/js/loader.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
function importdialog(directory, filename){
|
||||
$("body").append("<div id=\"importdialogholder\"></div>");
|
||||
$("#importdialogholder").load(OC.filePath('calendar', 'ajax', 'importdialog.php?filename=' + filename + '&path=' + directory));
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
$('tr[data-file$=".ics"]').attr("data-mime", "text/calendar");
|
||||
$('tr[data-file$=".vcs"]').attr("data-mime", "text/calendar");
|
||||
$('tr[data-file$=".ical"]').attr("data-mime", "text/calendar");
|
||||
if(typeof FileActions!=='undefined'){
|
||||
FileActions.register('text/calendar','Import to Calendar','',function(filename){
|
||||
importdialog($('#dir').val(),filename);
|
||||
});
|
||||
FileActions.setDefault('text/calendar','Import to Calendar');
|
||||
}
|
||||
});
|
|
@ -1,87 +0,0 @@
|
|||
<div id="eventinfo" title="<?php echo $l -> t("Edit an event");?>">
|
||||
<table id="eventinfo_table" width="100%">
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Title");?>:</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Location");?>:</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Category");?>:</td>
|
||||
<td></td>
|
||||
<td width="75px"> <?php echo $l -> t("Calendar");?>:</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="75px"></td>
|
||||
<td>
|
||||
<input type="checkbox" id="newcalendar_allday_checkbox" disabled="true">
|
||||
<label for="newcalendar_allday_checkbox"><?php echo $l -> t("All Day Event");?></label></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("From");?>:</td>
|
||||
<td>
|
||||
|
||||
</td><!--use jquery-->
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
<td width="75px"><?php echo $l -> t("To");?>:</td>
|
||||
<td>
|
||||
|
||||
</td><!--use jquery-->
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Repeat");?>:</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Attendees");?>:</td>
|
||||
<td style="height: 50px;"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<table>
|
||||
<tr>
|
||||
<td width="75px" style="vertical-align: top;"><?php echo $l -> t("Description");?>:</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<span id="editevent_actions">
|
||||
<input type="button" style="float: left;" value="<?php echo $l -> t("Close");?>">
|
||||
<input type="button" style="float: right;" value="<?php echo $l -> t("Edit");?>">
|
||||
</span>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( "#eventinfo" ).dialog({
|
||||
width : 500,
|
||||
close : function() {
|
||||
oc_cal_opendialog = 0;
|
||||
var lastchild = document.getElementById("body-user").lastChild
|
||||
while(lastchild.id != "lightbox"){
|
||||
document.getElementById("body-user").removeChild(lastchild);
|
||||
lastchild = document.getElementById("body-user").lastChild;
|
||||
}
|
||||
},
|
||||
open : function(){alert("Doesn't work yet.");}
|
||||
});
|
||||
$( "#from" ).datepicker({
|
||||
dateFormat : 'dd-mm-yy'
|
||||
});
|
||||
$( "#to" ).datepicker({
|
||||
dateFormat : 'dd-mm-yy'
|
||||
});
|
||||
}
|
||||
</script>
|
70
apps/calendar/templates/part.import.php
Normal file
70
apps/calendar/templates/part.import.php
Normal file
|
@ -0,0 +1,70 @@
|
|||
<div id="importdialog" title="<?php echo $l->t("Import Ical File"); ?>">
|
||||
<input type="hidden" id="filename" value="<?php echo $_GET["filename"];?>">
|
||||
<input type="hidden" id="path" value="<?php echo $_GET["path"];?>">
|
||||
<div id="first"><strong style="text-align: center;margin: 0 auto;"><?php echo $l->t("How to import the new calendar?");?></strong>
|
||||
<br><br>
|
||||
<input style="float: left;" type="button" value="<?php echo $l->t("Import into an existing calendar"); ?>" onclick="$('#first').css('display', 'none');$('#existingcal').css('display', 'block');">
|
||||
<input style="float: right;" type="button" value="<?php echo $l->t("Import into a new calendar");?>" onclick="$('#first').css('display', 'none');$('#newcal').css('display', 'block');">
|
||||
</div>
|
||||
<div id="existingcal" style="display: none;">
|
||||
<strong><?php echo $l->t("Please choose the calendar"); ?></strong><br><br>
|
||||
<form id="inputradioform">
|
||||
<?php
|
||||
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
|
||||
foreach($calendars as $calendar){
|
||||
echo '<input type="radio" style="width: 20px;" name="calendar" id="radio_' . $calendar["id"] . '" value="' . $calendar["id"] . '">' . $calendar["displayname"] . '<br>';
|
||||
}
|
||||
?>
|
||||
</form>
|
||||
<br><br>
|
||||
<input type="button" value="<?php echo $l->t("Import");?>!" onclick="importcal('existing');">
|
||||
<br><br>
|
||||
<input type="button" value="<?php echo $l->t("Back");?>" onclick="$('#existingcal').css('display', 'none');$('#first').css('display', 'block');">
|
||||
</div>
|
||||
<div id="newcal" style="display: none;">
|
||||
<strong><?php echo $l->t("Please fill out the form"); ?></strong>
|
||||
<!-- modified part of part.editcalendar.php -->
|
||||
<table width="100%" style="border: 0;">
|
||||
<tr>
|
||||
<th><?php echo $l->t('Displayname') ?></th>
|
||||
<td>
|
||||
<input id="displayname" type="text" value="">
|
||||
</td>
|
||||
</tr>
|
||||
<th><?php echo $l->t('Description') ?></th>
|
||||
<td>
|
||||
<textarea id="description"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- end of modified part -->
|
||||
<br><br>
|
||||
<input type="button" value="<?php echo $l->t("Import");?>!" onclick="importcal('new');">
|
||||
<br><br>
|
||||
<input type="button" value="<?php echo $l->t("Back");?>" onclick="$('#newcal').css('display', 'none');$('#first').css('display', 'block');">
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$("input:radio[name='calendar']:first").attr("checked","checked");
|
||||
$("#importdialog").dialog({
|
||||
width : 500,
|
||||
close : function(event, ui) {
|
||||
$(this).dialog('destroy').remove();
|
||||
$("#importdialogholder").remove();
|
||||
}
|
||||
});
|
||||
function importcal(importtype){
|
||||
var path = $("#path").val();
|
||||
var file = $("#filename").val();
|
||||
if(importtype == "existing"){
|
||||
var calid = $("input:radio[name='calendar']:checked").val();
|
||||
$.getJSON(OC.filePath('calendar', '', 'import.php') + "?import=existing&calid=" + calid + "&path=" + path + "&file=" + file);
|
||||
}
|
||||
if(importtype == "new"){
|
||||
var calname = $("#displayname").val();
|
||||
var description = $("#description").val();
|
||||
$.post(OC.filePath('calendar', '', 'import.php'), {'import':'new', 'calname':calname, 'description':description, 'path':path, 'file':file});
|
||||
}
|
||||
window.location = oc_webroot + "/apps/calendar/";
|
||||
}
|
||||
</script>
|
Loading…
Reference in a new issue