4 * Description: Set a preferred page to load on login from home page
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
11 use Friendica\Core\Hook;
12 use Friendica\Core\Renderer;
15 function startpage_install() {
16 Hook::register('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
17 Hook::register('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings');
18 Hook::register('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
21 function startpage_home_init(App $a, $b)
23 if (!DI::userSession()->getLocalUserId()) {
27 $page = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'startpage', 'startpage');
29 DI::baseUrl()->redirect($page);
35 * Callback from the settings post function.
36 * $post contains the $_POST array.
37 * We will make sure we've got a valid user account
38 * and if so set our configuration setting for this person.
42 function startpage_settings_post(App $a, $post)
44 if (!DI::userSession()->getLocalUserId()) {
48 if (!empty($_POST['startpage-submit'])) {
49 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'startpage', 'startpage', strip_tags(trim($_POST['startpage'])));
55 * Called from the Addon Setting form.
56 * Add our own settings info to the page.
59 function startpage_settings(App &$a, array &$data)
61 if (!DI::userSession()->getLocalUserId()) {
65 $startpage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'startpage', 'startpage');
67 $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/startpage/');
68 $html = Renderer::replaceMacros($t, [
69 '$startpage' => ['startpage', DI::l10n()->t('Home page to load after login - leave blank for profile wall'), $startpage, DI::l10n()->t('Examples: "network" or "notifications/system"')],
73 'addon' => 'startpage',
74 'title' => DI::l10n()->t('Startpage'),