4 * Description: Set a preferred page to load on login from home page
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
11 function startpage_install() {
12 register_hook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
13 register_hook('plugin_settings', 'addon/startpage/startpage.php', 'startpage_settings');
14 register_hook('plugin_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
18 function startpage_uninstall() {
19 unregister_hook('home_init', 'addon/startpage/startpage.php', 'startpage_home_init');
20 unregister_hook('plugin_settings', 'addon/startpage/startpage.php', 'startpage_settings');
21 unregister_hook('plugin_settings_post', 'addon/startpage/startpage.php', 'startpage_settings_post');
26 function startpage_home_init($a, $b) {
30 $page = get_pconfig(local_user(),'startpage','startpage');
32 $slash = ((strpos($page,'/') === 0) ? true : false);
33 if(stristr($page,'://'))
35 goaway($a->get_baseurl() . (($slash) ? '' : '/') . $page);
42 * Callback from the settings post function.
43 * $post contains the $_POST array.
44 * We will make sure we've got a valid user account
45 * and if so set our configuration setting for this person.
49 function startpage_settings_post($a,$post) {
52 if($_POST['startpage-submit'])
53 set_pconfig(local_user(),'startpage','startpage',strip_tags(trim($_POST['startpage'])));
59 * Called from the Plugin Setting form.
60 * Add our own settings info to the page.
66 function startpage_settings(&$a,&$s) {
71 /* Add our stylesheet to the page so we can make our settings look nice */
73 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/startpage/startpage.css' . '" media="all" />' . "\r\n";
75 /* Get the current state of our config variable */
77 $page = get_pconfig(local_user(),'startpage','startpage');
80 /* Add some HTML to the existing form */
82 $s .= '<span id="settings_startpage_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
83 $s .= '<h3>' . t('Startpage') . '</h3>';
85 $s .= '<div id="settings_startpage_expanded" class="settings-block" style="display: none;">';
86 $s .= '<span class="fakelink" onclick="openClose(\'settings_startpage_expanded\'); openClose(\'settings_startpage_inflated\');">';
87 $s .= '<h3>' . t('Startpage') . '</h3>';
89 $s .= '<div id="startpage-page-wrapper">';
90 $s .= '<label id="startpage-page-label" for="startpage-page">' . t('Home page to load after login - leave blank for profile wall') . '</label>';
91 $s .= '<input id="startpage-page" type="text" name="startpage" value="' . $page . '" />';
92 $s .= '</div><div class="clear"></div>';
93 $s .= '<div id="startpage-desc">' . t('Examples: "network" or "notifications/system"') . '</div>';
95 /* provide a submit button */
97 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="startpage-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';