mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 08:29:06 +00:00
Improve info badge generation, ensure expired bans don't show as active
This commit is contained in:
parent
001dc85648
commit
4a3eb465c0
@ -161,6 +161,11 @@ tr.hover {
|
|||||||
background-color: #ee5555;
|
background-color: #ee5555;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.litebans-label-ipmute {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #ee5555;
|
||||||
|
}
|
||||||
|
|
||||||
/* history.php */
|
/* history.php */
|
||||||
.litebans-label-history {
|
.litebans-label-history {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
79
info.php
79
info.php
@ -51,16 +51,34 @@ abstract class Info {
|
|||||||
return $this->page->get_avatar($banner_name, $row['banned_by_uuid'], true, $this->history_link($banner_name, $row['banned_by_uuid'], ':issued'), $name_left = false);
|
return $this->page->get_avatar($banner_name, $row['banned_by_uuid'], true, $this->history_link($banner_name, $row['banned_by_uuid'], ':issued'), $name_left = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function badge($name) {
|
||||||
|
return "<span class=\"{$this->page->settings->info_badge_classes} litebans-label-info litebans-label-$name\">" . $this->page->t("generic.$name") . "</span>";
|
||||||
|
}
|
||||||
|
|
||||||
function get_info() {
|
function get_info() {
|
||||||
$settings = $this->page->settings;
|
$settings = $this->page->settings;
|
||||||
$table = array(
|
$table = array(
|
||||||
'table.player' => function (Info $info) { return $info->punished_avatar(); },
|
'table.player' => function (Info $info) {
|
||||||
'table.executor' => function (Info $info) { return $info->moderator_avatar(); },
|
return $info->punished_avatar();
|
||||||
'table.reason' => function (Info $info) { return $info->page->clean($info->row['reason']); },
|
},
|
||||||
'table.date' => function (Info $info) { return $info->page->millis_to_date($info->row['time']); },
|
'table.executor' => function (Info $info) {
|
||||||
'table.expires' => function (Info $info) { return $info->page->expiry($info->row); },
|
return $info->moderator_avatar();
|
||||||
'table.server.scope' => function (Info $info) { return $info->page->server($info->row); },
|
},
|
||||||
'table.server.origin' => function (Info $info) { return $info->page->server($info->row, "server_origin"); },
|
'table.reason' => function (Info $info) {
|
||||||
|
return $info->page->clean($info->row['reason']);
|
||||||
|
},
|
||||||
|
'table.date' => function (Info $info) {
|
||||||
|
return $info->page->millis_to_date($info->row['time']);
|
||||||
|
},
|
||||||
|
'table.expires' => function (Info $info) {
|
||||||
|
return $info->page->expiry($info->row);
|
||||||
|
},
|
||||||
|
'table.server.scope' => function (Info $info) {
|
||||||
|
return $info->page->server($info->row);
|
||||||
|
},
|
||||||
|
'table.server.origin' => function (Info $info) {
|
||||||
|
return $info->page->server($info->row, "server_origin");
|
||||||
|
},
|
||||||
);
|
);
|
||||||
if (!$settings->info_show_server_scope) unset($table['table.server.scope']);
|
if (!$settings->info_show_server_scope) unset($table['table.server.scope']);
|
||||||
if (!$settings->info_show_server_origin) unset($table['table.server.origin']);
|
if (!$settings->info_show_server_origin) unset($table['table.server.origin']);
|
||||||
@ -73,21 +91,34 @@ class BanInfo extends Info {
|
|||||||
function get_info() {
|
function get_info() {
|
||||||
$array = parent::get_info();
|
$array = parent::get_info();
|
||||||
if ($this->page->active($this->row) === false) {
|
if ($this->page->active($this->row) === false) {
|
||||||
$array["table.reason.unban"] = function (Info $info) { return $info->page->clean($info->row['removed_by_reason']); };
|
$array["table.reason.unban"] = function (Info $info) {
|
||||||
|
return $info->page->clean($info->row['removed_by_reason']);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MuteInfo extends Info {
|
class MuteInfo extends Info {
|
||||||
function get_info() {
|
function get_info() {
|
||||||
$array = parent::get_info();
|
$array = parent::get_info();
|
||||||
if ($this->page->active($this->row) === false) {
|
if ($this->page->active($this->row) === false) {
|
||||||
$array["table.reason.unmute"] = function (Info $info) { return $info->page->clean($info->row['removed_by_reason']); };
|
$array["table.reason.unmute"] = function (Info $info) {
|
||||||
|
return $info->page->clean($info->row['removed_by_reason']);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function badge($badgeClasses, $name) {
|
||||||
|
if ($name === "ipban") $name = "ipmute";
|
||||||
|
return parent::badge($badgeClasses, $name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
class WarnInfo extends Info {}
|
|
||||||
|
class WarnInfo extends Info {
|
||||||
|
}
|
||||||
|
|
||||||
//+
|
//+
|
||||||
|
|
||||||
class KickInfo extends Info {
|
class KickInfo extends Info {
|
||||||
@ -146,33 +177,23 @@ if ($st->execute()) {
|
|||||||
|
|
||||||
$header = $page->name;
|
$header = $page->name;
|
||||||
$badges = "";
|
$badges = "";
|
||||||
$bc = $page->settings->info_badge_classes;
|
|
||||||
|
|
||||||
if (!($info instanceof KickInfo)) {
|
if (!($info instanceof KickInfo)) {
|
||||||
$active = $page->active($row);
|
$expired = $page->is_expired($row);
|
||||||
|
$active = !$expired && $page->active($row);
|
||||||
$ipban = $page->active($row, 'ipban');
|
$ipban = $page->active($row, 'ipban');
|
||||||
if ($ipban === true) {
|
if ($ipban === true) {
|
||||||
$idx = null;
|
$badges .= $info->badge("ipban");
|
||||||
if ($info instanceof BanInfo) {
|
|
||||||
$idx = "generic.ipban";
|
|
||||||
} else if ($info instanceof MuteInfo) {
|
|
||||||
$idx = "generic.ipmute";
|
|
||||||
}
|
|
||||||
if ($idx !== null) {
|
|
||||||
$badges .= "<span class='$bc litebans-label-info litebans-label-ipban'>" . $page->t($idx) . "</span>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($active === true) {
|
if ($active) {
|
||||||
$badges .= "<span class='$bc litebans-label-info litebans-label-active'>" . $page->t("generic.active") . "</span>";
|
$badges .= $info->badge("active");
|
||||||
if ($permanent) {
|
if ($permanent) {
|
||||||
$badges .= "<span class='$bc litebans-label-info litebans-label-permanent'>" . $page->t("generic.permanent") . "</span>";
|
$badges .= $info->badge("permanent");
|
||||||
}
|
}
|
||||||
|
} else if ($expired) {
|
||||||
|
$badges .= $info->badge("expired");
|
||||||
} else {
|
} else {
|
||||||
if ($page->is_expired($row)) {
|
$badges .= $info->badge("inactive");
|
||||||
$badges .= "<span class='$bc litebans-label-info litebans-label-expired'>" . $page->t("generic.expired") . "</span>";
|
|
||||||
} else {
|
|
||||||
$badges .= "<span class='$bc litebans-label-info litebans-label-inactive'>" . $page->t("generic.inactive") . "</span>";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$page->print_header(true, $header . "<div class=\"noalign-w litebans-label-container\">$badges</div>");
|
$page->print_header(true, $header . "<div class=\"noalign-w litebans-label-container\">$badges</div>");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user