case 'logs':
admin_page_logs_post($a);
break;
- case 'contactblock':
- admin_page_contactblock_post($a);
- break;
case 'blocklist':
admin_page_blocklist_post($a);
break;
case 'workerqueue':
$o = admin_page_workerqueue($a, false);
break;
- case 'contactblock':
- $o = admin_page_contactblock($a);
- break;
case 'blocklist':
$o = admin_page_blocklist($a);
break;
return; // NOTREACHED
}
-/**
- * @brief Process data send by the contact block admin page
- *
- * @param App $a
- * @throws ImagickException
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
-function admin_page_contactblock_post(App $a)
-{
- $contact_url = defaults($_POST, 'contact_url', '');
- $contacts = defaults($_POST, 'contacts', []);
-
- BaseModule::checkFormSecurityTokenRedirectOnError('/admin/contactblock', 'admin_contactblock');
-
- if (!empty($_POST['page_contactblock_block'])) {
- $contact_id = Contact::getIdForURL($contact_url);
- if ($contact_id) {
- Contact::block($contact_id);
- notice(L10n::t('The contact has been blocked from the node'));
- } else {
- notice(L10n::t("Could not find any contact entry for this URL \x28%s\x29", $contact_url));
- }
- }
- if (!empty($_POST['page_contactblock_unblock'])) {
- foreach ($contacts as $uid) {
- Contact::unblock($uid);
- }
- notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
- }
- $a->internalRedirect('admin/contactblock');
- return; // NOTREACHED
-}
-
-/**
- * @brief Admin panel for server-wide contact block
- *
- * @param App $a
- * @return string
- * @throws \Friendica\Network\HTTPException\InternalServerErrorException
- */
-function admin_page_contactblock(App $a)
-{
- $condition = ['uid' => 0, 'blocked' => true];
-
- $total = DBA::count('contact', $condition);
-
- $pager = new Pager($a->query_string, 30);
-
- $statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
-
- $contacts = DBA::toArray($statement);
-
- $t = Renderer::getMarkupTemplate('admin/contactblock.tpl');
- $o = Renderer::replaceMacros($t, [
- // strings //
- '$title' => L10n::t('Administration'),
- '$page' => L10n::t('Remote Contact Blocklist'),
- '$description' => L10n::t('This page allows you to prevent any message from a remote contact to reach your node.'),
- '$submit' => L10n::t('Block Remote Contact'),
- '$select_all' => L10n::t('select all'),
- '$select_none' => L10n::t('select none'),
- '$block' => L10n::t('Block'),
- '$unblock' => L10n::t('Unblock'),
- '$no_data' => L10n::t('No remote contact is blocked from this node.'),
-
- '$h_contacts' => L10n::t('Blocked Remote Contacts'),
- '$h_newblock' => L10n::t('Block New Remote Contact'),
- '$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Address'), L10n::t('Profile URL')],
-
- '$form_security_token' => BaseModule::getFormSecurityToken("admin_contactblock"),
-
- // values //
- '$baseurl' => System::baseUrl(true),
-
- '$contacts' => $contacts,
- '$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),
- '$paginate' => $pager->renderFull($total),
- '$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],
- ]);
- return $o;
-}
-
/**
* @brief Subpage where the admin can delete an item from their node given the GUID
*
$collector->addRoute(['GET', 'POST'], '/addons' , Module\Admin\Addons\Index::class);
$collector->addRoute(['GET', 'POST'], '/addons/{addon}' , Module\Admin\Addons\Details::class);
+ $collector->addRoute(['GET', 'POST'], '/blocklist/contact' , Module\Admin\Blocklist\Contact::class);
$collector->addRoute(['GET', 'POST'], '/features' , Module\Admin\Features::class);
$collector->addRoute(['GET'] , '/federation' , Module\Admin\Federation::class);
--- /dev/null
+<?php\r
+\r
+namespace Friendica\Module\Admin\Blocklist;\r
+\r
+use Friendica\Content\Pager;\r
+use Friendica\Core\L10n;\r
+use Friendica\Core\Renderer;\r
+use Friendica\Core\System;\r
+use Friendica\Database\DBA;\r
+use Friendica\Module\BaseAdminModule;\r
+use Friendica\Model;\r
+\r
+class Contact extends BaseAdminModule\r
+{\r
+ public static function post()\r
+ {\r
+ parent::post();\r
+\r
+ $contact_url = defaults($_POST, 'contact_url', '');\r
+ $contacts = defaults($_POST, 'contacts', []);\r
+\r
+ parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock');\r
+\r
+ if (!empty($_POST['page_contactblock_block'])) {\r
+ $contact_id = Model\Contact::getIdForURL($contact_url);\r
+ if ($contact_id) {\r
+ Model\Contact::block($contact_id);\r
+ notice(L10n::t('The contact has been blocked from the node'));\r
+ } else {\r
+ notice(L10n::t("Could not find any contact entry for this URL \x28%s\x29", $contact_url));\r
+ }\r
+ }\r
+\r
+ if (!empty($_POST['page_contactblock_unblock'])) {\r
+ foreach ($contacts as $uid) {\r
+ Model\Contact::unblock($uid);\r
+ }\r
+ notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));\r
+ }\r
+\r
+ self::getApp()->internalRedirect('admin/blocklist/contact');\r
+ }\r
+\r
+ public static function content()\r
+ {\r
+ parent::content();\r
+\r
+ $a = self::getApp();\r
+\r
+ $condition = ['uid' => 0, 'blocked' => true];\r
+\r
+ $total = DBA::count('contact', $condition);\r
+\r
+ $pager = new Pager($a->query_string, 30);\r
+\r
+ $statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);\r
+\r
+ $contacts = DBA::toArray($statement);\r
+\r
+ $t = Renderer::getMarkupTemplate('admin/blocklist/contact.tpl');\r
+ $o = Renderer::replaceMacros($t, [\r
+ // strings //\r
+ '$title' => L10n::t('Administration'),\r
+ '$page' => L10n::t('Remote Contact Blocklist'),\r
+ '$description' => L10n::t('This page allows you to prevent any message from a remote contact to reach your node.'),\r
+ '$submit' => L10n::t('Block Remote Contact'),\r
+ '$select_all' => L10n::t('select all'),\r
+ '$select_none' => L10n::t('select none'),\r
+ '$block' => L10n::t('Block'),\r
+ '$unblock' => L10n::t('Unblock'),\r
+ '$no_data' => L10n::t('No remote contact is blocked from this node.'),\r
+\r
+ '$h_contacts' => L10n::t('Blocked Remote Contacts'),\r
+ '$h_newblock' => L10n::t('Block New Remote Contact'),\r
+ '$th_contacts' => [L10n::t('Photo'), L10n::t('Name'), L10n::t('Address'), L10n::t('Profile URL')],\r
+\r
+ '$form_security_token' => parent::getFormSecurityToken("admin_contactblock"),\r
+\r
+ // values //\r
+ '$baseurl' => System::baseUrl(true),\r
+\r
+ '$contacts' => $contacts,\r
+ '$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),\r
+ '$paginate' => $pager->renderFull($total),\r
+ '$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],\r
+ ]);\r
+ return $o;\r
+ }\r
+}
\ No newline at end of file
'features' => ['admin/features' , L10n::t('Additional features') , 'features'],\r
'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'],\r
]],\r
+ 'tools' => [L10n::t('Tools'), [\r
+ 'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist') , 'contactblock'],\r
+ ]],\r
];\r
\r
$addons_admin = [];\r
--- /dev/null
+<script>
+ function selectall(cls) {
+ $('.' + cls).prop('checked', true);
+ return false;
+ }
+ function selectnone(cls) {
+ $('.' + cls).prop('checked', false);
+ return false;
+ }
+</script>
+<div id="adminpage">
+ <h1>{{$title}} - {{$page}}</h1>
+ <p>{{$description nofilter}}</p>
+ <form action="{{$baseurl}}/admin/blocklist/contact" method="post">
+ <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+
+ <h3>{{$h_contacts}}</h3>
+ {{if $contacts}}
+ <table id="contactblock">
+ <thead>
+ <tr>
+ <th></th>
+ {{foreach $th_contacts as $th}}
+ <th>
+ {{$th}}
+ </th>
+ {{/foreach}}
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{foreach $contacts as $contact}}
+ <tr>
+ <td class="checkbox"><input type="checkbox" class="contacts_ckbx" id="id_contact_{{$contact.id}}" name="contacts[]" value="{{$contact.id}}"/></td>
+ <td><img class="icon" src="{{$contact.micro}}" alt="{{$contact.nickname}}" title="{{$contact.nickname}}"></td>
+ <td class="name">{{$contact.name}}</td>
+ <td class="addr">{{$contact.addr}}</td>
+ <td class="addr"><a href="{{$contact.url}}" title="{{$contact.nickname}}" >{{$contact.url}}</a></td>
+ </tr>
+ {{/foreach}}
+ </tbody>
+ </table>
+ <p><a href="#" onclick="return selectall('contacts_ckbx');">{{$select_all}}</a> | <a href="#" onclick="return selectnone('contacts_ckbx');">{{$select_none}}</a></p>
+ {{$paginate nofilter}}
+ <div class="submit"><input type="submit" name="page_contactblock_unblock" value="{{$unblock}}" /></div>
+ {{else}}
+ <p>{{$no_data}}</p>
+ {{/if}}
+ </form>
+
+ <h3>{{$h_newblock}}</h3>
+ <form action="{{$baseurl}}/admin/blocklist/contact" method="post">
+ <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+ <table id="contactblock">
+ <tbody>
+ <tr>
+ <td>{{include file="field_input.tpl" field=$contacturl}}</td>
+ </tr>
+ </tbody>
+ </table>
+ <div class="submit"><input type="submit" name="page_contactblock_block" value="{{$submit}}" /></div>
+ </form>
+</div>
+++ /dev/null
-<script>
- function selectall(cls) {
- $('.' + cls).prop('checked', true);
- return false;
- }
- function selectnone(cls) {
- $('.' + cls).prop('checked', false);
- return false;
- }
-</script>
-<div id="adminpage">
- <h1>{{$title}} - {{$page}}</h1>
- <p>{{$description nofilter}}</p>
- <form action="{{$baseurl}}/admin/contactblock" method="post">
- <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
-
- <h3>{{$h_contacts}}</h3>
- {{if $contacts}}
- <table id="contactblock">
- <thead>
- <tr>
- <th></th>
- {{foreach $th_contacts as $th}}
- <th>
- {{$th}}
- </th>
- {{/foreach}}
- <th></th>
- </tr>
- </thead>
- <tbody>
- {{foreach $contacts as $contact}}
- <tr>
- <td class="checkbox"><input type="checkbox" class="contacts_ckbx" id="id_contact_{{$contact.id}}" name="contacts[]" value="{{$contact.id}}"/></td>
- <td><img class="icon" src="{{$contact.micro}}" alt="{{$contact.nickname}}" title="{{$contact.nickname}}"></td>
- <td class="name">{{$contact.name}}</td>
- <td class="addr">{{$contact.addr}}</td>
- <td class="addr"><a href="{{$contact.url}}" title="{{$contact.nickname}}" >{{$contact.url}}</a></td>
- </tr>
- {{/foreach}}
- </tbody>
- </table>
- <p><a href="#" onclick="return selectall('contacts_ckbx');">{{$select_all}}</a> | <a href="#" onclick="return selectnone('contacts_ckbx');">{{$select_none}}</a></p>
- {{$paginate nofilter}}
- <div class="submit"><input type="submit" name="page_contactblock_unblock" value="{{$unblock}}" /></div>
- {{else}}
- <p>{{$no_data}}</p>
- {{/if}}
- </form>
-
- <h3>{{$h_newblock}}</h3>
- <form action="{{$baseurl}}/admin/contactblock" method="post">
- <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
- <table id="contactblock">
- <tbody>
- <tr>
- <td>{{include file="field_input.tpl" field=$contacturl}}</td>
- </tr>
- </tbody>
- </table>
- <div class="submit"><input type="submit" name="page_contactblock_block" value="{{$submit}}" /></div>
- </form>
-</div>
--- /dev/null
+<script type="text/javascript" src="view/theme/frio/js/mod_admin.js"></script>
+<link rel="stylesheet" href="view/theme/frio/css/mod_admin.css" type="text/css" media="screen"/>
+
+<div id="admin-contactblock" class="adminpage generic-page-wrapper">
+ <h1>{{$title}} - {{$page}}</h1>
+ <p>{{$description nofilter}}</p>
+
+ {{* We organize the settings in collapsable panel-groups *}}
+ <div class="panel-group panel-group-settings" id="admin-settings" role="tablist" aria-multiselectable="true">
+ {{* The form for entering user profile which should be blocked *}}
+ <div class="panel">
+ <div class="section-subtitle-wrapper" role="tab" id="admin-settings-contactblock-block">
+ <h4>
+ <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#admin-settings" href="#admin-settings-contactblock-block-collapse" aria-expanded="false" aria-controls="admin-settings-contactblock-block-collapse">
+ {{$h_newblock}}
+ </a>
+ </h4>
+ </div>
+
+ <div id="admin-settings-contactblock-block-collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="admin-settings-contactblock-block">
+ <form action="{{$baseurl}}/admin/blocklist/contact" method="post">
+ <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+
+ {{include file="field_input.tpl" field=$contacturl}}
+
+ <div class="admin-settings-submit-wrapper form-group pull-right">
+ <button type="submit" class="btn btn-primary" name="page_contactblock_block" value="1">{{$submit}}</button>
+ </div>
+ <div class="clear"></div>
+ </form>
+ </div>
+ </div>
+
+ {{* The list of blocked user profiles with the possibility to unblock them *}}
+ <div class="panel">
+ <div class="section-subtitle-wrapper" role="tab" id="admin-settings-contactblock-blocked">
+ <h4>
+ <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#admin-settings" href="#admin-settings-contactblock-blocked-collapse" aria-expanded="{{if count($contacts) > 0}}true{{else}}false{{/if}}" aria-controls="admin-settings-contactblock-blocked-collapse">
+ {{$h_contacts}} ({{count($contacts)}})
+ </a>
+ </h4>
+ </div>
+
+ <div id="admin-settings-contactblock-blocked-collapse" class="panel-collapse collapse {{if count($contacts) > 0}}in{{/if}}" role="tabpanel" aria-labelledby="admin-settings-contactblock-blocked">
+ <form action="{{$baseurl}}/admin/blocklist/contact" method="post">
+ <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
+
+ {{if $contacts}}
+ <table id="contactblock" class="table table-condensed table-striped">
+ <thead>
+ <tr>
+ <th></th>
+ {{foreach $th_contacts as $th}}
+ <th>
+ {{$th}}
+ </th>
+ {{/foreach}}
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{foreach $contacts as $contact}}
+ <tr>
+ <td>
+ <div class="checkbox">
+ <input type="checkbox" class="contacts_ckbx" id="id_contact_{{$contact.id}}" name="contacts[]" value="{{$contact.id}}"/>
+ <label for="id_contact_{{$contact.id}}"></label>
+ </div>
+ </td>
+ <td><img class="icon" src="{{$contact.micro}}" alt="{{$contact.nickname}}" title="{{$contact.addr}}"></td>
+ <td class="name">{{$contact.name}}</td>
+ <td class="addr" colspan="3"><a href="{{$contact.url}}" title="{{$contact.addr}}" >{{$contact.url}}</a></td>
+ </tr>
+ {{/foreach}}
+ </tbody>
+ <tfoot>
+ <tr>
+ <td>
+ {{* Checkbox to select all blocked contacts *}}
+ <div class="checkbox">
+ <input type="checkbox" id="contactblock-select" class="selecttoggle contacts_ckbx" data-select-class="contacts_ckbx" data-select-all="{{$select_all}}" data-select-none="{{$select_none}}" title="{{$select_all}}"/>
+ <label for="contactblock-select"></label>
+ </div>
+ </td>
+ <td colspan="5">
+ {{$total_contacts}}
+ <div class="admin-settings-submit-wrapper form-group pull-right">
+ <button type="submit" class="btn btn-small btn-default pull-right" name="page_contactblock_unblock" value="1">{{$unblock}}</button>
+ </div>
+ <div class="clear"></div>
+ </td>
+ </tr>
+ </tfoot>
+ </table>
+
+ {{$paginate nofilter}}
+
+ {{else}}
+ <p>{{$no_data}}</p>
+ {{/if}}
+ </form>
+ </div>
+ </div>
+ </div>
+</div>
+++ /dev/null
-<script type="text/javascript" src="view/theme/frio/js/mod_admin.js"></script>
-<link rel="stylesheet" href="view/theme/frio/css/mod_admin.css" type="text/css" media="screen"/>
-
-<div id="admin-contactblock" class="adminpage generic-page-wrapper">
- <h1>{{$title}} - {{$page}}</h1>
- <p>{{$description nofilter}}</p>
-
- {{* We organize the settings in collapsable panel-groups *}}
- <div class="panel-group panel-group-settings" id="admin-settings" role="tablist" aria-multiselectable="true">
- {{* The form for entering user profile which should be blocked *}}
- <div class="panel">
- <div class="section-subtitle-wrapper" role="tab" id="admin-settings-contactblock-block">
- <h4>
- <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#admin-settings" href="#admin-settings-contactblock-block-collapse" aria-expanded="false" aria-controls="admin-settings-contactblock-block-collapse">
- {{$h_newblock}}
- </a>
- </h4>
- </div>
-
- <div id="admin-settings-contactblock-block-collapse" class="panel-collapse collapse" role="tabpanel" aria-labelledby="admin-settings-contactblock-block">
- <form action="{{$baseurl}}/admin/contactblock" method="post">
- <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
-
- {{include file="field_input.tpl" field=$contacturl}}
-
- <div class="admin-settings-submit-wrapper form-group pull-right">
- <button type="submit" class="btn btn-primary" name="page_contactblock_block" value="1">{{$submit}}</button>
- </div>
- <div class="clear"></div>
- </form>
- </div>
- </div>
-
- {{* The list of blocked user profiles with the possibility to unblock them *}}
- <div class="panel">
- <div class="section-subtitle-wrapper" role="tab" id="admin-settings-contactblock-blocked">
- <h4>
- <a class="accordion-toggle collapsed" data-toggle="collapse" data-parent="#admin-settings" href="#admin-settings-contactblock-blocked-collapse" aria-expanded="{{if count($contacts) > 0}}true{{else}}false{{/if}}" aria-controls="admin-settings-contactblock-blocked-collapse">
- {{$h_contacts}} ({{count($contacts)}})
- </a>
- </h4>
- </div>
-
- <div id="admin-settings-contactblock-blocked-collapse" class="panel-collapse collapse {{if count($contacts) > 0}}in{{/if}}" role="tabpanel" aria-labelledby="admin-settings-contactblock-blocked">
- <form action="{{$baseurl}}/admin/contactblock" method="post">
- <input type="hidden" name="form_security_token" value="{{$form_security_token}}">
-
- {{if $contacts}}
- <table id="contactblock" class="table table-condensed table-striped">
- <thead>
- <tr>
- <th></th>
- {{foreach $th_contacts as $th}}
- <th>
- {{$th}}
- </th>
- {{/foreach}}
- <th></th>
- </tr>
- </thead>
- <tbody>
- {{foreach $contacts as $contact}}
- <tr>
- <td>
- <div class="checkbox">
- <input type="checkbox" class="contacts_ckbx" id="id_contact_{{$contact.id}}" name="contacts[]" value="{{$contact.id}}"/>
- <label for="id_contact_{{$contact.id}}"></label>
- </div>
- </td>
- <td><img class="icon" src="{{$contact.micro}}" alt="{{$contact.nickname}}" title="{{$contact.addr}}"></td>
- <td class="name">{{$contact.name}}</td>
- <td class="addr" colspan="3"><a href="{{$contact.url}}" title="{{$contact.addr}}" >{{$contact.url}}</a></td>
- </tr>
- {{/foreach}}
- </tbody>
- <tfoot>
- <tr>
- <td>
- {{* Checkbox to select all blocked contacts *}}
- <div class="checkbox">
- <input type="checkbox" id="contactblock-select" class="selecttoggle contacts_ckbx" data-select-class="contacts_ckbx" data-select-all="{{$select_all}}" data-select-none="{{$select_none}}" title="{{$select_all}}"/>
- <label for="contactblock-select"></label>
- </div>
- </td>
- <td colspan="5">
- {{$total_contacts}}
- <div class="admin-settings-submit-wrapper form-group pull-right">
- <button type="submit" class="btn btn-small btn-default pull-right" name="page_contactblock_unblock" value="1">{{$unblock}}</button>
- </div>
- <div class="clear"></div>
- </td>
- </tr>
- </tfoot>
- </table>
-
- {{$paginate nofilter}}
-
- {{else}}
- <p>{{$no_data}}</p>
- {{/if}}
- </form>
- </div>
- </div>
- </div>
-</div>