]> source.dussan.org Git - nextcloud-server.git/commitdiff
validate the calendar name
authorGeorg Ehrke <dev@georgswebsite.de>
Sat, 21 Jan 2012 16:42:34 +0000 (17:42 +0100)
committerGeorg Ehrke <dev@georgswebsite.de>
Sat, 21 Jan 2012 16:42:52 +0000 (17:42 +0100)
apps/calendar/ajax/createcalendar.php
apps/calendar/ajax/updatecalendar.php
apps/calendar/js/calendar.js

index f8b5974f54cf45eb16caf55ad5c274a02adf108e..b719b207c742aabdbf17e769f3e3ae7646610fc1 100644 (file)
@@ -12,6 +12,18 @@ require_once('../../../lib/base.php');
 OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('calendar');
 
+if(trim($_POST['name']) == ''){
+       OC_JSON::error(array('message'=>'empty'));
+       exit;
+}
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+foreach($calendars as $cal){
+       if($cal['displayname'] == $_POST['name']){
+               OC_JSON::error(array('message'=>'namenotavailable'));
+               exit;
+       }
+}
+
 $userid = OC_User::getUser();
 $calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);
 OC_Calendar_Calendar::setCalendarActive($calendarid, 1);
index 14f560da5a3cbc8361d2cdc439f1c5011b5e076b..269b7b7ca06f3911c1754fdff99fba521b839097 100644 (file)
@@ -12,6 +12,18 @@ require_once('../../../lib/base.php');
 OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('calendar');
 
+if(trim($_POST['name']) == ''){
+       OC_JSON::error(array('message'=>'empty'));
+       exit;
+}
+$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
+foreach($calendars as $cal){
+       if($cal['displayname'] == $_POST['name'] && $cal['id'] != $_POST['id']){
+               OC_JSON::error(array('message'=>'namenotavailable'));
+               exit;
+       }
+}
+
 $calendarid = $_POST['id'];
 $calendar = OC_Calendar_App::getCalendar($calendarid);//access check
 OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], null, null, null, $_POST['color']);
index 228ea97c2da0715806fbfd7c9737518bb6b3941f..afd1b692dd422e02a1e5bbbbb8ceb3661c291bf0 100644 (file)
@@ -429,11 +429,17 @@ Calendar={
                                }
                        },
                        submit:function(button, calendarid){
-                               var displayname = $("#displayname_"+calendarid).val();
+                               var displayname = $.trim($("#displayname_"+calendarid).val());
                                var active = $("#edit_active_"+calendarid+":checked").length;
                                var description = $("#description_"+calendarid).val();
                                var calendarcolor = $("#calendarcolor_"+calendarid).val();
-
+                               if(displayname == ''){
+                                       $("#displayname_"+calendarid).css('background-color', '#FF2626');
+                                       $("#displayname_"+calendarid).focus(function(){
+                                               $("#displayname_"+calendarid).css('background-color', '#F8F8F8');
+                                       });
+                               }
+                               
                                var url;
                                if (calendarid == 'new'){
                                        url = OC.filePath('calendar', 'ajax', 'createcalendar.php');
@@ -449,6 +455,11 @@ Calendar={
                                                        if (calendarid == 'new'){
                                                                $('#choosecalendar_dialog > table').append('<tr><td colspan="6"><a href="#" onclick="Calendar.UI.Calendar.newCalendar(this);"><input type="button" value="' + newcalendar + '"></a></td></tr>');
                                                        }
+                                               }else{
+                                                       $("#displayname_"+calendarid).css('background-color', '#FF2626');
+                                                       $("#displayname_"+calendarid).focus(function(){
+                                                               $("#displayname_"+calendarid).css('background-color', '#F8F8F8');
+                                                       });
                                                }
                                        }, 'json');
                        },
@@ -677,6 +688,9 @@ $(document).ready(function(){
                                $('#calendar_holder').fullCalendar('option', 'aspectRatio', 1.35);
                        }
                },
+               columnFormat: {
+                   week: 'ddd d. MMM'
+               },
                selectable: true,
                selectHelper: true,
                select: Calendar.UI.newEvent,