Koha/course_reserves/mod_course.pl
Mark Tompsett 2ca766f392 Bug 21349: Instructors with special characters in cardnumber cannot be removed from course reserves
The cardnumber can contain strange non-javascript-friendly
characters. This patch converts all the internal references
to borrowernumber, but displays the cardnumber when showing
list of matching users.

TEST PLAN
---------
1) Make sure Course Reserves is being used. Check system preferences.
2) Make sure there is a Course entered.
3) Make sure there is a patron with an cardnumber which breaks
   the existing javascript (eg. Ka-boom:Ka-boom!KABOOM@#$!)
4) Go into the course list.
5) Click the course name link
6) In the "Instructor Search" box enter the patron name.
7) Select the patron which has the ugly cardnumber.
8) Click Save
   -- The course listing should have the new teacher listed.
9) Click the course name link again.
10) Click 'Remove' beside the instructor's name.
    -- nothing happens, and inspecting the error console gives
       you the ugly error described in comment #0
11) apply this patch
12) restart_all
13) sudo service apache2 restart
14) refresh the page.
15) click 'Remove' beside the instructor's name.
    -- name is removed.
16) Click Save
    -- the course listing no longer lists the new teacher.
17) Actually confirm that adding and removing others normally
    works as expected.
18) run koha qa test tools.

Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2018-10-29 00:35:41 +00:00

69 lines
2.3 KiB
Perl
Executable file

#!/usr/bin/perl
# Copyright 2012 ByWater Solutions
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use CGI qw ( -utf8 );
use C4::Output;
use C4::Reserves;
use C4::Auth;
use C4::CourseReserves qw(DelCourse ModCourse ModCourseInstructors);
my $cgi = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{ template_name => "about.tt",
query => $cgi,
type => "intranet",
authnotrequired => 0,
flagsrequired => { coursereserves => 'manage_courses' },
}
);
my $action = $cgi->param('action') || '';
my $course_id = $cgi->param('course_id');
if ( $action eq 'del' ) {
DelCourse( $course_id );
print $cgi->redirect("/cgi-bin/koha/course_reserves/course-reserves.pl");
} else {
my %params;
$params{'course_id'} = $course_id;
$params{'department'} = $cgi->param('department');
$params{'course_number'} = $cgi->param('course_number');
$params{'section'} = $cgi->param('section');
$params{'course_name'} = $cgi->param('course_name');
$params{'term'} = $cgi->param('term');
$params{'staff_note'} = $cgi->param('staff_note');
$params{'public_note'} = $cgi->param('public_note');
$params{'students_count'} = $cgi->param('students_count');
$params{'enabled'} = ( $cgi->param('enabled') eq 'on' ) ? 'yes' : 'no';
my $new_course_id = ModCourse(%params);
my @instructors = $cgi->multi_param('instructors');
ModCourseInstructors(
mode => 'replace',
borrowernumbers => \@instructors,
course_id => $new_course_id
);
print $cgi->redirect("/cgi-bin/koha/course_reserves/course-details.pl?course_id=$new_course_id");
}