<?php if (!isLoggedIn()) { echo _REQUIRE_LOGIN; return; } if (!atLeastSModerator()) { echo formatText("Sorry, the Helpdesk is currently in development. If you have a request, please send it to [c=1]."); return; } if (isset($_POST["summary"])) { sql_values(array("hlpSummary" => $_POST["summary"], "hlpCategory" => $_POST["category"], "hlpSubmitDate!" => "NOW()", "hlpSubmitter" => $_auth["useid"], "hlpReferenceType" => $_POST["referenceType"], "hlpReferenceId" => $_POST["referenceID"], "hlpOwner" => getRequestRefOwner($_POST["referenceType"], $_POST["referenceID"]))); $helpdeskItem = sql_insert("helpdesk"); addRequestDetail($helpdeskItem, "publicDetail", "publicFile", "all"); addRequestDetail($helpdeskItem, "privateDetail", "privateFile", "submitter"); redirect(url("helpdesk")); } $requestCat = strtolower($_cmd[2]); $requestRef = strtolower($_cmd[3]); $requestRefId = intval($_cmd[4]); $cats = array(); $catsResult = sql_rowset("helpdeskCats"); while ($catsData = sql_next($catsResult)) { $cats[$catsData["hdcid"]] = array("name" => $catsData["hdcName"], "type" => $catsData["hdcType"]); } sql_free($catsResult); ?> <div class="header"> Add a Request </div> <form action="<?php
function putRequestData($hlpData, $showDetails = false) { global $_auth; ?> <div class="container2 mar_bottom"> <div style="margin-left : 20px;"> <div style="margin-left : -20px; margin-top : 0.4em; float : left;"> <?php echo getIMG(url() . "images/emoticons/star.png"); ?> </div> <?php if ($hlpData["hlpReferenceType"] == "submission") { ?> <div style="float : right; margin-left : 1em; margin-bottom : 0.5em;"> <?php echo getObjectThumb($hlpData["hlpReferenceId"], 100, false); ?> </div> <?php } if ($hlpData["hlpReferenceType"] == "extras") { ?> <div style="float : right; margin-left : 1em; margin-bottom : 0.5em;"> <?php echo getObjectThumb($hlpData["hlpReferenceId"], 100, true); ?> </div> <?php } ?> <div class="header" style="padding : 0; padding-bottom : 0.3em;"> <a href="<?php echo url("helpdesk/details/" . $hlpData["hlpid"]); ?> "> <?php echo getRequestCategoryText($hlpData["hlpCategory"]); ?> </a> </div> <?php $ref = getRequestRefText($hlpData["hlpReferenceType"], $hlpData["hlpReferenceId"]); if ($ref != "--") { ?> <div> <b>In reference to</b>: <?php echo $ref; ?> </div> <?php } ?> <div> <b>Status</b>: <?php echo getRequestStatusText($hlpData["hlpStatus"]); ?> </div> <div> <b>Urgency</b>: <?php echo getRequestUrgencyText($hlpData["hlpUrgency"]); ?> </div> <?php $hasOwner = $hlpData["hlpOwner"] > 0; $isStaff = atLeastModerator(); $isSubmitter = isLoggedIn() && $_auth["useid"] == $hlpData["hlpSubmitter"]; $isOwner = isLoggedIn() && $_auth["useid"] == $hlpData["hlpOwner"]; if ($isOwner && $hlpData["hlpStatus"] == "wait-assign") { ?> <div class="mar_top"> <span class="error">Summary will be available after the request is assigned.</span> </div> <?php } else { ?> <div class="mar_top"> <?php echo formatText($hlpData["hlpSummary"], true, true); ?> </div> <?php } $allowedPrivacy = "'all'"; if ($isStaff) { $allowedPrivacy .= ",'private','submitter','owner'"; } else { if ($isSubmitter) { $allowedPrivacy .= ",'submitter'"; } if ($isOwner) { $allowedPrivacy .= ",'owner'"; } } if ($showDetails) { ?> <div style="clear : both;"></div> <?php sql_order("hddSubmitDate"); sql_where(array("hddItem" => $hlpData["hlpid"], "|1" => "`hddPrivacy` IN(" . $allowedPrivacy . ")")); $hddResult = sql_rowset("helpdeskDetails"); while ($hddData = sql_next($hddResult)) { putRequestDetail($hlpData, $hddData); } sql_free($hddResult); $doSubmitDetail = false; $detailPrivacy = "?"; if (isset($_POST["submitPrivate"])) { $doSubmitDetail = true; $detailPrivacy = "private"; } if (isset($_POST["submitSubmitter"])) { $doSubmitDetail = true; $detailPrivacy = "submitter"; } if (isset($_POST["submitOwner"])) { $doSubmitDetail = true; $detailPrivacy = "owner"; } if (isset($_POST["submitAll"])) { $doSubmitDetail = true; $detailPrivacy = "all"; } if ($doSubmitDetail) { addRequestDetail($hlpData["hlpid"], "detailText", "detailFile", $detailPrivacy); redirect(url(".")); } if ($hlpData["hlpStatus"] == "completed") { ?> <span class="error"><b>COMPLETED</b></span>. This request's status is 'completed', no further details are accepted. <?php } else { ?> <div class="container2 mar_bottom"> <div class="header" style="padding-left : 0; padding-top : 0;"> Submit new detail </div> <form action="<?php echo url("."); ?> " enctype="multipart/form-data" method="post"> <div class="mar_bottom"> <textarea name="detailText" rows="9" style="width : 95%;"></textarea> </div> <div class="mar_bottom" style="padding-right : 10%"> (optionally) <b>Upload a file</b>: </div> <div class="mar_bottom"> <input name="detailFile" type="file" size="30" /> </div> <?php if ($isSubmitter && !$hasOwner) { // A simple submit button. ?> <div class="mar_top"> <input type="submit" name="submitSubmitter" value="<?php echo _SUBMIT; ?> " /> </div> <?php } else { ?> <div class="mar_top"> Who should be able to read this detail: </div> <?php if ($hasOwner) { ?> <div class="mar_top"> <button name="submitAll"> <?php echo getRequestPrivacyText("all", $hlpData); ?> </button> </div> <?php if (!$isSubmitter) { ?> <div class="mar_top"> <button name="submitOwner"> <?php echo getRequestPrivacyText("owner", $hlpData); ?> </button> </div> <?php } } ?> <div class="mar_top"> <button name="submitSubmitter"> <?php echo getRequestPrivacyText("submitter", $hlpData); ?> </button> </div> <?php if ($isStaff) { // Only staff can submit staff-only details :3 ?> <div class="mar_top"> <button name="submitPrivate"> <?php echo getRequestPrivacyText("private", $hlpData); ?> </button> </div> <?php } ?> <div class="mar_top"> * <b>Submitter</b> — The user that made the request. <?php if ($hasOwner) { ?> <br /> * <b>Owner</b> — The user that owns the object questioned by the request. <?php } ?> </div> <?php } ?> </form> </div> <?php } } else { sql_where(array("hddItem" => $hlpData["hlpid"], "|1" => "`hddPrivacy` IN(" . $allowedPrivacy . ")")); $detailCount = sql_count("helpdeskDetails"); ?> <div style="text-align : left; margin-top : 0.6em;"> <a href="<?php echo url("helpdesk/details/" . $hlpData["hlpid"]); ?> "> View Request Details</a> (<?php echo $detailCount; ?> ) </div> <div style="clear : both;"></div> <?php } ?> </div> </div> <?php }