diff options
author | Florian Pritz <bluewind@xinu.at> | 2011-09-24 20:43:02 +0400 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2011-09-24 20:43:02 +0400 |
commit | 793e29e1245d079f89505294bef47f01c9111e8b (patch) | |
tree | 70c66381ebb5221547e881c99dc2b435e26e97e4 /apps/calendar | |
parent | f65d0e4f80eba0d24ee48f16a22d290fb1f334b3 (diff) | |
parent | 842ce24d2b17685c27eabdd2d0bb01899efdbc6f (diff) |
Merge branch 'working'
Diffstat (limited to 'apps/calendar')
-rw-r--r-- | apps/calendar/ajax/deleteevent.php | 30 | ||||
-rw-r--r-- | apps/calendar/js/calendar.js | 13 | ||||
-rw-r--r-- | apps/calendar/lib/object.php | 9 | ||||
-rw-r--r-- | apps/calendar/templates/part.editevent.php | 1 | ||||
-rw-r--r-- | apps/calendar/templates/part.eventform.php | 14 |
5 files changed, 58 insertions, 9 deletions
diff --git a/apps/calendar/ajax/deleteevent.php b/apps/calendar/ajax/deleteevent.php new file mode 100644 index 00000000000..08a0e1a1e26 --- /dev/null +++ b/apps/calendar/ajax/deleteevent.php @@ -0,0 +1,30 @@ +<?php +/** + * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +require_once('../../../lib/base.php'); + +$l10n = new OC_L10N('calendar'); + +if(!OC_USER::isLoggedIn()) { + die('<script type="text/javascript">document.location = oc_webroot;</script>'); +} + +$id = $_POST['id']; +$data = OC_Calendar_Object::find($id); +if (!$data) +{ + echo json_encode(array('status'=>'error')); + exit; +} +$calendar = OC_Calendar_Calendar::findCalendar($data['calendarid']); +if($calendar['userid'] != OC_User::getUser()){ + echo json_encode(array('status'=>'error')); + exit; +} +$result = OC_Calendar_Object::delete($id); +echo json_encode(array('status' => 'success')); +?> diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index 1a8bc499574..61a1945c343 100644 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -300,6 +300,19 @@ Calendar={ $('#dialog_holder').load(oc_webroot + '/apps/calendar/ajax/editeventform.php?id=' + id, Calendar.UI.startEventDialog); } }, + submitDeleteEventForm:function(url){ + var post = $( "#event_form" ).serialize(); + $("#errorbox").html(""); + $.post(url, post, function(data){ + if(data.status == 'success'){ + $('#event').dialog('destroy').remove(); + Calendar.UI.loadEvents(); + } else { + $("#errorbox").html("Deletion failed"); + } + + }, "json"); + }, validateEventForm:function(url){ var post = $( "#event_form" ).serialize(); $("#errorbox").html(""); diff --git a/apps/calendar/lib/object.php b/apps/calendar/lib/object.php index c4878dac651..0c7649776d5 100644 --- a/apps/calendar/lib/object.php +++ b/apps/calendar/lib/object.php @@ -115,7 +115,7 @@ class OC_Calendar_Object{ $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_objects SET objecttype=?,startdate=?,enddate=?,repeating=?,summary=?,calendardata=?, lastmodified = ? WHERE id = ?' ); $result = $stmt->execute(array($type,$startdate,$enddate,$repeating,$summary,$data,time(),$id)); - OC_Calendar_Calendar::touchCalendar($id); + OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); return true; } @@ -147,8 +147,10 @@ class OC_Calendar_Object{ * @return boolean */ public static function delete($id){ + $oldobject = self::find($id); $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*calendar_objects WHERE id = ?' ); $stmt->execute(array($id)); + OC_Calendar_Calendar::touchCalendar($oldobject['calendarid']); return true; } @@ -424,7 +426,7 @@ class OC_Calendar_Object{ { $title = $request["title"]; $location = $request["location"]; - $categories = $request["categories"]; + $categories = isset($request["categories"]) ? $request["categories"] : null; $allday = isset($request["allday"]); $from = $request["from"]; $fromtime = $request["fromtime"]; @@ -488,8 +490,7 @@ class OC_Calendar_Object{ } if($description != ""){ - $des = str_replace("\n","\\n", $description); - $vevent->DESCRIPTION = $des; + $vevent->DESCRIPTION = $description; }else{ unset($vevent->DESCRIPTION); } diff --git a/apps/calendar/templates/part.editevent.php b/apps/calendar/templates/part.editevent.php index 859828216b8..be637aeae55 100644 --- a/apps/calendar/templates/part.editevent.php +++ b/apps/calendar/templates/part.editevent.php @@ -5,6 +5,7 @@ <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="Calendar.UI.validateEventForm('ajax/editevent.php');"> + <input type="button" class="submit" style="float: left;" name="delete" value="<?php echo $l->t("Delete");?>" onclick="Calendar.UI.submitDeleteEventForm('ajax/deleteevent.php');"> </span> </form> </div> diff --git a/apps/calendar/templates/part.eventform.php b/apps/calendar/templates/part.eventform.php index 5b12407330a..5bb072cc23b 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");?>" value="<?php echo $_['title'] ?>" maxlength="100" name="title"/> + <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Title of the Event");?>" value="<?php echo isset($_['title']) ? $_['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");?>" value="<?php echo $_['location'] ?>" maxlength="100" name="location" /> + <input type="text" style="width:350px;" size="100" placeholder="<?php echo $l->t("Location of the Event");?>" value="<?php echo isset($_['location']) ? $_['location'] : '' ?>" maxlength="100" name="location" /> </td> </tr> </table> @@ -19,6 +19,7 @@ <select id="category" name="categories[]" multiple="multiple" title="<?php echo $l->t("Select category") ?>"> <?php foreach($_['category_options'] as $category){ + if (!isset($_['categories'])) {$_['categories'] = array();} echo '<option value="' . $category . '"' . (in_array($category, $_['categories']) ? ' selected="selected"' : '') . '>' . $category . '</option>'; } ?> @@ -28,6 +29,7 @@ <select style="width:140px;" name="calendar"> <?php foreach($_['calendar_options'] as $calendar){ + if (!isset($_['calendar'])) {$_['calendar'] = false;} echo '<option value="' . $calendar['id'] . '"' . ($_['calendar'] == $calendar['id'] ? ' selected="selected"' : '') . '>' . $calendar['displayname'] . '</option>'; } ?> @@ -64,8 +66,10 @@ <td> <select name="repeat" style="width:350px;"> <?php - foreach($_['repeat_options'] as $id => $label){ - echo '<option value="' . $id . '"' . ($_['repeat'] == $id ? ' selected="selected"' : '') . '>' . $label . '</option>'; + if (isset($_['repeat_options'])) { + foreach($_['repeat_options'] as $id => $label){ + echo '<option value="' . $id . '"' . ($_['repeat'] == $id ? ' selected="selected"' : '') . '>' . $label . '</option>'; + } } ?> </select></td> @@ -82,6 +86,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");?>" name="description"><?php echo $_['description'] ?></textarea></td> + <td><textarea style="width:350px;height: 150px;" placeholder="<?php echo $l->t("Description of the Event");?>" name="description"><?php echo isset($_['description']) ? $_['description'] : '' ?></textarea></td> </tr> </table> |