Fixes, adding corrections to the validation for the name field in the calendar Edit form
This commit is contained in:
@@ -39,10 +39,12 @@ G::LoadClass ( 'calendar' );
|
||||
$calendarObj = new calendar ( );
|
||||
if ((isset ( $_GET ['id'] )) && ($_GET ['id'] != "")) {
|
||||
$fields = $calendarObj->getCalendarInfo ( $CalendarUid );
|
||||
$fields ['OLD_NAME'] = $fields['CALENDAR_NAME'];
|
||||
}
|
||||
|
||||
if (! (isset ( $fields ['CALENDAR_UID'] ))) { //For a new Calendar
|
||||
$fields ['CALENDAR_UID'] = $CalendarUid;
|
||||
$fields ['OLD_NAME'] = '';
|
||||
//Default Business Hour
|
||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_DAY'] = 7;
|
||||
$fields ['BUSINESS_DAY'] [1] ['CALENDAR_BUSINESS_START'] = "09:00";
|
||||
|
||||
@@ -39,6 +39,8 @@ switch ($RBAC->userCanAccess('PM_SETUP_ADVANCE'))
|
||||
}
|
||||
// validating the fields
|
||||
$message = array();
|
||||
$oldName = isset($_POST['oldName'])?$_POST['oldName']:'';
|
||||
|
||||
switch ($_POST['action']){
|
||||
case 'calendarName':
|
||||
require_once ('classes/model/CalendarDefinition.php');
|
||||
@@ -50,13 +52,20 @@ switch ($_POST['action']){
|
||||
$aCalendarDefinitions = end($aCalendars);
|
||||
// var_dump($aCalendarDefinitions);
|
||||
foreach($aCalendarDefinitions as $aDefinitions) {
|
||||
if ($aDefinitions['CALENDAR_NAME']!=$_POST['name']){
|
||||
$validated = true;
|
||||
} else {
|
||||
if (trim($_POST['name'])==''){
|
||||
$validated = false;
|
||||
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
|
||||
break;
|
||||
}
|
||||
if ($aDefinitions['CALENDAR_NAME']!=$_POST['name']){
|
||||
$validated = true;
|
||||
} else {
|
||||
if ($aDefinitions['CALENDAR_NAME']!=$oldName) {
|
||||
$validated = false;
|
||||
$message = G::loadTranslation('ID_CALENDAR_INVALID_NAME');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'calendarDates':
|
||||
|
||||
Reference in New Issue
Block a user