Skip to content
Permalink
Browse files

Internal rearrangement of user tags methods.

- No Contact::user_color_classes_for.
- Move global tag list to Conf.
  • Loading branch information...
kohler committed Oct 28, 2019
1 parent b49a1d1 commit dc328732350557b1a80e4ee45caa8a7d481dc55e
Showing with 31 additions and 26 deletions.
  1. +2 −1 autoassign.php
  2. +2 −1 help.php
  3. +5 −4 src/api/api_paperpc.php
  4. +14 −2 src/conference.php
  5. +5 −16 src/contact.php
  6. +1 −1 src/mailclasses.php
  7. +2 −1 users.php
@@ -608,9 +608,10 @@ function divClass($name, $classes = null) {
foreach ($Conf->pc_members() as $pc)
$tagsjson[$pc->contactId] = " " . trim(strtolower($pc->viewable_tags($Me))) . " ";
Ht::stash_script("var hotcrp_pc_tags=" . json_encode($tagsjson) . ";");
foreach ($Me->viewable_user_tags() as $pctag)
foreach ($Conf->viewable_user_tags($Me) as $pctag) {
if ($pctag !== "pc")
$pctyp_sel[] = [$pctag, "#$pctag"];
}
$pctyp_sel[] = array("__flip__", "flip");
$sep = "";
foreach ($pctyp_sel as $pctyp) {
@@ -196,9 +196,10 @@ function show_help_topics($hth) {
function meaningful_pc_tag(Contact $user) {
foreach ($user->viewable_user_tags() as $tag)
foreach ($user->conf->viewable_user_tags($user) as $tag) {
if ($tag !== "pc")
return $tag;
}
return false;
}
@@ -20,10 +20,11 @@ private static function run(Contact $user, Qrequest $qreq, $prow, $type) {
$k = "{$type}ContactId";
$cid = $prow->$k;
}
$luser = $cid ? $user->conf->pc_member_by_id($cid) : null;
$j = ["ok" => true, "result" => $luser ? $user->name_html_for($luser) : "None"];
if ($user->can_view_reviewer_tags($prow))
$j["color_classes"] = $cid ? $user->user_color_classes_for($luser) : "";
$pcu = $cid ? $user->conf->pc_member_by_id($cid) : null;
$j = ["ok" => true, "result" => $pcu ? $user->name_html_for($pcu) : "None"];
if ($user->can_view_reviewer_tags($prow)) {
$j["color_classes"] = $cid ? $pcu->viewable_color_classes($user) : "";
}
return $j;
}
@@ -1820,6 +1820,18 @@ function pc_completion_map() {
return $map;
}
function viewable_user_tags(Contact $viewer) {
if ($viewer->privChair) {
return $this->pc_tags();
} else if ($viewer->can_view_user_tags()) {
$t = join(" ", $this->pc_tags());
$t = $this->tags()->strip_nonviewable($t, $viewer, null);
return explode(" ", $t);
} else {
return [];
}
}
// contactdb
@@ -3631,7 +3643,7 @@ function hotcrp_pc_json(Contact $user) {
$hpcj = $list = [];
foreach ($this->pc_members() as $pcm) {
$hpcj[$pcm->contactId] = $j = (object) ["name" => $user->name_text_for($pcm), "email" => $pcm->email];
if (($color_classes = $user->user_color_classes_for($pcm))) {
if (($color_classes = $pcm->viewable_color_classes($user))) {
$j->color_classes = $color_classes;
}
if ($this->sort_by_last && $pcm->lastName) {
@@ -3648,7 +3660,7 @@ function hotcrp_pc_json(Contact $user) {
$hpcj["__sort__"] = "last";
}
if ($user->can_view_user_tags()) {
$hpcj["__tags__"] = $user->viewable_user_tags();
$hpcj["__tags__"] = $this->viewable_user_tags($user);
}
if ($this->paper
&& ($user->privChair || $user->allow_administer($this->paper))) {
@@ -674,8 +674,11 @@ private function calculate_name_for($pfx, $user) {
$n = Text::name_html($user);
if ($pfx === "r"
&& isset($user->contactTags)
&& ($colors = $this->user_color_classes_for($user))) {
$n = '<span class="' . $colors . ' taghh">' . $n . '</span>';
&& ($viewable = $user->viewable_tags($this))) {
$dt = $this->conf->tags();
if (($colors = $dt->color_classes($viewable))) {
$n = '<span class="' . $colors . ' taghh">' . $n . '</span>';
}
}
return $n;
}
@@ -727,10 +730,6 @@ function reviewer_text_for($x) {
return $this->name_for("t", $x);
}
function user_color_classes_for(Contact $x) {
return $x->viewable_color_classes($this);
}
function ksort_cid_array(&$a) {
$pcm = $this->conf->pc_members();
uksort($a, function ($a, $b) use ($pcm) {
@@ -2215,16 +2214,6 @@ function can_view_user_tag($tag) {
return $this->can_view_user_tags()
&& $this->conf->tags()->strip_nonviewable($tag, $this, null) !== "";
}
function viewable_user_tags() {
if ($this->privChair)
return $this->conf->pc_tags();
else if ($this->can_view_pc() && $this->_can_view_pc > 1) {
$t = join(" ", $this->conf->pc_tags());
$t = $this->conf->tags()->strip_nonviewable($t, $this, null);
return explode(" ", $t);
} else
return [];
}
function can_view_tracker($tracker_json = null) {
return $this->privChair
@@ -121,7 +121,7 @@ function __construct($contact, $type, $papersel, $newrev_since) {
$this->defsel("pc_group", "Program committee", self::F_GROUP);
$selcount = count($this->sel);
$this->defsel("pc", "Program committee", self::F_ANYPC | self::F_NOPAPERS);
foreach ($this->contact->viewable_user_tags() as $t)
foreach ($this->conf->viewable_user_tags($this->contact) as $t)
if ($t !== "pc")
$this->defsel("pc:$t", "#$t program committee", self::F_ANYPC | self::F_NOPAPERS);
if (count($this->sel) == $selcount + 1)
@@ -16,9 +16,10 @@
$tOpt = [];
if ($Me->can_view_pc())
$tOpt["pc"] = "Program committee";
foreach ($Me->viewable_user_tags() as $t)
foreach ($Conf->viewable_user_tags($Me) as $t) {
if ($t !== "pc")
$tOpt["#$t"] = "#$t program committee";
}
if ($Me->can_view_pc() && $Me->isPC)
$tOpt["admin"] = "System administrators";
if ($Me->can_view_pc() && $Me->isPC && ($Qreq->t === "pcadmin" || $Qreq->t === "pcadminx"))

0 comments on commit dc32873

Please sign in to comment.
You can’t perform that action at this time.