diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php new file mode 100644 index 0000000000000000000000000000000000000000..e32bf4586523edf2dc162fdec1f83d8ba72ffede --- /dev/null +++ b/apps/calendar/ajax/editcalendar.php @@ -0,0 +1,29 @@ +<?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 = OC_Calendar_Calendar::findCalendar($_GET['calendarid']); +$tmpl = new OC_Template("calendar", "part.editcalendar"); +$tmpl->assign('calendar',$calendar); +$tmpl->printPage(); +?> diff --git a/apps/calendar/ajax/updatecalendar.php b/apps/calendar/ajax/updatecalendar.php new file mode 100644 index 0000000000000000000000000000000000000000..2836dda218ae7e318847857c42c51dc4a0afceea --- /dev/null +++ b/apps/calendar/ajax/updatecalendar.php @@ -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(); +} + +$calendarid = $_POST['id']; +OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']); +OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']); +$calendar = OC_Calendar_Calendar::findCalendar($calendarid); +$tmpl = new OC_Template('calendar', 'part.calendar.row'); +$tmpl->assign('calendar', $calendar); +echo json_encode( array( "status" => "success", "data" => $tmpl->fetchPage() )); diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js index bfead8f393342380595c7eed49ec261aa6ac34ef..d9bad110a6b319d51185159a05f29ea57779fa6c 100755 --- a/apps/calendar/js/calendar.js +++ b/apps/calendar/js/calendar.js @@ -903,3 +903,20 @@ function oc_cal_calender_activation(checkbox, calendarid) checkbox.checked = data == 1; }); } +function oc_cal_editcalendar(object, calendarid){ + $(object).closest('tr').load(oc_webroot + "/apps/calendar/ajax/editcalendar.php?calendarid="+calendarid); +} +function oc_cal_editcalendar_submit(button, calendarid){ + var displayname = $("#displayname_"+calendarid).val(); + var active = $("#active_"+calendarid+":checked").length; + var description = $("#description_"+calendarid).val(); + var calendarcolor = $("#calendarcolor_"+calendarid).val(); + + $.post("ajax/updatecalendar.php", { id: calendarid, name: displayname, active: active, description: description, color: calendarcolor }, + function(data){ + if(data.error == "true"){ + }else{ + $(button).closest('tr').html(data.data) + } + }, 'json'); +} diff --git a/apps/calendar/lib/calendar.php b/apps/calendar/lib/calendar.php index 5a4bed1fbc52f49e89debdc4c6472aaaabef3c10..c1223b5b3ab9e3424085f607bf2ccceb3c84eb7a 100644 --- a/apps/calendar/lib/calendar.php +++ b/apps/calendar/lib/calendar.php @@ -112,14 +112,14 @@ class OC_Calendar_Calendar{ public static function editCalendar($id,$name=null,$description=null,$components=null,$timezone=null,$order=null,$color=null){ // Need these ones for checking uri - $calendar = self::find($id); + $calendar = self::findCalendar($id); // Keep old stuff if(is_null($name)) $name = $calendar['name']; if(is_null($description)) $description = $calendar['description']; if(is_null($components)) $components = $calendar['components']; if(is_null($timezone)) $timezone = $calendar['timezone']; - if(is_null($order)) $order = $calendar['order']; + if(is_null($order)) $order = $calendar['calendarorder']; if(is_null($color)) $color = $calendar['color']; $stmt = OC_DB::prepare( 'UPDATE *PREFIX*calendar_calendars SET displayname=?,description=?,calendarorder=?,calendarcolor=?,timezone=?,components=?,ctag=ctag+1 WHERE id=?' ); diff --git a/apps/calendar/templates/part.choosecalendar.php b/apps/calendar/templates/part.choosecalendar.php index ebda6ddfb98fd3d4d19bcd4490a1d612aad7e288..30866270ac5ab8202ba671389f9986f01ba44559 100644 --- a/apps/calendar/templates/part.choosecalendar.php +++ b/apps/calendar/templates/part.choosecalendar.php @@ -4,16 +4,13 @@ $option_calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser()); for($i = 0; $i < count($option_calendars); $i++){ echo "<tr>"; - echo "<td width=\"20px\"><input id=\"active_" . $option_calendars[$i]["id"] . "\" type=\"checkbox\" onClick=\"oc_cal_calender_activation(this, " . $option_calendars[$i]["id"] . ")\"" . ($option_calendars[$i]["active"] ? ' checked="checked"' : '') . "></td>"; - echo "<td><label for=\"active_" . $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>"; + $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields'); + $tmpl->assign('calendar', $option_calendars[$i]); + $tmpl->printpage(); echo "</tr>"; } ?> </table> -<br /><br /><br /> -<input style="float: left;" type="button" onclick="oc_cal_choosecalendar_submit();" value="<?php echo $l->t("Submit"); ?>"> -</div> <script type="text/javascript"> $( "#choosecalendar_dialog" ).dialog({ width : 500, diff --git a/apps/calendar/templates/part.choosecalendar.rowfields.php b/apps/calendar/templates/part.choosecalendar.rowfields.php new file mode 100644 index 0000000000000000000000000000000000000000..ebe1ca0b13711aa37cec1ecba7807504fc7faf0b --- /dev/null +++ b/apps/calendar/templates/part.choosecalendar.rowfields.php @@ -0,0 +1,4 @@ +<?php + echo "<td width=\"20px\"><input id=\"active_" . $_['calendar']["id"] . "\" type=\"checkbox\" onClick=\"oc_cal_calender_activation(this, " . $_['calendar']["id"] . ")\"" . ($_['calendar']["active"] ? ' checked="checked"' : '') . "></td>"; + echo "<td><label for=\"active_" . $_['calendar']["id"] . "\">" . $_['calendar']["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("Edit") . "\" class=\"action\" onclick=\"oc_cal_editcalendar(this, " . $_['calendar']["id"] . ");\"><img src=\"/owncloud/core/img/actions/rename.svg\"></a></td>"; diff --git a/apps/calendar/templates/part.editcalendar.php b/apps/calendar/templates/part.editcalendar.php new file mode 100644 index 0000000000000000000000000000000000000000..d6f4e9f16fff312611f8a9ea45f07bb31519d4e9 --- /dev/null +++ b/apps/calendar/templates/part.editcalendar.php @@ -0,0 +1,32 @@ +<td id="editcalendar_dialog" title="<?php echo $l->t("Edit calendar"); ?>" colspan="4"> +<table width="100%" style="border: 0;"> +<tr> + <th><?php echo $l->t('Displayname') ?></th> + <td> + <input id="displayname_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['displayname'] ?>"> + </td> +</tr> +<tr> + <td></td> + <td> + <input id="active_<?php echo $_['calendar']['id'] ?>" type="checkbox"<?php echo ($_['calendar']['active'] ? ' checked="checked"' : '' ) ?>> + <label for="active_<?php echo $_['calendar']['id'] ?>"> + <?php echo $l->t('Active') ?> + </label> + </td> +</tr> +<tr> + <th><?php echo $l->t('Description') ?></th> + <td> + <textarea id="description_<?php echo $_['calendar']['id'] ?>"><?php echo $_['calendar']['description'] ?></textarea> + </td> +</tr> +<tr> + <th><?php echo $l->t('Calendar color') ?></th> + <td> + <input id="calendarcolor_<?php echo $_['calendar']['id'] ?>" type="text" value="<?php echo $_['calendar']['calendarcolor'] ?>"> + </td> +</tr> +</table> +<input style="float: left;" type="button" onclick="oc_cal_editcalendar_submit(this, <?php echo $_['calendar']['id'] ?>);" value="<?php echo $l->t("Submit"); ?>"> +</td>