From d261a47f76a5176bf62aca797ebaefd4ad160256 Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Thu, 14 Jun 2012 06:50:22 -0400 Subject: [PATCH] new plugin: profilehome redirects from homepage to a selectable profile. --- profilehome/admin.tpl | 2 ++ profilehome/profilehome.php | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 profilehome/admin.tpl create mode 100755 profilehome/profilehome.php diff --git a/profilehome/admin.tpl b/profilehome/admin.tpl new file mode 100755 index 00000000..cf7bc1a7 --- /dev/null +++ b/profilehome/admin.tpl @@ -0,0 +1,2 @@ +{{ inc field_select.tpl with $field=$user }}{{ endinc }} +
\ No newline at end of file diff --git a/profilehome/profilehome.php b/profilehome/profilehome.php new file mode 100755 index 00000000..ad0421b8 --- /dev/null +++ b/profilehome/profilehome.php @@ -0,0 +1,50 @@ + + */ + + + +function profilehome_install() { + register_hook('home_content', 'addon/profilehome/profilehome.php', 'profilehome_home'); + logger("installed profilehome"); +} + +function profilehome_uninstall() { + unregister_hook('home_content', 'addon/profilehome/profilehome.php', 'profilehome_home'); + logger("removed profilehome"); +} + +function profilehome_home(&$a, &$o){ + $user = get_config("profilehome","user"); + if ($user!==false) goaway($a->get_baseurl()."/profile/".$user); +} + +function profilehome_plugin_admin(&$a, &$o){ + $r = q("SELECT nickname, username FROM user WHERE verified=1 AND account_removed=0 AND account_expired=0"); + $users = array("##no##"=>"No redirect (use default home)"); + foreach ($r as $u) { + $users[$u['nickname']] = $u['username']." (".$u['nickname'].")"; + } + + $user = get_config("profilehome","user"); + + $t = file_get_contents(dirname(__file__)."/admin.tpl"); + $o = ''; + $o .= replace_macros( $t, array( + '$submit' => t('Submit'), + '$user' => array('user', t('Profile to use as home page'), $user, "", $users), + )); +} + +function profilehome_plugin_admin_post(&$a){ + check_form_security_token('profilehomesave'); + + $user = ((x($_POST, 'user')) ? notags(trim($_POST['user'])) : false); + if ($user=='##no##') $user=false; + set_config('profilehome', 'user', $user); + info( t('Profile home settings updated.') .EOL); +} \ No newline at end of file -- 2.39.5