Пример #1
0
    $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");
} else {
    // if the user is not logged in or does not have write access,
    // we submit the item for review
    $msg = AddSubmittedItem($_POST["item_id"], $_POST["unit_id"], $_POST["name"], $_POST["summary"], $_POST["description"], $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"], $_POST["extras"], $_POST["jvcl_info"]);
    if ($msg != "") {
        $msg = "Error while submitting the Item: " . $msg;
Пример #2
0
    if ($result == "") {
        $msg = "Modification successful";
    } else {
        $msg = "Error while modifying: " . $result;
    }
} elseif ($action == "delete") {
    if (array_key_exists("users", $_POST) && is_array($_POST["users"])) {
        StartAccessToDB();
        // Rules:
        // - It is not possible to delete all users
        // - A user cannot delete himself
        // - It is not possible to delete the last admin
        if (count($_POST["users"]) == GetUsersCount()) {
            $msg = "Cannot delete all users in the system.";
        } else {
            $LoggedUserId = GetLoggedUserId();
            $adminIds = GetAdminUsersId();
            $adminCount = count($adminIds);
            foreach ($_POST["users"] as $userId) {
                if ($LoggedUserId == $userId) {
                    $error = "You cannot delete yourself. Please ask another admin to do so.";
                } else {
                    if (in_array($userId, $adminIds)) {
                        $adminCount--;
                    }
                    if ($adminCount == 0) {
                        $error = "Cannot delete the last admin in the system.";
                    } else {
                        $error = DeleteUser($userId);
                    }
                }
Пример #3
0
    $tpl->parseCurrentBlock("back_unit");
    $projectId = GetProjectIdForUnit($_POST["unit_id"]);
} else {
    $tpl->setCurrentBlock("back_project");
    $tpl->setVariable("PROJECT_ID", $_POST["project_id"]);
    $tpl->parseCurrentBlock("back_project");
    $projectId = $_POST["project_id"];
}
$isLogged = IsLogged();
// If user is logged in and had write access, we directly update the database
if ($isLogged && IsWriter($projectId)) {
    // if we have a unit_id, we update, else we add
    if (array_key_exists("unit_id", $_POST) && $_POST["unit_id"] != "") {
        $msg = ModifyUnit($_POST["unit_id"], str_replace(".pas", ".dtx", $_POST["unit_name"]), $_POST["description"], $_POST["author"], $_POST["package"], $_POST["status"], GetLoggedUserId());
    } else {
        $msg = AddUnit(str_replace(".pas", ".dtx", $_POST["unit_name"]), $_POST["description"], $_POST["author"], $_POST["package"], $_POST["status"], $_POST["project_id"], GetLoggedUserId());
        if (is_numeric($msg)) {
            $msg = "";
        }
    }
    $tpl->setCurrentBlock("thanks_logged_in");
    $tpl->touchBlock("thanks_logged_in");
    $tpl->parseCurrentBlock("thanks_logged_in");
} else {
    /*    // if the user is not logged in or does not have write access, 
        // we submit the item for review
        $msg = AddSubmittedItem(
                 $_POST["item_id"], 
                 $_POST["unit_id"], 
                 $_POST["name"], $_POST["summary"], $_POST["description"], 
                 $_POST["return_value"], $_POST["see_also_list"], $_POST["parameters"],
Пример #4
0
} else {
    $action = "";
}
if ($action == "add") {
    if (!IsAdmin()) {
        $result = "Only administrators may add projects in the system.";
    } else {
        $result = AddProject($_POST["name"], $_POST["description"], $_POST["reviewers_emails"], $_POST["admin_email"], array_key_exists("send_notifications", $_POST) ? $_POST["send_notifications"] : "", GetLoggedUserId());
    }
    if ($result == "") {
        $msg = "Add successful";
    } else {
        $msg = "Error while adding: " . $result;
    }
} elseif ($action == "modify") {
    $result = ModifyProject($_POST["Id"], $_POST["name"], $_POST["description"], $_POST["reviewers_emails"], $_POST["admin_email"], array_key_exists("send_notifications", $_POST) ? $_POST["send_notifications"] : "", GetLoggedUserId());
    if ($result == "") {
        $msg = "Modification successful";
    } else {
        $msg = "Error while modifying: " . $result;
    }
} elseif ($action == "delete") {
    if (!IsAdmin()) {
        $msg = "Only administrators may delete projects from the system.";
    } elseif (array_key_exists("projects", $_POST) && is_array($_POST["projects"])) {
        StartAccessToDB();
        foreach ($_POST["projects"] as $project) {
            $error = DeleteProject($project);
            if ($error != "") {
                if ($msg != "") {
                    $msg .= "<br>";
Пример #5
0
function Logout()
{
    global $cookieName;
    global $lastLoginResult;
    $userId = GetLoggedUserId();
    if ($userId != -1) {
        ResetUserActivity($userId);
        setcookie($cookieName, "");
        unset($_COOKIE[$cookieName]);
        $lastLoginResult = LLR_NOW_LOGGED_OUT;
    } else {
        $lastLoginResult = LLR_NOT_LOGGED_IN;
    }
}
Пример #6
0
function ProcessDtx($filename, $projectId)
{
    StartAccessToDB();
    $lines = file($filename);
    $msg = "processing " . $filename . "<br>";
    $unitname = basename($filename);
    // Delete the existing unit (if any)
    $msg .= "deleting previous values for {$unitname}, if any...<br>";
    $deleteResult = DeleteUnitAndItemsByUnitName($unitname);
    if ($deleteResult != "") {
        $msg .= "Error while removing previous values: " . $deleteResult;
    } else {
        $msg .= "Success<br>";
        $unitId = -1;
        $index = 0;
        while ($index < count($lines)) {
            $curline = rtrim($lines[$index]);
            if (HasPrefix($curline, '##Package:')) {
                $package = substr($curline, strpos($curline, ':') + 2);
                $msg .= "found package: {$package}<br>";
            }
            if (HasPrefix($curline, '##Status:')) {
                $status = substr($curline, strpos($curline, ':') + 2);
                $msg .= "found status: {$status}<br>";
            }
            if (HasPrefix($curline, '@@')) {
                $msg .= "found item: {$curline} - ";
                if ($unitId == -1) {
                    $msg .= "Adding unit <a href=\"unit.php?Name={$unitname}\">{$unitname}</a> - ";
                    $unitId = AddUnit($unitname, "", "", $package, $status, $projectId, GetLoggedUserId());
                    if (is_string($unitId)) {
                        $msg .= $unitId . "<br>";
                        $unitId = -1;
                    }
                }
                if ($unitId != -1) {
                    $msg .= ProcessItem($lines, $index, $unitId);
                }
            }
            $index++;
        }
    }
    // delete the file, we don't need it anymore
    unlink($filename);
    EndAccessToDB();
    return $msg;
}