Beispiel #1
0
 static function form($action, $extra = null)
 {
     $method = @$extra["method"] ?: "post";
     if ($method === "get" && strpos($action, "?") !== false) {
         error_log(caller_landmark() . ": GET form action {$action} params will be ignored");
     }
     $enctype = @$extra["enctype"];
     if (!$enctype && $method !== "get") {
         $enctype = "multipart/form-data";
     }
     $x = '<form method="' . $method . '" action="' . $action . '"';
     if ($enctype) {
         $x .= ' enctype="' . $enctype . '"';
     }
     return $x . ' accept-charset="UTF-8"' . self::extra($extra) . '>';
 }
 function __construct($search, $args = array(), $qreq = null)
 {
     global $Conf;
     $this->search = $search;
     $this->contact = $this->search->contact;
     $this->qreq = $qreq ?: new Qobject();
     $this->sortable = isset($args["sort"]) && $args["sort"];
     if ($this->sortable && is_string($args["sort"])) {
         $this->sorters[] = ListSorter::parse_sorter($args["sort"]);
     } else {
         if ($this->sortable && $this->qreq->sort) {
             $this->sorters[] = ListSorter::parse_sorter($this->qreq->sort);
         } else {
             $this->sorters[] = ListSorter::parse_sorter("");
         }
     }
     $this->foldable = $this->sortable || !!get($args, "foldable") || $this->contact->privChair;
     $this->_paper_link_page = "";
     if (isset($qreq->linkto) && ($qreq->linkto == "paper" || $qreq->linkto == "review" || $qreq->linkto == "assign")) {
         $this->_paper_link_page = $qreq->linkto;
     }
     $this->listNumber = 0;
     if (get($args, "list")) {
         $this->listNumber = SessionList::allocate($search->listId($this->sortdef()));
     }
     if (is_string(get($args, "display"))) {
         $this->display = " " . $args["display"] . " ";
     } else {
         $svar = get($args, "foldtype", "pl") . "display";
         $this->display = $Conf->session($svar, "");
     }
     if (isset($args["reviewer"]) && ($r = $args["reviewer"])) {
         if (!is_object($r)) {
             error_log(caller_landmark() . ": warning: 'reviewer' not an object");
             $r = Contact::find_by_id($r);
         }
         $this->_reviewer = $r;
     }
     $this->atab = $this->qreq->atab;
     $this->_row_id_pattern = get($args, "row_id_pattern");
     $this->tagger = new Tagger($this->contact);
     $this->scoresOk = $this->contact->privChair || $this->contact->is_reviewer() || $Conf->timeAuthorViewReviews();
     $this->qopts = array("scores" => [], "options" => true);
     if ($this->search->complexSearch($this->qopts)) {
         $this->qopts["paperId"] = $this->search->paperList();
     }
     // NB that actually processed the search, setting PaperSearch::viewmap
     $this->viewmap = new Qobject($this->search->viewmap);
     if ($this->viewmap->compact || $this->viewmap->cc || $this->viewmap->compactcolumn || $this->viewmap->ccol || $this->viewmap->compactcolumns) {
         $this->viewmap->compactcolumns = $this->viewmap->columns = true;
     }
     if ($this->viewmap->column || $this->viewmap->col) {
         $this->viewmap->columns = true;
     }
     if ($this->viewmap->stat || $this->viewmap->stats || $this->viewmap->totals) {
         $this->viewmap->statistics = true;
     }
     if ($this->viewmap->authors && $this->viewmap->au === null) {
         $this->viewmap->au = true;
     }
     if ($Conf->submission_blindness() != Conf::BLIND_OPTIONAL && $this->viewmap->au && $this->viewmap->anonau === null) {
         $this->viewmap->anonau = true;
     }
     if ($this->viewmap->anonau && $this->viewmap->au === null) {
         $this->viewmap->au = true;
     }
     if ($this->viewmap->rownumbers) {
         $this->viewmap->rownum = true;
     }
 }
 function has_tag($t)
 {
     if ($this->roles & self::ROLE_PC && strcasecmp($t, "pc") == 0) {
         return true;
     }
     if ($this->contactTags) {
         return stripos($this->contactTags, " {$t}#") !== false;
     }
     if ($this->contactTags === false) {
         trigger_error(caller_landmark(1, "/^Conf::/") . ": Contact {$this->email} contactTags missing");
         $this->contactTags = null;
     }
     return false;
 }
Beispiel #4
0
 static function landmark()
 {
     return caller_landmark(1, self::$landmark_sanitizer);
 }
 public function save($name, $value)
 {
     global $Conf;
     $si = $this->si($name);
     if (!$si) {
         return;
     }
     if ($value !== null && !($si->storage_type & Si::SI_DATA ? is_string($value) : is_int($value))) {
         error_log(caller_landmark() . ": setting {$name}: invalid value " . var_export($value, true));
         return;
     }
     $s = $si->storage();
     if ($si->storage_type & Si::SI_SLICE) {
         if (!isset($this->savedv[$s])) {
             $this->savedv[$s] = [$Conf->setting($s, 0), $Conf->setting_data($s, null)];
         }
         $idx = $si->storage_type & Si::SI_DATA ? 1 : 0;
         $this->savedv[$s][$idx] = $value;
         if ($this->savedv[$s][0] === 0 && $this->savedv[$s][1] === null) {
             $this->savedv[$s] = null;
         }
     } else {
         if ($si->storage_type & Si::SI_DATA) {
             if ($value === null || $value === "" || $value === $si->default_value) {
                 $this->savedv[$s] = null;
             } else {
                 $this->savedv[$s] = [1, $value];
             }
         } else {
             if ($value === null || $value === $si->default_value) {
                 $this->savedv[$s] = null;
             } else {
                 $this->savedv[$s] = [$value, null];
             }
         }
     }
 }
Beispiel #6
0
 private static function do_query($args, $flags)
 {
     list($dblink, $qstr, $argv) = self::query_args($args, $flags, true);
     if (!($flags & self::F_RAW)) {
         $qstr = self::format_query_args($dblink, $qstr, $argv);
     }
     $result = $dblink->query($qstr);
     if ($result === true) {
         $result = $dblink;
     } else {
         if ($result === false && $flags & (self::F_LOG | self::F_ERROR)) {
             ++self::$logged_errors;
             if ($flags & self::F_ERROR) {
                 call_user_func(self::$error_handler, $dblink, $qstr);
             } else {
                 error_log(caller_landmark(1, "/^Dbl::/") . ": database error: " . $dblink->error . " in {$qstr}");
             }
         }
     }
     if (self::$check_warnings && !($flags & self::F_ALLOWERROR) && $dblink->warning_count) {
         $wresult = $dblink->query("show warnings");
         while ($wresult && ($wrow = $wresult->fetch_row())) {
             error_log(caller_landmark(1, "/^Dbl::/") . ": database warning: {$wrow['0']} ({$wrow['1']}) {$wrow['2']}");
         }
         $wresult && $wresult->close();
     }
     return $result;
 }
function assert_location()
{
    return caller_landmark(",^x?assert,");
}
 function query_error_handler($dblink, $query)
 {
     global $OK;
     $landmark = caller_landmark(1, "/^(?:Dbl::|Conf::q|call_user_func)/");
     if (PHP_SAPI == "cli") {
         fwrite(STDERR, "{$landmark}: database error: {$dblink->error} in {$query}\n");
     } else {
         error_log("{$landmark}: database error: {$dblink->error} in {$query}");
         self::msg_error("<p>" . htmlspecialchars($landmark) . ": database error: " . htmlspecialchars($this->dblink->error) . " in " . Ht::pre_text_wrap($query) . "</p>");
     }
     $OK = false;
 }
 public function __set($name, $value)
 {
     if ($name === "contactId") {
         error_log(caller_landmark() . ": PaperSearch->contactId deprecated, use cid");
         $this->cid = $value;
     } else {
         $this->{$name} = $value;
     }
 }
Beispiel #10
0
 function qe($query, $while = "", $suggestRetry = false)
 {
     global $OK;
     if ($while || $suggestRetry) {
         error_log(caller_landmark() . ": bad call to Conference::qe");
     }
     $result = $this->dblink->query($query);
     if ($result === false) {
         if (PHP_SAPI == "cli") {
             fwrite(STDERR, caller_landmark() . ": " . $this->db_error_text(true, "[{$query}]") . "\n");
         } else {
             $this->errorMsg($this->db_error_html(true, Ht::pre_text_wrap($query)));
         }
         $OK = false;
     }
     return $result;
 }