Skip to content

Commit 7a400a6

Browse files
Rui AlvesMichaelThumes
authored andcommitted
Issue #2035: Validate appointment edit on server side
1 parent 6037c55 commit 7a400a6

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Kernel/Modules/AgentAppointmentEdit.pm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,41 @@ sub Run {
10951095
# add/edit appointment
10961096
# ------------------------------------------------------------ #
10971097
elsif ( $Self->{Subaction} eq 'EditAppointment' ) {
1098+
1099+
my $ErrorMessage;
1100+
1101+
if ( !$GetParam{Title} ) {
1102+
$ErrorMessage = 'Title is required!';
1103+
}
1104+
elsif ( !$GetParam{CalendarID} ) {
1105+
$ErrorMessage = 'Calendar is required!';
1106+
}
1107+
elsif ( $GetParam{RecurrenceLimit} eq "2" && ( !$GetParam{RecurrenceCount} ) ) {
1108+
$ErrorMessage = 'Recurrence value is required!';
1109+
}
1110+
elsif ( $GetParam{RecurrenceLimit} eq "2" && ( $GetParam{RecurrenceCount} !~ /\d\d/ || $GetParam{RecurrenceCount} < 1 ) ) {
1111+
$ErrorMessage = 'Not a valid recurrence value!';
1112+
}
1113+
1114+
if ($ErrorMessage) {
1115+
1116+
# build JSON output
1117+
$JSON = $LayoutObject->JSONEncode(
1118+
Data => {
1119+
Success => 0,
1120+
Error => Translatable($ErrorMessage),
1121+
},
1122+
);
1123+
1124+
# send JSON response
1125+
return $LayoutObject->Attachment(
1126+
ContentType => 'application/json',
1127+
Content => $JSON,
1128+
Type => 'inline',
1129+
NoCache => 1,
1130+
);
1131+
}
1132+
10981133
my %Appointment;
10991134
if ( $GetParam{AppointmentID} ) {
11001135
%Appointment = $AppointmentObject->AppointmentGet(

0 commit comments

Comments
 (0)