diff --git a/mod/item.php b/mod/item.php
index f4dcf187fa..de9a51915a 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -131,10 +131,10 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
$post = DI::contentItem()->initializePost($post);
$post['edit'] = null;
- $post['post-type'] = $request['post_type'] ?? '';
- $post['wall'] = $request['wall'] ?? true;
+ $post['post-type'] = $request['post_type'] ?? '';
+ $post['wall'] = $request['wall'] ?? true;
$post['pubmail'] = $request['pubmail_enable'] ?? false;
- $post['created'] = $request['created_at'] ?? DateTimeFormat::utcNow();
+ $post['created'] = $request['created_at'] ?? DateTimeFormat::utcNow();
$post['edited'] = $post['changed'] = $post['commented'] = $post['created'];
$post['app'] = '';
$post['inform'] = '';
@@ -167,15 +167,15 @@ function item_insert(int $uid, array $request, bool $preview, string $return_pat
DI::logger()->info('Public item stored for user', ['uri-id' => $toplevel_item['uri-id'], 'uid' => $post['uid'], 'stored' => $stored]);
}
- $post['parent'] = $toplevel_item['id'];
- $post['gravity'] = Item::GRAVITY_COMMENT;
- $post['thr-parent'] = $parent_item['uri'];
- $post['wall'] = $toplevel_item['wall'];
+ $post['parent'] = $toplevel_item['id'];
+ $post['gravity'] = Item::GRAVITY_COMMENT;
+ $post['thr-parent'] = $parent_item['uri'];
+ $post['wall'] = $toplevel_item['wall'];
} else {
- $parent_item = [];
- $post['parent'] = 0;
- $post['gravity'] = Item::GRAVITY_PARENT;
- $post['thr-parent'] = $post['uri'];
+ $parent_item = [];
+ $post['parent'] = 0;
+ $post['gravity'] = Item::GRAVITY_PARENT;
+ $post['thr-parent'] = $post['uri'];
}
$post = DI::contentItem()->getACL($post, $parent_item, $request);
diff --git a/mod/photos.php b/mod/photos.php
index 779d229000..c2831270ab 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -114,8 +114,8 @@ function photos_post()
throw new HTTPException\NotFoundException(DI::l10n()->t('User not found.'));
}
- $can_post = false;
- $visitor = 0;
+ $can_post = false;
+ $visitor = 0;
$page_owner_uid = intval($user['uid']);
$community_page = in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_COMM_MAN]);
@@ -124,8 +124,8 @@ function photos_post()
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($page_owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($page_owner_uid);
- $can_post = true;
- $visitor = $contact_id;
+ $can_post = true;
+ $visitor = $contact_id;
}
if (!$can_post) {
@@ -141,7 +141,7 @@ function photos_post()
System::exit();
}
- $aclFormatter = DI::aclFormatter();
+ $aclFormatter = DI::aclFormatter();
$str_contact_allow = isset($_REQUEST['contact_allow']) ? $aclFormatter->toString($_REQUEST['contact_allow']) : $owner_record['allow_cid'] ?? '';
$str_circle_allow = isset($_REQUEST['circle_allow']) ? $aclFormatter->toString($_REQUEST['circle_allow']) : $owner_record['allow_gid'] ?? '';
$str_contact_deny = isset($_REQUEST['contact_deny']) ? $aclFormatter->toString($_REQUEST['contact_deny']) : $owner_record['deny_cid'] ?? '';
@@ -151,7 +151,7 @@ function photos_post()
if ($visibility === 'public') {
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
$str_contact_allow = $str_circle_allow = $str_contact_deny = $str_circle_deny = '';
- } else if ($visibility === 'custom') {
+ } elseif ($visibility === 'custom') {
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
// case that would make it public. So we always append the author's contact id to the allowed contacts.
// See https://github.com/friendica/friendica/issues/9672
@@ -317,7 +317,7 @@ function photos_post()
if (DBA::isResult($photos)) {
$photo = $photos[0];
- $ext = Images::getExtensionByMimeType($photo['type']);
+ $ext = Images::getExtensionByMimeType($photo['type']);
Photo::update(
['desc' => $desc, 'album' => $albname, 'allow_cid' => $str_contact_allow, 'allow_gid' => $str_circle_allow, 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_circle_deny],
['resource-id' => $resource_id, 'uid' => $page_owner_uid]
@@ -332,9 +332,9 @@ function photos_post()
if (DBA::isResult($photos) && !$item_id) {
// Create item container
$title = '';
- $uri = Item::newURI();
+ $uri = Item::newURI();
- $arr = [];
+ $arr = [];
$arr['guid'] = System::createUUID();
$arr['uid'] = $page_owner_uid;
$arr['uri'] = $uri;
@@ -356,7 +356,7 @@ function photos_post()
$arr['visible'] = 0;
$arr['origin'] = 1;
- $arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
+ $arr['body'] = Images::getBBCodeByResource($photo['resource-id'], $user['nickname'], $photo['scale'], $ext);
$item_id = Item::insert($arr);
}
@@ -370,7 +370,7 @@ function photos_post()
}
if (strlen($rawtags)) {
- $inform = '';
+ $inform = '';
// if the new tag doesn't have a namespace specifier (@foo or #foo) give it a hashtag
$x = substr($rawtags, 0, 1);
@@ -379,13 +379,13 @@ function photos_post()
}
$taginfo = [];
- $tags = BBCode::getTags($rawtags);
+ $tags = BBCode::getTags($rawtags);
if (count($tags)) {
foreach ($tags as $tag) {
if (strpos($tag, '@') === 0) {
$profile = '';
- $name = substr($tag, 1);
+ $name = substr($tag, 1);
$contact = Contact::getByURL($name);
if (empty($contact)) {
$newname = $name;
@@ -453,7 +453,7 @@ function photos_post()
}
$newinform .= $inform;
- $fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
+ $fields = ['inform' => $newinform, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
$condition = ['id' => $item_id];
Item::update($fields, $condition);
@@ -552,7 +552,7 @@ function photos_content()
$datum = null;
if (DI::args()->getArgc() > 3) {
$datatype = DI::args()->getArgv()[2];
- $datum = DI::args()->getArgv()[3];
+ $datum = DI::args()->getArgv()[3];
} elseif ((DI::args()->getArgc() > 2) && (DI::args()->getArgv()[2] === 'upload')) {
$datatype = 'upload';
} else {
@@ -582,12 +582,12 @@ function photos_content()
$can_post = true;
} elseif ($community_page && !empty(DI::userSession()->getRemoteContactID($owner_uid))) {
$contact_id = DI::userSession()->getRemoteContactID($owner_uid);
- $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
+ $contact = DBA::selectFirst('contact', [], ['id' => $contact_id, 'uid' => $owner_uid, 'blocked' => false, 'pending' => false]);
if (DBA::isResult($contact)) {
- $can_post = true;
+ $can_post = true;
$remote_contact = true;
- $visitor = $contact_id;
+ $visitor = $contact_id;
}
}
@@ -643,14 +643,14 @@ function photos_content()
$uploader = '';
$ret = [
- 'post_url' => 'profile/' . $user['nickname'] . '/photos',
- 'addon_text' => $uploader,
+ 'post_url' => 'profile/' . $user['nickname'] . '/photos',
+ 'addon_text' => $uploader,
'default_upload' => true
];
Hook::callAll('photo_upload_form', $ret);
- $default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
+ $default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
$default_upload_submit = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_submit.tpl'), [
'$submit' => DI::l10n()->t('Submit'),
]);
@@ -675,22 +675,22 @@ function photos_content()
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId()));
$o .= Renderer::replaceMacros($tpl, [
- '$pagename' => DI::l10n()->t('Upload Photos'),
- '$sessid' => session_id(),
- '$usage' => $usage_message,
- '$nickname' => $user['nickname'],
- '$newalbum' => DI::l10n()->t('New album name: '),
- '$existalbumtext' => DI::l10n()->t('or select existing album:'),
- '$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
- '$albumselect' => $albumselect,
- '$selname' => $selname,
- '$permissions' => DI::l10n()->t('Permissions'),
- '$aclselect' => $aclselect_e,
- '$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
- '$alt_uploader' => $ret['addon_text'],
- '$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
+ '$pagename' => DI::l10n()->t('Upload Photos'),
+ '$sessid' => session_id(),
+ '$usage' => $usage_message,
+ '$nickname' => $user['nickname'],
+ '$newalbum' => DI::l10n()->t('New album name: '),
+ '$existalbumtext' => DI::l10n()->t('or select existing album:'),
+ '$nosharetext' => DI::l10n()->t('Do not show a status post for this upload'),
+ '$albumselect' => $albumselect,
+ '$selname' => $selname,
+ '$permissions' => DI::l10n()->t('Permissions'),
+ '$aclselect' => $aclselect_e,
+ '$lockstate' => ACL::getLockstateForUserId(DI::userSession()->getLocalUserId()) ? 'lock' : 'unlock',
+ '$alt_uploader' => $ret['addon_text'],
+ '$default_upload_box' => ($ret['default_upload'] ? $default_upload_box : ''),
'$default_upload_submit' => ($ret['default_upload'] ? $default_upload_submit : ''),
- '$uploadurl' => $ret['post_url'],
+ '$uploadurl' => $ret['post_url'],
// ACL permissions box
'$return_path' => DI::args()->getQueryString(),
@@ -712,7 +712,7 @@ function photos_content()
}
$total = 0;
- $r = DBA::toArray(DBA::p(
+ $r = DBA::toArray(DBA::p(
"SELECT `resource-id`, MAX(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `album` = ?
AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
$owner_uid,
@@ -748,7 +748,7 @@ function photos_content()
$drop_url = DI::args()->getQueryString();
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
- '$l10n' => [
+ '$l10n' => [
'message' => DI::l10n()->t('Do you really want to delete this photo album and all its photos?'),
'confirm' => DI::l10n()->t('Delete Album'),
'cancel' => DI::l10n()->t('Cancel'),
@@ -768,11 +768,11 @@ function photos_content()
$album_e = $album;
$o .= Renderer::replaceMacros($edit_tpl, [
- '$nametext' => DI::l10n()->t('New album name: '),
- '$nickname' => $user['nickname'],
- '$album' => $album_e,
- '$hexalbum' => bin2hex($album),
- '$submit' => DI::l10n()->t('Submit'),
+ '$nametext' => DI::l10n()->t('New album name: '),
+ '$nickname' => $user['nickname'],
+ '$album' => $album_e,
+ '$hexalbum' => bin2hex($album),
+ '$submit' => DI::l10n()->t('Submit'),
'$dropsubmit' => DI::l10n()->t('Delete Album')
]);
}
@@ -782,7 +782,7 @@ function photos_content()
}
if ($order_field === 'created') {
- $order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
+ $order = [DI::l10n()->t('Show Newest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album), 'oldest'];
} else {
$order = [DI::l10n()->t('Show Oldest First'), 'photos/' . $user['nickname'] . '/album/' . bin2hex($album) . '?order=created', 'newest'];
}
@@ -798,7 +798,7 @@ function photos_content()
$ext = Images::getExtensionByMimeType($rr['type']);
$imgalt_e = $rr['filename'];
- $desc_e = $rr['desc'];
+ $desc_e = $rr['desc'];
$photos[] = [
'id' => $rr['id'],
@@ -817,13 +817,13 @@ function photos_content()
$tpl = Renderer::getMarkupTemplate('photo_album.tpl');
$o .= Renderer::replaceMacros($tpl, [
- '$photos' => $photos,
- '$album' => $album,
+ '$photos' => $photos,
+ '$album' => $album,
'$can_post' => $can_post,
- '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
- '$order' => $order,
- '$edit' => $edit,
- '$drop' => $drop,
+ '$upload' => [DI::l10n()->t('Upload New Photos'), 'photos/' . $user['nickname'] . '/upload/' . bin2hex($album)],
+ '$order' => $order,
+ '$edit' => $edit,
+ '$drop' => $drop,
'$paginate' => $pager->renderFull($total),
]);
@@ -848,7 +848,7 @@ function photos_content()
$drop_url = DI::args()->getQueryString();
return Renderer::replaceMacros(Renderer::getMarkupTemplate('confirm.tpl'), [
- '$l10n' => [
+ '$l10n' => [
'message' => DI::l10n()->t('Do you really want to delete this photo?'),
'confirm' => DI::l10n()->t('Delete Photo'),
'cancel' => DI::l10n()->t('Cancel'),
@@ -950,8 +950,8 @@ function photos_content()
if ($cmd === 'edit') {
$tools['view'] = ['photos/' . $user['nickname'] . '/image/' . $datum, DI::l10n()->t('View photo')];
} else {
- $tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
- $tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
+ $tools['edit'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/edit', DI::l10n()->t('Edit photo')];
+ $tools['delete'] = ['photos/' . $user['nickname'] . '/image/' . $datum . '/drop', DI::l10n()->t('Delete photo')];
$tools['profile'] = ['settings/profile/photo/crop/' . $ph[0]['resource-id'], DI::l10n()->t('Use as profile photo')];
}
@@ -973,9 +973,9 @@ function photos_content()
'filename' => $hires['filename'],
];
- $map = null;
+ $map = null;
$link_item = [];
- $total = 0;
+ $total = 0;
// Do we have an item for this photo?
@@ -989,12 +989,12 @@ function photos_content()
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
$condition = ["`parent` = ? AND `gravity` = ?", $link_item['parent'], Item::GRAVITY_COMMENT];
- $total = Post::count($condition);
+ $total = Post::count($condition);
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
- $items = Post::toArray(Post::selectForUser($link_item['uid'], array_merge(Item::ITEM_FIELDLIST, ['author-alias']), $condition, $params));
+ $items = Post::toArray(Post::selectForUser($link_item['uid'], array_merge(Item::ITEM_FIELDLIST, ['author-alias']), $condition, $params));
if (DI::userSession()->getLocalUserId() == $link_item['uid']) {
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
@@ -1021,51 +1021,51 @@ function photos_content()
$tags = ['title' => DI::l10n()->t('Tags: '), 'tags' => $tag_arr];
if ($cmd === 'edit') {
$tags['removeanyurl'] = 'post/' . $link_item['id'] . '/tag/remove?return=' . urlencode(DI::args()->getCommand());
- $tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
+ $tags['removetitle'] = DI::l10n()->t('[Select tags to remove]');
}
}
- $edit = Null;
+ $edit = null;
if ($cmd === 'edit' && $can_post) {
$edit_tpl = Renderer::getMarkupTemplate('photo_edit.tpl');
- $album_e = $ph[0]['album'];
- $caption_e = $ph[0]['desc'];
+ $album_e = $ph[0]['album'];
+ $caption_e = $ph[0]['desc'];
$aclselect_e = ACL::getFullSelectorHTML(DI::page(), DI::userSession()->getLocalUserId(), false, ACL::getDefaultUserPermissions($ph[0]));
$edit = Renderer::replaceMacros($edit_tpl, [
- '$id' => $ph[0]['id'],
- '$album' => ['albname', DI::l10n()->t('New album name'), $album_e, ''],
- '$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
- '$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
+ '$id' => $ph[0]['id'],
+ '$album' => ['albname', DI::l10n()->t('New album name'), $album_e, ''],
+ '$caption' => ['desc', DI::l10n()->t('Caption'), $caption_e, ''],
+ '$tags' => ['newtag', DI::l10n()->t('Add a Tag'), "", DI::l10n()->t('Example: @bob, @Barbara_Jensen, @jim@example.com, #California, #camping')],
'$rotate_none' => ['rotate', DI::l10n()->t('Do not rotate'), 0, '', true],
- '$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"), 1, ''],
- '$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"), 2, ''],
+ '$rotate_cw' => ['rotate', DI::l10n()->t("Rotate CW \x28right\x29"), 1, ''],
+ '$rotate_ccw' => ['rotate', DI::l10n()->t("Rotate CCW \x28left\x29"), 2, ''],
- '$nickname' => $user['nickname'],
+ '$nickname' => $user['nickname'],
'$resource_id' => $ph[0]['resource-id'],
'$permissions' => DI::l10n()->t('Permissions'),
- '$aclselect' => $aclselect_e,
+ '$aclselect' => $aclselect_e,
'$item_id' => $link_item['id'] ?? 0,
- '$submit' => DI::l10n()->t('Submit'),
- '$delete' => DI::l10n()->t('Delete Photo'),
+ '$submit' => DI::l10n()->t('Submit'),
+ '$delete' => DI::l10n()->t('Delete Photo'),
// ACL permissions box
'$return_path' => DI::args()->getQueryString(),
]);
}
- $like = '';
- $dislike = '';
+ $like = '';
+ $dislike = '';
$likebuttons = '';
- $comments = '';
- $paginate = '';
+ $comments = '';
+ $paginate = '';
if (!empty($link_item['id']) && !empty($link_item['uri'])) {
- $cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
- $tpl = Renderer::getMarkupTemplate('photo_item.tpl');
+ $cmnt_tpl = Renderer::getMarkupTemplate('comment_item.tpl');
+ $tpl = Renderer::getMarkupTemplate('photo_item.tpl');
$return_path = DI::args()->getCommand();
if (!DBA::isResult($items)) {
@@ -1076,25 +1076,25 @@ function photos_content()
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
- $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
+ $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
- '$jsreload' => $return_path,
- '$id' => $link_item['id'],
- '$parent' => $link_item['id'],
- '$profile_uid' => $owner_uid,
- '$mylink' => $contact['url'],
- '$mytitle' => DI::l10n()->t('This is you'),
- '$myphoto' => $contact['thumb'],
- '$comment' => DI::l10n()->t('Comment'),
- '$submit' => DI::l10n()->t('Submit'),
- '$preview' => DI::l10n()->t('Preview'),
- '$loading' => DI::l10n()->t('Loading...'),
- '$qcomment' => $qcomment,
- '$rand_num' => Crypto::randomDigits(12),
+ '$jsreload' => $return_path,
+ '$id' => $link_item['id'],
+ '$parent' => $link_item['id'],
+ '$profile_uid' => $owner_uid,
+ '$mylink' => $contact['url'],
+ '$mytitle' => DI::l10n()->t('This is you'),
+ '$myphoto' => $contact['thumb'],
+ '$comment' => DI::l10n()->t('Comment'),
+ '$submit' => DI::l10n()->t('Submit'),
+ '$preview' => DI::l10n()->t('Preview'),
+ '$loading' => DI::l10n()->t('Loading...'),
+ '$qcomment' => $qcomment,
+ '$rand_num' => Crypto::randomDigits(12),
]);
}
}
@@ -1132,29 +1132,29 @@ function photos_content()
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
- $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
+ $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
- '$jsreload' => $return_path,
- '$id' => $link_item['id'],
- '$parent' => $link_item['id'],
- '$profile_uid' => $owner_uid,
- '$mylink' => $contact['url'],
- '$mytitle' => DI::l10n()->t('This is you'),
- '$myphoto' => $contact['thumb'],
- '$comment' => DI::l10n()->t('Comment'),
- '$submit' => DI::l10n()->t('Submit'),
- '$preview' => DI::l10n()->t('Preview'),
- '$qcomment' => $qcomment,
- '$rand_num' => Crypto::randomDigits(12),
+ '$jsreload' => $return_path,
+ '$id' => $link_item['id'],
+ '$parent' => $link_item['id'],
+ '$profile_uid' => $owner_uid,
+ '$mylink' => $contact['url'],
+ '$mytitle' => DI::l10n()->t('This is you'),
+ '$myphoto' => $contact['thumb'],
+ '$comment' => DI::l10n()->t('Comment'),
+ '$submit' => DI::l10n()->t('Submit'),
+ '$preview' => DI::l10n()->t('Preview'),
+ '$qcomment' => $qcomment,
+ '$rand_num' => Crypto::randomDigits(12),
]);
}
foreach ($items as $item) {
- $comment = '';
+ $comment = '';
$template = $tpl;
$activity = DI::activity();
@@ -1181,7 +1181,7 @@ function photos_content()
}
$dropping = (($item['contact-id'] == $contact_id) || ($item['uid'] == DI::userSession()->getLocalUserId()));
- $drop = [
+ $drop = [
'dropping' => $dropping,
'pagedrop' => false,
'select' => DI::l10n()->t('Select'),
@@ -1189,7 +1189,7 @@ function photos_content()
];
$title_e = $item['title'];
- $body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
+ $body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
$comments .= Renderer::replaceMacros($template, [
'$id' => $item['id'],
@@ -1212,24 +1212,24 @@ function photos_content()
*/
$qcomment = null;
if (Addon::isEnabled('qcomment')) {
- $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
+ $words = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'qcomment', 'words');
$qcomment = $words ? explode("\n", $words) : [];
}
$comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
- '$jsreload' => $return_path,
- '$id' => $item['id'],
- '$parent' => $item['parent'],
- '$profile_uid' => $owner_uid,
- '$mylink' => $contact['url'],
- '$mytitle' => DI::l10n()->t('This is you'),
- '$myphoto' => $contact['thumb'],
- '$comment' => DI::l10n()->t('Comment'),
- '$submit' => DI::l10n()->t('Submit'),
- '$preview' => DI::l10n()->t('Preview'),
- '$qcomment' => $qcomment,
- '$rand_num' => Crypto::randomDigits(12),
+ '$jsreload' => $return_path,
+ '$id' => $item['id'],
+ '$parent' => $item['parent'],
+ '$profile_uid' => $owner_uid,
+ '$mylink' => $contact['url'],
+ '$mytitle' => DI::l10n()->t('This is you'),
+ '$myphoto' => $contact['thumb'],
+ '$comment' => DI::l10n()->t('Comment'),
+ '$submit' => DI::l10n()->t('Submit'),
+ '$preview' => DI::l10n()->t('Preview'),
+ '$qcomment' => $qcomment,
+ '$rand_num' => Crypto::randomDigits(12),
]);
}
}
@@ -1243,17 +1243,17 @@ function photos_content()
}
if ($cmd === 'view' && ($can_post || Security::canWriteToUserWall($owner_uid))) {
- $like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
+ $like_tpl = Renderer::getMarkupTemplate('like_noshare.tpl');
$likebuttons = Renderer::replaceMacros($like_tpl, [
- '$id' => $link_item['id'],
- '$like' => DI::l10n()->t('Like'),
- '$like_title' => DI::l10n()->t('I like this (toggle)'),
- '$dislike' => DI::l10n()->t('Dislike'),
- '$wait' => DI::l10n()->t('Please wait'),
+ '$id' => $link_item['id'],
+ '$like' => DI::l10n()->t('Like'),
+ '$like_title' => DI::l10n()->t('I like this (toggle)'),
+ '$dislike' => DI::l10n()->t('Dislike'),
+ '$wait' => DI::l10n()->t('Please wait'),
'$dislike_title' => DI::l10n()->t('I don\'t like this (toggle)'),
- '$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
- '$responses' => $responses,
- '$return_path' => DI::args()->getQueryString(),
+ '$hide_dislike' => DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike'),
+ '$responses' => $responses,
+ '$return_path' => DI::args()->getQueryString(),
]);
}
@@ -1262,22 +1262,22 @@ function photos_content()
$photo_tpl = Renderer::getMarkupTemplate('photo_view.tpl');
$o .= Renderer::replaceMacros($photo_tpl, [
- '$id' => $ph[0]['id'],
- '$album' => [$album_link, $ph[0]['album']],
- '$tools' => $tools,
- '$photo' => $photo,
- '$prevlink' => $prevlink,
- '$nextlink' => $nextlink,
- '$desc' => $ph[0]['desc'],
- '$tags' => $tags,
- '$edit' => $edit,
- '$map' => $map,
- '$map_text' => DI::l10n()->t('Map'),
+ '$id' => $ph[0]['id'],
+ '$album' => [$album_link, $ph[0]['album']],
+ '$tools' => $tools,
+ '$photo' => $photo,
+ '$prevlink' => $prevlink,
+ '$nextlink' => $nextlink,
+ '$desc' => $ph[0]['desc'],
+ '$tags' => $tags,
+ '$edit' => $edit,
+ '$map' => $map,
+ '$map_text' => DI::l10n()->t('Map'),
'$likebuttons' => $likebuttons,
- '$like' => $like,
- '$dislike' => $dislike,
- '$comments' => $comments,
- '$paginate' => $paginate,
+ '$like' => $like,
+ '$dislike' => $dislike,
+ '$comments' => $comments,
+ '$paginate' => $paginate,
]);
DI::page()['htmlhead'] .= "\n" . '' . "\n";
diff --git a/src/App/Page.php b/src/App/Page.php
index 45293b1e05..87493a67e4 100644
--- a/src/App/Page.php
+++ b/src/App/Page.php
@@ -81,7 +81,7 @@ class Page implements ArrayAccess
public function __construct(string $basepath)
{
$this->timestamp = microtime(true);
- $this->basePath = $basepath;
+ $this->basePath = $basepath;
}
public function setLogging(string $method, string $module, string $command)
@@ -445,7 +445,7 @@ class Page implements ArrayAccess
$this->initContent($response, $mode);
// Load current theme info after module has been initialized as theme could have been set in module
- $currentTheme = $appHelper->getCurrentTheme();
+ $currentTheme = $appHelper->getCurrentTheme();
$theme_info_file = 'view/theme/' . $currentTheme . '/theme.php';
if (file_exists($theme_info_file)) {
require_once $theme_info_file;
@@ -479,7 +479,7 @@ class Page implements ArrayAccess
// Add the navigation (menu) template
if ($moduleName != 'install' && $moduleName != 'maintenance') {
$this->page['htmlhead'] .= Renderer::replaceMacros(Renderer::getMarkupTemplate('nav_head.tpl'), []);
- $this->page['nav'] = $nav->getHtml();
+ $this->page['nav'] = $nav->getHtml();
}
// Build the page - now that we have all the components
@@ -512,7 +512,7 @@ class Page implements ArrayAccess
}
}
- $page = $this->page;
+ $page = $this->page;
// add and escape some common but crucial content for direct "echo" in HTML (security)
$page['title'] = htmlspecialchars($page['title'] ?? '');
diff --git a/src/Contact/Avatar.php b/src/Contact/Avatar.php
index b7ec5372a0..677ab8e048 100644
--- a/src/Contact/Avatar.php
+++ b/src/Contact/Avatar.php
@@ -215,7 +215,7 @@ class Avatar
}
$avatarpath = parse_url(self::baseUrl(), PHP_URL_PATH);
- $pos = strpos($parts['path'], $avatarpath);
+ $pos = strpos($parts['path'], $avatarpath);
if ($pos !== 0) {
return '';
}
diff --git a/src/Content/Item.php b/src/Content/Item.php
index d6e4cb7d59..943bda4591 100644
--- a/src/Content/Item.php
+++ b/src/Content/Item.php
@@ -116,8 +116,8 @@ class Item
public function determineCategoriesTerms(array $item, int $uid = 0): array
{
$categories = [];
- $folders = [];
- $first = true;
+ $folders = [];
+ $first = true;
$uid = $item['uid'] ?: $uid;
@@ -132,11 +132,11 @@ class Item
$url = '#';
}
$categories[] = [
- 'name' => $savedFolderName,
- 'url' => $url,
+ 'name' => $savedFolderName,
+ 'url' => $url,
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?cat=' . rawurlencode($savedFolderName) : '',
- 'first' => $first,
- 'last' => false
+ 'first' => $first,
+ 'last' => false
];
$first = false;
}
@@ -148,11 +148,11 @@ class Item
if ($this->userSession->getLocalUserId() == $uid) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $uid, Post\Category::FILE) as $savedFolderName) {
$folders[] = [
- 'name' => $savedFolderName,
- 'url' => "#",
+ 'name' => $savedFolderName,
+ 'url' => "#",
'removeurl' => $this->userSession->getLocalUserId() == $uid ? 'filerm/' . $item['id'] . '?term=' . rawurlencode($savedFolderName) : '',
- 'first' => $first,
- 'last' => false
+ 'first' => $first,
+ 'last' => false
];
$first = false;
}
@@ -197,55 +197,55 @@ class Item
// Sometimes the tag detection doesn't seem to work right
// This is some workaround
$nameparts = explode(' ', $name);
- $name = $nameparts[0];
+ $name = $nameparts[0];
// Try to detect the contact in various ways
if (strpos($name, 'http://') || strpos($name, '@')) {
$contact = Contact::getByURLForUser($name, $profile_uid);
} else {
$contact = false;
- $fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
+ $fields = ['id', 'url', 'nick', 'name', 'alias', 'network', 'forum', 'prv'];
if (strrpos($name, '+')) {
// Is it in format @nick+number?
- $tagcid = intval(substr($name, strrpos($name, '+') + 1));
+ $tagcid = intval(substr($name, strrpos($name, '+') + 1));
$contact = DBA::selectFirst('contact', $fields, ['id' => $tagcid, 'uid' => $profile_uid]);
}
// select someone by nick in the current network
if (!DBA::isResult($contact) && ($network != '')) {
$condition = ['nick' => $name, 'network' => $network, 'uid' => $profile_uid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by attag in the current network
if (!DBA::isResult($contact) && ($network != '')) {
$condition = ['attag' => $name, 'network' => $network, 'uid' => $profile_uid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
//select someone by name in the current network
if (!DBA::isResult($contact) && ($network != '')) {
$condition = ['name' => $name, 'network' => $network, 'uid' => $profile_uid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by nick in any network
if (!DBA::isResult($contact)) {
$condition = ['nick' => $name, 'uid' => $profile_uid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by attag in any network
if (!DBA::isResult($contact)) {
$condition = ['attag' => $name, 'uid' => $profile_uid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
// select someone by name in any network
if (!DBA::isResult($contact)) {
$condition = ['name' => $name, 'uid' => $profile_uid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
}
}
@@ -262,8 +262,8 @@ class Item
$replaced = true;
// create profile link
$profile = str_replace(',', '%2c', $profile);
- $newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
- $body = str_replace($tag_type . $name, $newtag, $body);
+ $newtag = $tag_type . '[url=' . $profile . ']' . $newname . '[/url]';
+ $body = str_replace($tag_type . $name, $newtag, $body);
}
}
@@ -303,7 +303,7 @@ class Item
'url' => $item['author-link'],
'alias' => $item['author-alias'],
];
- $author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
+ $author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
$author_arr = [
'uid' => 0,
@@ -312,7 +312,7 @@ class Item
'url' => $obj['author-link'],
'alias' => $obj['author-alias'],
];
- $objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
+ $objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
switch ($obj['verb']) {
case Activity::POST:
@@ -340,7 +340,7 @@ class Item
$parsedobj = XML::parseString($xmlhead . $item['object']);
- $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
+ $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
$item['body'] = $this->l10n->t('%1$s tagged %2$s\'s %3$s with %4$s', $author, $objauthor, $plink, $tag);
}
}
@@ -358,7 +358,7 @@ class Item
public function photoMenu(array $item, string $formSecurityToken): string
{
$this->profiler->startRecording('rendering');
- $sub_link = $contact_url = $pm_url = $status_link = '';
+ $sub_link = $contact_url = $pm_url = $status_link = '';
$photos_link = $posts_link = $block_link = $ignore_link = $collapse_link = $ignoreserver_link = '';
if ($this->userSession->getLocalUserId() && $this->userSession->getLocalUserId() == $item['uid'] && $item['gravity'] == ItemModel::GRAVITY_PARENT && !$item['self'] && !$item['mention']) {
@@ -379,16 +379,16 @@ class Item
$profile_link = $profile_link . '?' . http_build_query(['url' => $item['author-link'] . '/profile']);
}
- $cid = 0;
- $pcid = $item['author-id'];
- $network = '';
- $rel = 0;
+ $cid = 0;
+ $pcid = $item['author-id'];
+ $network = '';
+ $rel = 0;
$condition = ['uid' => $this->userSession->getLocalUserId(), 'uri-id' => $item['author-uri-id']];
- $contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'network', 'rel'], $condition);
if (DBA::isResult($contact)) {
- $cid = $contact['id'];
+ $cid = $contact['id'];
$network = $contact['network'];
- $rel = $contact['rel'];
+ $rel = $contact['rel'];
}
if (!empty($pcid)) {
@@ -415,16 +415,16 @@ class Item
if ($this->userSession->getLocalUserId()) {
$menu = [
- $this->l10n->t('Follow Thread') => $sub_link,
- $this->l10n->t('View Status') => $status_link,
- $this->l10n->t('View Profile') => $profile_link,
- $this->l10n->t('View Photos') => $photos_link,
- $this->l10n->t('Network Posts') => $posts_link,
- $this->l10n->t('View Contact') => $contact_url,
- $this->l10n->t('Send PM') => $pm_url,
- $this->l10n->t('Block') => $block_link,
- $this->l10n->t('Ignore') => $ignore_link,
- $this->l10n->t('Collapse') => $collapse_link,
+ $this->l10n->t('Follow Thread') => $sub_link,
+ $this->l10n->t('View Status') => $status_link,
+ $this->l10n->t('View Profile') => $profile_link,
+ $this->l10n->t('View Photos') => $photos_link,
+ $this->l10n->t('Network Posts') => $posts_link,
+ $this->l10n->t('View Contact') => $contact_url,
+ $this->l10n->t('Send PM') => $pm_url,
+ $this->l10n->t('Block') => $block_link,
+ $this->l10n->t('Ignore') => $ignore_link,
+ $this->l10n->t('Collapse') => $collapse_link,
$this->l10n->t("Ignore %s server", $authorBaseUri->getHost()) => $ignoreserver_link,
];
@@ -517,13 +517,13 @@ class Item
if (!empty($contact['prv']) || ($tag[1] == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION])) {
$private_group = $contact['prv'];
$only_to_group = ($tag[1] == Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]);
- $private_id = $contact['id'];
+ $private_id = $contact['id'];
$group_contact = $contact;
DI::logger()->info('Private group or exclusive mention', ['url' => $tag[2], 'mention' => $tag[1]]);
} elseif ($item['allow_cid'] == '<' . $contact['id'] . '>') {
$private_group = false;
$only_to_group = true;
- $private_id = $contact['id'];
+ $private_id = $contact['id'];
$group_contact = $contact;
DI::logger()->info('Public group', ['url' => $tag[2], 'mention' => $tag[1]]);
} else {
@@ -561,7 +561,7 @@ class Item
} elseif ($setPermissions) {
if (empty($receivers)) {
// For security reasons direct posts without any receiver will be posts to yourself
- $self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
+ $self = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
$receivers[] = $self['id'];
}
@@ -605,9 +605,9 @@ class Item
$owner_updated = '';
$owner_thumb = $item['contact-avatar'];
} else {
- $owner_avatar = $item['owner-id'];
- $owner_updated = $item['owner-updated'];
- $owner_thumb = $item['owner-avatar'];
+ $owner_avatar = $item['owner-id'];
+ $owner_updated = $item['owner-updated'];
+ $owner_thumb = $item['owner-avatar'];
}
if (empty($owner_thumb) || Photo::isPhotoURI($owner_thumb)) {
@@ -634,7 +634,7 @@ class Item
return $body;
}
- $fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'quote-uri-id'];
+ $fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network', 'quote-uri-id'];
$shared_item = Post::selectFirst($fields, ['uri-id' => $item['quote-uri-id'], 'uid' => [$item['uid'], 0], 'private' => [ItemModel::PUBLIC, ItemModel::UNLISTED]]);
if (!DBA::isResult($shared_item)) {
DI::logger()->notice('Post does not exist.', ['uri-id' => $item['quote-uri-id'], 'uid' => $item['uid']]);
@@ -649,7 +649,7 @@ class Item
*/
private function createSharedPostByGuid(string $guid, bool $add_media): string
{
- $fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
+ $fields = ['uri-id', 'uri', 'body', 'title', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink', 'network'];
$shared_item = Post::selectFirst($fields, ['guid' => $guid, 'uid' => 0, 'private' => [ItemModel::PUBLIC, ItemModel::UNLISTED]]);
if (!DBA::isResult($shared_item)) {
@@ -800,14 +800,14 @@ class Item
public function storeAttachmentFromRequest(array $request): string
{
- $attachment_type = $request['attachment_type'] ?? '';
+ $attachment_type = $request['attachment_type'] ?? '';
$attachment_title = $request['attachment_title'] ?? '';
- $attachment_text = $request['attachment_text'] ?? '';
+ $attachment_text = $request['attachment_text'] ?? '';
- $attachment_url = hex2bin($request['attachment_url'] ?? '');
+ $attachment_url = hex2bin($request['attachment_url'] ?? '');
$attachment_img_src = hex2bin($request['attachment_img_src'] ?? '');
- $attachment_img_width = $request['attachment_img_width'] ?? 0;
+ $attachment_img_width = $request['attachment_img_width'] ?? 0;
$attachment_img_height = $request['attachment_img_height'] ?? 0;
// Fetch the basic attachment data
@@ -815,10 +815,10 @@ class Item
unset($attachment['keywords']);
// Overwrite the basic data with possible changes from the frontend
- $attachment['type'] = $attachment_type;
+ $attachment['type'] = $attachment_type;
$attachment['title'] = $attachment_title;
- $attachment['text'] = $attachment_text;
- $attachment['url'] = $attachment_url;
+ $attachment['text'] = $attachment_text;
+ $attachment['url'] = $attachment_url;
if (!empty($attachment_img_src)) {
$attachment['images'] = [
@@ -842,7 +842,7 @@ class Item
$filedas = FileTag::fileToArray($post['file']);
}
- $list_array = explode(',', trim($category));
+ $list_array = explode(',', trim($category));
$post['file'] = FileTag::arrayToFile($list_array, 'category');
if (!empty($filedas) && is_array($filedas)) {
@@ -858,8 +858,8 @@ class Item
if ($toplevel_item) {
$post['allow_cid'] = $toplevel_item['allow_cid'] ?? '';
$post['allow_gid'] = $toplevel_item['allow_gid'] ?? '';
- $post['deny_cid'] = $toplevel_item['deny_cid'] ?? '';
- $post['deny_gid'] = $toplevel_item['deny_gid'] ?? '';
+ $post['deny_cid'] = $toplevel_item['deny_cid'] ?? '';
+ $post['deny_gid'] = $toplevel_item['deny_gid'] ?? '';
$post['private'] = $toplevel_item['private'];
return $post;
}
@@ -878,7 +878,7 @@ class Item
if ($visibility === 'public') {
// The ACL selector introduced in version 2019.12 sends ACL input data even when the Public visibility is selected
$post['allow_cid'] = $post['allow_gid'] = $post['deny_cid'] = $post['deny_gid'] = '';
- } else if ($visibility === 'custom') {
+ } elseif ($visibility === 'custom') {
// Since we know from the visibility parameter the item should be private, we have to prevent the empty ACL
// case that would make it public. So we always append the author's contact id to the allowed contacts.
// See https://github.com/friendica/friendica/issues/9672
@@ -907,7 +907,7 @@ class Item
if ((preg_match_all("/\[bookmark\=([^\]]*)\](.*?)\[\/bookmark\]/ism", $post['body'], $match, PREG_SET_ORDER) || !empty($data['type']))
&& ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE)
) {
- $post['post-type'] = ItemModel::PT_PAGE;
+ $post['post-type'] = ItemModel::PT_PAGE;
$post['object-type'] = Activity\ObjectType::BOOKMARK;
}
@@ -925,10 +925,10 @@ class Item
$post['direction'] = Conversation::PUSH;
$post['received'] = DateTimeFormat::utcNow();
$post['origin'] = true;
- $post['wall'] = $post['wall'] ?? true;
- $post['guid'] = $post['guid'] ?? System::createUUID();
- $post['verb'] = $post['verb'] ?? Activity::POST;
- $post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
+ $post['wall'] = $post['wall'] ?? true;
+ $post['guid'] = $post['guid'] ?? System::createUUID();
+ $post['verb'] = $post['verb'] ?? Activity::POST;
+ $post['uri'] = $post['uri'] ?? ItemModel::newURI($post['guid']);
$post['thr-parent'] = $post['thr-parent'] ?? $post['uri'];
if (empty($post['gravity'])) {
@@ -989,7 +989,7 @@ class Item
// Convert links with empty descriptions to links without an explicit description
$post['body'] = trim(preg_replace('#\[url=([^\]]*?)\]\[/url\]#ism', '[url]$1[/url]', $post['body']));
$post['body'] = $this->bbCodeVideo->transform($post['body']);
- $post = $this->setObjectType($post);
+ $post = $this->setObjectType($post);
// Personal notes must never be altered to a group post.
if ($post['post-type'] != ItemModel::PT_PERSONAL_NOTE) {
@@ -1083,7 +1083,7 @@ class Item
}
if (($expire_interval > 0) && !empty($created)) {
- $expire_date = time() - ($expire_interval * 86400);
+ $expire_date = time() - ($expire_interval * 86400);
$created_date = strtotime($created);
if ($created_date < $expire_date) {
DI::logger()->notice('Item created before expiration interval.', ['created' => date('c', $created_date), 'expired' => date('c', $expire_date)]);
diff --git a/src/Content/PageInfo.php b/src/Content/PageInfo.php
index 99863b8910..93d2e46750 100644
--- a/src/Content/PageInfo.php
+++ b/src/Content/PageInfo.php
@@ -59,7 +59,7 @@ class PageInfo
$body = substr_replace($body, "\n[bookmark=" . $data['url'] . ']' . $linkTitle . "[/bookmark]\n", $existingAttachmentPos, 0);
} else {
$footer = self::getFooterFromData($data, $no_photos);
- $body = self::stripTrailingUrlFromBody($body, $data['url']);
+ $body = self::stripTrailingUrlFromBody($body, $data['url']);
$body .= "\n" . $footer;
}
@@ -215,8 +215,11 @@ class PageInfo
$taglist = [];
foreach ($data['keywords'] as $keyword) {
- $hashtag = str_replace([' ', '+', '/', '.', '#', "'"],
- ['', '', '', '', '', ''], $keyword);
+ $hashtag = str_replace(
+ [' ', '+', '/', '.', '#', "'"],
+ ['', '', '', '', '', ''],
+ $keyword
+ );
$taglist[] = $hashtag;
}
@@ -270,7 +273,7 @@ class PageInfo
protected static function stripTrailingUrlFromBody(string $body, string $url): string
{
$quotedUrl = preg_quote($url, '#');
- $body = preg_replace_callback("#(?:
+ $body = preg_replace_callback("#(?:
\[url]$quotedUrl\[/url]|
\[url=$quotedUrl]$quotedUrl\[/url]|
\[url=$quotedUrl]([^[]*?)\[/url]|
diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php
index 458041f4bc..f03dfa84be 100644
--- a/src/Content/Text/BBCode.php
+++ b/src/Content/Text/BBCode.php
@@ -130,10 +130,11 @@ class BBCode
break;
case 'title':
- $value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
- $value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
+ $value = self::toPlaintext(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
+ $value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
$data['title'] = self::escapeContent($value);
+ // no break
default:
$data[$field] = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
break;
@@ -289,7 +290,7 @@ class BBCode
// Remove all unneeded white space
do {
$oldtext = $text;
- $text = str_replace([' ', "\n", "\r", '"'], ' ', $text);
+ $text = str_replace([' ', "\n", "\r", '"'], ' ', $text);
} while ($oldtext != $text);
return trim($text);
@@ -330,12 +331,12 @@ class BBCode
DI::logger()->info('the total body length exceeds the limit', ['maxlen' => $maxlen, 'body_len' => strlen($body)]);
$orig_body = $body;
- $new_body = '';
- $textlen = 0;
+ $new_body = '';
+ $textlen = 0;
- $img_start = strpos($orig_body, '[img');
+ $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
- $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
+ $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
while (($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
@@ -349,7 +350,7 @@ class BBCode
if ($textlen < $maxlen) {
DI::logger()->debug('the limit happens before an embedded image');
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
- $textlen = $maxlen;
+ $textlen = $maxlen;
}
} else {
$new_body = $new_body . substr($orig_body, 0, $img_start);
@@ -363,7 +364,7 @@ class BBCode
if ($textlen < $maxlen) {
DI::logger()->debug('the limit happens before the end of a non-embedded image');
$new_body = $new_body . substr($orig_body, 0, $maxlen - $textlen);
- $textlen = $maxlen;
+ $textlen = $maxlen;
}
} else {
$new_body = $new_body . substr($orig_body, 0, $img_end);
@@ -377,9 +378,9 @@ class BBCode
$orig_body = '';
}
- $img_start = strpos($orig_body, '[img');
+ $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
- $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
+ $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
}
if (($textlen + strlen($orig_body)) > $maxlen) {
@@ -433,7 +434,7 @@ class BBCode
if (((strpos($data['text'], '[img=') !== false) || (strpos($data['text'], '[img]') !== false) || DI::config()->get('system', 'always_show_preview')) && !empty($data['image'])) {
$data['preview'] = $data['image'];
- $data['image'] = '';
+ $data['image'] = '';
}
$return = '';
@@ -506,11 +507,11 @@ class BBCode
}
$title = htmlentities($data['title'] ?? '', ENT_QUOTES, 'UTF-8', false);
- $text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
+ $text = htmlentities($data['text'], ENT_QUOTES, 'UTF-8', false);
if ($plaintext || (($title != '') && strstr($text, $title))) {
$data['title'] = $data['url'];
} elseif (($text != '') && strstr($title, $text)) {
- $data['text'] = $data['title'];
+ $data['text'] = $data['title'];
$data['title'] = $data['url'];
}
@@ -584,11 +585,11 @@ class BBCode
$res = [
'start' => [
- 'open' => $start_open,
+ 'open' => $start_open,
'close' => $start_close
],
'end' => [
- 'open' => $end_open,
+ 'open' => $end_open,
'close' => $end_open + strlen('[/' . $name . ']')
],
];
@@ -614,17 +615,17 @@ class BBCode
{
DI::profiler()->startRecording('rendering');
$occurrences = 0;
- $pos = self::getTagPosition($text, $name, $occurrences);
+ $pos = self::getTagPosition($text, $name, $occurrences);
while ($pos !== false && $occurrences++ < 1000) {
- $start = substr($text, 0, $pos['start']['open']);
+ $start = substr($text, 0, $pos['start']['open']);
$subject = substr($text, $pos['start']['open'], $pos['end']['close'] - $pos['start']['open']);
- $end = substr($text, $pos['end']['close']);
+ $end = substr($text, $pos['end']['close']);
if ($end === false) {
$end = '';
}
$subject = preg_replace($pattern, $replace, $subject);
- $text = $start . $subject . $end;
+ $text = $start . $subject . $end;
$pos = self::getTagPosition($text, $name, $occurrences);
}
@@ -636,13 +637,13 @@ class BBCode
private static function extractImagesFromItemBody(string $body): array
{
$saved_image = [];
- $orig_body = $body;
- $new_body = '';
+ $orig_body = $body;
+ $new_body = '';
- $cnt = 0;
- $img_start = strpos($orig_body, '[img');
+ $cnt = 0;
+ $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
- $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
+ $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
while (($img_st_close !== false) && ($img_end !== false)) {
$img_st_close++; // make it point to AFTER the closing bracket
$img_end += $img_start;
@@ -650,7 +651,7 @@ class BBCode
if (!strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) {
// This is an embedded image
$saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close));
- $new_body = $new_body . substr($orig_body, 0, $img_start) . '[$#saved_image' . $cnt . '#$]';
+ $new_body = $new_body . substr($orig_body, 0, $img_start) . '[$#saved_image' . $cnt . '#$]';
$cnt++;
} else {
@@ -664,9 +665,9 @@ class BBCode
$orig_body = '';
}
- $img_start = strpos($orig_body, '[img');
+ $img_start = strpos($orig_body, '[img');
$img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false);
- $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
+ $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false);
}
$new_body = $new_body . $orig_body;
@@ -736,7 +737,7 @@ class BBCode
$attributes = self::extractShareAttributes($matches[2]);
$attributes['comment'] = trim($matches[1]);
- $attributes['shared'] = trim($matches[3]);
+ $attributes['shared'] = trim($matches[3]);
DI::profiler()->stopRecording();
return $attributes;
@@ -796,13 +797,13 @@ class BBCode
function ($match) use ($callback, $uriid) {
$attributes = self::extractShareAttributes($match[2]);
- $author_contact = Contact::getByURL($attributes['profile'], false, ['id', 'url', 'addr', 'name', 'micro']);
- $author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
+ $author_contact = Contact::getByURL($attributes['profile'], false, ['id', 'url', 'addr', 'name', 'micro']);
+ $author_contact['url'] = ($author_contact['url'] ?? $attributes['profile']);
$author_contact['addr'] = ($author_contact['addr'] ?? '');
- $attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
- $attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
- $attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile'];
+ $attributes['author'] = ($author_contact['name'] ?? '') ?: $attributes['author'];
+ $attributes['avatar'] = ($author_contact['micro'] ?? '') ?: $attributes['avatar'];
+ $attributes['profile'] = ($author_contact['url'] ?? '') ?: $attributes['profile'];
if (!empty($author_contact['id'])) {
$attributes['avatar'] = Contact::getAvatarUrlForId($author_contact['id'], Proxy::SIZE_THUMB);
@@ -831,7 +832,7 @@ class BBCode
"/\[[zi]mg(.*?)\]([^\[\]]*)\[\/[zi]mg\]/ism",
function ($match) use ($simplehtml, $uriid) {
$attribute_string = $match[1];
- $attributes = [];
+ $attributes = [];
foreach (['alt', 'width', 'height'] as $field) {
preg_match("/$field=(['\"])(.+?)\\1/ism", $attribute_string, $matches);
$attributes[$field] = html_entity_decode($matches[2] ?? '', ENT_QUOTES, 'UTF-8');
@@ -907,7 +908,7 @@ class BBCode
break;
case self::ACTIVITYPUB:
$author = '@' . $author_contact['addr'] . ':';
- $text = '
' . "\n";
+ $text = '' . "\n";
break;
default:
$text = ($is_quote_share ? "\n" : '');
@@ -916,7 +917,7 @@ class BBCode
$network = $contact['network'] ?? Protocol::PHANTOM;
$gsid = ContactSelector::getServerIdForProfile($attributes['profile']);
- $tpl = Renderer::getMarkupTemplate('shared_content.tpl');
+ $tpl = Renderer::getMarkupTemplate('shared_content.tpl');
$text .= self::SHARED_ANCHOR . Renderer::replaceMacros($tpl, [
'$profile' => $attributes['profile'],
'$avatar' => $attributes['avatar'],
@@ -938,7 +939,7 @@ class BBCode
private static function removePictureLinksCallback(array $match): string
{
$cache_key = 'remove:' . $match[1];
- $text = DI::cache()->get($cache_key);
+ $text = DI::cache()->get($cache_key);
if (is_null($text)) {
$curlResult = DI::httpClient()->head($match[1], [HttpClientOptions::TIMEOUT => DI::config()->get('system', 'xrd_timeout'), HttpClientOptions::REQUEST => HttpClientRequest::CONTENTTYPE]);
@@ -963,7 +964,7 @@ class BBCode
$doc = new DOMDocument();
@$doc->loadHTML($body);
$xpath = new DOMXPath($doc);
- $list = $xpath->query('//meta[@name]');
+ $list = $xpath->query('//meta[@name]');
foreach ($list as $node) {
$attr = [];
@@ -1034,7 +1035,7 @@ class BBCode
}
$cache_key = 'clean:' . $match[1];
- $text = DI::cache()->get($cache_key);
+ $text = DI::cache()->get($cache_key);
if (!is_null($text)) {
return $text;
}
@@ -1066,7 +1067,7 @@ class BBCode
$doc = new DOMDocument();
@$doc->loadHTML($body);
$xpath = new DOMXPath($doc);
- $list = $xpath->query('//meta[@name]');
+ $list = $xpath->query('//meta[@name]');
foreach ($list as $node) {
$attr = [];
if ($node->attributes->length) {
@@ -1134,7 +1135,7 @@ class BBCode
{
DI::profiler()->startRecording('rendering');
$regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
- $body = preg_replace_callback($regexp, [self::class, 'mentionCallback'], $body);
+ $body = preg_replace_callback($regexp, [self::class, 'mentionCallback'], $body);
DI::profiler()->stopRecording();
return $body;
}
@@ -1170,7 +1171,7 @@ class BBCode
{
DI::profiler()->startRecording('rendering');
$regexp = "/([@!])\[url\=([^\[\]]*)\].*?\[\/url\]/ism";
- $body = preg_replace_callback($regexp, [self::class, 'mentionToAddrCallback'], $body);
+ $body = preg_replace_callback($regexp, [self::class, 'mentionToAddrCallback'], $body);
DI::profiler()->stopRecording();
return $body;
}
@@ -1310,7 +1311,7 @@ class BBCode
* $match[2] = $title or absent
*/
$try_oembed_callback = function (array $match) use ($uriid) {
- $url = $match[1];
+ $url = $match[1];
$title = $match[2] ?? '';
try {
@@ -1325,7 +1326,7 @@ class BBCode
// Extract the private images which use data urls since preg has issues with
// large data sizes. Stash them away while we do bbcode conversion, and then put them back
// in after we've done all the regex matching. We cannot use any preg functions to do this.
- $extracted = self::extractImagesFromItemBody($text);
+ $extracted = self::extractImagesFromItemBody($text);
$saved_image = $extracted['images'];
// General clean up of the content, for example unneeded blanks and new lines
@@ -1474,13 +1475,13 @@ class BBCode
];
do {
$oldtext = $text;
- $text = str_replace($search, $replace, $text);
+ $text = str_replace($search, $replace, $text);
} while ($oldtext != $text);
// Replace these here only once
- $search = ["\n[table]", "[/table]\n"];
+ $search = ["\n[table]", "[/table]\n"];
$replace = ["[table]", "[/table]"];
- $text = str_replace($search, $replace, $text);
+ $text = str_replace($search, $replace, $text);
// Trim new lines regardless of the system.remove_multiplicated_lines config value
$text = trim($text, "\n");
@@ -1497,7 +1498,7 @@ class BBCode
];
do {
$oldtext = $text;
- $text = str_replace($search, $replace, $text);
+ $text = str_replace($search, $replace, $text);
} while ($oldtext != $text);
}
@@ -1634,7 +1635,7 @@ class BBCode
}
$elements = [
- 'del' => 's', 'ins' => 'em', 'kbd' => 'code', 'mark' => 'strong',
+ 'del' => 's', 'ins' => 'em', 'kbd' => 'code', 'mark' => 'strong',
'samp' => 'code', 'u' => 'em', 'var' => 'em'
];
foreach ($elements as $bbcode => $html) {
@@ -1749,7 +1750,7 @@ class BBCode
// handle nested quotes
$endlessloop = 0;
- while ((strpos($text, "[/spoiler]") !== false) && (strpos($text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
+ while ((strpos($text, "[/spoiler]") !== false) && (strpos($text, "[spoiler=") !== false) && (++$endlessloop < 20)) {
$text = preg_replace(
"/\[spoiler=[\"\']*(.*?)[\"\']*\](.*?)\[\/spoiler\]/ism",
'$1
$2 ',
@@ -1795,7 +1796,7 @@ class BBCode
// handle nested quotes
$endlessloop = 0;
- while ((strpos($text, "[/quote]") !== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) {
+ while ((strpos($text, "[/quote]") !== false) && (strpos($text, "[quote=") !== false) && (++$endlessloop < 20)) {
$text = preg_replace(
"/\[quote=[\"\']*(.*?)[\"\']*\](.*?)\[\/quote\]/ism",
"" . $t_wrote . "
$2
",
@@ -1829,7 +1830,7 @@ class BBCode
"/\[[iz]mg\=(.*?)\](.*?)\[\/[iz]mg\]/ism",
function ($matches) use ($simple_html, $uriid) {
$matches[1] = self::proxyUrl($matches[1], $simple_html, $uriid);
- $alt = htmlspecialchars($matches[2], ENT_COMPAT);
+ $alt = htmlspecialchars($matches[2], ENT_COMPAT);
// Fix for Markdown problems with Diaspora, see issue #12701
if (($simple_html != self::DIASPORA) || strpos($matches[2], '"') === false) {
return '';
@@ -2043,7 +2044,7 @@ class BBCode
// Server independent link to posts and comments
// See issue: https://github.com/diaspora/diaspora_federation/issues/75
$expression = "=diaspora://.*?/post/([0-9A-Za-z\-_@.:]{15,254}[0-9A-Za-z])=ism";
- $text = preg_replace($expression, DI::baseUrl() . "/display/$1", $text);
+ $text = preg_replace($expression, DI::baseUrl() . "/display/$1", $text);
/* Tag conversion
* Supports:
@@ -2218,7 +2219,7 @@ class BBCode
});
$regex = '#<([^>]*?)(href)="(?!' . implode('|', $allowed_link_protocols) . ')(.*?)"(.*?)>#ism';
- $text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . DI::l10n()->t('Invalid link protocol') . '">', $text);
+ $text = preg_replace($regex, '<$1$2="javascript:void(0)"$4 data-original-href="$3" class="invalid-href" title="' . DI::l10n()->t('Invalid link protocol') . '">', $text);
return $text;
}
@@ -2318,7 +2319,7 @@ class BBCode
* Transform #tags, strip off the [url] and replace spaces with underscore
*/
$url_search_string = "^\[\]";
- $text = preg_replace_callback(
+ $text = preg_replace_callback(
"/#\[url\=([$url_search_string]*)\](.*?)\[\/url\]/i",
function ($matches) {
return '#' . str_replace(' ', '_', $matches[2]);
@@ -2367,7 +2368,7 @@ class BBCode
if ($for_diaspora) {
$url_search_string = "^\[\]";
- $text = preg_replace_callback(
+ $text = preg_replace_callback(
"/([@!])\[(.*?)\]\(([$url_search_string]*?)\)/ism",
[self::class, 'bbCodeMention2DiasporaCallback'],
$text
@@ -2571,7 +2572,7 @@ class BBCode
$header .= "' message_id='" . str_replace(["'", "[", "]"], ["'", "[", "]"], $uri);
}
- $header .= "']";
+ $header .= "']";
DI::profiler()->stopRecording();
return $header;
diff --git a/src/Content/Text/Markdown.php b/src/Content/Text/Markdown.php
index f0ac888ab2..8aa9453041 100644
--- a/src/Content/Text/Markdown.php
+++ b/src/Content/Text/Markdown.php
@@ -24,10 +24,11 @@ class Markdown
* @param string $baseuri Optional. Prepend anchor links with this URL
* @return string
*/
- public static function convert($text, $hardwrap = true, $baseuri = null) {
+ public static function convert($text, $hardwrap = true, $baseuri = null)
+ {
DI::profiler()->startRecording('rendering');
- $MarkdownParser = new MarkdownParser();
+ $MarkdownParser = new MarkdownParser();
$MarkdownParser->code_class_prefix = 'language-';
$MarkdownParser->hard_wrap = $hardwrap;
$MarkdownParser->hashtag_protection = true;
@@ -121,10 +122,10 @@ class Markdown
//$s = preg_replace("/([^\]\=]|^)(https?\:\/\/)(vimeo|youtu|www\.youtube|soundcloud)([a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,]+)/ism", '$1[url=$2$3$4]$2$3$4[/url]',$s);
$s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/www.youtube.com\/watch\?v\=(.*?)\[\/url\]/ism', '[youtube]$2[/youtube]', 'url', $s);
- $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
- $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/shorts\/(.*?)\].*?\[\/url\]/ism' , '[youtube]$1[/youtube]', 'url', $s);
- $s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism' , '[vimeo]$2[/vimeo]' , 'url', $s);
- $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism' , '[vimeo]$1[/vimeo]' , 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/watch\?v\=(.*?)\].*?\[\/url\]/ism', '[youtube]$1[/youtube]', 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/www.youtube.com\/shorts\/(.*?)\].*?\[\/url\]/ism', '[youtube]$1[/youtube]', 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=?(.*?)\]https?:\/\/vimeo.com\/([0-9]+)(.*?)\[\/url\]/ism', '[vimeo]$2[/vimeo]', 'url', $s);
+ $s = BBCode::pregReplaceInTag('/\[url\=https?:\/\/vimeo.com\/([0-9]+)\](.*?)\[\/url\]/ism', '[vimeo]$1[/vimeo]', 'url', $s);
// remove duplicate adjacent code tags
$s = preg_replace('/(\[code\])+(.*?)(\[\/code\])+/ism', '[code]$2[/code]', $s);
diff --git a/src/Content/Widget/VCard.php b/src/Content/Widget/VCard.php
index b3943720d2..173a91d017 100644
--- a/src/Content/Widget/VCard.php
+++ b/src/Content/Widget/VCard.php
@@ -39,11 +39,11 @@ class VCard
$contact_url = Contact::getProfileLink($contact);
if ($contact['network'] != '') {
- $network_link = Strings::formatNetworkName($contact['network'], $contact_url);
- $network_svg = ContactSelector::networkToSVG($contact['network'], $contact['gsid'], '', DI::userSession()->getLocalUserId());
+ $network_link = Strings::formatNetworkName($contact['network'], $contact_url);
+ $network_svg = ContactSelector::networkToSVG($contact['network'], $contact['gsid'], '', DI::userSession()->getLocalUserId());
} else {
- $network_link = '';
- $network_svg = '';
+ $network_link = '';
+ $network_svg = '';
}
$follow_link = '';
@@ -53,7 +53,7 @@ class VCard
$mention_link = '';
$showgroup_link = '';
- $photo = Contact::getPhoto($contact);
+ $photo = Contact::getPhoto($contact);
if (DI::userSession()->getLocalUserId()) {
if (Contact\User::isIsBlocked($contact['id'], DI::userSession()->getLocalUserId())) {
@@ -68,8 +68,8 @@ class VCard
} else {
$pcontact = Contact::selectFirst([], ['uid' => DI::userSession()->getLocalUserId(), 'uri-id' => $contact['uri-id'], 'deleted' => false]);
- $id = $pcontact['id'] ?? $contact['id'];
- $rel = $pcontact['rel'] ?? Contact::NOTHING;
+ $id = $pcontact['id'] ?? $contact['id'];
+ $rel = $pcontact['rel'] ?? Contact::NOTHING;
$pending = $pcontact['pending'] ?? false;
if (!empty($pcontact) && in_array($pcontact['network'], [Protocol::MAIL, Protocol::FEED])) {
@@ -91,8 +91,8 @@ class VCard
if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) {
if (!$hide_mention) {
- $mention_label = DI::l10n()->t('Post to group');
- $mention_link = 'compose/0?body=!' . $contact['addr'];
+ $mention_label = DI::l10n()->t('Post to group');
+ $mention_link = 'compose/0?body=!' . $contact['addr'];
}
$showgroup_link = 'contact/' . $id . '/conversations';
} elseif (!$hide_mention) {
diff --git a/src/Core/Addon.php b/src/Core/Addon.php
index 42848da5ff..5b162fd986 100644
--- a/src/Core/Addon.php
+++ b/src/Core/Addon.php
@@ -40,12 +40,12 @@ class Addon
public static function getAvailableList(): array
{
$addons = [];
- $files = glob('addon/*/');
+ $files = glob('addon/*/');
if (is_array($files)) {
foreach ($files as $file) {
if (is_dir($file)) {
list($tmp, $addon) = array_map('trim', explode('/', $file));
- $info = self::getInfo($addon);
+ $info = self::getInfo($addon);
if (DI::config()->get('system', 'show_unsupported_addons')
|| strtolower($info['status']) != 'unsupported'
@@ -70,7 +70,7 @@ class Addon
public static function getAdminList(): array
{
$addons_admin = [];
- $addons = array_filter(DI::config()->get('addons') ?? []);
+ $addons = array_filter(DI::config()->get('addons') ?? []);
ksort($addons);
foreach ($addons as $name => $data) {
@@ -79,8 +79,8 @@ class Addon
}
$addons_admin[$name] = [
- 'url' => 'admin/addons/' . $name,
- 'name' => $name,
+ 'url' => 'admin/addons/' . $name,
+ 'name' => $name,
'class' => 'addon'
];
}
@@ -160,7 +160,7 @@ class Addon
DI::config()->set('addons', $addon, [
'last_update' => $t,
- 'admin' => function_exists($addon . '_addon_admin'),
+ 'admin' => function_exists($addon . '_addon_admin'),
]);
if (!self::isEnabled($addon)) {
@@ -182,7 +182,7 @@ class Addon
$addons = array_filter(DI::config()->get('addons') ?? []);
foreach ($addons as $name => $data) {
- $addonname = Strings::sanitizeFilePathItem(trim($name));
+ $addonname = Strings::sanitizeFilePathItem(trim($name));
$addon_file_path = 'addon/' . $addonname . '/' . $addonname . '.php';
if (file_exists($addon_file_path) && $data['last_update'] == filemtime($addon_file_path)) {
// Addon unmodified, skipping
@@ -218,12 +218,12 @@ class Addon
$addon = Strings::sanitizeFilePathItem($addon);
$info = [
- 'name' => $addon,
+ 'name' => $addon,
'description' => "",
- 'author' => [],
- 'maintainer' => [],
- 'version' => "",
- 'status' => ""
+ 'author' => [],
+ 'maintainer' => [],
+ 'version' => "",
+ 'status' => ""
];
if (!is_file("addon/$addon/$addon.php")) {
@@ -247,7 +247,7 @@ class Addon
}
list($type, $v) = $addon_info;
- $type = strtolower($type);
+ $type = strtolower($type);
if ($type == "author" || $type == "maintainer") {
$r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) {
@@ -302,7 +302,7 @@ class Addon
public static function getVisibleList(): array
{
$visible_addons = [];
- $addons = array_filter(DI::config()->get('addons') ?? []);
+ $addons = array_filter(DI::config()->get('addons') ?? []);
foreach ($addons as $name => $data) {
$visible_addons[] = $name;
diff --git a/src/Core/Protocol.php b/src/Core/Protocol.php
index b170d4c881..53f69bc509 100644
--- a/src/Core/Protocol.php
+++ b/src/Core/Protocol.php
@@ -57,7 +57,7 @@ class Protocol
const XMPP = 'xmpp'; // XMPP
const ZOT = 'zot!'; // Zot!
- const PHANTOM = 'unkn'; // Place holder
+ const PHANTOM = 'unkn'; // Place holder
/**
* Returns whether the provided protocol supports following
@@ -74,7 +74,7 @@ class Protocol
$hook_data = [
'protocol' => $protocol,
- 'result' => null
+ 'result' => null
];
Hook::callAll('support_follow', $hook_data);
@@ -96,7 +96,7 @@ class Protocol
$hook_data = [
'protocol' => $protocol,
- 'result' => null
+ 'result' => null
];
Hook::callAll('support_revoke_follow', $hook_data);
@@ -242,8 +242,8 @@ class Protocol
// Catch-all hook for connector addons
$hook_data = [
'contact' => $contact,
- 'uid' => $uid,
- 'result' => null,
+ 'uid' => $uid,
+ 'result' => null,
];
Hook::callAll('block', $hook_data);
@@ -281,8 +281,8 @@ class Protocol
// Catch-all hook for connector addons
$hook_data = [
'contact' => $contact,
- 'uid' => $uid,
- 'result' => null,
+ 'uid' => $uid,
+ 'result' => null,
];
Hook::callAll('unblock', $hook_data);
@@ -309,7 +309,7 @@ class Protocol
$hook_data = [
'protocol' => $protocol,
- 'result' => null
+ 'result' => null
];
Hook::callAll('support_probe', $hook_data);
diff --git a/src/Core/Search.php b/src/Core/Search.php
index 56509b3b93..0abd808377 100644
--- a/src/Core/Search.php
+++ b/src/Core/Search.php
@@ -117,15 +117,15 @@ class Search
$results = json_decode($resultJson, true);
$resultList = new ResultList(
- ($results['page'] ?? 0) ?: 1,
- $results['count'] ?? 0,
+ ($results['page'] ?? 0) ?: 1,
+ $results['count'] ?? 0,
($results['itemsperpage'] ?? 0) ?: 30
);
$profiles = $results['profiles'] ?? [];
foreach ($profiles as $profile) {
- $profile_url = $profile['profile_url'] ?? '';
+ $profile_url = $profile['profile_url'] ?? '';
$contactDetails = Contact::getByURLForUser($profile_url, DI::userSession()->getLocalUserId());
$result = new ContactResult(
@@ -137,7 +137,7 @@ class Search
Protocol::DFRN,
$contactDetails['cid'] ?? 0,
$contactDetails['zid'] ?? 0,
- $profile['tags'] ?? ''
+ $profile['tags'] ?? ''
);
$resultList->addResult($result);
@@ -231,7 +231,7 @@ class Search
// Converting Directory Search results into contact-looking records
$return = array_map(function ($result) {
static $contactType = [
- 'People' => Contact::TYPE_PERSON,
+ 'People' => Contact::TYPE_PERSON,
// Kept for backward compatibility
'Forum' => Contact::TYPE_COMMUNITY,
'Group' => Contact::TYPE_COMMUNITY,
diff --git a/src/Core/Theme.php b/src/Core/Theme.php
index dac930ceb1..8cd22a2e1c 100644
--- a/src/Core/Theme.php
+++ b/src/Core/Theme.php
@@ -20,7 +20,7 @@ class Theme
{
$allowed_themes_str = DI::config()->get('system', 'allowed_themes');
$allowed_themes_raw = explode(',', str_replace(' ', '', $allowed_themes_str));
- $allowed_themes = [];
+ $allowed_themes = [];
if (count($allowed_themes_raw)) {
foreach ($allowed_themes_raw as $theme) {
$theme = Strings::sanitizeFilePathItem(trim($theme));
@@ -58,14 +58,14 @@ class Theme
$theme = Strings::sanitizeFilePathItem($theme);
$info = [
- 'name' => $theme,
- 'description' => "",
- 'author' => [],
- 'maintainer' => [],
- 'version' => "",
- 'credits' => "",
+ 'name' => $theme,
+ 'description' => "",
+ 'author' => [],
+ 'maintainer' => [],
+ 'version' => "",
+ 'credits' => "",
'experimental' => file_exists("view/theme/$theme/experimental"),
- 'unsupported' => file_exists("view/theme/$theme/unsupported")
+ 'unsupported' => file_exists("view/theme/$theme/unsupported")
];
if (!is_file("view/theme/$theme/theme.php")) {
@@ -84,7 +84,7 @@ class Theme
$comment_line = trim($comment_line, "\t\n\r */");
if (strpos($comment_line, ':') !== false) {
list($key, $value) = array_map("trim", explode(":", $comment_line, 2));
- $key = strtolower($key);
+ $key = strtolower($key);
if ($key == "author") {
$result = preg_match("|([^<]+)<([^>]+)>|", $value, $matches);
if ($result) {
@@ -153,7 +153,7 @@ class Theme
}
$allowed_themes = Theme::getAllowedList();
- $key = array_search($theme, $allowed_themes);
+ $key = array_search($theme, $allowed_themes);
if ($key !== false) {
unset($allowed_themes[$key]);
Theme::setAllowedList($allowed_themes);
@@ -185,7 +185,7 @@ class Theme
$func();
}
- $allowed_themes = Theme::getAllowedList();
+ $allowed_themes = Theme::getAllowedList();
$allowed_themes[] = $theme;
Theme::setAllowedList($allowed_themes);
@@ -267,7 +267,7 @@ class Theme
{
$theme = Strings::sanitizeFilePathItem($theme);
- $appHelper = DI::appHelper();
+ $appHelper = DI::appHelper();
$base_theme = $appHelper->getThemeInfoValue('extends') ?? '';
if (file_exists("view/theme/$theme/config.php")) {
diff --git a/src/Core/Update.php b/src/Core/Update.php
index 7a221c38e1..7aeefc3793 100644
--- a/src/Core/Update.php
+++ b/src/Core/Update.php
@@ -169,7 +169,7 @@ class Update
if ($build != DB_UPDATE_VERSION || $force) {
require_once 'update.php';
- $stored = intval($build);
+ $stored = intval($build);
$current = intval(DB_UPDATE_VERSION);
if ($stored < $current || $force) {
DI::config()->reload();
@@ -203,8 +203,11 @@ class Update
// run the pre_update_nnnn functions in update.php
for ($version = $stored + 1; $version <= $current; $version++) {
DI::logger()->notice('Execute pre update.', ['version' => $version]);
- DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing pre update %d',
- DateTimeFormat::utcNow() . ' ' . date('e'), $version));
+ DI::config()->set('system', 'maintenance_reason', DI::l10n()->t(
+ '%s: executing pre update %d',
+ DateTimeFormat::utcNow() . ' ' . date('e'),
+ $version
+ ));
$r = self::runUpdateFunction($version, 'pre_update', $sendMail);
if (!$r) {
DI::logger()->warning('Pre update failed', ['version' => $version]);
@@ -245,8 +248,11 @@ class Update
// run the update_nnnn functions in update.php
for ($version = $stored + 1; $version <= $current; $version++) {
DI::logger()->notice('Execute post update.', ['version' => $version]);
- DI::config()->set('system', 'maintenance_reason', DI::l10n()->t('%s: executing post update %d',
- DateTimeFormat::utcNow() . ' ' . date('e'), $version));
+ DI::config()->set('system', 'maintenance_reason', DI::l10n()->t(
+ '%s: executing post update %d',
+ DateTimeFormat::utcNow() . ' ' . date('e'),
+ $version
+ ));
$r = self::runUpdateFunction($version, 'update', $sendMail);
if (!$r) {
DI::logger()->warning('Post update failed', ['version' => $version]);
@@ -359,13 +365,15 @@ class Update
foreach($adminEmails as $admin) {
$l10n = DI::l10n()->withLang($admin['language'] ?: 'en');
- $preamble = Strings::deindent($l10n->t("
+ $preamble = Strings::deindent($l10n->t(
+ "
The friendica developers released update %s recently,
but when I tried to install it, something went terribly wrong.
This needs to be fixed soon and I can't do it alone. Please contact a
friendica developer if you can not help me on your own. My database might be invalid.",
- $update_id));
- $body = $l10n->t('The error message is\n[pre]%s[/pre]', $error_message);
+ $update_id
+ ));
+ $body = $l10n->t('The error message is\n[pre]%s[/pre]', $error_message);
$email = DI::emailer()
->newSystemMail()
@@ -391,9 +399,12 @@ class Update
foreach(User::getAdminListForEmailing(['uid', 'language', 'email']) as $admin) {
$l10n = DI::l10n()->withLang($admin['language'] ?: 'en');
- $preamble = Strings::deindent($l10n->t('
+ $preamble = Strings::deindent($l10n->t(
+ '
The friendica database was successfully updated from %s to %s.',
- $from_build, $to_build));
+ $from_build,
+ $to_build
+ ));
$email = DI::emailer()
->newSystemMail()
diff --git a/src/Core/Worker/Cron.php b/src/Core/Worker/Cron.php
index 5e50a9159d..a4184caf70 100644
--- a/src/Core/Worker/Cron.php
+++ b/src/Core/Worker/Cron.php
@@ -112,7 +112,10 @@ class Cron
} elseif ($entry['priority'] != Worker::PRIORITY_CRITICAL) {
$new_priority = Worker::PRIORITY_NEGLIGIBLE;
}
- DBA::update('workerqueue', ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0], ['id' => $entry["id"]]
+ DBA::update(
+ 'workerqueue',
+ ['executed' => DBA::NULL_DATETIME, 'created' => DateTimeFormat::utcNow(), 'priority' => $new_priority, 'pid' => 0],
+ ['id' => $entry["id"]]
);
} else {
DI::logger()->info('Process runtime is okay', ['duration' => number_format($duration, 3), 'max' => $max_duration, 'id' => $entry["id"], 'pid' => $entry["pid"], 'command' => $command]);
diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php
index 2e26453767..6809838b96 100644
--- a/src/Database/DBStructure.php
+++ b/src/Database/DBStructure.php
@@ -73,8 +73,11 @@ class DBStructure
'deliverq', 'dsprphotoq', 'ffinder', 'sign', 'spam', 'term', 'user-item', 'thread', 'item', 'challenge',
'auth_codes', 'tokens', 'clients', 'profile_check', 'host', 'conversation', 'fcontact', 'addon', 'push_subscriber'];
- $tables = DBA::selectToArray('INFORMATION_SCHEMA.TABLES', ['TABLE_NAME'],
- ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']);
+ $tables = DBA::selectToArray(
+ 'INFORMATION_SCHEMA.TABLES',
+ ['TABLE_NAME'],
+ ['TABLE_SCHEMA' => DBA::databaseName(), 'TABLE_TYPE' => 'BASE TABLE']
+ );
if (empty($tables)) {
echo DI::l10n()->t('No unused tables found.');
@@ -143,8 +146,11 @@ class DBStructure
*/
private static function printUpdateError(string $message): string
{
- echo DI::l10n()->t("\nError %d occurred during database update:\n%s\n",
- DBA::errorNo(), DBA::errorMessage());
+ echo DI::l10n()->t(
+ "\nError %d occurred during database update:\n%s\n",
+ DBA::errorNo(),
+ DBA::errorMessage()
+ );
return DI::l10n()->t('Errors encountered performing database changes: ') . $message . '
';
}
@@ -522,30 +528,36 @@ class DBStructure
// This query doesn't seem to be executable as a prepared statement
$indexes = DBA::toArray(DBA::p("SHOW INDEX FROM " . DBA::quoteIdentifier($table)));
- $fields = DBA::selectToArray('INFORMATION_SCHEMA.COLUMNS',
+ $fields = DBA::selectToArray(
+ 'INFORMATION_SCHEMA.COLUMNS',
['COLUMN_NAME', 'COLUMN_TYPE', 'IS_NULLABLE', 'COLUMN_DEFAULT', 'EXTRA',
- 'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'],
+ 'COLUMN_KEY', 'COLLATION_NAME', 'COLUMN_COMMENT'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
- DBA::databaseName(), $table]);
+ DBA::databaseName(), $table]
+ );
- $foreign_keys = DBA::selectToArray('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
+ $foreign_keys = DBA::selectToArray(
+ 'INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
['COLUMN_NAME', 'CONSTRAINT_NAME', 'REFERENCED_TABLE_NAME', 'REFERENCED_COLUMN_NAME'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
- DBA::databaseName(), $table]);
+ DBA::databaseName(), $table]
+ );
- $table_status = DBA::selectFirst('INFORMATION_SCHEMA.TABLES',
+ $table_status = DBA::selectFirst(
+ 'INFORMATION_SCHEMA.TABLES',
['ENGINE', 'TABLE_COLLATION', 'TABLE_COMMENT'],
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ?",
- DBA::databaseName(), $table]);
+ DBA::databaseName(), $table]
+ );
- $fielddata = [];
- $indexdata = [];
+ $fielddata = [];
+ $indexdata = [];
$foreigndata = [];
if (DBA::isResult($foreign_keys)) {
foreach ($foreign_keys as $foreign_key) {
- $parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]];
- $constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters);
+ $parameters = ['foreign' => [$foreign_key['REFERENCED_TABLE_NAME'] => $foreign_key['REFERENCED_COLUMN_NAME']]];
+ $constraint = self::getConstraintName($table, $foreign_key['COLUMN_NAME'], $parameters);
$foreigndata[$constraint] = $foreign_key;
}
}
@@ -573,8 +585,8 @@ class DBStructure
$fielddata = [];
if (DBA::isResult($fields)) {
foreach ($fields as $field) {
- $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
- $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
+ $search = ['tinyint(1)', 'tinyint(3) unsigned', 'tinyint(4)', 'smallint(5) unsigned', 'smallint(6)', 'mediumint(8) unsigned', 'mediumint(9)', 'bigint(20)', 'int(10) unsigned', 'int(11)'];
+ $replace = ['boolean', 'tinyint unsigned', 'tinyint', 'smallint unsigned', 'smallint', 'mediumint unsigned', 'mediumint', 'bigint', 'int unsigned', 'int'];
$field['COLUMN_TYPE'] = str_replace($search, $replace, $field['COLUMN_TYPE']);
$fielddata[$field['COLUMN_NAME']]['type'] = $field['COLUMN_TYPE'];
@@ -596,13 +608,13 @@ class DBStructure
}
$fielddata[$field['COLUMN_NAME']]['Collation'] = $field['COLLATION_NAME'];
- $fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT'];
+ $fielddata[$field['COLUMN_NAME']]['comment'] = $field['COLUMN_COMMENT'];
}
}
return [
- 'fields' => $fielddata,
- 'indexes' => $indexdata,
+ 'fields' => $fielddata,
+ 'indexes' => $indexdata,
'foreign_keys' => $foreigndata,
'table_status' => $table_status
];
@@ -731,9 +743,11 @@ class DBStructure
*/
public static function existsForeignKeyForField(string $table, string $field): bool
{
- return DBA::exists('INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
+ return DBA::exists(
+ 'INFORMATION_SCHEMA.KEY_COLUMN_USAGE',
["`TABLE_SCHEMA` = ? AND `TABLE_NAME` = ? AND `COLUMN_NAME` = ? AND `REFERENCED_TABLE_SCHEMA` IS NOT NULL",
- DBA::databaseName(), $table, $field]);
+ DBA::databaseName(), $table, $field]
+ );
}
/**
@@ -806,8 +820,8 @@ class DBStructure
if (self::existsTable('user') && !DBA::exists('user', ['uid' => 0])) {
$user = [
- 'verified' => true,
- 'page-flags' => User::PAGE_FLAGS_SOAPBOX,
+ 'verified' => true,
+ 'page-flags' => User::PAGE_FLAGS_SOAPBOX,
'account-type' => User::ACCOUNT_TYPE_RELAY,
];
DBA::insert('user', $user);
@@ -883,7 +897,7 @@ class DBStructure
$permission = '';
}
$fields = ['id' => $set['psid'], 'uid' => $set['uid'], 'allow_cid' => $permission,
- 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
+ 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => ''];
DBA::insert('permissionset', $fields, Database::INSERT_IGNORE);
}
DBA::close($sets);
@@ -913,7 +927,7 @@ class DBStructure
$isUpdate = false;
$processes = DBA::select('information_schema.processlist', ['info'], [
- 'db' => DBA::databaseName(),
+ 'db' => DBA::databaseName(),
'command' => ['Query', 'Execute']
]);
diff --git a/src/Database/PostUpdate.php b/src/Database/PostUpdate.php
index 4db87bb429..a4db193752 100644
--- a/src/Database/PostUpdate.php
+++ b/src/Database/PostUpdate.php
@@ -35,7 +35,7 @@ use GuzzleHttp\Psr7\Uri;
class PostUpdate
{
// Needed for the helper function to read from the legacy term table
- const OBJECT_TYPE_POST = 1;
+ const OBJECT_TYPE_POST = 1;
const VERSION = 1550;
@@ -138,7 +138,7 @@ class PostUpdate
}
$max_item_delivery_data = DBA::selectFirst('item-delivery-data', ['iid'], ['queue_count > 0 OR queue_done > 0'], ['order' => ['iid']]);
- $max_iid = $max_item_delivery_data['iid'] ?? 0;
+ $max_iid = $max_item_delivery_data['iid'] ?? 0;
DI::logger()->info('Start update1297 with max iid: ' . $max_iid);
@@ -174,12 +174,19 @@ class PostUpdate
DI::logger()->info('Start');
- $contacts = DBA::p("SELECT `nurl`, `uid` FROM `contact`
+ $contacts = DBA::p(
+ "SELECT `nurl`, `uid` FROM `contact`
WHERE EXISTS (SELECT `nurl` FROM `contact` AS `c2`
WHERE `c2`.`nurl` = `contact`.`nurl` AND `c2`.`id` != `contact`.`id` AND `c2`.`uid` = `contact`.`uid` AND `c2`.`network` IN (?, ?, ?) AND NOT `deleted`)
AND (`network` IN (?, ?, ?) OR (`uid` = ?)) AND NOT `deleted` GROUP BY `nurl`, `uid`",
- Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB,
- Protocol::DIASPORA, Protocol::OSTATUS, Protocol::ACTIVITYPUB, 0);
+ Protocol::DIASPORA,
+ Protocol::OSTATUS,
+ Protocol::ACTIVITYPUB,
+ Protocol::DIASPORA,
+ Protocol::OSTATUS,
+ Protocol::ACTIVITYPUB,
+ 0
+ );
while ($contact = DBA::fetch($contacts)) {
DI::logger()->info('Remove duplicates', ['nurl' => $contact['nurl'], 'uid' => $contact['uid']]);
@@ -216,11 +223,11 @@ class PostUpdate
DI::logger()->info('Start', ['item' => $id]);
- $start_id = $id;
- $rows = 0;
+ $start_id = $id;
+ $rows = 0;
$condition = ["`id` > ?", $id];
- $params = ['order' => ['id'], 'limit' => 10000];
- $items = DBA::select('item', ['id', 'uri-id', 'uid'], $condition, $params);
+ $params = ['order' => ['id'], 'limit' => 10000];
+ $items = DBA::select('item', ['id', 'uri-id', 'uid'], $condition, $params);
if (DBA::errorNo() != 0) {
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
@@ -331,12 +338,18 @@ class PostUpdate
$rows = 0;
- $terms = DBA::p("SELECT `term`.`tid`, `item`.`uri-id`, `term`.`type`, `term`.`term`, `term`.`url`, `item-content`.`body`
+ $terms = DBA::p(
+ "SELECT `term`.`tid`, `item`.`uri-id`, `term`.`type`, `term`.`term`, `term`.`url`, `item-content`.`body`
FROM `term`
INNER JOIN `item` ON `item`.`id` = `term`.`oid`
INNER JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
WHERE term.type IN (?, ?, ?, ?) AND `tid` >= ? ORDER BY `tid` LIMIT 100000",
- Tag::HASHTAG, Tag::MENTION, Tag::EXCLUSIVE_MENTION, Tag::IMPLICIT_MENTION, $id);
+ Tag::HASHTAG,
+ Tag::MENTION,
+ Tag::EXCLUSIVE_MENTION,
+ Tag::IMPLICIT_MENTION,
+ $id
+ );
if (DBA::errorNo() != 0) {
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
@@ -345,17 +358,17 @@ class PostUpdate
while ($term = DBA::fetch($terms)) {
if (($term['type'] == Tag::MENTION) && !empty($term['url']) && !strstr($term['body'], $term['url'])) {
- $condition = ['nurl' => Strings::normaliseLink($term['url']), 'uid' => 0, 'deleted' => false];
- $contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
- if (!DBA::isResult($contact)) {
- $ssl_url = str_replace('http://', 'https://', $term['url']);
- $condition = ['`alias` IN (?, ?, ?) AND `uid` = ? AND NOT `deleted`', $term['url'], Strings::normaliseLink($term['url']), $ssl_url, 0];
- $contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
- }
+ $condition = ['nurl' => Strings::normaliseLink($term['url']), 'uid' => 0, 'deleted' => false];
+ $contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
+ if (!DBA::isResult($contact)) {
+ $ssl_url = str_replace('http://', 'https://', $term['url']);
+ $condition = ['`alias` IN (?, ?, ?) AND `uid` = ? AND NOT `deleted`', $term['url'], Strings::normaliseLink($term['url']), $ssl_url, 0];
+ $contact = DBA::selectFirst('contact', ['url', 'alias'], $condition, ['order' => ['id']]);
+ }
- if (DBA::isResult($contact) && (!strstr($term['body'], $contact['url']) && (empty($contact['alias']) || !strstr($term['body'], $contact['alias'])))) {
- $term['type'] = Tag::IMPLICIT_MENTION;
- }
+ if (DBA::isResult($contact) && (!strstr($term['body'], $contact['url']) && (empty($contact['alias']) || !strstr($term['body'], $contact['alias'])))) {
+ $term['type'] = Tag::IMPLICIT_MENTION;
+ }
}
Tag::store($term['uri-id'], $term['type'], $term['term'], $term['url']);
@@ -454,7 +467,7 @@ class PostUpdate
$file_text = '';
$condition = ['otype' => self::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => [Category::FILE, Category::CATEGORY]];
- $tags = DBA::selectToArray('term', ['type', 'term', 'url'], $condition);
+ $tags = DBA::selectToArray('term', ['type', 'term', 'url'], $condition);
foreach ($tags as $tag) {
if ($tag['type'] == Category::CATEGORY) {
$file_text .= '<' . $tag['term'] . '>';
@@ -490,9 +503,12 @@ class PostUpdate
$rows = 0;
- $terms = DBA::select('term', ['oid'],
+ $terms = DBA::select(
+ 'term',
+ ['oid'],
["`type` IN (?, ?) AND `oid` >= ?", Category::CATEGORY, Category::FILE, $id],
- ['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']]);
+ ['order' => ['oid'], 'limit' => 1000, 'group_by' => ['oid']]
+ );
if (DBA::errorNo() != 0) {
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
@@ -557,7 +573,7 @@ class PostUpdate
DI::logger()->info('Start', ['item' => $id]);
$start_id = $id;
- $rows = 0;
+ $rows = 0;
$items = DBA::p("SELECT `item`.`id`, `item`.`verb` AS `item-verb`, `item-content`.`verb`, `item-activity`.`activity`
FROM `item` LEFT JOIN `item-content` ON `item-content`.`uri-id` = `item`.`uri-id`
@@ -570,7 +586,7 @@ class PostUpdate
}
while ($item = DBA::fetch($items)) {
- $id = $item['id'];
+ $id = $item['id'];
$verb = $item['item-verb'];
if (empty($verb)) {
$verb = $item['verb'];
@@ -618,11 +634,11 @@ class PostUpdate
DI::logger()->info('Start', ['contact' => $id]);
- $start_id = $id;
- $rows = 0;
+ $start_id = $id;
+ $rows = 0;
$condition = ["`id` > ? AND `gsid` IS NULL AND `baseurl` != '' AND NOT `baseurl` IS NULL", $id];
- $params = ['order' => ['id'], 'limit' => 10000];
- $contacts = DBA::select('contact', ['id', 'baseurl'], $condition, $params);
+ $params = ['order' => ['id'], 'limit' => 10000];
+ $contacts = DBA::select('contact', ['id', 'baseurl'], $condition, $params);
if (DBA::errorNo() != 0) {
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
@@ -632,9 +648,11 @@ class PostUpdate
while ($contact = DBA::fetch($contacts)) {
$id = $contact['id'];
- DBA::update('contact',
+ DBA::update(
+ 'contact',
['gsid' => GServer::getID($contact['baseurl'], true), 'baseurl' => GServer::cleanURL($contact['baseurl'])],
- ['id' => $contact['id']]);
+ ['id' => $contact['id']]
+ );
++$rows;
}
@@ -671,10 +689,10 @@ class PostUpdate
DI::logger()->info('Start', ['apcontact' => $id]);
- $start_id = $id;
- $rows = 0;
- $condition = ["`url` > ? AND `gsid` IS NULL AND `baseurl` != '' AND NOT `baseurl` IS NULL", $id];
- $params = ['order' => ['url'], 'limit' => 10000];
+ $start_id = $id;
+ $rows = 0;
+ $condition = ["`url` > ? AND `gsid` IS NULL AND `baseurl` != '' AND NOT `baseurl` IS NULL", $id];
+ $params = ['order' => ['url'], 'limit' => 10000];
$apcontacts = DBA::select('apcontact', ['url', 'baseurl'], $condition, $params);
if (DBA::errorNo() != 0) {
@@ -685,9 +703,11 @@ class PostUpdate
while ($apcontact = DBA::fetch($apcontacts)) {
$id = $apcontact['url'];
- DBA::update('apcontact',
+ DBA::update(
+ 'apcontact',
['gsid' => GServer::getID($apcontact['baseurl'], true), 'baseurl' => GServer::cleanURL($apcontact['baseurl'])],
- ['url' => $apcontact['url']]);
+ ['url' => $apcontact['url']]
+ );
++$rows;
}
@@ -723,7 +743,7 @@ class PostUpdate
DI::logger()->info('Start');
$deleted = 0;
- $avatar = [4 => 'photo', 5 => 'thumb', 6 => 'micro'];
+ $avatar = [4 => 'photo', 5 => 'thumb', 6 => 'micro'];
$photos = DBA::select('photo', ['id', 'contact-id', 'resource-id', 'scale'], ["`contact-id` != ? AND `album` = ?", 0, Photo::CONTACT_PHOTOS]);
while ($photo = DBA::fetch($photos)) {
@@ -764,7 +784,7 @@ class PostUpdate
$condition = ["`hash` IS NULL"];
DI::logger()->info('Start', ['rest' => DBA::count('photo', $condition)]);
- $rows = 0;
+ $rows = 0;
$photos = DBA::select('photo', [], $condition, ['limit' => 100]);
if (DBA::errorNo() != 0) {
@@ -814,7 +834,7 @@ class PostUpdate
$condition = ["`extid` != ? AND EXISTS(SELECT `id` FROM `post-user` WHERE `uri-id` = `item`.`uri-id` AND `uid` = `item`.`uid` AND `external-id` IS NULL)", ''];
DI::logger()->info('Start', ['rest' => DBA::count('item', $condition)]);
- $rows = 0;
+ $rows = 0;
$items = DBA::select('item', ['uri-id', 'uid', 'extid'], $condition, ['order' => ['id'], 'limit' => 10000]);
if (DBA::errorNo() != 0) {
@@ -856,7 +876,7 @@ class PostUpdate
$condition = ["`uri-id` IS NULL"];
DI::logger()->info('Start', ['rest' => DBA::count('contact', $condition)]);
- $rows = 0;
+ $rows = 0;
$contacts = DBA::select('contact', ['id', 'url'], $condition, ['limit' => 1000]);
if (DBA::errorNo() != 0) {
@@ -903,7 +923,7 @@ class PostUpdate
$condition = ["`uri-id` IS NULL"];
DI::logger()->info('Start', ['rest' => DBA::count('fcontact', $condition)]);
- $rows = 0;
+ $rows = 0;
$fcontacts = DBA::select('fcontact', ['id', 'url', 'guid'], $condition, ['limit' => 1000]);
if (DBA::errorNo() != 0) {
@@ -950,7 +970,7 @@ class PostUpdate
$condition = ["`uri-id` IS NULL"];
DI::logger()->info('Start', ['rest' => DBA::count('apcontact', $condition)]);
- $rows = 0;
+ $rows = 0;
$apcontacts = DBA::select('apcontact', ['url', 'uuid'], $condition, ['limit' => 1000]);
if (DBA::errorNo() != 0) {
@@ -997,7 +1017,7 @@ class PostUpdate
$condition = ["`uri-id` IS NULL"];
DI::logger()->info('Start', ['rest' => DBA::count('event', $condition)]);
- $rows = 0;
+ $rows = 0;
$events = DBA::select('event', ['id', 'uri', 'guid'], $condition, ['limit' => 1000]);
if (DBA::errorNo() != 0) {
@@ -1053,10 +1073,14 @@ class PostUpdate
$rows = 0;
$received = '';
- $conversations = DBA::p("SELECT `post-view`.`uri-id`, `conversation`.`source`, `conversation`.`received` FROM `conversation`
+ $conversations = DBA::p(
+ "SELECT `post-view`.`uri-id`, `conversation`.`source`, `conversation`.`received` FROM `conversation`
INNER JOIN `post-view` ON `post-view`.`uri` = `conversation`.`item-uri`
WHERE NOT `source` IS NULL AND `conversation`.`protocol` = ? AND `uri-id` > ? LIMIT ?",
- Conversation::PARCEL_ACTIVITYPUB, $id, 1000);
+ Conversation::PARCEL_ACTIVITYPUB,
+ $id,
+ 1000
+ );
if (DBA::errorNo() != 0) {
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
@@ -1199,11 +1223,11 @@ class PostUpdate
DI::logger()->info('Start', ['contact' => $id]);
- $start_id = $id;
- $rows = 0;
+ $start_id = $id;
+ $rows = 0;
$condition = ["`id` > ? AND `gsid` IS NULL AND `network` = ?", $id, Protocol::DIASPORA];
- $params = ['order' => ['id'], 'limit' => 10000];
- $contacts = DBA::select('contact', ['id', 'url'], $condition, $params);
+ $params = ['order' => ['id'], 'limit' => 10000];
+ $contacts = DBA::select('contact', ['id', 'url'], $condition, $params);
if (DBA::errorNo() != 0) {
DI::logger()->error('Database error', ['no' => DBA::errorNo(), 'message' => DBA::errorMessage()]);
@@ -1217,9 +1241,11 @@ class PostUpdate
unset($parts['path']);
$server = (string)Uri::fromParts($parts);
- DBA::update('contact',
+ DBA::update(
+ 'contact',
['gsid' => GServer::getID($server, true), 'baseurl' => GServer::cleanURL($server)],
- ['id' => $contact['id']]);
+ ['id' => $contact['id']]
+ );
++$rows;
}
@@ -1256,10 +1282,10 @@ class PostUpdate
DI::logger()->info('Start', ['apcontact' => $id]);
- $start_id = $id;
- $rows = 0;
- $condition = ["`url` > ? AND NOT `gsid` IS NULL", $id];
- $params = ['order' => ['url'], 'limit' => 10000];
+ $start_id = $id;
+ $rows = 0;
+ $condition = ["`url` > ? AND NOT `gsid` IS NULL", $id];
+ $params = ['order' => ['url'], 'limit' => 10000];
$apcontacts = DBA::select('apcontact', ['url', 'gsid', 'sharedinbox', 'inbox'], $condition, $params);
if (DBA::errorNo() != 0) {
@@ -1310,7 +1336,7 @@ class PostUpdate
$id = (int)(DI::keyValue()->get('post_update_version_1544_id') ?? 0);
if ($id == 0) {
$post = Post::selectFirstPost(['uri-id'], [], ['order' => ['uri-id' => true]]);
- $id = (int)($post['uri-id'] ?? 0);
+ $id = (int)($post['uri-id'] ?? 0);
}
DI::logger()->info('Start', ['uri-id' => $id]);
@@ -1375,7 +1401,7 @@ class PostUpdate
$id = (int)(DI::keyValue()->get('post_update_version_1550_id') ?? 0);
if ($id == 0) {
$post = Post::selectFirstPost(['uri-id'], [], ['order' => ['uri-id' => true]]);
- $id = (int)($post['uri-id'] ?? 0);
+ $id = (int)($post['uri-id'] ?? 0);
}
DI::logger()->info('Start', ['uri-id' => $id]);
diff --git a/src/Factory/Api/Mastodon/Status.php b/src/Factory/Api/Mastodon/Status.php
index fc1715c1d5..8eba9221e7 100644
--- a/src/Factory/Api/Mastodon/Status.php
+++ b/src/Factory/Api/Mastodon/Status.php
@@ -221,8 +221,8 @@ class Status extends BaseFactory
$application = new \Friendica\Object\Api\Mastodon\Application($item['app'] ?: $platform);
- $mentions = $this->mstdnMentionFactory->createFromUriId($uriId)->getArrayCopy();
- $tags = $this->mstdnTagFactory->createFromUriId($uriId);
+ $mentions = $this->mstdnMentionFactory->createFromUriId($uriId)->getArrayCopy();
+ $tags = $this->mstdnTagFactory->createFromUriId($uriId);
if ($item['has-media']) {
$card = $this->mstdnCardFactory->createFromUriId($uriId);
$attachments = $this->mstdnAttachmentFactory->createFromUriId($uriId);
@@ -349,7 +349,7 @@ class Status extends BaseFactory
$quote_id = $media['media-uri-id'];
} else {
$shared_item = Post::selectFirst(['uri-id'], ['plink' => $media[0]['url'], 'uid' => [$uid, 0]]);
- $quote_id = $shared_item['uri-id'] ?? 0;
+ $quote_id = $shared_item['uri-id'] ?? 0;
}
}
} else {
diff --git a/src/Model/APContact.php b/src/Model/APContact.php
index e88cccd619..a364344a51 100644
--- a/src/Model/APContact.php
+++ b/src/Model/APContact.php
@@ -13,7 +13,6 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Database\DBA;
use Friendica\DI;
-use Friendica\Model\Item;
use Friendica\Network\HTTPException;
use Friendica\Network\Probe;
use Friendica\Protocol\ActivityNamespace;
@@ -153,7 +152,7 @@ class APContact
// Detect multiple fast repeating request to the same address
// See https://github.com/friendica/friendica/issues/9303
$cachekey = 'apcontact:' . ItemURI::getIdByURI($url);
- $result = DI::cache()->get($cachekey);
+ $result = DI::cache()->get($cachekey);
if (!is_null($result)) {
DI::logger()->info('Multiple requests for the address', ['url' => $url, 'update' => $update, 'result' => $result]);
if (!empty($fetched_contact)) {
@@ -165,7 +164,7 @@ class APContact
if (DI::baseUrl()->isLocalUrl($url) && ($local_uid = User::getIdForURL($url))) {
try {
- $data = Transmitter::getProfile($local_uid);
+ $data = Transmitter::getProfile($local_uid);
$local_owner = User::getOwnerDataById($local_uid);
} catch(HTTPException\NotFoundException $e) {
$data = null;
@@ -177,11 +176,11 @@ class APContact
try {
$curlResult = HTTPSignature::fetchRaw($url);
- $failed = empty($curlResult->getBodyString()) ||
+ $failed = empty($curlResult->getBodyString()) ||
(!$curlResult->isSuccess() && ($curlResult->getReturnCode() != 410));
- if (!$failed) {
- $data = json_decode($curlResult->getBodyString(), true);
+ if (!$failed) {
+ $data = json_decode($curlResult->getBodyString(), true);
$failed = empty($data) || !is_array($data);
}
@@ -206,13 +205,13 @@ class APContact
return $fetched_contact;
}
- $apcontact['url'] = $compacted['@id'];
- $apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
- $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
+ $apcontact['url'] = $compacted['@id'];
+ $apcontact['uuid'] = JsonLD::fetchElement($compacted, 'diaspora:guid', '@value');
+ $apcontact['type'] = str_replace('as:', '', JsonLD::fetchElement($compacted, '@type'));
$apcontact['following'] = JsonLD::fetchElement($compacted, 'as:following', '@id');
$apcontact['followers'] = JsonLD::fetchElement($compacted, 'as:followers', '@id');
- $apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
- $apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
+ $apcontact['inbox'] = (JsonLD::fetchElement($compacted, 'ldp:inbox', '@id') ?? '');
+ $apcontact['outbox'] = JsonLD::fetchElement($compacted, 'as:outbox', '@id');
$apcontact['sharedinbox'] = '';
if (!empty($compacted['as:endpoints'])) {
@@ -303,12 +302,12 @@ class APContact
}
}
- $apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
+ $apcontact['manually-approve'] = (int)JsonLD::fetchElement($compacted, 'as:manuallyApprovesFollowers');
$apcontact['posting-restricted'] = (int)JsonLD::fetchElement($compacted, 'lemmy:postingRestrictedToMods');
- $apcontact['suspended'] = (int)JsonLD::fetchElement($compacted, 'toot:suspended');
+ $apcontact['suspended'] = (int)JsonLD::fetchElement($compacted, 'toot:suspended');
if (!empty($compacted['as:generator'])) {
- $apcontact['baseurl'] = JsonLD::fetchElement($compacted['as:generator'], 'as:url', '@id');
+ $apcontact['baseurl'] = JsonLD::fetchElement($compacted['as:generator'], 'as:url', '@id');
$apcontact['generator'] = JsonLD::fetchElement($compacted['as:generator'], 'as:name', '@value');
}
@@ -348,7 +347,7 @@ class APContact
if (!empty($local_owner)) {
$statuses_count = self::getStatusesCount($local_owner);
} else {
- $outbox = HTTPSignature::fetch($apcontact['outbox']);
+ $outbox = HTTPSignature::fetch($apcontact['outbox']);
$statuses_count = $outbox['totalItems'] ?? 0;
}
if (!empty($statuses_count)) {
diff --git a/src/Model/Circle.php b/src/Model/Circle.php
index 00b4b16d5d..f9323897e9 100644
--- a/src/Model/Circle.php
+++ b/src/Model/Circle.php
@@ -23,7 +23,7 @@ use Friendica\Protocol\ActivityPub;
class Circle
{
const FOLLOWERS = '~';
- const MUTUALS = '&';
+ const MUTUALS = '&';
/**
* Fetches circle record by user id and maybe includes deleted circles as well
@@ -163,7 +163,8 @@ class Circle
*/
public static function countUnseen(int $uid)
{
- $stmt = DBA::p("SELECT `circle`.`id`, `circle`.`name`,
+ $stmt = DBA::p(
+ "SELECT `circle`.`id`, `circle`.`name`,
(SELECT COUNT(*) FROM `post-user`
WHERE `uid` = ?
AND `unseen`
@@ -230,15 +231,15 @@ class Circle
if ($user['def_gid'] == $gid) {
$user['def_gid'] = 0;
- $change = true;
+ $change = true;
}
if (strpos($user['allow_gid'], '<' . $gid . '>') !== false) {
$user['allow_gid'] = str_replace('<' . $gid . '>', '', $user['allow_gid']);
- $change = true;
+ $change = true;
}
if (strpos($user['deny_gid'], '<' . $gid . '>') !== false) {
$user['deny_gid'] = str_replace('<' . $gid . '>', '', $user['deny_gid']);
- $change = true;
+ $change = true;
}
if ($change) {
@@ -410,13 +411,13 @@ class Circle
if ($key !== false) {
if ($expand_followers) {
$followers = Contact::selectToArray(['id'], [
- 'uid' => $uid,
- 'rel' => [Contact::FOLLOWER, Contact::FRIEND],
- 'network' => $networks,
+ 'uid' => $uid,
+ 'rel' => [Contact::FOLLOWER, Contact::FRIEND],
+ 'network' => $networks,
'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION],
- 'archive' => false,
- 'pending' => false,
- 'blocked' => false,
+ 'archive' => false,
+ 'pending' => false,
+ 'blocked' => false,
]);
foreach ($followers as $follower) {
@@ -431,13 +432,13 @@ class Circle
$key = array_search(self::MUTUALS, $circle_ids);
if ($key !== false) {
$mutuals = Contact::selectToArray(['id'], [
- 'uid' => $uid,
- 'rel' => [Contact::FRIEND],
- 'network' => $networks,
+ 'uid' => $uid,
+ 'rel' => [Contact::FRIEND],
+ 'network' => $networks,
'contact-type' => [Contact::TYPE_UNKNOWN, Contact::TYPE_PERSON],
- 'archive' => false,
- 'pending' => false,
- 'blocked' => false,
+ 'archive' => false,
+ 'pending' => false,
+ 'blocked' => false,
]);
foreach ($mutuals as $mutual) {
@@ -478,8 +479,8 @@ class Circle
{
$display_circles = [
[
- 'name' => '',
- 'id' => '0',
+ 'name' => '',
+ 'id' => '0',
'selected' => ''
]
];
@@ -487,8 +488,8 @@ class Circle
$stmt = DBA::select('group', [], ['deleted' => false, 'uid' => $uid, 'cid' => null], ['order' => ['name']]);
while ($circle = DBA::fetch($stmt)) {
$display_circles[] = [
- 'name' => $circle['name'],
- 'id' => $circle['id'],
+ 'name' => $circle['name'],
+ 'id' => $circle['id'],
'selected' => $gid == $circle['id'] ? 'true' : ''
];
}
@@ -497,8 +498,8 @@ class Circle
DI::logger()->info('Got circles', $display_circles);
$o = Renderer::replaceMacros(Renderer::getMarkupTemplate('circle_selection.tpl'), [
- '$id' => $id,
- '$label' => $label,
+ '$id' => $id,
+ '$label' => $label,
'$circles' => $display_circles
]);
return $o;
@@ -526,10 +527,10 @@ class Circle
$display_circles = [
[
- 'text' => DI::l10n()->t('Everybody'),
- 'id' => 0,
+ 'text' => DI::l10n()->t('Everybody'),
+ 'id' => 0,
'selected' => (($circle_id === 'everyone') ? 'circle-selected' : ''),
- 'href' => $every,
+ 'href' => $every,
]
];
@@ -544,7 +545,7 @@ class Circle
if ($editmode == 'full') {
$circleedit = [
- 'href' => 'circle/' . $circle['id'],
+ 'href' => 'circle/' . $circle['id'],
'title' => DI::l10n()->t('edit'),
];
} else {
@@ -552,23 +553,23 @@ class Circle
}
if ($each == 'circle') {
- $networks = Widget::unavailableNetworks();
+ $networks = Widget::unavailableNetworks();
$sql_values = array_merge([$circle['id']], $networks);
- $condition = ["`circle-id` = ? AND NOT `contact-network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"];
- $condition = array_merge($condition, $sql_values);
+ $condition = ["`circle-id` = ? AND NOT `contact-network` IN (" . substr(str_repeat("?, ", count($networks)), 0, -2) . ")"];
+ $condition = array_merge($condition, $sql_values);
- $count = DBA::count('circle-member-view', $condition);
+ $count = DBA::count('circle-member-view', $condition);
$circle_name = sprintf('%s (%d)', $circle['name'], $count);
} else {
$circle_name = $circle['name'];
}
$display_circles[] = [
- 'id' => $circle['id'],
- 'cid' => $cid,
- 'text' => $circle_name,
- 'href' => $each . '/' . $circle['id'],
- 'edit' => $circleedit,
+ 'id' => $circle['id'],
+ 'cid' => $cid,
+ 'text' => $circle_name,
+ 'href' => $each . '/' . $circle['id'],
+ 'edit' => $circleedit,
'selected' => $selected,
'ismember' => in_array($circle['id'], $member_of),
];
@@ -581,18 +582,18 @@ class Circle
}
$tpl = Renderer::getMarkupTemplate('circle_side.tpl');
- $o = Renderer::replaceMacros($tpl, [
- '$add' => DI::l10n()->t('add'),
- '$title' => DI::l10n()->t('Circles'),
- '$circles' => $display_circles,
- '$new_circle' => $editmode == 'extended' || $editmode == 'full' ? 1 : '',
- '$circle_page' => 'circle/',
- '$edittext' => DI::l10n()->t('Edit circle'),
- '$uncircled' => $every === 'contact' ? DI::l10n()->t('Contacts not in any circle') : '',
- '$uncircled_selected' => (($circle_id === 'none') ? 'circle-selected' : ''),
- '$createtext' => DI::l10n()->t('Create a new circle'),
- '$create_circle' => DI::l10n()->t('Circle Name: '),
- '$edit_circles_text' => DI::l10n()->t('Edit circles'),
+ $o = Renderer::replaceMacros($tpl, [
+ '$add' => DI::l10n()->t('add'),
+ '$title' => DI::l10n()->t('Circles'),
+ '$circles' => $display_circles,
+ '$new_circle' => $editmode == 'extended' || $editmode == 'full' ? 1 : '',
+ '$circle_page' => 'circle/',
+ '$edittext' => DI::l10n()->t('Edit circle'),
+ '$uncircled' => $every === 'contact' ? DI::l10n()->t('Contacts not in any circle') : '',
+ '$uncircled_selected' => (($circle_id === 'none') ? 'circle-selected' : ''),
+ '$createtext' => DI::l10n()->t('Create a new circle'),
+ '$create_circle' => DI::l10n()->t('Circle Name: '),
+ '$edit_circles_text' => DI::l10n()->t('Edit circles'),
'$form_security_token' => BaseModule::getFormSecurityToken('circle_edit'),
]);
diff --git a/src/Model/Contact.php b/src/Model/Contact.php
index 083f66287f..e894dc64ea 100644
--- a/src/Model/Contact.php
+++ b/src/Model/Contact.php
@@ -74,12 +74,12 @@ class Contact
* This will only be assigned to contacts, not to user accounts
* @{
*/
- const TYPE_UNKNOWN = -1;
- const TYPE_PERSON = User::ACCOUNT_TYPE_PERSON;
+ const TYPE_UNKNOWN = -1;
+ const TYPE_PERSON = User::ACCOUNT_TYPE_PERSON;
const TYPE_ORGANISATION = User::ACCOUNT_TYPE_ORGANISATION;
- const TYPE_NEWS = User::ACCOUNT_TYPE_NEWS;
- const TYPE_COMMUNITY = User::ACCOUNT_TYPE_COMMUNITY;
- const TYPE_RELAY = User::ACCOUNT_TYPE_RELAY;
+ const TYPE_NEWS = User::ACCOUNT_TYPE_NEWS;
+ const TYPE_COMMUNITY = User::ACCOUNT_TYPE_COMMUNITY;
+ const TYPE_RELAY = User::ACCOUNT_TYPE_RELAY;
/**
* @}
*/
@@ -335,7 +335,7 @@ class Contact
if (!empty($fields)) {
foreach (['id', 'next-update', 'network', 'local-data'] as $internal) {
if (!in_array($internal, $fields)) {
- $fields[] = $internal;
+ $fields[] = $internal;
$removal[] = $internal;
}
}
@@ -353,9 +353,9 @@ class Contact
// Then the alias (which could be anything)
if (!DBA::isResult($contact)) {
// The link could be provided as http although we stored it as https
- $ssl_url = str_replace('http://', 'https://', $url);
+ $ssl_url = str_replace('http://', 'https://', $url);
$condition = ['`alias` IN (?, ?, ?) AND `uid` = ? AND NOT `deleted`', $url, Strings::normaliseLink($url), $ssl_url, $uid];
- $contact = DBA::selectFirst('contact', $fields, $condition, $options);
+ $contact = DBA::selectFirst('contact', $fields, $condition, $options);
}
if (!DBA::isResult($contact)) {
@@ -837,7 +837,7 @@ class Contact
}
$fields = ['uid', 'username', 'nickname', 'page-flags', 'account-type', 'prvkey', 'pubkey'];
- $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]);
+ $user = DBA::selectFirst('user', $fields, ['uid' => $uid, 'verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]);
if (!DBA::isResult($user)) {
return false;
}
@@ -868,11 +868,11 @@ class Contact
'network' => Protocol::DFRN,
'url' => $url,
// it seems as if ported accounts can have wrong values, so we make sure that now everything is fine.
- 'nurl' => Strings::normaliseLink($url),
- 'uri-id' => ItemURI::getIdByURI($url),
- 'addr' => $user['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3),
- 'notify' => DI::baseUrl() . '/dfrn_notify/' . $user['nickname'],
- 'poll' => DI::baseUrl() . '/feed/' . $user['nickname'],
+ 'nurl' => Strings::normaliseLink($url),
+ 'uri-id' => ItemURI::getIdByURI($url),
+ 'addr' => $user['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3),
+ 'notify' => DI::baseUrl() . '/dfrn_notify/' . $user['nickname'],
+ 'poll' => DI::baseUrl() . '/feed/' . $user['nickname'],
];
$avatar = Photo::selectFirst(['resource-id', 'type'], ['uid' => $uid, 'profile' => true]);
@@ -897,14 +897,14 @@ class Contact
$fields['micro'] = self::getDefaultAvatar($fields, Proxy::SIZE_MICRO);
}
- $fields['avatar'] = User::getAvatarUrl($user);
- $fields['header'] = User::getBannerUrl($user);
- $fields['forum'] = in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_COMM_MAN]);
- $fields['prv'] = $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP;
- $fields['unsearchable'] = !$profile['net-publish'];
+ $fields['avatar'] = User::getAvatarUrl($user);
+ $fields['header'] = User::getBannerUrl($user);
+ $fields['forum'] = in_array($user['page-flags'], [User::PAGE_FLAGS_COMMUNITY, User::PAGE_FLAGS_COMM_MAN]);
+ $fields['prv'] = $user['page-flags'] == User::PAGE_FLAGS_PRVGROUP;
+ $fields['unsearchable'] = !$profile['net-publish'];
$fields['manually-approve'] = in_array($user['page-flags'], [User::PAGE_FLAGS_NORMAL, User::PAGE_FLAGS_PRVGROUP, User::PAGE_FLAGS_COMM_MAN]);
- $fields['baseurl'] = DI::baseUrl();
- $fields['gsid'] = GServer::getID($fields['baseurl'], true);
+ $fields['baseurl'] = DI::baseUrl();
+ $fields['gsid'] = GServer::getID($fields['baseurl'], true);
$update = false;
@@ -1083,7 +1083,7 @@ class Contact
public static function markForArchival(array $contact)
{
if ((!isset($contact['uri-id']) || !isset($contact['url']) || !isset($contact['archive']) || !isset($contact['self']) || !isset($contact['term-date'])) && !empty($contact['id'])) {
- $fields = ['id', 'uri-id', 'url', 'archive', 'self', 'term-date'];
+ $fields = ['id', 'uri-id', 'url', 'archive', 'self', 'term-date'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $contact['id']]);
if (!DBA::isResult($contact)) {
return;
@@ -1135,7 +1135,7 @@ class Contact
{
// Always unarchive the relay contact entry
if (!empty($contact['batch']) && !empty($contact['term-date']) && ($contact['term-date'] > DBA::NULL_DATETIME)) {
- $fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false, 'unsearchable' => true];
+ $fields = ['failed' => false, 'term-date' => DBA::NULL_DATETIME, 'archive' => false, 'unsearchable' => true];
$condition = ['uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
if (!DBA::exists('contact', array_merge($condition, $fields))) {
self::update($fields, $condition);
@@ -1149,7 +1149,7 @@ class Contact
}
if ((!isset($contact['url']) || !isset($contact['uri-id'])) && !empty($contact['id'])) {
- $fields = ['id', 'uri-id', 'url', 'batch', 'term-date'];
+ $fields = ['id', 'uri-id', 'url', 'batch', 'term-date'];
$contact = DBA::selectFirst('contact', $fields, ['id' => $contact['id']]);
if (!DBA::isResult($contact)) {
return;
@@ -1205,11 +1205,11 @@ class Contact
if ($contact['contact-type'] == Contact::TYPE_COMMUNITY) {
$mention_label = DI::l10n()->t('Post to group');
- $mention_url = 'compose/0?body=!' . $contact['addr'];
+ $mention_url = 'compose/0?body=!' . $contact['addr'];
$network_label = DI::l10n()->t('View group');
} else {
$mention_label = DI::l10n()->t('Mention');
- $mention_url = 'compose/0?body=@' . $contact['addr'];
+ $mention_url = 'compose/0?body=@' . $contact['addr'];
$network_label = DI::l10n()->t('Network Posts');
}
$network_url = 'contact/' . $contact['id'] . '/conversations';
@@ -1369,10 +1369,10 @@ class Contact
if (DBA::isResult($personal_contact) && !Probe::isProbable($personal_contact['network'])) {
DI::logger()->info('Take contact data from personal contact', ['url' => $url, 'update' => $update, 'contact' => $personal_contact]);
- $data = $personal_contact;
- $data['photo'] = $personal_contact['avatar'];
+ $data = $personal_contact;
+ $data['photo'] = $personal_contact['avatar'];
$data['account-type'] = $personal_contact['contact-type'];
- $data['hide'] = $personal_contact['unsearchable'];
+ $data['hide'] = $personal_contact['unsearchable'];
unset($data['avatar']);
unset($data['contact-type']);
unset($data['unsearchable']);
@@ -1404,17 +1404,17 @@ class Contact
if (!$contact_id) {
// We only insert the basic data. The rest will be done in "updateFromProbeArray"
$fields = [
- 'uid' => $uid,
- 'url' => $data['url'],
- 'baseurl' => $data['baseurl'] ?? '',
- 'nurl' => Strings::normaliseLink($data['url']),
- 'network' => $data['network'],
- 'created' => DateTimeFormat::utcNow(),
- 'rel' => self::SHARING,
- 'writable' => 1,
- 'blocked' => 0,
- 'readonly' => 0,
- 'pending' => 0,
+ 'uid' => $uid,
+ 'url' => $data['url'],
+ 'baseurl' => $data['baseurl'] ?? '',
+ 'nurl' => Strings::normaliseLink($data['url']),
+ 'network' => $data['network'],
+ 'created' => DateTimeFormat::utcNow(),
+ 'rel' => self::SHARING,
+ 'writable' => 1,
+ 'blocked' => 0,
+ 'readonly' => 0,
+ 'pending' => 0,
];
$condition = ['nurl' => Strings::normaliseLink($data['url']), 'uid' => $uid, 'deleted' => false];
@@ -1627,13 +1627,13 @@ class Contact
if (DI::pConfig()->get($uid, 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
- $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
+ $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
$o = '';
}
$fields = array_merge(Item::DISPLAY_FIELDLIST, ['featured']);
- $items = Post::toArray(Post::selectForUser($uid, $fields, $condition, $params));
+ $items = Post::toArray(Post::selectForUser($uid, $fields, $condition, $params));
$o .= DI::conversation()->render($items, ConversationContent::MODE_CONTACT_POSTS);
@@ -1690,7 +1690,7 @@ class Contact
if (DI::pConfig()->get($uid, 'system', 'infinite_scroll')) {
$tpl = Renderer::getMarkupTemplate('infinite_scroll_head.tpl');
- $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
+ $o = Renderer::replaceMacros($tpl, ['$reload_uri' => DI::args()->getQueryString()]);
} else {
$o = '';
}
@@ -1706,7 +1706,7 @@ class Contact
$sql2 = "SELECT `thr-parent-id` AS `uri-id`, `created` FROM `post-user-view` WHERE " . array_shift($condition2);
$union = array_merge($condition1, $condition2);
- $sql = $sql1 . " UNION " . $sql2;
+ $sql = $sql1 . " UNION " . $sql2;
$sql .= " ORDER BY `created` DESC LIMIT ?, ?";
$union = array_merge($union, [$pager->getStart(), $pager->getItemsPerPage()]);
@@ -1715,7 +1715,7 @@ class Contact
if (empty($last_created) && ($pager->getStart() == 0)) {
$fields = ['uri-id', 'thr-parent-id', 'gravity', 'author-id', 'created'];
$pinned = Post\Collection::selectToArrayForContact($cid, Post\Collection::FEATURED, $fields);
- $items = array_merge($items, $pinned);
+ $items = array_merge($items, $pinned);
}
$o .= DI::conversation()->render($items, ConversationContent::MODE_CONTACTS, $update, false, 'pinned_created', $uid);
@@ -1906,9 +1906,9 @@ class Contact
*/
private static function checkAvatarCacheByArray(array $contact, bool $no_update = false): array
{
- $update = false;
+ $update = false;
$contact_fields = [];
- $fields = ['photo', 'thumb', 'micro'];
+ $fields = ['photo', 'thumb', 'micro'];
foreach ($fields as $field) {
if (isset($contact[$field])) {
$contact_fields[] = $field;
@@ -1964,7 +1964,7 @@ class Contact
if (!empty($contact['gsid'])) {
// Use default banners for certain platforms
- $gserver = DBA::selectFirst('gserver', ['platform'], ['id' => $contact['gsid']]);
+ $gserver = DBA::selectFirst('gserver', ['platform'], ['id' => $contact['gsid']]);
$platform = strtolower($gserver['platform'] ?? '');
} else {
$platform = '';
@@ -2009,18 +2009,18 @@ class Contact
switch ($size) {
case Proxy::SIZE_MICRO:
$avatar['size'] = 48;
- $default = self::DEFAULT_AVATAR_MICRO;
+ $default = self::DEFAULT_AVATAR_MICRO;
break;
case Proxy::SIZE_THUMB:
$avatar['size'] = 80;
- $default = self::DEFAULT_AVATAR_THUMB;
+ $default = self::DEFAULT_AVATAR_THUMB;
break;
case Proxy::SIZE_SMALL:
default:
$avatar['size'] = 300;
- $default = self::DEFAULT_AVATAR_PHOTO;
+ $default = self::DEFAULT_AVATAR_PHOTO;
break;
}
@@ -2029,14 +2029,14 @@ class Contact
$type = Contact::TYPE_PERSON;
if (!empty($contact['id'])) {
- $account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['id' => $contact['id']]);
- $platform = $account['platform'] ?? '';
+ $account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['id' => $contact['id']]);
+ $platform = $account['platform'] ?? '';
$type = $account['contact-type'] ?? Contact::TYPE_PERSON;
}
if (empty($platform) && !empty($contact['uri-id'])) {
- $account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['uri-id' => $contact['uri-id']]);
- $platform = $account['platform'] ?? '';
+ $account = DBA::selectFirst('account-user-view', ['platform', 'contact-type'], ['uri-id' => $contact['uri-id']]);
+ $platform = $account['platform'] ?? '';
$type = $account['contact-type'] ?? Contact::TYPE_PERSON;
}
@@ -2146,7 +2146,7 @@ class Contact
return DI::baseUrl() . $default;
}
- $avatar['url'] = '';
+ $avatar['url'] = '';
$avatar['success'] = false;
Hook::callAll('avatar_lookup', $avatar);
@@ -2174,7 +2174,7 @@ class Contact
if (empty($updated)) {
$account = DBA::selectFirst('account-user-view', ['updated', 'guid'], ['id' => $cid]);
$updated = $account['updated'] ?? '';
- $guid = $account['guid'] ?? '';
+ $guid = $account['guid'] ?? '';
}
$guid = urlencode($guid);
@@ -2242,7 +2242,7 @@ class Contact
if (empty($updated) || empty($guid)) {
$account = DBA::selectFirst('account-user-view', ['updated', 'guid'], ['id' => $cid]);
$updated = $account['updated'] ?? '';
- $guid = $account['guid'] ?? '';
+ $guid = $account['guid'] ?? '';
}
$guid = urlencode($guid);
@@ -2373,11 +2373,11 @@ class Contact
if ($default_avatar && Proxy::isLocalImage($avatar)) {
$fields = [
- 'avatar' => $avatar,
+ 'avatar' => $avatar,
'avatar-date' => DateTimeFormat::utcNow(),
- 'photo' => $avatar,
- 'thumb' => self::getDefaultAvatar($contact, Proxy::SIZE_THUMB),
- 'micro' => self::getDefaultAvatar($contact, Proxy::SIZE_MICRO)
+ 'photo' => $avatar,
+ 'thumb' => self::getDefaultAvatar($contact, Proxy::SIZE_THUMB),
+ 'micro' => self::getDefaultAvatar($contact, Proxy::SIZE_MICRO)
];
DI::logger()->debug('Use default avatar', ['id' => $cid, 'uid' => $uid]);
}
@@ -2416,11 +2416,11 @@ class Contact
$photos = Photo::importProfilePhoto($avatar, $uid, $cid, true);
if ($photos) {
$fields = [
- 'avatar' => $avatar,
- 'photo' => $photos[0],
- 'thumb' => $photos[1],
- 'micro' => $photos[2],
- 'blurhash' => $photos[3],
+ 'avatar' => $avatar,
+ 'photo' => $photos[0],
+ 'thumb' => $photos[1],
+ 'micro' => $photos[2],
+ 'blurhash' => $photos[3],
'avatar-date' => DateTimeFormat::utcNow(),
];
$update = true;
@@ -2473,7 +2473,7 @@ class Contact
{
// Update contact data for all users
$condition = ['self' => false, 'nurl' => Strings::normaliseLink($url)];
- $contacts = DBA::select('contact', ['id', 'uid'], $condition);
+ $contacts = DBA::select('contact', ['id', 'uid'], $condition);
while ($contact = DBA::fetch($contacts)) {
DI::logger()->info('Deleting contact', ['id' => $contact['id'], 'uid' => $contact['uid'], 'url' => $url]);
self::remove($contact['id']);
@@ -2600,7 +2600,7 @@ class Contact
public static function removeDuplicates(string $nurl, int $uid)
{
$condition = ['nurl' => $nurl, 'uid' => $uid, 'self' => false, 'deleted' => false, 'network' => Protocol::FEDERATED];
- $count = DBA::count('contact', $condition);
+ $count = DBA::count('contact', $condition);
if ($count <= 1) {
return false;
}
@@ -2615,7 +2615,7 @@ class Contact
DI::logger()->info('Found duplicates', ['count' => $count, 'first' => $first, 'uid' => $uid, 'nurl' => $nurl]);
// Find all duplicates
- $condition = ["`nurl` = ? AND `uid` = ? AND `id` != ? AND NOT `self` AND NOT `deleted`", $nurl, $uid, $first];
+ $condition = ["`nurl` = ? AND `uid` = ? AND `id` != ? AND NOT `self` AND NOT `deleted`", $nurl, $uid, $first];
$duplicates = DBA::select('contact', ['id', 'network'], $condition);
while ($duplicate = DBA::fetch($duplicates)) {
if (!in_array($duplicate['network'], Protocol::FEDERATED)) {
@@ -2686,7 +2686,7 @@ class Contact
$data = Probe::uri($contact['url'], $network, $contact['uid']);
if (in_array($data['network'], Protocol::FEDERATED) && (parse_url($data['url'], PHP_URL_SCHEME) == 'http')) {
- $ssl_url = str_replace('http://', 'https://', $contact['url']);
+ $ssl_url = str_replace('http://', 'https://', $contact['url']);
$ssl_data = Probe::uri($ssl_url, $network, $contact['uid']);
if (($ssl_data['network'] == $data['network']) && (parse_url($ssl_data['url'], PHP_URL_SCHEME) != 'http')) {
$data = $ssl_data;
@@ -2883,12 +2883,12 @@ class Contact
}
if (isset($ret['account-type']) && is_int($ret['account-type'])) {
- $ret['forum'] = false;
- $ret['prv'] = false;
+ $ret['forum'] = false;
+ $ret['prv'] = false;
$ret['contact-type'] = $ret['account-type'];
if (($ret['contact-type'] == User::ACCOUNT_TYPE_COMMUNITY) && isset($ret['manually-approve'])) {
$ret['forum'] = (bool)!$ret['manually-approve'];
- $ret['prv'] = (bool)!$ret['forum'];
+ $ret['prv'] = (bool)!$ret['forum'];
}
}
@@ -2907,7 +2907,7 @@ class Contact
}
$update = false;
- $guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], $ret['baseurl'] ?? $ret['alias'] ?? '');
+ $guid = ($ret['guid'] ?? '') ?: Item::guidFromUri($ret['url'], $ret['baseurl'] ?? $ret['alias'] ?? '');
// make sure to not overwrite existing values with blank entries except some technical fields
$keep = ['batch', 'notify', 'poll', 'request', 'confirm', 'poco', 'baseurl'];
@@ -2974,7 +2974,7 @@ class Contact
}
if (($uid == 0) || in_array($ret['network'], [Protocol::DFRN, Protocol::DIASPORA, Protocol::ACTIVITYPUB])) {
- $ret['last-update'] = $updated;
+ $ret['last-update'] = $updated;
$ret['success_update'] = $updated;
}
@@ -3106,10 +3106,10 @@ class Contact
if (!empty($arr['contact']['name'])) {
$probed = false;
- $ret = $arr['contact'];
+ $ret = $arr['contact'];
} else {
$probed = true;
- $ret = Probe::uri($url, $network, $uid);
+ $ret = Probe::uri($url, $network, $uid);
// Ensure that the public contact exists
if ($ret['network'] != Protocol::PHANTOM) {
@@ -3124,7 +3124,7 @@ class Contact
// check if we already have a contact
$condition = ['uid' => $uid, 'nurl' => Strings::normaliseLink($ret['url']), 'deleted' => false];
- $contact = DBA::selectFirst('contact', ['id', 'rel', 'url', 'pending', 'hub-verify'], $condition);
+ $contact = DBA::selectFirst('contact', ['id', 'rel', 'url', 'pending', 'hub-verify'], $condition);
$protocol = self::getProtocol($ret['url'], $ret['network']);
@@ -3203,7 +3203,7 @@ class Contact
'nick' => $ret['nick'],
'network' => $ret['network'],
'baseurl' => $ret['baseurl'],
- 'gsid' => $ret['gsid'] ?? null,
+ 'gsid' => $ret['gsid'] ?? null,
'contact-type' => $ret['account-type'] ?? self::TYPE_PERSON,
'protocol' => $protocol,
'pubkey' => $ret['pubkey'],
@@ -3223,7 +3223,7 @@ class Contact
return $result;
}
- $contact_id = $contact['id'];
+ $contact_id = $contact['id'];
$result['cid'] = $contact_id;
if ($contact['contact-type'] == self::TYPE_COMMUNITY) {
@@ -3268,7 +3268,7 @@ class Contact
return false;
}
- $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked', 'baseurl'];
+ $fields = ['id', 'url', 'name', 'nick', 'avatar', 'photo', 'network', 'blocked', 'baseurl'];
$pub_contact = DBA::selectFirst('contact', $fields, ['id' => $datarray['author-id']]);
if (!DBA::isResult($pub_contact)) {
// Should never happen
@@ -3280,10 +3280,10 @@ class Contact
return false;
}
- $url = ($datarray['author-link'] ?? '') ?: $pub_contact['url'];
- $name = $pub_contact['name'];
- $photo = ($pub_contact['avatar'] ?? '') ?: $pub_contact["photo"];
- $nick = $pub_contact['nick'];
+ $url = ($datarray['author-link'] ?? '') ?: $pub_contact['url'];
+ $name = $pub_contact['name'];
+ $photo = ($pub_contact['avatar'] ?? '') ?: $pub_contact["photo"];
+ $nick = $pub_contact['nick'];
$network = $pub_contact['network'];
// Ensure that we don't create a new contact when there already is one
@@ -3361,7 +3361,7 @@ class Contact
/// @TODO Encapsulate this into a function/method
$fields = ['uid', 'username', 'email', 'page-flags', 'notify-flags', 'language'];
- $user = DBA::selectFirst('user', $fields, ['uid' => $importer['uid']]);
+ $user = DBA::selectFirst('user', $fields, ['uid' => $importer['uid']]);
if (DBA::isResult($user) && !in_array($user['page-flags'], [User::PAGE_FLAGS_SOAPBOX, User::PAGE_FLAGS_FREELOVE, User::PAGE_FLAGS_COMMUNITY])) {
// create notification
if (is_array($contact_record)) {
@@ -3395,7 +3395,7 @@ class Contact
}
$condition = ['uid' => $importer['uid'], 'url' => $url, 'pending' => true];
- $fields = ['pending' => false];
+ $fields = ['pending' => false];
if ($user['page-flags'] == User::PAGE_FLAGS_FREELOVE) {
$fields['rel'] = self::FRIEND;
}
@@ -3500,7 +3500,7 @@ class Contact
DBA::update(
'contact',
['bdyear' => substr($nextbd, 0, 4), 'bd' => $nextbd],
- ['id' => $contact['id']]
+ ['id' => $contact['id']]
);
}
}
@@ -3655,9 +3655,9 @@ class Contact
*/
public static function isGroup(int $contactid): bool
{
- $fields = ['contact-type'];
+ $fields = ['contact-type'];
$condition = ['id' => $contactid];
- $contact = DBA::selectFirst('contact', $fields, $condition);
+ $contact = DBA::selectFirst('contact', $fields, $condition);
if (!DBA::isResult($contact)) {
return false;
}
@@ -3675,7 +3675,7 @@ class Contact
public static function canReceivePrivateMessages(array $contact): bool
{
$protocol = $contact['network'] ?? $contact['protocol'] ?? Protocol::PHANTOM;
- $self = $contact['self'] ?? false;
+ $self = $contact['self'] ?? false;
return in_array($protocol, [Protocol::DFRN, Protocol::DIASPORA, Protocol::ACTIVITYPUB]) && !$self;
}
@@ -3706,12 +3706,12 @@ class Contact
}
$condition = [
- 'network' => $networks,
- 'server-failed' => false,
- 'failed' => false,
- 'deleted' => false,
- 'unsearchable' => false,
- 'uid' => $uid
+ 'network' => $networks,
+ 'server-failed' => false,
+ 'failed' => false,
+ 'deleted' => false,
+ 'unsearchable' => false,
+ 'uid' => $uid
];
if (!$show_blocked) {
@@ -3755,10 +3755,10 @@ class Contact
*/
public static function addByUrls(array $urls): array
{
- $added = 0;
- $updated = 0;
+ $added = 0;
+ $updated = 0;
$unchanged = 0;
- $count = 0;
+ $count = 0;
foreach ($urls as $url) {
if (empty($url) || !is_string($url)) {
diff --git a/src/Model/Contact/Relation.php b/src/Model/Contact/Relation.php
index 76e0a7ac63..5172d87c70 100644
--- a/src/Model/Contact/Relation.php
+++ b/src/Model/Contact/Relation.php
@@ -98,7 +98,7 @@ class Relation
$uid = User::getIdForURL($url);
if (!empty($uid)) {
DI::logger()->info('Fetch the followers/followings locally', ['url' => $url]);
- $followers = self::getContacts($uid, [Contact::FOLLOWER, Contact::FRIEND]);
+ $followers = self::getContacts($uid, [Contact::FOLLOWER, Contact::FRIEND]);
$followings = self::getContacts($uid, [Contact::SHARING, Contact::FRIEND]);
} elseif (!Contact::isLocal($url)) {
DI::logger()->info('Fetch the followers/followings by polling the endpoints', ['url' => $url]);
@@ -117,7 +117,7 @@ class Relation
}
} else {
DI::logger()->warning('Contact seems to be local but could not be found here', ['url' => $url]);
- $followers = [];
+ $followers = [];
$followings = [];
}
@@ -158,7 +158,7 @@ class Relation
}
$contacts = array_unique($contacts);
- $follower_counter = 0;
+ $follower_counter = 0;
$following_counter = 0;
DI::logger()->info('Discover contacts', ['id' => $target, 'url' => $url, 'contacts' => count($contacts)]);
@@ -199,7 +199,7 @@ class Relation
*/
private static function getContacts(int $uid, array $rel, bool $only_ap = true): array
{
- $list = [];
+ $list = [];
$profile = Profile::getByUID($uid);
if (!empty($profile['hide-friends'])) {
return $list;
@@ -300,7 +300,7 @@ class Relation
* @param integer $uid
* @return boolean
*/
- static public function areSuggestionsOutdated(int $uid): bool
+ public static function areSuggestionsOutdated(int $uid): bool
{
return DI::pConfig()->get($uid, 'suggestion', 'last_update') + 3600 < time();
}
@@ -311,7 +311,7 @@ class Relation
* @param integer $uid
* @return void
*/
- static public function updateCachedSuggestions(int $uid)
+ public static function updateCachedSuggestions(int $uid)
{
if (!self::areSuggestionsOutdated($uid)) {
return;
@@ -334,11 +334,11 @@ class Relation
* @param int $limit optional, default 80
* @return array
*/
- static public function getCachedSuggestions(int $uid, int $start = 0, int $limit = 80): array
+ public static function getCachedSuggestions(int $uid, int $start = 0, int $limit = 80): array
{
$condition = ["`uid` = ? AND `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE NOT `ignore` AND `uid` = ?)", 0, $uid];
- $params = ['limit' => [$start, $limit]];
- $cached = DBA::selectToArray('contact', [], $condition, $params);
+ $params = ['limit' => [$start, $limit]];
+ $cached = DBA::selectToArray('contact', [], $condition, $params);
if (!empty($cached)) {
return $cached;
@@ -355,15 +355,15 @@ class Relation
* @param int $limit optional, default 80
* @return array
*/
- static public function getSuggestions(int $uid, int $start = 0, int $limit = 80): array
+ public static function getSuggestions(int $uid, int $start = 0, int $limit = 80): array
{
if ($uid == 0) {
return [];
}
- $cid = Contact::getPublicIdByUserId($uid);
+ $cid = Contact::getPublicIdByUserId($uid);
$totallimit = $start + $limit;
- $contacts = [];
+ $contacts = [];
DI::logger()->info('Collecting suggestions', ['uid' => $uid, 'cid' => $cid, 'start' => $start, 'limit' => $limit]);
@@ -371,17 +371,21 @@ class Relation
// The query returns contacts where contacts interacted with whom the given user follows.
// Contacts who already are in the user's contact table are ignored.
- $results = DBA::select('contact', [], ["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
+ $results = DBA::select(
+ 'contact',
+ [],
+ ["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
(SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ?)
AND NOT `cid` IN (SELECT `id` FROM `contact` WHERE `uid` = ? AND `nurl` IN
(SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))) AND `id` = `cid`)
AND NOT `hidden` AND `network` IN (?, ?, ?)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
- $cid,
- 0,
- $uid, Contact::FRIEND, Contact::SHARING,
- Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid
- ], [
+ $cid,
+ 0,
+ $uid, Contact::FRIEND, Contact::SHARING,
+ Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid
+ ],
+ [
'order' => ['last-item' => true],
'limit' => $totallimit,
]
@@ -401,15 +405,17 @@ class Relation
// The query returns contacts where contacts interacted with whom also interacted with the given user.
// Contacts who already are in the user's contact table are ignored.
- $results = DBA::select('contact', [],
+ $results = DBA::select(
+ 'contact',
+ [],
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` IN
(SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ?)
AND NOT `cid` IN (SELECT `id` FROM `contact` WHERE `uid` = ? AND `nurl` IN
(SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?))) AND `id` = `cid`)
AND NOT `hidden` AND `network` IN (?, ?, ?)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
- $cid, 0, $uid, Contact::FRIEND, Contact::SHARING,
- Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
+ $cid, 0, $uid, Contact::FRIEND, Contact::SHARING,
+ Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
['order' => ['last-item' => true], 'limit' => $totallimit]
);
@@ -425,12 +431,14 @@ class Relation
}
// The query returns contacts that follow the given user but aren't followed by that user.
- $results = DBA::select('contact', [],
+ $results = DBA::select(
+ 'contact',
+ [],
["`nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` = ?)
AND NOT `hidden` AND `uid` = ? AND `network` IN (?, ?, ?)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
- $uid, Contact::FOLLOWER, 0,
- Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
+ $uid, Contact::FOLLOWER, 0,
+ Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
['order' => ['last-item' => true], 'limit' => $totallimit]
);
@@ -446,12 +454,14 @@ class Relation
}
// The query returns any contact that isn't followed by that user.
- $results = DBA::select('contact', [],
+ $results = DBA::select(
+ 'contact',
+ [],
["NOT `nurl` IN (SELECT `nurl` FROM `contact` WHERE `uid` = ? AND `rel` IN (?, ?) AND `nurl` = `nurl`)
AND NOT `hidden` AND `uid` = ? AND `network` IN (?, ?, ?)
AND NOT `uri-id` IN (SELECT `uri-id` FROM `account-suggestion` WHERE `uri-id` = `contact`.`uri-id` AND `uid` = ?)",
- $uid, Contact::FRIEND, Contact::SHARING, 0,
- Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
+ $uid, Contact::FRIEND, Contact::SHARING, 0,
+ Protocol::ACTIVITYPUB, Protocol::DFRN, $diaspora, $uid],
['order' => ['last-item' => true], 'limit' => $totallimit]
);
@@ -476,7 +486,7 @@ class Relation
public static function countFollows(int $cid, array $condition = []): int
{
$condition = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
- $sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
+ $sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
$result = DBA::fetchFirst($sql, $condition);
return $result['total'] ?? 0;
@@ -495,7 +505,7 @@ class Relation
public static function listFollows(int $cid, array $condition = [], int $count = 30, int $offset = 0)
{
$condition = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
- $sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
+ $sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition);
if ($count > 0) {
$sql .= " LIMIT ?, ?";
$condition = array_merge($condition, [$offset, $count]);
@@ -514,7 +524,7 @@ class Relation
public static function countFollowers(int $cid, array $condition = [])
{
$condition = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
- $sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
+ $sql = "SELECT COUNT(*) AS `total` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
$result = DBA::fetchFirst($sql, $condition);
return $result['total'] ?? 0;
@@ -533,7 +543,7 @@ class Relation
public static function listFollowers(int $cid, array $condition = [], int $count = 30, int $offset = 0)
{
$condition = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
- $sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
+ $sql = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition);
if ($count > 0) {
$sql .= " LIMIT ?, ?";
$condition = array_merge($condition, [$offset, $count]);
@@ -553,13 +563,13 @@ class Relation
{
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
- $sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
- $sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
- $union = array_merge($condition1, $condition2);
- $sql = $sql1 . " INTERSECT " . $sql2;
+ $sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
+ $sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
+ $union = array_merge($condition1, $condition2);
+ $sql = $sql1 . " INTERSECT " . $sql2;
$contacts = 0;
- $query = DBA::p($sql, $union);
+ $query = DBA::p($sql, $union);
while (DBA::fetch($query)) {
$contacts++;
}
@@ -582,10 +592,10 @@ class Relation
{
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
- $sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
- $sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
- $union = array_merge($condition1, $condition2);
- $sql = $sql1 . " INTERSECT " . $sql2;
+ $sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
+ $sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition2);
+ $union = array_merge($condition1, $condition2);
+ $sql = $sql1 . " INTERSECT " . $sql2;
if ($count > 0) {
$sql .= " LIMIT ?, ?";
$union = array_merge($union, [$offset, $count]);
@@ -605,13 +615,13 @@ class Relation
{
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
- $sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
- $sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
- $union = array_merge($condition1, $condition2);
- $sql = $sql1 . " UNION " . $sql2;
+ $sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
+ $sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
+ $union = array_merge($condition1, $condition2);
+ $sql = $sql1 . " UNION " . $sql2;
$contacts = 0;
- $query = DBA::p($sql, $union);
+ $query = DBA::p($sql, $union);
while (DBA::fetch($query)) {
$contacts++;
}
@@ -634,10 +644,10 @@ class Relation
{
$condition1 = DBA::mergeConditions($condition, ["`cid` = ? and `follows`", $cid]);
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ? and `follows`", $cid]);
- $sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
- $sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
- $union = array_merge($condition1, $condition2);
- $sql = $sql1 . " UNION " . $sql2;
+ $sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `relation-cid` WHERE " . array_shift($condition1);
+ $sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
+ $union = array_merge($condition1, $condition2);
+ $sql = $sql1 . " UNION " . $sql2;
if ($count > 0) {
$sql .= " LIMIT ?, ?";
$union = array_merge($union, [$offset, $count]);
@@ -659,13 +669,13 @@ class Relation
{
$condition1 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $sourceId]);
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $targetId]);
- $sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
- $sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
- $union = array_merge($condition1, $condition2);
- $sql = $sql1 . " INTERSECT " . $sql2;
+ $sql1 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
+ $sql2 = "SELECT `contact`.`id` FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
+ $union = array_merge($condition1, $condition2);
+ $sql = $sql1 . " INTERSECT " . $sql2;
$contacts = 0;
- $query = DBA::p($sql, $union);
+ $query = DBA::p($sql, $union);
while (DBA::fetch($query)) {
$contacts++;
}
@@ -690,10 +700,10 @@ class Relation
{
$condition1 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $sourceId]);
$condition2 = DBA::mergeConditions($condition, ["`relation-cid` = ?", $targetId]);
- $sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
- $sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
- $union = array_merge($condition1, $condition2);
- $sql = $sql1 . " INTERSECT " . $sql2;
+ $sql1 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " . array_shift($condition1);
+ $sql2 = "SELECT `contact`.* FROM `contact-relation` INNER JOIN `contact` ON `contact`.`id` = `cid` WHERE " .array_shift($condition2);
+ $union = array_merge($condition1, $condition2);
+ $sql = $sql1 . " INTERSECT " . $sql2;
if ($count > 0) {
$sql .= " LIMIT ?, ?";
$union = array_merge($union, [$offset, $count]);
@@ -712,10 +722,11 @@ class Relation
*/
public static function countCommonFollows(int $sourceId, int $targetId, array $condition = []): int
{
- $condition = DBA::mergeConditions($condition,
+ $condition = DBA::mergeConditions(
+ $condition,
['`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)',
- $sourceId, $targetId]
+ $sourceId, $targetId]
);
return DI::dba()->count('contact', $condition);
@@ -735,13 +746,17 @@ class Relation
*/
public static function listCommonFollows(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
- $condition = DBA::mergeConditions($condition,
+ $condition = DBA::mergeConditions(
+ $condition,
["`id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)
AND `id` IN (SELECT `relation-cid` FROM `contact-relation` WHERE `cid` = ? AND `follows`)",
- $sourceId, $targetId]
+ $sourceId, $targetId]
);
- return DI::dba()->selectToArray('contact', [], $condition,
+ return DI::dba()->selectToArray(
+ 'contact',
+ [],
+ $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
@@ -757,10 +772,11 @@ class Relation
*/
public static function countCommonFollowers(int $sourceId, int $targetId, array $condition = []): int
{
- $condition = DBA::mergeConditions($condition,
+ $condition = DBA::mergeConditions(
+ $condition,
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
- $sourceId, $targetId]
+ $sourceId, $targetId]
);
return DI::dba()->count('contact', $condition);
@@ -780,13 +796,17 @@ class Relation
*/
public static function listCommonFollowers(int $sourceId, int $targetId, array $condition = [], int $count = 30, int $offset = 0, bool $shuffle = false)
{
- $condition = DBA::mergeConditions($condition,
+ $condition = DBA::mergeConditions(
+ $condition,
["`id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)
AND `id` IN (SELECT `cid` FROM `contact-relation` WHERE `relation-cid` = ? AND `follows`)",
- $sourceId, $targetId]
+ $sourceId, $targetId]
);
- return DI::dba()->selectToArray('contact', [], $condition,
+ return DI::dba()->selectToArray(
+ 'contact',
+ [],
+ $condition,
['limit' => [$offset, $count], 'order' => [$shuffle ? 'RAND()' : 'name']]
);
}
@@ -799,78 +819,156 @@ class Relation
*/
public static function calculateInteractionScore(int $uid)
{
- $days = DI::config()->get('channel', 'interaction_score_days');
+ $days = DI::config()->get('channel', 'interaction_score_days');
$contact_id = Contact::getPublicIdByUserId($uid);
DI::logger()->debug('Calculation - start', ['uid' => $uid, 'cid' => $contact_id, 'days' => $days]);
$follow = Verb::getID(Activity::FOLLOW);
- $view = Verb::getID(Activity::VIEW);
- $read = Verb::getID(Activity::READ);
+ $view = Verb::getID(Activity::VIEW);
+ $read = Verb::getID(Activity::READ);
DBA::update('contact-relation', ['score' => 0, 'relation-score' => 0, 'thread-score' => 0, 'relation-thread-score' => 0], ['relation-cid' => $contact_id]);
- $total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
- $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $total = DBA::fetchFirst(
+ "SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
DI::logger()->debug('Calculate relation-score', ['uid' => $uid, 'total' => $total['activity']]);
- $interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
+ $interactions = DBA::p(
+ "SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
- $uid, Contact::SHARING, Contact::FRIEND, $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $uid,
+ Contact::SHARING,
+ Contact::FRIEND,
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
while ($interaction = DBA::fetch($interactions)) {
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
DBA::update('contact-relation', ['relation-score' => $score, 'follows' => $interaction['follows']], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
}
DBA::close($interactions);
- $total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
- $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $total = DBA::fetchFirst(
+ "SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
DI::logger()->debug('Calculate relation-thread-score', ['uid' => $uid, 'total' => $total['activity']]);
- $interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
+ $interactions = DBA::p(
+ "SELECT `post`.`author-id`, count(*) AS `activity`, EXISTS(SELECT `pid` FROM `account-user-view` WHERE `pid` = `post`.`author-id` AND `uid` = ? AND `rel` IN (?, ?)) AS `follows`
FROM `post-user` INNER JOIN `post` ON `post`.`uri-id` = `post-user`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
- $uid, Contact::SHARING, Contact::FRIEND, $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $uid,
+ Contact::SHARING,
+ Contact::FRIEND,
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
while ($interaction = DBA::fetch($interactions)) {
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
DBA::update('contact-relation', ['relation-thread-score' => $score, 'follows' => !empty($interaction['follows'])], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
}
DBA::close($interactions);
- $total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
- $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $total = DBA::fetchFirst(
+ "SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
DI::logger()->debug('Calculate score', ['uid' => $uid, 'total' => $total['activity']]);
- $interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
- $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $interactions = DBA::p(
+ "SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`thr-parent-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
while ($interaction = DBA::fetch($interactions)) {
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
DBA::update('contact-relation', ['score' => $score], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
}
DBA::close($interactions);
- $total = DBA::fetchFirst("SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
- $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $total = DBA::fetchFirst(
+ "SELECT count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?)",
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
DI::logger()->debug('Calculate thread-score', ['uid' => $uid, 'total' => $total['activity']]);
- $interactions = DBA::p("SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
- $contact_id, DateTimeFormat::utc('now - ' . $days . ' day'), $uid, $contact_id, $follow, $view, $read);
+ $interactions = DBA::p(
+ "SELECT `post`.`author-id`, count(*) AS `activity` FROM `post-user` INNER JOIN `post` ON `post-user`.`uri-id` = `post`.`parent-uri-id` WHERE `post-user`.`author-id` = ? AND `post-user`.`received` >= ? AND `post-user`.`uid` = ? AND `post`.`author-id` != ? AND NOT `post`.`vid` IN (?, ?, ?) GROUP BY `post`.`author-id`",
+ $contact_id,
+ DateTimeFormat::utc('now - ' . $days . ' day'),
+ $uid,
+ $contact_id,
+ $follow,
+ $view,
+ $read
+ );
while ($interaction = DBA::fetch($interactions)) {
$score = min((int)(($interaction['activity'] / $total['activity']) * 65535), 65535);
DBA::update('contact-relation', ['thread-score' => $score], ['relation-cid' => $contact_id, 'cid' => $interaction['author-id']]);
}
DBA::close($interactions);
- $total = DBA::fetchFirst("SELECT count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ?",
- $contact_id, $uid, DateTimeFormat::utc('now - ' . $days . ' day'));
+ $total = DBA::fetchFirst(
+ "SELECT count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ?",
+ $contact_id,
+ $uid,
+ DateTimeFormat::utc('now - ' . $days . ' day')
+ );
DI::logger()->debug('Calculate post-score', ['uid' => $uid, 'total' => $total['posts']]);
- $posts = DBA::p("SELECT `author-id`, count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ? GROUP BY `author-id`",
- $contact_id, $uid, DateTimeFormat::utc('now - ' . $days . ' day'));
+ $posts = DBA::p(
+ "SELECT `author-id`, count(*) AS `posts` FROM `post-thread-user` WHERE EXISTS(SELECT `cid` FROM `contact-relation` WHERE `cid` = `post-thread-user`.`author-id` AND `relation-cid` = ? AND `follows`) AND `uid` = ? AND `created` > ? GROUP BY `author-id`",
+ $contact_id,
+ $uid,
+ DateTimeFormat::utc('now - ' . $days . ' day')
+ );
while ($post = DBA::fetch($posts)) {
$score = min((int)(($post['posts'] / $total['posts']) * 65535), 65535);
DBA::update('contact-relation', ['post-score' => $score], ['relation-cid' => $contact_id, 'cid' => $post['author-id']]);
diff --git a/src/Model/Contact/User.php b/src/Model/Contact/User.php
index e7f5699556..17663e233b 100644
--- a/src/Model/Contact/User.php
+++ b/src/Model/Contact/User.php
@@ -56,9 +56,9 @@ class User
return false;
}
- $fields = self::preparedFields($contact);
- $fields['cid'] = $pcid;
- $fields['uid'] = $contact['uid'];
+ $fields = self::preparedFields($contact);
+ $fields['cid'] = $pcid;
+ $fields['uid'] = $contact['uid'];
$fields['uri-id'] = $contact['uri-id'];
$ret = DBA::insert('user-contact', $fields, Database::INSERT_UPDATE);
@@ -89,7 +89,7 @@ class User
continue;
}
$update_fields['cid'] = $contact['pid'];
- $ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']], true);
+ $ret = DBA::update('user-contact', $update_fields, ['uri-id' => $contact['uri-id'], 'uid' => $contact['uid']], true);
DI::logger()->info('Updated user contact', ['uid' => $contact['uid'], 'id' => $contact['pid'], 'uri-id' => $contact['uri-id'], 'ret' => $ret]);
}
diff --git a/src/Model/Event.php b/src/Model/Event.php
index 86567681e1..6cb73f4c37 100644
--- a/src/Model/Event.php
+++ b/src/Model/Event.php
@@ -29,7 +29,6 @@ use Friendica\Util\XML;
*/
class Event
{
-
public static function getHTML(array $event, bool $simple = false, int $uriid = 0): string
{
if (empty($event)) {
@@ -232,28 +231,28 @@ class Event
*/
public static function store(array $arr): int
{
- $guid = $arr['guid'] ?? '' ?: System::createUUID();
- $uri = $arr['uri'] ?? '' ?: Item::newURI($guid);
+ $guid = $arr['guid'] ?? '' ?: System::createUUID();
+ $uri = $arr['uri'] ?? '' ?: Item::newURI($guid);
$event = [
- 'id' => intval($arr['id'] ?? 0),
- 'uid' => intval($arr['uid'] ?? 0),
- 'cid' => intval($arr['cid'] ?? 0),
+ 'id' => intval($arr['id'] ?? 0),
+ 'uid' => intval($arr['uid'] ?? 0),
+ 'cid' => intval($arr['cid'] ?? 0),
'guid' => $guid,
'uri' => $uri,
'uri-id' => ItemURI::insert(['uri' => $uri, 'guid' => $guid]),
- 'type' => ($arr['type'] ?? '') ?: 'event',
- 'summary' => $arr['summary'] ?? '',
- 'desc' => $arr['desc'] ?? '',
- 'location' => $arr['location'] ?? '',
- 'allow_cid' => $arr['allow_cid'] ?? '',
- 'allow_gid' => $arr['allow_gid'] ?? '',
- 'deny_cid' => $arr['deny_cid'] ?? '',
- 'deny_gid' => $arr['deny_gid'] ?? '',
+ 'type' => ($arr['type'] ?? '') ?: 'event',
+ 'summary' => $arr['summary'] ?? '',
+ 'desc' => $arr['desc'] ?? '',
+ 'location' => $arr['location'] ?? '',
+ 'allow_cid' => $arr['allow_cid'] ?? '',
+ 'allow_gid' => $arr['allow_gid'] ?? '',
+ 'deny_cid' => $arr['deny_cid'] ?? '',
+ 'deny_gid' => $arr['deny_gid'] ?? '',
'nofinish' => intval($arr['nofinish'] ?? (!empty($arr['start']) && empty($arr['finish']))),
'created' => DateTimeFormat::utc(($arr['created'] ?? '') ?: 'now'),
- 'edited' => DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now'),
- 'start' => DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME),
- 'finish' => DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME),
+ 'edited' => DateTimeFormat::utc(($arr['edited'] ?? '') ?: 'now'),
+ 'start' => DateTimeFormat::utc(($arr['start'] ?? '') ?: DBA::NULL_DATETIME),
+ 'finish' => DateTimeFormat::utc(($arr['finish'] ?? '') ?: DBA::NULL_DATETIME),
];
@@ -357,7 +356,7 @@ class Event
$item['body'] = self::getBBCode($event);
$item['event-id'] = $event['id'];
- $item['object'] = '