Add creating calendars with the web interface
This commit is contained in:
parent
f3e98878da
commit
74f6dd5d5a
7 changed files with 118 additions and 12 deletions
39
apps/calendar/ajax/createcalendar.php
Normal file
39
apps/calendar/ajax/createcalendar.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/*************************************************
|
||||||
|
* ownCloud - Calendar Plugin *
|
||||||
|
* *
|
||||||
|
* (c) Copyright 2011 Georg Ehrke *
|
||||||
|
* author: Georg Ehrke *
|
||||||
|
* email: ownclouddev at georgswebsite dot de *
|
||||||
|
* homepage: ownclouddev.georgswebsite.de *
|
||||||
|
* manual: ownclouddev.georgswebsite.de/manual *
|
||||||
|
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
|
||||||
|
* *
|
||||||
|
* If you are not able to view the License, *
|
||||||
|
* <http://www.gnu.org/licenses/> *
|
||||||
|
* <http://ownclouddev.georgswebsite.de/license/> *
|
||||||
|
* please write to the Free Software Foundation. *
|
||||||
|
* Address: *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, *
|
||||||
|
* MA 02111-1307 USA *
|
||||||
|
*************************************************/
|
||||||
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
|
$l10n = new OC_L10N('calendar');
|
||||||
|
|
||||||
|
// We send json data
|
||||||
|
header( "Content-Type: application/jsonrequest" );
|
||||||
|
|
||||||
|
// Check if we are a user
|
||||||
|
if( !OC_User::isLoggedIn()){
|
||||||
|
echo json_encode( array( "status" => "error", "data" => array( "message" => $l->t("Authentication error") )));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$userid = OC_User::getUser();
|
||||||
|
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], $_POST['description'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
|
||||||
|
OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
|
||||||
|
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
||||||
|
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
|
||||||
|
$tmpl->assign('calendar', $calendar);
|
||||||
|
echo json_encode( array( "status" => "error", "data" => $tmpl->fetchPage().'' ));
|
|
@ -24,6 +24,7 @@ if(!OC_USER::isLoggedIn()) {
|
||||||
}
|
}
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
|
$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
|
||||||
$tmpl = new OC_Template("calendar", "part.editcalendar");
|
$tmpl = new OC_Template("calendar", "part.editcalendar");
|
||||||
$tmpl->assign('calendar',$calendar);
|
$tmpl->assign('new', false);
|
||||||
|
$tmpl->assign('calendar', $calendar);
|
||||||
$tmpl->printPage();
|
$tmpl->printPage();
|
||||||
?>
|
?>
|
||||||
|
|
35
apps/calendar/ajax/newcalendar.php
Normal file
35
apps/calendar/ajax/newcalendar.php
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
/*************************************************
|
||||||
|
* ownCloud - Calendar Plugin *
|
||||||
|
* *
|
||||||
|
* (c) Copyright 2011 Georg Ehrke *
|
||||||
|
* author: Georg Ehrke *
|
||||||
|
* email: ownclouddev at georgswebsite dot de *
|
||||||
|
* homepage: ownclouddev.georgswebsite.de *
|
||||||
|
* manual: ownclouddev.georgswebsite.de/manual *
|
||||||
|
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
|
||||||
|
* *
|
||||||
|
* If you are not able to view the License, *
|
||||||
|
* <http://www.gnu.org/licenses/> *
|
||||||
|
* <http://ownclouddev.georgswebsite.de/license/> *
|
||||||
|
* please write to the Free Software Foundation. *
|
||||||
|
* Address: *
|
||||||
|
* 59 Temple Place, Suite 330, Boston, *
|
||||||
|
* MA 02111-1307 USA *
|
||||||
|
*************************************************/
|
||||||
|
require_once('../../../lib/base.php');
|
||||||
|
$l10n = new OC_L10N('calendar');
|
||||||
|
if(!OC_USER::isLoggedIn()) {
|
||||||
|
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
|
||||||
|
}
|
||||||
|
$calendar = array(
|
||||||
|
'id' => 'new',
|
||||||
|
'displayname' => 'Test',
|
||||||
|
'description' => 'Test calendar',
|
||||||
|
'calendarcolor' => 'black',
|
||||||
|
);
|
||||||
|
$tmpl = new OC_Template('calendar', 'part.editcalendar');
|
||||||
|
$tmpl->assign('new', true);
|
||||||
|
$tmpl->assign('calendar', $calendar);
|
||||||
|
$tmpl->printPage();
|
||||||
|
?>
|
|
@ -34,6 +34,6 @@ $calendarid = $_POST['id'];
|
||||||
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']);
|
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']);
|
||||||
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
|
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
|
||||||
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
$calendar = OC_Calendar_Calendar::findCalendar($calendarid);
|
||||||
$tmpl = new OC_Template('calendar', 'part.calendar.row');
|
$tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
|
||||||
$tmpl->assign('calendar', $calendar);
|
$tmpl->assign('calendar', $calendar);
|
||||||
echo json_encode( array( "status" => "success", "data" => $tmpl->fetchPage() ));
|
echo json_encode( array( "status" => "success", "data" => $tmpl->fetchPage() ));
|
||||||
|
|
|
@ -200,6 +200,10 @@ Calendar={
|
||||||
},
|
},
|
||||||
events:[],
|
events:[],
|
||||||
loadEvents:function(year){
|
loadEvents:function(year){
|
||||||
|
if( typeof (year) == 'undefined') {
|
||||||
|
this.events = [];
|
||||||
|
year = Calendar.Date.current.getFullYear();
|
||||||
|
}
|
||||||
if( typeof (this.events[year]) == "undefined") {
|
if( typeof (this.events[year]) == "undefined") {
|
||||||
this.events[year] = []
|
this.events[year] = []
|
||||||
}
|
}
|
||||||
|
@ -213,7 +217,9 @@ Calendar={
|
||||||
$( "#parsingfail_dialog" ).dialog();
|
$( "#parsingfail_dialog" ).dialog();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Calendar.UI.events[year] = newevents[year];
|
if (typeof(newevents[year]) != 'undefined'){
|
||||||
|
Calendar.UI.events[year] = newevents[year];
|
||||||
|
}
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
Calendar.UI.updateView();
|
Calendar.UI.updateView();
|
||||||
});
|
});
|
||||||
|
@ -677,7 +683,7 @@ $(document).ready(function(){
|
||||||
$('#listview #more_after').click(Calendar.UI.List.renderMoreAfter);
|
$('#listview #more_after').click(Calendar.UI.List.renderMoreAfter);
|
||||||
});
|
});
|
||||||
//event vars
|
//event vars
|
||||||
Calendar.UI.loadEvents(Calendar.Date.current.getFullYear());
|
Calendar.UI.loadEvents();
|
||||||
|
|
||||||
function oc_cal_switch2today() {
|
function oc_cal_switch2today() {
|
||||||
Calendar.Date.current = new Date();
|
Calendar.Date.current = new Date();
|
||||||
|
@ -718,23 +724,40 @@ function oc_cal_calender_activation(checkbox, calendarid)
|
||||||
$.post(oc_webroot + "/apps/calendar/ajax/activation.php", { calendarid: calendarid, active: checkbox.checked?1:0 },
|
$.post(oc_webroot + "/apps/calendar/ajax/activation.php", { calendarid: calendarid, active: checkbox.checked?1:0 },
|
||||||
function(data) {
|
function(data) {
|
||||||
checkbox.checked = data == 1;
|
checkbox.checked = data == 1;
|
||||||
Calendar.UI.loadEvents(Calendar.Date.current.getFullYear());
|
Calendar.UI.loadEvents();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function oc_cal_editcalendar(object, calendarid){
|
function oc_cal_editcalendar(object, calendarid){
|
||||||
$(object).closest('tr').load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid);
|
var tr = $(document.createElement('tr'))
|
||||||
|
.load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid);
|
||||||
|
$(object).closest('tr').after(tr).hide();
|
||||||
}
|
}
|
||||||
function oc_cal_editcalendar_submit(button, calendarid){
|
function oc_cal_newcalendar(object){
|
||||||
|
var tr = $(document.createElement('tr'))
|
||||||
|
.load(oc_webroot + "/apps/calendar/ajax/newcalendar.php");
|
||||||
|
$(object).closest('tr').after(tr).hide();
|
||||||
|
}
|
||||||
|
function oc_cal_calendar_submit(button, calendarid){
|
||||||
var displayname = $("#displayname_"+calendarid).val();
|
var displayname = $("#displayname_"+calendarid).val();
|
||||||
var active = $("#active_"+calendarid+":checked").length;
|
var active = $("#active_"+calendarid+":checked").length;
|
||||||
var description = $("#description_"+calendarid).val();
|
var description = $("#description_"+calendarid).val();
|
||||||
var calendarcolor = $("#calendarcolor_"+calendarid).val();
|
var calendarcolor = $("#calendarcolor_"+calendarid).val();
|
||||||
|
|
||||||
$.post("ajax/updatecalendar.php", { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
|
var url;
|
||||||
|
if (calendarid == 'new'){
|
||||||
|
url = "ajax/createcalendar.php";
|
||||||
|
}else{
|
||||||
|
url = "ajax/updatecalendar.php";
|
||||||
|
}
|
||||||
|
$.post(url, { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor },
|
||||||
function(data){
|
function(data){
|
||||||
if(data.error == "true"){
|
if(data.error == "true"){
|
||||||
}else{
|
}else{
|
||||||
$(button).closest('tr').html(data.data)
|
$(button).closest('tr').prev().html(data.data).show().next().remove();
|
||||||
|
Calendar.UI.loadEvents();
|
||||||
}
|
}
|
||||||
}, 'json');
|
}, 'json');
|
||||||
}
|
}
|
||||||
|
function oc_cal_calendar_cancel(button, calendarid){
|
||||||
|
$(button).closest('tr').prev().show().next().remove();
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,11 @@ for($i = 0; $i < count($option_calendars); $i++){
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">
|
||||||
|
<a href="#" onclick="oc_cal_newcalendar(this);"><?php echo $l->t('New Calendar') ?></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$( "#choosecalendar_dialog" ).dialog({
|
$( "#choosecalendar_dialog" ).dialog({
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<td id="editcalendar_dialog" title="<?php echo $l->t("Edit calendar"); ?>" colspan="4">
|
<td id="<?php echo $_['new'] ? 'new' : 'edit' ?>calendar_dialog" title="<?php echo $_['new'] ? $l->t("New calendar") : $l->t("Edit calendar"); ?>" colspan="4">
|
||||||
<table width="100%" style="border: 0;">
|
<table width="100%" style="border: 0;">
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $l->t('Displayname') ?></th>
|
<th><?php echo $l->t('Displayname') ?></th>
|
||||||
|
@ -6,15 +6,17 @@
|
||||||
<input id="displayname_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['displayname'] ?>">
|
<input id="displayname_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['displayname'] ?>">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php if (!$_['new']): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td>
|
<td>
|
||||||
<input id="active_<?php echo $_['calendar']['id'] ?>" type="checkbox"<?php echo ($_['calendar']['active'] ? ' checked="checked"' : '' ) ?>>
|
<input id="active_<?php echo $_['calendar']['id'] ?>" type="checkbox"<?php echo $_['calendar']['active'] ? ' checked="checked"' : '' ?>>
|
||||||
<label for="active_<?php echo $_['calendar']['id'] ?>">
|
<label for="active_<?php echo $_['calendar']['id'] ?>">
|
||||||
<?php echo $l->t('Active') ?>
|
<?php echo $l->t('Active') ?>
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $l->t('Description') ?></th>
|
<th><?php echo $l->t('Description') ?></th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -28,5 +30,6 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<input style="float: left;" type="button" onclick="oc_cal_editcalendar_submit(this, <?php echo $_['calendar']['id'] ?>);" value="<?php echo $l->t("Submit"); ?>">
|
<input style="float: left;" type="button" onclick="oc_cal_calendar_submit(this, <?php echo $_['new'] ? "'new'" : $_['calendar']['id'] ?>);" value="<?php echo $_['new'] ? $l->t("Save") : $l->t("Submit"); ?>">
|
||||||
|
<input style="float: left;" type="button" onclick="oc_cal_calendar_cancel(this, <?php echo $_['new'] ? "'new'" : $_['calendar']['id'] ?>);" value="<?php echo $l->t("Cancel"); ?>">
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue