X-Git-Url: https://git.mxchange.org/?p=friendica-addons.git;a=blobdiff_plain;f=numfriends%2Fnumfriends.php;h=5d6575c44a2b865888764e98b6803e0fc5b9e592;hp=2f48a0d7d369926412f381b7b9854a8f5ad5594c;hb=c71f7b0e1a7bb5ca88347b295dd3a4cc3106c5a9;hpb=0b459e83794fff75fc9cbd980738147e367becf4 diff --git a/numfriends/numfriends.php b/numfriends/numfriends.php old mode 100755 new mode 100644 index 2f48a0d7..5d6575c4 --- a/numfriends/numfriends.php +++ b/numfriends/numfriends.php @@ -4,15 +4,14 @@ * Description: Change number of contacts shown of profile sidebar * Version: 1.0 * Author: Mike Macgirvin - * - * */ - +use Friendica\Core\Addon; +use Friendica\Core\PConfig; function numfriends_install() { - register_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); - register_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); + Addon::registerHook('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); + Addon::registerHook('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); logger("installed numfriends"); } @@ -20,15 +19,13 @@ function numfriends_install() { function numfriends_uninstall() { - unregister_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); - unregister_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); + Addon::unregisterHook('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings'); + Addon::unregisterHook('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post'); logger("removed numfriends"); } - - /** * * Callback from the settings post function. @@ -37,29 +34,26 @@ function numfriends_uninstall() { * and if so set our configuration setting for this person. * */ - function numfriends_settings_post($a,$post) { if(! local_user() || (! x($_POST,'numfriends-submit'))) return; - set_pconfig(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); + PConfig::set(local_user(),'system','display_friend_count',intval($_POST['numfriends'])); info( t('Numfriends settings updated.') . EOL); } /** * - * Called from the Plugin Setting form. + * Called from the Addon Setting form. * Add our own settings info to the page. * */ - - - -function numfriends_settings(&$a,&$s) { - - if(! local_user()) +function numfriends_settings(&$a, &$s) +{ + if (! local_user()) { return; + } /* Add our stylesheet to the page so we can make our settings look nice */ @@ -67,9 +61,7 @@ function numfriends_settings(&$a,&$s) { /* Get the current state of our config variable */ - $numfriends = get_pconfig(local_user(),'system','display_friend_count'); - if($numfriends === false) - $numfriends = 24; + $numfriends = PConfig::get(local_user(), 'system', 'display_friend_count', 24); /* Add some HTML to the existing form */ @@ -83,5 +75,4 @@ function numfriends_settings(&$a,&$s) { /* provide a submit button */ $s .= '
'; - }