mirror of
https://github.com/nextcloud/server.git
synced 2026-03-26 04:14:20 -04:00
first add event function in calendar app
This commit is contained in:
parent
84761b1518
commit
ca08ccb61c
8 changed files with 224 additions and 22 deletions
0
apps/calendar/ajax/choosecalendar.php
Normal file → Executable file
0
apps/calendar/ajax/choosecalendar.php
Normal file → Executable file
0
apps/calendar/ajax/editeventform.php
Normal file → Executable file
0
apps/calendar/ajax/editeventform.php
Normal file → Executable file
|
|
@ -18,6 +18,145 @@
|
|||
* 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>");
|
||||
}
|
||||
//short variables
|
||||
$title = $_POST["title"];
|
||||
$location = $_POST["location"];
|
||||
$cat = $_POST["cat"];
|
||||
$cal = $_POST["cal"];
|
||||
$cal = "1";
|
||||
$allday = $_POST["allday"];
|
||||
$from = $_POST["from"];
|
||||
$fromtime = $_POST["fromtime"];
|
||||
$to = $_POST["to"];
|
||||
$totime = $_POST["totime"];
|
||||
$description = $_POST["description"];
|
||||
$repeat = $_POST["repeat"];
|
||||
/*switch($_POST["repeatfreq"]){
|
||||
case "DAILY":
|
||||
$repeatfreq = "DAILY";
|
||||
case "WEEKLY":
|
||||
$repeatfreq = "WEEKLY";
|
||||
case "WEEKDAY":
|
||||
$repeatfreq = "DAILY;BYDAY=MO,TU,WE,TH,FR"; //load weeksdayss from userconfig when weekdays are choosable
|
||||
case "":
|
||||
$repeatfreq = "";
|
||||
case "":
|
||||
$repeatfreq = "";
|
||||
case "":
|
||||
$repeatfreq = "";
|
||||
default:
|
||||
$repeat = "false";
|
||||
}*/
|
||||
$repeat = "false";
|
||||
//validate variables
|
||||
$errnum = 0;
|
||||
$errarr = array("title"=>"false", "cal"=>"false", "from"=>"false", "fromtime"=>"false", "to"=>"false", "totime"=>"false", "endbeforestart"=>"false");
|
||||
if($title == ""){
|
||||
$errarr["title"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
$calendar = OC_Calendar_Calendar::findCalendar($cal);
|
||||
if($calendar["userid"] != OC_User::getUser()){
|
||||
$errarr["cal"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
$fromday = substr($_POST["from"], 0, 2);
|
||||
$frommonth = substr($_POST["from"], 3, 2);
|
||||
$fromyear = substr($_POST["from"], 6, 4);
|
||||
if(!checkdate($frommonth, $fromday, $fromyear)){
|
||||
$errarr["from"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
$fromhours = substr($_POST["fromtime"], 0, 2);
|
||||
$fromminutes = substr($_POST["fromtime"], 3, 2);
|
||||
if($fromhours > 24 || $fromminutes > 60 || $fromtime == ""){
|
||||
$errarr["fromtime"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
$today = substr($_POST["to"], 0, 2);
|
||||
$tomonth = substr($_POST["to"], 3, 2);
|
||||
$toyear = substr($_POST["to"], 6, 4);
|
||||
if(!checkdate($tomonth, $today, $toyear)){
|
||||
$errarr["to"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
$tohours = substr($_POST["totime"], 0, 2);
|
||||
$tominutes = substr($_POST["totime"], 3, 2);
|
||||
if($tohours > 24 || $tominutes > 60 || $totime == ""){
|
||||
$errarr["totime"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
if($today < $fromday && $frommonth == $tomonth && $fromyear == $toyear){
|
||||
$errarr["endbeforestart"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
if($today == $fromday && $frommonth > $tomonth && $fromyear == $toyear){
|
||||
$errarr["endbeforestart"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
if($today == $fromday && $frommonth == $tomonth && $fromyear > $toyear){
|
||||
$errarr["endbeforestart"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
if($fromday == $today && $frommonth == $tomonth && $fromyear == $toyear){
|
||||
if($tohours < $fromhours){
|
||||
$errarr["endbeforestart"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
if($tohours == $fromhours && $tominutes < $fromminutes){
|
||||
$errarr["endbeforestart"] = "true";
|
||||
$errnum++;
|
||||
}
|
||||
}
|
||||
if($errnum != 0){
|
||||
//show validate errors
|
||||
$errarr["error"] = "true";
|
||||
echo json_encode($errarr);
|
||||
exit;
|
||||
}else{
|
||||
$data = "BEGIN:VCALENDAR\nPRODID:ownCloud Calendar\nVERSION:2.0\n";
|
||||
if(OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone") == ""){
|
||||
$timezone = "Europe/London";
|
||||
}else{
|
||||
$timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone");
|
||||
}
|
||||
$created = date("Ymd") . "T" . date("His");
|
||||
$data .= "BEGIN:VEVENT\n";
|
||||
$data .= "CREATED:" . $created . "\nLAST-MODIFIED:" . $created . "\nDTSTAMP:" . $created . "\n";
|
||||
$data .= "SUMMARY:" . $title . "\n";
|
||||
if($allday == "true"){
|
||||
$start = $fromyear . $frommonth . $fromday;
|
||||
$unixend = mktime(0,0,0,$tomonth, $today, $toyear) + (24 * 60 * 60);
|
||||
$end = date("Ymd", $unixend);
|
||||
$data .= "DTSTART;VALUE=DATE:" . $start . "\n";
|
||||
$data .= "DTEND;VALUE=DATE:" . $end . "\n";
|
||||
}else{
|
||||
$start = $fromyear . $frommonth . $fromday . "T" . $fromhours . $fromminutes . "00";
|
||||
$end = $toyear . $tomonth . $today . "T" . $tohours . $tominutes . "00";
|
||||
$data .= "DTSTART;TZID=" . $timezone . ":" . $start . "\n";
|
||||
$data .= "DTEND;TZID=" . $timezone . ":" . $end . "\n";
|
||||
}
|
||||
if($location != ""){
|
||||
$data .= "LOCATION:" . $location . "\n";
|
||||
}
|
||||
if($description != ""){
|
||||
$des = str_replace("\n","\\n", $description);
|
||||
$data .= "DESCRIPTION:" . $des . "\n";
|
||||
}
|
||||
if($cat != "none"){
|
||||
$data .= "CATEGORIES:" . $cat . "\n";
|
||||
}
|
||||
if($repeat == "true"){
|
||||
$data .= "RRULE:" . $repeat . "\n";
|
||||
}
|
||||
$data .= "END:VEVENT\nEND:VCALENDAR";
|
||||
echo $data;
|
||||
$result = OC_Calendar_Calendar::addCalendarObject($cal, $data);
|
||||
}
|
||||
?>
|
||||
0
apps/calendar/ajax/neweventform.php
Normal file → Executable file
0
apps/calendar/ajax/neweventform.php
Normal file → Executable file
|
|
@ -3,5 +3,6 @@
|
|||
../templates/part.editevent.php
|
||||
../templates/part.eventinfo.php
|
||||
../templates/part.newevent.php
|
||||
../templates/part.choosecalendar.php
|
||||
../js/calendar.js
|
||||
../js/calendar_init.js
|
||||
|
|
@ -907,7 +907,7 @@
|
|||
<!-- Dialogs -->
|
||||
<div id="dialog_holder"></div>
|
||||
<div id="parsingfail_dialog" title="Parsing Fail">
|
||||
There was a fail, while parsing the file.
|
||||
<?php echo $l->t("There was a fail, while parsing the file."); ?>
|
||||
</div>
|
||||
<!-- End of Dialogs -->
|
||||
<script type="text/javascript">
|
||||
|
|
@ -938,6 +938,16 @@
|
|||
document.getElementById("listview_radio").value = listview_radio;
|
||||
document.getElementById("today_input").value = today_button_value;
|
||||
document.getElementById("choosecalendar_input").value = choosecalendar_value;
|
||||
document.getElementById("download_input").src = oc_webroot + "/core/img/actions/download.svg";
|
||||
//document.getElementById("download_input").src = oc_webroot + "/core/img/actions/download.svg";
|
||||
</script>
|
||||
<script type="text/javascript" id="js_events"></script>
|
||||
<script type="text/javascript" id="js_events">
|
||||
<?php
|
||||
//
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
</script>
|
||||
|
|
@ -1,10 +1,16 @@
|
|||
<div id="choosecalendar_dialog" title="<?php echo $l->t("Choose active calendars"); ?>">
|
||||
<table width="100%" style="border: 0;">
|
||||
<?php
|
||||
$option_calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
|
||||
for($i = 0; $i < count($option_calendars); $i++){
|
||||
echo "<input type=\"button\" id=\"button_" . $option_calendars[$i]["id"] . "\" value=\"" . $option_calendars[$i]["displayname"] . "\">";
|
||||
echo "<tr>";
|
||||
echo "<td width=\"20px\"><input id=\"checkbox_" . $option_calendars[$i]["id"] . "\" type=\"checkbox\"></td>";
|
||||
echo "<td><label for=\"checkbox_" . $option_calendars[$i]["id"] . "\">" . $option_calendars[$i]["displayname"] . "</label></td>";
|
||||
echo "<td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Download") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/download.svg\"></a></td><td width=\"20px\"><a style=\"display: block; opacity: 0.214133;\" href=\"#\" title=\"" . $l->t("Rename") . "\" class=\"action\"><img src=\"/owncloud/core/img/actions/rename.svg\"></a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<br /><br /><br />
|
||||
<input style="float: left;" type="button" onclick="oc_cal_choosecalendar_submit();" value="<?php echo $l->t("Submit"); ?>">
|
||||
</div>
|
||||
|
|
@ -20,7 +26,4 @@ for($i = 0; $i < count($option_calendars); $i++){
|
|||
}
|
||||
}
|
||||
});
|
||||
function highlight_button(id){
|
||||
document.getElementById("button_" + id).style.color = "#000000";
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,15 +1,16 @@
|
|||
<div id="newevent" title="<?php echo $l -> t("Create a new event");?>">
|
||||
<form id="newevent_form">
|
||||
<table id="newevent_table" width="100%">
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Title");?>:</td>
|
||||
<td>
|
||||
<input type="text" style="width:350px;" size="100" placeholder="<?php echo $l -> t("Title of the Event");?>" maxlength="100" />
|
||||
<input type="text" style="width:350px;" size="100" placeholder="<?php echo $l -> t("Title of the Event");?>" maxlength="100" id="newevent_title"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Location");?>:</td>
|
||||
<td>
|
||||
<input type="text" style="width:350px;" size="100" placeholder="<?php echo $l -> t("Location of the Event");?>" maxlength="100" />
|
||||
<input type="text" style="width:350px;" size="100" placeholder="<?php echo $l -> t("Location of the Event");?>" maxlength="100" id="newevent_location" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
@ -17,14 +18,14 @@
|
|||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Category");?>:</td>
|
||||
<td>
|
||||
<select class="formselect" id="formcategorie_select" style="width:140px;">
|
||||
<option>Coming soon</option><!--
|
||||
<select class="formselect" id="formcategorie_select" style="width:140px;" id="newevent_cat">
|
||||
<option>Coming soon</option>
|
||||
<option>Work</option>
|
||||
<option>Call</option>-->
|
||||
<option>Call</option>
|
||||
</select></td>
|
||||
<td width="75px"> <?php echo $l -> t("Calendar");?>:</td>
|
||||
<td>
|
||||
<select class="formselect" id="formcalendar_select" style="width:140px;">
|
||||
<select class="formselect" id="formcalendar_select" style="width:140px;" id="newevent_cal">
|
||||
<?php
|
||||
$option_calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
|
||||
for($i = 0; $i < count($option_calendars); $i++){
|
||||
|
|
@ -83,7 +84,7 @@
|
|||
|
||||
<input type="time" value="<?php echo $time . ":" . $minutes;?>" id="totime">
|
||||
</td><!--use jquery-->
|
||||
</tr>
|
||||
</tr><!--
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Repeat");?>:</td>
|
||||
<td>
|
||||
|
|
@ -96,28 +97,30 @@
|
|||
<option id="repeat_monthly"><?php echo $l->t("Monthly");?></option>
|
||||
<option id="repeat_yearly"><?php echo $l->t("Yearly");?></option>
|
||||
</select></td>
|
||||
</tr>
|
||||
</tr>-->
|
||||
</table>
|
||||
<hr>
|
||||
<table>
|
||||
<table><!--
|
||||
<tr>
|
||||
<td width="75px"><?php echo $l -> t("Attendees");?>:</td>
|
||||
<td style="height: 50px;"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
<hr>-->
|
||||
<table>
|
||||
<tr>
|
||||
<td width="75px" style="vertical-align: top;"><?php echo $l -> t("Description");?>:</td>
|
||||
<td> <textarea style="width:350px;height: 150px;"placeholder="<?php echo $l->t("Description of the Event");?>"></textarea></td>
|
||||
<td><textarea style="width:350px;height: 150px;"placeholder="<?php echo $l->t("Description of the Event");?>" id="description"></textarea></td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
|
||||
<span id="newcalendar_actions">
|
||||
<input type="button" style="float: left;" value="<?php echo $l -> t("Submit");?>">
|
||||
<input type="button" class="submit" style="float: left;" value="<?php echo $l -> t("Submit");?>" onclick="validate_newevent_form();">
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( "#newevent" ).dialog({
|
||||
$("#newevent").dialog({
|
||||
width : 500,
|
||||
close : function() {
|
||||
oc_cal_opendialog = 0;
|
||||
|
|
@ -147,4 +150,50 @@
|
|||
document.getElementById("totime").style.color = "#A9A9A9";
|
||||
}
|
||||
}
|
||||
function validate_newevent_form(){
|
||||
var newevent_title = document.getElementById("newevent_title").value;
|
||||
var newevent_location = document.getElementById("newevent_location").value;
|
||||
var newevent_cat;// = document.getElementById("newevent_cat").options[document.getElementById("newevent_cat").selectedIndex].value;
|
||||
var newevent_cal;// = document.getElementById("newevent_cal").options[document.getElementById("newevent_cal").selectedIndex].value;
|
||||
var newevent_allday = document.getElementById("newcalendar_allday_checkbox").checked;
|
||||
var newevent_from = document.getElementById("from").value;
|
||||
var newevent_fromtime = document.getElementById("fromtime").value;
|
||||
var newevent_to = document.getElementById("to").value;
|
||||
var newevent_totime = document.getElementById("totime").value;
|
||||
var newevent_description = document.getElementById("description").value;
|
||||
$.post("ajax/newevent.php", { title: newevent_title, location: newevent_location, cat: newevent_cat, cal: newevent_cal, allday: newevent_allday, from: newevent_from, fromtime: newevent_fromtime, to: newevent_to, totime: newevent_totime, description: newevent_description},
|
||||
function(data){
|
||||
if(data.error == "true"){
|
||||
document.getElementById("errorbox").innerHTML = "";
|
||||
var output = "Missing fields: <br />";
|
||||
if(data.title == "true"){
|
||||
output = output + "Title<br />";
|
||||
}
|
||||
if(data.cal == "true"){
|
||||
output = output + "Calendar<br />";
|
||||
}
|
||||
if(data.from == "true"){
|
||||
output = output + "From Date<br />";
|
||||
}
|
||||
if(data.fromtime == "true"){
|
||||
output = output + "From Time<br />";
|
||||
}
|
||||
if(data.to == "true"){
|
||||
output = output + "To Date<br />";
|
||||
}
|
||||
if(data.totime == "true"){
|
||||
output = output + "To Time<br />";
|
||||
}
|
||||
if(data.endbeforestart == "true"){
|
||||
output = "The event ends before it starts!";
|
||||
}
|
||||
if(data.dberror == "true"){
|
||||
output = "There was a database fail!";
|
||||
}
|
||||
document.getElementById("errorbox").innerHTML = output;
|
||||
}else{
|
||||
window.location.reload();
|
||||
}
|
||||
},"json");
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in a new issue