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

(-)a/Koha/UploadedFiles.pm (-1 / +14 lines)
Lines 159-165 sub search_term { Link Here
159
    }
159
    }
160
    return $self->search(
160
    return $self->search(
161
        [ { filename => { like => '%'.$term.'%' }, %public },
161
        [ { filename => { like => '%'.$term.'%' }, %public },
162
          { hashvalue => { like => '%'.$params->{term}.'%' }, %public } ],
162
          { hashvalue => { like => '%'.$params->{term}.'%' }, %public },
163
          { dir => { like => '%'.$params->{term}.'%' }, %public } ],
163
        { order_by => { -asc => 'id' }},
164
        { order_by => { -asc => 'id' }},
164
    );
165
    );
165
}
166
}
Lines 178-183 sub getCategories { Link Here
178
    [ map {{ code => $_->{authorised_value}, name => $_->{lib} }} @$cats ];
179
    [ map {{ code => $_->{authorised_value}, name => $_->{lib} }} @$cats ];
179
}
180
}
180
181
182
=head3 getPaths
183
184
getPaths returns a list of upload path codes and names
185
186
=cut
187
188
sub getPaths {
189
    my ( $class ) = @_;
190
    my $cats = C4::Koha::GetAuthorisedValues('UPLOAD_PATH');
191
    [ map {{ code => $_->{authorised_value}, name => $_->{lib} }} @$cats ];
192
}
193
181
=head3 _type
194
=head3 _type
182
195
183
Returns name of corresponding DBIC resultset
196
Returns name of corresponding DBIC resultset
(-)a/installer/data/mysql/atomicupdate/bug_20208.perl (+3 lines)
Lines 9-14 if( CheckVersion( $DBversion ) ) { Link Here
9
        });
9
        });
10
        $dbh->do("ALTER TABLE `uploaded_files` MODIFY COLUMN `dir` mediumtext DEFAULT NULL");
10
        $dbh->do("ALTER TABLE `uploaded_files` MODIFY COLUMN `dir` mediumtext DEFAULT NULL");
11
    }
11
    }
12
    $dbh->do(q{
13
        INSERT IGNORE INTO authorised_value_categories( category_name ) VALUES ('UPLOAD_PATH')
14
    });
12
    SetVersion( $DBversion );
15
    SetVersion( $DBversion );
13
    print "Upgrade to $DBversion done (Bug 20208 - Development - Peddie School - Custom file upload paths)\n";
16
    print "Upgrade to $DBversion done (Bug 20208 - Development - Peddie School - Custom file upload paths)\n";
14
}
17
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt (-3 / +32 lines)
Lines 48-53 Link Here
48
            <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
48
            <input type="file" id="fileToUpload" name="fileToUpload" multiple/>
49
        </div>
49
        </div>
50
        </li>
50
        </li>
51
        <li>
52
            <label for="fileChecksum">Add file checksum to the uploaded filename: </label>
53
            <label class="radio">
54
                Yes<input type="radio" name="checksum" id="checksum" value="1" checked />
55
                No<input type="radio" name="checksum" id="checksum" value="0" />
56
            </label>
57
        </li>
58
        [% IF uploadpaths %]
59
            <li>
60
                <label for="uploadpath">Upload Path: </label>
61
                <select id="uploadpath" name="uploadpath">
62
                [% IF !plugin %]
63
                    <option value=""></option>
64
                [% END %]
65
                [% FOREACH dir IN uploadpaths %]
66
                    <option value="[% dir.code | html %]">[% dir.name | html %]</option>
67
                [% END %]
68
                </select>
69
            </li>
70
        [% END %]
51
        [% IF uploadcategories %]
71
        [% IF uploadcategories %]
52
            <li>
72
            <li>
53
                <label for="uploadcategory">Category: </label>
73
                <label for="uploadcategory">Category: </label>
Lines 156-162 Link Here
156
    <tr>
176
    <tr>
157
        <th>Filename</th>
177
        <th>Filename</th>
158
        <th>Size</th>
178
        <th>Size</th>
179
        <th>File checksum</th>
159
        <th>Hashvalue</th>
180
        <th>Hashvalue</th>
181
        <th>Upload path</th>
160
        <th>Category</th>
182
        <th>Category</th>
161
        [% IF !plugin %]<th>Public</th>[% END %]
183
        [% IF !plugin %]<th>Public</th>[% END %]
162
        [% IF !plugin %]<th>Temporary</th>[% END %]
184
        [% IF !plugin %]<th>Temporary</th>[% END %]
Lines 168-174 Link Here
168
    <tr>
190
    <tr>
169
        <td>[% record.filename | html %]</td>
191
        <td>[% record.filename | html %]</td>
170
        <td>[% record.filesize | html %]</td>
192
        <td>[% record.filesize | html %]</td>
193
        <td>[% IF record.checksum %]Yes[% ELSE %]No[% END %]</td>
171
        <td>[% record.hashvalue | html %]</td>
194
        <td>[% record.hashvalue | html %]</td>
195
        <td>[% record.dir | html %]</td>
172
        <td>[% record.uploadcategorycode | html %]</td>
196
        <td>[% record.uploadcategorycode | html %]</td>
173
        [% IF !plugin %]
197
        [% IF !plugin %]
174
            <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
198
            <td>[% IF record.public %]Yes[% ELSE %]No[% END %]</td>
Lines 271-286 Link Here
271
            $("#searchfile").hide();
295
            $("#searchfile").hide();
272
            $("#lastbreadcrumb").text( _("Add a new upload") );
296
            $("#lastbreadcrumb").text( _("Add a new upload") );
273
297
274
            var cat, xtra='';
298
            var dir, cat, xtra='';
275
            if( $("#uploadcategory").val() )
299
            if( $("#uploadcategory").val() )
276
                cat = encodeURIComponent( $("#uploadcategory").val() );
300
                cat = encodeURIComponent( $("#uploadcategory").val() );
277
            if( cat ) xtra= 'category=' + cat + '&';
301
            if( cat ) xtra= 'category=' + cat + '&';
302
278
            [% IF plugin %]
303
            [% IF plugin %]
279
                xtra = xtra + 'public=1&temp=0';
304
                xtra = xtra + 'public=1&temp=0&';
280
            [% ELSE %]
305
            [% ELSE %]
281
                if( !cat ) xtra = 'temp=1&';
306
                if( !cat ) xtra = 'temp=1&';
282
                if( $('#public').prop('checked') ) xtra = xtra + 'public=1';
307
                if( $('#public').prop('checked') ) xtra = xtra + 'public=1&';
283
            [% END %]
308
            [% END %]
309
            if( $("#uploadpath").val() )
310
                dir = encodeURIComponent( $("#uploadpath").val() );
311
            if( dir ) xtra= xtra + 'dir=' + dir + '&';
312
            xtra = xtra + 'checksum=' + $('#checksum:checked').val();
284
            xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
313
            xhr= AjaxUpload( $('#fileToUpload'), $('#fileuploadprogress'), xtra, cbUpload );
285
        }
314
        }
286
        function CancelUpload() {
315
        function CancelUpload() {
(-)a/tools/upload-file.pl (-2 / +2 lines)
Lines 75-82 sub upload_pars { # this sub parses QUERY_STRING in order to build the Link Here
75
    $qstr = Encode::decode_utf8( uri_unescape( $qstr ) );
75
    $qstr = Encode::decode_utf8( uri_unescape( $qstr ) );
76
    # category could include a utf8 character
76
    # category could include a utf8 character
77
    my $rv = {};
77
    my $rv = {};
78
    foreach my $p ( qw[public category temp] ) {
78
    foreach my $p ( qw[public category temp checksum dir] ) {
79
        if( $qstr =~ /(^|&)$p=(\w+)(&|$)/ ) {
79
        if( $qstr =~ /(^|&)$p=([\w\/\_]*)(&|$)/ ) {
80
            $rv->{$p} = $2;
80
            $rv->{$p} = $2;
81
        }
81
        }
82
    }
82
    }
(-)a/tools/upload.pl (-1 / +1 lines)
Lines 51-56 $template->param( Link Here
51
    owner      => $loggedinuser,
51
    owner      => $loggedinuser,
52
    plugin     => $plugin,
52
    plugin     => $plugin,
53
    uploadcategories => Koha::UploadedFiles->getCategories,
53
    uploadcategories => Koha::UploadedFiles->getCategories,
54
    uploadpaths => Koha::UploadedFiles->getPaths,
54
);
55
);
55
56
56
if ( $op eq 'new' ) {
57
if ( $op eq 'new' ) {
57
- 

Return to bug 20208