function SetCommonLoginStatus(&$tpl, $paramArray = array()) { $toolbar_tpl = new HTML_Template_IT("./"); $toolbar_tpl->loadTemplatefile("common_loginstatus.tpl.html", true, true); // parse the section depending on the current state of the user if (!IsLogged()) { // not logged, calculate return page $returnPage = $_SERVER['PHP_SELF']; $getCount = count($_GET); if ($getCount > 0) { $returnPage .= "?"; $i = 0; foreach (array_keys($_GET) as $getParam) { $returnPage .= $getParam . "=" . $_GET[$getParam]; if ($i < $getCount - 1) { $returnPage .= "&"; } $i++; } } $toolbar_tpl->setCurrentBlock("not_logged"); $toolbar_tpl->setVariable("RETURN_PAGE", urlencode($returnPage)); $toolbar_tpl->parseCurrentBlock("not_logged"); } else { if (array_key_exists("ItemId", $paramArray)) { $projectId = GetProjectIdForItem($paramArray["ItemId"]); } elseif (array_key_exists("UnitId", $paramArray)) { $projectId = GetProjectIdForUnit($paramArray["UnitId"]); } elseif (array_key_exists("ProjectId", $paramArray)) { $projectId = $paramArray["ProjectId"]; } else { $projectId = ""; } if ($projectId == "") { // no project Id, we simply indicate the logged in state $toolbar_tpl->setCurrentBlock("logged"); $toolbar_tpl->setVariable("USERNAME", GetLoggedUserName()); $toolbar_tpl->parseCurrentBlock("logged"); } else { if (!IsWriter($projectId)) { // no write access to project $toolbar_tpl->setCurrentBlock("not_allowed"); $toolbar_tpl->setVariable("USERNAME", GetLoggedUserName()); $toolbar_tpl->parseCurrentBlock("not_allowed"); } else { // full write access $toolbar_tpl->setCurrentBlock("logged_and_write"); $toolbar_tpl->setVariable("USERNAME", GetLoggedUserName()); $toolbar_tpl->parseCurrentBlock("logged_and_write"); } } } $tpl->setVariable("COMMON_LOGIN_STATUS", $toolbar_tpl->get()); }
<?php $pageTitle = "Messages"; include './includes/header.php'; IsLogged(); ?> <table class="table table-bordered table-striped"> <thead> <tr> <th>Message</th> <th>From</th> <th>Date</th> </tr> </thead> <tbody> <?php $get = mysqli_query($dbConect, "SELECT * FROM messages ORDER BY post_date"); if ($get) { while ($row = $get->fetch_assoc()) { ?> <tr> <td><?php echo $row['content']; ?> </td> <td><?php echo $row['author']; ?> </td> <td><?php
$tpl->parseCurrentBlock("search_section"); // Assign data to the browse block $tpl->setCurrentBlock("browse_section"); $tpl->setCurrentBlock("browse_project"); $tpl->setVariable("PROJECT_ID", $project["Id"]); $tpl->setVariable("PROJECT_NAME", $project["Name"]); $tpl->setVariable("PROJECT_DESCRIPTION", $project["Description"]); $tpl->parseCurrentBlock("browse_project"); $tpl->parseCurrentBlock("browse_section"); } } else { $tpl->setCurrentBlock("search_no_projects"); $tpl->setVariable("NO_PROJECTS_MESSAGE", "There are no projects in the system, the search function is disabled."); $tpl->parseCurrentBlock("search_no_projects"); $tpl->setCurrentBlock("browse_no_projects"); $tpl->setVariable("NO_PROJECTS_MESSAGE", "There are no projects in the system, the browse function is disabled."); $tpl->parseCurrentBlock("browse_no_projects"); } // if user is not logged in, show section to ask him to do so. // if user is logged in, show section that allows him to change his details if (!IsLogged()) { $tpl->setCurrentBlock("not_logged"); $tpl->touchBlock("not_logged"); $tpl->parseCurrentBlock("not_logged"); } else { $tpl->setCurrentBlock("logged"); $tpl->touchBlock("logged"); $tpl->parseCurrentBlock("logged"); } // print the output $tpl->show();
SetCommonLoginStatus($tpl); SetCommonToolbar($tpl); SetCommonFooter($tpl); // setup the "Back" link if (array_key_exists("item_id", $_POST) && $_POST["item_id"] != "") { $tpl->setCurrentBlock("back_item"); $tpl->setVariable("ITEM_ID", $_POST["item_id"]); $tpl->parseCurrentBlock("back_item"); $projectId = GetProjectIdForItem($_POST["item_id"]); } else { $tpl->setCurrentBlock("back_unit"); $tpl->setVariable("UNIT_ID", $_POST["unit_id"]); $tpl->parseCurrentBlock("back_unit"); $projectId = GetProjectIdForUnit($_POST["unit_id"]); } $isLogged = IsLogged(); // If user is logged in and had write access, we directly update the database if ($isLogged && IsWriter($projectId)) { $_POST["description"] = str_replace("\\\\", "\\", $_POST["description"]); // if we have an item_id, we update, else we add if (array_key_exists("item_id", $_POST) && $_POST["item_id"] != "") { $msg = ModifyItem($_POST["item_id"], $_POST["name"], $_POST["summary"], $_POST["description"], $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"], $_POST["extras"], $_POST["jvcl_info"], GetLoggedUserId()); } else { $msg = AddItem($_POST["unit_id"], $_POST["name"], $_POST["summary"], $_POST["description"], $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"], $_POST["extras"], $_POST["jvcl_info"], GetLoggedUserId()); } if (is_string($msg) && $msg != "") { $msg = "Error while submitting the Item: " . $msg; } else { $msg = "Item added/updated successfuly"; } $tpl->setCurrentBlock("thanks_logged_in");
function AcessPrivate() { if (!IsLogged()) { Redirect(URL_BASE); } }
/** * Returns user permissions for a particular table * A - Add * D - Delete * E - Edit * S - List/View/Search * P - Print/Expor * @param String table * @return String * @intellisense */ function GetUserPermissions($table = "") { global $strTableName, $globalEvents; if (!$table) { $table = $strTableName; } $permissions = ""; if (!IsLogged()) { return ""; } $permissions = GetUserPermissionsStatic($table); if ($globalEvents->exists("GetTablePermissions", $table)) { $permissions = $globalEvents->GetTablePermissions($permissions, $table); } return $permissions; }