X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=fromapp%2Ffromapp.php;h=51392ff57ba5500ffa0438ec15894983e9b20df0;hb=ba5eeed5df7f955d1c51b6d469ca361312349173;hp=9a9fa12ba970ac68c97cf83c9886056e21d9c49c;hpb=8f94568ada11948c5f69dbb7da721e27d82b69ab;p=friendica-addons.git diff --git a/fromapp/fromapp.php b/fromapp/fromapp.php index 9a9fa12b..51392ff5 100644 --- a/fromapp/fromapp.php +++ b/fromapp/fromapp.php @@ -7,6 +7,7 @@ * */ +use Friendica\Core\PConfig; function fromapp_install() { @@ -32,8 +33,8 @@ function fromapp_settings_post($a,$post) { if(! local_user() || (! x($_POST,'fromapp-submit'))) return; - set_pconfig(local_user(),'fromapp','app',$_POST['fromapp-input']); - set_pconfig(local_user(),'fromapp','force',intval($_POST['fromapp-force'])); + PConfig::set(local_user(),'fromapp','app',$_POST['fromapp-input']); + PConfig::set(local_user(),'fromapp','force',intval($_POST['fromapp-force'])); info( t('Fromapp settings updated.') . EOL); } @@ -49,19 +50,22 @@ function fromapp_settings(&$a,&$s) { /* Get the current state of our config variable */ - $fromapp = get_pconfig(local_user(),'fromapp','app'); - if($fromapp === false) - $fromapp = ''; + $fromapp = PConfig::get(local_user(),'fromapp', 'app', ''); - $force = intval(get_pconfig(local_user(),'fromapp','force')); + $force = intval(PConfig::get(local_user(),'fromapp','force')); $force_enabled = (($force) ? ' checked="checked" ' : ''); /* Add some HTML to the existing form */ - $s .= '
'; + $s .= ''; $s .= '

' . t('FromApp Settings') . '

'; + $s .= '
'; + $s .= ''; } -function fromapp_post_hook(&$a,&$item) { - if(! local_user()) - return; +function fromapp_post_hook(&$a, &$item) +{ + if (! local_user()) { + return; + } - if(local_user() != $item['uid']) - return; + if (local_user() != $item['uid']) { + return; + } - $app = get_pconfig(local_user(), 'fromapp', 'app'); - $force = intval(get_pconfig(local_user(), 'fromapp','force')); + $app = PConfig::get(local_user(), 'fromapp', 'app'); + $force = intval(PConfig::get(local_user(), 'fromapp', 'force')); - if(($app === false) || (! strlen($app))) - return; + if (is_null($app) || (! strlen($app))) { + return; + } - if(strlen(trim($item['app'])) && (! $force)) + if (strlen(trim($item['app'])) && (! $force)) { return; + } - $apps = explode(',',$app); - $item['app'] = trim($apps[mt_rand(0,count($apps)-1)]); + $apps = explode(',', $app); + $item['app'] = trim($apps[mt_rand(0, count($apps)-1)]); + return; - -} \ No newline at end of file +}