Added $user_config global based on existing config object for storing user-specific settings.

Added event to the user page so that extensions can hook into it, providing user-specific setting controls
This commit is contained in:
Matthew Barbour
2019-06-26 22:11:53 -05:00
committed by matthew
parent 8e3b8a7a1b
commit 8f0aa8a4ca
6 changed files with 129 additions and 20 deletions

View File

@@ -19,6 +19,17 @@ class UserBlockBuildingEvent extends Event
}
}
class UserOptionsBuildingEvent extends Event
{
/** @var array */
public $parts = [];
public function add__html(string $html)
{
$this->parts[] = $html;
}
}
class UserPageBuildingEvent extends Event
{
/** @var User */
@@ -254,6 +265,17 @@ class UserPage extends Extension
ksort($event->stats);
$this->theme->display_user_page($event->display_user, $event->stats);
if (!$user->is_anonymous()) {
if ($user->id == $event->display_user->id || $user->can("edit_user_info")) {
$uobe = new UserOptionsBuildingEvent();
send_event($uobe);
$page->add_block(new Block("Options", $this->theme->build_options($event->display_user, $uobe), "main", 60));
}
}
if ($user->id == $event->display_user->id) {
$ubbe = new UserBlockBuildingEvent();
send_event($ubbe);