streams/Code/Widget/Follow.php

46 lines
1.1 KiB
PHP
Raw Normal View History

2017-03-16 01:48:27 +00:00
<?php
2022-02-16 04:08:28 +00:00
namespace Code\Widget;
2017-03-16 01:48:27 +00:00
2020-03-04 02:00:20 +00:00
use App;
2022-02-16 04:08:28 +00:00
use Code\Lib\ServiceClass;
use Code\Render\Theme;
2022-02-12 20:43:29 +00:00
2022-01-25 04:37:14 +00:00
2021-12-02 23:02:31 +00:00
class Follow
{
public function widget($args)
{
if (!local_channel()) {
return EMPTY_STR;
}
$uid = App::$channel['channel_id'];
2021-12-03 03:01:39 +00:00
$r = q(
"select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
2021-12-02 23:02:31 +00:00
intval($uid)
);
if ($r) {
$total_channels = $r[0]['total'];
}
2022-01-25 04:37:14 +00:00
$limit = ServiceClass::fetch($uid, 'total_channels');
2021-12-02 23:02:31 +00:00
if ($limit !== false) {
$abook_usage_message = sprintf(t("You have %1$.0f of %2$.0f allowed connections."), $total_channels, $limit);
} else {
$abook_usage_message = EMPTY_STR;
}
2022-02-12 20:43:29 +00:00
return replace_macros(Theme::get_template('follow.tpl'), [
2021-12-02 23:02:31 +00:00
'$connect' => t('Add New Connection'),
'$desc' => t('Enter channel address'),
'$hint' => t('Examples: bob@example.com, https://example.com/barbara'),
'$follow' => t('Connect'),
'$abook_usage_message' => $abook_usage_message
]);
}
2017-03-16 01:48:27 +00:00
}