<?php
-
/**
* @file mod/admin.php
*
* @brief Friendica admin
*/
use Friendica\App;
+use Friendica\Content\Feature;
use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Model\User;
+use Friendica\Object\Contact;
require_once 'include/enotify.php';
require_once 'include/text.php';
*/
function admin_post(App $a)
{
-
-
if (!is_site_admin()) {
return;
}
case 'dbsync':
admin_page_dbsync_post($a);
break;
+ case 'contactblock':
+ admin_page_contactblock_post($a);
+ break;
case 'blocklist':
admin_page_blocklist_post($a);
break;
*/
function admin_content(App $a)
{
-
if (!is_site_admin()) {
return login(false);
}
// apc_delete($toDelete);
//}
// Header stuff
- $a->page['htmlhead'] .= replace_macros(get_markup_template('admin_settings_head.tpl'), array());
+ $a->page['htmlhead'] .= replace_macros(get_markup_template('admin/settings_head.tpl'), array());
/*
* Side bar links
'features' => array("admin/features/" , t("Additional features") , "features"),
'dbsync' => array("admin/dbsync/" , t('DB updates') , "dbsync"),
'queue' => array("admin/queue/" , t('Inspect Queue') , "queue"),
+ 'contactblock' => array("admin/contactblock/", t('Contact Blocklist') , "contactblock"),
'blocklist' => array("admin/blocklist/" , t('Server Blocklist') , "blocklist"),
'federation' => array("admin/federation/" , t('Federation Statistics'), "federation"),
'deleteitem' => array("admin/deleteitem/" , t('Delete Item') , 'deleteitem'),
$aside_tools['diagnostics_probe'] = array('probe/', t('probe address'), 'probe');
$aside_tools['diagnostics_webfinger'] = array('webfinger/', t('check webfinger'), 'webfinger');
- $t = get_markup_template("admin_aside.tpl");
+ $t = get_markup_template('admin/aside.tpl');
$a->page['aside'] .= replace_macros($t, array(
'$admin' => $aside_tools,
'$subpages' => $aside_sub,
'$admurl' => "admin/"
));
-
-
- /*
- * Page content
- */
+ // Page content
$o = '';
// urls
if ($a->argc > 1) {
case 'federation':
$o = admin_page_federation($a);
break;
+ case 'contactblock':
+ $o = admin_page_contactblock($a);
+ break;
case 'blocklist':
$o = admin_page_blocklist($a);
break;
);
}
}
- $t = get_markup_template("admin_blocklist.tpl");
+ $t = get_markup_template('admin/blocklist.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Server Blocklist'),
return; // NOTREACHED
}
+/**
+ * @brief Process data send by the contact block admin page
+ *
+ * @param App $a
+ */
+function admin_page_contactblock_post(App $a)
+{
+ $contact_url = x($_POST, 'contact_url') ? $_POST['contact_url'] : '';
+ $contacts = x($_POST, 'contacts') ? $_POST['contacts'] : [];
+
+ check_form_security_token_redirectOnErr('/admin/contactblock', 'admin_contactblock');
+
+ if (x($_POST, 'page_contactblock_block')) {
+ $contact_id = Contact::getIdForURL($contact_url, 0);
+ if ($contact_id) {
+ Contact::block($contact_id);
+ notice(t('The contact has been blocked from the node'));
+ } else {
+ notice(t('Could not find any contact entry for this URL (%s)', $contact_url));
+ }
+ }
+ if (x($_POST, 'page_contactblock_unblock')) {
+ foreach ($contacts as $uid) {
+ Contact::unblock($uid);
+ }
+ notice(tt("%s contact unblocked", "%s contacts unblocked", count($contacts)));
+ }
+ goaway('admin/contactblock');
+ return; // NOTREACHED
+}
+
+/**
+ * @brief Admin panel for server-wide contact block
+ *
+ * @param App $a
+ * @return string
+ */
+function admin_page_contactblock(App $a)
+{
+ $condition = ['uid' => 0, 'blocked' => true];
+
+ $total = dba::count('contact', $condition);
+
+ $a->set_pager_total($total);
+ $a->set_pager_itemspage(30);
+
+ $statement = dba::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
+
+ $contacts = dba::inArray($statement);
+
+ $t = get_markup_template('admin/contactblock.tpl');
+ $o = replace_macros($t, array(
+ // strings //
+ '$title' => t('Administration'),
+ '$page' => t('Remote Contact Blocklist'),
+ '$description' => t('This page allows you to prevent any message from a remote contact to reach your node.'),
+ '$submit' => t('Block Remote Contact'),
+ '$select_all' => t('select all'),
+ '$select_none' => t('select none'),
+ '$block' => t('Block'),
+ '$unblock' => t('Unblock'),
+ '$no_data' => t('No remote contact is blocked from this node.'),
+
+ '$h_contacts' => t('Blocked Remote Contacts'),
+ '$h_newblock' => t('Block New Remote Contact'),
+ '$th_contacts' => [t('Photo'), t('Name'), t('Address'), t('Profile URL')],
+
+ '$form_security_token' => get_form_security_token("admin_contactblock"),
+
+ // values //
+ '$baseurl' => System::baseUrl(true),
+
+ '$contacts' => $contacts,
+ '$total_contacts' => tt('%s total blocked contact', '%s total blocked contacts', $total),
+ '$paginate' => paginate($a),
+ '$contacturl' => ['contact_url', t("Profile URL"), '', 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
*
*/
function admin_page_deleteitem(App $a)
{
- $t = get_markup_template("admin_deleteitem.tpl");
+ $t = get_markup_template('admin/deleteitem.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
$hint = t('The <em>Auto Discovered Contact Directory</em> feature is not enabled, it will improve the data displayed here.');
// load the template, replace the macros and return the page content
- $t = get_markup_template("admin_federation.tpl");
+ $t = get_markup_template('admin/federation.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Federation Statistics'),
WHERE `c`.`id` = `q`.`cid`
ORDER BY `q`.`cid`, `q`.`created`;");
- $t = get_markup_template("admin_queue.tpl");
+ $t = get_markup_template('admin/queue.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Inspect Queue'),
$queues = array('label' => t('Message queues'), 'queue' => $queue, 'workerq' => $workerqueue);
- $t = get_markup_template("admin_summary.tpl");
+ $t = get_markup_template('admin/summary.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Summary'),
$optimize_max_tablesize = 100;
}
- $t = get_markup_template("admin_site.tpl");
+ $t = get_markup_template('admin/site.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Site'),
'$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$shortcut_icon' => array('shortcut_icon', t("Shortcut icon"), Config::get('system','shortcut_icon'), t("Link to an icon that will be used for browsers.")),
'$touch_icon' => array('touch_icon', t("Touch icon"), Config::get('system','touch_icon'), t("Link to an icon that will be used for tablets and mobiles.")),
- '$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/siteinfo.'), get_server())),
+ '$info' => array('info', t('Additional Info'), $info, sprintf(t('For public servers: you can add additional information here that will be listed at %s/servers.'), get_server())),
'$language' => array('language', t("System language"), Config::get('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), Config::get('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$theme_mobile' => array('theme_mobile', t("Mobile system theme"), Config::get('system', 'mobile-theme', '---'), t("Theme for mobile devices"), $theme_choices_mobile),
check_form_security_token_redirectOnErr('/admin/users', 'admin_users');
if (!($nu_name === "") && !($nu_email === "") && !($nu_nickname === "")) {
- require_once 'include/user.php';
-
- $result = create_user(array('username' => $nu_name, 'email' => $nu_email,
+ $result = User::create(array('username' => $nu_name, 'email' => $nu_email,
'nickname' => $nu_nickname, 'verified' => 1, 'language' => $nu_language));
if (!$result['success']) {
notice($result['message']);
$th_users = array_map(null, array(t('Name'), t('Email'), t('Register date'), t('Last login'), t('Last item'), t('Account')), $valid_orders
);
- $t = get_markup_template("admin_users.tpl");
+ $t = get_markup_template('admin/users.tpl');
$o = replace_macros($t, array(
// strings //
'$title' => t('Administration'),
$func($a, $admin_form);
}
- $t = get_markup_template("admin_plugins_details.tpl");
+ $t = get_markup_template('admin/plugins_details.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
}
}
- $t = get_markup_template("admin_plugins.tpl");
+ $t = get_markup_template('admin/plugins.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Plugins'),
$screenshot = null;
}
- $t = get_markup_template("admin_plugins_details.tpl");
+ $t = get_markup_template('admin/plugins_details.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Themes'),
}
}
- $t = get_markup_template("admin_plugins.tpl");
+ $t = get_markup_template('admin/plugins.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
'$page' => t('Themes'),
$phplogenabled = t('PHP log currently disabled.');
}
- $t = get_markup_template("admin_logs.tpl");
+ $t = get_markup_template('admin/logs.tpl');
return replace_macros($t, array(
'$title' => t('Administration'),
*/
function admin_page_viewlogs(App $a)
{
- $t = get_markup_template("admin_viewlogs.tpl");
+ $t = get_markup_template('admin/viewlogs.tpl');
$f = Config::get('system', 'logfile');
$data = '';
logger('postvars: ' . print_r($_POST, true), LOGGER_DATA);
$arr = array();
- $features = get_features(false);
+ $features = Feature::get(false);
foreach ($features as $fname => $fdata) {
foreach (array_slice($fdata, 1) as $f) {
{
if ((argc() > 1) && (argv(1) === 'features')) {
$arr = array();
- $features = get_features(false);
+ $features = Feature::get(false);
foreach ($features as $fname => $fdata) {
$arr[$fname] = array();
}
}
- $tpl = get_markup_template("admin_settings_features.tpl");
+ $tpl = get_markup_template('admin/settings_features.tpl');
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("admin_manage_features"),
'$title' => t('Manage Additional Features'),