4 * Description: Set a preferred page to load on login from home page
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
9 use Friendica\Core\Hook;
12 function startpage_install() {
13 Hook::register('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
14 Hook::register('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings');
15 Hook::register('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
18 function startpage_home_init($a, $b)
24 $page = DI::pConfig()->get(local_user(), 'startpage', 'startpage');
26 DI::baseUrl()->redirect($page);
33 * Callback from the settings post function.
34 * $post contains the $_POST array.
35 * We will make sure we've got a valid user account
36 * and if so set our configuration setting for this person.
40 function startpage_settings_post($a, $post)
46 if (!empty($_POST['startpage-submit'])) {
47 DI::pConfig()->set(local_user(), 'startpage', 'startpage', strip_tags(trim($_POST['startpage'])));
53 * Called from the Addon Setting form.
54 * Add our own settings info to the page.
57 function startpage_settings(&$a, &$s)
63 /* Add our stylesheet to the page so we can make our settings look nice */
65 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n";
67 /* Get the current state of our config variable */
69 $page = DI::pConfig()->get(local_user(), 'startpage', 'startpage');
71 /* Add some HTML to the existing form */
73 $s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
74 $s .= '<h3>' . DI::l10n()->t('Startpage') . '</h3>';
76 $s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">';
77 $s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
78 $s .= '<h3>' . DI::l10n()->t('Startpage') . '</h3>';
80 $s .= '<div id="startpage-page-wrapper">';
81 $s .= '<label id="startpage-page-label" for="startpage-page">' . DI::l10n()->t('Home page to load after login - leave blank for profile wall') . '</label>';
82 $s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />';
83 $s .= '</div><div class="clear"></div>';
84 $s .= '<div id="startpage-desc">' . DI::l10n()->t('Examples: "network" or "notifications/system"') . '</div>';
86 /* provide a submit button */
88 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . DI::l10n()->t('Save Settings') . '" /></div></div>';