View | Details | Raw Unified | Return to bug 38489
Collapse All | Expand All

(-)a/admin/file_transports.pl (-54 / +54 lines)
Lines 42-66 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
42
42
43
my @messages;
43
my @messages;
44
44
45
my $sftp_servers = Koha::File::Transports->search;
45
my $file_transports = Koha::File::Transports->search;
46
46
47
if ( $op eq 'cud-add' ) {
47
if ( $op eq 'cud-add' ) {
48
    my $name               = $input->param('sftp_name');
48
    my $name               = $input->param('name');
49
    my $host               = $input->param('sftp_host')      || 'localhost';
49
    my $host               = $input->param('host')      || 'localhost';
50
    my $port               = $input->param('sftp_port')      || 22;
50
    my $port               = $input->param('port')      || 22;
51
    my $transport          = $input->param('sftp_transport') || 'sftp';
51
    my $transport          = $input->param('transport') || 'sftp';
52
    my $passive            = ( scalar $input->param('sftp_passiv') ) ? 1 : 0;
52
    my $passive            = ( scalar $input->param('passiv') ) ? 1 : 0;
53
    my $auth_mode          = $input->param('sftp_auth_mode')          || 'password';
53
    my $auth_mode          = $input->param('auth_mode')          || 'password';
54
    my $user_name          = $input->param('sftp_user_name')          || undef;
54
    my $user_name          = $input->param('user_name')          || undef;
55
    my $password           = $input->param('sftp_password')           || undef;
55
    my $password           = $input->param('password')           || undef;
56
    my $key_file           = $input->param('sftp_key_file')           || undef;
56
    my $key_file           = $input->param('key_file')           || undef;
57
    my $download_directory = $input->param('sftp_download_directory') || undef;
57
    my $download_directory = $input->param('download_directory') || undef;
58
    my $upload_directory   = $input->param('sftp_upload_directory')   || undef;
58
    my $upload_directory   = $input->param('upload_directory')   || undef;
59
    my $status             = $input->param('sftp_status')             || '';
59
    my $status             = $input->param('status')             || '';
60
    my $debug              = ( scalar $input->param('sftp_debug_mode') ) ? 1 : 0;
60
    my $debug              = ( scalar $input->param('debug_mode') ) ? 1 : 0;
61
61
62
    try {
62
    try {
63
        my $sftp_server = Koha::File::Transport->new(
63
        my $file_transport = Koha::File::Transport->new(
64
            {
64
            {
65
                name               => $name,
65
                name               => $name,
66
                host               => $host,
66
                host               => $host,
Lines 96-119 if ( $op eq 'cud-add' ) { Link Here
96
    $op = 'list';
96
    $op = 'list';
97
97
98
} elsif ( $op eq 'edit_form' ) {
98
} elsif ( $op eq 'edit_form' ) {
99
    my $sftp_server_id = $input->param('sftp_server_id');
99
    my $file_transport_id = $input->param('file_transport_id');
100
    my $sftp_server;
100
    my $file_transport;
101
    my $sftp_server_plain_text_password;
101
    my $file_transport_plain_text_password;
102
    my $sftp_server_plain_text_key;
102
    my $file_transport_plain_text_key;
103
103
104
    $sftp_server = Koha::File::Transports->find($sftp_server_id)
104
    $file_transport = Koha::File::Transports->find($file_transport_id)
105
        unless !$sftp_server_id;
105
        unless !$file_transport_id;
106
106
107
    unless ( !$sftp_server ) {
107
    unless ( !$file_transport ) {
108
        $sftp_server_plain_text_password = $sftp_server->plain_text_password || '';
108
        $file_transport_plain_text_password = $file_transport->plain_text_password || '';
109
        $sftp_server_plain_text_key      = $sftp_server->plain_text_key      || '';
109
        $file_transport_plain_text_key      = $file_transport->plain_text_key      || '';
110
    }
110
    }
111
111
112
    if ($sftp_server) {
112
    if ($file_transport) {
113
        $template->param(
113
        $template->param(
114
            sftp_server                     => $sftp_server,
114
            file_transport                     => $file_transport,
115
            sftp_server_plain_text_password => $sftp_server_plain_text_password,
115
            file_transport_plain_text_password => $file_transport_plain_text_password,
116
            sftp_server_plain_text_key      => $sftp_server_plain_text_key,
116
            file_transport_plain_text_key      => $file_transport_plain_text_key,
117
        );
117
        );
118
    } else {
118
    } else {
119
        push @messages, {
119
        push @messages, {
Lines 124-156 if ( $op eq 'cud-add' ) { Link Here
124
    }
124
    }
125
125
126
} elsif ( $op eq 'cud-edit_save' ) {
126
} elsif ( $op eq 'cud-edit_save' ) {
127
    my $sftp_server_id = $input->param('sftp_server_id');
127
    my $file_transport_id = $input->param('file_transport_id');
128
    my $sftp_server_plain_text_password;
128
    my $file_transport_plain_text_password;
129
    my $sftp_server;
129
    my $file_transport;
130
130
131
    $sftp_server = Koha::File::Transports->find($sftp_server_id)
131
    $file_transport = Koha::File::Transports->find($file_transport_id)
132
        unless !$sftp_server_id;
132
        unless !$file_transport_id;
133
133
134
    $sftp_server_plain_text_password = $sftp_server->plain_text_password
134
    $file_transport_plain_text_password = $file_transport->plain_text_password
135
        unless !$sftp_server_id;
135
        unless !$file_transport_id;
136
136
137
    if ($sftp_server) {
137
    if ($file_transport) {
138
        my $name               = $input->param('sftp_name');
138
        my $name               = $input->param('name');
139
        my $host               = $input->param('sftp_host')      || 'localhost';
139
        my $host               = $input->param('host')      || 'localhost';
140
        my $port               = $input->param('sftp_port')      || 22;
140
        my $port               = $input->param('port')      || 22;
141
        my $transport          = $input->param('sftp_transport') || 'sftp';
141
        my $transport          = $input->param('transport') || 'sftp';
142
        my $passive            = ( scalar $input->param('sftp_passiv') ) ? 1 : 0;
142
        my $passive            = ( scalar $input->param('passiv') ) ? 1 : 0;
143
        my $auth_mode          = $input->param('sftp_auth_mode')          || 'password';
143
        my $auth_mode          = $input->param('auth_mode')          || 'password';
144
        my $user_name          = $input->param('sftp_user_name')          || undef;
144
        my $user_name          = $input->param('user_name')          || undef;
145
        my $password           = $input->param('sftp_password')           || undef;
145
        my $password           = $input->param('password')           || undef;
146
        my $key_file           = $input->param('sftp_key_file')           || undef;
146
        my $key_file           = $input->param('key_file')           || undef;
147
        my $download_directory = $input->param('sftp_download_directory') || undef;
147
        my $download_directory = $input->param('download_directory') || undef;
148
        my $upload_directory   = $input->param('sftp_upload_directory')   || undef;
148
        my $upload_directory   = $input->param('upload_directory')   || undef;
149
        my $status             = $input->param('sftp_status')             || '';
149
        my $status             = $input->param('status')             || '';
150
        my $debug              = ( scalar $input->param('sftp_debug_mode') ) ? 1 : 0;
150
        my $debug              = ( scalar $input->param('debug_mode') ) ? 1 : 0;
151
151
152
        try {
152
        try {
153
            $sftp_server->set(
153
            $file_transport->set(
154
                {
154
                {
155
                    name               => $name,
155
                    name               => $name,
156
                    host               => $host,
156
                    host               => $host,
Lines 195-201 if ( $op eq 'cud-add' ) { Link Here
195
195
196
if ( $op eq 'list' ) {
196
if ( $op eq 'list' ) {
197
    $template->param(
197
    $template->param(
198
        servers_count => $sftp_servers->count,
198
        servers_count => $file_transports->count,
199
    );
199
    );
200
}
200
}
201
201
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/file_transports.tt (-131 / +130 lines)
Lines 9-15 Link Here
9
            [% t("New file transport") | html %]
9
            [% t("New file transport") | html %]
10
            ›
10
            ›
11
        [% ELSIF op == 'edit_form' %]
11
        [% ELSIF op == 'edit_form' %]
12
            [% tx("Modify file transport '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]
12
            [% tx("Modify file transport '{file_transport}'", { file_transport = file_transport.name }) | html %]
13
            ›
13
            ›
14
        [% END %]
14
        [% END %]
15
        [% t("File transports") | html %]
15
        [% t("File transports") | html %]
Lines 42-48 Link Here
42
            [% END %]
42
            [% END %]
43
        [% ELSIF op == 'edit_form' %]
43
        [% ELSIF op == 'edit_form' %]
44
            [% WRAPPER breadcrumb_item bc_active= 1 %]
44
            [% WRAPPER breadcrumb_item bc_active= 1 %]
45
                [% tx("Modify file transport '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]
45
                [% tx("Modify file transport '{file_transport}'", { file_transport = file_transport.name }) | html %]
46
            [% END %]
46
            [% END %]
47
        [% ELSE %]
47
        [% ELSE %]
48
            [% WRAPPER breadcrumb_item bc_active= 1 %]
48
            [% WRAPPER breadcrumb_item bc_active= 1 %]
Lines 59-65 Link Here
59
                [% INCLUDE 'messages.inc' %]
59
                [% INCLUDE 'messages.inc' %]
60
60
61
                [% FOREACH m IN messages %]
61
                [% FOREACH m IN messages %]
62
                    <div class="alert alert-[% m.type | html %]" id="sftp_action_result_dialog">
62
                    <div class="alert alert-[% m.type | html %]" id="action_result_dialog">
63
                        [% SWITCH m.code %]
63
                        [% SWITCH m.code %]
64
                        [% CASE 'error_on_insert' %]
64
                        [% CASE 'error_on_insert' %]
65
                            <span>An error occurred when adding the server. The passed ID already exists.</span>
65
                            <span>An error occurred when adding the server. The passed ID already exists.</span>
Lines 77-84 Link Here
77
                    </div>
77
                    </div>
78
                [% END %]
78
                [% END %]
79
79
80
                <div class="alert alert-info" id="sftp_delete_success" style="display: none;"></div>
80
                <div class="alert alert-info" id="delete_success" style="display: none;"></div>
81
                <div class="alert alert-warning" id="sftp_delete_error" style="display: none;"></div>
81
                <div class="alert alert-warning" id="delete_error" style="display: none;"></div>
82
82
83
                [% IF op == 'add_form' %]
83
                [% IF op == 'add_form' %]
84
                    <!-- Modal -->
84
                    <!-- Modal -->
Lines 136-143 Link Here
136
                        <fieldset class="rows">
136
                        <fieldset class="rows">
137
                            <ol>
137
                            <ol>
138
                                <li>
138
                                <li>
139
                                    <label for="sftp_name" class="required">Name: </label>
139
                                    <label for="name" class="required">Name: </label>
140
                                    <input type="text" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" />
140
                                    <input type="text" name="name" id="name" size="60" class="required focus" required="required" />
141
                                    <span class="required">Required</span>
141
                                    <span class="required">Required</span>
142
                                </li>
142
                                </li>
143
                            </ol>
143
                            </ol>
Lines 146-212 Link Here
146
                        <fieldset class="rows">
146
                        <fieldset class="rows">
147
                            <ol>
147
                            <ol>
148
                                <li>
148
                                <li>
149
                                    <label for="sftp_transport" class="required">Transport: </label>
149
                                    <label for="transport" class="required">Transport: </label>
150
                                    <select name="sftp_transport" id="sftp_transport" class="required">
150
                                    <select name="transport" id="transport" class="required">
151
                                        <option value="ftp">FTP</option>
151
                                        <option value="ftp">FTP</option>
152
                                        <option value="sftp" selected="selected">SFTP</option>
152
                                        <option value="sftp" selected="selected">SFTP</option>
153
                                    </select>
153
                                    </select>
154
                                    <span class="required">Required</span>
154
                                    <span class="required">Required</span>
155
                                </li>
155
                                </li>
156
                                <li>
156
                                <li>
157
                                    <label for="sftp_host" class="required">Host: </label>
157
                                    <label for="host" class="required">Host: </label>
158
                                    <input type="text" value="localhost" name="sftp_host" id="sftp_host" size="60" class="required" />
158
                                    <input type="text" value="localhost" name="host" id="host" size="60" class="required" />
159
                                    <span class="required">Required</span>
159
                                    <span class="required">Required</span>
160
                                </li>
160
                                </li>
161
                                <li>
161
                                <li>
162
                                    <label for="sftp_port" class="required">Port: </label>
162
                                    <label for="port" class="required">Port: </label>
163
                                    <input type="text" inputmode="numeric" pattern="[0-9]*" value="22" name="sftp_port" id="sftp_port" size="20" class="required" />
163
                                    <input type="text" inputmode="numeric" pattern="[0-9]*" value="22" name="port" id="port" size="20" class="required" />
164
                                    <span class="required">Required</span>
164
                                    <span class="required">Required</span>
165
                                </li>
165
                                </li>
166
                                <li>
166
                                <li>
167
                                    <label for="sftp_passive">Passive mode: </label>
167
                                    <label for="passive">Passive mode: </label>
168
                                    <select name="sftp_passive" id="sftp_passive" disabled="disabled">
168
                                    <select name="passive" id="passive" disabled="disabled">
169
                                        <option value="1" selected="selected">On (Recommended)</option>
169
                                        <option value="1" selected="selected">On (Recommended)</option>
170
                                        <option value="0">Off</option>
170
                                        <option value="0">Off</option>
171
                                    </select>
171
                                    </select>
172
                                    <span class="hint">Only applies to FTP connections</span>
172
                                    <span class="hint">Only applies to FTP connections</span>
173
                                </li>
173
                                </li>
174
                                <li>
174
                                <li>
175
                                    <label for="sftp_auth_mode">Authentication mode: </label>
175
                                    <label for="auth_mode">Authentication mode: </label>
176
                                    <select name="sftp_auth_mode" id="sftp_auth_mode">
176
                                    <select name="auth_mode" id="auth_mode">
177
                                        <option value="password" selected="selected">Password-based</option>
177
                                        <option value="password" selected="selected">Password-based</option>
178
                                        <option value="key_file">Key file-based</option>
178
                                        <option value="key_file">Key file-based</option>
179
                                        <option value="noauth">No authentication</option>
179
                                        <option value="noauth">No authentication</option>
180
                                    </select>
180
                                    </select>
181
                                </li>
181
                                </li>
182
                                <li>
182
                                <li>
183
                                    <label for="sftp_user_name" class="required">Username: </label>
183
                                    <label for="user_name" class="required">Username: </label>
184
                                    <input type="text" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" />
184
                                    <input type="text" name="user_name" id="user_name" size="60" autocomplete="off" class="required" />
185
                                    <span class="required">Required</span>
185
                                    <span class="required">Required</span>
186
                                </li>
186
                                </li>
187
                                <li>
187
                                <li>
188
                                    <label for="sftp_password">Password: </label>
188
                                    <label for="password">Password: </label>
189
                                    <input type="password" name="sftp_password" id="sftp_password" size="60" autocomplete="off" />
189
                                    <input type="password" name="password" id="password" size="60" autocomplete="off" />
190
                                </li>
190
                                </li>
191
                                <li>
191
                                <li>
192
                                    <label for="sftp_key_file">Key file: </label>
192
                                    <label for="key_file">Key file: </label>
193
                                    <textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58"></textarea>
193
                                    <textarea name="key_file" id="key_file" rows="10" cols="58"></textarea>
194
                                    <span class="hint">Only applies to SFTP connections</span>
194
                                    <span class="hint">Only applies to SFTP connections</span>
195
                                </li>
195
                                </li>
196
                                <li>
196
                                <li>
197
                                    <label for="sftp_download_directory">Remote download directory: </label>
197
                                    <label for="download_directory">Remote download directory: </label>
198
                                    <input type="text" name="sftp_download_directory" id="sftp_download_directory" size="60" autocomplete="off" /><br />
198
                                    <input type="text" name="download_directory" id="download_directory" size="60" autocomplete="off" /><br />
199
                                    <span class="hint">The path on the remote server where we will download from</span>
199
                                    <span class="hint">The path on the remote server where we will download from</span>
200
                                </li>
200
                                </li>
201
                                <li>
201
                                <li>
202
                                    <label for="sftp_upload_directory">Remote upload directory: </label>
202
                                    <label for="upload_directory">Remote upload directory: </label>
203
                                    <input type="text" name="sftp_upload_directory" id="sftp_upload_directory" size="60" autocomplete="off" /><br />
203
                                    <input type="text" name="upload_directory" id="upload_directory" size="60" autocomplete="off" /><br />
204
                                    <span class="hint">The path on the remote server where we will upload to</span>
204
                                    <span class="hint">The path on the remote server where we will upload to</span>
205
                                </li>
205
                                </li>
206
                                <input type="hidden" value="" name="sftp_status" id="sftp_status" />
206
                                <input type="hidden" value="" name="status" id="status" />
207
                                <li>
207
                                <li>
208
                                    <label for="sftp_debug_mode">Debug mode: </label>
208
                                    <label for="debug_mode">Debug mode: </label>
209
                                    <select name="sftp_debug_mode" id="sftp_debug_mode">
209
                                    <select name="debug_mode" id="debug_mode">
210
                                        <option value="1">Enabled</option>
210
                                        <option value="1">Enabled</option>
211
                                        <option value="0" selected="selected">Disabled</option>
211
                                        <option value="0" selected="selected">Disabled</option>
212
                                    </select>
212
                                    </select>
Lines 269-285 Link Here
269
                    </div>
269
                    </div>
270
                    <!-- END Modal -->
270
                    <!-- END Modal -->
271
271
272
                    <h1>[% tx("Modify file transport '{sftp_server}'", { sftp_server = sftp_server.name }) | html %]</h1>
272
                    <h1>[% tx("Modify file transport '{file_transport}'", { file_transport = file_transport.name }) | html %]</h1>
273
273
274
                    <form action="/cgi-bin/koha/admin/file_transports.pl" id="edit_save" name="edit_save" class="validated" method="post">
274
                    <form action="/cgi-bin/koha/admin/file_transports.pl" id="edit_save" name="edit_save" class="validated" method="post">
275
                        [% INCLUDE 'csrf-token.inc' %]
275
                        [% INCLUDE 'csrf-token.inc' %]
276
                        <input type="hidden" name="op" value="cud-edit_save" />
276
                        <input type="hidden" name="op" value="cud-edit_save" />
277
                        <input type="hidden" name="file_transport_id" value="[%- sftp_server.id | html -%]" />
277
                        <input type="hidden" name="file_transport_id" value="[%- file_transport.id | html -%]" />
278
                        <fieldset class="rows">
278
                        <fieldset class="rows">
279
                            <ol>
279
                            <ol>
280
                                <li>
280
                                <li>
281
                                    <label for="sftp_name" class="required">Name: </label>
281
                                    <label for="name" class="required">Name: </label>
282
                                    <input type="text" value="[% sftp_server.name | html %]" name="sftp_name" id="sftp_name" size="60" class="required focus" required="required" />
282
                                    <input type="text" value="[% file_transport.name | html %]" name="name" id="name" size="60" class="required focus" required="required" />
283
                                    <span class="required">Required</span>
283
                                    <span class="required">Required</span>
284
                                </li>
284
                                </li>
285
                            </ol>
285
                            </ol>
Lines 288-301 Link Here
288
                        <fieldset class="rows">
288
                        <fieldset class="rows">
289
                            <ol>
289
                            <ol>
290
                                <li>
290
                                <li>
291
                                    <label for="sftp_transport" class="required">Transport: </label>
291
                                    <label for="transport" class="required">Transport: </label>
292
                                    <select name="sftp_transport" id="sftp_transport" class="required">
292
                                    <select name="transport" id="transport" class="required">
293
                                        [% IF sftp_server.transport == 'ftp' %]
293
                                        [% IF file_transport.transport == 'ftp' %]
294
                                            <option value="ftp" selected="selected">FTP</option>
294
                                            <option value="ftp" selected="selected">FTP</option>
295
                                        [% ELSE %]
295
                                        [% ELSE %]
296
                                            <option value="ftp">FTP</option>
296
                                            <option value="ftp">FTP</option>
297
                                        [% END %]
297
                                        [% END %]
298
                                        [% IF sftp_server.transport == 'sftp' %]
298
                                        [% IF file_transport.transport == 'sftp' %]
299
                                            <option value="sftp" selected="selected">SFTP</option>
299
                                            <option value="sftp" selected="selected">SFTP</option>
300
                                        [% ELSE %]
300
                                        [% ELSE %]
301
                                            <option value="sftp">SFTP</option>
301
                                            <option value="sftp">SFTP</option>
Lines 304-327 Link Here
304
                                    <span class="required">Required</span>
304
                                    <span class="required">Required</span>
305
                                </li>
305
                                </li>
306
                                <li>
306
                                <li>
307
                                    <label for="sftp_host" class="required">Host: </label>
307
                                    <label for="host" class="required">Host: </label>
308
                                    <input type="text" value="[% sftp_server.host | html %]" name="sftp_host" id="sftp_host" size="60" class="required" />
308
                                    <input type="text" value="[% file_transport.host | html %]" name="host" id="host" size="60" class="required" />
309
                                    <span class="required">Required</span>
309
                                    <span class="required">Required</span>
310
                                </li>
310
                                </li>
311
                                <li>
311
                                <li>
312
                                    <label for="sftp_port" class="required">Port: </label>
312
                                    <label for="port" class="required">Port: </label>
313
                                    <input type="text" inputmode="numeric" pattern="[0-9]*" value="[% sftp_server.port | html %]" name="sftp_port" id="sftp_port" size="20" class="required" />
313
                                    <input type="text" inputmode="numeric" pattern="[0-9]*" value="[% file_transport.port | html %]" name="port" id="port" size="20" class="required" />
314
                                    <span class="required">Required</span>
314
                                    <span class="required">Required</span>
315
                                </li>
315
                                </li>
316
                                <li>
316
                                <li>
317
                                    <label for="sftp_passive">Passive mode: </label>
317
                                    <label for="passive">Passive mode: </label>
318
                                    <select name="sftp_passive" id="sftp_passive" disabled="disabled">
318
                                    <select name="passive" id="passive" disabled="disabled">
319
                                        [% IF sftp_server.passive == 1 %]
319
                                        [% IF file_transport.passive == 1 %]
320
                                            <option value="1" selected="selected">Enabled (Recommended)</option>
320
                                            <option value="1" selected="selected">Enabled (Recommended)</option>
321
                                        [% ELSE %]
321
                                        [% ELSE %]
322
                                            <option value="1">Enabled (Recommended)</option>
322
                                            <option value="1">Enabled (Recommended)</option>
323
                                        [% END %]
323
                                        [% END %]
324
                                        [% IF sftp_server.passive == 0 %]
324
                                        [% IF file_transport.passive == 0 %]
325
                                            <option value="0" selected="selected">Disabled</option>
325
                                            <option value="0" selected="selected">Disabled</option>
326
                                        [% ELSE %]
326
                                        [% ELSE %]
327
                                            <option value="0">Disabled</option>
327
                                            <option value="0">Disabled</option>
Lines 330-348 Link Here
330
                                    <span class="hint">Only applies to FTP connections</span>
330
                                    <span class="hint">Only applies to FTP connections</span>
331
                                </li>
331
                                </li>
332
                                <li>
332
                                <li>
333
                                    <label for="sftp_auth_mode">Authentication mode: </label>
333
                                    <label for="auth_mode">Authentication mode: </label>
334
                                    <select name="sftp_auth_mode" id="sftp_auth_mode">
334
                                    <select name="auth_mode" id="auth_mode">
335
                                        [% IF sftp_server.auth_mode == 'password' %]
335
                                        [% IF file_transport.auth_mode == 'password' %]
336
                                            <option value="password" selected="selected">Password-based</option>
336
                                            <option value="password" selected="selected">Password-based</option>
337
                                        [% ELSE %]
337
                                        [% ELSE %]
338
                                            <option value="password">Password-based</option>
338
                                            <option value="password">Password-based</option>
339
                                        [% END %]
339
                                        [% END %]
340
                                        [% IF sftp_server.auth_mode == 'key_file' %]
340
                                        [% IF file_transport.auth_mode == 'key_file' %]
341
                                            <option value="key_file" selected="selected">Key file-based</option>
341
                                            <option value="key_file" selected="selected">Key file-based</option>
342
                                        [% ELSE %]
342
                                        [% ELSE %]
343
                                            <option value="key_file">Key file-based</option>
343
                                            <option value="key_file">Key file-based</option>
344
                                        [% END %]
344
                                        [% END %]
345
                                        [% IF sftp_server.auth_mode == 'noauth' %]
345
                                        [% IF file_transport.auth_mode == 'noauth' %]
346
                                            <option value="noauth" selected="selected">No authentication</option>
346
                                            <option value="noauth" selected="selected">No authentication</option>
347
                                        [% ELSE %]
347
                                        [% ELSE %]
348
                                            <option value="noauth">No authentication</option>
348
                                            <option value="noauth">No authentication</option>
Lines 350-388 Link Here
350
                                    </select>
350
                                    </select>
351
                                </li>
351
                                </li>
352
                                <li>
352
                                <li>
353
                                    <label for="sftp_user_name" class="required">Username: </label>
353
                                    <label for="user_name" class="required">Username: </label>
354
                                    <input type="text" value="[% sftp_server.user_name | html %]" name="sftp_user_name" id="sftp_user_name" size="60" autocomplete="off" class="required" />
354
                                    <input type="text" value="[% file_transport.user_name | html %]" name="user_name" id="user_name" size="60" autocomplete="off" class="required" />
355
                                    <span class="required">Required</span>
355
                                    <span class="required">Required</span>
356
                                </li>
356
                                </li>
357
                                <li>
357
                                <li>
358
                                    <label for="sftp_password">Password: </label>
358
                                    <label for="password">Password: </label>
359
                                    <input type="password" value="[% sftp_server_plain_text_password | html %]" name="sftp_password" id="sftp_password" size="60" autocomplete="off" />
359
                                    <input type="password" value="[% file_transport_plain_text_password | html %]" name="password" id="password" size="60" autocomplete="off" />
360
                                </li>
360
                                </li>
361
                                <li>
361
                                <li>
362
                                    <label for="sftp_key_file">Key file path: </label>
362
                                    <label for="key_file">Key file path: </label>
363
                                    <textarea name="sftp_key_file" id="sftp_key_file" rows="10" cols="58">[% sftp_server_plain_text_key | html %]</textarea>
363
                                    <textarea name="key_file" id="key_file" rows="10" cols="58">[% file_transport_plain_text_key | html %]</textarea>
364
                                    <span class="hint">Only applies to SFTP connections</span>
364
                                    <span class="hint">Only applies to SFTP connections</span>
365
                                </li>
365
                                </li>
366
                                <li>
366
                                <li>
367
                                    <label for="sftp_download_directory">Remote download directory: </label>
367
                                    <label for="download_directory">Remote download directory: </label>
368
                                    <input type="text" value="[% sftp_server.download_directory | html %]" name="sftp_download_directory" id="sftp_download_directory" size="60" autocomplete="off" /><br />
368
                                    <input type="text" value="[% file_transport.download_directory | html %]" name="download_directory" id="download_directory" size="60" autocomplete="off" /><br />
369
                                    <span class="hint">The path on the remote server where we will download from</span>
369
                                    <span class="hint">The path on the remote server where we will download from</span>
370
                                </li>
370
                                </li>
371
                                <li>
371
                                <li>
372
                                    <label for="sftp_upload_directory">Remote upload directory: </label>
372
                                    <label for="upload_directory">Remote upload directory: </label>
373
                                    <input type="text" value="[% sftp_server.upload_directory | html %]" name="sftp_upload_directory" id="sftp_upload_directory" size="60" autocomplete="off" /><br />
373
                                    <input type="text" value="[% file_transport.upload_directory | html %]" name="upload_directory" id="upload_directory" size="60" autocomplete="off" /><br />
374
                                    <span class="hint">The path on the remote server where we will upload to</span>
374
                                    <span class="hint">The path on the remote server where we will upload to</span>
375
                                </li>
375
                                </li>
376
                                <input type="hidden" value="" name="sftp_status" id="sftp_status" />
376
                                <input type="hidden" value="" name="status" id="status" />
377
                                <li>
377
                                <li>
378
                                    <label for="sftp_debug_mode">Debug mode: </label>
378
                                    <label for="debug_mode">Debug mode: </label>
379
                                    <select name="sftp_debug_mode" id="sftp_debug_mode">
379
                                    <select name="debug_mode" id="debug_mode">
380
                                        [% IF sftp_server.debug == 1 %]
380
                                        [% IF file_transport.debug == 1 %]
381
                                            <option value="1" selected="selected">Enabled</option>
381
                                            <option value="1" selected="selected">Enabled</option>
382
                                        [% ELSE %]
382
                                        [% ELSE %]
383
                                            <option value="1">Enabled</option>
383
                                            <option value="1">Enabled</option>
384
                                        [% END %]
384
                                        [% END %]
385
                                        [% IF sftp_server.debug == 0 %]
385
                                        [% IF file_transport.debug == 0 %]
386
                                            <option value="0" selected="selected">Disabled</option>
386
                                            <option value="0" selected="selected">Disabled</option>
387
                                        [% ELSE %]
387
                                        [% ELSE %]
388
                                            <option value="0">Disabled</option>
388
                                            <option value="0">Disabled</option>
Lines 401-407 Link Here
401
401
402
                [% IF op == 'list' %]
402
                [% IF op == 'list' %]
403
                    <div id="toolbar" class="btn-toolbar">
403
                    <div id="toolbar" class="btn-toolbar">
404
                        <a class="btn btn-default" id="new_sftp_server" href="/cgi-bin/koha/admin/file_transports.pl?op=add_form"><i class="fa fa-plus"></i> New file transport</a>
404
                        <a class="btn btn-default" id="new_file_transport" href="/cgi-bin/koha/admin/file_transports.pl?op=add_form"><i class="fa fa-plus"></i> New file transport</a>
405
                    </div>
405
                    </div>
406
406
407
                    <h1>File transports</h1>
407
                    <h1>File transports</h1>
Lines 618-624 Link Here
618
                        {
618
                        {
619
                            "data": function(row, type, val, meta) {
619
                            "data": function(row, type, val, meta) {
620
                                let result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/file_transports.pl?op=edit_form&amp;file_transport_id='+ encodeURIComponent(row.file_transport_id) +'"><i class="fa-solid fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
620
                                let result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/file_transports.pl?op=edit_form&amp;file_transport_id='+ encodeURIComponent(row.file_transport_id) +'"><i class="fa-solid fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n";
621
                                result += '<a class="btn btn-default btn-xs delete_server" role="button" href="#" data-bs-toggle="modal" data-bs-target="#delete_confirm_modal" data-sftp-server-id="'+ encodeURIComponent(row.file_transport_id) +'" data-sftp-server-name="'+ encodeURIComponent(row.name.escapeHtml()) +'"><i class="fa fa-trash-can" aria-hidden="true"></i> '+_("Delete")+'</a>';
621
                                result += '<a class="btn btn-default btn-xs delete_server" role="button" href="#" data-bs-toggle="modal" data-bs-target="#delete_confirm_modal" data-file-transport-id="'+ encodeURIComponent(row.file_transport_id) +'" data-file-transport-name="'+ encodeURIComponent(row.name.escapeHtml()) +'"><i class="fa fa-trash-can" aria-hidden="true"></i> '+_("Delete")+'</a>';
622
                                return result;
622
                                return result;
623
                            },
623
                            },
624
                            "searchable": false,
624
                            "searchable": false,
Lines 636-678 Link Here
636
                });
636
                });
637
637
638
                $('#file_transports').on("click", '.delete_server', function() {
638
                $('#file_transports').on("click", '.delete_server', function() {
639
                    var file_transport_id   = $(this).data('sftp-server-id');
639
                    var file_transport_id   = $(this).data('file-transport-id');
640
                    var sftp_server_name = decodeURIComponent($(this).data('sftp-server-name'));
640
                    var file_transport_name = decodeURIComponent($(this).data('file-transport-name'));
641
641
642
                    $("#delete_confirm_dialog").html(
642
                    $("#delete_confirm_dialog").html(
643
                        _("You are about to delete the '%s' file transport.").format(sftp_server_name)
643
                        _("You are about to delete the '%s' file transport.").format(file_transport_name)
644
                    );
644
                    );
645
                    $("#delete_confirm_modal_button").data('sftp-server-id', file_transport_id);
645
                    $("#delete_confirm_modal_button").data('file-transport-id', file_transport_id);
646
                    $("#delete_confirm_modal_button").data('sftp-server-name', sftp_server_name);
646
                    $("#delete_confirm_modal_button").data('file-transport-name', file_transport_name);
647
                });
647
                });
648
648
649
                $("#delete_confirm_modal_button").on("click", function() {
649
                $("#delete_confirm_modal_button").on("click", function() {
650
650
651
                    var file_transport_id   = $(this).data('sftp-server-id');
651
                    var file_transport_id   = $(this).data('file-transport-id');
652
                    var sftp_server_name = $(this).data('sftp-server-name');
652
                    var file_transport_name = $(this).data('file-transport-name');
653
653
654
                    $.ajax({
654
                    $.ajax({
655
                        method: "DELETE",
655
                        method: "DELETE",
656
                        url: "/api/v1/config/file_transports/"+file_transport_id
656
                        url: "/api/v1/config/file_transports/"+file_transport_id
657
                    }).success(function() {
657
                    }).success(function() {
658
                        window.file_transports.api().ajax.reload(function(data) {
658
                        window.file_transports.api().ajax.reload(function(data) {
659
                            $("#sftp_action_result_dialog").hide();
659
                            $("#action_result_dialog").hide();
660
                            $("#sftp_delete_success").html(_("Server '%s' deleted successfully.").format(sftp_server_name)).show();
660
                            $("#delete_success").html(_("Server '%s' deleted successfully.").format(file_transport_name)).show();
661
                        });
661
                        });
662
                    }).fail(function() {
662
                    }).fail(function() {
663
                        $("#sftp_delete_error").html(_("Error deleting server '%s'. Please ensure all linked EDI accounts are unlinked or deleted. Check the logs for details.").format(sftp_server_name)).show();
663
                        $("#delete_error").html(_("Error deleting server '%s'. Please ensure all linked EDI accounts are unlinked or deleted. Check the logs for details.").format(file_transport_name)).show();
664
                    }).done(function() {
664
                    }).done(function() {
665
                        $("#delete_confirm_modal").modal('hide');
665
                        $("#delete_confirm_modal").modal('hide');
666
                    });
666
                    });
667
                });
667
                });
668
668
669
                transportChange();
669
                transportChange();
670
                $("#sftp_transport").on("change", function(event) {
670
                $("#transport").on("change", function(event) {
671
                    transportChange();
671
                    transportChange();
672
                });
672
                });
673
673
674
                authModeChange();
674
                authModeChange();
675
                $("#sftp_auth_mode").on("change", function(event) {
675
                $("#auth_mode").on("change", function(event) {
676
                    authModeChange();
676
                    authModeChange();
677
                });
677
                });
678
678
Lines 714-786 Link Here
714
            });
714
            });
715
715
716
            function transportChange() {
716
            function transportChange() {
717
                let sftp_transport = $("#sftp_transport");
717
                let transport = $("#transport");
718
718
719
                if(sftp_transport.val() == "ftp") {
719
                if(transport.val() == "ftp") {
720
                    $("#sftp_host").removeAttr("disabled");
720
                    $("#host").removeAttr("disabled");
721
                    $("#sftp_port").removeAttr("disabled");
721
                    $("#port").removeAttr("disabled");
722
                    $("#sftp_passive").removeAttr("disabled");
722
                    $("#passive").removeAttr("disabled");
723
                    $("#sftp_auth_mode").removeAttr("disabled");
723
                    $("#auth_mode").removeAttr("disabled");
724
                    $("#sftp_user_name").removeAttr("disabled");
724
                    $("#user_name").removeAttr("disabled");
725
                    $("#sftp_password").removeAttr("disabled");
725
                    $("#password").removeAttr("disabled");
726
                    $("#sftp_key_file").attr("disabled", "disabled");
726
                    $("#key_file").attr("disabled", "disabled");
727
727
728
                    $("#sftp_auth_mode option[value='password']").removeAttr("disabled");
728
                    $("#auth_mode option[value='password']").removeAttr("disabled");
729
                    $("#sftp_auth_mode option[value='key_file']").attr("disabled", "disabled");
729
                    $("#auth_mode option[value='key_file']").attr("disabled", "disabled");
730
                    $("#sftp_auth_mode option[value='noauth']").removeAttr("disabled");
730
                    $("#auth_mode option[value='noauth']").removeAttr("disabled");
731
                    if($("#sftp_auth_mode option:selected").val() == "key_file") {
731
                    if($("#auth_mode option:selected").val() == "key_file") {
732
                        $("#sftp_auth_mode option[value='password']").prop("selected", true);
732
                        $("#auth_mode option[value='password']").prop("selected", true);
733
                    }
733
                    }
734
734
735
                    let sftp_port = $("#sftp_port").val();
735
                    let port = $("#port").val();
736
                    if(sftp_port == 22) $("#sftp_port").val("21");
736
                    if(port == 22) $("#port").val("21");
737
737
738
                    authModeChange();
738
                    authModeChange();
739
                } else if(sftp_transport.val() == "sftp") {
739
                } else if(transport.val() == "sftp") {
740
                    $("#sftp_host").removeAttr("disabled");
740
                    $("#host").removeAttr("disabled");
741
                    $("#sftp_port").removeAttr("disabled");
741
                    $("#port").removeAttr("disabled");
742
                    $("#sftp_passive").attr("disabled", "disabled");
742
                    $("#passive").attr("disabled", "disabled");
743
                    $("#sftp_auth_mode").removeAttr("disabled");
743
                    $("#auth_mode").removeAttr("disabled");
744
                    $("#sftp_user_name").removeAttr("disabled");
744
                    $("#user_name").removeAttr("disabled");
745
                    $("#sftp_password").removeAttr("disabled");
745
                    $("#password").removeAttr("disabled");
746
                    $("#sftp_key_file").removeAttr("disabled");
746
                    $("#key_file").removeAttr("disabled");
747
747
748
                    $("#sftp_auth_mode option[value='password']").removeAttr("disabled");
748
                    $("#auth_mode option[value='password']").removeAttr("disabled");
749
                    $("#sftp_auth_mode option[value='key_file']").removeAttr("disabled");
749
                    $("#auth_mode option[value='key_file']").removeAttr("disabled");
750
                    $("#sftp_auth_mode option[value='noauth']").removeAttr("disabled");
750
                    $("#auth_mode option[value='noauth']").removeAttr("disabled");
751
                    $("#sftp_passive option[value='1']").prop("selected", true);
751
                    $("#passive option[value='1']").prop("selected", true);
752
752
753
                    let sftp_port = $("#sftp_port").val();
753
                    let port = $("#port").val();
754
                    if(sftp_port == 21) $("#sftp_port").val("22");
754
                    if(port == 21) $("#port").val("22");
755
755
756
                    return authModeChange();
756
                    return authModeChange();
757
                }
757
                }
758
            }
758
            }
759
759
760
            function authModeChange() {
760
            function authModeChange() {
761
                let sftp_auth_mode = $("#sftp_auth_mode").val();
761
                let auth_mode = $("#auth_mode").val();
762
762
763
                if(sftp_auth_mode == "password") {
763
                if(auth_mode == "password") {
764
                    $("#sftp_password").removeAttr("disabled");
764
                    $("#password").removeAttr("disabled");
765
                    $("#sftp_key_file").attr("disabled", "disabled");
765
                    $("#key_file").attr("disabled", "disabled");
766
                } else if(sftp_auth_mode == "key_file") {
766
                } else if(auth_mode == "key_file") {
767
                    $("#sftp_password").attr("disabled", "disabled");
767
                    $("#password").attr("disabled", "disabled");
768
                    $("#sftp_key_file").removeAttr("disabled");
768
                    $("#key_file").removeAttr("disabled");
769
                } else {
769
                } else {
770
                    $("#sftp_password").attr("disabled", "disabled");
770
                    $("#password").attr("disabled", "disabled");
771
                    $("#sftp_key_file").attr("disabled", "disabled");
771
                    $("#key_file").attr("disabled", "disabled");
772
                }
772
                }
773
            }
773
            }
774
774
775
            function modalChange() {
775
            function modalChange() {
776
                $('#modal_message').hide();
776
                $('#modal_message').hide();
777
                if ( $('#sftp_transport').val() == 'sftp' ) $('#modal_message').show();
777
                if ( $('#transport').val() == 'sftp' ) $('#modal_message').show();
778
778
779
                $('#modal_host').text( $('#sftp_host').val() );
779
                $('#modal_host').text( $('#host').val() );
780
                $('#modal_port').text( $('#sftp_port').val() );
780
                $('#modal_port').text( $('#port').val() );
781
                $('#modal_transport').text( $('#sftp_transport option:selected').text() );
781
                $('#modal_transport').text( $('#transport option:selected').text() );
782
                $('#modal_user_name').text( $('#sftp_user_name').val() );
782
                $('#modal_user_name').text( $('#user_name').val() );
783
                $('#modal_auth_mode').text( $('#sftp_auth_mode option:selected').text() );
783
                $('#modal_auth_mode').text( $('#auth_mode option:selected').text() );
784
            }
784
            }
785
        </script>
785
        </script>
786
    [% END %]
786
    [% END %]
787
- 

Return to bug 38489