diff --git a/apps/calendar/ajax/editcalendar.php b/apps/calendar/ajax/editcalendar.php
new file mode 100644
index 00000000000..e32bf458652
--- /dev/null
+++ b/apps/calendar/ajax/editcalendar.php
@@ -0,0 +1,29 @@
+ *
+ * *
+ * 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("");
+}
+$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 00000000000..2836dda218a
--- /dev/null
+++ b/apps/calendar/ajax/updatecalendar.php
@@ -0,0 +1,39 @@
+ *
+ * *
+ * 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 bfead8f3933..d9bad110a6b 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 5a4bed1fbc5..c1223b5b3ab 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 ebda6ddfb98..30866270ac5 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 "
";
- echo " | ";
- echo " | ";
- echo "t("Download") . "\" class=\"action\"> | t("Rename") . "\" class=\"action\"> | ";
+ $tmpl = new OC_Template('calendar', 'part.choosecalendar.rowfields');
+ $tmpl->assign('calendar', $option_calendars[$i]);
+ $tmpl->printpage();
echo "
";
}
?>
-
-">
-