mirror of
https://github.com/friendica/friendica
synced 2025-04-23 19:10:13 +00:00
Move admin/blocklist/contact to src/Module
- Add Module\Admin\ContactBlock\Contact class - Add route for admin/blocklist/contact - Add contact blocklist admin aside menu entry - Move templates/admin/contactblock.tpl to templates/admin/blocklist/contact.tpl in base and frio - Remove admin_page_contactblock and admin_page_contactblock_post from mod/admin.php
This commit is contained in:
parent
446cb905e4
commit
cf885841c8
6 changed files with 97 additions and 92 deletions
89
src/Module/Admin/Blocklist/Contact.php
Normal file
89
src/Module/Admin/Blocklist/Contact.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Module\Admin\Blocklist;
|
||||
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Module\BaseAdminModule;
|
||||
use Friendica\Model;
|
||||
|
||||
class Contact extends BaseAdminModule
|
||||
{
|
||||
public static function post()
|
||||
{
|
||||
parent::post();
|
||||
|
||||
$contact_url = defaults($_POST, 'contact_url', '');
|
||||
$contacts = defaults($_POST, 'contacts', []);
|
||||
|
||||
parent::checkFormSecurityTokenRedirectOnError('/admin/blocklist/contact', 'admin_contactblock');
|
||||
|
||||
if (!empty($_POST['page_contactblock_block'])) {
|
||||
$contact_id = Model\Contact::getIdForURL($contact_url);
|
||||
if ($contact_id) {
|
||||
Model\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) {
|
||||
Model\Contact::unblock($uid);
|
||||
}
|
||||
notice(L10n::tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
|
||||
}
|
||||
|
||||
self::getApp()->internalRedirect('admin/blocklist/contact');
|
||||
}
|
||||
|
||||
public static function content()
|
||||
{
|
||||
parent::content();
|
||||
|
||||
$a = self::getApp();
|
||||
|
||||
$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/blocklist/contact.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' => parent::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;
|
||||
}
|
||||
}
|
|
@ -59,6 +59,9 @@ abstract class BaseAdminModule extends BaseModule
|
|||
'features' => ['admin/features' , L10n::t('Additional features') , 'features'],
|
||||
'tos' => ['admin/tos' , L10n::t('Terms of Service') , 'tos'],
|
||||
]],
|
||||
'tools' => [L10n::t('Tools'), [
|
||||
'contactblock' => ['admin/blocklist/contact', L10n::t('Contact Blocklist') , 'contactblock'],
|
||||
]],
|
||||
];
|
||||
|
||||
$addons_admin = [];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue