diff options
author | Georg Ehrke <georg.stefan.germany@googlemail.com> | 2011-08-28 20:13:40 +0200 |
---|---|---|
committer | Georg Ehrke <georg.stefan.germany@googlemail.com> | 2011-08-28 20:13:40 +0200 |
commit | ca08ccb61c143bfbe821c7fbc5b136a2a8dfa293 (patch) | |
tree | 1cfa4a90577ede9745fbb10ffa1e21e71bdbf161 /apps | |
parent | 84761b1518c54e9f43eae3a831c9456c0daad3ca (diff) | |
download | nextcloud-server-ca08ccb61c143bfbe821c7fbc5b136a2a8dfa293.tar.gz nextcloud-server-ca08ccb61c143bfbe821c7fbc5b136a2a8dfa293.zip |
first add event function in calendar app
Diffstat (limited to 'apps')
-rwxr-xr-x[-rw-r--r--] | apps/calendar/ajax/choosecalendar.php | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | apps/calendar/ajax/editeventform.php | 0 | ||||
-rwxr-xr-x | apps/calendar/ajax/newevent.php | 143 | ||||
-rwxr-xr-x[-rw-r--r--] | apps/calendar/ajax/neweventform.php | 0 | ||||
-rw-r--r-- | apps/calendar/l10n/xgettextfiles | 1 | ||||
-rwxr-xr-x | apps/calendar/templates/calendar.php | 16 | ||||
-rw-r--r-- | apps/calendar/templates/part.choosecalendar.php | 11 | ||||
-rw-r--r-- | apps/calendar/templates/part.newevent.php | 75 |
8 files changed, 224 insertions, 22 deletions
diff --git a/apps/calendar/ajax/choosecalendar.php b/apps/calendar/ajax/choosecalendar.php index 03765dabe9d..03765dabe9d 100644..100755 --- a/apps/calendar/ajax/choosecalendar.php +++ b/apps/calendar/ajax/choosecalendar.php diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php index 8d1c8b69c3f..8d1c8b69c3f 100644..100755 --- a/apps/calendar/ajax/editeventform.php +++ b/apps/calendar/ajax/editeventform.php diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php index a87eab02af5..b51208f680a 100755 --- a/apps/calendar/ajax/newevent.php +++ b/apps/calendar/ajax/newevent.php @@ -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); +} +?>
\ No newline at end of file diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php index b1cb6d5b816..b1cb6d5b816 100644..100755 --- a/apps/calendar/ajax/neweventform.php +++ b/apps/calendar/ajax/neweventform.php diff --git a/apps/calendar/l10n/xgettextfiles b/apps/calendar/l10n/xgettextfiles index 37f68b82062..c94fb9d8b2e 100644 --- a/apps/calendar/l10n/xgettextfiles +++ b/apps/calendar/l10n/xgettextfiles @@ -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
\ No newline at end of file diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php index b9b11f8a274..8690d7a45d2 100755 --- a/apps/calendar/templates/calendar.php +++ b/apps/calendar/templates/calendar.php @@ -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>
\ No newline at end of file diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index 487ee7645d7..0aef52b4388 100644 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -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> diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php index bc19042f10c..837e032c734 100644 --- a/apps/calendar/templates/part.newevent.php +++ b/apps/calendar/templates/part.newevent.php @@ -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>
\ No newline at end of file |