Exemple #1
0
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());
}
Exemple #2
0
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");
    $tpl->touchBlock("thanks_logged_in");
    $tpl->parseCurrentBlock("thanks_logged_in");
function LoggedUserHasAccessToProject($projectId)
{
    return IsWriter($projectId);
}