Exemple #1
0
function _update_schema_regrade_flags(Conf $conf)
{
    $result = $conf->ql("select rgr.*, u.cid from RepositoryGradeRequest rgr\n        left join (select link, pset, min(cid) cid\n                   from ContactLink where type=" . LINK_REPO . " group by link, pset) u on (u.link=rgr.repoid)");
    while ($row = edb_orow($result)) {
        if ($row->cid && ($u = $conf->user_by_id($row->cid)) && ($pset = $conf->pset_by_id($row->pset))) {
            $info = new PsetView($pset, $u, $u);
            $info->force_set_commit($row->hash);
            $update = ["flags" => ["t" . $row->requested_at => ["uid" => $u->contactId]]];
            $info->update_current_info($update);
        }
    }
    Dbl::free($result);
    return true;
}
Exemple #2
0
 private static function modify_password_mail($where, $dopassword, $sendtype, $ids)
 {
     global $Conf;
     $j = (object) array("ok" => true);
     $result = $Conf->qe_raw("select * from ContactInfo where {$where} and contactId" . sql_in_numeric_set($ids));
     while ($row = edb_orow($result)) {
         $Acct = Contact::make($row);
         if ($dopassword) {
             $Acct->change_password(null, true);
         }
         if ($sendtype && $Acct->password != "" && !$Acct->disabled) {
             $Acct->sendAccountInfo($sendtype, false);
         } else {
             if ($sendtype) {
                 $j->warnings[] = "Not sending mail to disabled account " . htmlspecialchars($Acct->email) . ".";
             }
         }
     }
     return $j;
 }
function fix_one_delegation()
{
    global $Conf;
    $row = Dbl::fetch_first_row("select r.paperId, r.contactId, u.email, q.ct, q.cs, r.reviewNeedsSubmit\n            from PaperReview r\n            left join (select paperId, requestedBy, count(reviewId) ct, count(reviewSubmitted) cs\n                       from PaperReview where reviewType<" . REVIEW_SECONDARY . "\n                       group by paperId, requestedBy) q\n                on (q.paperId=r.paperId and q.requestedBy=r.contactId)\n            left join ContactInfo u on (u.contactId=r.contactId)\n            where r.reviewType=" . REVIEW_SECONDARY . " and r.reviewSubmitted is null\n            and if(coalesce(q.ct,0)=0,1,if(q.cs=0,-1,0))!=r.reviewNeedsSubmit\n            limit 1");
    if (!$row) {
        return false;
    }
    $pid = (int) $row[0];
    $req_cid = (int) $row[1];
    $req_email = $row[2];
    $prow = $Conf->paperRow(["paperId" => $pid], null);
    fwrite(STDERR, "Problem: #{$pid} review by {$req_email}\n");
    fwrite(STDERR, "  reviewNeedsSubmit {$row['5']}, " . plural($row[3] ?: 0, "delegate") . ", " . plural($row[4] ?: 0, "submitted delegate") . "\n");
    $result = Dbl::qe("select l.* from ActionLog l where paperId=? order by logId asc", $pid);
    $proposals = $confirmations = [];
    while ($row = edb_orow($result)) {
        if ($row->contactId == $req_cid && preg_match('/\\ALogged proposal for (\\S+) to review/', $row->action, $m) && ($xid = Contact::id_by_email($m[1]))) {
            $proposals[$xid] = true;
        } else {
            if (preg_match('/\\AAdded External review by (\\S+)/', $row->action, $m) && ($pc = pcByEmail($m[1])) && $pc->can_administer($prow)) {
                $confirmations[$row->contactId] = $pc->contactId;
            }
        }
    }
    Dbl::free($result);
    foreach ($proposals as $xid => $x) {
        if (isset($confirmations[$xid])) {
            $result1 = Dbl::qe("update PaperReview set requestedBy=? where paperId=? and contactId=? and requestedBy=?", $req_cid, $pid, $xid, $confirmations[$xid]);
            $result2 = Dbl::qe("update PaperReview r, PaperReview q set r.reviewNeedsSubmit=0 where r.paperId=? and r.contactId=? and q.paperId=? and q.contactId=? and q.reviewSubmitted is not null", $pid, $req_cid, $pid, $xid);
            if ($result1->affected_rows || $result2->affected_rows) {
                return true;
            }
        }
    }
    error_log("Failed to resolve paper #{$pid} review by {$req_email}");
    return false;
}
 private function _review_word_counts($restriction, $basek, $k, $count)
 {
     $a = $this->review_cid_int_array($restriction, $basek, $k);
     if ($a !== false || $count) {
         return $a;
     }
     $result = Dbl::qe("select * from PaperReview where reviewWordCount is null and paperId={$this->paperId}");
     $rf = ReviewForm::get();
     $qs = [];
     while ($rrow = edb_orow($result)) {
         $qs[] = "update PaperReview set reviewWordCount=" . $rf->word_count($rrow) . " where reviewId=" . $rrow->reviewId;
     }
     Dbl::free($result);
     if (count($qs)) {
         $mresult = Dbl::multi_qe(join(";", $qs));
         while ($result = $mresult->next()) {
             Dbl::free($result);
         }
         unset($this->reviewWordCounts, $this->allReviewWordCounts);
     }
     return $this->_review_word_counts($restriction, $basek, $k, $count + 1);
 }
                $b[] = Text::word_regex($word);
            }
        }
    }
    $x = (object) array("preg_utf8" => join("|", $a));
    if (count($a) == count($b)) {
        $x->preg_raw = join("|", $b);
    }
    return $x;
}
// Current PC member information
if ($reviewer > 0) {
    $col = array(array(), array(), array());
    // Conflict information
    $result = $Conf->qe("select firstName, lastName, affiliation, collaborators from ContactInfo where contactId={$reviewer}");
    if ($result && ($row = edb_orow($result))) {
        if ($row->collaborators) {
            $col[1][] = "<div class='f-c'>Collaborators</div><div class='f-e'>" . nl2br(htmlspecialchars($row->collaborators)) . "</div>";
        }
        $useless_words = array("university" => 1, "the" => 1, "and" => 1, "of" => 1, "univ" => 1, "none" => 1, "a" => 1, "an" => 1, "at" => 1, "jr" => 1, "sr" => 1, "iii" => 1);
        // search outline from old CRP, done here in a very different way
        preg_match_all('/[a-z&]{2,}/', strtolower($row->firstName . " " . $row->lastName . " " . $row->affiliation), $match);
        $useless = $useless_words;
        $search = array();
        $showco = "";
        foreach ($match[0] as $s) {
            if (!isset($useless[$s])) {
                $search[] = "co:" . (ctype_alnum($s) ? $s : "\"{$s}\"");
                $showco .= $s . " ";
                $useless[$s] = 1;
            }
 public function upload_document($docj, PaperOption $o)
 {
     global $Conf;
     // look for an existing document with same sha1;
     // check existing docid's sha1
     $docid = get($docj, "docid");
     if ($docid) {
         $oldj = $this->document_to_json($o->id, $docid);
         if (get($docj, "sha1") && get($oldj, "sha1") !== $docj->sha1) {
             $docid = null;
         }
     } else {
         if (!$docid && $this->paperid > 0 && get($docj, "sha1")) {
             $result = Dbl::qe("select paperStorageId from PaperStorage where paperId=? and documentType=? and sha1=?", $this->paperid, $o->id, $docj->sha1);
             if ($row = edb_row($result)) {
                 $docid = $row[0];
             }
         }
     }
     if ($docid) {
         $docj->docid = $docid;
         return;
     }
     // check filter
     if (get($docj, "filter") && is_int($docj->filter)) {
         if (is_int(get($docj, "original_id"))) {
             $result = Dbl::qe("select paperStorageId, timestamp, sha1 from PaperStorage where paperStorageId=?", $docj->original_id);
         } else {
             if (is_string(get($docj, "original_sha1"))) {
                 $result = Dbl::qe("select paperStorageId, timestamp, sha1 from PaperStorage where paperId=? and sha1=?", $this->paperid, $docj->original_sha1);
             } else {
                 if ($o->id == DTYPE_SUBMISSION || $o->id == DTYPE_FINAL) {
                     $result = Dbl::qe("select PaperStorage.paperStorageId, PaperStorage.timestamp, PaperStorage.sha1 from PaperStorage join Paper on (Paper.paperId=PaperStorage.paperId and Paper." . ($o->id == DTYPE_SUBMISSION ? "paperStorageId" : "finalPaperStorageId") . "=PaperStorage.paperStorageId) where Paper.paperId=?", $this->paperid);
                 } else {
                     $result = null;
                 }
             }
         }
         if ($row = edb_orow($result)) {
             $docj->original_id = (int) $row->paperStorageId;
             $docj->original_timestamp = (int) $row->timestamp;
             $docj->original_sha1 = $row->sha1;
             if (get($docj, "preserve_timestamp")) {
                 $docj->timestamp = (int) $docj->original_timestamp;
             }
         } else {
             unset($docj->original_id);
         }
     }
     // if no sha1 match, upload
     $docclass = new HotCRPDocument($o->id);
     $upload = null;
     if ($docclass->load($docj)) {
         $upload = $docclass->upload($docj, (object) array("paperId" => $this->paperid));
     }
     if ($upload && get($upload, "paperStorageId") > 1) {
         foreach (array("size", "sha1", "mimetype", "timestamp") as $k) {
             $docj->{$k} = $upload->{$k};
         }
         $this->uploaded_documents[] = $docj->docid = $upload->paperStorageId;
     } else {
         $docj->docid = 1;
         $this->set_option_error_html($o, $upload ? $upload->error_html : "empty document");
     }
 }
if (!@$_REQUEST["newrev_since"] && ($t = $Conf->setting("pcrev_informtime"))) {
    $_REQUEST["newrev_since"] = $Conf->parseableTime($t, true);
}
echo 'Assignments since:&nbsp; ', Ht::entry("newrev_since", @$_REQUEST["newrev_since"], array("placeholder" => "(all)", "size" => 30)), '</div>';
echo '<div class="fx9 g"></div></div>';
$Conf->footerScript("setmailpsel(\$\$(\"recipients\"))");
echo "</td></tr>\n";
// ** CC, REPLY-TO
if ($Me->is_manager()) {
    foreach (Mailer::$email_fields as $lcfield => $field) {
        if ($lcfield !== "to" && $lcfield !== "bcc") {
            $xfield = $lcfield == "reply-to" ? "replyto" : $lcfield;
            $ec = isset($Error[$xfield]) ? " error" : "";
            echo "  <tr><td class='mhnp{$ec} nw'>{$field}:</td><td class='mhdp{$ec}'>", "<input type='text' class='textlite-tt' name='{$xfield}' value=\"", htmlspecialchars($_REQUEST[$xfield]), "\" size='64' />", $xfield == "replyto" ? "<div class='g'></div>" : "", "</td></tr>\n\n";
        }
    }
}
// ** SUBJECT
echo "  <tr><td class='mhnp nw'>Subject:</td><td class='mhdp'>", "<tt>[", htmlspecialchars(Conf::$gShortName), "]&nbsp;</tt><input type='text' class='textlite-tt' name='subject' value=\"", htmlspecialchars($_REQUEST["subject"]), "\" size='64' /></td></tr>\n\n <tr><td></td><td class='mhb'>\n", Ht::textarea("emailBody", $_REQUEST["emailBody"], array("class" => "tt", "rows" => 20, "cols" => 80, "spellcheck" => "true")), "</td></tr>\n</table></div>\n\n";
if ($Me->privChair) {
    $result = $Conf->qe("select * from MailLog order by mailId desc limit 18");
    if (edb_nrows($result)) {
        echo "<div style='padding-top:12px'>", "<strong>Recent mails:</strong>\n";
        while ($row = edb_orow($result)) {
            echo "<div class='mhdd'><div style='position:relative;overflow:hidden'>", "<div style='position:absolute;white-space:nowrap'><a class='q' href=\"", hoturl("mail", "fromlog=" . $row->mailId), "\">", htmlspecialchars($row->subject), " &ndash; <span class='dim'>", htmlspecialchars($row->emailBody), "</span></a></div>", "<br /></div></div>\n";
        }
        echo "</div>\n\n";
    }
}
echo "<div class='aa' style='clear:both'>\n", Ht::submit("Prepare mail"), " &nbsp; <span class='hint'>You’ll be able to review the mails before they are sent.</span>\n</div>\n\n\n<div id='mailref'>Keywords enclosed in percent signs, such as <code>%NAME%</code> or <code>%REVIEWDEADLINE%</code>, are expanded for each mail.  Use the following syntax:\n<div class='g'></div>\n<table>\n<tr><td class='plholder'><table>\n<tr><td class='lxcaption'><code>%URL%</code></td>\n    <td class='llentry'>Site URL.</td></tr>\n<tr><td class='lxcaption'><code>%LOGINURL%</code></td>\n    <td class='llentry'>URL for recipient to log in to the site.</td></tr>\n<tr><td class='lxcaption'><code>%NUMSUBMITTED%</code></td>\n    <td class='llentry'>Number of papers submitted.</td></tr>\n<tr><td class='lxcaption'><code>%NUMACCEPTED%</code></td>\n    <td class='llentry'>Number of papers accepted.</td></tr>\n<tr><td class='lxcaption'><code>%NAME%</code></td>\n    <td class='llentry'>Full name of recipient.</td></tr>\n<tr><td class='lxcaption'><code>%FIRST%</code>, <code>%LAST%</code></td>\n    <td class='llentry'>First and last names, if any, of recipient.</td></tr>\n<tr><td class='lxcaption'><code>%EMAIL%</code></td>\n    <td class='llentry'>Email address of recipient.</td></tr>\n<tr><td class='lxcaption'><code>%REVIEWDEADLINE%</code></td>\n    <td class='llentry'>Reviewing deadline appropriate for recipient.</td></tr>\n</table></td><td class='plholder'><table>\n<tr><td class='lxcaption'><code>%NUMBER%</code></td>\n    <td class='llentry'>Paper number relevant for mail.</td></tr>\n<tr><td class='lxcaption'><code>%TITLE%</code></td>\n    <td class='llentry'>Paper title.</td></tr>\n<tr><td class='lxcaption'><code>%TITLEHINT%</code></td>\n    <td class='llentry'>First couple words of paper title (useful for mail subject).</td></tr>\n<tr><td class='lxcaption'><code>%OPT(AUTHORS)%</code></td>\n    <td class='llentry'>Paper authors (if recipient is allowed to see the authors).</td></tr>\n<tr><td><div class='g'></div></td></tr>\n<tr><td class='lxcaption'><code>%REVIEWS%</code></td>\n    <td class='llentry'>Pretty-printed paper reviews.</td></tr>\n<tr><td class='lxcaption'><code>%COMMENTS%</code></td>\n    <td class='llentry'>Pretty-printed paper comments, if any.</td></tr>\n<tr><td class='lxcaption'><code>%COMMENTS(TAG)%</code></td>\n    <td class='llentry'>Comments tagged #TAG, if any.</td></tr>\n<tr><td><div class='g'></div></td></tr>\n<tr><td class='lxcaption'><code>%IF(SHEPHERD)%...%ENDIF%</code></td>\n    <td class='llentry'>Include text only if a shepherd is assigned.</td></tr>\n<tr><td class='lxcaption'><code>%SHEPHERD%</code></td>\n    <td class='llentry'>Shepherd name and email, if any.</td></tr>\n<tr><td class='lxcaption'><code>%SHEPHERDNAME%</code></td>\n    <td class='llentry'>Shepherd name, if any.</td></tr>\n<tr><td class='lxcaption'><code>%SHEPHERDEMAIL%</code></td>\n    <td class='llentry'>Shepherd email, if any.</td></tr>\n<tr><td class='lxcaption'><code>%TAGVALUE(t)%</code></td>\n    <td class='llentry'>Value of paper’s tag <code>t</code>.</td></tr>\n</table></td></tr>\n</table></div>\n\n</div></form>\n";
$Conf->footer();
Exemple #8
0
        if (!$zlib_output_compression) {
            header("Content-Length: 43");
        }
        print "GIF89a€!ù,D;";
    }
    exit;
}
if (!$Me->isPC) {
    $Me->escape();
}
function output($User)
{
    global $Me;
    $u = $Me->user_linkpart($User);
    echo '<div class="facebook61">', '<a href="', hoturl("index", ["u" => $u]), '">', '<img class="bigface61" src="' . hoturl("face", ["u" => $u, "imageid" => $User->contactImageId ?: 0]) . '" border="0" />', '</a>', '<h2 class="infacebook61"><a class="q" href="', hoturl("index", ["u" => $u]), '">', htmlspecialchars($u), '</a>';
    if ($Me->privChair) {
        echo "&nbsp;", become_user_link($User);
    }
    echo '</h2>';
    if ($User !== $Me) {
        echo '<h3 class="infacebook61">', Text::user_html($User), '</h3>';
    }
    echo '</div>';
}
$Conf->header("Thefacebook", "face");
$u = Dbl::qe("select contactId, email, firstName, lastName, seascode_username, contactImageId from ContactInfo where roles=0");
while ($user = edb_orow($u)) {
    output($user);
}
echo "<div class='clear'></div>\n";
$Conf->footer();
Exemple #9
0
 function commit_notes($hash)
 {
     assert(!$this->gitless);
     $result = $this->conf->qe("select * from CommitNotes where hash=? and pset=?", $hash, $this->psetid);
     $cn = edb_orow($result);
     if ($cn && $cn->notes) {
         $cn->notes = json_decode($cn->notes);
     }
     Dbl::free($result);
     return $cn;
 }
Exemple #10
0
 static function send_reviewers($template, $row, $rest = array())
 {
     global $Conf, $Me, $Opt;
     $result = $Conf->qe("select ContactInfo.contactId,\n                firstName, lastName, email, preferredEmail, password, roles, disabled,\n                conflictType, reviewType myReviewType\n                from ContactInfo\n                join PaperReview on (PaperReview.contactId=ContactInfo.contactId and PaperReview.paperId={$row->paperId})\n                left join PaperConflict on (PaperConflict.contactId=ContactInfo.contactId and PaperConflict.paperId={$row->paperId})\n                group by ContactInfo.contactId");
     if (!isset($rest["cc"]) && isset($Opt["emailCc"])) {
         $rest["cc"] = $Opt["emailCc"];
     } else {
         if (!isset($rest["cc"])) {
             $rest["cc"] = Text::user_email_to(Contact::site_contact());
         }
     }
     // must set the current conflict type in $row for each contact
     $contact_info_map = $row->replace_contact_info_map(null);
     $contacts = array();
     while ($contact = edb_orow($result)) {
         $row->assign_contact_info($contact, $contact->contactId);
         self::send_to(Contact::make($contact), $template, $row, $rest);
         $contacts[] = Text::user_html($contact);
     }
     $row->replace_contact_info_map($contact_info_map);
     if ($Me->allow_administer($row) && !$row->has_author($Me) && count($contacts)) {
         $endmsg = isset($rest["infoMsg"]) ? ", " . $rest["infoMsg"] : ".";
         $Conf->infoMsg("Sent email to paper #{$row->paperId}’s " . pluralx($contacts, "reviewer") . ", " . commajoin($contacts) . $endmsg);
     }
 }
function updateSchema($Conf)
{
    global $Opt, $OK;
    // avoid error message abut timezone, set to $Opt
    // (which might be overridden by database values later)
    if (function_exists("date_default_timezone_set") && isset($Opt["timezone"]) && $Opt["timezone"]) {
        date_default_timezone_set($Opt["timezone"]);
    }
    while (($result = Dbl::ql("insert into Settings set name='__schema_lock', value=1 on duplicate key update value=1")) && $result->affected_rows == 0) {
        time_nanosleep(0, 200000000);
    }
    $Conf->update_schema_version(null);
    error_log($Opt["dbName"] . ": updating schema from version " . $Conf->sversion);
    if ($Conf->sversion == 6 && Dbl::ql("alter table ReviewRequest add `reason` text")) {
        $Conf->update_schema_version(7);
    }
    if ($Conf->sversion == 7 && Dbl::ql("alter table PaperReview add `textField7` mediumtext NOT NULL") && Dbl::ql("alter table PaperReview add `textField8` mediumtext NOT NULL") && Dbl::ql("insert into ReviewFormField set fieldName='textField7', shortName='Additional text field'") && Dbl::ql("insert into ReviewFormField set fieldName='textField8', shortName='Additional text field'")) {
        $Conf->update_schema_version(8);
    }
    if ($Conf->sversion == 8 && Dbl::ql("alter table ReviewFormField add `levelChar` tinyint(1) NOT NULL default '0'") && Dbl::ql("alter table PaperReviewArchive add `textField7` mediumtext NOT NULL") && Dbl::ql("alter table PaperReviewArchive add `textField8` mediumtext NOT NULL")) {
        $Conf->update_schema_version(9);
    }
    if ($Conf->sversion == 9 && Dbl::ql("alter table Paper add `sha1` varbinary(20) NOT NULL default ''")) {
        $Conf->update_schema_version(10);
    }
    if ($Conf->sversion == 10 && Dbl::ql("alter table PaperReview add `reviewRound` tinyint(1) NOT NULL default '0'") && Dbl::ql("alter table PaperReviewArchive add `reviewRound` tinyint(1) NOT NULL default '0'") && Dbl::ql("alter table PaperReview add key `reviewRound` (`reviewRound`)") && $Conf->update_schema_version(11)) {
        if (count($Conf->round_list()) > 1) {
            // update review rounds (XXX locking)
            $result = Dbl::ql("select paperId, tag from PaperTag where tag like '%~%'");
            $rrs = array();
            while ($row = edb_row($result)) {
                list($contact, $round) = explode("~", $row[1]);
                if ($round = array_search($round, $Conf->round_list())) {
                    if (!isset($rrs[$round])) {
                        $rrs[$round] = array();
                    }
                    $rrs[$round][] = "(contactId={$contact} and paperId={$row['0']})";
                }
            }
            foreach ($rrs as $round => $pairs) {
                $q = "update PaperReview set reviewRound={$round} where " . join(" or ", $pairs);
                Dbl::ql($q);
            }
            $x = trim(preg_replace('/(\\S+)\\s*/', "tag like '%~\$1' or ", $Conf->setting_data("tag_rounds")));
            Dbl::ql("delete from PaperTag where " . substr($x, 0, strlen($x) - 3));
        }
    }
    if ($Conf->sversion == 11 && Dbl::ql("create table `ReviewRating` (\n  `reviewId` int(11) NOT NULL,\n  `contactId` int(11) NOT NULL,\n  `rating` tinyint(1) NOT NULL default '0',\n  UNIQUE KEY `reviewContact` (`reviewId`,`contactId`),\n  UNIQUE KEY `reviewContactRating` (`reviewId`,`contactId`,`rating`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8")) {
        $Conf->update_schema_version(12);
    }
    if ($Conf->sversion == 12 && Dbl::ql("alter table PaperReview add `reviewToken` int(11) NOT NULL default '0'")) {
        $Conf->update_schema_version(13);
    }
    if ($Conf->sversion == 13 && Dbl::ql("alter table OptionType add `optionValues` text NOT NULL default ''")) {
        $Conf->update_schema_version(14);
    }
    if ($Conf->sversion == 14 && Dbl::ql("insert into Settings (name, value) select 'rev_tokens', count(reviewId) from PaperReview where reviewToken!=0 on duplicate key update value=values(value)")) {
        $Conf->update_schema_version(15);
    }
    if ($Conf->sversion == 15) {
        // It's OK if this fails!  Update 11 added reviewRound to
        // PaperReviewArchive (so old databases have the column), but I forgot
        // to upgrade schema.sql (so new databases lack the column).
        Dbl::ql("alter table PaperReviewArchive add `reviewRound` tinyint(1) NOT NULL default '0'");
        $OK = true;
        $Conf->update_schema_version(16);
    }
    if ($Conf->sversion == 16 && Dbl::ql("alter table PaperReview add `reviewEditVersion` int(1) NOT NULL default '0'")) {
        $Conf->update_schema_version(17);
    }
    if ($Conf->sversion == 17 && Dbl::ql("alter table PaperReviewPreference add key `paperId` (`paperId`)") && Dbl::ql("create table PaperRank (\n  `paperId` int(11) NOT NULL,\n  `contactId` int(11) NOT NULL,\n  `rank` int(11) NOT NULL,\n  UNIQUE KEY `contactPaper` (`contactId`,`paperId`),\n  KEY `paperId` (`paperId`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8;")) {
        $Conf->update_schema_version(18);
    }
    if ($Conf->sversion == 18 && Dbl::ql("alter table PaperComment add `replyTo` int(11) NOT NULL")) {
        $Conf->update_schema_version(19);
    }
    if ($Conf->sversion == 19 && Dbl::ql("drop table PaperRank")) {
        $Conf->update_schema_version(20);
    }
    if ($Conf->sversion == 20 && Dbl::ql("alter table PaperComment add `timeNotified` int(11) NOT NULL default '0'")) {
        $Conf->update_schema_version(21);
    }
    if ($Conf->sversion == 21 && Dbl::ql("update PaperConflict set conflictType=8 where conflictType=3")) {
        $Conf->update_schema_version(22);
    }
    if ($Conf->sversion == 22 && Dbl::ql("insert into ChairAssistant (contactId) select contactId from Chair on duplicate key update ChairAssistant.contactId=ChairAssistant.contactId") && Dbl::ql("update ContactInfo set roles=roles+2 where roles=5")) {
        $Conf->update_schema_version(23);
    }
    if ($Conf->sversion == 23) {
        $Conf->update_schema_version(24);
    }
    if ($Conf->sversion == 24 && Dbl::ql("alter table ContactInfo add `preferredEmail` varchar(120)")) {
        $Conf->update_schema_version(25);
    }
    if ($Conf->sversion == 25) {
        if ($Conf->settings["final_done"] > 0 && !isset($Conf->settings["final_soft"]) && Dbl::ql("insert into Settings (name, value) values ('final_soft', " . $Conf->settings["final_done"] . ") on duplicate key update value=values(value)")) {
            $Conf->settings["final_soft"] = $Conf->settings["final_done"];
        }
        $Conf->update_schema_version(26);
    }
    if ($Conf->sversion == 26 && Dbl::ql("alter table PaperOption add `data` text") && Dbl::ql("alter table OptionType add `type` tinyint(1) NOT NULL default '0'") && Dbl::ql("update OptionType set type=2 where optionValues='i'") && Dbl::ql("update OptionType set type=1 where type=0 and optionValues!=''")) {
        $Conf->update_schema_version(27);
    }
    if ($Conf->sversion == 27 && Dbl::ql("alter table PaperStorage add `sha1` varbinary(20) NOT NULL default ''") && Dbl::ql("alter table PaperStorage add `documentType` int(3) NOT NULL default '0'") && Dbl::ql("update PaperStorage s, Paper p set s.sha1=p.sha1 where s.paperStorageId=p.paperStorageId and p.finalPaperStorageId=0 and s.paperStorageId>0") && Dbl::ql("update PaperStorage s, Paper p set s.sha1=p.sha1, s.documentType=" . DTYPE_FINAL . " where s.paperStorageId=p.finalPaperStorageId and s.paperStorageId>0")) {
        $Conf->update_schema_version(28);
    }
    if ($Conf->sversion == 28 && Dbl::ql("alter table OptionType add `sortOrder` tinyint(1) NOT NULL default '0'")) {
        $Conf->update_schema_version(29);
    }
    if ($Conf->sversion == 29 && Dbl::ql("delete from Settings where name='pldisplay_default'")) {
        $Conf->update_schema_version(30);
    }
    if ($Conf->sversion == 30 && Dbl::ql("DROP TABLE IF EXISTS `Formula`") && Dbl::ql("CREATE TABLE `Formula` (\n  `formulaId` int(11) NOT NULL auto_increment,\n  `name` varchar(200) NOT NULL,\n  `heading` varchar(200) NOT NULL default '',\n  `headingTitle` text NOT NULL default '',\n  `expression` text NOT NULL,\n  `authorView` tinyint(1) NOT NULL default '1',\n  PRIMARY KEY  (`formulaId`),\n  UNIQUE KEY `formulaId` (`formulaId`),\n  UNIQUE KEY `name` (`name`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8")) {
        $Conf->update_schema_version(31);
    }
    if ($Conf->sversion == 31 && Dbl::ql("alter table Formula add `createdBy` int(11) NOT NULL default '0'") && Dbl::ql("alter table Formula add `timeModified` int(11) NOT NULL default '0'") && Dbl::ql("alter table Formula drop index `name`")) {
        $Conf->update_schema_version(32);
    }
    if ($Conf->sversion == 32 && Dbl::ql("alter table PaperComment add key `timeModified` (`timeModified`)")) {
        $Conf->update_schema_version(33);
    }
    if ($Conf->sversion == 33 && Dbl::ql("alter table PaperComment add `paperStorageId` int(11) NOT NULL default '0'")) {
        $Conf->update_schema_version(34);
    }
    if ($Conf->sversion == 34 && Dbl::ql("alter table ContactInfo add `contactTags` text")) {
        $Conf->update_schema_version(35);
    }
    if ($Conf->sversion == 35 && Dbl::ql("alter table ContactInfo modify `defaultWatch` int(11) NOT NULL default '2'") && Dbl::ql("alter table PaperWatch modify `watch` int(11) NOT NULL default '0'")) {
        $Conf->update_schema_version(36);
    }
    if ($Conf->sversion == 36 && Dbl::ql("alter table PaperReview add `reviewNotified` int(1) default NULL") && Dbl::ql("alter table PaperReviewArchive add `reviewNotified` int(1) default NULL")) {
        $Conf->update_schema_version(37);
    }
    if ($Conf->sversion == 37 && Dbl::ql("alter table OptionType add `displayType` tinyint(1) NOT NULL default '0'")) {
        $Conf->update_schema_version(38);
    }
    if ($Conf->sversion == 38 && Dbl::ql("update PaperComment set forReviewers=1 where forReviewers=-1")) {
        $Conf->update_schema_version(39);
    }
    if ($Conf->sversion == 39 && Dbl::ql("CREATE TABLE `MailLog` (\n  `mailId` int(11) NOT NULL auto_increment,\n  `recipients` varchar(200) NOT NULL,\n  `paperIds` text,\n  `cc` text,\n  `replyto` text,\n  `subject` text,\n  `emailBody` text,\n  PRIMARY KEY  (`mailId`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8")) {
        $Conf->update_schema_version(40);
    }
    if ($Conf->sversion == 40 && Dbl::ql("alter table Paper add `capVersion` int(1) NOT NULL default '0'")) {
        $Conf->update_schema_version(41);
    }
    if ($Conf->sversion == 41 && Dbl::ql("alter table Paper modify `mimetype` varchar(80) NOT NULL default ''") && Dbl::ql("alter table PaperStorage modify `mimetype` varchar(80) NOT NULL default ''")) {
        $Conf->update_schema_version(42);
    }
    if ($Conf->sversion == 42 && Dbl::ql("alter table PaperComment add `ordinal` int(11) NOT NULL default '0'")) {
        $Conf->update_schema_version(43);
    }
    if ($Conf->sversion == 42 && ($result = Dbl::ql("describe PaperComment `ordinal`")) && ($o = edb_orow($result)) && substr($o->Type, 0, 3) == "int" && (!$o->Null || $o->Null == "NO") && (!$o->Default || $o->Default == "0")) {
        $Conf->update_schema_version(43);
    }
    if ($Conf->sversion == 43 && Dbl::ql("alter table Paper add `withdrawReason` text")) {
        $Conf->update_schema_version(44);
    }
    if ($Conf->sversion == 44 && Dbl::ql("alter table PaperStorage add `filename` varchar(255)")) {
        $Conf->update_schema_version(45);
    }
    if ($Conf->sversion == 45 && Dbl::ql("alter table PaperReview add `timeRequested` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReview add `timeRequestNotified` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReviewArchive add `timeRequested` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReviewArchive add `timeRequestNotified` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReview drop column `requestedOn`") && Dbl::ql("alter table PaperReviewArchive drop column `requestedOn`")) {
        $Conf->update_schema_version(46);
    }
    if ($Conf->sversion == 46 && Dbl::ql("alter table ContactInfo add `disabled` tinyint(1) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(47);
    }
    if ($Conf->sversion == 47 && Dbl::ql("delete from ti using TopicInterest ti left join TopicArea ta using (topicId) where ta.topicId is null")) {
        $Conf->update_schema_version(48);
    }
    if ($Conf->sversion == 48 && Dbl::ql("alter table PaperReview add `reviewAuthorNotified` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReviewArchive add `reviewAuthorNotified` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReviewArchive add `reviewToken` int(11) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(49);
    }
    if ($Conf->sversion == 49 && Dbl::ql("alter table PaperOption drop index `paperOption`") && Dbl::ql("alter table PaperOption add index `paperOption` (`paperId`,`optionId`,`value`)")) {
        $Conf->update_schema_version(50);
    }
    if ($Conf->sversion == 50 && Dbl::ql("alter table Paper add `managerContactId` int(11) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(51);
    }
    if ($Conf->sversion == 51 && Dbl::ql("alter table Paper drop column `numComments`") && Dbl::ql("alter table Paper drop column `numAuthorComments`")) {
        $Conf->update_schema_version(52);
    }
    // Due to a bug in the schema updater, some databases might have
    // sversion>=53 but no `PaperComment.commentType` column. Fix them.
    if (($Conf->sversion == 52 || $Conf->sversion >= 53 && ($result = Dbl::ql("show columns from PaperComment like 'commentType'")) && edb_nrows($result) == 0) && Dbl::ql("lock tables PaperComment write, Settings write") && Dbl::ql("alter table PaperComment add `commentType` int(11) NOT NULL DEFAULT '0'")) {
        $new_sversion = max($Conf->sversion, 53);
        $result = Dbl::ql("show columns from PaperComment like 'forAuthors'");
        if (!$result || edb_nrows($result) == 0 || Dbl::ql("update PaperComment set commentType=" . (COMMENTTYPE_AUTHOR | COMMENTTYPE_RESPONSE) . " where forAuthors=2") && Dbl::ql("update PaperComment set commentType=commentType|" . COMMENTTYPE_DRAFT . " where forAuthors=2 and forReviewers=0") && Dbl::ql("update PaperComment set commentType=" . COMMENTTYPE_ADMINONLY . " where forAuthors=0 and forReviewers=2") && Dbl::ql("update PaperComment set commentType=" . COMMENTTYPE_PCONLY . " where forAuthors=0 and forReviewers=0") && Dbl::ql("update PaperComment set commentType=" . COMMENTTYPE_REVIEWER . " where forAuthors=0 and forReviewers=1") && Dbl::ql("update PaperComment set commentType=" . COMMENTTYPE_AUTHOR . " where forAuthors!=0 and forAuthors!=2") && Dbl::ql("update PaperComment set commentType=commentType|" . COMMENTTYPE_BLIND . " where blind=1")) {
            $Conf->update_schema_version($new_sversion);
        }
    }
    if ($Conf->sversion < 53) {
        Dbl::qx_raw($Conf->dblink, "alter table PaperComment drop column `commentType`");
    }
    Dbl::ql("unlock tables");
    if ($Conf->sversion == 53 && Dbl::ql("alter table PaperComment drop column `forReviewers`") && Dbl::ql("alter table PaperComment drop column `forAuthors`") && Dbl::ql("alter table PaperComment drop column `blind`")) {
        $Conf->update_schema_version(54);
    }
    if ($Conf->sversion == 54 && Dbl::ql("alter table PaperStorage add `infoJson` varchar(255) DEFAULT NULL")) {
        $Conf->update_schema_version(55);
    }
    if ($Conf->sversion == 55 && Dbl::ql("alter table ContactInfo modify `password` varbinary(2048) NOT NULL")) {
        $Conf->update_schema_version(56);
    }
    if ($Conf->sversion == 56 && Dbl::ql("alter table Settings modify `data` blob")) {
        $Conf->update_schema_version(57);
    }
    if ($Conf->sversion == 57 && Dbl::ql("DROP TABLE IF EXISTS `Capability`") && Dbl::ql("CREATE TABLE `Capability` (\n  `capabilityId` int(11) NOT NULL AUTO_INCREMENT,\n  `capabilityType` int(11) NOT NULL,\n  `contactId` int(11) NOT NULL,\n  `paperId` int(11) NOT NULL,\n  `timeExpires` int(11) NOT NULL,\n  `salt` varbinary(255) NOT NULL,\n  `data` blob,\n  PRIMARY KEY (`capabilityId`),\n  UNIQUE KEY `capabilityId` (`capabilityId`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8") && Dbl::ql("DROP TABLE IF EXISTS `CapabilityMap`") && Dbl::ql("CREATE TABLE `CapabilityMap` (\n  `capabilityValue` varbinary(255) NOT NULL,\n  `capabilityId` int(11) NOT NULL,\n  `timeExpires` int(11) NOT NULL,\n  PRIMARY KEY (`capabilityValue`),\n  UNIQUE KEY `capabilityValue` (`capabilityValue`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8")) {
        $Conf->update_schema_version(58);
    }
    if ($Conf->sversion == 58 && Dbl::ql("alter table PaperReview modify `paperSummary` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `commentsToAuthor` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `commentsToPC` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `commentsToAddress` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `weaknessOfPaper` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `strengthOfPaper` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `textField7` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReview modify `textField8` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `paperSummary` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `commentsToAuthor` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `commentsToPC` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `commentsToAddress` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `weaknessOfPaper` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `strengthOfPaper` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `textField7` mediumtext DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive modify `textField8` mediumtext DEFAULT NULL")) {
        $Conf->update_schema_version(59);
    }
    if ($Conf->sversion == 59 && Dbl::ql("alter table ActionLog modify `action` varbinary(4096) NOT NULL") && Dbl::ql("alter table ContactInfo modify `note` varbinary(4096) DEFAULT NULL") && Dbl::ql("alter table ContactInfo modify `collaborators` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table ContactInfo modify `contactTags` varbinary(4096) DEFAULT NULL") && Dbl::ql("alter table Formula modify `headingTitle` varbinary(4096) NOT NULL") && Dbl::ql("alter table Formula modify `expression` varbinary(4096) NOT NULL") && Dbl::ql("alter table OptionType modify `description` varbinary(8192) DEFAULT NULL") && Dbl::ql("alter table OptionType modify `optionValues` varbinary(8192) NOT NULL") && Dbl::ql("alter table PaperReviewRefused modify `reason` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table ReviewFormField modify `description` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table ReviewFormOptions modify `description` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table ReviewRequest modify `reason` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table Settings modify `data` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table ContactAddress modify `addressLine1` varchar(2048) NOT NULL") && Dbl::ql("alter table ContactAddress modify `addressLine2` varchar(2048) NOT NULL") && Dbl::ql("alter table ContactAddress modify `city` varchar(2048) NOT NULL") && Dbl::ql("alter table ContactAddress modify `state` varchar(2048) NOT NULL") && Dbl::ql("alter table ContactAddress modify `zipCode` varchar(2048) NOT NULL") && Dbl::ql("alter table ContactAddress modify `country` varchar(2048) NOT NULL") && Dbl::ql("alter table PaperTopic modify `topicId` int(11) NOT NULL") && Dbl::ql("alter table PaperTopic modify `paperId` int(11) NOT NULL") && Dbl::ql("drop table if exists ChairTag")) {
        $Conf->update_schema_version(60);
    }
    if ($Conf->sversion == 60 && Dbl::ql("insert into Settings (name,value,data) select concat('msg.',substr(name,1,length(name)-3)), value, data from Settings where name='homemsg' or name='conflictdefmsg'") && $Conf->update_schema_version(61)) {
        foreach (array("conflictdef", "home") as $k) {
            if (isset($Conf->settingTexts["{$k}msg"])) {
                $Conf->settingTexts["msg.{$k}"] = $Conf->settingTexts["{$k}msg"];
            }
        }
        $Conf->settings["allowPaperOption"] = 61;
    }
    if ($Conf->sversion == 61 && Dbl::ql("alter table Capability modify `data` varbinary(4096) DEFAULT NULL")) {
        $Conf->update_schema_version(62);
    }
    if (!isset($Conf->settings["outcome_map"])) {
        $ojson = array();
        $result = Dbl::ql("select * from ReviewFormOptions where fieldName='outcome'");
        while ($row = edb_orow($result)) {
            $ojson[$row->level] = $row->description;
        }
        $Conf->save_setting("outcome_map", 1, $ojson);
    }
    if ($Conf->sversion == 62 && isset($Conf->settings["outcome_map"])) {
        $Conf->update_schema_version(63);
    }
    if (!isset($Conf->settings["review_form"]) && $Conf->sversion < 65) {
        update_schema_create_review_form($Conf);
    }
    if ($Conf->sversion == 63 && isset($Conf->settings["review_form"])) {
        $Conf->update_schema_version(64);
    }
    if ($Conf->sversion == 64 && Dbl::ql("drop table if exists `ReviewFormField`") && Dbl::ql("drop table if exists `ReviewFormOptions`")) {
        $Conf->update_schema_version(65);
    }
    if (!isset($Conf->settings["options"]) && $Conf->sversion < 67) {
        update_schema_create_options($Conf);
    }
    if ($Conf->sversion == 65 && isset($Conf->settings["options"])) {
        $Conf->update_schema_version(66);
    }
    if ($Conf->sversion == 66 && Dbl::ql("drop table if exists `OptionType`")) {
        $Conf->update_schema_version(67);
    }
    if ($Conf->sversion == 67 && Dbl::ql("alter table PaperComment modify `comment` varbinary(32767) DEFAULT NULL") && Dbl::ql("alter table PaperComment add `commentTags` varbinary(1024) DEFAULT NULL")) {
        $Conf->update_schema_version(68);
    }
    if ($Conf->sversion == 68 && Dbl::ql("alter table PaperReviewPreference add `expertise` int(4) DEFAULT NULL")) {
        $Conf->update_schema_version(69);
    }
    if ($Conf->sversion == 69 && Dbl::ql("alter table Paper drop column `pcPaper`")) {
        $Conf->update_schema_version(70);
    }
    if ($Conf->sversion == 70 && Dbl::ql("alter table ContactInfo modify `voicePhoneNumber` varbinary(256) DEFAULT NULL") && Dbl::ql("alter table ContactInfo modify `faxPhoneNumber` varbinary(256) DEFAULT NULL") && Dbl::ql("alter table ContactInfo modify `collaborators` varbinary(8192) DEFAULT NULL") && Dbl::ql("alter table ContactInfo drop column `note`") && Dbl::ql("alter table ContactInfo add `data` varbinary(32767) DEFAULT NULL")) {
        $Conf->update_schema_version(71);
    }
    if ($Conf->sversion == 71 && Dbl::ql("alter table Settings modify `name` varbinary(256) DEFAULT NULL") && Dbl::ql("update Settings set name=rtrim(name)")) {
        $Conf->update_schema_version(72);
    }
    if ($Conf->sversion == 72 && Dbl::ql("update TopicInterest set interest=-2 where interest=0") && Dbl::ql("update TopicInterest set interest=4 where interest=2") && Dbl::ql("delete from TopicInterest where interest=1")) {
        $Conf->update_schema_version(73);
    }
    if ($Conf->sversion == 73 && Dbl::ql("alter table PaperStorage add `size` bigint(11) DEFAULT NULL") && Dbl::ql("update PaperStorage set `size`=length(paper) where paper is not null")) {
        $Conf->update_schema_version(74);
    }
    if ($Conf->sversion == 74 && Dbl::ql("alter table ContactInfo drop column `visits`")) {
        $Conf->update_schema_version(75);
    }
    if ($Conf->sversion == 75) {
        foreach (array("capability_gc", "s3_scope", "s3_signing_key") as $k) {
            if (isset($Conf->settings[$k])) {
                $Conf->save_setting("__" . $k, $Conf->settings[$k], get($Conf->settingTexts, $k));
                $Conf->save_setting($k, null);
            }
        }
        $Conf->update_schema_version(76);
    }
    if ($Conf->sversion == 76 && Dbl::ql("update PaperReviewPreference set expertise=-expertise")) {
        $Conf->update_schema_version(77);
    }
    if ($Conf->sversion == 77 && Dbl::ql("alter table MailLog add `q` varchar(4096)")) {
        $Conf->update_schema_version(78);
    }
    if ($Conf->sversion == 78 && Dbl::ql("alter table MailLog add `t` varchar(200)")) {
        $Conf->update_schema_version(79);
    }
    if ($Conf->sversion == 79 && Dbl::ql("alter table ContactInfo add `passwordTime` int(11) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(80);
    }
    if ($Conf->sversion == 80 && Dbl::ql("alter table PaperReview modify `reviewRound` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperReviewArchive modify `reviewRound` int(11) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(81);
    }
    if ($Conf->sversion == 81 && Dbl::ql("alter table PaperStorage add `filterType` int(3) DEFAULT NULL") && Dbl::ql("alter table PaperStorage add `originalStorageId` int(11) DEFAULT NULL")) {
        $Conf->update_schema_version(82);
    }
    if ($Conf->sversion == 82 && Dbl::ql("update Settings set name='msg.resp_instrux' where name='msg.responseinstructions'")) {
        $Conf->update_schema_version(83);
    }
    if ($Conf->sversion == 83 && Dbl::ql("alter table PaperComment add `commentRound` int(11) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(84);
    }
    if ($Conf->sversion == 84 && Dbl::ql("insert ignore into Settings (name, value) select 'resp_active', value from Settings where name='resp_open'")) {
        $Conf->update_schema_version(85);
    }
    if ($Conf->sversion == 85 && Dbl::ql("DROP TABLE IF EXISTS `PCMember`") && Dbl::ql("DROP TABLE IF EXISTS `ChairAssistant`") && Dbl::ql("DROP TABLE IF EXISTS `Chair`")) {
        $Conf->update_schema_version(86);
    }
    if ($Conf->sversion == 86 && update_schema_transfer_address($Conf)) {
        $Conf->update_schema_version(87);
    }
    if ($Conf->sversion == 87 && Dbl::ql("DROP TABLE IF EXISTS `ContactAddress`")) {
        $Conf->update_schema_version(88);
    }
    if ($Conf->sversion == 88 && Dbl::ql("alter table ContactInfo drop key `name`") && Dbl::ql("alter table ContactInfo drop key `affiliation`") && Dbl::ql("alter table ContactInfo drop key `email_3`") && Dbl::ql("alter table ContactInfo drop key `firstName_2`") && Dbl::ql("alter table ContactInfo drop key `lastName`")) {
        $Conf->update_schema_version(89);
    }
    if ($Conf->sversion == 89 && update_schema_unaccented_name($Conf)) {
        $Conf->update_schema_version(90);
    }
    if ($Conf->sversion == 90 && Dbl::ql("alter table PaperReview add `reviewAuthorSeen` int(11) DEFAULT NULL")) {
        $Conf->update_schema_version(91);
    }
    if ($Conf->sversion == 91 && Dbl::ql("alter table PaperReviewArchive add `reviewAuthorSeen` int(11) DEFAULT NULL")) {
        $Conf->update_schema_version(92);
    }
    if ($Conf->sversion == 92 && Dbl::ql("alter table Paper drop key `titleAbstractText`") && Dbl::ql("alter table Paper drop key `allText`") && Dbl::ql("alter table Paper drop key `authorText`") && Dbl::ql("alter table Paper modify `authorInformation` varbinary(8192) DEFAULT NULL") && Dbl::ql("alter table Paper modify `abstract` varbinary(16384) DEFAULT NULL") && Dbl::ql("alter table Paper modify `collaborators` varbinary(8192) DEFAULT NULL") && Dbl::ql("alter table Paper modify `withdrawReason` varbinary(1024) DEFAULT NULL")) {
        $Conf->update_schema_version(93);
    }
    if ($Conf->sversion == 93 && Dbl::ql("alter table TopicArea modify `topicName` varchar(200) DEFAULT NULL")) {
        $Conf->update_schema_version(94);
    }
    if ($Conf->sversion == 94 && Dbl::ql("alter table PaperOption modify `data` varbinary(32768) DEFAULT NULL")) {
        foreach (PaperOption::nonfixed_option_list($Conf) as $xopt) {
            if ($xopt->type === "text") {
                Dbl::ql("delete from PaperOption where optionId={$xopt->id} and data=''");
            }
        }
        $Conf->update_schema_version(95);
    }
    if ($Conf->sversion == 95 && Dbl::ql("alter table Capability add unique key `salt` (`salt`)") && Dbl::ql("update Capability join CapabilityMap using (capabilityId) set Capability.salt=CapabilityMap.capabilityValue") && Dbl::ql("drop table if exists `CapabilityMap`")) {
        $Conf->update_schema_version(96);
    }
    if ($Conf->sversion == 96 && Dbl::ql("alter table ContactInfo add `passwordIsCdb` tinyint(1) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(97);
    }
    if ($Conf->sversion == 97 && Dbl::ql("alter table PaperReview add `reviewWordCount` int(11) DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive add `reviewWordCount` int(11)  DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive drop key `reviewId`") && Dbl::ql("alter table PaperReviewArchive drop key `contactPaper`") && Dbl::ql("alter table PaperReviewArchive drop key `reviewSubmitted`") && Dbl::ql("alter table PaperReviewArchive drop key `reviewNeedsSubmit`") && Dbl::ql("alter table PaperReviewArchive drop key `reviewType`") && Dbl::ql("alter table PaperReviewArchive drop key `requestedBy`")) {
        $Conf->update_schema_version(98);
    }
    if ($Conf->sversion == 98) {
        update_schema_review_word_counts($Conf);
        $Conf->update_schema_version(99);
    }
    if ($Conf->sversion == 99 && Dbl::ql("alter table ContactInfo ENGINE=InnoDB") && Dbl::ql("alter table Paper ENGINE=InnoDB") && Dbl::ql("alter table PaperComment ENGINE=InnoDB") && Dbl::ql("alter table PaperConflict ENGINE=InnoDB") && Dbl::ql("alter table PaperOption ENGINE=InnoDB") && Dbl::ql("alter table PaperReview ENGINE=InnoDB") && Dbl::ql("alter table PaperStorage ENGINE=InnoDB") && Dbl::ql("alter table PaperTag ENGINE=InnoDB") && Dbl::ql("alter table PaperTopic ENGINE=InnoDB") && Dbl::ql("alter table Settings ENGINE=InnoDB")) {
        $Conf->update_schema_version(100);
    }
    if ($Conf->sversion == 100 && Dbl::ql("alter table ActionLog ENGINE=InnoDB") && Dbl::ql("alter table Capability ENGINE=InnoDB") && Dbl::ql("alter table Formula ENGINE=InnoDB") && Dbl::ql("alter table MailLog ENGINE=InnoDB") && Dbl::ql("alter table PaperReviewArchive ENGINE=InnoDB") && Dbl::ql("alter table PaperReviewPreference ENGINE=InnoDB") && Dbl::ql("alter table PaperReviewRefused ENGINE=InnoDB") && Dbl::ql("alter table PaperWatch ENGINE=InnoDB") && Dbl::ql("alter table ReviewRating ENGINE=InnoDB") && Dbl::ql("alter table ReviewRequest ENGINE=InnoDB") && Dbl::ql("alter table TopicArea ENGINE=InnoDB") && Dbl::ql("alter table TopicInterest ENGINE=InnoDB")) {
        $Conf->update_schema_version(101);
    }
    if ($Conf->sversion == 101 && Dbl::ql("alter table ActionLog modify `ipaddr` varbinary(32) DEFAULT NULL") && Dbl::ql("alter table MailLog modify `recipients` varbinary(200) NOT NULL") && Dbl::ql("alter table MailLog modify `q` varbinary(4096) DEFAULT NULL") && Dbl::ql("alter table MailLog modify `t` varbinary(200) DEFAULT NULL") && Dbl::ql("alter table Paper modify `mimetype` varbinary(80) NOT NULL DEFAULT ''") && Dbl::ql("alter table PaperStorage modify `mimetype` varbinary(80) NOT NULL DEFAULT ''") && Dbl::ql("alter table PaperStorage modify `filename` varbinary(255) DEFAULT NULL") && Dbl::ql("alter table PaperStorage modify `infoJson` varbinary(8192) DEFAULT NULL")) {
        $Conf->update_schema_version(102);
    }
    if ($Conf->sversion == 102 && Dbl::ql("alter table PaperReview modify `paperSummary` mediumblob") && Dbl::ql("alter table PaperReview modify `commentsToAuthor` mediumblob") && Dbl::ql("alter table PaperReview modify `commentsToPC` mediumblob") && Dbl::ql("alter table PaperReview modify `commentsToAddress` mediumblob") && Dbl::ql("alter table PaperReview modify `weaknessOfPaper` mediumblob") && Dbl::ql("alter table PaperReview modify `strengthOfPaper` mediumblob") && Dbl::ql("alter table PaperReview modify `textField7` mediumblob") && Dbl::ql("alter table PaperReview modify `textField8` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `paperSummary` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `commentsToAuthor` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `commentsToPC` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `commentsToAddress` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `weaknessOfPaper` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `strengthOfPaper` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `textField7` mediumblob") && Dbl::ql("alter table PaperReviewArchive modify `textField8` mediumblob")) {
        $Conf->update_schema_version(103);
    }
    if ($Conf->sversion == 103 && Dbl::ql("alter table Paper modify `title` varbinary(256) DEFAULT NULL") && Dbl::ql("alter table Paper drop key `title`")) {
        $Conf->update_schema_version(104);
    }
    if ($Conf->sversion == 104 && Dbl::ql("alter table PaperReview add `reviewFormat` tinyint(1) DEFAULT NULL") && Dbl::ql("alter table PaperReviewArchive add `reviewFormat` tinyint(1) DEFAULT NULL")) {
        $Conf->update_schema_version(105);
    }
    if ($Conf->sversion == 105 && Dbl::ql("alter table PaperComment add `commentFormat` tinyint(1) DEFAULT NULL")) {
        $Conf->update_schema_version(106);
    }
    if ($Conf->sversion == 106 && Dbl::ql("alter table PaperComment add `authorOrdinal` int(11) NOT NULL default '0'") && Dbl::ql("update PaperComment set authorOrdinal=ordinal where commentType>=" . COMMENTTYPE_AUTHOR)) {
        $Conf->update_schema_version(107);
    }
    // repair missing comment ordinals; reset incorrect `ordinal`s for
    // author-visible comments
    if ($Conf->sversion == 107) {
        $result = Dbl::ql("select paperId, commentId from PaperComment where ordinal=0 and (commentType&" . (COMMENTTYPE_RESPONSE | COMMENTTYPE_DRAFT) . ")=0 and commentType>=" . COMMENTTYPE_PCONLY . " and commentType<" . COMMENTTYPE_AUTHOR . " order by commentId");
        while ($row = edb_row($result)) {
            Dbl::ql("update PaperComment,\n(select coalesce(count(commentId),0) commentCount from Paper\n    left join PaperComment on (PaperComment.paperId=Paper.paperId and (commentType&" . (COMMENTTYPE_RESPONSE | COMMENTTYPE_DRAFT) . ")=0 and commentType>=" . COMMENTTYPE_PCONLY . " and commentType<" . COMMENTTYPE_AUTHOR . " and commentId<{$row['1']})\n    where Paper.paperId={$row['0']} group by Paper.paperId) t\nset ordinal=(t.commentCount+1) where commentId={$row['1']}");
        }
        $result = Dbl::ql("select paperId, commentId from PaperComment where ordinal=0 and (commentType&" . (COMMENTTYPE_RESPONSE | COMMENTTYPE_DRAFT) . ")=0 and commentType>=" . COMMENTTYPE_AUTHOR . " order by commentId");
        while ($row = edb_row($result)) {
            Dbl::ql("update PaperComment,\n(select coalesce(count(commentId),0) commentCount from Paper\n    left join PaperComment on (PaperComment.paperId=Paper.paperId and (commentType&" . (COMMENTTYPE_RESPONSE | COMMENTTYPE_DRAFT) . ")=0 and commentType>=" . COMMENTTYPE_AUTHOR . " and commentId<{$row['1']})\n    where Paper.paperId={$row['0']} group by Paper.paperId) t\nset authorOrdinal=(t.commentCount+1) where commentId={$row['1']}");
        }
        $result = Dbl::ql("select paperId, commentId from PaperComment where ordinal=authorOrdinal and (commentType&" . (COMMENTTYPE_RESPONSE | COMMENTTYPE_DRAFT) . ")=0 and commentType>=" . COMMENTTYPE_AUTHOR . " order by commentId");
        while ($row = edb_row($result)) {
            Dbl::ql("update PaperComment,\n(select coalesce(max(ordinal),0) maxOrdinal from Paper\n    left join PaperComment on (PaperComment.paperId=Paper.paperId and (commentType&" . (COMMENTTYPE_RESPONSE | COMMENTTYPE_DRAFT) . ")=0 and commentType>=" . COMMENTTYPE_PCONLY . " and commentType<" . COMMENTTYPE_AUTHOR . " and commentId<{$row['1']})\n    where Paper.paperId={$row['0']} group by Paper.paperId) t\nset ordinal=(t.maxOrdinal+1) where commentId={$row['1']}");
        }
        $Conf->update_schema_version(108);
    }
    // contact tags format change
    if ($Conf->sversion == 108 && Dbl::ql("update ContactInfo set contactTags=substr(replace(contactTags, ' ', '#0 ') from 3)") && Dbl::ql("update ContactInfo set contactTags=replace(contactTags, '#0#0 ', '#0 ')")) {
        $Conf->update_schema_version(109);
    }
    if ($Conf->sversion == 109 && Dbl::ql("alter table PaperTag modify `tagIndex` float NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(110);
    }
    if ($Conf->sversion == 110 && Dbl::ql("alter table ContactInfo drop `faxPhoneNumber`") && Dbl::ql("alter table ContactInfo add `country` varbinary(256) default null") && update_schema_transfer_country($Conf)) {
        $Conf->update_schema_version(111);
    }
    if ($Conf->sversion == 111) {
        update_schema_review_word_counts($Conf);
        $Conf->update_schema_version(112);
    }
    if ($Conf->sversion == 112 && Dbl::ql("alter table ContactInfo add `passwordUseTime` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table ContactInfo add `updateTime` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("update ContactInfo set passwordUseTime=lastLogin where passwordUseTime=0")) {
        $Conf->update_schema_version(113);
    }
    if ($Conf->sversion == 113 && Dbl::ql("drop table if exists `PaperReviewArchive`")) {
        $Conf->update_schema_version(114);
    }
    if ($Conf->sversion == 114 && Dbl::ql("alter table PaperReview add `timeDisplayed` int(11) NOT NULL DEFAULT '0'") && Dbl::ql("alter table PaperComment add `timeDisplayed` int(11) NOT NULL DEFAULT '0'")) {
        $Conf->update_schema_version(115);
    }
    if ($Conf->sversion == 115 && Dbl::ql("alter table Formula drop column `authorView`")) {
        $Conf->update_schema_version(116);
    }
    if ($Conf->sversion == 116 && Dbl::ql("alter table PaperComment add `commentOverflow` longblob DEFAULT NULL")) {
        $Conf->update_schema_version(117);
    }
    if ($Conf->sversion == 117 && update_schema_drop_keys_if_exist("PaperTopic", ["paperTopic", "PRIMARY"]) && Dbl::ql("alter table PaperTopic add primary key (`paperId`,`topicId`)") && update_schema_drop_keys_if_exist("TopicInterest", ["contactTopic", "PRIMARY"]) && Dbl::ql("alter table TopicInterest add primary key (`contactId`,`topicId`)")) {
        $Conf->update_schema_version(118);
    }
    if ($Conf->sversion == 118 && update_schema_drop_keys_if_exist("PaperTag", ["paperTag", "PRIMARY"]) && Dbl::ql("alter table PaperTag add primary key (`paperId`,`tag`)") && update_schema_drop_keys_if_exist("PaperReviewPreference", ["paperId", "PRIMARY"]) && Dbl::ql("alter table PaperReviewPreference add primary key (`paperId`,`contactId`)") && update_schema_drop_keys_if_exist("PaperConflict", ["contactPaper", "contactPaperConflict", "PRIMARY"]) && Dbl::ql("alter table PaperConflict add primary key (`contactId`,`paperId`)") && Dbl::ql("alter table MailLog modify `paperIds` blob") && Dbl::ql("alter table MailLog modify `cc` blob") && Dbl::ql("alter table MailLog modify `replyto` blob") && Dbl::ql("alter table MailLog modify `subject` blob") && Dbl::ql("alter table MailLog modify `emailBody` blob")) {
        $Conf->update_schema_version(119);
    }
    if ($Conf->sversion == 119 && update_schema_drop_keys_if_exist("PaperWatch", ["contactPaper", "contactPaperWatch", "PRIMARY"]) && Dbl::ql("alter table PaperWatch add primary key (`paperId`,`contactId`)")) {
        $Conf->update_schema_version(120);
    }
    if ($Conf->sversion == 120 && Dbl::ql("alter table Paper add `paperFormat` tinyint(1) DEFAULT NULL")) {
        $Conf->update_schema_version(121);
    }
    if ($Conf->sversion == 121 && Dbl::ql_raw("update PaperReview r, Paper p set r.reviewNeedsSubmit=1 where p.paperId=r.paperId and p.timeSubmitted<=0 and r.reviewSubmitted is null") && Dbl::ql_raw("update PaperReview r, Paper p, PaperReview rq set r.reviewNeedsSubmit=0 where p.paperId=r.paperId and p.paperId=rq.paperId and p.timeSubmitted<=0 and r.reviewType=" . REVIEW_SECONDARY . " and r.contactId=rq.requestedBy and rq.reviewType<" . REVIEW_SECONDARY . " and rq.reviewSubmitted is not null") && Dbl::ql_raw("update PaperReview r, Paper p, PaperReview rq set r.reviewNeedsSubmit=-1 where p.paperId=r.paperId and p.paperId=rq.paperId and p.timeSubmitted<=0 and r.reviewType=" . REVIEW_SECONDARY . " and r.contactId=rq.requestedBy and rq.reviewType<" . REVIEW_SECONDARY . " and r.reviewNeedsSubmit=0")) {
        $Conf->update_schema_version(122);
    }
    if ($Conf->sversion == 122 && Dbl::ql("alter table ReviewRequest add `reviewRound` int(1) DEFAULT NULL")) {
        $Conf->update_schema_version(123);
    }
    if ($Conf->sversion == 123 && Dbl::ql("update ContactInfo set disabled=1 where password='' and email regexp '^anonymous[0-9]*\$'")) {
        $Conf->update_schema_version(124);
    }
    if ($Conf->sversion == 124 && Dbl::ql("update ContactInfo set password='' where password='******' or passwordIsCdb")) {
        $Conf->update_schema_version(125);
    }
    if ($Conf->sversion == 125 && Dbl::ql("alter table ContactInfo drop column `passwordIsCdb`")) {
        $Conf->update_schema_version(126);
    }
    if ($Conf->sversion == 126 && Dbl::ql("update ContactInfo set disabled=1, password='' where email regexp '^anonymous[0-9]*\$'")) {
        $Conf->update_schema_version(127);
    }
    if ($Conf->sversion == 127 && Dbl::ql("update PaperReview set reviewWordCount=null")) {
        $Conf->update_schema_version(128);
    }
    if ($Conf->sversion == 128 && update_schema_bad_comment_timeDisplayed($Conf)) {
        $Conf->update_schema_version(129);
    }
    if ($Conf->sversion == 129 && Dbl::ql("update PaperComment set timeDisplayed=1 where timeDisplayed=0 and timeNotified>0")) {
        $Conf->update_schema_version(130);
    }
    if ($Conf->sversion == 130 && Dbl::ql("DROP TABLE IF EXISTS `PaperTagAnno`") && Dbl::ql("CREATE TABLE `PaperTagAnno` (\n  `tag` varchar(40) NOT NULL,   # see TAG_MAXLEN in header.php\n  `annoId` int(11) NOT NULL,\n  `tagIndex` float NOT NULL DEFAULT '0',\n  `heading` varbinary(8192) DEFAULT NULL,\n  `annoFormat` tinyint(1) DEFAULT NULL,\n  `infoJson` varbinary(32768) DEFAULT NULL,\n  PRIMARY KEY (`tag`,`annoId`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8")) {
        $Conf->update_schema_version(131);
    }
    if ($Conf->sversion == 131 && Dbl::ql("alter table PaperStorage modify `infoJson` varbinary(32768) DEFAULT NULL")) {
        $Conf->update_schema_version(132);
    }
    Dbl::ql("delete from Settings where name='__schema_lock'");
}
Exemple #12
0
function paperOptions($id = null)
{
    global $Conf;
    if ($Conf->setting("paperOption") <= 0 || $Conf->sversion <= 0) {
        return array();
    }
    $svar = defval($_SESSION, "paperOption", null);
    if (!$svar || !is_array($svar) || count($svar) < 3 || $svar[2] < 2 || $svar[0] < $Conf->setting("paperOption")) {
        $opt = array();
        $result = $Conf->q("select * from OptionType order by sortOrder, optionName");
        $order = 0;
        while ($row = edb_orow($result)) {
            // begin backwards compatibility to old schema versions
            if (!isset($row->optionValues)) {
                $row->optionValues = "";
            }
            if (!isset($row->type) && $row->optionValues == "i") {
                $row->type = PaperOption::T_NUMERIC;
            } else {
                if (!isset($row->type)) {
                    $row->type = $row->optionValues ? PaperOption::T_SELECTOR : PaperOption::T_CHECKBOX;
                }
            }
            // end backwards compatibility to old schema versions
            $row->optionAbbrev = preg_replace("/-+\$/", "", preg_replace("/[^a-z0-9_]+/", "-", strtolower($row->optionName)));
            if ($row->optionAbbrev == "paper" || $row->optionAbbrev == "submission" || $row->optionAbbrev == "final" || ctype_digit($row->optionAbbrev)) {
                $row->optionAbbrev = "opt" . $row->optionId;
            }
            $row->sortOrder = $order++;
            if (!isset($row->displayType)) {
                $row->displayType = PaperOption::DT_NORMAL;
            }
            if ($row->type == PaperOption::T_FINALPDF) {
                $row->displayType = PaperOption::DT_SUBMISSION;
            }
            $row->isDocument = PaperOption::type_is_document($row->type);
            $row->isFinal = PaperOption::type_is_final($row->type);
            $opt[$row->optionId] = $row;
        }
        $_SESSION["paperOption"] = $svar = array($Conf->setting("paperOption"), $opt, 2);
    }
    return $id ? defval($svar[1], $id, null) : $svar[1];
}
 function reviewRow($selector, &$whyNot = null)
 {
     $whyNot = array();
     if (!is_array($selector)) {
         $selector = array('reviewId' => $selector);
     }
     if (isset($selector['reviewId'])) {
         $whyNot['reviewId'] = $selector['reviewId'];
         if (($reviewId = cvtint($selector['reviewId'])) <= 0) {
             $whyNot['invalidId'] = 'review';
             return null;
         }
     }
     if (isset($selector['paperId'])) {
         $whyNot['paperId'] = $selector['paperId'];
         if (($paperId = cvtint($selector['paperId'])) <= 0) {
             $whyNot['invalidId'] = 'paper';
             return null;
         }
     }
     $q = "select PaperReview.*,\n                ContactInfo.firstName, ContactInfo.lastName, ContactInfo.email, ContactInfo.roles as contactRoles,\n                ContactInfo.contactTags,\n                ReqCI.firstName as reqFirstName, ReqCI.lastName as reqLastName, ReqCI.email as reqEmail";
     if (isset($selector["ratings"])) {
         $q .= ",\n                group_concat(ReviewRating.rating) as allRatings";
     }
     if (isset($selector["myRating"])) {
         $q .= ",\n                MyRating.rating as myRating";
     }
     $q .= "\n               from PaperReview\n                join ContactInfo using (contactId)\n                left join ContactInfo as ReqCI on (ReqCI.contactId=PaperReview.requestedBy)\n";
     if (isset($selector["ratings"])) {
         $q .= "             left join ReviewRating on (ReviewRating.reviewId=PaperReview.reviewId)\n";
     }
     if (isset($selector["myRating"])) {
         $q .= "             left join ReviewRating as MyRating on (MyRating.reviewId=PaperReview.reviewId and MyRating.contactId=" . $selector["myRating"] . ")\n";
     }
     $where = array();
     $order = array("paperId");
     if (isset($reviewId)) {
         $where[] = "PaperReview.reviewId={$reviewId}";
     }
     if (isset($paperId)) {
         $where[] = "PaperReview.paperId={$paperId}";
     }
     $cwhere = array();
     if (isset($selector["contactId"])) {
         $cwhere[] = "PaperReview.contactId=" . cvtint($selector["contactId"]);
     }
     if (get($selector, "rev_tokens")) {
         $cwhere[] = "PaperReview.reviewToken in (" . join(",", $selector["rev_tokens"]) . ")";
     }
     if (count($cwhere)) {
         $where[] = "(" . join(" or ", $cwhere) . ")";
     }
     if (count($cwhere) > 1) {
         $order[] = "(PaperReview.contactId=" . cvtint($selector["contactId"]) . ") desc";
     }
     if (isset($selector['reviewOrdinal'])) {
         $where[] = "PaperReview.reviewSubmitted>0 and reviewOrdinal=" . cvtint($selector['reviewOrdinal']);
     } else {
         if (isset($selector['submitted'])) {
             $where[] = "PaperReview.reviewSubmitted>0";
         }
     }
     if (!count($where)) {
         $whyNot['internal'] = 1;
         return null;
     }
     $q = $q . " where " . join(" and ", $where) . " group by PaperReview.reviewId\n                order by " . join(", ", $order) . ", reviewOrdinal, timeRequested, reviewType desc, reviewId";
     $result = $this->q($q);
     if (!$result) {
         $whyNot['dbError'] = "Database error while fetching review (" . htmlspecialchars($q) . "): " . htmlspecialchars($this->dblink->error);
         return null;
     }
     $x = array();
     while ($row = edb_orow($result)) {
         $x[] = $row;
     }
     Dbl::free($result);
     if (isset($selector["array"])) {
         return $x;
     } else {
         if (count($x) == 1 || count($x) > 1 && get($selector, "first")) {
             return $x[0];
         }
     }
     if (count($x) == 0) {
         $whyNot['noReview'] = 1;
     } else {
         $whyNot['multipleReviews'] = 1;
     }
     return null;
 }
 public static function contact_map($ssel)
 {
     $result = Dbl::qe_raw("select ContactInfo.contactId, firstName, lastName, affiliation, email from ContactInfo join PaperConflict on (PaperConflict.contactId=ContactInfo.contactId) where conflictType>=" . CONFLICT_AUTHOR . " and paperId" . $ssel->sql_predicate() . " group by ContactInfo.contactId");
     $contact_map = [];
     while ($row = edb_orow($result)) {
         $row->contactId = (int) $row->contactId;
         $contact_map[$row->contactId] = $row;
     }
     return $contact_map;
 }
Exemple #15
0
 static function add_regrades($info)
 {
     list($user, $repo) = array($info->user, $info->repo);
     if (!isset($info->regrades) && !$info->pset->gitless_grades) {
         $info->regrades = array();
         $result = Dbl::qe("select * from RepositoryGradeRequest where repoid=? and pset=? order by requested_at desc", $repo->repoid, $info->pset->psetid);
         while ($row = edb_orow($result)) {
             if ($rc = @$info->recent_commits($row->hash)) {
                 $row->subject = $rc->subject;
                 $row->commitat = $rc->commitat;
             }
             $info->regrades[$row->hash] = $row;
         }
     }
     return isset($info->regrades) && count($info->regrades);
 }
Exemple #16
0
function clean_queue($qname, $qconf, $qid)
{
    global $Conf, $Now;
    $runtimeout = isset($qconf->runtimeout) ? $qconf->runtimeout : 300;
    $result = $Conf->qe("select * from ExecutionQueue where queueclass='" . sqlq($qname) . "' and queueid<{$qid}");
    while ($row = edb_orow($result)) {
        // remove dead items from queue
        // - lockfile contains "0\n": child has exited, remove it
        // - lockfile specified but not there
        // - no lockfile & last update < 30sec ago
        // - running for more than 5min (configurable)
        if ($row->lockfile && @file_get_contents($row->lockfile) === "0\n") {
            unlink($row->lockfile);
            $row->inputfifo && unlink($row->inputfifo);
        }
        if ($row->lockfile && !file_exists($row->lockfile) || $row->runat <= 0 && $row->updateat < $Now - 30 || $runtimeout && $row->runat > 0 && $row->runat < $Now - $runtimeout) {
            $Conf->qe("delete from ExecutionQueue where queueid={$row->queueid}");
        }
    }
}
Exemple #17
0
function show_regrades($result)
{
    global $Conf, $Me, $Now, $LastPsetFix;
    $rows = $uids = [];
    while ($row = edb_orow($result)) {
        $row->notes = json_decode($row->notes);
        $latest = "";
        $uid = 0;
        foreach (get($row->notes, "flags", []) as $t => $v) {
            if (!get($v, "resolved") && $t > $latest) {
                $latest = $t;
                $uid = get($v, "uid");
            }
        }
        if ($latest) {
            $rows[] = [$latest, $uid, $row];
            $uids[$uid] = true;
        }
    }
    Dbl::free($result);
    if (empty($rows)) {
        return;
    }
    usort($rows, function ($a, $b) {
        return strcmp($a[0], $b[0]);
    });
    $contacts = [];
    $result = $Conf->qe("select * from ContactInfo where contactId?a", array_keys($uids));
    while ($c = Contact::fetch($result, $Conf)) {
        $contacts[$c->contactId] = $c;
    }
    Dbl::free($result);
    echo '<div id="_regrades">';
    echo "<h3>flagged commits</h3>";
    echo '<table class="s61"><tbody>';
    $trn = 0;
    $checkbox = false;
    $sprefix = "";
    $reqsort = req("sort");
    $reqanonymize = req("anonymize");
    $pcmembers = pcMembers();
    foreach ($rows as $rowx) {
        $uid = $rowx[1];
        $row = $rowx[2];
        $u = $contacts[$uid];
        ++$trn;
        echo '<tr class="k', $trn % 2, '">';
        if ($checkbox) {
            echo '<td class="s61checkbox">', Ht::checkbox("s61_" . urlencode($Me->user_idpart($u)), 1, array("class" => "s61check")), '</td>';
        }
        echo '<td class="s61rownumber">', $trn, '.</td>';
        $pset = $Conf->pset_by_id($row->pset);
        echo '<td class="s61pset">', htmlspecialchars($pset->title), '</td>';
        echo '<td class="s61username">', '<a href="', hoturl("pset", ["pset" => $pset->urlkey, "u" => $Me->user_linkpart($u), "commit" => $row->hash, "sort" => $reqsort]), '">', htmlspecialchars($Me->user_linkpart($u)), '</a></td>', '<td class="s61hash"><a href="', hoturl("pset", array("pset" => $pset->urlkey, "u" => $Me->user_linkpart($u), "commit" => $row->hash, "sort" => $reqsort)), '">', substr($row->hash, 0, 7), '</a></td>';
        if (get($row->notes, "gradercid") || $row->main_gradercid) {
            $gcid = get($row->notes, "gradercid") ?: $row->main_gradercid;
            if (isset($pcmembers[$gcid])) {
                echo "<td>" . htmlspecialchars($pcmembers[$gcid]->firstName) . "</td>";
            } else {
                echo "<td>???</td>";
            }
        } else {
            echo "<td></td>";
        }
        echo "<td>";
        if ($row->hash === $row->gradehash) {
            echo "✱";
        }
        if ($row->haslinenotes) {
            echo "♪";
        }
        echo "</td>";
        $total = "";
        if ($row->notes) {
            $garr = render_grades($pset, $row->notes, null);
            if ($garr->totalindex !== null) {
                $total = $garr->all[$garr->totalindex];
            }
        }
        echo '<td class="r">' . $total . '</td>';
        echo '</tr>';
    }
    echo "</tbody></table></div>\n";
}
Exemple #18
0
 private function run()
 {
     global $Conf, $Opt, $Me, $Error, $subjectPrefix, $mailer_options;
     $subject = trim(defval($_REQUEST, "subject", ""));
     if (substr($subject, 0, strlen($subjectPrefix)) != $subjectPrefix) {
         $subject = $subjectPrefix . $subject;
     }
     $emailBody = $_REQUEST["emailBody"];
     $template = array("subject" => $subject, "body" => $emailBody);
     $rest = array("cc" => $_REQUEST["cc"], "reply-to" => $_REQUEST["replyto"], "pset" => $this->recip->pset, "no_error_quit" => true);
     $rest = array_merge($rest, $mailer_options);
     $mailer = new CS61Mailer($Me, null, $rest);
     $prep = $mailer->make_preparation($template, $rest);
     $paper_sensitive = preg_match('/%[A-Z0-9]+[(%]/', $prep->subject . $prep->body);
     $q = $this->recip->query($paper_sensitive);
     if (!$q) {
         return $Conf->errorMsg("Bad recipients value");
     }
     $result = $Conf->qe_raw($q);
     if (!$result) {
         return;
     }
     $recipients = defval($_REQUEST, "recipients", "");
     if ($this->sending) {
         $q = "recipients='" . sqlq($recipients) . "', cc='" . sqlq($_REQUEST["cc"]) . "', replyto='" . sqlq($_REQUEST["replyto"]) . "', subject='" . sqlq($_REQUEST["subject"]) . "', emailBody='" . sqlq($_REQUEST["emailBody"]) . "'";
         if ($Conf->sversion >= 79) {
             $q .= ", q='" . sqlq($_REQUEST["q"]) . "', t='" . sqlq($_REQUEST["t"]) . "'";
         }
         if ($log_result = Dbl::query_raw("insert into MailLog set {$q}")) {
             $this->mailid_text = " #" . $log_result->insert_id;
         }
         $Me->log_activity("Sending mail{$this->mailid_text} \"{$subject}\"");
     } else {
         $rest["no_send"] = true;
     }
     $mailer = new CS61Mailer();
     $fake_prep = (object) array("subject" => "", "body" => "", "to" => array(), "contactId" => array(), "fake" => 1);
     $last_prep = $fake_prep;
     $nrows_done = 0;
     $nrows_left = edb_nrows($result);
     $nwarnings = 0;
     $preperrors = array();
     while ($row = edb_orow($result)) {
         ++$nrows_done;
         $contact = new Contact($row);
         $mailer->reset($contact, $row, $rest);
         $prep = $mailer->make_preparation($template, $rest);
         if (@$prep->errors) {
             foreach ($prep->errors as $lcfield => $hline) {
                 $reqfield = $lcfield == "reply-to" ? "replyto" : $lcfield;
                 $Error[$reqfield] = true;
                 $emsg = Mailer::$email_fields[$lcfield] . " destination isn’t a valid email list: <blockquote><tt>" . htmlspecialchars($hline) . "</tt></blockquote> Make sure email address are separated by commas; put names in \"quotes\" and email addresses in &lt;angle brackets&gt;.";
                 if (!isset($preperrors[$emsg])) {
                     $Conf->errorMsg($emsg);
                 }
                 $preperrors[$emsg] = true;
             }
         } else {
             if ($this->process_prep($prep, $last_prep, $row)) {
                 if ((!$Me->privChair || @$Opt["chairHidePasswords"]) && !@$last_prep->sensitive) {
                     $srest = array_merge($rest, array("sensitivity" => "display"));
                     $mailer->reset($contact, $row, $srest);
                     $last_prep->sensitive = $mailer->make_preparation($template, $srest);
                 }
             }
         }
         if ($nwarnings != $mailer->nwarnings() || $nrows_done % 5 == 0) {
             $this->echo_mailinfo($nrows_done, $nrows_left);
         }
         if ($nwarnings != $mailer->nwarnings()) {
             $this->echo_prologue();
             $nwarnings = $mailer->nwarnings();
             echo "<div id='foldmailwarn{$nwarnings}' class='hidden'><div class='warning'>", join("<br />", $mailer->warnings()), "</div></div>";
             echo Ht::unstash_script("\$\$('mailwarnings').innerHTML = \$\$('foldmailwarn{$nwarnings}').innerHTML;");
         }
     }
     $this->process_prep($fake_prep, $last_prep, (object) array());
     $this->echo_mailinfo($nrows_done, $nrows_left);
     if (!$this->started && !count($preperrors)) {
         return $Conf->errorMsg("No users match “" . $this->recip->unparse() . "” for that search.");
     } else {
         if (!$this->started) {
             return false;
         } else {
             if (!$this->sending) {
                 $this->echo_actions();
             }
         }
     }
     echo "</div></form>";
     echo Ht::unstash_script("fold('mail', null);");
     $Conf->footer();
     exit;
 }
 private function preferences_paperpc($scoreinfo)
 {
     global $Conf;
     $time = microtime(true);
     $this->prefs = array();
     foreach ($this->pcm as $cid => $p) {
         $this->prefs[$cid] = array();
     }
     $all_fields = ReviewForm::all_fields();
     $scoredir = 1;
     if ($scoreinfo === "x") {
         $score = "1";
     } else {
         if ((substr($scoreinfo, 0, 1) === "-" || substr($scoreinfo, 0, 1) === "+") && isset($all_fields[substr($scoreinfo, 1)])) {
             $score = "PaperReview." . substr($scoreinfo, 1);
             $scoredir = substr($scoreinfo, 0, 1) === "-" ? -1 : 1;
         } else {
             $score = "PaperReview.overAllMerit";
         }
     }
     $query = "select Paper.paperId, ? contactId,\n            coalesce(PaperConflict.conflictType, 0) as conflictType,\n            coalesce(PaperReview.reviewType, 0) as myReviewType,\n            coalesce(PaperReview.reviewSubmitted, 0) as myReviewSubmitted,\n            coalesce({$score}, 0) as reviewScore,\n            Paper.outcome,\n            Paper.managerContactId\n        from Paper\n        left join PaperConflict on (PaperConflict.paperId=Paper.paperId and PaperConflict.contactId=?)\n        left join PaperReview on (PaperReview.paperId=Paper.paperId and PaperReview.contactId=?)\n        where Paper.paperId ?a\n        group by Paper.paperId";
     $nmade = 0;
     foreach ($this->pcm as $cid => $p) {
         $result = Dbl::qe($query, $cid, $cid, $cid, $this->papersel);
         // First, collect score extremes
         $scoreextreme = array();
         $rows = array();
         while ($row = edb_orow($result)) {
             if ($row->conflictType > 0 || $row->myReviewType == 0 || $row->myReviewSubmitted == 0 || $row->reviewScore == 0) {
                 $this->prefs[$row->contactId][$row->paperId] = self::PNOASSIGN;
             } else {
                 if (!isset($scoreextreme[$row->paperId]) || $scoredir * $row->reviewScore > $scoredir * $scoreextreme[$row->paperId]) {
                     $scoreextreme[$row->paperId] = $row->reviewScore;
                 }
                 $rows[] = $row;
             }
         }
         // Then, collect preferences; ignore score differences farther
         // than 1 score away from the relevant extreme
         foreach ($rows as $row) {
             $scoredifference = $scoredir * ($row->reviewScore - $scoreextreme[$row->paperId]);
             if ($scoredifference >= -1) {
                 $this->prefs[$row->contactId][$row->paperId] = $scoredifference;
             }
         }
         unset($rows);
         // don't need the memory any more
         Dbl::free($result);
         ++$nmade;
         if ($nmade % 4 == 0) {
             $this->set_progress(sprintf("Loading reviewer preferences (%d%% done)", (int) ($nmade * 100 / count($this->pcm) + 0.5)));
         }
     }
     $this->make_pref_groups();
     $this->profile["preferences"] = microtime(true) - $time;
 }
Exemple #20
0
 function apply_capability_text($text)
 {
     if (preg_match(',\\A([-+]?)0([1-9][0-9]*)(a)(\\S+)\\z,', $text, $m) && ($result = $this->conf->ql("select paperId, capVersion from Paper where paperId={$m['2']}")) && ($row = edb_orow($result))) {
         $rowcap = $this->conf->capability_text($row, $m[3]);
         $text = substr($text, strlen($m[1]));
         if ($rowcap === $text || $rowcap === str_replace("/", "_", $text)) {
             return $this->change_capability((int) $m[2], self::CAP_AUTHORVIEW, $m[1] !== "-");
         }
     }
     return null;
 }
Exemple #21
0
function show_regrades($result)
{
    global $Conf, $Me, $Now, $LastPsetFix;
    $rows = array();
    echo '<div id="_regrades">';
    echo "<h3>regrade requests</h3>";
    echo '<table class="s61"><tbody>';
    $trn = 0;
    $checkbox = false;
    $sprefix = "";
    $pcmembers = pcMembers();
    while ($row = edb_orow($result)) {
        ++$trn;
        echo '<tr class="k', $trn % 2, '">';
        if ($checkbox) {
            echo '<td class="s61rownumber">', Ht::checkbox("s61_" . $Me->user_idpart($row->student), 1, array("class" => "s61check")), '</td>';
        }
        echo '<td class="s61rownumber">', $trn, '.</td>';
        $pset = Pset::$all[$row->pset];
        echo '<td class="s61pset">', htmlspecialchars($pset->title), '</td>';
        $row->usernames = explode(" ", $row->usernames);
        sort($row->usernames);
        $x = array();
        foreach ($row->usernames as $u) {
            $x[] = '<a href="' . hoturl("pset", array("pset" => $pset->urlkey, "u" => $u, "commit" => $row->hash, "sort" => @$_REQUEST["sort"])) . '">' . htmlspecialchars($u) . '</a>';
        }
        echo '<td class="s61username">', join(", ", $x), '</td>';
        echo '<td class="s61hash"><a href="', hoturl("pset", array("pset" => $pset->urlkey, "u" => $row->usernames[0], "commit" => $row->hash, "sort" => @$_REQUEST["sort"])), '">', substr($row->hash, 0, 7), '</a></td>';
        if (@$row->gradercid || @$row->main_gradercid) {
            $gcid = @$row->gradercid ?: $row->main_gradercid;
            if (isset($pcmembers[$gcid])) {
                echo "<td>" . htmlspecialchars($pcmembers[$gcid]->firstName) . "</td>";
            } else {
                echo "<td>???</td>";
            }
        } else {
            echo "<td></td>";
        }
        if ($row->haslinenotes) {
            echo "<td>♪</td>";
        } else {
            echo "<td></td>";
        }
        $total = "";
        if ($row->notes) {
            $garr = render_grades($pset, json_decode($row->notes), null);
            if ($garr->totalindex !== null) {
                $total = $garr->all[$garr->totalindex];
            }
        }
        echo '<td class="r">' . $total . '</td>';
        echo '</tr>';
    }
    echo "</tbody></table></div>\n";
}
 function assign_review($pid, $reviewer_cid, $type, $extra = array())
 {
     global $Conf, $Now;
     $result = Dbl::qe("select reviewId, reviewType, reviewRound, reviewModified, reviewToken, requestedBy, reviewSubmitted from PaperReview where paperId=? and contactId=?", $pid, $reviewer_cid);
     $rrow = edb_orow($result);
     Dbl::free($result);
     $reviewId = $rrow ? $rrow->reviewId : 0;
     // can't delete a review that's in progress
     if ($type <= 0 && $rrow && $rrow->reviewType && $rrow->reviewModified) {
         if ($rrow->reviewType >= REVIEW_SECONDARY) {
             $type = REVIEW_PC;
         } else {
             return $reviewId;
         }
     }
     // change database
     if ($type > 0 && ($round = get($extra, "round_number")) === null) {
         $round = $Conf->current_round();
     }
     if ($type > 0 && (!$rrow || !$rrow->reviewType)) {
         $qa = "";
         if (get($extra, "mark_notify")) {
             $qa .= ", timeRequestNotified={$Now}";
         }
         if (get($extra, "token")) {
             $qa .= self::unassigned_review_token();
         }
         $new_requester_cid = $this->contactId;
         if ($new_requester = get($extra, "requester_contact")) {
             $new_requester_cid = $new_requester->contactId;
         }
         $q = "insert into PaperReview set paperId={$pid}, contactId={$reviewer_cid}, reviewType={$type}, reviewRound={$round}, timeRequested={$Now}{$qa}, requestedBy={$new_requester_cid}";
     } else {
         if ($type > 0 && ($rrow->reviewType != $type || $rrow->reviewRound != $round)) {
             $q = "update PaperReview set reviewType={$type}, reviewRound={$round}";
             if (!$rrow->reviewSubmitted) {
                 $q .= ", reviewNeedsSubmit=1";
             }
             $q .= " where reviewId={$reviewId}";
         } else {
             if ($type <= 0 && $rrow && $rrow->reviewType) {
                 $q = "delete from PaperReview where reviewId={$reviewId}";
             } else {
                 return $reviewId;
             }
         }
     }
     if (!($result = Dbl::qe_raw($q))) {
         return false;
     }
     if ($q[0] == "d") {
         $msg = "Removed " . ReviewForm::$revtype_names[$rrow->reviewType] . " review";
         $reviewId = 0;
     } else {
         if ($q[0] == "u") {
             $msg = "Changed " . ReviewForm::$revtype_names[$rrow->reviewType] . " review to " . ReviewForm::$revtype_names[$type];
         } else {
             $msg = "Added " . ReviewForm::$revtype_names[$type] . " review";
             $reviewId = $result->insert_id;
         }
     }
     $Conf->log($msg . " by " . $this->email, $reviewer_cid, $pid);
     // on new review, update PaperReviewRefused, ReviewRequest, delegation
     if ($q[0] == "i") {
         Dbl::ql("delete from PaperReviewRefused where paperId={$pid} and contactId={$reviewer_cid}");
         if ($req_email = get($extra, "requested_email")) {
             Dbl::qe("delete from ReviewRequest where paperId={$pid} and email=?", $req_email);
         }
         if ($type < REVIEW_SECONDARY) {
             self::update_review_delegation($pid, $new_requester_cid, 1);
         }
     } else {
         if ($q[0] == "d") {
             if ($rrow->reviewType < REVIEW_SECONDARY && $rrow->requestedBy > 0) {
                 self::update_review_delegation($pid, $rrow->requestedBy, -1);
             }
         } else {
             if ($type == REVIEW_SECONDARY && $rrow->reviewType != REVIEW_SECONDARY && !$rrow->reviewSubmitted) {
                 self::update_review_delegation($pid, $reviewer_cid, 0);
             }
         }
     }
     // Mark rev_tokens setting for future update by update_rev_tokens_setting
     if ($rrow && get($rrow, "reviewToken") && $type <= 0) {
         $Conf->settings["rev_tokens"] = -1;
     }
     // Set pcrev_assigntime
     if ($q[0] == "i" && $type >= REVIEW_PC && $Conf->setting("pcrev_assigntime", 0) < $Now) {
         $Conf->save_setting("pcrev_assigntime", $Now);
     }
     Contact::update_rights();
     return $reviewId;
 }
// Review assignment
if ($Me->is_reviewer() && ($Me->privChair || $papersub)) {
    echo $nhome_hr ? $home_hr : "", "<div class='homegrp' id='homerev'>\n";
    $all_review_fields = ReviewForm::all_fields();
    $merit_field = get($all_review_fields, "overAllMerit");
    $merit_noptions = $merit_field ? count($merit_field->options) : 0;
    // Information about my reviews
    $where = array();
    if ($Me->contactId) {
        $where[] = "PaperReview.contactId=" . $Me->contactId;
    }
    if ($tokens = $Me->review_tokens()) {
        $where[] = "reviewToken in (" . join(",", $tokens) . ")";
    }
    $result = Dbl::qe_raw("select count(reviewSubmitted) num_submitted,\n\tcount(if(reviewNeedsSubmit=0,reviewSubmitted,1)) num_needs_submit,\n\tgroup_concat(if(reviewSubmitted is not null,overAllMerit,null)) scores,\n\tgroup_concat(distinct if(reviewNeedsSubmit!=0 and reviewSubmitted is null,reviewRound,null)) unsubmitted_rounds\n\tfrom PaperReview\n\tjoin Paper using (paperId)\n\twhere (" . join(" or ", $where) . ")\n    and (reviewSubmitted is not null or timeSubmitted>0)\n    group by PaperReview.reviewId>0");
    if ($myrow = edb_orow($result)) {
        $myrow->scores = scoreCounts($myrow->scores, $merit_noptions);
    }
    // Information about PC reviews
    $npc = $sumpcSubmit = $npcScore = $sumpcScore = 0;
    if ($Me->isPC || $Me->privChair) {
        $result = Dbl::qe_raw("select count(reviewId) num_submitted,\n\tgroup_concat(overAllMerit) scores\n\tfrom ContactInfo\n\tleft join PaperReview on (PaperReview.contactId=ContactInfo.contactId and PaperReview.reviewSubmitted is not null)\n        where (roles&" . Contact::ROLE_PC . ")!=0\n\tgroup by ContactInfo.contactId");
        while ($row = edb_row($result)) {
            ++$npc;
            if ($row[0]) {
                $sumpcSubmit += $row[0];
                $scores = scoreCounts($row[1], $merit_noptions);
                ++$npcScore;
                $sumpcScore += $scores->avg;
            }
        }
function requestReviewChecks($themHtml, $reqId)
{
    global $Me, $prow;
    // check for outstanding review request
    $result = Dbl::qe_raw("select reviewId, firstName, lastName, email, password from PaperReview join ContactInfo on (ContactInfo.contactId=PaperReview.requestedBy) where paperId={$prow->paperId} and PaperReview.contactId={$reqId}");
    if (!$result) {
        return false;
    } else {
        if ($row = edb_orow($result)) {
            return Conf::msg_error(Text::user_html($row) . " has already requested a review from {$themHtml}.");
        }
    }
    // check for outstanding refusal to review
    $result = Dbl::qe_raw("select paperId, '<conflict>' from PaperConflict where paperId={$prow->paperId} and contactId={$reqId} union select paperId, reason from PaperReviewRefused where paperId={$prow->paperId} and contactId={$reqId}");
    if (edb_nrows($result) > 0) {
        $row = edb_row($result);
        if ($row[1] === "<conflict>") {
            return Conf::msg_error("{$themHtml} has a conflict registered with paper #{$prow->paperId} and cannot be asked to review it.");
        } else {
            if ($Me->override_deadlines($prow)) {
                Conf::msg_info("Overriding previous refusal to review paper #{$prow->paperId}." . ($row[1] ? "  (Their reason was “" . htmlspecialchars($row[1]) . "”.)" : ""));
                Dbl::qe_raw("delete from PaperReviewRefused where paperId={$prow->paperId} and contactId={$reqId}");
            } else {
                return Conf::msg_error("{$themHtml} refused a previous request to review paper #{$prow->paperId}." . ($row[1] ? " (Their reason was “" . htmlspecialchars($row[1]) . "”.)" : "") . ($Me->allow_administer($prow) ? " As an administrator, you can override this refusal with the “Override...” checkbox." : ""));
            }
        }
    }
    return true;
}
    $query .= " where " . join(" and ", $wheres);
}
$query .= " order by logId desc";
if (!$firstDate && $page !== false) {
    $maxNrows = $nlinks * $count + 1;
    $query .= " limit {$start},{$maxNrows}";
}
//$Conf->infoMsg(nl2br(htmlspecialchars($query)));
$result = $Conf->qe($query);
$nrows = edb_nrows($result);
if ($firstDate || $page === false) {
    $maxNrows = $nrows;
}
$n = 0;
$trs = array();
while (($row = edb_orow($result)) && ($n < $count || $page === false)) {
    if ($firstDate && $row->timestamp > $firstDate) {
        $start++;
        $nrows--;
        continue;
    } else {
        if ($page === false && ($n % $count != 0 || $n + $count < $nrows)) {
            $n++;
            continue;
        } else {
            if ($page === false) {
                $start = $n;
                $page = $n / $count + 1;
                $nrows -= $n;
                $maxNrows -= $n - 1;
                $n = 0;
 private function _rows($field_list)
 {
     global $Conf;
     if (!$field_list) {
         return null;
     }
     // prepare query text
     $this->qopts["scores"] = array_keys($this->qopts["scores"]);
     if (empty($this->qopts["scores"])) {
         unset($this->qopts["scores"]);
     }
     $pq = $Conf->paperQuery($this->contact, $this->qopts);
     // make query
     $result = Dbl::qe_raw($pq);
     if (!$result) {
         return null;
     }
     // fetch rows
     $rows = array();
     while ($row = PaperInfo::fetch($result, $this->contact)) {
         $rows[$row->paperId] = $row;
     }
     // prepare review query (see also search > getfn == "reviewers")
     $this->review_list = array();
     if (isset($this->qopts["reviewList"]) && !empty($rows)) {
         $result = Dbl::qe("select Paper.paperId, reviewId, reviewType,\n                reviewSubmitted, reviewModified, reviewNeedsSubmit, reviewRound,\n                reviewOrdinal,\n                PaperReview.contactId, lastName, firstName, email\n                from Paper\n                join PaperReview using (paperId)\n                join ContactInfo on (PaperReview.contactId=ContactInfo.contactId)\n                where paperId?a", array_keys($rows));
         while ($row = edb_orow($result)) {
             Contact::set_sorter($row);
             $this->review_list[$row->paperId][] = $row;
         }
         foreach ($this->review_list as &$revlist) {
             usort($revlist, "PaperList::review_list_compar");
         }
         unset($revlist);
     }
     // prepare PC topic interests
     if (isset($this->qopts["allReviewerPreference"])) {
         $ord = 0;
         $pcm = pcMembers();
         foreach ($pcm as $pc) {
             $pc->prefOrdinal = sprintf("-0.%04d", $ord++);
             $pc->topicInterest = array();
         }
         $result = Dbl::qe("select contactId, topicId, " . $Conf->query_topic_interest() . " from TopicInterest");
         while ($row = edb_row($result)) {
             $pcm[$row[0]]->topicInterest[$row[1]] = $row[2];
         }
     }
     // analyze rows (usually noop)
     foreach ($field_list as $fdef) {
         $fdef->analyze($this, $rows);
     }
     // sort rows
     if (!empty($this->sorters)) {
         $rows = $this->_sort($rows);
         if (isset($this->qopts["allReviewScores"])) {
             $this->_sortReviewOrdinal($rows);
         }
     }
     // set `any->optID`
     if ($nopts = PaperOption::count_option_list()) {
         foreach ($rows as $prow) {
             foreach ($prow->options() as $o) {
                 if (!$this->any["opt{$o->id}"] && $this->contact->can_view_paper_option($prow, $o->option)) {
                     $this->any["opt{$o->id}"] = true;
                     --$nopts;
                 }
             }
             if (!$nopts) {
                 break;
             }
         }
     }
     Dbl::free($result);
     return $rows;
 }
Exemple #27
0
 public function check_capability($capabilityText)
 {
     if ($capabilityText[0] != "1") {
         return false;
     }
     $value = base64_decode(str_replace(array("-", "_"), array("+", "/"), substr($capabilityText, 1)));
     if (strlen($value) >= 16 && ($result = $this->q("select * from CapabilityMap where capabilityValue='" . sqlq($value) . "'")) && ($row = edb_orow($result)) && ($row->timeExpires == 0 || $row->timeExpires >= time())) {
         $result = $this->q("select * from Capability where capabilityId=" . $row->capabilityId);
         if ($row = edb_orow($result)) {
             $row->capabilityValue = $value;
             return $row;
         }
     }
     return false;
 }