function GetNoAccessToProjectPage($projectId) { $tpl = new HTML_Template_IT("./"); $tpl->loadTemplatefile("no_access_to_project.tpl.html", true, false); SetCommonLoginStatus($tpl); SetAdminToolbar($tpl); SetCommonFooter($tpl); $projectInfos = GetProjectInfos($projectId); $tpl->setVariable("PROJECT_NAME", $projectInfos["Name"]); // print the output return $tpl->get(); }
$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; } $unitInfos = GetUnitInfos($_POST["unit_id"]); if (is_string($unitInfos)) { if ($msg != "") { $msg .= "<br>"; } $msg .= "Error getting Unit infos: " . $unitInfos; } $projectInfos = GetProjectInfos($unitInfos["ProjectId"]); if (is_string($projectInfos)) { if ($msg != "") { $msg .= "<br>"; } $msg .= "Error getting project infos: " . $projectInfos; } // Send the email to notify admins a new item has been submitted, if asked to do so if ($projectInfos["SendNotifications"] == 1) { $mailResult = SendEMail($projectInfos["ReviewersEmails"], $projectInfos["AdminEmail"], "An item has been submitted: " . $_POST["name"], "Item " . $_POST["name"] . " has just been submitted into jedihelp. Please review it."); if ($mailResult != "") { if ($msg != "") { $msg .= "<BR>"; } $msg .= "Error sending mail: " . $mailResult; }
$tpl->setCurrentBlock("per_pages_list"); $tpl->setVariable("VALUE", $per_pages_list[$i]); $tpl->setVariable("SELECTED", $per_pages_list[$i] == $per_pages ? "selected" : ""); $tpl->parseCurrentBlock("per_pages_list"); } $tpl->setVariable("PAGE", $page); $tpl->setVariable("PER_PAGES", $per_pages); $result = array(($page - 1) * $per_pages, $per_pages); return $result; } StartAccessToDB(); $tpl = new HTML_Template_IT("./"); $tpl->loadTemplatefile("browse.tpl.html", true, true); SetCommonLoginStatus($tpl); SetCommonFooter($tpl); $projectInfos = GetProjectInfos($_GET["Id"]); if (!is_array($projectInfos)) { if ($projectInfos == "") { die("Project " . $_GET["Id"] . " does not exist in the database."); } else { die($projectInfos); } exit; } SetCommonToolbar($tpl, array("ProjectId" => $projectInfos["Id"])); SetLastChanged($tpl, $projectInfos["userId"], $projectInfos["LastChange"]); $tpl->setVariable("PROJECT_ID", $projectInfos["Id"]); $tpl->setVariable("PROJECT_NAME", $projectInfos["Name"]); $tpl->setVariable("PROJECT_DESCRIPTION", EncodeString($projectInfos["Description"])); // --------------------------------------------------------------- // Decide to display units or types
fclose($file); $tpl->show(); } } elseif (array_key_exists(DTX_COOKIE_NAME . "_project", $_COOKIE)) { // Step 3: The last cookie is the project Id cookie, so we know // that we can create the zip file from the dtx files. // create zip $zipname = tempnam("", "jh_"); $zip = new pclzip($zipname); $addResult = $zip->add($outDirName . "/", PCLZIP_OPT_REMOVE_ALL_PATH); if ($addResult == 0) { $msg = "Error creating zip file:" . $zip->errorInfo(true); $tpl->SetVariable("MESSAGE", $msg); $tpl->Show(); } else { $projectInfos = GetProjectInfos($_COOKIE[DTX_COOKIE_NAME . "_project"]); $filename = $projectInfos["Name"] . ".zip"; // we have the zip, send it header("Content-Type: archive/zip"); // replace by text/plain for debug header('Content-Disposition: attachment; filename="' . $filename . '"'); // don't use file_get_contents, it might be too recent // echo file_get_contents($zipname); $file = fopen($zipname, "rb"); while (!feof($file)) { echo fread($file, 1024); } fclose($file); } // now that the zip is created, we can remove all files and the directory unlink($zipname);
$projectId = $_GET["Id"]; if (!LoggedUserHasAccessToProject($projectId)) { die(GetNoAccessToProjectPage($projectId)); } } else { $projectId = ""; } $tpl = new HTML_Template_IT("./"); $tpl->loadTemplatefile("admin_edit_project.tpl.html", true, true); SetCommonLoginStatus($tpl); SetAdminToolbar($tpl); SetCommonFooter($tpl); if (is_numeric($projectId)) { // here we edit an existing project $tpl->setVariable("ACTION", "modify"); $project = GetProjectInfos($projectId); $tpl->setVariable("ID", $project["Id"]); $tpl->setVariable("NAME", $project["Name"]); $tpl->setVariable("DESCRIPTION", EncodeString(trim($project["Description"]))); $tpl->setVariable("REVIEWERS_EMAILS", $project["ReviewersEmails"]); $tpl->setVariable("ADMIN_EMAIL", $project["AdminEmail"]); $tpl->setVariable("SEND_NOTIFICATIONS_CHECKED", $project["SendNotifications"] == 1 ? "checked" : ""); } else { // here we add a project $tpl->setVariable("ACTION", "add"); $tpl->setVariable("ID", ""); $tpl->setVariable("NAME", ""); $tpl->setVariable("DESCRIPTION", ""); $tpl->setVariable("REVIEWERS_EMAILS", ""); $tpl->setVariable("ADMIN_EMAIL", ""); $tpl->setVariable("SEND_NOTIFICATIONS_CHECKED", "");
function GetItemImageUrl($itemName, $itemProjectId) { global $itemImageBaseUrl; $projectInfos = GetProjectInfos($itemProjectId); return $itemImageBaseUrl . strtolower($projectInfos["Name"]) . "/" . strtoupper($itemName) . ".bmp"; }