fromapp force setting

This commit is contained in:
friendica 2012-09-24 17:21:30 -07:00
parent 1ea5df563f
commit 8f94568ada
3 changed files with 21 additions and 5 deletions

Binary file not shown.

View File

@ -1,13 +1,13 @@
#fromapp-label { #fromapp-label, #fromapp-force-label {
float: left; float: left;
width: 200px; width: 200px;
margin-bottom: 25px; margin-bottom: 25px;
} }
#fromapp { #fromapp-input, #fromapp-force {
float: left; float: left;
} }

View File

@ -32,7 +32,9 @@ function fromapp_settings_post($a,$post) {
if(! local_user() || (! x($_POST,'fromapp-submit'))) if(! local_user() || (! x($_POST,'fromapp-submit')))
return; return;
set_pconfig(local_user(),'fromapp','app',$_POST['fromapp']); set_pconfig(local_user(),'fromapp','app',$_POST['fromapp-input']);
set_pconfig(local_user(),'fromapp','force',intval($_POST['fromapp-force']));
info( t('Fromapp settings updated.') . EOL); info( t('Fromapp settings updated.') . EOL);
} }
@ -51,13 +53,23 @@ function fromapp_settings(&$a,&$s) {
if($fromapp === false) if($fromapp === false)
$fromapp = ''; $fromapp = '';
$force = intval(get_pconfig(local_user(),'fromapp','force'));
$force_enabled = (($force) ? ' checked="checked" ' : '');
/* Add some HTML to the existing form */ /* Add some HTML to the existing form */
$s .= '<div class="settings-block">'; $s .= '<div class="settings-block">';
$s .= '<h3>' . t('FromApp Settings') . '</h3>'; $s .= '<h3>' . t('FromApp Settings') . '</h3>';
$s .= '<div id="fromapp-wrapper">'; $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 .= '<label id="fromapp-label" for="fromapp-input">' . 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 .= '<input id="fromapp-input" type="text" name="fromapp-input" value="' . $fromapp . '" ' . '/>';
$s .= '<div class="clear"></div>';
$s .= '<label id="fromapp-force-label" for="fromapp-force">' . t('Use this application name even if another application was used.') . '</label>';
$s .= '<input id="fromapp-force" type="checkbox" name="fromapp-force" value="1" ' . $force_enabled . '/>';
$s .= '</div><div class="clear"></div>'; $s .= '</div><div class="clear"></div>';
/* provide a submit button */ /* provide a submit button */
@ -74,10 +86,14 @@ function fromapp_post_hook(&$a,&$item) {
return; return;
$app = get_pconfig(local_user(), 'fromapp', 'app'); $app = get_pconfig(local_user(), 'fromapp', 'app');
$force = intval(get_pconfig(local_user(), 'fromapp','force'));
if(($app === false) || (! strlen($app))) if(($app === false) || (! strlen($app)))
return; return;
if(strlen(trim($item['app'])) && (! $force))
return;
$apps = explode(',',$app); $apps = explode(',',$app);
$item['app'] = trim($apps[mt_rand(0,count($apps)-1)]); $item['app'] = trim($apps[mt_rand(0,count($apps)-1)]);
return; return;