streams/Zotlabs/Widget/Follow.php

42 lines
968 B
PHP
Raw Normal View History

2017-03-16 01:48:27 +00:00
<?php
namespace Zotlabs\Widget;
2020-03-04 02:00:20 +00:00
use App;
2017-03-16 01:48:27 +00:00
class Follow {
function widget($args) {
2020-03-04 02:00:20 +00:00
if (! local_channel()) {
return EMPTY_STR;
}
$uid = App::$channel['channel_id'];
2017-03-16 01:48:27 +00:00
$r = q("select count(*) as total from abook where abook_channel = %d and abook_self = 0 ",
intval($uid)
);
2020-03-04 02:00:20 +00:00
if ($r) {
2017-03-16 01:48:27 +00:00
$total_channels = $r[0]['total'];
2020-03-04 02:00:20 +00:00
}
2017-03-16 01:48:27 +00:00
$limit = service_class_fetch($uid,'total_channels');
2020-03-04 02:00:20 +00:00
if ($limit !== false) {
2017-03-16 01:48:27 +00:00
$abook_usage_message = sprintf( t("You have %1$.0f of %2$.0f allowed connections."), $total_channels, $limit);
}
else {
2020-03-04 02:00:20 +00:00
$abook_usage_message = EMPTY_STR;
2017-03-16 01:48:27 +00:00
}
2020-03-04 02:00:20 +00:00
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'),
2017-03-16 01:48:27 +00:00
'$abook_usage_message' => $abook_usage_message
2020-03-04 02:00:20 +00:00
]);
2017-03-16 01:48:27 +00:00
}
}