Author: jfthomps
Date: Tue Jun 13 14:39:17 2017
New Revision: 1798606

URL: http://svn.apache.org/viewvc?rev=1798606&view=rev
Log:
VCL-981 - create a new theme that is more responsive for mobile devices

authentication.php:
-modified localLogin: attempt to get theme assigned in database for user's 
affiliation and set that for the VCLSKIN cookie
-modified checkExpiredDemoUser: get skin from calling getAffiliationTheme 
instead of DEFAULTTHEME constant

sitemaintenance.php: modified writeMaintenanceFile: write theme for Global 
affiliation to file so that can be used to display maintenance message

utils.php:
-modified initGlobals: when user not authed, get $skin from 
getAffiliationTheme(0) instead of from DEFAULTTHEME
-modified maintenanceCheck: read site theme from maintenance file; use that if 
it is valid and VCLSKIN cookie is not set
-modified getAffiliationTheme: added check for $affilid being passed as 0; if 
so, just query to get the theme for Global affiliation

Modified:
    vcl/trunk/web/.ht-inc/authentication.php
    vcl/trunk/web/.ht-inc/sitemaintenance.php
    vcl/trunk/web/.ht-inc/utils.php

Modified: vcl/trunk/web/.ht-inc/authentication.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/authentication.php?rev=1798606&r1=1798605&r2=1798606&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/authentication.php (original)
+++ vcl/trunk/web/.ht-inc/authentication.php Tue Jun 13 14:39:17 2017
@@ -486,7 +486,8 @@ function localLogin($userid, $passwd, $a
                else
                        setcookie("VCLAUTH", "{$cookie['data']}", 0, "/", 
COOKIEDOMAIN);
                //load main page
-               setcookie("VCLSKIN", DEFAULTTHEME, (time() + (SECINDAY * 31)), 
"/", COOKIEDOMAIN);
+               $theme = 
getAffiliationTheme($authMechs[$authtype]['affiliationid']);
+               setcookie("VCLSKIN", $theme, (time() + (SECINDAY * 31)), "/", 
COOKIEDOMAIN);
                header("Location: " . BASEURL . SCRIPT);
                dbDisconnect();
                exit;
@@ -629,7 +630,7 @@ function checkExpiredDemoUser($userid, $
                                updateGroups(array($nodemoid), $userid);
                                checkUpdateServerRequestGroups($groupid);
                                if(empty($skin)) {
-                                       $skin = DEFAULTTHEME;
+                                       $skin = getAffiliationTheme(0);
                                        require_once("themes/$skin/page.php");
                                }
                                $mode = 'expiredemouser';

Modified: vcl/trunk/web/.ht-inc/sitemaintenance.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/sitemaintenance.php?rev=1798606&r1=1798605&r2=1798606&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/sitemaintenance.php (original)
+++ vcl/trunk/web/.ht-inc/sitemaintenance.php Tue Jun 13 14:39:17 2017
@@ -549,6 +549,8 @@ function writeMaintenanceFile($start, $e
        if(! $fh = fopen($file, 'w')) {
                return false;
        }
+       $globaltheme = getAffiliationTheme(0);
+       fwrite($fh, "THEME=$globaltheme\n");
        $numend = date('YmdHi', $end);
        fwrite($fh, "END=$numend\n");
        fwrite($fh, "$msg\n");

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1798606&r1=1798605&r2=1798606&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Tue Jun 13 14:39:17 2017
@@ -189,7 +189,7 @@ function initGlobals() {
                                        $skin = 'example2';
                                        break;
                                default:
-                                       $skin = DEFAULTTHEME;
+                                       $skin = getAffiliationTheme(0);
                                        break;
                        }
                }
@@ -200,7 +200,7 @@ function initGlobals() {
                        $skin = 'example1';
                }*/
                else
-                       $skin = DEFAULTTHEME;
+                       $skin = getAffiliationTheme(0);
                if($mode != 'selectauth' && $mode != 'submitLogin')
                        require_once("themes/$skin/page.php");
 
@@ -747,6 +747,7 @@ function maintenanceCheck() {
                return;
        }  
        $inmaintenance = 0;
+       $skin = '';
        foreach($files as $file) {
                if(! 
preg_match("|^$search([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$|", 
$file, $matches))
                        continue;
@@ -770,6 +771,9 @@ function maintenanceCheck() {
                                        else
                                                $inmaintenance = 1;
                                }
+                               
elseif(preg_match("/^THEME=([-A-Za-z0-9@#_:;,\.])+$/", $line, $matches)) {
+                                       $skin = $matches[1];
+                               }
                                else
                                        $msg .= $line;
                        }
@@ -784,6 +788,18 @@ function maintenanceCheck() {
                $user = array();
                if(array_key_exists('VCLSKIN', $_COOKIE))
                        $skin = strtolower($_COOKIE['VCLSKIN']);
+               if($skin != '') {
+                       $allskins = array();
+                       foreach(glob('themes/*') as $item) {
+                               if(! is_dir($item))
+                                       continue;
+                               $tmp = explode('/', $item);
+                               $item = $tmp[1];
+                               $allskins[$item] = 1;
+                       }
+                       if(! array_key_exists($skin, $allskins))
+                               $skin = DEFAULTTHEME;
+               }
                else
                        $skin = DEFAULTTHEME;
                setVCLLocale();
@@ -3900,7 +3916,7 @@ function getAffiliationDataUpdateText($a
 ///
 /// \fn getAffiliationTheme($affilid)
 ///
-/// \param $affilid - id of an affiliation
+/// \param $affilid - id of an affiliation, or 0 to get theme for Global
 ///
 /// \return name of the affiliations's theme
 ///
@@ -3908,11 +3924,16 @@ function getAffiliationDataUpdateText($a
 ///
 
////////////////////////////////////////////////////////////////////////////////
 function getAffiliationTheme($affilid) {
-       $query = "SELECT COALESCE(a1.theme, a2.theme) AS theme "
-              . "FROM affiliation a1, "
-              .      "affiliation a2 "
-              . "WHERE a1.id = $affilid AND "
-              .       "a2.name = 'Global'";
+       if($affilid == 0) {
+               $query = "SELECT theme FROM affiliation WHERE name = 'Global'";
+       }
+       else {
+               $query = "SELECT COALESCE(a1.theme, a2.theme) AS theme "
+                      . "FROM affiliation a1, "
+                      .      "affiliation a2 "
+                      . "WHERE a1.id = $affilid AND "
+                      .       "a2.name = 'Global'";
+       }
        $qh = doQuery($query);
        if(($row = mysql_fetch_assoc($qh)) && ! empty($row['theme']))
                return $row['theme'];


Reply via email to