aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2011-09-15 21:20:42 +0200
committerBart Visscher <bartv@thisnet.nl>2011-09-16 00:21:19 +0200
commit15559d3e8889e763f49a66e2df15169ae3164577 (patch)
treea957156b4c2e40da41b8688ab2f49bf46dc40e6c /apps
parentb413dcfa7cb1906b674234569de2e494a3df07bc (diff)
downloadnextcloud-server-15559d3e8889e763f49a66e2df15169ae3164577.tar.gz
nextcloud-server-15559d3e8889e763f49a66e2df15169ae3164577.zip
First implementation of edit event
Diffstat (limited to 'apps')
-rw-r--r--apps/calendar/ajax/editevent.php33
-rw-r--r--apps/calendar/ajax/editeventform.php67
-rw-r--r--apps/calendar/ajax/newevent.php130
-rw-r--r--apps/calendar/ajax/neweventform.php29
-rw-r--r--apps/calendar/js/calendar.js55
-rw-r--r--apps/calendar/lib/object.php210
-rw-r--r--apps/calendar/templates/part.editevent.php19
-rw-r--r--apps/calendar/templates/part.eventform.php30
-rw-r--r--apps/calendar/templates/part.newevent.php63
9 files changed, 400 insertions, 236 deletions
diff --git a/apps/calendar/ajax/editevent.php b/apps/calendar/ajax/editevent.php
index 6182a60e611..54a9897b959 100644
--- a/apps/calendar/ajax/editevent.php
+++ b/apps/calendar/ajax/editevent.php
@@ -2,21 +2,42 @@
/*************************************************
* 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 *
+ * (c) Copyright 2011 Bart Visscher *
* License: GNU AFFERO GENERAL PUBLIC LICENSE *
* *
* <http://www.gnu.org/licenses/> *
* 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>');
+}
+
+$errarr = OC_Calendar_Object::validateRequest($_POST);
+if($errarr){
+ //show validate errors
+ $errarr["error"] = "true";
+ echo json_encode($errarr);
+ exit;
+}else{
+ $id = $_POST['id'];
+ $data = OC_Calendar_Object::find($id);
+ if (!$data)
+ {
+ echo json_encode(array("error"=>"true"));
+ exit;
+ }
+ $vcalendar = Sabre_VObject_Reader::read($data['calendardata']);
+ OC_Calendar_Object::updateVCalendarFromRequest($_POST, $vcalendar);
+ $result = OC_Calendar_Object::edit($id, $vcalendar->serialize());
+ echo json_encode(array("success"=>"true"));
+}
?>
diff --git a/apps/calendar/ajax/editeventform.php b/apps/calendar/ajax/editeventform.php
index 8d1c8b69c3f..132bb4ae74c 100644
--- a/apps/calendar/ajax/editeventform.php
+++ b/apps/calendar/ajax/editeventform.php
@@ -1 +1,68 @@
+<?php
+/*************************************************
+ * ownCloud - Calendar Plugin *
+ * *
+ * (c) Copyright 2011 Bart Visscher *
+ * License: GNU AFFERO GENERAL PUBLIC LICENSE *
+ * *
+ * If you are not able to view the License, *
+ * <http://www.gnu.org/licenses/> *
+ * 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>');
+}
+
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+$categories = OC_Calendar_Object::getCategoryOptions($l10n);
+$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
+
+$id = $_GET['id'];
+$data = OC_Calendar_Object::find($id);
+$object = Sabre_VObject_Reader::read($data['calendardata']);
+$vevent = $object->VEVENT;
+$dtstart = $vevent->DTSTART;
+$dtend = $vevent->DTEND;
+switch($dtstart->getDateType()) {
+ case Sabre_VObject_Element_DateTime::LOCALTZ:
+ $startdate = $dtstart->getDateTime()->format('d-m-Y');
+ $starttime = $dtstart->getDateTime()->format('H:i');
+ $enddate = $dtend->getDateTime()->format('d-m-Y');
+ $endtime = $dtend->getDateTime()->format('H:i');
+ $allday = false;
+ break;
+}
+
+$summary = isset($vevent->SUMMARY) ? $vevent->SUMMARY->value : '';
+$location = isset($vevent->LOCATION) ? $vevent->LOCATION->value : '';
+$category = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
+$repeat = isset($vevent->CATEGORY) ? $vevent->CATEGORY->value : '';
+$description = isset($vevent->DESCRIPTION) ? $vevent->DESCRIPTION->value : '';
+
+$tmpl = new OC_Template('calendar', 'part.editevent');
+$tmpl->assign('id', $id);
+$tmpl->assign('calendars', $calendars);
+$tmpl->assign('categories', $categories);
+$tmpl->assign('repeat_options', $repeat_options);
+
+$tmpl->assign('title', $summary);
+$tmpl->assign('location', $location);
+$tmpl->assign('category', $category);
+$tmpl->assign('calendar', $data['calendarid']);
+$tmpl->assign('allday', $allday);
+$tmpl->assign('startdate', $startdate);
+$tmpl->assign('starttime', $starttime);
+$tmpl->assign('enddate', $enddate);
+$tmpl->assign('endtime', $endtime);
+$tmpl->assign('repeat', $repeat);
+$tmpl->assign('description', $description);
+$tmpl->printpage();
+?>
diff --git a/apps/calendar/ajax/newevent.php b/apps/calendar/ajax/newevent.php
index b81190fd642..fb3745d0525 100644
--- a/apps/calendar/ajax/newevent.php
+++ b/apps/calendar/ajax/newevent.php
@@ -19,139 +19,23 @@
* 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 = str_replace("option_","", $_POST["cal"]);
-$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){
+$errarr = OC_Calendar_Object::validateRequest($_POST);
+if($errarr){
//show validate errors
$errarr["error"] = "true";
echo json_encode($errarr);
exit;
}else{
- $data = "BEGIN:VCALENDAR\nPRODID:ownCloud Calendar\nVERSION:2.0\n";
- $timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
- $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 != $l->t("None")){
- $data .= "CATEGORIES:" . $cat . "\n";
- }*/
- /*if($repeat == "true"){
- $data .= "RRULE:" . $repeat . "\n";
- }*/
- $data .= "END:VEVENT\nEND:VCALENDAR";
- $result = OC_Calendar_Object::add($cal, $data);
+ $cal = $_POST['calendar'];
+ $vcalendar = OC_Calendar_Object::createVCalendarFromRequest($_POST);
+ $result = OC_Calendar_Object::add($cal, $vcalendar->serialize());
echo json_encode(array("success"=>"true"));
}
?>
diff --git a/apps/calendar/ajax/neweventform.php b/apps/calendar/ajax/neweventform.php
index d331be40e15..1d8a61dffd2 100644
--- a/apps/calendar/ajax/neweventform.php
+++ b/apps/calendar/ajax/neweventform.php
@@ -26,33 +26,8 @@ if(!OC_USER::isLoggedIn()) {
}
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
-$categories = array(
- $l10n->t('None'),
- $l10n->t('Birthday'),
- $l10n->t('Business'),
- $l10n->t('Call'),
- $l10n->t('Clients'),
- $l10n->t('Deliverer'),
- $l10n->t('Holidays'),
- $l10n->t('Ideas'),
- $l10n->t('Journey'),
- $l10n->t('Jubilee'),
- $l10n->t('Meeting'),
- $l10n->t('Other'),
- $l10n->t('Personal'),
- $l10n->t('Projects'),
- $l10n->t('Questions'),
- $l10n->t('Work'),
-);
-$repeat_options = array(
- 'doesnotrepeat' => $l10n->t('Does not repeat'),
- 'daily' => $l10n->t('Daily'),
- 'weekly' => $l10n->t('Weekly'),
- 'weekday' => $l10n->t('Every Weekday'),
- 'biweekly' => $l10n->t('Bi-Weekly'),
- 'monthly' => $l10n->t('Monthly'),
- 'yearly' => $l10n->t('Yearly'),
-);
+$categories = OC_Calendar_Object::getCategoryOptions($l10n);
+$repeat_options = OC_Calendar_Object::getRepeatOptions($l10n);
$startday = substr($_GET['d'], 0, 2);
$startmonth = substr($_GET['d'], 2, 2);
$startyear = substr($_GET['d'], 4, 4);
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 04d709b6ae2..ad44c5d4bc0 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -273,9 +273,21 @@ Calendar={
.addClass('event')
.data('event_info', event)
.hover(this.createEventPopup,
- this.hideEventPopup);
+ this.hideEventPopup)
+ .click(this.editEventPopup);
eventcontainer.append(event_holder);
},
+ editEventPopup:function(event){
+ event.stopPropagation();
+ var event_data = $(this).data('event_info');
+ var id = event_data.id;
+ if(oc_cal_opendialog == 0){
+ $("#dialog_holder").load(oc_webroot + "/apps/calendar/ajax/editeventform.php?id="+id);
+ oc_cal_opendialog = 1;
+ }else{
+ alert(t("calendar", "You can't open more than one dialog per site!"));
+ }
+ },
createEventPopup:function(e){
var popup = $(this).data('popup');
if (!popup){
@@ -764,3 +776,44 @@ function oc_cal_newevent(selector, time){
alert(t("calendar", "You can't open more than one dialog per site!"));
}
}
+
+function validate_event_form(url){
+ var post = $( "#event_form" ).serialize();
+ $("#errorbox").html("");
+ $.post(url, post,
+ function(data){
+ if(data.error == "true"){
+ 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!";
+ }
+ $("#errorbox").html(output);
+ }else{
+ window.location.reload();
+ }
+ if(data.success == true){
+ location.reload();
+ }
+ },"json");
+}
diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php
index aa30c7305dc..ab29307ce13 100644
--- a/apps/calendar/lib/object.php
+++ b/apps/calendar/lib/object.php
@@ -288,4 +288,214 @@ class OC_Calendar_Object{
return null;
}
}
+
+ public static function getCategoryOptions($l10n)
+ {
+ return array(
+ $l10n->t('None'),
+ $l10n->t('Birthday'),
+ $l10n->t('Business'),
+ $l10n->t('Call'),
+ $l10n->t('Clients'),
+ $l10n->t('Deliverer'),
+ $l10n->t('Holidays'),
+ $l10n->t('Ideas'),
+ $l10n->t('Journey'),
+ $l10n->t('Jubilee'),
+ $l10n->t('Meeting'),
+ $l10n->t('Other'),
+ $l10n->t('Personal'),
+ $l10n->t('Projects'),
+ $l10n->t('Questions'),
+ $l10n->t('Work'),
+ );
+ }
+
+ public static function getRepeatOptions($l10n)
+ {
+ return array(
+ 'doesnotrepeat' => $l10n->t('Does not repeat'),
+ 'daily' => $l10n->t('Daily'),
+ 'weekly' => $l10n->t('Weekly'),
+ 'weekday' => $l10n->t('Every Weekday'),
+ 'biweekly' => $l10n->t('Bi-Weekly'),
+ 'monthly' => $l10n->t('Monthly'),
+ 'yearly' => $l10n->t('Yearly'),
+ );
+ }
+ public static function validateRequest($request)
+ {
+ $errnum = 0;
+ $errarr = array('title'=>'false', 'cal'=>'false', 'from'=>'false', 'fromtime'=>'false', 'to'=>'false', 'totime'=>'false', 'endbeforestart'=>'false');
+ if($request['title'] == ''){
+ $errarr['title'] = 'true';
+ $errnum++;
+ }
+ $calendar = OC_Calendar_Calendar::findCalendar($request['calendar']);
+ if($calendar['userid'] != OC_User::getUser()){
+ $errarr['cal'] = 'true';
+ $errnum++;
+ }
+ $fromday = substr($request['from'], 0, 2);
+ $frommonth = substr($request['from'], 3, 2);
+ $fromyear = substr($request['from'], 6, 4);
+ if(!checkdate($frommonth, $fromday, $fromyear)){
+ $errarr['from'] = 'true';
+ $errnum++;
+ }
+ $allday = isset($request['allday']);
+ if(!$allday && self::checkTime(urldecode($request['fromtime']))) {
+ $errarr['fromtime'] = 'true';
+ $errnum++;
+ }
+
+ $today = substr($request['to'], 0, 2);
+ $tomonth = substr($request['to'], 3, 2);
+ $toyear = substr($request['to'], 6, 4);
+ if(!checkdate($tomonth, $today, $toyear)){
+ $errarr['to'] = 'true';
+ $errnum++;
+ }
+ ;
+ if(!$allday && self::checkTime(urldecode($request['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){
+ list($tohours, $tominutes) = explode(':', $request['totime']);
+ list($fromhours, $fromminutes) = explode(':', $request['fromtime']);
+ if($tohours < $fromhours){
+ $errarr['endbeforestart'] = 'true';
+ $errnum++;
+ }
+ if($tohours == $fromhours && $tominutes < $fromminutes){
+ $errarr['endbeforestart'] = 'true';
+ $errnum++;
+ }
+ }
+ if ($errnum)
+ {
+ return $errarr;
+ }
+ return false;
+ }
+
+ protected static function checkTime($time)
+ {
+ list($hours, $minutes) = explode(':', $time);
+ return empty($time)
+ || $hours < 0 || $hours > 24
+ || $minutes < 0 || $minutes > 60;
+ }
+
+ public static function createVCalendarFromRequest($request)
+ {
+ $vcalendar = new Sabre_VObject_Component('VCALENDAR');
+ $vcalendar->add('PRODID', 'ownCloud Calendar');
+ $vcalendar->add('VERSION', '2.0');
+
+ $now = new DateTime();
+
+ $vevent = new Sabre_VObject_Component('VEVENT');
+ $vcalendar->add($vevent);
+
+ $created = new Sabre_VObject_Element_DateTime('CREATED');
+ $created->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
+ $vevent->add($created);
+
+ return self::updateVCalendarFromRequest($request, $vcalendar);
+ }
+
+ public static function updateVCalendarFromRequest($request, $vcalendar)
+ {
+ $title = $request["title"];
+ $location = $request["location"];
+ $cat = $request["category"];
+ $allday = isset($request["allday"]);
+ $from = $request["from"];
+ $fromtime = $request["fromtime"];
+ $to = $request["to"];
+ $totime = $request["totime"];
+ $description = $request["description"];
+ //$repeat = $request["repeat"];
+ /*switch($request["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";
+
+ $now = new DateTime();
+ $vevent = $vcalendar->VEVENT[0];
+
+ $last_modified = new Sabre_VObject_Element_DateTime('LAST-MODIFIED');
+ $last_modified->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
+ $vevent->__set('LAST-MODIFIED', $last_modified);
+
+ $dtstamp = new Sabre_VObject_Element_DateTime('DTSTAMP');
+ $dtstamp->setDateTime($now, Sabre_VObject_Element_DateTime::UTC);
+ $vevent->DTSTAMP = $dtstamp;
+
+ $vevent->SUMMARY = $title;
+
+ $dtstart = new Sabre_VObject_Element_DateTime('DTSTART');
+ $dtend = new Sabre_VObject_Element_DateTime('DTEND');
+ if($allday){
+ $start = new DateTime($from);
+ $end = new DateTime($to.' +1 day');
+ $dtstart->setDateTime($start, Sabre_VObject_Element_DateTime::DATE);
+ $dtend->setDateTime($end, Sabre_VObject_Element_DateTime::DATE);
+ }else{
+ $timezone = OC_Preferences::getValue(OC_USER::getUser(), "calendar", "timezone", "Europe/London");
+ $timezone = new DateTimeZone($timezone);
+ $start = new DateTime($from.' '.$fromtime, $timezone);
+ $end = new DateTime($to.' '.$totime, $timezone);
+ $dtstart->setDateTime($start, Sabre_VObject_Element_DateTime::LOCALTZ);
+ $dtend->setDateTime($end, Sabre_VObject_Element_DateTime::LOCALTZ);
+ }
+ $vevent->DTSTART = $dtstart;
+ $vevent->DTEND = $dtend;
+
+ if($location != ""){
+ $vevent->LOCATION = $location;
+ }
+
+ if($description != ""){
+ $des = str_replace("\n","\\n", $description);
+ $vevent->DESCRIPTION = $des;
+ }
+
+ if($cat != ""){
+ $vevent->CATEGORIES = $cat;
+ }
+
+ /*if($repeat == "true"){
+ $vevent->RRULE = $repeat;
+ }*/
+
+ return $vcalendar;
+ }
}
diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php
index e722515c9d0..7fbb75756cd 100644
--- a/apps/calendar/templates/part.editevent.php
+++ b/apps/calendar/templates/part.editevent.php
@@ -1,8 +1,12 @@
<div id="editevent" title="<?php echo $l->t("Edit an event");?>">
+ <form id="event_form">
+ <input type="hidden" name="id" value="<?php echo $_['id'] ?>">
<?php echo $this->inc("part.eventform"); ?>
- <span id="editevent_actions">
- <input type="button" style="float: left;" value="<?php echo $l->t("Submit");?>">
+ <div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
+ <span id="actions">
+ <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_event_form('ajax/editevent.php');">
</span>
+ </form>
</div>
<script type="text/javascript">
$( "#editevent" ).dialog({
@@ -14,8 +18,7 @@
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'
@@ -27,13 +30,13 @@
if(document.getElementById("totime").disabled == true) {
document.getElementById("fromtime").disabled = false;
document.getElementById("totime").disabled = false;
- document.getElementById("fromtime").style.color = "#333";
- document.getElementById("totime").style.color = "#333";
+ $("#fromtime").css('color', "#333");
+ $("#totime").css('color', "#333");
} else {
document.getElementById("fromtime").disabled = true;
document.getElementById("totime").disabled = true;
- document.getElementById("fromtime").style.color = "#A9A9A9";
- document.getElementById("totime").style.color = "#A9A9A9";
+ $("#fromtime").css('color', "#A9A9A9");
+ $("#totime").css('color', "#A9A9A9");
}
}
</script>
diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php
index 450f6417624..4c3024e1deb 100644
--- a/apps/calendar/templates/part.eventform.php
+++ b/apps/calendar/templates/part.eventform.php
@@ -2,13 +2,13 @@
<tr>
<th width="75px"><?php echo $l->t("Title");?>:</th>
<td>
- <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" maxlength="100" id="newevent_title"/>
+ <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" value="<?php echo $_['title'] ?>" maxlength="100" name="title"/>
</td>
</tr>
<tr>
<th width="75px"><?php echo $l->t("Location");?>:</th>
<td>
- <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" maxlength="100" id="newevent_location" />
+ <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo $_['location'] ?>" maxlength="100" name="location" />
</td>
</tr>
</table>
@@ -16,19 +16,19 @@
<tr>
<th width="75px"><?php echo $l->t("Category");?>:</th>
<td>
- <select class="formselect" id="formcategorie_select" style="width:140px;">
+ <select style="width:140px;" name="category">
<?php
foreach($_['categories'] as $category){
- echo '<option value="' . $category . '">' . $category . '</option>';
+ echo '<option value="' . $category . '"' . ($_['category'] == $category ? ' selected="selected"' : '') . '>' . $category . '</option>';
}
?>
</select></td>
<th width="75px">&nbsp;&nbsp;&nbsp;<?php echo $l->t("Calendar");?>:</th>
<td>
- <select class="formselect" id="formcalendar_select" style="width:140px;" id="newevent_cal">
+ <select style="width:140px;" name="calendar">
<?php
foreach($_['calendars'] as $calendar){
- echo '<option id="option_' . $calendar['id'] . '">' . $calendar['displayname'] . '</option>';
+ echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>';
}
?>
</select></td>
@@ -39,34 +39,34 @@
<tr>
<th width="75px"></th>
<td>
- <input onclick="lock_time();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="newcalendar_allday_checkbox">
+ <input onclick="lock_time();" type="checkbox"<?php if($_['allday']){echo 'checked="checked"';} ?> id="allday_checkbox" name="allday">
<?php if($_['allday']){echo '<script type="text/javascript">document.getElementById("fromtime").disabled = true;document.getElementById("totime").disabled = true;document.getElementById("fromtime").style.color = "#A9A9A9";document.getElementById("totime").style.color = "#A9A9A9";</script>';}?>
- <label for="newcalendar_allday_checkbox"><?php echo $l->t("All Day Event");?></label></td>
+ <label for="allday_checkbox"><?php echo $l->t("All Day Event");?></label></td>
</tr>
<tr>
<th width="75px"><?php echo $l->t("From");?>:</th>
<td>
- <input type="text" value="<?php echo $_['startdate'];?>" id="from">
+ <input type="text" value="<?php echo $_['startdate'];?>" name="from" id="from">
&nbsp;&nbsp;
- <input type="time" value="<?php echo $_['starttime'];?>" id="fromtime">
+ <input type="time" value="<?php echo $_['starttime'];?>" name="fromtime" id="fromtime">
</td><!--use jquery-->
</tr>
<tr>
<th width="75px"><?php echo $l->t("To");?>:</th>
<td>
- <input type="text" value="<?php echo $_['enddate'];?>" id="to">
+ <input type="text" value="<?php echo $_['enddate'];?>" name="to" id="to">
&nbsp;&nbsp;
- <input type="time" value="<?php echo $_['endtime'];?>" id="totime">
+ <input type="time" value="<?php echo $_['endtime'];?>" name="totime" id="totime">
</td><!--use jquery-->
</tr><!--
<tr>
<th width="75px"><?php echo $l->t("Repeat");?>:</th>
<td>
- <select class="formselect" id="formrepeat_select" style="width:350px;">
+ <select name="repeat" style="width:350px;">
<?php
foreach($_['repeat_options'] as $id => $label){
- echo '<option id="repeat_' . $id . '">' . $label . '</option>';
+ echo '<option value="' . $id . '"' . ($_['repeat'] == $id ? ' selected="selected"' : '') . '>' . $label . '</option>';
}
?>
</select></td>
@@ -83,6 +83,6 @@
<table>
<tr>
<th width="75px" style="vertical-align: top;"><?php echo $l->t("Description");?>:</th>
- <td><textarea style="width:350px;height: 150px;"placeholder="<?php echo $l->t("Description of the Event");?>" id="description"></textarea></td>
+ <td><textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo $_['description'] ?></textarea></td>
</tr>
</table>
diff --git a/apps/calendar/templates/part.newevent.php b/apps/calendar/templates/part.newevent.php
index a1c48d2c22b..cff8d4412b2 100644
--- a/apps/calendar/templates/part.newevent.php
+++ b/apps/calendar/templates/part.newevent.php
@@ -1,9 +1,9 @@
<div id="newevent" title="<?php echo $l->t("Create a new event");?>">
- <form>
+ <form id="event_form">
<?php echo $this->inc("part.eventform"); ?>
<div style="width: 100%;text-align: center;color: #FF1D1D;" id="errorbox"></div>
- <span id="newcalendar_actions">
- <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_newevent_form();">
+ <span id="actions">
+ <input type="button" class="submit" style="float: left;" value="<?php echo $l->t("Submit");?>" onclick="validate_event_form('ajax/newevent.php');">
</span>
</form>
</div>
@@ -29,62 +29,13 @@
if(document.getElementById("totime").disabled == true) {
document.getElementById("fromtime").disabled = false;
document.getElementById("totime").disabled = false;
- document.getElementById("fromtime").style.color = "#333";
- document.getElementById("totime").style.color = "#333";
+ $("#fromtime").css('color', "#333");
+ $("#totime").css('color', "#333");
} else {
document.getElementById("fromtime").disabled = true;
document.getElementById("totime").disabled = true;
- document.getElementById("fromtime").style.color = "#A9A9A9";
- document.getElementById("totime").style.color = "#A9A9A9";
+ $("#fromtime").css('color', "#A9A9A9");
+ $("#totime").css('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("formcategorie_select").options[document.getElementById("formcategorie_select").selectedIndex].value;
- var newevent_cal = document.getElementById("formcalendar_select").options[document.getElementById("formcalendar_select").selectedIndex].id;
- 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();
- }
- if(data.success == true){
- location.reload();
- }
- },"json");
- }
</script>