2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2021-02-12 21:02:20 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2021-02-12 21:02:20 +00:00
|
|
|
class Biography extends Extension
|
|
|
|
{
|
|
|
|
/** @var BiographyTheme */
|
2023-06-27 14:56:49 +00:00
|
|
|
protected Themelet $theme;
|
2021-02-12 21:02:20 +00:00
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onUserPageBuilding(UserPageBuildingEvent $event): void
|
2021-02-12 21:02:20 +00:00
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
global $page, $user;
|
2021-02-12 21:02:20 +00:00
|
|
|
$duser = $event->display_user;
|
|
|
|
$duser_config = UserConfig::get_for_user($event->display_user->id);
|
|
|
|
$bio = $duser_config->get_string("biography", "");
|
|
|
|
|
|
|
|
if ($user->id == $duser->id) {
|
|
|
|
$this->theme->display_composer($page, $bio);
|
2021-02-26 23:55:00 +00:00
|
|
|
} else {
|
2021-02-12 21:02:20 +00:00
|
|
|
$this->theme->display_biography($page, $bio);
|
2021-02-26 23:55:00 +00:00
|
|
|
}
|
2021-02-12 21:02:20 +00:00
|
|
|
}
|
|
|
|
|
2024-01-15 11:52:35 +00:00
|
|
|
public function onPageRequest(PageRequestEvent $event): void
|
2021-02-12 21:02:20 +00:00
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
global $page, $user, $user_config;
|
2024-02-10 23:03:14 +00:00
|
|
|
if ($event->page_matches("biography", method: "POST")) {
|
2024-06-29 17:43:04 +00:00
|
|
|
$bio = $event->get_POST('biography');
|
|
|
|
log_info("biography", "Set biography to $bio");
|
|
|
|
$user_config->set_string("biography", $bio);
|
2024-02-10 23:03:14 +00:00
|
|
|
$page->flash("Bio Updated");
|
|
|
|
$page->set_mode(PageMode::REDIRECT);
|
|
|
|
$page->set_redirect(referer_or(make_link()));
|
2021-02-12 21:02:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|