Bug 17801: Use issuedate for limits in Most Circulated Items
[srvgit] / C4 / Context.pm
index df4b5db..2ab2263 100644 (file)
@@ -248,7 +248,6 @@ sub new {
     }
 
     my $conf_cache = Koha::Caches->get_instance('config');
-    my $config_from_cache;
     if ( $conf_cache->cache ) {
         $self = $conf_cache->get_from_cache('koha_conf');
     }
@@ -695,7 +694,6 @@ sub dbh
 {
     my $self = shift;
     my $params = shift;
-    my $sth;
 
     unless ( $params->{new} ) {
         return Koha::Database->schema->storage->dbh;
@@ -809,7 +807,8 @@ sub userenv {
   C4::Context->set_userenv($usernum, $userid, $usercnum,
                            $userfirstname, $usersurname,
                            $userbranch, $branchname, $userflags,
-                           $emailaddress, $shibboleth);
+                           $emailaddress, $shibboleth
+                           $desk_id, $desk_name);
 
 Establish a hash of user environment variables.
 
@@ -820,7 +819,7 @@ set_userenv is called in Auth.pm
 #'
 sub set_userenv {
     shift @_;
-    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth)=
+    my ($usernum, $userid, $usercnum, $userfirstname, $usersurname, $userbranch, $branchname, $userflags, $emailaddress, $shibboleth, $desk_id, $desk_name)=
     map { Encode::is_utf8( $_ ) ? $_ : Encode::decode('UTF-8', $_) } # CGI::Session doesn't handle utf-8, so we decode it here
     @_;
     my $var=$context->{"activeuser"} || '';
@@ -833,6 +832,8 @@ sub set_userenv {
         #possibly a law problem
         "branch"     => $userbranch,
         "branchname" => $branchname,
+        "desk_id"    => $desk_id,
+        "desk_name"  => $desk_name,
         "flags"      => $userflags,
         "emailaddress"     => $emailaddress,
         "shibboleth" => $shibboleth,
@@ -1071,8 +1072,47 @@ sub set_remote_address {
     }
 }
 
+=head3 https_enabled
+
+https_enabled should be called when checking if a HTTPS connection
+is used.
+
+Note that this depends on a HTTPS environmental variable being defined
+by the web server. This function may not return the expected result,
+if your web server or reverse proxies are not setting the correct
+X-Forwarded-Proto headers and HTTPS environmental variable.
+
+Note too that the HTTPS value can vary from web server to web server.
+We are relying on the convention of the value being "on" or "ON" here.
+
+=cut
+
+sub https_enabled {
+    my $https_enabled = 0;
+    my $env_https = $ENV{HTTPS};
+    if ($env_https){
+        if ($env_https =~ /^ON$/i){
+            $https_enabled = 1;
+        }
+    }
+    return $https_enabled;
+}
+
 1;
 
+=head3 needs_install
+
+    if ( $context->needs_install ) { ... }
+
+This method returns a boolean representing the install status of the Koha instance.
+
+=cut
+
+sub needs_install {
+    my ($self) = @_;
+    return ($self->preference('Version')) ? 0 : 1;
+}
+
 __END__
 
 =head1 ENVIRONMENT