2017-03-16 01:48:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zotlabs\Widget;
|
|
|
|
|
2020-03-04 02:00:20 +00:00
|
|
|
use App;
|
2022-01-25 04:37:14 +00:00
|
|
|
use Zotlabs\Lib\ServiceClass;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
return replace_macros(get_markup_template('follow.tpl'), [
|
|
|
|
'$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
|
|
|
}
|