added sol100 and chado cvterm pages to validate_all.t
[sgn.git] / lib / CXGN / Page / DeveloperSettings.pm
blob2217f59c5c972f884ca8511d1da6e14d6c578054
1 #!/usr/bin/perl
2 package CXGN::Page::DeveloperSettings;
3 use strict;
5 #use CXGN::Class::DBI;
6 use base qw/CXGN::Class::DBI CXGN::Page::Session/;
8 use CXGN::Cookie;
9 use CXGN::VHost;
10 use CXGN::Login;
11 use CXGN::Page::Session; #we directly reference the constructor
13 #These are acceptable keys, or a registry, for DeveloperSettings:
14 our @VALID_KEYS =
15 qw/
16 devel_type
17 dt_localsite
18 dt_develsite
19 dt_livesite
20 toolbar_closed
21 logging_pane_open
22 capture_stderr
23 timestamp
24 /;
26 our $COOKIE_NAME = 'developer_settings';
27 our $DB_SCHEMA = 'sgn_people';
28 our $DB_TABLE = 'sp_person';
29 our $DB_COLUMN = 'developer_settings';
30 our $ID_COLUMN = 'sp_person_id';
31 our $ID = undef;
33 =head1 Instance Methods
35 =head2 new([$dbh])
37 Constructor takes optional database handle, determines settings
38 based on the following order of precedence:
40 1) Local VHost Config, overrides everything
41 2) Cookie
42 3) Database, 'developer_settings' in logged-in sp_person
44 Settings are not taken in whole from any one source. A setting
45 key from the database that doesn't exist in the cookie or VHost
46 config will not be clobbered
48 Settings are then saved to the database and the cookie is set.
49 Therefore the constructor and save() MUST be called BEFORE
50 headers on a page are sent.
52 =cut
54 sub new {
55 my $class = shift;
56 my $dbh = shift;
57 my $user_type = undef;
58 my $tid = undef;
59 ($tid, $user_type) = CXGN::Login->new($dbh)->has_session();
60 $ID = $tid if $tid;
61 my $self = CXGN::Page::Session::new($class, $dbh);
62 $self->{user_type} = $user_type;
64 #This is why we redefine the constructor:
65 my $vhost = CXGN::VHost->new();
66 $self->{vhost} = $vhost;
67 if($vhost->get_conf('devel_type') eq "local"){
68 foreach my $k (@VALID_KEYS) {
69 $self->alter_setting($k, $vhost->get_conf($k)) if $vhost->get_conf($k);
72 $self->save();
73 return $self;
76 sub is_developer {
77 my $self = shift;
78 return 1 if $self->{user_type} eq "curator";
79 return 0;