This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/biography/main.php

39 lines
1.1 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
2021-02-12 21:02:20 +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
public function onUserPageBuilding(UserPageBuildingEvent $event): void
2021-02-12 21:02:20 +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
}
public function onPageRequest(PageRequestEvent $event): void
2021-02-12 21:02:20 +00:00
{
global $page, $user, $user_config;
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);
$page->flash("Bio Updated");
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(referer_or(make_link()));
2021-02-12 21:02:20 +00:00
}
}
}