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

(-)a/C4/Auth.pm (-2 lines)
Lines 1378-1385 sub checkauth { Link Here
1378
        OpacAuthorities                       => C4::Context->preference("OpacAuthorities"),
1378
        OpacAuthorities                       => C4::Context->preference("OpacAuthorities"),
1379
        OpacBrowser                           => C4::Context->preference("OpacBrowser"),
1379
        OpacBrowser                           => C4::Context->preference("OpacBrowser"),
1380
        TagsEnabled                           => C4::Context->preference("TagsEnabled"),
1380
        TagsEnabled                           => C4::Context->preference("TagsEnabled"),
1381
        OPACUserJS                            => C4::Context->preference("OPACUserJS"),
1382
        OPACUserCSS                           => C4::Context->preference("OPACUserCSS"),
1383
        intranetcolorstylesheet               => C4::Context->preference("intranetcolorstylesheet"),
1381
        intranetcolorstylesheet               => C4::Context->preference("intranetcolorstylesheet"),
1384
        intranetstylesheet                    => C4::Context->preference("intranetstylesheet"),
1382
        intranetstylesheet                    => C4::Context->preference("intranetstylesheet"),
1385
        IntranetNav                           => C4::Context->preference("IntranetNav"),
1383
        IntranetNav                           => C4::Context->preference("IntranetNav"),
(-)a/Koha/Library.pm (+2 lines)
Lines 353-358 sub to_api_mapping { Link Here
353
        branchip         => 'ip',
353
        branchip         => 'ip',
354
        branchnotes      => 'notes',
354
        branchnotes      => 'notes',
355
        marcorgcode      => 'marc_org_code',
355
        marcorgcode      => 'marc_org_code',
356
        opacusercss      => undef,
357
        opacuserjs       => undef
356
    };
358
    };
357
}
359
}
358
360
(-)a/Koha/Template/Plugin/Branches.pm (-8 / +8 lines)
Lines 154-178 sub pickup_locations { Link Here
154
}
154
}
155
155
156
sub GetBranchSpecificJS {
156
sub GetBranchSpecificJS {
157
    my ($self, $branchcode) = @_;
157
    my ( $self, $branchcode ) = @_;
158
158
159
    return q{} unless defined $branchcode;
159
    return q{} unless defined $branchcode;
160
160
161
    my $library = Koha::Libraries->find($branchcode);
161
    my $library    = Koha::Libraries->find($branchcode);
162
    my $userjs = $library ? $library->userjs : q{};
162
    my $opacuserjs = $library ? $library->opacuserjs : q{};
163
163
164
    return $userjs
164
    return $opacuserjs;
165
}
165
}
166
166
167
sub GetBranchSpecificCSS {
167
sub GetBranchSpecificCSS {
168
    my ($self, $branchcode) = @_;
168
    my ( $self, $branchcode ) = @_;
169
169
170
    return q{} unless defined $branchcode;
170
    return q{} unless defined $branchcode;
171
171
172
    my $library = Koha::Libraries->find($branchcode);
172
    my $library     = Koha::Libraries->find($branchcode);
173
    my $usercss = $library ? $library->usercss : q{};
173
    my $opacusercss = $library ? $library->opacusercss : q{};
174
174
175
    return $usercss
175
    return $opacusercss;
176
}
176
}
177
177
178
1;
178
1;
(-)a/admin/branches.pl (-2 / +2 lines)
Lines 81-88 if ( $op eq 'add_form' ) { Link Here
81
      marcorgcode
81
      marcorgcode
82
      pickup_location
82
      pickup_location
83
      public
83
      public
84
      userjs
84
      opacuserjs
85
      usercss
85
      opacusercss
86
    );
86
    );
87
    my $is_a_modif = $input->param('is_a_modif');
87
    my $is_a_modif = $input->param('is_a_modif');
88
88
(-)a/api/v1/swagger/definitions/library.yaml (-10 lines)
Lines 107-122 properties: Link Here
107
  public:
107
  public:
108
    type: boolean
108
    type: boolean
109
    description: If the library is visible to the public
109
    description: If the library is visible to the public
110
  userjs:
111
    type:
112
      - string
113
      - "null"
114
    description: Any branch-specific UserJS for the OPAC
115
  usercss:
116
    type:
117
      - string
118
      - "null"
119
    description: Any branch-specific UserCSS for the OPAC
120
  smtp_server:
110
  smtp_server:
121
    type:
111
    type:
122
      - object
112
      - object
(-)a/installer/data/mysql/atomicupdate/bug_32721-add_branch_level_js.pl (-7 / +7 lines)
Lines 7-25 return { Link Here
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
9
10
        if( !column_exists( 'branches', 'userjs' ) ) {
10
        if( !column_exists( 'branches', 'opacuserjs' ) ) {
11
          $dbh->do(q{
11
          $dbh->do(q{
12
              ALTER TABLE branches ADD COLUMN `userjs` longtext DEFAULT NULL AFTER `public`
12
              ALTER TABLE branches ADD COLUMN `opacuserjs` longtext DEFAULT NULL AFTER `public`
13
          });
13
          });
14
14
15
          say $out "Added column 'branches.userjs'";
15
          say $out "Added column 'branches.opacuserjs'";
16
        }
16
        }
17
        if( !column_exists( 'branches', 'usercss' ) ) {
17
        if( !column_exists( 'branches', 'opacusercss' ) ) {
18
          $dbh->do(q{
18
          $dbh->do(q{
19
              ALTER TABLE branches ADD COLUMN `usercss` longtext DEFAULT NULL AFTER `userjs`
19
              ALTER TABLE branches ADD COLUMN `opacusercss` longtext DEFAULT NULL AFTER `opacuserjs`
20
          });
20
          });
21
21
22
          say $out "Added column 'branches.usercss'";
22
          say $out "Added column 'branches.opacusercss'";
23
        }
23
        }
24
    },
24
    },
25
};
25
};
(-)a/installer/data/mysql/kohastructure.sql (-2 / +2 lines)
Lines 1609-1616 CREATE TABLE `branches` ( Link Here
1609
  `marcorgcode` varchar(16) DEFAULT NULL COMMENT 'MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode',
1609
  `marcorgcode` varchar(16) DEFAULT NULL COMMENT 'MARC Organization Code, see http://www.loc.gov/marc/organizations/orgshome.html, when empty defaults to syspref MARCOrgCode',
1610
  `pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'the ability to act as a pickup location',
1610
  `pickup_location` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'the ability to act as a pickup location',
1611
  `public` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether this library should show in the opac',
1611
  `public` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'whether this library should show in the opac',
1612
  `userjs` longtext DEFAULT NULL COMMENT 'branch specific javascript for the OPAC',
1612
  `opacuserjs` longtext DEFAULT NULL COMMENT 'branch specific javascript for the OPAC',
1613
  `usercss` longtext DEFAULT NULL COMMENT 'branch specific css for the OPAC',
1613
  `opacusercss` longtext DEFAULT NULL COMMENT 'branch specific css for the OPAC',
1614
  PRIMARY KEY (`branchcode`)
1614
  PRIMARY KEY (`branchcode`)
1615
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1615
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1616
/*!40101 SET character_set_client = @saved_cs_client */;
1616
/*!40101 SET character_set_client = @saved_cs_client */;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt (-6 / +6 lines)
Lines 291-307 Link Here
291
                <li>
291
                <li>
292
                    <label for="UserJS">UserJS: </label>
292
                    <label for="UserJS">UserJS: </label>
293
                    <div style="display:flex; flex-direction:column;">
293
                    <div style="display:flex; flex-direction:column;">
294
                        <a class="expand-textarea" id="expand_userjs" data-target="userjs" data-syntax="javascript" href="#">Click to edit</a>
294
                        <a class="expand-textarea" id="expand_opacuserjs" data-target="opacuserjs" data-syntax="javascript" href="#">Click to edit</a>
295
                        <textarea style="display:none" name="userjs" id="userjs" class="codemirror" rows="10" cols="40">[% library.userjs | html %]</textarea>
295
                        <textarea style="display:none" name="opacuserjs" id="opacuserjs" class="codemirror" rows="10" cols="40">[% library.opacuserjs | html %]</textarea>
296
                        <a class="collapse-textarea" id="collapse_userjs" data-target="userjs" data-syntax="javascript" style="display:none" href="#">Click to collapse</br></a>
296
                        <a class="collapse-textarea" id="collapse_opacuserjs" data-target="opacuserjs" data-syntax="javascript" style="display:none" href="#">Click to collapse</br></a>
297
                    </div>
297
                    </div>
298
                </li>
298
                </li>
299
                <li>
299
                <li>
300
                    <label for="UserCSS">UserCSS: </label>
300
                    <label for="UserCSS">UserCSS: </label>
301
                    <div style="display:flex; flex-direction:column;">
301
                    <div style="display:flex; flex-direction:column;">
302
                        <a class="expand-textarea" id="expand_usercss" data-target="usercss" data-syntax="css" href="#">Click to edit</a>
302
                        <a class="expand-textarea" id="expand_opacusercss" data-target="opacusercss" data-syntax="css" href="#">Click to edit</a>
303
                        <textarea style="display:none" name="usercss" id="usercss" class="" rows="10" cols="40">[% library.usercss | html %]</textarea>
303
                        <textarea style="display:none" name="opacusercss" id="opacusercss" class="" rows="10" cols="40">[% library.opacusercss | html %]</textarea>
304
                        <a class="collapse-textarea" id="collapse_usercss" data-target="usercss" data-syntax="css" style="display:none" href="#">Click to collapse</br></a>
304
                        <a class="collapse-textarea" id="collapse_opacusercss" data-target="opacusercss" data-syntax="css" style="display:none" href="#">Click to collapse</br></a>
305
                    </div>
305
                    </div>
306
                </li>
306
                </li>
307
                </li>
307
                </li>
(-)a/t/db_dependent/Template/Plugin/Branches.t (-17 / +16 lines)
Lines 227-261 subtest 'branch specific js and css' => sub { Link Here
227
    my $newbranch_with = $builder->build({
227
    my $newbranch_with = $builder->build({
228
        source => 'Branch',
228
        source => 'Branch',
229
        value => {
229
        value => {
230
            userjs => 'console.log(\'Hello World\');',
230
            opacuserjs => 'console.log(\'Hello World\');',
231
            usercss => 'body { background-color: blue; }'
231
            opacusercss => 'body { background-color: blue; }'
232
        }
232
        }
233
    });
233
    });
234
    my $newbranch_none = $builder->build({
234
    my $newbranch_none = $builder->build({
235
        source => 'Branch',
235
        source => 'Branch',
236
        value => {
236
        value => {
237
            userjs => '',
237
            opacuserjs => '',
238
            usercss => ''
238
            opacusercss => ''
239
        }
239
        }
240
    });
240
    });
241
241
242
    my $plugin = Koha::Template::Plugin::Branches->new();
242
    my $plugin = Koha::Template::Plugin::Branches->new();
243
243
244
    my $userjs = $plugin->GetBranchSpecificJS($newbranch_with->{branchcode});
244
    my $opacuserjs = $plugin->GetBranchSpecificJS($newbranch_with->{branchcode});
245
    is($userjs, $newbranch_with->{userjs},'received correct JS string from function');
245
    is($opacuserjs, $newbranch_with->{opacuserjs},'received correct JS string from function');
246
246
247
    my $usercss = $plugin->GetBranchSpecificCSS($newbranch_with->{branchcode});
247
    my $opacusercss = $plugin->GetBranchSpecificCSS($newbranch_with->{branchcode});
248
    is($usercss, $newbranch_with->{usercss},'received correct CSS string from function');
248
    is($opacusercss, $newbranch_with->{opacusercss},'received correct CSS string from function');
249
249
250
    $userjs = $plugin->GetBranchSpecificJS($newbranch_none->{branchcode});
250
    $opacuserjs = $plugin->GetBranchSpecificJS($newbranch_none->{branchcode});
251
    $usercss = $plugin->GetBranchSpecificCSS($newbranch_none->{branchcode});
251
    $opacusercss = $plugin->GetBranchSpecificCSS($newbranch_none->{branchcode});
252
    is($userjs, q{},'received correct blank string from function when branch has none');
252
    is($opacuserjs, q{},'received correct blank string from function when branch has none');
253
    is($usercss, q{},'received correct blank string from function when branch has none');
253
    is($opacusercss, q{},'received correct blank string from function when branch has none');
254
254
255
    $userjs = $plugin->GetBranchSpecificJS();
255
    $opacuserjs = $plugin->GetBranchSpecificJS();
256
    $usercss = $plugin->GetBranchSpecificCSS();
256
    $opacusercss = $plugin->GetBranchSpecificCSS();
257
    is($userjs, q{},'received correct blank string from function when no branch set');
257
    is($opacuserjs, q{},'received correct blank string from function when no branch set');
258
    is($usercss, q{},'received correct blank string from function when no branch set');
258
    is($opacusercss, q{},'received correct blank string from function when no branch set');
259
259
260
    $schema->storage->txn_rollback;
260
    $schema->storage->txn_rollback;
261
};
261
};
262
- 

Return to bug 32721