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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt (-1 / +7 lines)
Lines 239-244 Link Here
239
                    </select>
239
                    </select>
240
                    [% INCLUDE 'html-customization-help.inc' %]
240
                    [% INCLUDE 'html-customization-help.inc' %]
241
                </li>
241
                </li>
242
                [% UNLESS my_branch %]
242
                <li>
243
                <li>
243
                    <label for="branchcode">Library: </label>
244
                    <label for="branchcode">Library: </label>
244
                    <select id="branchcode" name="branchcode">
245
                    <select id="branchcode" name="branchcode">
Lines 250-255 Link Here
250
                        [% PROCESS options_for_libraries libraries => Branches.all( selected => additional_content.branchcode, unfiltered => 1, ) %]
251
                        [% PROCESS options_for_libraries libraries => Branches.all( selected => additional_content.branchcode, unfiltered => 1, ) %]
251
                    </select>
252
                    </select>
252
                </li>
253
                </li>
254
                [% END %]
253
                [% UNLESS languages.size %]
255
                [% UNLESS languages.size %]
254
                    <li>
256
                    <li>
255
                        [% IF category == 'news' %]
257
                        [% IF category == 'news' %]
Lines 404-410 Link Here
404
                            [% SET default_localization = c.default_localization %]
406
                            [% SET default_localization = c.default_localization %]
405
                            [% IF ( c.is_expired ) %]<tr class="expired">[% ELSE %]<tr>[% END %]
407
                            [% IF ( c.is_expired ) %]<tr class="expired">[% ELSE %]<tr>[% END %]
406
                            <td>
408
                            <td>
407
                                <input type="checkbox" name="ids" value="[% c.id | html %]" />
409
                            [% UNLESS ( my_branch && my_branch != c.branchcode ) %]
410
                                <input type="checkbox" name="ids" value="[% c.idnew | html %]" />
411
                            [% END %]
408
                            </td>
412
                            </td>
409
                            <td>
413
                            <td>
410
                                [% IF c.category == 'news' || c.category == 'pages' %]
414
                                [% IF c.category == 'news' || c.category == 'pages' %]
Lines 460-465 Link Here
460
                                </div>
464
                                </div>
461
                            </td>
465
                            </td>
462
                            <td class="actions">
466
                            <td class="actions">
467
                            [% UNLESS ( my_branch && my_branch != c.branchcode ) %]
463
                                <div class="btn-group dropup">
468
                                <div class="btn-group dropup">
464
                                    <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.id | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa-solid fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
469
                                    <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&amp;id=[% c.id | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa-solid fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">
465
                                        <span class="caret"></span>
470
                                        <span class="caret"></span>
Lines 477-482 Link Here
477
                                <div class="btn-group">
482
                                <div class="btn-group">
478
                                    <a href="#" class="delete_news btn btn-default btn-xs" data-id="[% c.id | html %]"><i class="fa fa-trash-can"></i> Delete</a>
483
                                    <a href="#" class="delete_news btn btn-default btn-xs" data-id="[% c.id | html %]"><i class="fa fa-trash-can"></i> Delete</a>
479
                                </div>
484
                                </div>
485
                            [% END %]
480
                            </td>
486
                            </td>
481
                        </tr>
487
                        </tr>
482
                        [% END %]
488
                        [% END %]
(-)a/tools/additional-contents.pl (-38 / +46 lines)
Lines 38-51 use Koha::AdditionalContents; Link Here
38
38
39
my $cgi = CGI->new;
39
my $cgi = CGI->new;
40
40
41
my $op             = $cgi->param('op') || 'list';
41
my $op       = $cgi->param('op') || 'list';
42
my $id             = $cgi->param('id');
42
my $id       = $cgi->param('id');
43
my $category       = $cgi->param('category') || 'news';
43
my $category = $cgi->param('category') || 'news';
44
my $wysiwyg;
44
my $wysiwyg;
45
my $redirect       = $cgi->param('redirect');
45
my $redirect = $cgi->param('redirect');
46
my $editmode;
46
my $editmode;
47
47
48
if( $cgi->param('editmode') ){
48
if ( $cgi->param('editmode') ) {
49
    $wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0;
49
    $wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0;
50
} else {
50
} else {
51
    $wysiwyg = C4::Context->preference("AdditionalContentsEditor") eq "tinymce" ? 1 : 0;
51
    $wysiwyg = C4::Context->preference("AdditionalContentsEditor") eq "tinymce" ? 1 : 0;
Lines 55-68 $editmode = $wysiwyg eq 1 ? "wysiwyg" : "text"; Link Here
55
55
56
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
56
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
57
    {
57
    {
58
        template_name   => "tools/additional-contents.tt",
58
        template_name => "tools/additional-contents.tt",
59
        query           => $cgi,
59
        query         => $cgi,
60
        type            => "intranet",
60
        type          => "intranet",
61
        flagsrequired   => { tools => 'edit_additional_contents' },
61
        flagsrequired => { tools => 'edit_additional_contents' },
62
    }
62
    }
63
);
63
);
64
64
65
my @messages;
65
my @messages;
66
my $my_branch =
67
    C4::Context->preference("IndependentBranches")
68
    && !C4::Context->IsSuperLibrarian()
69
    ? C4::Context->userenv()->{'branch'}
70
    : undef;
66
if ( $op eq 'add_form' ) {
71
if ( $op eq 'add_form' ) {
67
72
68
    my $additional_content = Koha::AdditionalContents->find($id);
73
    my $additional_content = Koha::AdditionalContents->find($id);
Lines 72-92 if ( $op eq 'add_form' ) { Link Here
72
        $category            = $additional_content->category;
77
        $category            = $additional_content->category;
73
    }
78
    }
74
    $template->param(
79
    $template->param(
75
        additional_content => $additional_content,
80
        my_branch           => $my_branch,
81
        additional_content  => $additional_content,
76
        translated_contents => $translated_contents,
82
        translated_contents => $translated_contents,
77
    );
83
    );
78
}
84
} elsif ( $op eq 'cud-add_validate' ) {
79
elsif ( $op eq 'cud-add_validate' ) {
80
    output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } );
85
    output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } );
81
    my $location   = $cgi->param('location');
86
    my $location   = $cgi->param('location');
82
    my $code       = $cgi->param('code');
87
    my $code       = $cgi->param('code');
83
    my $branchcode = $cgi->param('branchcode') || undef;
88
    my $branchcode = $my_branch ? $my_branch : $cgi->param('branchcode') || undef;
89
    my $idnew      = $cgi->param('idnew');
84
90
85
    my @lang       = $cgi->multi_param('lang');
91
    my @lang = $cgi->multi_param('lang');
86
92
87
    my $expirationdate = $cgi->param('expirationdate');
93
    my $expirationdate = $cgi->param('expirationdate');
88
    my $published_on = $cgi->param('published_on');
94
    my $published_on   = $cgi->param('published_on');
89
    my $number = $cgi->param('number');
95
    my $number         = $cgi->param('number');
90
96
91
    try {
97
    try {
92
        Koha::Database->new->schema->txn_do(
98
        Koha::Database->new->schema->txn_do(
Lines 181-208 elsif ( $op eq 'cud-add_validate' ) { Link Here
181
        }
187
        }
182
    };
188
    };
183
189
184
    if( $redirect eq "just_save" ){
190
    if ( $redirect eq "just_save" ) {
185
        print $cgi->redirect("/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=$id&category=$category&editmode=$editmode&redirect=done");
191
        print $cgi->redirect(
192
            "/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=$id&category=$category&editmode=$editmode&redirect=done"
193
        );
186
        exit;
194
        exit;
187
    } else {
195
    } else {
188
        $op = 'list';
196
        $op = 'list';
189
    }
197
    }
190
}
198
} elsif ( $op eq 'cud-delete_confirmed' ) {
191
elsif ( $op eq 'cud-delete_confirmed' ) {
199
    output_and_exit_if_error( $cgi, $cookie, $template, { check => 'csrf_token' } );
192
    output_and_exit_if_error($cgi, $cookie, $template, { check => 'csrf_token' });
193
    my @ids = $cgi->multi_param('ids');
200
    my @ids = $cgi->multi_param('ids');
194
201
195
    try {
202
    try {
196
        Koha::Database->new->schema->txn_do(
203
        Koha::Database->new->schema->txn_do(
197
            sub {
204
            sub {
198
                my $contents =
205
                my $contents = Koha::AdditionalContents->search( { id => \@ids } );
199
                  Koha::AdditionalContents->search( { id => \@ids } );
200
206
201
                if ( C4::Context->preference("NewsLog") ) {
207
                if ( C4::Context->preference("NewsLog") ) {
202
                    while ( my $c = $contents->next ) {
208
                    while ( my $c = $contents->next ) {
203
                        my $translated_contents = $c->translated_contents;
209
                        my $translated_contents = $c->translated_contents;
204
                        while ( my $translated_content = $translated_contents->next ) {
210
                        while ( my $translated_content = $translated_contents->next ) {
205
                            logaction('NEWS', 'DELETE' , undef, sprintf("%s|%s|%s|%s", $c->code, $translated_content->lang, $translated_content->content));
211
                            logaction(
212
                                'NEWS', 'DELETE', undef,
213
                                sprintf(
214
                                    "%s|%s|%s|%s", $c->code, $translated_content->lang, $translated_content->content
215
                                )
216
                            );
206
                        }
217
                        }
207
                    }
218
                    }
208
                }
219
                }
Lines 220-229 elsif ( $op eq 'cud-delete_confirmed' ) { Link Here
220
231
221
if ( $op eq 'list' ) {
232
if ( $op eq 'list' ) {
222
    my $additional_contents = Koha::AdditionalContents->search(
233
    my $additional_contents = Koha::AdditionalContents->search(
223
        { category => $category, 'additional_contents_localizations.lang' => 'default' },
234
        { category => $category,                   'additional_contents_localizations.lang' => 'default' },
224
        { order_by => { -desc => 'published_on' }, join => 'additional_contents_localizations' }
235
        { order_by => { -desc => 'published_on' }, join => 'additional_contents_localizations' }
225
    );
236
    );
226
    $template->param( additional_contents => $additional_contents );
237
    $template->param( additional_contents => $additional_contents, my_branch => $my_branch );
227
}
238
}
228
239
229
my $translated_languages = C4::Languages::getTranslatedLanguages;
240
my $translated_languages = C4::Languages::getTranslatedLanguages;
Lines 232-255 for my $language (@$translated_languages) { Link Here
232
    for my $sublanguage ( @{ $language->{sublanguages_loop} } ) {
243
    for my $sublanguage ( @{ $language->{sublanguages_loop} } ) {
233
        if ( $language->{plural} ) {
244
        if ( $language->{plural} ) {
234
            push @languages,
245
            push @languages,
235
              {
246
                {
236
                lang        => $sublanguage->{rfc4646_subtag},
247
                lang        => $sublanguage->{rfc4646_subtag},
237
                description => $sublanguage->{native_description} . ' '
248
                description => $sublanguage->{native_description} . ' '
238
                  . $sublanguage->{region_description} . ' ('
249
                    . $sublanguage->{region_description} . ' ('
239
                  . $sublanguage->{rfc4646_subtag} . ')',
250
                    . $sublanguage->{rfc4646_subtag} . ')',
240
              };
251
                };
241
        }
252
        } else {
242
        else {
243
            push @languages,
253
            push @languages,
244
              {
254
                {
245
                lang        => $sublanguage->{rfc4646_subtag},
255
                lang        => $sublanguage->{rfc4646_subtag},
246
                description => $sublanguage->{native_description} . ' ('
256
                description => $sublanguage->{native_description} . ' (' . $sublanguage->{rfc4646_subtag} . ')',
247
                  . $sublanguage->{rfc4646_subtag} . ')',
257
                };
248
              };
249
        }
258
        }
250
    }
259
    }
251
}
260
}
252
unshift @languages, {lang => 'default'} if @languages;
261
unshift @languages, { lang => 'default' } if @languages;
253
262
254
$template->param(
263
$template->param(
255
    op        => $op,
264
    op        => $op,
256
- 

Return to bug 34631