Skip to content
Permalink
Browse files

Users can also have badges and emoji.

  • Loading branch information...
kohler committed Oct 28, 2019
1 parent dc32873 commit 679807402517cdf0d085a1c43818aba104b8827a
Showing with 77 additions and 27 deletions.
  1. +9 −4 lib/tagger.php
  2. +55 −20 log.php
  3. +4 −0 src/contact.php
  4. +6 −0 src/contactlist.php
  5. +3 −3 stylesheets/style.css
@@ -854,7 +854,9 @@ static function unparse_emoji_html($e, $count) {
return $b . '</span>';
}
function unparse_decoration_html($tags) {
const DECOR_PAPER = 0;
const DECOR_USER = 1;
function unparse_decoration_html($tags, $type = 0) {
if (is_array($tags)) {
$tags = join(" ", $tags);
}
@@ -882,7 +884,7 @@ function unparse_decoration_html($tags) {
$count = max($count, (float) $value);
}
$b = self::unparse_emoji_html($e, $count);
if (!empty($links)) {
if ($type === self::DECOR_PAPER && !empty($links)) {
$b = '<a class="qq" href="' . $this->conf->hoturl("search", ["q" => join(" OR ", $links)]) . '">' . $b . '</a>';
}
if ($x === "") {
@@ -897,10 +899,13 @@ function unparse_decoration_html($tags) {
if (($t = $dt->check($mx[1])) && $t->badges) {
$klass = ' class="badge ' . $t->badges[0] . 'badge"';
$tag = $this->unparse(trim($mx[0]));
if (($link = $this->link($tag))) {
if ($type === self::DECOR_PAPER && ($link = $this->link($tag))) {
$b = '<a href="' . $link . '"' . $klass . '>#' . $tag . '</a>';
} else {
$b = '<span' . $klass . '>#' . $tag . '</span>';
if ($type !== self::DECOR_USER) {
$tag = '#' . $tag;
}
$b = '<span' . $klass . '>' . $tag . '</span>';
}
$x .= ' ' . $b;
}
75 log.php
@@ -555,34 +555,69 @@ function searchbar(LogRowGenerator $lrg, $page) {
}
// render rows
$user_html = [];
function set_user_html($user, $qreq_n) {
global $Conf, $Me, $user_html;
if (($pc = $Conf->pc_member_by_id($user->contactId))) {
$user = $pc;
}
$t = Text::name_html($user);
if ($user->disabled === "deleted") {
$t = '<del>' . $t . ' &lt;' . htmlspecialchars($user->email) . '&gt;</del>';
}
if (($viewable = $user->viewable_tags($Me))) {
$dt = $Conf->tags();
if (($colors = $dt->color_classes($viewable))) {
$t = '<span class="' . $colors . ' taghh">' . $t . '</span>';
}
}
$t = '<a href="' . $Conf->hoturl("log", ["q" => "", "u" => $user->email, "n" => $qreq_n]) . '">' . $t . '</a>';
if ($viewable && $dt->has_decoration) {
$tagger = new Tagger($Me);
$t .= $tagger->unparse_decoration_html($viewable, Tagger::DECOR_USER);
}
$roles = 0;
if (isset($user->roles) && ($user->roles & Contact::ROLE_PCLIKE)) {
$roles = $user->viewable_pc_roles($Me);
}
if (!($roles & Contact::ROLE_PCLIKE)) {
$t .= ' &lt;' . htmlspecialchars($user->email) . '&gt;';
}
if ($roles !== 0 && ($rolet = Contact::role_html_for($roles))) {
$t .= " $rolet";
}
$user_html[$user->contactId] = $t;
return $t;
}
function render_users($users, $via) {
global $Conf, $Qreq, $Me;
global $Conf, $Qreq, $Me, $user_html;
$all_pc = true;
$ts = [];
usort($users, "Contact::compare");
foreach ($users as $user) {
if ($all_pc && (!isset($user->roles) || !($user->roles & Contact::ROLE_PCLIKE)))
if ($all_pc
&& (!isset($user->roles) || !($user->roles & Contact::ROLE_PCLIKE))) {
$all_pc = false;
if (!$user->email && $user->disabled === "deleted")
return '<del>[deleted user ' . $user->contactId . ']</del>';
else {
$t = $Me->reviewer_html_for($user);
if ($user->disabled === "deleted")
$t = "<del>" . $t . " &lt;" . htmlspecialchars($user->email) . "&gt;</del>";
else {
$t = '<a href="' . hoturl("log", ["q" => "", "u" => $user->email, "n" => $Qreq->n]) . '">' . $t . '</a>';
$roles = 0;
if (isset($user->roles) && ($user->roles & Contact::ROLE_PCLIKE))
$roles = $user->viewable_pc_roles($Me);
if (!($roles & Contact::ROLE_PCLIKE))
$t .= ' &lt;' . htmlspecialchars($user->email) . '&gt;';
if ($roles !== 0 && ($rolet = Contact::role_html_for($roles)))
$t .= " $rolet";
if ($via)
$t .= ($via < 0 ? ' <i>via link</i>' : ' <i>via admin</i>');
}
if ($user->disabled === "deleted") {
if ($user->email) {
$t = '<del>' . Text::name_html($user) . ' &lt;' . htmlspecialchars($user->email) . '&gt;</del>';
} else {
$t = '<del>[deleted user ' . $user->contactId . ']</del>';
}
} else {
if (isset($user_html[$user->contactId])) {
$t = $user_html[$user->contactId];
} else {
$t = set_user_html($user, $Qreq->n);
}
if ($via) {
$t .= ($via < 0 ? ' <i>via link</i>' : ' <i>via admin</i>');
}
$ts[] = $t;
}
$ts[] = $t;
}
if (count($ts) <= 3) {
return join(", ", $ts);
@@ -679,6 +679,10 @@ private function calculate_name_for($pfx, $user) {
if (($colors = $dt->color_classes($viewable))) {
$n = '<span class="' . $colors . ' taghh">' . $n . '</span>';
}
if ($dt->has_decoration) {
$tagger = new Tagger($this);
$n .= $tagger->unparse_decoration_html($viewable, Tagger::DECOR_USER);
}
}
return $n;
}
@@ -281,6 +281,12 @@ function content($fieldId, $row) {
$t = '<span class="taghl">' . $t . '</span>';
if ($this->user->privChair) {
$t = "<a href=\"" . hoturl("profile", "u=" . urlencode($row->email) . $this->contactLinkArgs) . "\"" . ($row->is_disabled() ? ' class="uu"' : "") . ">$t</a>";
}
if (($viewable = $row->viewable_tags($this->user))
&& $this->conf->tags()->has_decoration) {
$tagger = new Tagger($this->user);
$t .= $tagger->unparse_decoration_html($viewable, Tagger::DECOR_USER);
}
$roles = $row->viewable_pc_roles($this->user);
if ($roles === Contact::ROLE_PC && $this->limit === "pc") {
$roles = 0;
@@ -2027,12 +2027,12 @@ td.pl_lastvisit, td.pl_logtime {
display: inline-block;
font-size: 69%;
line-height: 1;
padding: 2px 0.3em 2px;
background-color: #cccccc;
padding: 2px 0.3em 3px;
border-radius: 0.3em;
bottom: 1px;
position: relative;
bottom: 1px;
white-space: nowrap;
background: #cccccc;
font-weight: bold;
}
.aumovebox {

0 comments on commit 6798074

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