예제 #1
0
function downloadForm($editable)
{
    global $rf, $Conf, $Me, $prow, $paperTable, $Opt;
    $explicit = true;
    if ($paperTable->rrow) {
        $rrows = array($paperTable->rrow);
    } else {
        if ($editable) {
            $rrows = array();
        } else {
            $rrows = $paperTable->viewable_rrows;
            $explicit = false;
        }
    }
    $text = "";
    foreach ($rrows as $rr) {
        if ($rr->reviewSubmitted) {
            $text .= downloadView($prow, $rr, $editable);
        }
    }
    foreach ($rrows as $rr) {
        if (!$rr->reviewSubmitted && ($explicit || $rr->reviewModified)) {
            $text .= downloadView($prow, $rr, $editable);
        }
    }
    if (count($rrows) == 0 && $editable) {
        $text .= downloadView($prow, null, $editable);
    }
    if (!$explicit) {
        $paperTable->resolveComments();
        foreach ($paperTable->crows as $cr) {
            if ($Me->can_view_comment($prow, $cr, false)) {
                $text .= $cr->unparse_text($Me, true) . "\n";
            }
        }
    }
    if (!$text) {
        $whyNot = $Me->perm_view_review($prow, null, null);
        return Conf::msg_error(whyNotText($whyNot ?: array("fail" => 1), "review"));
    }
    if ($editable) {
        $text = ReviewForm::textFormHeader(count($rrows) > 1) . $text;
    }
    $filename = (count($rrows) > 1 ? "reviews" : "review") . "-" . $prow->paperId;
    if (count($rrows) == 1 && $rrows[0]->reviewSubmitted) {
        $filename .= unparseReviewOrdinal($rrows[0]->reviewOrdinal);
    }
    downloadText($text, $filename, !$editable);
}
예제 #2
0
 protected function finish($ssel, $texts, $errors)
 {
     global $Conf, $Opt;
     $texts = $ssel->reorder($texts);
     if (empty($texts)) {
         if (empty($errors)) {
             Conf::msg_error("No papers selected.");
         } else {
             Conf::msg_error(join("<br />\n", array_keys($errors)) . "<br />\nNothing to download.");
         }
         return;
     }
     $warnings = array();
     $nerrors = 0;
     foreach ($errors as $ee => $iserror) {
         $warnings[] = whyNotHtmlToText($ee);
         if ($iserror) {
             $nerrors++;
         }
     }
     if ($nerrors) {
         array_unshift($warnings, "Some " . ($this->isform ? "review forms" : "reviews") . " are missing:");
     }
     if ($this->isform && (count($texts) == 1 || $this->iszip)) {
         $rfname = "review";
     } else {
         $rfname = "reviews";
     }
     if (count($texts) == 1 && !$this->iszip) {
         $rfname .= key($texts);
     }
     if ($this->isform) {
         $header = ReviewForm::textFormHeader(count($texts) > 1 && !$this->iszip);
     } else {
         $header = "";
     }
     if (!$this->iszip) {
         $text = $header;
         if (!empty($warnings) && $this->isform) {
             foreach ($warnings as $w) {
                 $text .= prefix_word_wrap("==-== ", whyNotHtmlToText($w), "==-== ");
             }
             $text .= "\n";
         } else {
             if (!empty($warnings)) {
                 $text .= join("\n", $warnings) . "\n\n";
             }
         }
         $text .= join("", $texts);
         downloadText($text, $rfname);
     } else {
         $zip = new ZipDocument($Opt["downloadPrefix"] . "reviews.zip");
         $zip->warnings = $warnings;
         foreach ($texts as $pid => $text) {
             $zip->add($header . $text, $Opt["downloadPrefix"] . $rfname . $pid . ".txt");
         }
         $result = $zip->download();
         if (!$result->error) {
             exit;
         }
     }
 }
예제 #3
0
// offline.php -- HotCRP offline review management page
// HotCRP is Copyright (c) 2006-2016 Eddie Kohler and Regents of the UC
// Distributed under an MIT-like license; see LICENSE
require_once "src/initweb.php";
if ($Me->is_empty()) {
    $Me->escape();
}
$rf = ReviewForm::get();
// general error messages
if (defval($_REQUEST, "post") && !count($_POST)) {
    $Conf->post_missing_msg();
}
// download blank review form action
if (isset($_REQUEST["downloadForm"])) {
    $text = ReviewForm::textFormHeader("blank") . $rf->textForm(null, null, $Me, null) . "\n";
    downloadText($text, "review");
}
// upload review form action
if (isset($_REQUEST["uploadForm"]) && fileUploaded($_FILES["uploadedFile"]) && check_post()) {
    $tf = $rf->beginTextForm($_FILES["uploadedFile"]["tmp_name"], $_FILES["uploadedFile"]["name"]);
    while ($req = $rf->parseTextForm($tf)) {
        $rf->check_save_review($req, $tf, $Me);
    }
    $rf->textFormMessages($tf);
    // Uploading forms may have completed the reviewer's task; recheck roles.
    Contact::update_rights();
} else {
    if (isset($_REQUEST["uploadForm"])) {
        Conf::msg_error("Choose a file first.");
    }