function saveTagIndexes($tag, $filename, &$settings, &$titles, &$linenos, &$errors)
{
    global $Conf, $Me, $Error;
    $result = $Conf->qe($Conf->paperQuery($Me, array("paperId" => array_keys($settings))));
    while ($row = PaperInfo::fetch($result, $Me)) {
        if ($settings[$row->paperId] !== null && !$Me->can_change_tag($row, $tag, null, 1)) {
            $errors[$linenos[$row->paperId]] = "You cannot rank paper #{$row->paperId}.";
            unset($settings[$row->paperId]);
        } else {
            if ($titles[$row->paperId] !== "" && strcmp($row->title, $titles[$row->paperId]) != 0 && strcasecmp($row->title, simplify_whitespace($titles[$row->paperId])) != 0) {
                $errors[$linenos[$row->paperId]] = "Warning: Title doesn’t match";
            }
        }
    }
    if (!$tag) {
        defappend($Error["tags"], "No tag defined");
    } else {
        if (count($settings)) {
            $x = array("paper,tag,lineno");
            foreach ($settings as $pid => $value) {
                $x[] = "{$pid},{$tag}#" . ($value === null ? "clear" : $value) . "," . $linenos[$pid];
            }
            $assigner = new AssignmentSet($Me);
            $assigner->parse(join("\n", $x) . "\n", $filename);
            $assigner->report_errors();
            $assigner->execute();
        }
    }
    $settings = $titles = $linenos = array();
}
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf, $Opt;
     // maybe download preferences for someone else
     $Rev = $user;
     if (($cid = cvtint($qreq->reviewer)) > 0 && $user->privChair) {
         if (!($Rev = Contact::find_by_id($cid))) {
             return Conf::msg_error("No such reviewer");
         }
     }
     if (!$Rev->isPC) {
         return self::EPERM;
     }
     $q = $Conf->paperQuery($Rev, array("paperId" => $ssel->selection(), "topics" => 1, "reviewerPreference" => 1));
     $result = Dbl::qe_raw($q);
     $texts = array();
     while ($prow = PaperInfo::fetch($result, $Rev)) {
         $t = $prow->paperId . "," . CsvGenerator::quote($prow->title);
         if ($prow->conflictType > 0) {
             $t .= ",conflict";
         } else {
             $t .= "," . unparse_preference($prow);
         }
         $t .= "\n";
         if ($this->extended) {
             if ($Rev->can_view_authors($prow, false)) {
                 $t .= prefix_word_wrap("#  Authors: ", $prow->pretty_text_author_list(), "#           ");
             }
             $t .= prefix_word_wrap("# Abstract: ", rtrim($prow->abstract), "#           ");
             if ($prow->topicIds != "") {
                 $t .= prefix_word_wrap("#   Topics: ", $prow->unparse_topics_text(), "#           ");
             }
             $t .= "\n";
         }
         defappend($texts[$prow->paperId], $t);
     }
     downloadCSV(join("", $ssel->reorder($texts)), ["paper", "title", "preference"], "revprefs");
 }
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf;
     $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "topics" => 1)));
     $texts = array();
     while ($prow = PaperInfo::fetch($result, $user)) {
         if ($whyNot = $user->perm_view_paper($prow)) {
             Conf::msg_error(whyNotText($whyNot, "view"));
         } else {
             $text = "===========================================================================\n";
             $n = "Paper #" . $prow->paperId . ": ";
             $l = max(14, (int) ((75.5 - strlen($prow->title) - strlen($n)) / 2) + strlen($n));
             $text .= prefix_word_wrap($n, $prow->title, $l);
             $text .= "---------------------------------------------------------------------------\n";
             $l = strlen($text);
             if ($user->can_view_authors($prow, $qreq->t == "a")) {
                 $text .= prefix_word_wrap("Authors: ", $prow->pretty_text_author_list(), 14);
             }
             if ($prow->topicIds != "" && ($tt = $prow->unparse_topics_text())) {
                 $text .= prefix_word_wrap("Topics: ", $tt, 14);
             }
             if ($l != strlen($text)) {
                 $text .= "---------------------------------------------------------------------------\n";
             }
             $text .= rtrim($prow->abstract) . "\n\n";
             defappend($texts[$prow->paperId], $text);
             $rfSuffix = count($texts) == 1 ? $prow->paperId : "s";
         }
     }
     if (count($texts)) {
         downloadText(join("", $ssel->reorder($texts)), "abstract{$rfSuffix}");
     }
 }
 function run(Contact $user, $qreq, $ssel)
 {
     global $Conf;
     $result = Dbl::qe_raw($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "allReviews" => 1, "reviewerName" => 1)));
     $texts = array();
     $errors = array();
     $user->set_forceShow(true);
     $rf = ReviewForm::get();
     while ($row = PaperInfo::fetch($result, $user)) {
         if ($whyNot = $user->perm_view_review($row, null, null)) {
             $errors[whyNotText($whyNot, "view review")] = true;
         } else {
             if ($row->reviewSubmitted) {
                 defappend($texts[$row->paperId], $rf->pretty_text($row, $row, $user) . "\n");
             }
         }
     }
     $crows = $Conf->comment_rows($Conf->paperQuery($user, array("paperId" => $ssel->selection(), "allComments" => 1, "reviewerName" => 1)), $user);
     foreach ($crows as $row) {
         if ($user->can_view_comment($row, $row, null)) {
             $crow = new CommentInfo($row, $row);
             defappend($texts[$row->paperId], $crow->unparse_text($user) . "\n");
         }
     }
     $this->finish($ssel, $texts, $errors);
 }