[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:
parent
9453fda166
commit
5cbbe5e1b3
5 changed files with 21 additions and 25 deletions
|
@ -171,12 +171,6 @@ class User
|
||||||
return ($this->id === $config->get_int('anon_id'));
|
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
|
public function set_class(string $class): void
|
||||||
{
|
{
|
||||||
global $database;
|
global $database;
|
||||||
|
|
|
@ -68,20 +68,18 @@ class BulkActions extends Extension
|
||||||
{
|
{
|
||||||
global $page, $user;
|
global $page, $user;
|
||||||
|
|
||||||
if ($user->is_logged_in()) {
|
$babbe = new BulkActionBlockBuildingEvent();
|
||||||
$babbe = new BulkActionBlockBuildingEvent();
|
$babbe->search_terms = $event->search_terms;
|
||||||
$babbe->search_terms = $event->search_terms;
|
|
||||||
|
|
||||||
send_event($babbe);
|
send_event($babbe);
|
||||||
|
|
||||||
if (sizeof($babbe->actions) == 0) {
|
if (sizeof($babbe->actions) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
usort($babbe->actions, [$this, "sort_blocks"]);
|
|
||||||
|
|
||||||
$this->theme->display_selector($page, $babbe->actions, Tag::implode($event->search_terms));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
usort($babbe->actions, [$this, "sort_blocks"]);
|
||||||
|
|
||||||
|
$this->theme->display_selector($page, $babbe->actions, Tag::implode($event->search_terms));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
|
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
|
||||||
|
|
|
@ -551,13 +551,15 @@ class Pools extends Extension
|
||||||
|
|
||||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
|
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event): void
|
||||||
{
|
{
|
||||||
global $database;
|
global $database, $user;
|
||||||
|
|
||||||
$options = $database->get_pairs("SELECT id,title FROM pools ORDER BY title");
|
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.
|
// 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_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));
|
$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
|
public function onBulkAction(BulkActionEvent $event): void
|
||||||
|
|
|
@ -260,9 +260,8 @@ class TranscodeImage extends Extension
|
||||||
{
|
{
|
||||||
global $user, $config;
|
global $user, $config;
|
||||||
|
|
||||||
$engine = $config->get_string(TranscodeConfig::ENGINE);
|
|
||||||
|
|
||||||
if ($user->can(Permissions::EDIT_FILES)) {
|
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)));
|
$event->add_action(self::ACTION_BULK_TRANSCODE, "Transcode Image", null, "", $this->theme->get_transcode_picker_html($this->get_supported_output_mimes($engine)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -393,7 +393,10 @@ class UserPage extends Extension
|
||||||
$this->theme->display_user_links($page, $user, $ubbe->get_parts());
|
$this->theme->display_user_links($page, $user, $ubbe->get_parts());
|
||||||
}
|
}
|
||||||
if (
|
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
|
($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(
|
$this->theme->display_ip_list(
|
||||||
|
|
Reference in a new issue