Prettied up the permissions page a bit
[gwvp.git] / gwvplib / gwvpweb.php
index 01215ab..6f8c36c 100644 (file)
@@ -94,7 +94,7 @@ function gwvp_goMainPage($bodyFunction = null)
                echo "</td></tr>";
        }
        
-       echo "<tr width=\"100%\"><td>";
+       echo "<tr width=\"100%\" bgcolor=\"#ddffdd\"><td>";
        gwvp_MenuBuilder();
        echo "</td><td align=\"right\">";
        gwvp_LoginBuilder();
@@ -109,7 +109,7 @@ function gwvp_goMainPage($bodyFunction = null)
                if(function_exists($bodyFunction)) {
                        $bodyFunction();
                } else {
-                       error_log("Got called with non-existant body function");
+                       error_log("Got called with non-existant body function, $bodyFunction");
                        gwvp_BodyBuilder();
                }
        }
@@ -147,15 +147,40 @@ function gwvp_MessageBuilder()
 // builds the menu structure
 function gwvp_MenuBuilder()
 {
-       global $MENU_ITEMS;
+       global $MENU_ITEMS, $BASE_URL;
        
        ksort($MENU_ITEMS);
        
-       echo "<table border=\"1\"><tr><td>Menu</td>";
+       echo "<table border=\"1\"><tr><td><b><i>Menu</i></b></td>";
        foreach($MENU_ITEMS as $key => $val) {
                $link = $val["link"];
                $text = $val["text"];
-               echo "<td><a href=\"$link\">$text</a></td>";
+               
+               // TODO: redo this bit with stristr to find urls - special case for home
+               $menucolor = "";
+               if(isset($_REQUEST["q"])) {
+                       $extlink = str_replace("$BASE_URL/", "", $link);
+                       error_log("trying to do replace of $BASE_URL in $link, got $extlink for ".$_REQUEST["q"]);
+                       if(stristr($_REQUEST["q"], $extlink)!==false) {
+                               $menucolor = " bgcolor=\"#ffdddd\"";
+                               
+                       }
+               } else {
+                       // special case for home
+                       if($link == $BASE_URL) $menucolor = " bgcolor=\"#ffdddd\"";
+               }
+               
+               
+               
+               
+               if(isset($val["userlevel"])) {
+                       if(gwvp_CheckAuthLevel($val["userlevel"])) {
+                               echo "<td$menucolor><a href=\"$link\">$text</a></td>";
+                       }
+                       
+               } else {
+                       echo "<td$menucolor><a href=\"$link\">$text</a></td>";
+               }
        }
        echo "</tr></table>";
        
@@ -169,7 +194,7 @@ function gwvp_LoginBuilder()
        if($login === false) {
                gwvp_SingleLineLoginForm();
        } else {
-               echo "Hello, ".gwvp_GetFullName($login);
+               echo "Hello, ".gwvp_GetFullName($login)." <a href=\"$BASE_URL/logout\">logout</a>";
        }
 }