[core] remove is_logged_in

This was only used in a couple of places, and user classes are more useful
This commit is contained in:
Shish 2024-05-04 15:43:29 +01:00 committed by Shish
parent 9453fda166
commit 5cbbe5e1b3
5 changed files with 21 additions and 25 deletions

View file

@ -171,12 +171,6 @@ class User
return ($this->id === $config->get_int('anon_id'));
}
public function is_logged_in(): bool
{
global $config;
return ($this->id !== $config->get_int('anon_id'));
}
public function set_class(string $class): void
{
global $database;

View file

@ -68,7 +68,6 @@ class BulkActions extends Extension
{
global $page, $user;
if ($user->is_logged_in()) {
$babbe = new BulkActionBlockBuildingEvent();
$babbe->search_terms = $event->search_terms;
@ -82,7 +81,6 @@ class BulkActions extends Extension
$this->theme->display_selector($page, $babbe->actions, Tag::implode($event->search_terms));
}
}
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
{

View file

@ -551,14 +551,16 @@ class Pools extends Extension
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
{
global $database;
global $database, $user;
if(!$user->can(Permissions::POOLS_UPDATE)) {
$options = $database->get_pairs("SELECT id,title FROM pools ORDER BY title");
// TODO: Don't cast into strings, make BABBE accept HTMLElement instead.
$event->add_action("bulk_pool_add_existing", "Add To (P)ool", "p", "", (string) $this->theme->get_bulk_pool_selector($options));
$event->add_action("bulk_pool_add_new", "Create Pool", "", "", (string) $this->theme->get_bulk_pool_input($event->search_terms));
}
}
public function onBulkAction(BulkActionEvent $event): void
{

View file

@ -260,9 +260,8 @@ class TranscodeImage extends Extension
{
global $user, $config;
$engine = $config->get_string(TranscodeConfig::ENGINE);
if ($user->can(Permissions::EDIT_FILES)) {
$engine = $config->get_string(TranscodeConfig::ENGINE);
$event->add_action(self::ACTION_BULK_TRANSCODE, "Transcode Image", null, "", $this->theme->get_transcode_picker_html($this->get_supported_output_mimes($engine)));
}
}

View file

@ -393,7 +393,10 @@ class UserPage extends Extension
$this->theme->display_user_links($page, $user, $ubbe->get_parts());
}
if (
($user->can(Permissions::VIEW_IP) || ($user->is_logged_in() && $user->id == $event->display_user->id)) && # admin or self-user
(
$user->can(Permissions::VIEW_IP) || # user can view all IPS
($user->id == $event->display_user->id) # or user is viewing themselves
) &&
($event->display_user->id != $config->get_int('anon_id')) # don't show anon's IP list, it is le huge
) {
$this->theme->display_ip_list(