Example #1
0
    $tpl->setCurrentBlock("back_unit");
    $tpl->setVariable("UNIT_ID", $_POST["unit_id"]);
    $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"], 
Example #2
0
function ProcessItem($lines, &$index, $unitId)
{
    $Name = substr($lines[$index], 2);
    $Summary = "";
    $Author = "";
    $Description = "";
    $ReturnValue = "";
    $SeeAlso = "";
    $Parameters = "";
    $Extras = "";
    $JVCLInfo = "";
    $curSectionRef =& $Extras;
    // be careful with case of $curSectionRef
    $WrapCol = WrappingColumn;
    $curSectionContent = '';
    do {
        $curLine = rtrim($lines[$index]);
        switch (strtolower($curLine)) {
            case 'summary':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $Summary;
                break;
            case 'author':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $Author;
                break;
            case 'description':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $Description;
                break;
            case 'return value':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $ReturnValue;
                break;
            case 'see also':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $SeeAlso;
                break;
            case 'parameters':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $Parameters;
                break;
            case 'jvclinfo':
                $curSectionRef = $curSectionContent;
                $curSectionContent = '';
                $curSectionRef =& $JVCLInfo;
                break;
            default:
                if (!HasPrefix($curLine, '----------') && !HasPrefix(trim($curLine), "@@")) {
                    $WrapCol = strlen(trim($curLine));
                    $curSectionContent .= $curLine . "\r\n";
                }
        }
        $index++;
    } while ($index < count($lines) and !HasPrefix(trim($lines[$index]), '@@'));
    // As we got out, we need to set the value of the section that
    // got pointed to last.
    $curSectionRef = Unwrap($curSectionContent, WrappingColumn, IndentationSpaces);
    // go back one line
    $index--;
    $Name = rtrim($Name);
    $Summary = rtrim($Summary);
    $Author = rtrim($Author);
    $Description = rtrim($Description);
    $ReturnValue = rtrim($ReturnValue);
    $SeeAlso = rtrim($SeeAlso);
    $Parameters = rtrim($Parameters);
    $Extras = rtrim($Extras);
    $JVCLInfo = rtrim($JVCLInfo);
    // We can now insert in the database
    if (substr($Name, -4) == ".pas") {
        $Name = str_replace(".pas", ".dtx", $Name);
        $existTest = UnitExistsByName($Name);
        if (is_string($existTest)) {
            return "Error while looking for {$Name}: {$existTest}";
        }
        if ($existTest) {
            if ($Summary != "") {
                $Description = $Summary . "\n" . $Description;
            }
            $updateResult = ModifyUnit($unitId, $Name, $Description, $Author, null, null, GetLoggedUserId());
            if ($updateResult == "") {
                return "Unit details updated.<br>";
            } else {
                return "Error while updating unit: " . $updateResult . "<br>";
            }
        } else {
            return "Error while processing unit details, the unit {$Name} does not exist !!!!<br>";
        }
    } else {
        $itemId = AddItem($unitId, $Name, Unwrap($Summary, $WrapCol, IndentationSpaces), Unwrap($Description, $WrapCol, IndentationSpaces), Unwrap($ReturnValue, $WrapCol, IndentationSpaces), Unwrap($SeeAlso, $WrapCol, IndentationSpaces), Unwrap($Parameters, $WrapCol, IndentationSpaces), Unwrap($Extras, $WrapCol, IndentationSpaces), Unwrap($JVCLInfo, $WrapCol, IndentationSpaces), GetLoggedUserId());
        if (is_string($itemId)) {
            return "Error while adding the item: " . $itemId . "<br>";
        } else {
            return "Added item with key <a href=\"item.php?Id={$itemId}\">{$itemId}</a><br>";
        }
    }
}