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;
10 use Friendica\Core\L10n;
13 function startpage_install() {
14 Hook::register('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
15 Hook::register('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings');
16 Hook::register('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
19 function startpage_uninstall()
21 Hook::unregister('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
22 Hook::unregister('addon_settings', 'addon/startpage/startpage.php', 'startpage_settings');
23 Hook::unregister('addon_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
26 function startpage_home_init($a, $b)
32 $page = DI::pConfig()->get(local_user(), 'startpage', 'startpage');
34 DI::baseUrl()->redirect($page);
41 * Callback from the settings post function.
42 * $post contains the $_POST array.
43 * We will make sure we've got a valid user account
44 * and if so set our configuration setting for this person.
48 function startpage_settings_post($a, $post)
54 if (!empty($_POST['startpage-submit'])) {
55 DI::pConfig()->set(local_user(), 'startpage', 'startpage', strip_tags(trim($_POST['startpage'])));
61 * Called from the Addon Setting form.
62 * Add our own settings info to the page.
65 function startpage_settings(&$a, &$s)
71 /* Add our stylesheet to the page so we can make our settings look nice */
73 DI::page()['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . DI::baseUrl()->get() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n";
75 /* Get the current state of our config variable */
77 $page = DI::pConfig()->get(local_user(), 'startpage', 'startpage');
79 /* Add some HTML to the existing form */
81 $s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
82 $s .= '<h3>' . L10n::t('Startpage') . '</h3>';
84 $s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">';
85 $s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
86 $s .= '<h3>' . L10n::t('Startpage') . '</h3>';
88 $s .= '<div id="startpage-page-wrapper">';
89 $s .= '<label id="startpage-page-label" for="startpage-page">' . L10n::t('Home page to load after login - leave blank for profile wall') . '</label>';
90 $s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />';
91 $s .= '</div><div class="clear"></div>';
92 $s .= '<div id="startpage-desc">' . L10n::t('Examples: "network" or "notifications/system"') . '</div>';
94 /* provide a submit button */
96 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div></div>';