3 namespace Friendica\Module\Admin\Blocklist;
\r
5 use Friendica\Content\Pager;
\r
6 use Friendica\Core\L10n;
\r
7 use Friendica\Core\Renderer;
\r
8 use Friendica\Core\System;
\r
9 use Friendica\Database\DBA;
\r
10 use Friendica\Module\BaseAdminModule;
\r
11 use Friendica\Model;
\r
13 class Contact extends BaseAdminModule
\r
15 public static function post()
\r
19 $contact_url = defaults($_POST, 'contact_url', '');
\r
20 $contacts = defaults($_POST, 'contacts', []);
\r
22 parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock');
\r
24 if (!empty($_POST['page_contactblock_block'])) {
\r
25 $contact_id = Model\Contact::getIdForURL($contact_url);
\r
27 Model\Contact::block($contact_id);
\r
28 notice(L10n::t('The contact has been blocked from the node'));
\r
30 notice(L10n::t("Could not find any contact entry for this URL \x28%s\x29", $contact_url));
\r
34 if (!empty($_POST['page_contactblock_unblock'])) {
\r
35 foreach ($contacts as $uid) {
\r
36 Model\Contact::unblock($uid);
\r
38 notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
\r
41 self::getApp()->internalRedirect('admin/blocklist/contact');
\r
44 public static function content()
\r
48 $a = self::getApp();
\r
50 $condition = ['uid' => 0, 'blocked' => true];
\r
52 $total = DBA::count('contact', $condition);
\r
54 $pager = new Pager($a->query_string, 30);
\r
56 $statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
\r
58 $contacts = DBA::toArray($statement);
\r
60 $t = Renderer::getMarkupTemplate('admin/blocklist/contact.tpl');
\r
61 $o = Renderer::replaceMacros($t, [
\r
63 '$title' => L10n::t('Administration'),
\r
64 '$page' => L10n::t('Remote Contact Blocklist'),
\r
65 '$description' => L10n::t('This page allows you to prevent any message from a remote contact to reach your node.'),
\r
66 '$submit' => L10n::t('Block Remote Contact'),
\r
67 '$select_all' => L10n::t('select all'),
\r
68 '$select_none' => L10n::t('select none'),
\r
69 '$block' => L10n::t('Block'),
\r
70 '$unblock' => L10n::t('Unblock'),
\r
71 '$no_data' => L10n::t('No remote contact is blocked from this node.'),
\r
73 '$h_contacts' => L10n::t('Blocked Remote Contacts'),
\r
74 '$h_newblock' => L10n::t('Block New Remote Contact'),
\r
75 '$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Address'), L10n::t('Profile URL')],
\r
77 '$form_security_token' => parent::getFormSecurityToken("admin_contactblock"),
\r
80 '$baseurl' => System::baseUrl(true),
\r
82 '$contacts' => $contacts,
\r
83 '$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),
\r
84 '$paginate' => $pager->renderFull($total),
\r
85 '$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],
\r