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

(-)a/C4/Auth.pm (-14 lines)
Lines 1886-1900 sub checkpw_internal { Link Here
1886
            return 1, $cardnumber, $userid;
1886
            return 1, $cardnumber, $userid;
1887
        }
1887
        }
1888
    }
1888
    }
1889
    if ( $userid && $userid eq 'demo'
1890
        && "$password" eq 'demo'
1891
        && C4::Context->config('demo') )
1892
    {
1893
1894
        # DEMO => the demo user is allowed to do everything (if demo set to 1 in koha.conf
1895
        # some features won't be effective : modify systempref, modify MARC structure,
1896
        return 2;
1897
    }
1898
    return 0;
1889
    return 0;
1899
}
1890
}
1900
1891
Lines 2051-2061 sub haspermission { Link Here
2051
        # Super User Account from /etc/koha.conf
2042
        # Super User Account from /etc/koha.conf
2052
        $flags->{'superlibrarian'} = 1;
2043
        $flags->{'superlibrarian'} = 1;
2053
    }
2044
    }
2054
    elsif ( $userid eq 'demo' && C4::Context->config('demo') ) {
2055
2056
        # Demo user that can do "anything" (demo=1 in /etc/koha.conf)
2057
        $flags->{'superlibrarian'} = 1;
2058
    }
2059
2045
2060
    return $flags if $flags->{superlibrarian};
2046
    return $flags if $flags->{superlibrarian};
2061
2047
(-)a/C4/InstallAuth.pm (-10 lines)
Lines 419-434 sub checkpw { Link Here
419
        );
419
        );
420
        return 2;
420
        return 2;
421
    }
421
    }
422
    if (   $userid
423
        && $userid     eq 'demo'
424
        && "$password" eq 'demo'
425
        && C4::Context->config('demo') )
426
    {
427
428
# DEMO => the demo user is allowed to do everything (if demo set to 1 in koha.conf
429
# some features won't be effective : modify systempref, modify MARC structure,
430
        return 2;
431
    }
432
    return 0;
422
    return 0;
433
}
423
}
434
424
(-)a/admin/auth_subfields_structure.pl (-6 / +2 lines)
Lines 224-230 if ($op eq 'add_form') { Link Here
224
		my $hidden = $ohidden[$i]; #collate from 3 hiddens;
224
		my $hidden = $ohidden[$i]; #collate from 3 hiddens;
225
		my $isurl = $input->param("isurl$i")?1:0;
225
		my $isurl = $input->param("isurl$i")?1:0;
226
		if ($liblibrarian) {
226
		if ($liblibrarian) {
227
			unless (C4::Context->config('demo') or C4::Context->config('demo') eq 1) {
228
				if (auth_subfield_structure_exists($authtypecode, $tagfield, $tagsubfield)) {
227
				if (auth_subfield_structure_exists($authtypecode, $tagfield, $tagsubfield)) {
229
					$sth_update->execute(
228
					$sth_update->execute(
230
						$authtypecode,
229
						$authtypecode,
Lines 269-275 if ($op eq 'add_form') { Link Here
269
                        $defaultvalue,
268
                        $defaultvalue,
270
					);
269
					);
271
				}
270
				}
272
			}
273
		}
271
		}
274
	}
272
	}
275
    print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode");
273
    print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode");
Lines 293-302 if ($op eq 'add_form') { Link Here
293
################## DELETE_CONFIRMED ##################################
291
################## DELETE_CONFIRMED ##################################
294
# called by delete_confirm, used to effectively confirm deletion of data in DB
292
# called by delete_confirm, used to effectively confirm deletion of data in DB
295
} elsif ($op eq 'delete_confirmed') {
293
} elsif ($op eq 'delete_confirmed') {
296
	unless (C4::Context->config('demo') or C4::Context->config('demo') eq 1) {
294
    my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?");
297
		my $sth=$dbh->prepare("delete from auth_subfield_structure where tagfield=? and tagsubfield=? and authtypecode=?");
295
    $sth->execute($tagfield,$tagsubfield,$authtypecode);
298
		$sth->execute($tagfield,$tagsubfield,$authtypecode);
299
	}
300
    print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode");
296
    print $input->redirect("/cgi-bin/koha/admin/auth_subfields_structure.pl?tagfield=$tagfield&authtypecode=$authtypecode");
301
    exit;
297
    exit;
302
													# END $OP eq DELETE_CONFIRMED
298
													# END $OP eq DELETE_CONFIRMED
(-)a/admin/auth_tag_structure.pl (-29 / +25 lines)
Lines 117-147 if ($op eq 'add_form') { Link Here
117
    my $repeatable       = $input->param('repeatable') ? 1 : 0;
117
    my $repeatable       = $input->param('repeatable') ? 1 : 0;
118
    my $mandatory        = $input->param('mandatory')  ? 1 : 0;
118
    my $mandatory        = $input->param('mandatory')  ? 1 : 0;
119
    my $authorised_value = $input->param('authorised_value');
119
    my $authorised_value = $input->param('authorised_value');
120
    unless (C4::Context->config('demo') eq 1) {
120
    if ($input->param('modif')) {
121
        if ($input->param('modif')) {
121
        $sth=$dbh->prepare("UPDATE auth_tag_structure SET tagfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, authorised_value=? WHERE authtypecode=? AND tagfield=?");
122
            $sth=$dbh->prepare("UPDATE auth_tag_structure SET tagfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, authorised_value=? WHERE authtypecode=? AND tagfield=?");
122
        $sth->execute(
123
            $sth->execute(
123
            $tagfield,
124
                $tagfield,
124
            $liblibrarian,
125
                $liblibrarian,
125
            $libopac,
126
                $libopac,
126
            $repeatable,
127
                $repeatable,
127
            $mandatory,
128
                $mandatory,
128
            $authorised_value,
129
                $authorised_value,
129
            $authtypecode,
130
                $authtypecode,
130
            $tagfield,
131
                $tagfield,
131
        );
132
            );
132
    } else {
133
        } else {
133
        $sth=$dbh->prepare("INSERT INTO auth_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,authtypecode) VALUES (?,?,?,?,?,?,?)");
134
            $sth=$dbh->prepare("INSERT INTO auth_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,authtypecode) VALUES (?,?,?,?,?,?,?)");
134
        $sth->execute(
135
            $sth->execute(
135
            $tagfield,
136
                $tagfield,
136
            $liblibrarian,
137
                $liblibrarian,
137
            $libopac,
138
                $libopac,
138
            $repeatable,
139
                $repeatable,
139
            $mandatory,
140
                $mandatory,
140
            $authorised_value,
141
                $authorised_value,
141
            $authtypecode
142
                $authtypecode
142
       );
143
           );
144
        }
145
    }
143
    }
146
    print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode");
144
    print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode");
147
    exit;
145
    exit;
Lines 160-169 if ($op eq 'add_form') { Link Here
160
################## DELETE_CONFIRMED ##################################
158
################## DELETE_CONFIRMED ##################################
161
# called by delete_confirm, used to effectively confirm deletion of data in DB
159
# called by delete_confirm, used to effectively confirm deletion of data in DB
162
} elsif ($op eq 'delete_confirmed') {
160
} elsif ($op eq 'delete_confirmed') {
163
    unless (C4::Context->config('demo') eq 1) {
161
    $dbh->do(q|delete from auth_tag_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode);
164
        $dbh->do(q|delete from auth_tag_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode);
162
    $dbh->do(q|delete from auth_subfield_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode);
165
        $dbh->do(q|delete from auth_subfield_structure where tagfield=? and authtypecode=?|, undef, $searchfield, $authtypecode);
166
    }
167
    my $tagfield = $input->param('tagfield');
163
    my $tagfield = $input->param('tagfield');
168
    print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode");
164
    print $input->redirect("/cgi-bin/koha/admin/auth_tag_structure.pl?searchfield=$tagfield&authtypecode=$authtypecode");
169
    exit;
165
    exit;
(-)a/admin/marc_subfields_structure.pl (-55 / +49 lines)
Lines 281-336 elsif ( $op eq 'add_validate' ) { Link Here
281
        my $maxlength = $maxlength[$i] ? $maxlength[$i] : 9999;
281
        my $maxlength = $maxlength[$i] ? $maxlength[$i] : 9999;
282
        
282
        
283
        if (defined($liblibrarian) && $liblibrarian ne "") {
283
        if (defined($liblibrarian) && $liblibrarian ne "") {
284
            my $is_demo = C4::Context->config('demo') || '';
284
            if (marc_subfield_structure_exists($tagfield, $tagsubfield, $frameworkcode)) {
285
            if ( $is_demo ne '1' ) {
285
                $sth_update->execute(
286
                if (marc_subfield_structure_exists($tagfield, $tagsubfield, $frameworkcode)) {
286
                    $tagfield,
287
                    $sth_update->execute(
287
                    $tagsubfield,
288
                    $liblibrarian,
289
                    $libopac,
290
                    $repeatable,
291
                    $mandatory,
292
                    $kohafield,
293
                    $tab,
294
                    $seealso,
295
                    $authorised_value,
296
                    $authtypecode,
297
                    $value_builder,
298
                    $hidden,
299
                    $isurl,
300
                    $frameworkcode,
301
                    $link,
302
                    $defaultvalue,
303
                    $maxlength,
304
                    (
288
                        $tagfield,
305
                        $tagfield,
289
                        $tagsubfield,
306
                        $tagsubfield,
290
                        $liblibrarian,
291
                        $libopac,
292
                        $repeatable,
293
                        $mandatory,
294
                        $kohafield,
295
                        $tab,
296
                        $seealso,
297
                        $authorised_value,
298
                        $authtypecode,
299
                        $value_builder,
300
                        $hidden,
301
                        $isurl,
302
                        $frameworkcode,
307
                        $frameworkcode,
303
                        $link,
308
                    ),
304
                        $defaultvalue,
309
                );
305
                        $maxlength,
310
            } else {
306
                        (
311
                $sth_insert->execute(
307
                            $tagfield,
312
                    $tagfield,
308
                            $tagsubfield,
313
                    $tagsubfield,
309
                            $frameworkcode,
314
                    $liblibrarian,
310
                        ),
315
                    $libopac,
311
                    );
316
                    $repeatable,
312
                } else {
317
                    $mandatory,
313
                    $sth_insert->execute(
318
                    $kohafield,
314
                        $tagfield,
319
                    $tab,
315
                        $tagsubfield,
320
                    $seealso,
316
                        $liblibrarian,
321
                    $authorised_value,
317
                        $libopac,
322
                    $authtypecode,
318
                        $repeatable,
323
                    $value_builder,
319
                        $mandatory,
324
                    $hidden,
320
                        $kohafield,
325
                    $isurl,
321
                        $tab,
326
                    $frameworkcode,
322
                        $seealso,
327
                    $link,
323
                        $authorised_value,
328
                    $defaultvalue,
324
                        $authtypecode,
329
                    $maxlength,
325
                        $value_builder,
330
                );
326
                        $hidden,
327
                        $isurl,
328
                        $frameworkcode,
329
                        $link,
330
                        $defaultvalue,
331
                        $maxlength,
332
                    );
333
                }
334
            }
331
            }
335
        }
332
        }
336
    }
333
    }
Lines 373-387 elsif ( $op eq 'delete_confirm' ) { Link Here
373
}
370
}
374
elsif ( $op eq 'delete_confirmed' ) {
371
elsif ( $op eq 'delete_confirmed' ) {
375
    my $dbh = C4::Context->dbh;
372
    my $dbh = C4::Context->dbh;
376
    my $is_demo = C4::Context->config('demo') || '';
373
    my $sth =
377
    if ( $is_demo ne '1' ) {
374
      $dbh->prepare(
378
        my $sth =
379
          $dbh->prepare(
380
"delete from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?"
375
"delete from marc_subfield_structure where tagfield=? and tagsubfield=? and frameworkcode=?"
381
          );
376
      );
382
        $sth->execute( $tagfield, $tagsubfield, $frameworkcode );
377
    $sth->execute( $tagfield, $tagsubfield, $frameworkcode );
383
        $sth->finish;
378
    $sth->finish;
384
    }
385
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
379
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
386
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
380
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
387
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
381
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
(-)a/admin/marctagstructure.pl (-40 / +36 lines)
Lines 121-157 if ($op eq 'add_form') { Link Here
121
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
121
	my $repeatable       = $input->param('repeatable') ? 1 : 0;
122
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
122
	my $mandatory        = $input->param('mandatory')  ? 1 : 0;
123
	my $authorised_value = $input->param('authorised_value');
123
	my $authorised_value = $input->param('authorised_value');
124
    unless (C4::Context->config('demo')) {
124
    if ($input->param('modif')) {
125
        if ($input->param('modif')) {
125
        $sth = $dbh->prepare(
126
            $sth = $dbh->prepare(
126
        "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
127
            "UPDATE marc_tag_structure SET liblibrarian=? ,libopac=? ,repeatable=? ,mandatory=? ,authorised_value=? WHERE frameworkcode=? AND tagfield=?"
127
        );
128
            );
128
        $sth->execute(  $liblibrarian,
129
            $sth->execute(  $liblibrarian,
129
                        $libopac,
130
                            $libopac,
130
                        $repeatable,
131
                            $repeatable,
131
                        $mandatory,
132
                            $mandatory,
132
                        $authorised_value,
133
                            $authorised_value,
133
                        $frameworkcode,
134
                            $frameworkcode,
134
                        $tagfield
135
                            $tagfield
135
        );
136
            );
136
    } else {
137
        } else {
137
        $sth = $dbh->prepare(
138
            $sth = $dbh->prepare(
138
        "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)"
139
            "INSERT INTO marc_tag_structure (tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value,frameworkcode) values (?,?,?,?,?,?,?)"
139
        );
140
            );
140
        $sth->execute($tagfield,
141
            $sth->execute($tagfield,
141
                      $liblibrarian,
142
                          $liblibrarian,
142
                      $libopac,
143
                          $libopac,
143
                      $repeatable,
144
                          $repeatable,
144
                      $mandatory,
145
                          $mandatory,
145
                      $authorised_value,
146
                          $authorised_value,
146
                      $frameworkcode
147
                          $frameworkcode
147
        );
148
            );
149
        }
150
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
151
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
152
        $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
153
        $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
154
    }
148
    }
149
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
150
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
151
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
152
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
155
    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
153
    print $input->redirect("/cgi-bin/koha/admin/marctagstructure.pl?searchfield=$tagfield&frameworkcode=$frameworkcode");
156
    exit;
154
    exit;
157
													# END $OP eq ADD_VALIDATE
155
													# END $OP eq ADD_VALIDATE
Lines 170-185 if ($op eq 'add_form') { Link Here
170
################## DELETE_CONFIRMED ##################################
168
################## DELETE_CONFIRMED ##################################
171
# called by delete_confirm, used to effectively confirm deletion of data in DB
169
# called by delete_confirm, used to effectively confirm deletion of data in DB
172
} elsif ($op eq 'delete_confirmed') {
170
} elsif ($op eq 'delete_confirmed') {
173
	unless (C4::Context->config('demo')) {
171
    my $sth1 = $dbh->prepare("DELETE FROM marc_tag_structure      WHERE tagfield=? AND frameworkcode=?");
174
        my $sth1 = $dbh->prepare("DELETE FROM marc_tag_structure      WHERE tagfield=? AND frameworkcode=?");
172
    my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?");
175
        my $sth2 = $dbh->prepare("DELETE FROM marc_subfield_structure WHERE tagfield=? AND frameworkcode=?");
173
    $sth1->execute($searchfield, $frameworkcode);
176
        $sth1->execute($searchfield, $frameworkcode);
174
    $sth2->execute($searchfield, $frameworkcode);
177
        $sth2->execute($searchfield, $frameworkcode);
175
    $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
178
        $cache->clear_from_cache("MarcStructure-0-$frameworkcode");
176
    $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
179
        $cache->clear_from_cache("MarcStructure-1-$frameworkcode");
177
    $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
180
        $cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode");
178
    $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
181
        $cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode");
182
	}
183
	$template->param(
179
	$template->param(
184
          searchfield => $searchfield,
180
          searchfield => $searchfield,
185
        frameworkcode => $frameworkcode,
181
        frameworkcode => $frameworkcode,
(-)a/admin/preferences.pl (-7 / +5 lines)
Lines 314-329 $tab ||= 'acquisitions'; # Ideally this should be "local-use" but preferences.pl Link Here
314
my $highlighted;
314
my $highlighted;
315
315
316
if ( $op eq 'save' ) {
316
if ( $op eq 'save' ) {
317
    unless ( C4::Context->config( 'demo' ) ) {
317
    foreach my $param ( $input->param() ) {
318
        foreach my $param ( $input->param() ) {
318
        my ( $pref ) = ( $param =~ /pref_(.*)/ );
319
            my ( $pref ) = ( $param =~ /pref_(.*)/ );
320
319
321
            next if ( !defined( $pref ) );
320
        next if ( !defined( $pref ) );
322
321
323
            my $value = join( ',', $input->param( $param ) );
322
        my $value = join( ',', $input->param( $param ) );
324
323
325
            C4::Context->set_preference( $pref, $value );
324
        C4::Context->set_preference( $pref, $value );
326
        }
327
    }
325
    }
328
326
329
    print $input->redirect( '/cgi-bin/koha/admin/preferences.pl?tab=' . $tab );
327
    print $input->redirect( '/cgi-bin/koha/admin/preferences.pl?tab=' . $tab );
(-)a/admin/systempreferences.pl (-4 / +2 lines)
Lines 276-282 if ( $op eq 'update_and_reedit' ) { Link Here
276
        }
276
        }
277
    }
277
    }
278
    my $variable = $input->param('variable');
278
    my $variable = $input->param('variable');
279
    C4::Context->set_preference($variable, $value) unless C4::Context->config('demo');
279
    C4::Context->set_preference($variable, $value);
280
}
280
}
281
281
282
################## ADD_FORM ##################################
282
################## ADD_FORM ##################################
Lines 335-342 if ( $op eq 'add_form' ) { Link Here
335
        $value = encode_base64($value);
335
        $value = encode_base64($value);
336
    }
336
    }
337
337
338
    C4::Context->set_preference( $variable, $value, $expl, $type, $options )
338
    C4::Context->set_preference( $variable, $value, $expl, $type, $options );
339
        unless C4::Context->config('demo');
340
    print $input->redirect("/cgi-bin/koha/admin/systempreferences.pl?tab=");
339
    print $input->redirect("/cgi-bin/koha/admin/systempreferences.pl?tab=");
341
    exit;
340
    exit;
342
################## DELETE_CONFIRM ##################################
341
################## DELETE_CONFIRM ##################################
343
- 

Return to bug 12227