Esempio n. 1
0
 public static function active($listtype = null, $id = null)
 {
     global $Conf, $Me, $Now;
     // check current-list cache
     if (!$listtype && self::$active_list) {
         return self::$active_list;
     } else {
         if (!$listtype) {
             $listtype = "p";
             $id = $Conf->paper ? $Conf->paper->paperId : null;
         }
     }
     if (!$id) {
         return null;
     }
     $listid = "{$id}/{$listtype}";
     if (self::$active_listid === $listid) {
         return self::$active_list;
     }
     // start with requested list
     $list = self::requested();
     if ($list && !str_starts_with(get_s($list, "listid"), $listtype)) {
         $list = null;
     }
     // look up ID in list; try new lists if not found
     $k = false;
     if ($list) {
         $k = array_search($id, $list->ids);
     }
     if ($k === false) {
         $list = self::try_list([], $listtype);
         $k = array_search($id, $list->ids);
     }
     if ($k === false && $Me->privChair) {
         $list = self::try_list(["t" => "all"], $listtype);
         $k = array_search($id, $list->ids);
     }
     if ($k === false) {
         $list = null;
     }
     // save list changes
     if ($list && !get($list, "listno")) {
         $list->listno = self::allocate($list->listid);
     }
     if ($list) {
         $list->timestamp = $Now;
         self::change($list->listno, $list);
         $list->id_position = $k;
     }
     self::$active_listid = $listid;
     self::$active_list = $list;
     return $list;
 }
 public function table_html($listname, $options = array())
 {
     global $Conf;
     if (!$this->_prepare()) {
         return null;
     }
     if (isset($options["fold"])) {
         foreach ($options["fold"] as $n => $v) {
             $this->viewmap->{$n} = $v;
         }
     }
     if (isset($options["table_id"])) {
         $this->viewmap->table_id = $options["table_id"];
     }
     // need tags for row coloring
     if ($this->contact->can_view_tags(null)) {
         $this->qopts["tags"] = 1;
     }
     $this->table_type = $listname;
     // get column list, check sort
     $field_list = $this->_list_columns($listname);
     if (!$field_list) {
         Conf::msg_error("There is no paper list query named “" . htmlspecialchars($listname) . "”.");
         return null;
     }
     $field_list = $this->_columns($field_list, true);
     $body_attr = $this->row_attr;
     $rows = $this->_rows($field_list);
     if ($rows === null) {
         return null;
     }
     // return IDs if requested
     if (empty($rows)) {
         if ($altq = $this->search->alternate_query()) {
             $altqh = htmlspecialchars($altq);
             $url = $this->search->url_site_relative_raw($altq);
             if (substr($url, 0, 5) == "search") {
                 $altqh = "<a href=\"" . htmlspecialchars(Navigation::siteurl() . $url) . "\">" . $altqh . "</a>";
             }
             return "No matching papers. Did you mean “{$altqh}”?";
         } else {
             return "No matching papers";
         }
     }
     // get field array
     $fieldDef = array();
     $ncol = $titlecol = 0;
     // folds: au:1, anonau:2, fullrow:3, aufull:4, force:5, rownum:6, [fields]
     $next_fold = 7;
     foreach ($field_list as $fdef) {
         if ($fdef->view != Column::VIEW_NONE) {
             $fieldDef[] = $fdef;
         }
         if ($fdef->view != Column::VIEW_NONE && $fdef->foldable) {
             $fdef->foldable = $next_fold;
             ++$next_fold;
         }
         if ($fdef->name == "title") {
             $titlecol = $ncol;
         }
         if ($fdef->view == Column::VIEW_COLUMN && !$fdef->is_folded) {
             ++$ncol;
         }
     }
     // count non-callout columns
     $skipcallout = 0;
     foreach ($fieldDef as $fdef) {
         if ($fdef->name != "id" && !isset($fdef->is_selector)) {
             break;
         } else {
             ++$skipcallout;
         }
     }
     // create render state
     $rstate = new PaperListRenderState($ncol, $titlecol, $skipcallout);
     // collect row data
     $body = array();
     $lastheading = !empty($this->search->groupmap) ? -1 : -2;
     $need_render = false;
     foreach ($rows as $row) {
         ++$this->count;
         if ($lastheading > -2) {
             $lastheading = $this->_check_heading($this->_row_thenval($row), $rstate, $rows, $lastheading, $body);
         }
         $body[] = $this->_row_text($rstate, $row, $fieldDef);
         if ($this->need_render && !$need_render) {
             $Conf->footerScript('$(plinfo.render_needed)', 'plist_render_needed');
             $need_render = true;
         }
         if ($this->need_render && $this->count % 16 == 15) {
             $body[count($body) - 1] .= "  <script>plinfo.render_needed()</script>\n";
             $this->need_render = false;
         }
     }
     if ($lastheading > -2 && $this->search->is_order_anno) {
         while ($lastheading + 1 < count($this->search->groupmap)) {
             $lastheading = $this->_check_heading($lastheading + 1, $rstate, $rows, $lastheading, $body);
         }
     }
     // header cells
     $colhead = "";
     $url = $this->search->url_site_relative_raw();
     if (!defval($options, "noheader")) {
         $colhead .= " <thead class=\"pltable\">\n  <tr class=\"pl_headrow\">";
         $ord = 0;
         $titleextra = $this->_make_title_header_extra($rstate, $fieldDef, get($options, "header_links"));
         foreach ($fieldDef as $fdef) {
             if ($fdef->view != Column::VIEW_COLUMN || $fdef->is_folded) {
                 continue;
             }
             $colhead .= "<th class=\"pl " . $fdef->className;
             if ($fdef->foldable) {
                 $colhead .= " fx" . $fdef->foldable;
             }
             $colhead .= "\">";
             if ($fdef->has_content) {
                 $colhead .= $this->_field_title($fdef, $ord);
             }
             if ($titleextra && $fdef->className == "pl_title") {
                 $colhead .= $titleextra;
                 $titleextra = false;
             }
             $colhead .= "</th>";
             ++$ord;
         }
         $colhead .= "</tr>\n";
         if ($this->search->is_order_anno) {
             $colhead .= "  <tr class=\"pl_headrow pl_annorow\" data-anno-tag=\"{$this->search->is_order_anno}\">";
             if ($rstate->titlecol) {
                 $colhead .= "<td colspan=\"{$rstate->titlecol}\"></td>";
             }
             $colhead .= "<td colspan=\"" . ($rstate->ncol - $rstate->titlecol) . "\"><a href=\"#\" onclick=\"return plinfo_tags.edit_anno(this)\">Annotate order</a></td></tr>\n";
         }
         $colhead .= " </thead>\n";
     }
     // table skeleton including fold classes
     $foldclasses = array();
     if ($this->foldable) {
         $foldclasses = $this->_analyze_folds($rstate, $fieldDef);
     }
     $enter = "";
     if (self::$include_stash) {
         $enter .= Ht::take_stash();
     }
     $enter .= "<table class=\"pltable plt_" . htmlspecialchars($listname);
     if (defval($options, "class")) {
         $enter .= " " . $options["class"];
     }
     if ($this->listNumber) {
         $enter .= " has_hotcrp_list";
     }
     if (!empty($foldclasses)) {
         $enter .= " " . join(" ", $foldclasses);
     }
     if ($this->viewmap->table_id) {
         $enter .= "\" id=\"" . $this->viewmap->table_id;
     }
     if (defval($options, "attributes")) {
         foreach ($options["attributes"] as $n => $v) {
             $enter .= "\" {$n}=\"" . htmlspecialchars($v);
         }
     }
     if ($this->search->is_order_anno) {
         $enter .= "\" data-order-tag=\"{$this->search->is_order_anno}";
     }
     foreach ($body_attr as $k => $v) {
         $enter .= "\" {$k}=\"" . htmlspecialchars($v);
     }
     if ($this->listNumber) {
         $enter .= '" data-hotcrp-list="' . $this->listNumber;
     }
     $enter .= "\" data-fold=\"true\">\n";
     $exit = "</table>";
     // maybe make columns, maybe not
     $tbody_class = "pltable";
     if ($this->viewmap->columns && !empty($rstate->ids) && $this->_column_split($rstate, $colhead, $body)) {
         $enter = '<div class="plsplit_col_ctr_ctr"><div class="plsplit_col_ctr">' . $enter;
         $exit = $exit . "</div></div>";
         $ncol = $rstate->split_ncol;
         $tbody_class = "pltable_split";
     } else {
         $enter .= $colhead;
         $tbody_class .= $rstate->hascolors ? " pltable_colored" : "";
     }
     // footer
     $foot = "";
     if ($this->viewmap->statistics && !$this->viewmap->columns) {
         $foot .= $this->_statistics_rows($rstate, $fieldDef);
     }
     if ($fieldDef[0] instanceof SelectorPaperColumn && !defval($options, "nofooter")) {
         $foot .= $this->_footer($ncol, get_s($options, "footer_extra"));
     }
     if ($foot) {
         $enter .= ' <tfoot' . ($rstate->hascolors ? ' class="pltable_colored"' : "") . ">\n" . $foot . " </tfoot>\n";
     }
     // body
     $enter .= " <tbody class=\"{$tbody_class}\">\n";
     // header scripts to set up delegations
     if ($this->_header_script) {
         $enter .= '  <script>' . $this->_header_script . "</script>\n";
     }
     // session variable to remember the list
     if ($this->listNumber) {
         $sl = $this->search->create_session_list_object($rstate->ids, self::_listDescription($listname), $this->sortdef());
         if (isset($this->qreq->sort)) {
             $url .= (strpos($url, "?") ? "&" : "?") . "sort=" . urlencode($this->qreq->sort);
         }
         $sl->url = $url;
         if (get($options, "list_properties")) {
             foreach ($options["list_properties"] as $k => $v) {
                 $sl->{$k} = $v;
             }
         }
         SessionList::change($this->listNumber, $sl);
     }
     foreach ($fieldDef as $fdef) {
         if ($fdef->has_content) {
             $this->any[$fdef->name] = true;
         }
     }
     if ($rstate->has_openau) {
         $this->any->openau = true;
     }
     if ($rstate->has_anonau) {
         $this->any->anonau = true;
     }
     $this->ids = $rstate->ids;
     return $enter . join("", $body) . " </tbody>\n" . $exit;
 }
function reviewLinks($prow, $rrows, $crows, $rrow, $mode, &$allreviewslink)
{
    global $Conf, $Me;
    $conflictType = $Me->view_conflict_type($prow);
    $allow_admin = $Me->allow_administer($prow);
    $any_comments = false;
    $admin = $Me->can_administer($prow);
    $xsep = ' <span class="barsep">·</span> ';
    $nvisible = 0;
    $myrr = null;
    if ($rrows) {
        foreach ($rrows as $rr) {
            if ($Me->can_view_review($prow, $rr, null)) {
                $nvisible++;
            }
            if ($rr->contactId == $Me->contactId || !$myrr && $Me->is_my_review($rr)) {
                $myrr = $rr;
            }
        }
    }
    // comments
    $pret = "";
    if ($crows && count($crows) > 0 && !$rrow && $mode !== "edit") {
        $cids = array();
        $cnames = array();
        $tagger = new Tagger($Me);
        foreach ($crows as $cr) {
            if ($Me->can_view_comment($prow, $cr, null)) {
                if ($Me->can_view_comment_identity($prow, $cr, null)) {
                    $n = Text::abbrevname_html($cr->user());
                } else {
                    $n = "anonymous";
                }
                if ($cr->commentType & COMMENTTYPE_RESPONSE) {
                    $rname = $Conf->resp_round_name($cr->commentRound);
                    $n = $n === "anonymous" ? "" : " ({$n})";
                    if ($cr->commentType & COMMENTTYPE_DRAFT && $rname != "1") {
                        $n = "<i>Draft {$rname} Response</i>{$n}";
                    } else {
                        if ($cr->commentType & COMMENTTYPE_DRAFT) {
                            $n = "<i>Draft Response</i>{$n}";
                        } else {
                            if ($rname != "1") {
                                $n = "<i>{$rname} Response</i>{$n}";
                            } else {
                                $n = "<i>Response</i>{$n}";
                            }
                        }
                    }
                }
                $cids[] = $cid = CommentInfo::unparse_html_id($cr);
                $tclass = "cmtlink";
                if ($cr->commentTags && ($tags = Tagger::strip_nonviewable($cr->commentTags, $Me)) && $Me->can_view_comment_tags($prow, $cr, null) && ($color = TagInfo::color_classes($tags))) {
                    if (TagInfo::classes_have_colors($color)) {
                        $tclass .= " tagcolorspan";
                    }
                    $tclass .= " {$color} taghl";
                }
                $cnames[] = '<a class="' . $tclass . '" href="#' . $cid . '">' . $n . '</a>';
            }
        }
        if (count($cids) > 0) {
            $pret = '<div class="revnotes"><a href="#' . $cids[0] . '"><strong>' . plural(count($cids), "Comment") . '</strong></a>: <span class="nb">' . join(',</span> <span class="nb">', $cnames) . "</span></div>";
            $any_comments = true;
        }
    }
    $t = "";
    // see all reviews
    $allreviewslink = false;
    if (($nvisible > 1 || $nvisible > 0 && !$myrr) && ($mode !== "p" || $rrow)) {
        $allreviewslink = true;
        $x = '<a href="' . hoturl("paper", "p={$prow->paperId}") . '" class="xx">' . Ht::img("view24.png", "[All reviews]", "dlimg") . "&nbsp;<u>All reviews</u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
    }
    // edit paper
    if ($mode !== "edit" && $prow->conflictType >= CONFLICT_AUTHOR && !$Me->can_administer($prow)) {
        $x = '<a href="' . hoturl("paper", "p={$prow->paperId}&amp;m=edit") . '" class="xx">' . Ht::img("edit24.png", "[Edit paper]", "dlimg") . "&nbsp;<u><strong>Edit paper</strong></u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
    }
    // edit review
    if ($mode === "re" || $mode === "assign" && $t !== "" || !$prow) {
        /* no link */
    } else {
        if ($myrr && $rrow != $myrr) {
            $myrlink = unparseReviewOrdinal($myrr);
            $a = '<a href="' . hoturl("review", "p={$prow->paperId}&r={$myrlink}") . '" class="xx">';
            if ($Me->can_review($prow, $myrr)) {
                $x = $a . Ht::img("review24.png", "[Edit review]", "dlimg") . "&nbsp;<u><b>Edit your review</b></u></a>";
            } else {
                $x = $a . Ht::img("review24.png", "[Your review]", "dlimg") . "&nbsp;<u><b>Your review</b></u></a>";
            }
            $t .= ($t === "" ? "" : $xsep) . $x;
        } else {
            if (!$myrr && !$rrow && $Me->can_review($prow, null)) {
                $x = '<a href="' . hoturl("review", "p={$prow->paperId}&amp;m=re") . '" class="xx">' . Ht::img("review24.png", "[Write review]", "dlimg") . "&nbsp;<u><b>Write review</b></u></a>";
                $t .= ($t === "" ? "" : $xsep) . $x;
            }
        }
    }
    // review assignments
    if ($mode !== "assign" && $mode !== "edit" && $Me->can_request_review($prow, true)) {
        $x = '<a href="' . hoturl("assign", "p={$prow->paperId}") . '" class="xx">' . Ht::img("assign24.png", "[Assign]", "dlimg") . "&nbsp;<u>" . ($admin ? "Assign reviews" : "External reviews") . "</u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
    }
    // new comment
    $nocmt = preg_match('/\\A(?:assign|contact|edit|re)\\z/', $mode);
    if (!$allreviewslink && !$nocmt && $Me->can_comment($prow, null)) {
        $x = '<a href="#cnew" onclick="return papercomment.edit_new()" class="xx">' . Ht::img("comment24.png", "[Add comment]", "dlimg") . "&nbsp;<u>Add comment</u></a>";
        $t .= ($t === "" ? "" : $xsep) . $x;
        $any_comments = true;
    }
    // new response
    if (!$nocmt && ($prow->conflictType >= CONFLICT_AUTHOR || $allow_admin) && ($rrounds = $Conf->time_author_respond())) {
        foreach ($rrounds as $i => $rname) {
            $cid = ($i ? $rname : "") . "response";
            $what = "Add";
            if ($crows) {
                foreach ($crows as $cr) {
                    if ($cr->commentType & COMMENTTYPE_RESPONSE && $cr->commentRound == $i) {
                        $what = "Edit";
                        if ($cr->commentType & COMMENTTYPE_DRAFT) {
                            $what = "Edit draft";
                        }
                    }
                }
            }
            $x = '<a href="#' . $cid . '" onclick=\'return papercomment.edit_response(' . json_encode($rname) . ')\' class="xx">' . Ht::img("comment24.png", "[{$what} response]", "dlimg") . "&nbsp;" . ($conflictType >= CONFLICT_AUTHOR ? '<u style="font-weight:bold">' : '<u>') . $what . ($i ? " {$rname}" : "") . ' response</u></a>';
            $t .= ($t === "" ? "" : $xsep) . $x;
            $any_comments = true;
        }
    }
    // override conflict
    if ($allow_admin && !$admin) {
        $x = '<a href="' . selfHref(array("forceShow" => 1)) . '" class="xx">' . Ht::img("override24.png", "[Override]", "dlimg") . "&nbsp;<u>Override conflict</u></a> to show reviewers and allow editing";
        $t .= ($t === "" ? "" : $xsep) . $x;
    } else {
        if ($Me->privChair && !$allow_admin) {
            $x = "You can’t override your conflict because this paper has an administrator.";
            $t .= ($t === "" ? "" : $xsep) . $x;
        }
    }
    if ($any_comments) {
        CommentInfo::echo_script($prow);
    }
    if (($list = SessionList::active()) && ($pret || $t)) {
        return '<div class="has_hotcrp_list" data-hotcrp-list="' . $list->listno . '">' . $pret . $t . '</div>';
    } else {
        return $pret . $t;
    }
}
 static function track_api($qreq, $user)
 {
     if (!$user->privChair || !check_post()) {
         json_exit(array("ok" => false));
     }
     // argument: IDENTIFIER LISTNUM [POSITION] -OR- stop
     if ($qreq->track === "stop") {
         self::clear();
         return;
     }
     // check tracker_start_at to ignore concurrent updates
     if (($start_at = $qreq->tracker_start_at) && ($tracker = self::lookup())) {
         $time = $tracker->position_at;
         if (isset($tracker->start_at)) {
             $time = $tracker->start_at;
         }
         if ($time > $start_at) {
             return;
         }
     }
     // actually track
     $args = preg_split('/\\s+/', $qreq->track);
     if (count($args) >= 2 && ($xlist = SessionList::lookup($args[1])) && str_starts_with($xlist->listid, "p/")) {
         $position = null;
         if (count($args) >= 3 && ctype_digit($args[2])) {
             $position = array_search((int) $args[2], $xlist->ids);
         }
         self::update($xlist, $args[0], $position);
     }
 }
 private function header_head($title)
 {
     global $Me, $ConfSitePATH, $Opt;
     // load session list and clear its cookie
     $list = SessionList::active();
     SessionList::set_requested(0);
     echo "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta name=\"google\" content=\"notranslate\" />\n";
     if (isset($Opt["fontScript"])) {
         echo $Opt["fontScript"];
     }
     echo $this->make_css_link("stylesheets/style.css"), "\n";
     if (get($Opt, "mobileStylesheet")) {
         echo '<meta name="viewport" content="width=device-width, initial-scale=1">', "\n";
         echo $this->make_css_link("stylesheets/mobile.css", "screen and (max-width: 768px)"), "\n";
     }
     if (isset($Opt["stylesheets"])) {
         foreach (mkarray($Opt["stylesheets"]) as $css) {
             echo $this->make_css_link($css), "\n";
         }
     }
     // favicon
     if ($favicon = defval($Opt, "favicon", "images/review24.png")) {
         if (strpos($favicon, "://") === false && $favicon[0] != "/") {
             if (get($Opt, "assetsUrl") && substr($favicon, 0, 7) === "images/") {
                 $favicon = $Opt["assetsUrl"] . $favicon;
             } else {
                 $favicon = Navigation::siteurl() . $favicon;
             }
         }
         if (substr($favicon, -4) == ".png") {
             echo "<link rel=\"icon\" type=\"image/png\" href=\"{$favicon}\" />\n";
         } else {
             if (substr($favicon, -4) == ".ico") {
                 echo "<link rel=\"shortcut icon\" href=\"{$favicon}\" />\n";
             } else {
                 if (substr($favicon, -4) == ".gif") {
                     echo "<link rel=\"icon\" type=\"image/gif\" href=\"{$favicon}\" />\n";
                 } else {
                     echo "<link rel=\"icon\" href=\"{$favicon}\" />\n";
                 }
             }
         }
     }
     // title
     echo "<title>";
     if ($title) {
         $title = preg_replace("/<([^>\"']|'[^']*'|\"[^\"]*\")*>/", "", $title);
         $title = preg_replace(",(?: |&nbsp;| )+,", " ", $title);
         $title = str_replace("&#x2215;", "-", $title);
     }
     if ($title) {
         echo $title, " - ";
     }
     echo htmlspecialchars($Opt["shortName"]), "</title>\n</head>\n";
     // jQuery
     $stash = Ht::take_stash();
     if (isset($Opt["jqueryUrl"])) {
         $jquery = $Opt["jqueryUrl"];
     } else {
         if (get($Opt, "jqueryCdn")) {
             $jquery = "//code.jquery.com/jquery-1.12.3.min.js";
         } else {
             $jquery = "scripts/jquery-1.12.3.min.js";
         }
     }
     Ht::stash_html($this->make_script_file($jquery, true) . "\n");
     // Javascript settings to set before script.js
     Ht::stash_script("siteurl=" . json_encode(Navigation::siteurl()) . ";siteurl_suffix=\"" . Navigation::php_suffix() . "\"");
     if (session_id() !== "") {
         Ht::stash_script("siteurl_postvalue=\"" . post_value() . "\"");
     }
     if ($list) {
         Ht::stash_script("hotcrp_list=" . json_encode(["num" => $list->listno, "id" => $list->listid]) . ";");
     }
     if ($urldefaults = hoturl_defaults()) {
         Ht::stash_script("siteurl_defaults=" . json_encode($urldefaults) . ";");
     }
     Ht::stash_script("assetsurl=" . json_encode($Opt["assetsUrl"]) . ";");
     $huser = (object) array();
     if ($Me && $Me->email) {
         $huser->email = $Me->email;
     }
     if ($Me && $Me->is_pclike()) {
         $huser->is_pclike = true;
     }
     if ($Me && $Me->has_database_account()) {
         $huser->cid = $Me->contactId;
     }
     Ht::stash_script("hotcrp_user="******";");
     $pid = get($_REQUEST, "paperId");
     $pid = $pid && ctype_digit($pid) ? (int) $pid : 0;
     if (!$pid && $this->paper) {
         $pid = $this->paper->paperId;
     }
     if ($pid) {
         Ht::stash_script("hotcrp_paperid={$pid}");
     }
     if ($pid && $Me && $Me->is_admin_force()) {
         Ht::stash_script("hotcrp_want_override_conflict=true");
     }
     // script.js
     if (!get($Opt, "noDefaultScript")) {
         Ht::stash_html($this->make_script_file("scripts/script.js") . "\n");
     }
     // other scripts
     if (get($Opt, "scripts")) {
         foreach ($Opt["scripts"] as $file) {
             Ht::stash_html($this->make_script_file($file) . "\n");
         }
     }
     if ($stash) {
         Ht::stash_html($stash);
     }
 }
 function create_session_list_object($ids, $listname, $sort = "")
 {
     $l = SessionList::create($this->listId($sort), $ids, $this->description($listname), $this->url_site_relative_raw());
     if ($this->matchPreg) {
         $l->matchPreg = $this->matchPreg;
     }
     return $l;
 }
 function table_html($listname, $url, $listtitle = "", $foldsession = null)
 {
     global $Conf, $contactListFields;
     // PC tags
     $listquery = $listname;
     $queryOptions = array();
     if (str_starts_with($listname, "#")) {
         $queryOptions["where"] = "(u.contactTags like " . Dbl::utf8ci("'% " . sqlq_for_like(substr($listname, 1)) . "#%'") . ")";
         $listquery = "pc";
     }
     // get paper list
     if (!($baseFieldId = $this->listFields($listquery))) {
         Conf::msg_error("There is no people list query named “" . htmlspecialchars($listquery) . "”.");
         return null;
     }
     $this->limit = array_shift($baseFieldId);
     // get field array
     $fieldDef = array();
     $acceptable_fields = array();
     $this->any = (object) array("sel" => false);
     $ncol = 0;
     foreach ($baseFieldId as $fid) {
         if ($this->selector($fid, $queryOptions) === false) {
             continue;
         }
         if (!($fieldDef[$fid] = @$contactListFields[$fid])) {
             $fieldDef[$fid] = $contactListFields[self::FIELD_SCORE];
         }
         $acceptable_fields[$fid] = true;
         if ($fieldDef[$fid][1] == 1) {
             $ncol++;
         }
     }
     // run query
     $rows = $this->_rows($queryOptions);
     if (!$rows || count($rows) == 0) {
         return "No matching people";
     }
     // list number
     if ($this->listNumber === true) {
         $this->listNumber = SessionList::allocate("u/" . $this->limit);
         $this->contactLinkArgs .= "&amp;ls=" . $this->listNumber;
     }
     // sort rows
     if (!@$acceptable_fields[$this->sortField]) {
         $this->sortField = null;
     }
     $srows = $this->_sort($rows);
     // count non-callout columns
     $firstcallout = $lastcallout = null;
     $n = 0;
     foreach ($fieldDef as $fieldId => $fdef) {
         if ($fdef[1] == 1) {
             if ($firstcallout === null && $fieldId < self::FIELD_SELECTOR) {
                 $firstcallout = $n;
             }
             if ($fieldId < self::FIELD_SCORE) {
                 $lastcallout = $n + 1;
             }
             ++$n;
         }
     }
     $firstcallout = $firstcallout ? $firstcallout : 0;
     $lastcallout = ($lastcallout ? $lastcallout : $ncol) - $firstcallout;
     // collect row data
     $this->count = 0;
     $show_colors = $this->contact->isPC;
     $anyData = array();
     $body = '';
     $extrainfo = $hascolors = false;
     $ids = array();
     foreach ($srows as $row) {
         if (($this->limit == "resub" || $this->limit == "extsub") && $row->numReviewsSubmitted == 0) {
             continue;
         }
         $trclass = "k" . $this->count % 2;
         if ($show_colors && ($m = $row->viewable_color_classes($this->contact))) {
             if (TagInfo::classes_have_colors($m)) {
                 $trclass = $m;
                 $hascolors = true;
             } else {
                 $trclass .= " {$m}";
             }
         }
         if ($row->disabled && $this->contact->isPC) {
             $trclass .= " graytext";
         }
         $this->count++;
         $ids[] = (int) $row->contactId;
         // First create the expanded callout row
         $tt = "";
         foreach ($fieldDef as $fieldId => $fdef) {
             if ($fdef[1] >= 2 && ($d = $this->content($fieldId, $row)) !== "") {
                 $tt .= "<div";
                 //$t .= "  <tr class=\"pl_$fdef[0] pl_callout $trclass";
                 if ($fdef[1] >= 3) {
                     $tt .= " class=\"fx" . ($fdef[1] - 2) . "\"";
                 }
                 $tt .= '><em class="plx">' . $this->header($fieldId, -1, $row) . ":</em> " . $d . "</div>";
             }
         }
         if ($tt !== "") {
             $x = "  <tr class=\"plx {$trclass}\">";
             if ($firstcallout > 0) {
                 $x .= "<td colspan=\"{$firstcallout}\"></td>";
             }
             $tt = $x . "<td class=\"plx\" colspan=\"" . ($lastcallout - $firstcallout) . "\">" . $tt . "</td></tr>\n";
         }
         // Now the normal row
         $t = "  <tr class=\"pl {$trclass}\">\n";
         $n = 0;
         foreach ($fieldDef as $fieldId => $fdef) {
             if ($fdef[1] == 1) {
                 $c = $this->content($fieldId, $row);
                 $t .= "    <td class=\"pl pl_{$fdef['0']}\"";
                 if ($n >= $lastcallout && $tt != "") {
                     $t .= " rowspan=\"2\"";
                 }
                 $t .= ">" . $c . "</td>\n";
                 if ($c != "") {
                     $anyData[$fieldId] = 1;
                 }
                 ++$n;
             }
         }
         $t .= "  </tr>\n";
         $body .= $t . $tt;
     }
     $foldclasses = array();
     foreach (self::$folds as $k => $fold) {
         if (@$this->have_folds[$fold] !== null) {
             $this->have_folds[$fold] = strpos(displayOptionsSet("uldisplay"), " {$fold} ") !== false;
             $foldclasses[] = "fold" . ($k + 1) . ($this->have_folds[$fold] ? "o" : "c");
         }
     }
     $x = "<table id=\"foldul\" class=\"pltable pltable_full plt_" . htmlspecialchars($listquery);
     if ($foldclasses) {
         $x .= " " . join(" ", $foldclasses);
     }
     if ($foldclasses && $foldsession) {
         $x .= "\" data-fold-session=\"{$foldsession}";
     }
     $x .= "\">\n";
     if ($this->showHeader) {
         $x .= "  <thead class=\"pltable\">\n  <tr class=\"pl_headrow\">\n";
         $ord = 0;
         if ($this->sortable && $url) {
             $sortUrl = htmlspecialchars($url) . (strpos($url, "?") ? "&amp;" : "?") . "sort=";
             $q = '<a class="pl_sort" rel="nofollow" href="' . $sortUrl;
             foreach ($fieldDef as $fieldId => $fdef) {
                 if ($fdef[1] != 1) {
                     continue;
                 } else {
                     if (!isset($anyData[$fieldId])) {
                         $x .= "    <th class=\"pl pl_{$fdef['0']}\"></th>\n";
                         continue;
                     }
                 }
                 $x .= "    <th class=\"pl pl_{$fdef['0']}\">";
                 $ftext = $this->header($fieldId, $ord++);
                 if ($this->sortField == null && $fieldId == 1) {
                     $this->sortField = $fieldId;
                 }
                 if ($fieldId == $this->sortField) {
                     $x .= '<a class="pl_sort_def' . ($this->reverseSort ? "_rev" : "") . '" rel="nofollow" href="' . $sortUrl . $fieldId . ($this->reverseSort ? "N" : "R") . '">' . $ftext . "</a>";
                 } else {
                     if ($fdef[2]) {
                         $x .= $q . $fieldId . "\">" . $ftext . "</a>";
                     } else {
                         $x .= $ftext;
                     }
                 }
                 $x .= "</th>\n";
             }
         } else {
             foreach ($fieldDef as $fieldId => $fdef) {
                 if ($fdef[1] == 1 && isset($anyData[$fieldId])) {
                     $x .= "    <th class=\"pl pl_{$fdef['0']}\">" . $this->header($fieldId, $ord++) . "</th>\n";
                 } else {
                     if ($fdef[1] == 1) {
                         $x .= "    <th class=\"pl pl_{$fdef['0']}\"></th>\n";
                     }
                 }
             }
         }
         $x .= "  </tr></thead>\n";
     }
     reset($fieldDef);
     if (key($fieldDef) == self::FIELD_SELECTOR) {
         $x .= $this->footer($ncol, $hascolors);
     }
     $x .= "<tbody class=\"pltable" . ($hascolors ? " pltable_colored" : "") . "\">" . $body . "</tbody></table>";
     if ($this->listNumber) {
         $l = SessionList::create("u/" . $listname, $ids, $listtitle ? $listtitle : "Users", hoturl_site_relative_raw("users", ["t" => $listname]));
         SessionList::change($this->listNumber, $l);
     }
     return $x;
 }
Esempio n. 8
0
 private function header_head($title)
 {
     global $Me, $ConfSitePATH, $CurrentList;
     echo "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n<meta http-equiv=\"Content-Language\" content=\"en\" />\n<meta name=\"google\" content=\"notranslate\" />\n";
     if (strstr($title, "<") !== false) {
         $title = preg_replace("/<([^>\"']|'[^']*'|\"[^\"]*\")*>/", "", $title);
     }
     echo $this->opt("fontScript", "");
     echo $this->make_css_link("stylesheets/style.css"), "\n";
     if ($this->opt("mobileStylesheet")) {
         echo '<meta name="viewport" content="width=device-width, initial-scale=1">', "\n";
         echo $this->make_css_link("stylesheets/mobile.css", "screen and (max-width: 768px)"), "\n";
     }
     foreach (mkarray($this->opt("stylesheets", [])) as $css) {
         echo $this->make_css_link($css), "\n";
     }
     // favicon
     $favicon = $this->opt("favicon");
     if ($favicon) {
         if (strpos($favicon, "://") === false && $favicon[0] != "/") {
             if ($this->opt["assetsUrl"] && substr($favicon, 0, 7) === "images/") {
                 $favicon = $this->opt["assetsUrl"] . $favicon;
             } else {
                 $favicon = Navigation::siteurl() . $favicon;
             }
         }
         if (substr($favicon, -4) == ".png") {
             echo "<link rel=\"icon\" type=\"image/png\" href=\"{$favicon}\" />\n";
         } else {
             if (substr($favicon, -4) == ".ico") {
                 echo "<link rel=\"shortcut icon\" href=\"{$favicon}\" />\n";
             } else {
                 if (substr($favicon, -4) == ".gif") {
                     echo "<link rel=\"icon\" type=\"image/gif\" href=\"{$favicon}\" />\n";
                 } else {
                     echo "<link rel=\"icon\" href=\"{$favicon}\" />\n";
                 }
             }
         }
     }
     // jQuery
     if (isset($this->opt["jqueryUrl"])) {
         $jquery = $this->opt["jqueryUrl"];
     } else {
         if ($this->opt("jqueryCdn")) {
             $jquery = "//code.jquery.com/jquery-1.12.3.min.js";
         } else {
             $jquery = "scripts/jquery-1.12.3.min.js";
         }
     }
     Ht::stash_html($this->make_script_file($jquery, true) . "\n");
     Ht::stash_html($this->make_script_file("scripts/jquery.color-2.1.2.min.js", true) . "\n");
     Ht::stash_html($this->make_script_file("scripts/jquery.flot.min.js", true) . "\n");
     //Ht::stash_html($this->make_script_file("scripts/ZeroClipboard.min.js", true) . "\n");
     // Javascript settings to set before script.js
     Ht::stash_script("siteurl=" . json_encode(Navigation::siteurl()) . ";siteurl_suffix=\"" . Navigation::php_suffix() . "\"");
     if (session_id() !== "") {
         Ht::stash_script("siteurl_postvalue=\"" . post_value() . "\"");
     }
     if (@$CurrentList && ($list = SessionList::lookup($CurrentList))) {
         Ht::stash_script("hotcrp_list={num:{$CurrentList},id:\"" . addcslashes($list->listid, "\n\r\\\"/") . "\"}");
     }
     if ($urldefaults = hoturl_defaults()) {
         Ht::stash_script("siteurl_defaults=" . json_encode($urldefaults) . ";");
     }
     Ht::stash_script("assetsurl=" . json_encode($this->opt["assetsUrl"]) . ";");
     $huser = (object) array();
     if ($Me && $Me->email) {
         $huser->email = $Me->email;
     }
     if ($Me && $Me->is_pclike()) {
         $huser->is_pclike = true;
     }
     Ht::stash_script("hotcrp_user="******"ZeroClipboard.setDefaults({moviePath:\"" . Navigation::siteurl() . "cacheable" . Navigation::php_suffix() . "?file=scripts/ZeroClipboard.swf&amp;mtime=" . filemtime("$ConfSitePATH/scripts/ZeroClipboard.swf") . "\"})");
     // script.js
     if (!$this->opt("noDefaultScript")) {
         Ht::stash_html($this->make_script_file("scripts/script.js") . "\n");
     }
     echo Ht::unstash();
     echo "<title>";
     if ($title) {
         echo $title, " - ";
     }
     echo htmlspecialchars($this->short_name), "</title>\n</head>\n";
 }
Esempio n. 9
0
 private function header_head($title)
 {
     global $Me, $ConfSiteBase, $ConfSiteSuffix, $ConfSitePATH, $Opt, $CurrentList;
     echo "<!DOCTYPE html>\n<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n<meta http-equiv=\"Content-Language\" content=\"en\" />\n<meta name=\"google\" content=\"notranslate\" />\n";
     if (strstr($title, "<") !== false) {
         $title = preg_replace("/<([^>\"']|'[^']*'|\"[^\"]*\")*>/", "", $title);
     }
     if (isset($Opt["fontScript"])) {
         echo $Opt["fontScript"];
     }
     echo $this->make_css_link("stylesheets/style.css"), "\n";
     if (isset($Opt["stylesheets"])) {
         foreach ($Opt["stylesheets"] as $css) {
             echo $this->make_css_link($css), "\n";
         }
     }
     // favicon
     if ($favicon = defval($Opt, "favicon")) {
         if (strpos($favicon, "://") === false && $favicon[0] != "/") {
             if (@$Opt["assetsUrl"] && substr($favicon, 0, 7) === "images/") {
                 $favicon = $Opt["assetsUrl"] . $favicon;
             } else {
                 $favicon = $ConfSiteBase . $favicon;
             }
         }
         if (substr($favicon, -4) == ".png") {
             echo "<link rel=\"icon\" type=\"image/png\" href=\"{$favicon}\" />\n";
         } else {
             if (substr($favicon, -4) == ".ico") {
                 echo "<link rel=\"shortcut icon\" href=\"{$favicon}\" />\n";
             } else {
                 if (substr($favicon, -4) == ".gif") {
                     echo "<link rel=\"icon\" type=\"image/gif\" href=\"{$favicon}\" />\n";
                 } else {
                     echo "<link rel=\"icon\" href=\"{$favicon}\" />\n";
                 }
             }
         }
     }
     // jQuery
     if (isset($Opt["jqueryUrl"])) {
         $jquery = $Opt["jqueryUrl"];
     } else {
         if (@$Opt["jqueryCdn"]) {
             $jquery = "//code.jquery.com/jquery-1.11.3.min.js";
         } else {
             $jquery = "scripts/jquery-1.11.3.min.js";
         }
     }
     $this->scriptStuff = $this->make_script_file($jquery, true) . "\n";
     $this->scriptStuff .= $this->make_script_file("scripts/jquery.color-2.1.2.min.js", true) . "\n";
     $this->scriptStuff .= $this->make_script_file("scripts/jquery.flot.min.js", true) . "\n";
     //$this->scriptStuff .= $this->make_script_file("scripts/ZeroClipboard.min.js", true) . "\n";
     // Javascript settings to set before script.js
     $this->scriptStuff .= "<script>siteurl=\"{$ConfSiteBase}\";siteurl_suffix=\"{$ConfSiteSuffix}\"";
     if (session_id() !== "") {
         $this->scriptStuff .= ";siteurl_postvalue=\"" . post_value() . "\"";
     }
     if (@$CurrentList && ($list = SessionList::lookup($CurrentList))) {
         $this->scriptStuff .= ";hotcrp_list={num:{$CurrentList},id:\"" . addcslashes($list->listid, "\n\r\\\"/") . "\"}";
     }
     if ($urldefaults = hoturl_defaults()) {
         $this->scriptStuff .= ";siteurl_defaults=" . json_encode($urldefaults);
     }
     $huser = (object) array();
     if ($Me && $Me->email) {
         $huser->email = $Me->email;
     }
     if ($Me && $Me->is_pclike()) {
         $huser->is_pclike = true;
     }
     $this->scriptStuff .= ";hotcrp_user="******"paperId"];
     $pid = $pid && ctype_digit($pid) ? (int) $pid : 0;
     if ($pid) {
         $this->scriptStuff .= ";hotcrp_paperid={$pid}";
     }
     if ($pid && $Me && $Me->privChair && ($forceShow = @$_REQUEST["forceShow"]) && $forceShow != "0") {
         $this->scriptStuff .= ";hotcrp_want_override_conflict=true";
     }
     //$this->scriptStuff .= ";ZeroClipboard.setDefaults({moviePath:\"${ConfSiteBase}cacheable$ConfSiteSuffix?file=scripts/ZeroClipboard.swf&amp;mtime=" . filemtime("$ConfSitePATH/scripts/ZeroClipboard.swf") . "\"})";
     $this->scriptStuff .= "</script>\n";
     // script.js
     $this->scriptStuff .= $this->make_script_file("scripts/script.js") . "\n";
     echo $this->scriptStuff;
     $this->scriptStuff = "";
     echo "<title>", $title, " - ", htmlspecialchars($Opt["shortName"]), "</title>\n</head>\n";
 }