4 * Description: Change number of contacts shown of profile sidebar
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
10 use Friendica\Core\Hook;
11 use Friendica\Core\Logger;
12 use Friendica\Core\Renderer;
15 function numfriends_install() {
17 Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
18 Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
20 Logger::notice("installed numfriends");
25 * Callback from the settings post function.
26 * $post contains the $_POST array.
27 * We will make sure we've got a valid user account
28 * and if so set our configuration setting for this person.
31 function numfriends_settings_post($post) {
32 if (! DI::userSession()->getLocalUserId() || empty($_POST['numfriends-submit'])) {
36 DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', intval($_POST['numfriends']));
42 * Called from the Addon Setting form.
43 * Add our own settings info to the page.
46 function numfriends_settings(array &$data)
48 if (!DI::userSession()->getLocalUserId()) {
52 $numfriends = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'display_friend_count', 24);
54 $t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/');
55 $html = Renderer::replaceMacros($t, [
56 '$numfriends' => ['numfriends', DI::l10n()->t('How many contacts to display on profile sidebar'), $numfriends],
60 'addon' => 'numfriends',
61 'title' => DI::l10n()->t('Numfriends Settings'),