From 9b92b979d4647472f0beefae30c08855a3284966 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 5 Mar 2005 02:17:23 +0000 Subject: [PATCH] Added a simple flag in ccbs.pm to make the system suitable for public viewing (ie. no changes). --- html/ccbs.pm | 7 +++++++ html/do-add-player.pl | 2 ++ html/do-add-tournament.pl | 2 ++ html/do-edit-scores.pl | 2 ++ html/do-finish-tournament.pl | 2 ++ html/do-registration.pl | 2 ++ html/do-reset-randomsongs.pl | 2 ++ html/do-set-active-round.pl | 2 ++ html/do-set-active-tournament.pl | 2 ++ html/do-set-paid.pl | 2 ++ html/do-start-round.pl | 2 ++ html/do-unregister.pl | 2 ++ html/templates/index.tmpl | 4 ++++ html/templates/main.tmpl | 8 +++++--- html/templates/show-tournament.tmpl | 6 ++++-- html/templates/tournaments.tmpl | 4 ++++ 16 files changed, 46 insertions(+), 5 deletions(-) diff --git a/html/ccbs.pm b/html/ccbs.pm index 21a19a8..8195543 100755 --- a/html/ccbs.pm +++ b/html/ccbs.pm @@ -7,6 +7,9 @@ use strict; use warnings; our $ccbs_dbdebug = 0; + +# Set this flag to disable any admin tasks -- it's quite crude, but hey :-) +our $ccbs_noadmin = 0; sub print_header { print CGI::header(-type=>'text/html; charset=utf-8'); @@ -60,6 +63,7 @@ sub process_template { my ($page, $title, $vars) = @_; $vars->{'page'} = $page; $vars->{'title'} = $title; + $vars->{'public'} = $ccbs_noadmin; my $config = { INCLUDE_PATH => 'templates/', @@ -85,6 +89,9 @@ sub user_error { exit; } +sub admin_only { + user_error("Beklager, databasen står i no-admin-mode.") if ($ccbs_noadmin); +} $SIG{__DIE__} = sub { # Gosh! Net::Resolver::DNS is brain-damaged. diff --git a/html/do-add-player.pl b/html/do-add-player.pl index 7817b14..2ed4b6c 100755 --- a/html/do-add-player.pl +++ b/html/do-add-player.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-add-tournament.pl b/html/do-add-tournament.pl index 0ef54ef..50efd38 100755 --- a/html/do-add-tournament.pl +++ b/html/do-add-tournament.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-edit-scores.pl b/html/do-edit-scores.pl index 95006e0..898d5db 100755 --- a/html/do-edit-scores.pl +++ b/html/do-edit-scores.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-finish-tournament.pl b/html/do-finish-tournament.pl index b493968..a22da17 100755 --- a/html/do-finish-tournament.pl +++ b/html/do-finish-tournament.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-registration.pl b/html/do-registration.pl index 36c5e2f..6f7b9e3 100755 --- a/html/do-registration.pl +++ b/html/do-registration.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-reset-randomsongs.pl b/html/do-reset-randomsongs.pl index e470b73..6c79994 100755 --- a/html/do-reset-randomsongs.pl +++ b/html/do-reset-randomsongs.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-set-active-round.pl b/html/do-set-active-round.pl index db32ece..5b0376e 100755 --- a/html/do-set-active-round.pl +++ b/html/do-set-active-round.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-set-active-tournament.pl b/html/do-set-active-tournament.pl index c27ebf5..3a15a93 100755 --- a/html/do-set-active-tournament.pl +++ b/html/do-set-active-tournament.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-set-paid.pl b/html/do-set-paid.pl index 7ac795d..5622bb7 100755 --- a/html/do-set-paid.pl +++ b/html/do-set-paid.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-start-round.pl b/html/do-start-round.pl index f7a86ce..d843be2 100755 --- a/html/do-start-round.pl +++ b/html/do-start-round.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/do-unregister.pl b/html/do-unregister.pl index 3751e30..4a1101e 100755 --- a/html/do-unregister.pl +++ b/html/do-unregister.pl @@ -4,6 +4,8 @@ use ccbs; use strict; use warnings; +ccbs::admin_only(); + my $dbh = ccbs::db_connect(); my $cgi = new CGI; diff --git a/html/templates/index.tmpl b/html/templates/index.tmpl index 4b872ad..28ec269 100644 --- a/html/templates/index.tmpl +++ b/html/templates/index.tmpl @@ -9,11 +9,14 @@
+[% IF !public %]

Storskjerm

@@ -21,3 +24,4 @@
  • Sett aktiv turnering
  • +[% END %] diff --git a/html/templates/main.tmpl b/html/templates/main.tmpl index 286cac7..46b0e5d 100644 --- a/html/templates/main.tmpl +++ b/html/templates/main.tmpl @@ -10,9 +10,11 @@

    [% title %]

    - Forside | - Turneringer | - Sangvelger + Forside + | Turneringer +[% IF !public %] + | Sangvelger +[% END %]

    diff --git a/html/templates/show-tournament.tmpl b/html/templates/show-tournament.tmpl index 3a6c34f..8619ca9 100644 --- a/html/templates/show-tournament.tmpl +++ b/html/templates/show-tournament.tmpl @@ -12,7 +12,7 @@
    -[% IF closing_valid %] +[% IF closing_valid && !public %]

    Start ny runde

    @@ -54,7 +54,7 @@
    [% END %] -[% IF finishing_valid %] +[% IF finishing_valid && !public %]

    Avslutt turnering

    @@ -89,6 +89,7 @@ [% END %] [% FOR r = rounds %] +[% IF r.locked || !public %]

    Runde [% r.round %]

    @@ -253,3 +254,4 @@
    [% END %] +[% END %] diff --git a/html/templates/tournaments.tmpl b/html/templates/tournaments.tmpl index 7d0d6bf..0665786 100644 --- a/html/templates/tournaments.tmpl +++ b/html/templates/tournaments.tmpl @@ -1,8 +1,10 @@ [%# vim:set filetype=html: %] +[% IF !public %]

    Legg til turnering

    +[% END %] [% SET last_season = 0 %] [% FOR t = tournaments %] @@ -21,7 +23,9 @@ [% END %]
  • [% t.tournamentname %] +[% IF !public %] (registrering) +[% END %]
  • [% END %] -- 2.39.2