mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-05 07:42:55 +00:00
04df7f6e05
- added more type-hints - cleaned up some files (curly braces, spaces)
64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Name: Numfriends
|
|
* Description: Change number of contacts shown of profile sidebar
|
|
* Version: 1.0
|
|
* Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
|
|
*/
|
|
|
|
use Friendica\App;
|
|
use Friendica\Core\Hook;
|
|
use Friendica\Core\Logger;
|
|
use Friendica\Core\Renderer;
|
|
use Friendica\DI;
|
|
|
|
function numfriends_install() {
|
|
|
|
Hook::register('addon_settings', 'addon/numfriends/numfriends.php', 'numfriends_settings');
|
|
Hook::register('addon_settings_post', 'addon/numfriends/numfriends.php', 'numfriends_settings_post');
|
|
|
|
Logger::notice("installed numfriends");
|
|
}
|
|
|
|
/**
|
|
*
|
|
* Callback from the settings post function.
|
|
* $post contains the $_POST array.
|
|
* We will make sure we've got a valid user account
|
|
* and if so set our configuration setting for this person.
|
|
*
|
|
*/
|
|
function numfriends_settings_post(App $a, $post) {
|
|
if (! local_user() || empty($_POST['numfriends-submit'])) {
|
|
return;
|
|
}
|
|
|
|
DI::pConfig()->set(local_user(), 'system', 'display_friend_count', intval($_POST['numfriends']));
|
|
}
|
|
|
|
|
|
/**
|
|
*
|
|
* Called from the Addon Setting form.
|
|
* Add our own settings info to the page.
|
|
*
|
|
*/
|
|
function numfriends_settings(App &$a, array &$data)
|
|
{
|
|
if (!local_user()) {
|
|
return;
|
|
}
|
|
|
|
$numfriends = DI::pConfig()->get(local_user(), 'system', 'display_friend_count', 24);
|
|
|
|
$t = Renderer::getMarkupTemplate('settings.tpl', 'addon/numfriends/');
|
|
$html = Renderer::replaceMacros($t, [
|
|
'$numfriends' => ['numfriends', DI::l10n()->t('How many contacts to display on profile sidebar'), $numfriends],
|
|
]);
|
|
|
|
$data = [
|
|
'addon' => 'numfriends',
|
|
'title' => DI::l10n()->t('Numfriends Settings'),
|
|
'html' => $html,
|
|
];
|
|
}
|