mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-27 11:22:26 +00:00
new plugin: profilehome
redirects from homepage to a selectable profile.
This commit is contained in:
parent
640c21f22f
commit
d261a47f76
2 changed files with 52 additions and 0 deletions
2
profilehome/admin.tpl
Executable file
2
profilehome/admin.tpl
Executable file
|
@ -0,0 +1,2 @@
|
|||
{{ inc field_select.tpl with $field=$user }}{{ endinc }}
|
||||
<div class="submit"><input type="submit" value="$submit" /></div>
|
50
profilehome/profilehome.php
Executable file
50
profilehome/profilehome.php
Executable file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Profile home
|
||||
* Description: Redirect from homepage to a profile
|
||||
* Version: 1.0
|
||||
* Author: Fabio Comuni <http://kirgroup.com/profile/fabrixxm>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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 = '<input type="hidden" name="form_security_token" value="' .get_form_security_token("profilehomesave") .'">';
|
||||
$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);
|
||||
}
|
Loading…
Reference in a new issue