private function _row_text($rstate, $row, $fieldDef) { global $Conf; $rowidx = count($rstate->ids); $rstate->ids[] = (int) $row->paperId; $trclass = "k" . $rstate->colorindex; if (get($row, "paperTags") && ($viewable = $row->viewable_tags($this->contact, true)) && ($m = TagInfo::color_classes($viewable))) { if (TagInfo::classes_have_colors($m)) { $rstate->hascolors = true; $trclass = $m; } else { $trclass .= " " . $m; } if ($row->conflictType > 0 && !$this->contact->can_view_tags($row, false)) { $trclass .= " conflictmark"; } } if ($highlightclass = get($this->search->highlightmap, $row->paperId)) { $trclass .= " {$highlightclass}mark"; } $rstate->colorindex = 1 - $rstate->colorindex; $rstate->last_trclass = $trclass; $this->row_attr = []; // main columns $tm = ""; foreach ($fieldDef as $fdef) { if ($fdef->view != Column::VIEW_COLUMN) { continue; } $empty = $fdef->content_empty($this, $row); if ($fdef->is_folded) { if (!$empty) { $fdef->has_content = true; } } else { $tm .= "<td class=\"pl " . $fdef->className; if ($fdef->foldable) { $tm .= " fx{$fdef->foldable}"; } $tm .= "\">"; if (!$empty && ($c = $fdef->content($this, $row, $rowidx)) !== "") { $tm .= $c; $fdef->has_content = true; } $tm .= "</td>"; } } // extension columns $tt = ""; foreach ($fieldDef as $fdef) { if ($fdef->view != Column::VIEW_ROW) { continue; } $empty = $fdef->content_empty($this, $row); $is_authors = $fdef->name === "authors"; if ($fdef->is_folded && !$is_authors) { if (!$empty) { $fdef->has_content = true; } } else { $tt .= "<div class=\"" . $fdef->className; if ($is_authors) { $tt .= " fx1"; if ($this->contact->can_view_authors($row, false)) { $rstate->has_openau = true; } else { $tt .= " fx2"; $rstate->has_anonau = true; } } else { if ($fdef->foldable) { $tt .= " fx" . $fdef->foldable; } } $tt .= "\">"; if (!$empty && ($c = $fdef->content($this, $row, $rowidx)) !== "") { if ($c[0] !== "<" || !preg_match('/\\A((?:<(?:div|p).*?>)*)([\\s\\S]*)\\z/', $c, $cm)) { $cm = [null, "", $c]; } $tt .= $cm[1] . '<em class="plx">' . $fdef->header($this, -1) . ':</em> ' . $cm[2]; $fdef->has_content = true; } $tt .= "</div>"; } } if (isset($row->folded) && $row->folded) { $trclass .= " fx3"; $rstate->row_folded = true; } else { if ($rstate->row_folded) { $rstate->row_folded = false; } } $t = " <tr"; if ($this->_row_id_pattern) { $t .= " id=\"" . str_replace("#", $row->paperId, $this->_row_id_pattern) . "\""; } $t .= " class=\"pl {$trclass}\" data-pid=\"{$row->paperId}"; foreach ($this->row_attr as $k => $v) { $t .= "\" {$k}=\"" . htmlspecialchars($v); } $t .= "\">" . $tm . "</tr>\n"; if ($tt !== "") { $t .= " <tr class=\"plx {$trclass}\" data-pid=\"{$row->paperId}\">"; if ($rstate->skipcallout > 0) { $t .= "<td colspan=\"{$rstate->skipcallout}\"></td>"; } $t .= "<td class=\"plx\" colspan=\"" . ($rstate->ncol - $rstate->skipcallout) . "\">{$tt}</td></tr>\n"; } return $t; }
function viewable_color_classes(Contact $user) { return TagInfo::color_classes($this->viewable_tags($user)); }
public function add_tag_info_json($pj, Contact $user) { if (!property_exists($this, "paperTags")) { $this->load_tags(); } $tagger = new Tagger($user); $editable = $this->editable_tags($user); $viewable = $this->viewable_tags($user); $tags_view_html = $tagger->unparse_and_link($viewable, $this->paperTags, false); $pj->tags = TagInfo::split($viewable); $pj->tags_edit_text = $tagger->unparse($editable); $pj->tags_view_html = $tags_view_html; $pj->color_classes = TagInfo::color_classes($viewable); }
public function unparse_json($contact, $include_displayed_at = false) { global $Conf; if ($this->commentId && !$contact->can_view_comment($this->prow, $this, null)) { return false; } // placeholder for new comment if (!$this->commentId) { if (!$contact->can_comment($this->prow, $this)) { return false; } $cj = (object) array("pid" => $this->prow->paperId, "is_new" => true, "editable" => true); if ($this->commentType & COMMENTTYPE_RESPONSE) { $cj->response = $Conf->resp_round_name($this->commentRound); } return $cj; } // otherwise, viewable comment $cj = (object) array("pid" => $this->prow->paperId, "cid" => $this->commentId); $cj->ordinal = $this->unparse_ordinal(); $cj->visibility = self::$visibility_map[$this->commentType & COMMENTTYPE_VISIBILITY]; if ($this->commentType & COMMENTTYPE_BLIND) { $cj->blind = true; } if ($this->commentType & COMMENTTYPE_DRAFT) { $cj->draft = true; } if ($this->commentType & COMMENTTYPE_RESPONSE) { $cj->response = $Conf->resp_round_name($this->commentRound); } if ($contact->can_comment($this->prow, $this)) { $cj->editable = true; } // tags if ($this->commentTags && $contact->can_view_comment_tags($this->prow, $this, null)) { if ($tags = $this->viewable_tags($contact)) { $cj->tags = TagInfo::split($tags); } if ($tags && ($cc = TagInfo::color_classes($tags))) { $cj->color_classes = $cc; } } // identity and time $idable = $contact->can_view_comment_identity($this->prow, $this, null); $idable_override = $idable || $contact->can_view_comment_identity($this->prow, $this, true); if ($idable || $idable_override) { $user = $this->user(); $cj->author = Text::user_html($user); $cj->author_email = $user->email; if (!$idable) { $cj->author_hidden = true; } } if ($this->timeModified > 0 && $idable_override) { $cj->modified_at = (int) $this->timeModified; $cj->modified_at_text = $Conf->printableTime($cj->modified_at); } else { if ($this->timeModified > 0) { $cj->modified_at = $Conf->obscure_time($this->timeModified); $cj->modified_at_text = $Conf->unparse_time_obscure($cj->modified_at); $cj->modified_at_obscured = true; } } if ($include_displayed_at) { // XXX exposes information, should hide before export $cj->displayed_at = (int) $this->timeDisplayed; } // text if ($this->commentOverflow) { $cj->text = $this->commentOverflow; } else { $cj->text = $this->comment; } // format if (($fmt = $this->commentFormat) === null) { $fmt = Conf::$gDefaultFormat; } if ($fmt) { $cj->format = (int) $fmt; } return $cj; }
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") . " <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}&m=edit") . '" class="xx">' . Ht::img("edit24.png", "[Edit paper]", "dlimg") . " <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") . " <u><b>Edit your review</b></u></a>"; } else { $x = $a . Ht::img("review24.png", "[Your review]", "dlimg") . " <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}&m=re") . '" class="xx">' . Ht::img("review24.png", "[Write review]", "dlimg") . " <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") . " <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") . " <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") . " " . ($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") . " <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; } }
private function _prepare_reviewer_color(Contact $user) { $this->reviewer_color = array(); foreach (pcMembers() as $p) { $this->reviewer_color[$p->contactId] = TagInfo::color_classes($p->viewable_tags($user)); } }