4 * Description: Change number of contacts shown of profile sidebar
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
11 use Friendica\Core\PConfig;
13 function numfriends_install() {
15 register_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
16 register_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
18 logger("installed numfriends");
22 function numfriends_uninstall() {
24 unregister_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
25 unregister_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
28 logger("removed numfriends");
35 * Callback from the settings post function.
36 * $post contains the $_POST array.
37 * We will make sure we've got a valid user account
38 * and if so set our configuration setting for this person.
42 function numfriends_settings_post($a,$post) {
43 if(! local_user() || (! x($_POST,'numfriends-submit')))
46 PConfig::set(local_user(),'system','display_friend_count',intval($_POST['numfriends']));
47 info( t('Numfriends settings updated.') . EOL);
53 * Called from the Plugin Setting form.
54 * Add our own settings info to the page.
60 function numfriends_settings(&$a,&$s) {
65 /* Add our stylesheet to the page so we can make our settings look nice */
67 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/numfriends/numfriends.css' . '" media="all" />' . "\r\n";
69 /* Get the current state of our config variable */
71 $numfriends = PConfig::get(local_user(),'system','display_friend_count');
72 if($numfriends === false)
75 /* Add some HTML to the existing form */
77 $s .= '<div class="settings-block">';
78 $s .= '<h3>' . t('Numfriends Settings') . '</h3>';
79 $s .= '<div id="numfriends-wrapper">';
80 $s .= '<label id="numfriends-label" for="numfriends">' . t('How many contacts to display on profile sidebar') . '</label>';
81 $s .= '<input id="numfriends-input" type="text" name="numfriends" value="' . intval($numfriends) . '" ' . '/>';
82 $s .= '</div><div class="clear"></div>';
84 /* provide a submit button */
86 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="numfriends-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';