forked from friendica/friendica-addons
posted 3 seconds ago from _________
This commit is contained in:
parent
2dd4220084
commit
6c1a20968c
3 changed files with 98 additions and 0 deletions
BIN
fromapp.tgz
Normal file
BIN
fromapp.tgz
Normal file
Binary file not shown.
14
fromapp/fromapp.css
Normal file
14
fromapp/fromapp.css
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
|
||||
|
||||
#fromapp-label {
|
||||
float: left;
|
||||
width: 200px;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
#fromapp {
|
||||
float: left;
|
||||
}
|
||||
|
||||
|
84
fromapp/fromapp.php
Normal file
84
fromapp/fromapp.php
Normal file
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: FromApp
|
||||
* Description: Change the displayed application you are posting from
|
||||
* Version: 1.0
|
||||
* Author: Commander Zot
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
function fromapp_install() {
|
||||
|
||||
register_hook('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
|
||||
register_hook('plugin_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
|
||||
register_hook('plugin_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
|
||||
|
||||
logger("installed fromapp");
|
||||
}
|
||||
|
||||
|
||||
function fromapp_uninstall() {
|
||||
|
||||
unregister_hook('post_local', 'addon/fromapp/fromapp.php', 'fromapp_post_hook');
|
||||
unregister_hook('plugin_settings', 'addon/fromapp/fromapp.php', 'fromapp_settings');
|
||||
unregister_hook('plugin_settings_post', 'addon/fromapp/fromapp.php', 'fromapp_settings_post');
|
||||
|
||||
|
||||
logger("removed fromapp");
|
||||
}
|
||||
|
||||
function fromapp_settings_post($a,$post) {
|
||||
if(! local_user() || (! x($_POST,'fromapp-submit')))
|
||||
return;
|
||||
|
||||
set_pconfig(local_user(),'fromapp','app',$_POST['fromapp']);
|
||||
info( t('Fromapp settings updated.') . EOL);
|
||||
}
|
||||
|
||||
function fromapp_settings(&$a,&$s) {
|
||||
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||
|
||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/fromapp/fromapp.css' . '" media="all" />' . "\r\n";
|
||||
|
||||
/* Get the current state of our config variable */
|
||||
|
||||
$fromapp = get_pconfig(local_user(),'fromapp','app');
|
||||
if($fromapp === false)
|
||||
$fromapp = '';
|
||||
|
||||
/* Add some HTML to the existing form */
|
||||
|
||||
$s .= '<div class="settings-block">';
|
||||
$s .= '<h3>' . t('FromApp Settings') . '</h3>';
|
||||
$s .= '<div id="fromapp-wrapper">';
|
||||
$s .= '<label id="fromapp-label" for="fromapp">' . t('The application name you would like to show your posts originating from.') . '</label>';
|
||||
$s .= '<input id="fromapp-input" type="text" name="fromapp" value="' . $fromapp . '" ' . '/>';
|
||||
$s .= '</div><div class="clear"></div>';
|
||||
|
||||
/* provide a submit button */
|
||||
|
||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="fromapp-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
|
||||
|
||||
}
|
||||
|
||||
function fromapp_post_hook(&$a,&$item) {
|
||||
if(! local_user())
|
||||
return;
|
||||
|
||||
if(local_user() != $item['uid'])
|
||||
return;
|
||||
|
||||
$app = get_pconfig(local_user(), 'fromapp', 'app');
|
||||
|
||||
if(($app === false) || (! strlen($app)))
|
||||
return;
|
||||
|
||||
$item['app'] = $app;
|
||||
return;
|
||||
|
||||
}
|
Loading…
Reference in a new issue