4 * Description: Change number of contacts shown of profile sidebar
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
12 function numfriends_install() {
14 register_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
15 register_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
17 logger("installed numfriends");
21 function numfriends_uninstall() {
23 unregister_hook('plugin_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
24 unregister_hook('plugin_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
27 logger("removed numfriends");
34 * Callback from the settings post function.
35 * $post contains the $_POST array.
36 * We will make sure we've got a valid user account
37 * and if so set our configuration setting for this person.
41 function numfriends_settings_post($a,$post) {
42 if(! local_user() || (! x($_POST,'numfriends-submit')))
45 set_pconfig(local_user(),'system','display_friend_count',intval($_POST['numfriends']));
46 info( t('Numfriends settings updated.') . EOL);
52 * Called from the Plugin Setting form.
53 * Add our own settings info to the page.
59 function numfriends_settings(&$a,&$s) {
64 /* Add our stylesheet to the page so we can make our settings look nice */
66 $a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/numfriends/numfriends.css' . '" media="all" />' . "\r\n";
68 /* Get the current state of our config variable */
70 $numfriends = get_pconfig(local_user(),'system','display_friend_count');
71 if($numfriends === false)
74 /* Add some HTML to the existing form */
76 $s .= '<div class="settings-block">';
77 $s .= '<h3>' . t('Numfriends Settings') . '</h3>';
78 $s .= '<div id="numfriends-wrapper">';
79 $s .= '<label id="numfriends-label" for="numfriends">' . t('How many contacts to display on profile sidebar') . '</label>';
80 $s .= '<input id="numfriends-input" type="text" name="numfriends" value="' . intval($numfriends) . '" ' . '/>';
81 $s .= '</div><div class="clear"></div>';
83 /* provide a submit button */
85 $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="numfriends-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';