';
- list($no_active, $all_active, $post_active, $conv_active, $new_active, $starred_active, $bookmarked_active) = network_query_get_sel_tab($a);
+ list($no_active, $all_active, $post_active, $conv_active, $starred_active) = network_query_get_sel_tab($a);
// if no tabs are selected, defaults to activitys
if ($no_active == 'active') {
@@ -931,28 +707,6 @@ function network_tabs(App $a)
'accesskey' => 'r',
];
- if (Feature::isEnabled(local_user(), 'new_tab')) {
- $tabs[] = [
- 'label' => DI::l10n()->t('New'),
- 'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['new' => true])),
- 'sel' => $new_active,
- 'title' => DI::l10n()->t('Activity Stream - by date'),
- 'id' => 'activitiy-by-date-tab',
- 'accesskey' => 'w',
- ];
- }
-
- if (Feature::isEnabled(local_user(), 'link_tab')) {
- $tabs[] = [
- 'label' => DI::l10n()->t('Shared Links'),
- 'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['bmark' => true])),
- 'sel' => $bookmarked_active,
- 'title' => DI::l10n()->t('Interesting Links'),
- 'id' => 'shared-links-tab',
- 'accesskey' => 'b',
- ];
- }
-
$tabs[] = [
'label' => DI::l10n()->t('Starred'),
'url' => $cmd . '?' . http_build_query(array_merge($def_param, ['star' => true])),
@@ -965,7 +719,7 @@ function network_tabs(App $a)
// save selected tab, but only if not in file mode
if (empty($_GET['file'])) {
DI::pConfig()->set(local_user(), 'network.view', 'tab.selected', [
- $all_active, $post_active, $conv_active, $new_active, $starred_active, $bookmarked_active
+ $all_active, $post_active, $conv_active, $starred_active
]);
}
diff --git a/mod/notes.php b/mod/notes.php
index 67f8fcab29..d3ce0fa40c 100644
--- a/mod/notes.php
+++ b/mod/notes.php
@@ -40,7 +40,7 @@ function notes_init(App $a)
function notes_content(App $a, $update = false)
{
if (!local_user()) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
return;
}
@@ -55,7 +55,7 @@ function notes_content(App $a, $update = false)
'default_location' => $a->user['default-location'],
'nickname' => $a->user['nickname'],
'lockstate' => 'lock',
- 'acl' => '',
+ 'acl' => \Friendica\Core\ACL::getSelfOnlyHTML(local_user(), DI::l10n()->t('Personal notes are visible only by yourself.')),
'bang' => '',
'visitor' => 'block',
'profile_uid' => local_user(),
diff --git a/mod/oexchange.php b/mod/oexchange.php
index 97367c3ea5..f68fe6f2d2 100644
--- a/mod/oexchange.php
+++ b/mod/oexchange.php
@@ -23,7 +23,6 @@ use Friendica\App;
use Friendica\Core\Renderer;
use Friendica\DI;
use Friendica\Module\Security\Login;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
function oexchange_init(App $a) {
@@ -45,7 +44,6 @@ function oexchange_content(App $a) {
}
if (($a->argc > 1) && $a->argv[1] === 'done') {
- info(DI::l10n()->t('Post successful.') . EOL);
return;
}
@@ -58,7 +56,7 @@ function oexchange_content(App $a) {
$tags = ((!empty($_REQUEST['tags']))
? '&tags=' . urlencode(Strings::escapeTags(trim($_REQUEST['tags']))) : '');
- $s = Network::fetchUrl(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags);
+ $s = DI::httpRequest()->fetch(DI::baseUrl() . '/parse_url?url=' . $url . $title . $description . $tags);
if (!strlen($s)) {
return;
diff --git a/mod/ostatus_subscribe.php b/mod/ostatus_subscribe.php
index 64774eead9..3f716c8c7b 100644
--- a/mod/ostatus_subscribe.php
+++ b/mod/ostatus_subscribe.php
@@ -23,13 +23,11 @@ use Friendica\App;
use Friendica\Core\Protocol;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Network\Probe;
-use Friendica\Util\Network;
function ostatus_subscribe_content(App $a)
{
if (!local_user()) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_subscribe');
// NOTREACHED
}
@@ -47,7 +45,7 @@ function ostatus_subscribe_content(App $a)
return $o . DI::l10n()->t('No contact provided.');
}
- $contact = Probe::uri($_REQUEST['url']);
+ $contact = Contact::getByURL($_REQUEST['url']);
if (!$contact) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
return $o . DI::l10n()->t('Couldn\'t fetch information for contact.');
@@ -56,7 +54,7 @@ function ostatus_subscribe_content(App $a)
$api = $contact['baseurl'] . '/api/';
// Fetching friends
- $curlResult = Network::curl($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
+ $curlResult = DI::httpRequest()->get($api . 'statuses/friends.json?screen_name=' . $contact['nick']);
if (!$curlResult->isSuccess()) {
DI::pConfig()->delete($uid, 'ostatus', 'legacy_contact');
@@ -88,7 +86,7 @@ function ostatus_subscribe_content(App $a)
$o .= '
' . $counter . '/' . $total . ': ' . $url;
- $probed = Probe::uri($url);
+ $probed = Contact::getByURL($url);
if ($probed['network'] == Protocol::OSTATUS) {
$result = Contact::createFromProbe($a->user, $probed['url'], true, Protocol::OSTATUS);
if ($result['success']) {
diff --git a/mod/parse_url.php b/mod/parse_url.php
index b40ddf1d71..a1faab6efb 100644
--- a/mod/parse_url.php
+++ b/mod/parse_url.php
@@ -24,10 +24,11 @@
*/
use Friendica\App;
+use Friendica\Content\PageInfo;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\System;
-use Friendica\Util\Network;
+use Friendica\DI;
use Friendica\Util\ParseUrl;
use Friendica\Util\Strings;
@@ -84,7 +85,7 @@ function parse_url_content(App $a)
// Check if the URL is an image, video or audio file. If so format
// the URL with the corresponding BBCode media tag
// Fetch the header of the URL
- $curlResponse = Network::curl($url, false, ['novalidate' => true, 'nobody' => true]);
+ $curlResponse = DI::httpRequest()->get($url, false, ['novalidate' => true, 'nobody' => true]);
if ($curlResponse->isSuccess()) {
// Convert the header fields into an array
@@ -177,7 +178,7 @@ function parse_url_content(App $a)
}
// Format it as BBCode attachment
- $info = add_page_info_data($siteinfo);
+ $info = "\n" . PageInfo::getFooterFromData($siteinfo);
echo $info;
diff --git a/mod/photos.php b/mod/photos.php
index f33a9241ef..3b2fa0c3a8 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -25,6 +25,7 @@ use Friendica\Content\Nav;
use Friendica\Content\Pager;
use Friendica\Content\Text\BBCode;
use Friendica\Core\ACL;
+use Friendica\Core\Addon;
use Friendica\Core\Hook;
use Friendica\Core\Logger;
use Friendica\Core\Renderer;
@@ -175,14 +176,14 @@ function photos_post(App $a)
}
if (!$can_post) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
exit();
}
$owner_record = User::getOwnerDataById($page_owner_uid);
if (!$owner_record) {
- notice(DI::l10n()->t('Contact information unavailable') . EOL);
+ notice(DI::l10n()->t('Contact information unavailable'));
Logger::log('photos_post: unable to locate contact record for page owner. uid=' . $page_owner_uid);
exit();
}
@@ -193,7 +194,7 @@ function photos_post(App $a)
}
$album = hex2bin($a->argv[3]);
- if ($album === DI::l10n()->t('Profile Photos') || $album === 'Contact Photos' || $album === DI::l10n()->t('Contact Photos')) {
+ if ($album === DI::l10n()->t('Profile Photos') || $album === Photo::CONTACT_PHOTOS || $album === DI::l10n()->t(Photo::CONTACT_PHOTOS)) {
DI::baseUrl()->redirect($_SESSION['photo_return']);
return; // NOTREACHED
}
@@ -204,7 +205,7 @@ function photos_post(App $a)
);
if (!DBA::isResult($r)) {
- notice(DI::l10n()->t('Album not found.') . EOL);
+ notice(DI::l10n()->t('Album not found.'));
DI::baseUrl()->redirect('photos/' . $a->data['user']['nickname'] . '/album');
return; // NOTREACHED
}
@@ -295,9 +296,8 @@ function photos_post(App $a)
// Update the photo albums cache
Photo::clearAlbumCache($page_owner_uid);
- notice('Successfully deleted the photo.');
} else {
- notice('Failed to delete the photo.');
+ notice(DI::l10n()->t('Failed to delete the photo.'));
DI::baseUrl()->redirect('photos/' . $a->argv[1] . '/image/' . $a->argv[3]);
}
@@ -676,21 +676,21 @@ function photos_post(App $a)
if ($error !== UPLOAD_ERR_OK) {
switch ($error) {
case UPLOAD_ERR_INI_SIZE:
- notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')) . EOL);
+ notice(DI::l10n()->t('Image exceeds size limit of %s', ini_get('upload_max_filesize')));
break;
case UPLOAD_ERR_FORM_SIZE:
- notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)) . EOL);
+ notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($_REQUEST['MAX_FILE_SIZE'] ?? 0)));
break;
case UPLOAD_ERR_PARTIAL:
- notice(DI::l10n()->t('Image upload didn\'t complete, please try again') . EOL);
+ notice(DI::l10n()->t('Image upload didn\'t complete, please try again'));
break;
case UPLOAD_ERR_NO_FILE:
- notice(DI::l10n()->t('Image file is missing') . EOL);
+ notice(DI::l10n()->t('Image file is missing'));
break;
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE:
case UPLOAD_ERR_EXTENSION:
- notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator') . EOL);
+ notice(DI::l10n()->t('Server can\'t accept new file upload at this time, please contact your administrator'));
break;
}
@unlink($src);
@@ -706,7 +706,7 @@ function photos_post(App $a)
$maximagesize = DI::config()->get('system', 'maximagesize');
if ($maximagesize && ($filesize > $maximagesize)) {
- notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)) . EOL);
+ notice(DI::l10n()->t('Image exceeds size limit of %s', Strings::formatBytes($maximagesize)));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end', $foo);
@@ -714,7 +714,7 @@ function photos_post(App $a)
}
if (!$filesize) {
- notice(DI::l10n()->t('Image file is empty.') . EOL);
+ notice(DI::l10n()->t('Image file is empty.'));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end', $foo);
@@ -729,7 +729,7 @@ function photos_post(App $a)
if (!$image->isValid()) {
Logger::log('mod/photos.php: photos_post(): unable to process image' , Logger::DEBUG);
- notice(DI::l10n()->t('Unable to process image.') . EOL);
+ notice(DI::l10n()->t('Unable to process image.'));
@unlink($src);
$foo = 0;
Hook::callAll('photo_post_end',$foo);
@@ -758,7 +758,7 @@ function photos_post(App $a)
if (!$r) {
Logger::log('mod/photos.php: photos_post(): image store failed', Logger::DEBUG);
- notice(DI::l10n()->t('Image upload failed.') . EOL);
+ notice(DI::l10n()->t('Image upload failed.'));
return;
}
@@ -841,12 +841,12 @@ function photos_content(App $a)
// photos/name/image/xxxxx/drop
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
- notice(DI::l10n()->t('Public access denied.') . EOL);
+ notice(DI::l10n()->t('Public access denied.'));
return;
}
if (empty($a->data['user'])) {
- notice(DI::l10n()->t('No photos selected') . EOL);
+ notice(DI::l10n()->t('No photos selected'));
return;
}
@@ -912,7 +912,7 @@ function photos_content(App $a)
}
if ($a->data['user']['hidewall'] && (local_user() != $owner_uid) && !$remote_contact) {
- notice(DI::l10n()->t('Access to this item is restricted.') . EOL);
+ notice(DI::l10n()->t('Access to this item is restricted.'));
return;
}
@@ -938,7 +938,7 @@ function photos_content(App $a)
$albumselect .= '';
if (!empty($a->data['albums'])) {
foreach ($a->data['albums'] as $album) {
- if (($album['album'] === '') || ($album['album'] === 'Contact Photos') || ($album['album'] === DI::l10n()->t('Contact Photos'))) {
+ if (($album['album'] === '') || ($album['album'] === Photo::CONTACT_PHOTOS) || ($album['album'] === DI::l10n()->t(Photo::CONTACT_PHOTOS))) {
continue;
}
$selected = (($selname === $album['album']) ? ' selected="selected" ' : '');
@@ -988,8 +988,6 @@ function photos_content(App $a)
'$uploadurl' => $ret['post_url'],
// ACL permissions box
- '$group_perms' => DI::l10n()->t('Show to Groups'),
- '$contact_perms' => DI::l10n()->t('Show to Contacts'),
'$return_path' => DI::args()->getQueryString(),
]);
@@ -1041,7 +1039,6 @@ function photos_content(App $a)
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
'$method' => 'post',
'$message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
- '$extra_inputs' => [],
'$confirm' => DI::l10n()->t('Delete Album'),
'$confirm_url' => $drop_url,
'$confirm_name' => 'dropalbum',
@@ -1051,7 +1048,7 @@ function photos_content(App $a)
// edit album name
if ($cmd === 'edit') {
- if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== DI::l10n()->t('Contact Photos'))) {
+ if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== Photo::CONTACT_PHOTOS) && ($album !== DI::l10n()->t(Photo::CONTACT_PHOTOS))) {
if ($can_post) {
$edit_tpl = Renderer::getMarkupTemplate('album_edit.tpl');
@@ -1068,7 +1065,7 @@ function photos_content(App $a)
}
}
} else {
- if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== 'Contact Photos') && ($album !== DI::l10n()->t('Contact Photos')) && $can_post) {
+ if (($album !== DI::l10n()->t('Profile Photos')) && ($album !== Photo::CONTACT_PHOTOS) && ($album !== DI::l10n()->t(Photo::CONTACT_PHOTOS)) && $can_post) {
$edit = [DI::l10n()->t('Edit Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/edit'];
$drop = [DI::l10n()->t('Drop Album'), 'photos/' . $a->data['user']['nickname'] . '/album/' . bin2hex($album) . '/drop'];
}
@@ -1137,7 +1134,7 @@ function photos_content(App $a)
if (DBA::exists('photo', ['resource-id' => $datum, 'uid' => $owner_uid])) {
notice(DI::l10n()->t('Permission denied. Access to this item may be restricted.'));
} else {
- notice(DI::l10n()->t('Photo not available') . EOL);
+ notice(DI::l10n()->t('Photo not available'));
}
return;
}
@@ -1148,7 +1145,6 @@ function photos_content(App $a)
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
'$method' => 'post',
'$message' => DI::l10n()->t('Do you really want to delete this photo?'),
- '$extra_inputs' => [],
'$confirm' => DI::l10n()->t('Delete Photo'),
'$confirm_url' => $drop_url,
'$confirm_name' => 'delete',
@@ -1353,8 +1349,6 @@ function photos_content(App $a)
'$delete' => DI::l10n()->t('Delete Photo'),
// ACL permissions box
- '$group_perms' => DI::l10n()->t('Show to Groups'),
- '$contact_perms' => DI::l10n()->t('Show to Contacts'),
'$return_path' => DI::args()->getQueryString(),
]);
}
@@ -1383,6 +1377,16 @@ function photos_content(App $a)
if (!DBA::isResult($items)) {
if (($can_post || Security::canWriteToUserWall($owner_uid))) {
+ /*
+ * Hmmm, code depending on the presence of a particular addon?
+ * This should be better if done by a hook
+ */
+ $qcomment = null;
+ if (Addon::isEnabled('qcomment')) {
+ $words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
+ $qcomment = $words ? explode("\n", $words) : [];
+ }
+
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
@@ -1397,7 +1401,7 @@ function photos_content(App $a)
'$preview' => DI::l10n()->t('Preview'),
'$loading' => DI::l10n()->t('Loading...'),
'$sourceapp' => DI::l10n()->t($a->sourcename),
- '$ww' => '',
+ '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12)
]);
}
@@ -1430,6 +1434,16 @@ function photos_content(App $a)
}
if (($can_post || Security::canWriteToUserWall($owner_uid))) {
+ /*
+ * Hmmm, code depending on the presence of a particular addon?
+ * This should be better if done by a hook
+ */
+ $qcomment = null;
+ if (Addon::isEnabled('qcomment')) {
+ $words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
+ $qcomment = $words ? explode("\n", $words) : [];
+ }
+
$comments .= Renderer::replaceMacros($cmnt_tpl,[
'$return_path' => '',
'$jsreload' => $return_path,
@@ -1443,7 +1457,7 @@ function photos_content(App $a)
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$sourceapp' => DI::l10n()->t($a->sourcename),
- '$ww' => '',
+ '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12)
]);
}
@@ -1493,6 +1507,16 @@ function photos_content(App $a)
]);
if (($can_post || Security::canWriteToUserWall($owner_uid))) {
+ /*
+ * Hmmm, code depending on the presence of a particular addon?
+ * This should be better if done by a hook
+ */
+ $qcomment = null;
+ if (Addon::isEnabled('qcomment')) {
+ $words = DI::pConfig()->get(local_user(), 'qcomment', 'words');
+ $qcomment = $words ? explode("\n", $words) : [];
+ }
+
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
@@ -1506,7 +1530,7 @@ function photos_content(App $a)
'$submit' => DI::l10n()->t('Submit'),
'$preview' => DI::l10n()->t('Preview'),
'$sourceapp' => DI::l10n()->t($a->sourcename),
- '$ww' => '',
+ '$qcomment' => $qcomment,
'$rand_num' => Crypto::randomDigits(12)
]);
}
@@ -1551,8 +1575,8 @@ function photos_content(App $a)
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource-id`",
intval($a->data['user']['uid']),
- DBA::escape('Contact Photos'),
- DBA::escape(DI::l10n()->t('Contact Photos'))
+ DBA::escape(Photo::CONTACT_PHOTOS),
+ DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS))
);
if (DBA::isResult($r)) {
$total = count($r);
@@ -1566,8 +1590,8 @@ function photos_content(App $a)
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
$sql_extra GROUP BY `resource-id` ORDER BY `created` DESC LIMIT %d , %d",
intval($a->data['user']['uid']),
- DBA::escape('Contact Photos'),
- DBA::escape(DI::l10n()->t('Contact Photos')),
+ DBA::escape(Photo::CONTACT_PHOTOS),
+ DBA::escape(DI::l10n()->t(Photo::CONTACT_PHOTOS)),
$pager->getStart(),
$pager->getItemsPerPage()
);
diff --git a/mod/ping.php b/mod/ping.php
index 6b3b015ac8..7c8d6c846d 100644
--- a/mod/ping.php
+++ b/mod/ping.php
@@ -34,7 +34,6 @@ use Friendica\Model\Verb;
use Friendica\Protocol\Activity;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
-use Friendica\Util\Proxy as ProxyUtils;
use Friendica\Util\XML;
/**
@@ -136,13 +135,9 @@ function ping_init(App $a)
$notifs = ping_get_notifications(local_user());
- $condition = ["`unseen` AND `uid` = ? AND `contact-id` != ? AND (`vid` != ? OR `vid` IS NULL)",
- local_user(), local_user(), Verb::getID(Activity::FOLLOW)];
- $fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
- 'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid', 'wall', 'activity'];
- $params = ['order' => ['received' => true]];
- $items = Item::selectForUser(local_user(), $fields, $condition, $params);
-
+ $condition = ["`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
+ local_user(), Verb::getID(Activity::FOLLOW)];
+ $items = Item::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition);
if (DBA::isResult($items)) {
$items_unseen = Item::inArray($items);
$arr = ['items' => $items_unseen];
@@ -156,6 +151,7 @@ function ping_init(App $a)
}
}
}
+ DBA::close($items);
if ($network_count) {
// Find out how unseen network posts are spread across groups
@@ -331,12 +327,8 @@ function ping_init(App $a)
if (DBA::isResult($notifs)) {
foreach ($notifs as $notif) {
- $contact = Contact::getDetailsByURL($notif['url']);
- if (isset($contact['micro'])) {
- $notif['photo'] = ProxyUtils::proxifyUrl($contact['micro'], false, ProxyUtils::SIZE_MICRO);
- } else {
- $notif['photo'] = ProxyUtils::proxifyUrl($notif['photo'], false, ProxyUtils::SIZE_MICRO);
- }
+ $contact = Contact::getByURL($notif['url'], false, ['micro', 'id', 'avatar']);
+ $notif['photo'] = Contact::getMicro($contact, $notif['photo']);
$local_time = DateTimeFormat::local($notif['date']);
diff --git a/mod/poco.php b/mod/poco.php
index f1fdc55d75..f084361dc4 100644
--- a/mod/poco.php
+++ b/mod/poco.php
@@ -27,139 +27,37 @@ use Friendica\Core\Protocol;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Protocol\PortableContact;
-use Friendica\Util\DateTimeFormat;
use Friendica\Util\Strings;
use Friendica\Util\XML;
function poco_init(App $a) {
- $system_mode = false;
-
if (intval(DI::config()->get('system', 'block_public')) || (DI::config()->get('system', 'block_local_dir'))) {
throw new \Friendica\Network\HTTPException\ForbiddenException();
}
if ($a->argc > 1) {
- $nickname = Strings::escapeTags(trim($a->argv[1]));
- }
- if (empty($nickname)) {
- if (!DBA::exists('profile', ['net-publish' => true])) {
- throw new \Friendica\Network\HTTPException\ForbiddenException();
- }
- $system_mode = true;
+ // Only the system mode is supported
+ throw new \Friendica\Network\HTTPException\NotFoundException();
}
$format = ($_GET['format'] ?? '') ?: 'json';
- $justme = false;
- $global = false;
-
- if ($a->argc > 1 && $a->argv[1] === '@server') {
- // List of all servers that this server knows
- $ret = PortableContact::serverlist();
- header('Content-type: application/json');
- echo json_encode($ret);
- exit();
+ $totalResults = DBA::count('profile', ['net-publish' => true]);
+ if ($totalResults == 0) {
+ throw new \Friendica\Network\HTTPException\ForbiddenException();
}
- if ($a->argc > 1 && $a->argv[1] === '@global') {
- // List of all profiles that this server recently had data from
- $global = true;
- $update_limit = date(DateTimeFormat::MYSQL, time() - 30 * 86400);
- }
- if ($a->argc > 2 && $a->argv[2] === '@me') {
- $justme = true;
- }
- if ($a->argc > 3 && $a->argv[3] === '@all') {
- $justme = false;
- }
- if ($a->argc > 3 && $a->argv[3] === '@self') {
- $justme = true;
- }
- if ($a->argc > 4 && intval($a->argv[4]) && $justme == false) {
- $cid = intval($a->argv[4]);
- }
-
- if (!$system_mode && !$global) {
- $user = DBA::selectFirst('owner-view', ['uid', 'nickname'], ['nickname' => $nickname, 'hide-friends' => false]);
- if (!DBA::isResult($user)) {
- throw new \Friendica\Network\HTTPException\NotFoundException();
- }
- }
-
- if ($justme) {
- $sql_extra = " AND `contact`.`self` = 1 ";
- } else {
- $sql_extra = "";
- }
-
- if (!empty($cid)) {
- $sql_extra = sprintf(" AND `contact`.`id` = %d ", intval($cid));
- }
- if (!empty($_GET['updatedSince'])) {
- $update_limit = date(DateTimeFormat::MYSQL, strtotime($_GET['updatedSince']));
- }
- if ($global) {
- $contacts = q("SELECT count(*) AS `total` FROM `gcontact` WHERE `updated` >= '%s' AND `updated` >= `last_failure` AND NOT `hide` AND `network` IN ('%s', '%s', '%s')",
- DBA::escape($update_limit),
- DBA::escape(Protocol::DFRN),
- DBA::escape(Protocol::DIASPORA),
- DBA::escape(Protocol::OSTATUS)
- );
- } elseif ($system_mode) {
- $totalResults = DBA::count('profile', ['net-publish' => true]);
- } else {
- $contacts = q("SELECT count(*) AS `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
- AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
- AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra",
- intval($user['uid']),
- DBA::escape(Protocol::DFRN),
- DBA::escape(Protocol::DIASPORA),
- DBA::escape(Protocol::OSTATUS),
- DBA::escape(Protocol::STATUSNET)
- );
- }
- if (empty($totalResults) && DBA::isResult($contacts)) {
- $totalResults = intval($contacts[0]['total']);
- } elseif (empty($totalResults)) {
- $totalResults = 0;
- }
if (!empty($_GET['startIndex'])) {
$startIndex = intval($_GET['startIndex']);
} else {
$startIndex = 0;
}
- $itemsPerPage = ((!empty($_GET['count'])) ? intval($_GET['count']) : $totalResults);
+ $itemsPerPage = (!empty($_GET['count']) ? intval($_GET['count']) : $totalResults);
- if ($global) {
- Logger::log("Start global query", Logger::DEBUG);
- $contacts = q("SELECT * FROM `gcontact` WHERE `updated` > '%s' AND NOT `hide` AND `network` IN ('%s', '%s', '%s') AND `updated` > `last_failure`
- ORDER BY `updated` DESC LIMIT %d, %d",
- DBA::escape($update_limit),
- DBA::escape(Protocol::DFRN),
- DBA::escape(Protocol::DIASPORA),
- DBA::escape(Protocol::OSTATUS),
- intval($startIndex),
- intval($itemsPerPage)
- );
- } elseif ($system_mode) {
- Logger::log("Start system mode query", Logger::DEBUG);
- $contacts = DBA::selectToArray('owner-view', [], ['net-publish' => true], ['limit' => [$startIndex, $itemsPerPage]]);
- } else {
- Logger::log("Start query for user " . $user['nickname'], Logger::DEBUG);
- $contacts = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
- AND (`success_update` >= `failure_update` OR `last-item` >= `failure_update`)
- AND `network` IN ('%s', '%s', '%s', '%s') $sql_extra LIMIT %d, %d",
- intval($user['uid']),
- DBA::escape(Protocol::DFRN),
- DBA::escape(Protocol::DIASPORA),
- DBA::escape(Protocol::OSTATUS),
- DBA::escape(Protocol::STATUSNET),
- intval($startIndex),
- intval($itemsPerPage)
- );
- }
- Logger::log("Query done", Logger::DEBUG);
+ Logger::info("Start system mode query");
+ $contacts = DBA::selectToArray('owner-view', [], ['net-publish' => true], ['limit' => [$startIndex, $itemsPerPage]]);
+
+ Logger::info("Query done");
$ret = [];
if (!empty($_GET['sorted'])) {
@@ -168,7 +66,7 @@ function poco_init(App $a) {
if (!empty($_GET['filtered'])) {
$ret['filtered'] = false;
}
- if (!empty($_GET['updatedSince']) && ! $global) {
+ if (!empty($_GET['updatedSince'])) {
$ret['updatedSince'] = false;
}
$ret['startIndex'] = (int) $startIndex;
@@ -176,7 +74,6 @@ function poco_init(App $a) {
$ret['totalResults'] = (int) $totalResults;
$ret['entry'] = [];
-
$fields_ret = [
'id' => false,
'displayName' => false,
@@ -193,7 +90,7 @@ function poco_init(App $a) {
'generation' => false
];
- if (empty($_GET['fields']) || ($_GET['fields'] === '@all')) {
+ if (empty($_GET['fields'])) {
foreach ($fields_ret as $k => $v) {
$fields_ret[$k] = true;
}
@@ -215,13 +112,7 @@ function poco_init(App $a) {
}
if (! isset($contact['generation'])) {
- if ($global) {
- $contact['generation'] = 3;
- } elseif ($system_mode) {
- $contact['generation'] = 1;
- } else {
- $contact['generation'] = 2;
- }
+ $contact['generation'] = 1;
}
if (($contact['keywords'] == "") && isset($contact['pub_keywords'])) {
@@ -268,20 +159,16 @@ function poco_init(App $a) {
$entry['preferredUsername'] = $contact['nick'];
}
if ($fields_ret['updated']) {
- if (! $global) {
- $entry['updated'] = $contact['success_update'];
+ $entry['updated'] = $contact['success_update'];
- if ($contact['name-date'] > $entry['updated']) {
- $entry['updated'] = $contact['name-date'];
- }
- if ($contact['uri-date'] > $entry['updated']) {
- $entry['updated'] = $contact['uri-date'];
- }
- if ($contact['avatar-date'] > $entry['updated']) {
- $entry['updated'] = $contact['avatar-date'];
- }
- } else {
- $entry['updated'] = $contact['updated'];
+ if ($contact['name-date'] > $entry['updated']) {
+ $entry['updated'] = $contact['name-date'];
+ }
+ if ($contact['uri-date'] > $entry['updated']) {
+ $entry['updated'] = $contact['uri-date'];
+ }
+ if ($contact['avatar-date'] > $entry['updated']) {
+ $entry['updated'] = $contact['avatar-date'];
}
$entry['updated'] = date("c", strtotime($entry['updated']));
}
@@ -314,19 +201,13 @@ function poco_init(App $a) {
if ($fields_ret['address']) {
$entry['address'] = [];
- // Deactivated. It just reveals too much data. (Although its from the default profile)
- //if (isset($rr['address']))
- // $entry['address']['streetAddress'] = $rr['address'];
-
if (isset($contact['locality'])) {
$entry['address']['locality'] = $contact['locality'];
}
+
if (isset($contact['region'])) {
$entry['address']['region'] = $contact['region'];
}
- // See above
- //if (isset($rr['postal-code']))
- // $entry['address']['postalCode'] = $rr['postal-code'];
if (isset($contact['country'])) {
$entry['address']['country'] = $contact['country'];
@@ -342,7 +223,7 @@ function poco_init(App $a) {
$ret['entry'][] = [];
}
- Logger::log("End of poco", Logger::DEBUG);
+ Logger::info("End of poco");
if ($format === 'xml') {
header('Content-type: text/xml');
diff --git a/mod/pubsub.php b/mod/pubsub.php
index cae346493f..ece95dceab 100644
--- a/mod/pubsub.php
+++ b/mod/pubsub.php
@@ -25,6 +25,7 @@ use Friendica\Core\Protocol;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
+use Friendica\Protocol\Feed;
use Friendica\Protocol\OStatus;
use Friendica\Util\Strings;
use Friendica\Util\Network;
@@ -146,11 +147,11 @@ function pubsub_post(App $a)
Logger::log('Import item for ' . $nick . ' from ' . $contact['nick'] . ' (' . $contact['id'] . ')');
$feedhub = '';
- consume_feed($xml, $importer, $contact, $feedhub);
+ Feed::consume($xml, $importer, $contact, $feedhub);
// do it a second time for DFRN so that any children find their parents.
if ($contact['network'] === Protocol::DFRN) {
- consume_feed($xml, $importer, $contact, $feedhub);
+ Feed::consume($xml, $importer, $contact, $feedhub);
}
hub_post_return();
diff --git a/mod/pubsubhubbub.php b/mod/pubsubhubbub.php
index 4d33503796..3445436182 100644
--- a/mod/pubsubhubbub.php
+++ b/mod/pubsubhubbub.php
@@ -24,7 +24,6 @@ use Friendica\Core\Logger;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\PushSubscriber;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
function post_var($name) {
@@ -126,7 +125,7 @@ function pubsubhubbub_init(App $a) {
$hub_callback = rtrim($hub_callback, ' ?');
$separator = parse_url($hub_callback, PHP_URL_QUERY) === null ? '?' : '&';
- $fetchResult = Network::fetchUrlFull($hub_callback . $separator . $params);
+ $fetchResult = DI::httpRequest()->fetchFull($hub_callback . $separator . $params);
$body = $fetchResult->getBody();
$ret = $fetchResult->getReturnCode();
diff --git a/mod/redir.php b/mod/redir.php
index d928e66df0..b2f76738be 100644
--- a/mod/redir.php
+++ b/mod/redir.php
@@ -27,7 +27,6 @@ use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\Profile;
-use Friendica\Util\Network;
use Friendica\Util\Strings;
function redir_init(App $a) {
@@ -171,7 +170,7 @@ function redir_magic($a, $cid, $url)
}
// Test for magic auth on the target system
- $serverret = Network::curl($basepath . '/magic');
+ $serverret = DI::httpRequest()->get($basepath . '/magic');
if ($serverret->isSuccess()) {
$separator = strpos($target_url, '?') ? '&' : '?';
$target_url .= $separator . 'zrl=' . urlencode($visitor) . '&addr=' . urlencode($contact_url);
diff --git a/mod/repair_ostatus.php b/mod/repair_ostatus.php
index 33e97499e5..0d30fc298d 100644
--- a/mod/repair_ostatus.php
+++ b/mod/repair_ostatus.php
@@ -28,7 +28,7 @@ use Friendica\Model\Contact;
function repair_ostatus_content(App $a) {
if (! local_user()) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
DI::baseUrl()->redirect('ostatus_repair');
// NOTREACHED
}
diff --git a/mod/settings.php b/mod/settings.php
index 9b2f4f650e..92a7bb461f 100644
--- a/mod/settings.php
+++ b/mod/settings.php
@@ -31,7 +31,6 @@ use Friendica\Core\Worker;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\GContact;
use Friendica\Model\Group;
use Friendica\Model\Notify\Type;
use Friendica\Model\User;
@@ -63,7 +62,7 @@ function settings_post(App $a)
}
if (count($a->user) && !empty($a->user['uid']) && $a->user['uid'] != local_user()) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
return;
}
@@ -198,13 +197,10 @@ function settings_post(App $a)
unset($dcrpass);
if (!$mbox) {
$failed = true;
- notice(DI::l10n()->t('Failed to connect with email account using the settings provided.') . EOL);
+ notice(DI::l10n()->t('Failed to connect with email account using the settings provided.'));
}
}
}
- if (!$failed) {
- info(DI::l10n()->t('Email settings updated.') . EOL);
- }
}
}
@@ -219,7 +215,6 @@ function settings_post(App $a)
DI::pConfig()->set(local_user(), 'feature', substr($k, 8), ((intval($v)) ? 1 : 0));
}
}
- info(DI::l10n()->t('Features updated') . EOL);
return;
}
@@ -231,7 +226,7 @@ function settings_post(App $a)
// was there an error
if ($_FILES['importcontact-filename']['error'] > 0) {
Logger::notice('Contact CSV file upload error');
- info(DI::l10n()->t('Contact CSV file upload error'));
+ notice(DI::l10n()->t('Contact CSV file upload error'));
} else {
$csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name']));
// import contacts
@@ -424,10 +419,10 @@ function settings_post(App $a)
$hidewall = 1;
if (!$str_contact_allow && !$str_group_allow && !$str_contact_deny && !$str_group_deny) {
if ($def_gid) {
- info(DI::l10n()->t('Private forum has no privacy permissions. Using default privacy group.'). EOL);
+ info(DI::l10n()->t('Private forum has no privacy permissions. Using default privacy group.'));
$str_group_allow = '<' . $def_gid . '>';
} else {
- notice(DI::l10n()->t('Private forum has no privacy permissions and no default privacy group.') . EOL);
+ notice(DI::l10n()->t('Private forum has no privacy permissions and no default privacy group.'));
}
}
}
@@ -443,8 +438,8 @@ function settings_post(App $a)
$fields['openidserver'] = '';
}
- if (DBA::update('user', $fields, ['uid' => local_user()])) {
- info(DI::l10n()->t('Settings updated.') . EOL);
+ if (!DBA::update('user', $fields, ['uid' => local_user()])) {
+ notice(DI::l10n()->t('Settings were not updated.'));
}
// clear session language
@@ -475,9 +470,6 @@ function settings_post(App $a)
Worker::add(PRIORITY_LOW, 'ProfileUpdate', local_user());
- // Update the global contact for the user
- GContact::updateForUser(local_user());
-
DI::baseUrl()->redirect('settings');
return; // NOTREACHED
}
@@ -489,12 +481,12 @@ function settings_content(App $a)
Nav::setSelected('settings');
if (!local_user()) {
- //notice(DI::l10n()->t('Permission denied.') . EOL);
+ //notice(DI::l10n()->t('Permission denied.'));
return Login::form();
}
if (!empty($_SESSION['submanage'])) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
+ notice(DI::l10n()->t('Permission denied.'));
return;
}
@@ -722,7 +714,7 @@ function settings_content(App $a)
$profile = DBA::selectFirst('profile', [], ['uid' => local_user()]);
if (!DBA::isResult($profile)) {
- notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.') . EOL);
+ notice(DI::l10n()->t('Unable to find your profile. Please contact your admin.'));
return;
}
@@ -837,26 +829,6 @@ function settings_content(App $a)
$stpl = Renderer::getMarkupTemplate('settings/settings.tpl');
- // Private/public post links for the non-JS ACL form
- $private_post = 1;
- if (!empty($_REQUEST['public']) && !$_REQUEST['public']) {
- $private_post = 0;
- }
-
- $query_str = DI::args()->getQueryString();
- if (strpos($query_str, 'public=1') !== false) {
- $query_str = str_replace(['?public=1', '&public=1'], ['', ''], $query_str);
- }
-
- // I think $a->query_string may never have ? in it, but I could be wrong
- // It looks like it's from the index.php?q=[etc] rewrite that the web
- // server does, which converts any ? to &, e.g. suggest&ignore=61 for suggest?ignore=61
- if (strpos($query_str, '?') === false) {
- $public_post_link = '?public=1';
- } else {
- $public_post_link = '&public=1';
- }
-
/* Installed langs */
$lang_choices = DI::l10n()->getAvailableLanguages();
@@ -874,7 +846,7 @@ function settings_content(App $a)
'$password1'=> ['password', DI::l10n()->t('New Password:'), '', DI::l10n()->t('Allowed characters are a-z, A-Z, 0-9 and special characters except white spaces, accentuated letters and colon (:).')],
'$password2'=> ['confirm', DI::l10n()->t('Confirm:'), '', DI::l10n()->t('Leave password fields blank unless changing')],
'$password3'=> ['opassword', DI::l10n()->t('Current Password:'), '', DI::l10n()->t('Your current password to confirm the changes')],
- '$password4'=> ['mpassword', DI::l10n()->t('Password:'), '', DI::l10n()->t('Your current password to confirm the changes')],
+ '$password4'=> ['mpassword', DI::l10n()->t('Password:'), '', DI::l10n()->t('Your current password to confirm the changes of the email address')],
'$oid_enable' => (!DI::config()->get('system', 'no_openid')),
'$openid' => $openid_field,
'$delete_openid' => ['delete_openid', DI::l10n()->t('Delete OpenID URL'), false, ''],
diff --git a/mod/subthread.php b/mod/subthread.php
index ebec978c59..93992d8daa 100644
--- a/mod/subthread.php
+++ b/mod/subthread.php
@@ -34,7 +34,7 @@ function subthread_content(App $a)
$item_id = (($a->argc > 1) ? Strings::escapeTags(trim($a->argv[1])) : 0);
- if (!Item::performActivity($item_id, 'follow')) {
+ if (!Item::performActivity($item_id, 'follow', local_user())) {
Logger::info('Following item failed', ['item' => $item_id]);
throw new HTTPException\BadRequestException();
}
diff --git a/mod/suggest.php b/mod/suggest.php
index 5fb9bdcff7..0965978ce0 100644
--- a/mod/suggest.php
+++ b/mod/suggest.php
@@ -20,39 +20,18 @@
*/
use Friendica\App;
-use Friendica\Content\ContactSelector;
use Friendica\Content\Widget;
use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
-use Friendica\Model\GContact;
-use Friendica\Util\Proxy as ProxyUtils;
-
-function suggest_init(App $a)
-{
- if (! local_user()) {
- return;
- }
-}
-
-function suggest_post(App $a)
-{
- if (!empty($_POST['ignore']) && !empty($_POST['confirm'])) {
- DBA::insert('gcign', ['uid' => local_user(), 'gcid' => $_POST['ignore']]);
- notice(DI::l10n()->t('Contact suggestion successfully ignored.'));
- }
-
- DI::baseUrl()->redirect('suggest');
-}
+use Friendica\Module\Contact as ModuleContact;
+use Friendica\Network\HTTPException;
function suggest_content(App $a)
{
- $o = '';
-
- if (! local_user()) {
- notice(DI::l10n()->t('Permission denied.') . EOL);
- return;
+ if (!local_user()) {
+ throw new HTTPException\ForbiddenException(DI::l10n()->t('Permission denied.'));
}
$_SESSION['return_path'] = DI::args()->getCommand();
@@ -60,80 +39,20 @@ function suggest_content(App $a)
DI::page()['aside'] .= Widget::findPeople();
DI::page()['aside'] .= Widget::follow();
-
- $r = GContact::suggestionQuery(local_user());
-
- if (! DBA::isResult($r)) {
- $o .= DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.');
- return $o;
+ $contacts = Contact\Relation::getSuggestions(local_user());
+ if (!DBA::isResult($contacts)) {
+ return DI::l10n()->t('No suggestions available. If this is a new site, please try again in 24 hours.');
}
-
- if (!empty($_GET['ignore'])) {
- //