User page code for user/group admin
[gwvp.git] / gwvplib / gwvpweb.php
index f476161..01215ab 100644 (file)
@@ -20,7 +20,8 @@ function gwvp_goWebBegin()
        
        // next, we go thru the CALL_ME_FUNCTIONS - the purpose of call_me_functions is to determine if a function should be called based on
        // the functions return (i.e. if function returns false, its not it, otherwise it returns a function name we have to call)
-       // this is important for our plugin structure later on
+       // this is important for our plugin structure later on - the key on the array serves an an ordering method
+       ksort($CALL_ME_FUNCTIONS);
        foreach($CALL_ME_FUNCTIONS as $key => $val) {
                error_log("checking callmefunction $key as $val");
                $callme = $val();
@@ -34,6 +35,12 @@ function gwvp_goWebBegin()
        gwvp_goMainPage();
 }
 
+function gwvp_SendMessage($messagetype, $message)
+{
+       $_SESSION["messagetype"] = $messagetype;
+       $_SESSION["message"] = $message;
+}
+
 function gwvp_goMainPage($bodyFunction = null)
 {
        // the main page will look pretty simple, a title, a menu then a body
@@ -79,9 +86,21 @@ function gwvp_goMainPage($bodyFunction = null)
        echo "<h1>Git over Web Via PHP</h2>";
        
        
-       echo "<table width=\"100%\"><tr width=\"100%\"><td>";
+       echo "<table width=\"100%\">";
+
+       if(isset($_SESSION["message"])) {
+               echo "<tr width=\"100%\"><td colspan=\"2\">";
+               gwvp_MessageBuilder();
+               echo "</td></tr>";
+       }
+       
+       echo "<tr width=\"100%\"><td>";
        gwvp_MenuBuilder();
-       echo "</td></tr>";
+       echo "</td><td align=\"right\">";
+       gwvp_LoginBuilder();
+       echo "</td>";
+       
+       echo "</tr>";
        
        echo "<tr><td>";
        if($bodyFunction == null) {
@@ -102,6 +121,29 @@ function gwvp_goMainPage($bodyFunction = null)
        
 }
 
+
+// builds the message builder if its needed
+function gwvp_MessageBuilder()
+{
+       $message = "";
+       $messagetype = "info";
+       if(isset($_SESSION["message"])) $message = $_SESSION["message"];
+       if(isset($_SESSION["messagetype"])) $messagetype = $_SESSION["messagetype"];
+       
+       if($message != "") {
+               switch($messagetype) {
+                       case "info":
+                               echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#AAFFAA\">$message</td></tr></table>";
+                               break;
+                       case "error":
+                               echo "<table border=\"1\" width=\"100%\"><tr width=\"100%\"><td bgcolor=\"#FFAAAA\">$message</td></tr></table>";
+                               break;
+               }
+               unset($_SESSION["message"]);
+               if(isset($_SESSION["messagetype"])) unset($_SESSION["messagetype"]);
+       }
+}
+
 // builds the menu structure
 function gwvp_MenuBuilder()
 {
@@ -119,6 +161,18 @@ function gwvp_MenuBuilder()
        
 }
 
+function gwvp_LoginBuilder()
+{
+       global $WEB_ROOT_FS, $BASE_URL;
+       
+       $login = gwvp_IsLoggedIn();
+       if($login === false) {
+               gwvp_SingleLineLoginForm();
+       } else {
+               echo "Hello, ".gwvp_GetFullName($login);
+       }
+}
+
 // builds the body structure
 function gwvp_BodyBuilder()
 {