disabled event-editing scripts for link-shared calendars, as per:

https://github.com/owncloud/calendar/pull/308#issuecomment-33214846
master
Michał 'rysiek' Woźniak 2014-01-24 16:09:20 +01:00
parent 417dcef2e2
commit dcc7c7e962
3 changed files with 34 additions and 10 deletions

View File

@ -83,6 +83,13 @@ Calendar={
}
},
UI:{
/*
* checking if the calendar is link-shared and hence not editable
*/
isLinkShared: function() {
// simple enough, eh?
return ( $('#linksharedinfo').length > 0 )
},
loading: function(isLoading){
if (isLoading){
$('#loading').show();
@ -141,6 +148,10 @@ Calendar={
$('#event-title').focus().val('').val(val);
},
newEvent:function(start, end, allday){
// nothing to do for link-shared public calendars
if (Calendar.UI.isLinkShared()) return false;
start = Math.round(start.getTime()/1000);
if (end){
end = Math.round(end.getTime()/1000);
@ -154,7 +165,7 @@ Calendar={
}
},
editEvent:function(calEvent, jsEvent, view){
if (calEvent.editable == false || calEvent.source.editable == false) {
if (calEvent.editable == false || calEvent.source.editable == false) {
return;
}
var id = calEvent.id;
@ -223,10 +234,14 @@ Calendar={
},"json");
},
moveEvent:function(event, dayDelta, minuteDelta, allDay, revertFunc){
if($('#event').length != 0) {
revertFunc();
return;
}
// nothing to do for link-shared public calendars
if (Calendar.UI.isLinkShared()) return false;
if($('#event').length != 0) {
revertFunc();
return;
}
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax/event', 'move.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, allDay: allDay?1:0, lastmodified: event.lastmodified},
function(data) {
@ -241,7 +256,11 @@ Calendar={
});
},
resizeEvent:function(event, dayDelta, minuteDelta, revertFunc){
Calendar.UI.loading(true);
// nothing to do for link-shared public calendars
if (Calendar.UI.isLinkShared()) return false;
Calendar.UI.loading(true);
$.post(OC.filePath('calendar', 'ajax/event', 'resize.php'), { id: event.id, dayDelta: dayDelta, minuteDelta: minuteDelta, lastmodified: event.lastmodified},
function(data) {
Calendar.UI.loading(false);
@ -561,7 +580,7 @@ Calendar={
init:function(){
if(typeof OC.Share !== typeof undefined){
var itemShares = [OC.Share.SHARE_TYPE_USER, OC.Share.SHARE_TYPE_GROUP];
$('#sharewith').autocomplete({minLength: 1, source: function(search, response) {
$('#sharewith, .internal-share .share-with.ui-autocomplete-input').live('keydown.autocomplete', function(){$(this).autocomplete({minLength: 1, source: function(search, response) {
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getShareWith', search: search.term, itemShares: itemShares }, function(result) {
if (result.status == 'success' && result.data.length > 0) {
response(result.data);
@ -596,7 +615,7 @@ Calendar={
});
return false;
}
});
});});
$('.shareactions > input:checkbox').change(function() {
var container = $(this).parents('li').first();

View File

@ -153,7 +153,6 @@ if (isset($rootLinkItem)) {
// Display the event
} elseif ($linkItem['item_type'] === 'event') {
//OCP\Util::addscript('calendar', 'calendar');
OCP\Util::addStyle('calendar', 'style');
//OCP\Util::addscript('', 'jquery.multiselect');
//OCP\Util::addStyle('', 'jquery.multiselect');

View File

@ -1,7 +1,13 @@
<script type="text/javascript" src="<?php print_unescaped(OC_Helper::linkTo('calendar/js', 'l10n.php'));?>"></script>
<div id="notification" style="display:none;"></div>
<?php if (isset($_['link_shared_calendar_name'])) { ?>
<?php
/*
* if the calendar is link-shared -- display the info
* the existence of #linksharedinfo is also used in calendar.js to determine if the calendar is link-shared
*/
if (isset($_['link_shared_calendar_name'])) {
?>
<div id="linksharedinfo">User <?php p($_['link_shared_calendar_owner'])?> shared &quot;<?php p($_['link_shared_calendar_name'])?>&quot; calendar with you; explore below or download using this link:<br/><a href="<?php p($_['link_shared_calendar_url'])?>&amp;download"><?php p($_['link_shared_calendar_url'])?>&amp;download</a></div>
<?php } ?>
<div id="controls">