mirror of
https://github.com/friendica/friendica
synced 2025-11-07 10:14:40 +01:00
Fix code style
This commit is contained in:
parent
d4697a17a3
commit
0e59dba914
102 changed files with 3038 additions and 2764 deletions
22
mod/item.php
22
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);
|
||||
|
|
|
|||
290
mod/photos.php
290
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" . '<meta name="twitter:card" content="summary_large_image" />' . "\n";
|
||||
|
|
|
|||
|
|
@ -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'] ?? '');
|
||||
|
|
|
|||
|
|
@ -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 '';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)]);
|
||||
|
|
|
|||
|
|
@ -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]|
|
||||
|
|
|
|||
|
|
@ -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 = '@<span class="vcard"><a href="' . $author_contact['url'] . '" class="url u-url mention" title="' . $author_contact['addr'] . '"><span class="fn nickname mention">' . $author_contact['addr'] . '</span></a>:</span>';
|
||||
$text = '<div><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . '</a> ' . $author . '<blockquote>' . $content . '</blockquote></div>' . "\n";
|
||||
$text = '<div><a href="' . $attributes['link'] . '">' . html_entity_decode('♲', ENT_QUOTES, 'UTF-8') . '</a> ' . $author . '<blockquote>' . $content . '</blockquote></div>' . "\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",
|
||||
'<details class="spoiler"><summary>$1</summary>$2</details>',
|
||||
|
|
@ -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",
|
||||
"<p><strong class=" . '"author"' . ">" . $t_wrote . "</strong></p><blockquote>$2</blockquote>",
|
||||
|
|
@ -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 '<img src="' . $matches[1] . '" alt="' . $alt . '" title="' . $alt . '" class="' . (empty($alt) ? 'empty-description' : 'has-alt-description') . '">';
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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")) {
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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 . '<br />';
|
||||
}
|
||||
|
|
@ -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']
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
]);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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']]);
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$item['object'] .= '</object>' . "\n";
|
||||
|
||||
|
|
@ -375,13 +374,13 @@ class Event
|
|||
return $item;
|
||||
}
|
||||
|
||||
$item['post-type'] = Item::PT_EVENT;
|
||||
$item['title'] = '';
|
||||
$item['object-type'] = Activity\ObjectType::EVENT;
|
||||
$item['body'] = self::getBBCode($event);
|
||||
$item['event-id'] = $event_id;
|
||||
$item['post-type'] = Item::PT_EVENT;
|
||||
$item['title'] = '';
|
||||
$item['object-type'] = Activity\ObjectType::EVENT;
|
||||
$item['body'] = self::getBBCode($event);
|
||||
$item['event-id'] = $event_id;
|
||||
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] = '<object><type>' . XML::escape(Activity\ObjectType::EVENT) . '</type><title></title><id>' . XML::escape($event['uri']) . '</id>';
|
||||
$item['object'] .= '<content>' . XML::escape(self::getBBCode($event)) . '</content>';
|
||||
$item['object'] .= '</object>' . "\n";
|
||||
|
||||
|
|
@ -398,7 +397,7 @@ class Event
|
|||
{
|
||||
// First day of the week (0 = Sunday).
|
||||
$firstDay = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'first_day_of_week') ?? 0;
|
||||
$defaultView = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'defaultView') ?? 'month';
|
||||
$defaultView = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'calendar', 'defaultView') ?? 'month';
|
||||
|
||||
return [
|
||||
'firstDay' => $firstDay,
|
||||
|
|
@ -649,12 +648,12 @@ class Event
|
|||
if (DI::userSession()->getLocalUserId() && DI::userSession()->getLocalUserId() == $event['uid'] && $event['type'] == 'event') {
|
||||
$edit = !$event['cid'] ? ['calendar/event/edit/' . $event['id'], DI::l10n()->t('Edit event'), '', ''] : null;
|
||||
$copy = !$event['cid'] ? ['calendar/event/copy/' . $event['id'], DI::l10n()->t('Duplicate event'), '', ''] : null;
|
||||
$drop = ['calendar/api/delete/' . $event['id'], DI::l10n()->t('Delete event'), '', ''];
|
||||
$drop = ['calendar/api/delete/' . $event['id'], DI::l10n()->t('Delete event'), '', ''];
|
||||
}
|
||||
|
||||
$title = strip_tags(BBCode::convertForUriId($event['uri-id'], $event['summary']));
|
||||
if (!$title) {
|
||||
[$title, $_trash] = explode("<br", BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['desc'])), BBCode::TWITTER_API);
|
||||
list($title, $_trash) = explode("<br", BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['desc'])), BBCode::TWITTER_API);
|
||||
}
|
||||
|
||||
$event['author-link'] = Contact::magicLink($event['author-link']);
|
||||
|
|
@ -694,7 +693,7 @@ class Event
|
|||
}
|
||||
|
||||
switch ($format) {
|
||||
// Format the exported data as a CSV file.
|
||||
// Format the exported data as a CSV file.
|
||||
case "csv":
|
||||
$o .= '"Subject", "Start Date", "Start Time", "Description", "End Date", "End Time", "Location"' . PHP_EOL;
|
||||
|
||||
|
|
@ -744,21 +743,21 @@ class Event
|
|||
$tmp = $event['summary'];
|
||||
$tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
|
||||
$tmp = addcslashes($tmp, ',;');
|
||||
$o .= 'SUMMARY:' . $tmp . PHP_EOL;
|
||||
$o .= 'SUMMARY:' . $tmp . PHP_EOL;
|
||||
}
|
||||
|
||||
if ($event['desc']) {
|
||||
$tmp = $event['desc'];
|
||||
$tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
|
||||
$tmp = addcslashes($tmp, ',;');
|
||||
$o .= 'DESCRIPTION:' . $tmp . PHP_EOL;
|
||||
$o .= 'DESCRIPTION:' . $tmp . PHP_EOL;
|
||||
}
|
||||
|
||||
if ($event['location']) {
|
||||
$tmp = $event['location'];
|
||||
$tmp = str_replace(PHP_EOL, PHP_EOL . ' ', $tmp);
|
||||
$tmp = addcslashes($tmp, ',;');
|
||||
$o .= 'LOCATION:' . $tmp . PHP_EOL;
|
||||
$o .= 'LOCATION:' . $tmp . PHP_EOL;
|
||||
}
|
||||
|
||||
$o .= 'END:VEVENT' . PHP_EOL;
|
||||
|
|
@ -912,7 +911,7 @@ class Event
|
|||
}
|
||||
|
||||
// Construct the profile link (magic-auth).
|
||||
$author = [
|
||||
$author = [
|
||||
'uid' => 0,
|
||||
'id' => $item['author-id'],
|
||||
'network' => $item['author-network'],
|
||||
|
|
|
|||
|
|
@ -39,44 +39,44 @@ use Psr\Http\Message\UriInterface;
|
|||
class GServer
|
||||
{
|
||||
// Directory types
|
||||
const DT_NONE = 0;
|
||||
const DT_POCO = 1;
|
||||
const DT_NONE = 0;
|
||||
const DT_POCO = 1;
|
||||
const DT_MASTODON = 2;
|
||||
|
||||
// Methods to detect server types
|
||||
|
||||
// Non endpoint specific methods
|
||||
const DETECT_MANUAL = 0;
|
||||
const DETECT_HEADER = 1;
|
||||
const DETECT_BODY = 2;
|
||||
const DETECT_HOST_META = 3;
|
||||
const DETECT_CONTACTS = 4;
|
||||
const DETECT_AP_ACTOR = 5;
|
||||
const DETECT_MANUAL = 0;
|
||||
const DETECT_HEADER = 1;
|
||||
const DETECT_BODY = 2;
|
||||
const DETECT_HOST_META = 3;
|
||||
const DETECT_CONTACTS = 4;
|
||||
const DETECT_AP_ACTOR = 5;
|
||||
const DETECT_AP_COLLECTION = 6;
|
||||
|
||||
const DETECT_UNSPECIFIC = [self::DETECT_MANUAL, self::DETECT_HEADER, self::DETECT_BODY, self::DETECT_HOST_META, self::DETECT_CONTACTS, self::DETECT_AP_ACTOR];
|
||||
|
||||
// Implementation specific endpoints
|
||||
// @todo Possibly add Lemmy detection via the endpoint /api/v3/site
|
||||
const DETECT_FRIENDIKA = 10;
|
||||
const DETECT_FRIENDICA = 11;
|
||||
const DETECT_STATUSNET = 12;
|
||||
const DETECT_GNUSOCIAL = 13;
|
||||
const DETECT_CONFIG_JSON = 14; // Statusnet, GNU Social, Older Hubzilla/Redmatrix
|
||||
const DETECT_FRIENDIKA = 10;
|
||||
const DETECT_FRIENDICA = 11;
|
||||
const DETECT_STATUSNET = 12;
|
||||
const DETECT_GNUSOCIAL = 13;
|
||||
const DETECT_CONFIG_JSON = 14; // Statusnet, GNU Social, Older Hubzilla/Redmatrix
|
||||
const DETECT_SITEINFO_JSON = 15; // Newer Hubzilla
|
||||
const DETECT_MASTODON_API = 16;
|
||||
const DETECT_STATUS_PHP = 17; // Nextcloud
|
||||
const DETECT_V1_CONFIG = 18;
|
||||
const DETECT_SYSTEM_ACTOR = 20; // Mistpark, Osada, Roadhouse, Zap
|
||||
const DETECT_THREADS = 21;
|
||||
const DETECT_MASTODON_API = 16;
|
||||
const DETECT_STATUS_PHP = 17; // Nextcloud
|
||||
const DETECT_V1_CONFIG = 18;
|
||||
const DETECT_SYSTEM_ACTOR = 20; // Mistpark, Osada, Roadhouse, Zap
|
||||
const DETECT_THREADS = 21;
|
||||
|
||||
// Standardized endpoints
|
||||
const DETECT_STATISTICS_JSON = 100;
|
||||
const DETECT_NODEINFO_10 = 101; // Nodeinfo Version 1.0
|
||||
const DETECT_NODEINFO_20 = 102; // Nodeinfo Version 2.0
|
||||
const DETECT_NODEINFO2_10 = 103; // Nodeinfo2 Version 1.0
|
||||
const DETECT_NODEINFO_21 = 104; // Nodeinfo Version 2.1
|
||||
const DETECT_NODEINFO_22 = 105; // Nodeinfo Version 2.2
|
||||
const DETECT_NODEINFO_10 = 101; // Nodeinfo Version 1.0
|
||||
const DETECT_NODEINFO_20 = 102; // Nodeinfo Version 2.0
|
||||
const DETECT_NODEINFO2_10 = 103; // Nodeinfo2 Version 1.0
|
||||
const DETECT_NODEINFO_21 = 104; // Nodeinfo Version 2.1
|
||||
const DETECT_NODEINFO_22 = 105; // Nodeinfo Version 2.2
|
||||
|
||||
/**
|
||||
* Check for the existence of a server and adds it in the background if not existant
|
||||
|
|
@ -343,7 +343,7 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
if ($gserver['created'] <= DBA::NULL_DATETIME) {
|
||||
$fields = ['created' => DateTimeFormat::utcNow()];
|
||||
$fields = ['created' => DateTimeFormat::utcNow()];
|
||||
$condition = ['nurl' => Strings::normaliseLink($server_url)];
|
||||
self::update($fields, $condition);
|
||||
}
|
||||
|
|
@ -450,9 +450,11 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', [], ['nurl' => $nurl]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
$next_update = self::getNextUpdateDate(false, $gserver['created'], $gserver['last_contact']);
|
||||
self::update(['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
||||
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
||||
['nurl' => $nurl]);
|
||||
self::update(
|
||||
['url' => $url, 'failed' => true, 'blocked' => Network::isUrlBlocked($url), 'last_failure' => DateTimeFormat::utcNow(),
|
||||
'next_contact' => $next_update, 'network' => Protocol::PHANTOM, 'detection-method' => null],
|
||||
['nurl' => $nurl]
|
||||
);
|
||||
DI::logger()->info('Set failed status for existing server', ['url' => $url]);
|
||||
if (self::isDefunct($gserver)) {
|
||||
self::archiveContacts($gserver['id']);
|
||||
|
|
@ -461,8 +463,8 @@ class GServer
|
|||
}
|
||||
|
||||
self::insert(['url' => $url, 'nurl' => $nurl,
|
||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||
'network' => Protocol::PHANTOM, 'created' => DateTimeFormat::utcNow(),
|
||||
'failed' => true, 'last_failure' => DateTimeFormat::utcNow()]);
|
||||
DI::logger()->info('Set failed status for new server', ['url' => $url]);
|
||||
}
|
||||
|
||||
|
|
@ -592,7 +594,7 @@ class GServer
|
|||
if ((parse_url($url, PHP_URL_HOST) == parse_url($valid_url, PHP_URL_HOST)) &&
|
||||
(parse_url($url, PHP_URL_PATH) == parse_url($valid_url, PHP_URL_PATH)) &&
|
||||
(parse_url($url, PHP_URL_SCHEME) != parse_url($valid_url, PHP_URL_SCHEME))) {
|
||||
$url = $valid_url;
|
||||
$url = $valid_url;
|
||||
}
|
||||
|
||||
$in_webroot = empty(parse_url($url, PHP_URL_PATH));
|
||||
|
|
@ -627,10 +629,10 @@ class GServer
|
|||
if ($serverdata['network'] == Protocol::PHANTOM) {
|
||||
if ($in_webroot) {
|
||||
// Fetch the landing page, possibly it reveals some data
|
||||
$accept = 'application/activity+json,application/ld+json,application/json,*/*;q=0.9';
|
||||
$accept = 'application/activity+json,application/ld+json,application/json,*/*;q=0.9';
|
||||
$curlResult = DI::httpClient()->get($url, $accept, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess() && $curlResult->getReturnCode() == '406') {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$html_fetched = true;
|
||||
} else {
|
||||
$html_fetched = false;
|
||||
|
|
@ -639,8 +641,8 @@ class GServer
|
|||
if ($curlResult->isSuccess()) {
|
||||
$json = json_decode($curlResult->getBodyString(), true);
|
||||
if (!empty($json) && is_array($json)) {
|
||||
$data = self::fetchDataFromSystemActor($json, $serverdata);
|
||||
$serverdata = $data['server'];
|
||||
$data = self::fetchDataFromSystemActor($json, $serverdata);
|
||||
$serverdata = $data['server'];
|
||||
$systemactor = $data['actor'];
|
||||
if (!$html_fetched && !in_array($serverdata['detection-method'], [self::DETECT_SYSTEM_ACTOR, self::DETECT_AP_COLLECTION])) {
|
||||
$curlResult = DI::httpClient()->get($url, HttpClientAccept::HTML, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
|
|
@ -739,7 +741,7 @@ class GServer
|
|||
return false;
|
||||
}
|
||||
|
||||
$serverdata['url'] = $url;
|
||||
$serverdata['url'] = $url;
|
||||
$serverdata['nurl'] = Strings::normaliseLink($url);
|
||||
|
||||
// We have to prevent an endless loop here.
|
||||
|
|
@ -803,10 +805,10 @@ class GServer
|
|||
$gserver = DBA::selectFirst('gserver', ['network'], ['nurl' => Strings::normaliseLink($url)]);
|
||||
if (!DBA::isResult($gserver)) {
|
||||
$serverdata['created'] = DateTimeFormat::utcNow();
|
||||
$ret = self::insert($serverdata);
|
||||
$id = DBA::lastInsertId();
|
||||
$ret = self::insert($serverdata);
|
||||
$id = DBA::lastInsertId();
|
||||
} else {
|
||||
$ret = self::update($serverdata, ['nurl' => $serverdata['nurl']]);
|
||||
$ret = self::update($serverdata, ['nurl' => $serverdata['nurl']]);
|
||||
$gserver = DBA::selectFirst('gserver', ['id'], ['nurl' => $serverdata['nurl']]);
|
||||
if (DBA::isResult($gserver)) {
|
||||
$id = $gserver['id'];
|
||||
|
|
@ -816,8 +818,8 @@ class GServer
|
|||
// Count the number of known contacts from this server
|
||||
if (!empty($id) && !in_array($serverdata['network'], [Protocol::PHANTOM, Protocol::FEED])) {
|
||||
$apcontacts = DBA::count('apcontact', ['gsid' => $id]);
|
||||
$contacts = DBA::count('contact', ['uid' => 0, 'gsid' => $id, 'failed' => false]);
|
||||
$max_users = max($apcontacts, $contacts);
|
||||
$contacts = DBA::count('contact', ['uid' => 0, 'gsid' => $id, 'failed' => false]);
|
||||
$max_users = max($apcontacts, $contacts);
|
||||
if ($max_users > $serverdata['registered-users']) {
|
||||
DI::logger()->info('Update registered users', ['id' => $id, 'url' => $serverdata['nurl'], 'registered-users' => $max_users]);
|
||||
self::update(['registered-users' => $max_users], ['id' => $id]);
|
||||
|
|
@ -846,7 +848,7 @@ class GServer
|
|||
|
||||
if (!empty($systemactor)) {
|
||||
$contact = Contact::getByURL($systemactor, true, ['gsid', 'baseurl', 'id', 'network', 'url', 'name']);
|
||||
DI::logger()->debug('Fetched system actor', ['url' => $url, 'gsid' => $id, 'contact' => $contact]);
|
||||
DI::logger()->debug('Fetched system actor', ['url' => $url, 'gsid' => $id, 'contact' => $contact]);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
|
|
@ -879,9 +881,9 @@ class GServer
|
|||
$data['subscribe'] = (bool)($data['subscribe'] ?? false);
|
||||
|
||||
if (!$data['subscribe'] || empty($data['scope']) || !in_array(strtolower($data['scope']), ['all', 'tags'])) {
|
||||
$data['scope'] = '';
|
||||
$data['scope'] = '';
|
||||
$data['subscribe'] = false;
|
||||
$data['tags'] = [];
|
||||
$data['tags'] = [];
|
||||
}
|
||||
|
||||
$gserver = DBA::selectFirst('gserver', ['id', 'url', 'network', 'relay-subscribe', 'relay-scope'], ['nurl' => Strings::normaliseLink($server_url)]);
|
||||
|
|
@ -975,13 +977,13 @@ class GServer
|
|||
return $serverdata;
|
||||
}
|
||||
|
||||
$valid = false;
|
||||
$valid = false;
|
||||
$old_serverdata = $serverdata;
|
||||
|
||||
$serverdata['detection-method'] = self::DETECT_STATISTICS_JSON;
|
||||
|
||||
if (!empty($data['version'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['version'] = $data['version'];
|
||||
// Version numbers on statistics.json are presented with additional info, e.g.:
|
||||
// 0.6.3.0-p1702cc1c, 0.6.99.0-p1b9ab160 or 3.4.3-2-1191.
|
||||
|
|
@ -989,12 +991,12 @@ class GServer
|
|||
}
|
||||
|
||||
if (!empty($data['name'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['site_name'] = $data['name'];
|
||||
}
|
||||
|
||||
if (!empty($data['network'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['platform'] = strtolower($data['network']);
|
||||
|
||||
if ($serverdata['platform'] == 'diaspora') {
|
||||
|
|
@ -1009,22 +1011,22 @@ class GServer
|
|||
}
|
||||
|
||||
if (!empty($data['total_users'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['registered-users'] = max($data['total_users'], 1);
|
||||
}
|
||||
|
||||
if (!empty($data['active_users_monthly'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['active-month-users'] = max($data['active_users_monthly'], 0);
|
||||
}
|
||||
|
||||
if (!empty($data['active_users_halfyear'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['active-halfyear-users'] = max($data['active_users_halfyear'], 0);
|
||||
}
|
||||
|
||||
if (!empty($data['local_posts'])) {
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
$serverdata['local-posts'] = max($data['local_posts'], 0);
|
||||
}
|
||||
|
||||
|
|
@ -1065,8 +1067,8 @@ class GServer
|
|||
return [];
|
||||
}
|
||||
|
||||
$nodeinfo1_url = '';
|
||||
$nodeinfo2_url = '';
|
||||
$nodeinfo1_url = '';
|
||||
$nodeinfo2_url = '';
|
||||
$detection_method = self::DETECT_MANUAL;
|
||||
|
||||
foreach ($nodeinfo['links'] as $link) {
|
||||
|
|
@ -1078,13 +1080,13 @@ class GServer
|
|||
if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
|
||||
$nodeinfo1_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
} elseif (($detection_method < self::DETECT_NODEINFO_20) && ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0')) {
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$detection_method = self::DETECT_NODEINFO_20;
|
||||
} elseif (($detection_method < self::DETECT_NODEINFO_21) && ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.1')) {
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$detection_method = self::DETECT_NODEINFO_21;
|
||||
} elseif (($detection_method < self::DETECT_NODEINFO_22) && ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.2')) {
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$nodeinfo2_url = Network::addBasePath($link['href'], $httpResult->getUrl());
|
||||
$detection_method = self::DETECT_NODEINFO_22;
|
||||
}
|
||||
}
|
||||
|
|
@ -1132,7 +1134,7 @@ class GServer
|
|||
|
||||
$server = [
|
||||
'detection-method' => self::DETECT_NODEINFO_10,
|
||||
'register_policy' => Register::CLOSED
|
||||
'register_policy' => Register::CLOSED
|
||||
];
|
||||
|
||||
if (!empty($nodeinfo['openRegistrations'])) {
|
||||
|
|
@ -1232,8 +1234,8 @@ class GServer
|
|||
|
||||
$server = [
|
||||
'detection-method' => $detection_method,
|
||||
'register_policy' => Register::CLOSED,
|
||||
'platform' => 'unknown',
|
||||
'register_policy' => Register::CLOSED,
|
||||
'platform' => 'unknown',
|
||||
];
|
||||
|
||||
if (!empty($nodeinfo['openRegistrations'])) {
|
||||
|
|
@ -1363,7 +1365,7 @@ class GServer
|
|||
|
||||
$server = [
|
||||
'detection-method' => self::DETECT_NODEINFO2_10,
|
||||
'register_policy' => Register::CLOSED
|
||||
'register_policy' => Register::CLOSED
|
||||
];
|
||||
|
||||
if (!empty($nodeinfo['openRegistrations'])) {
|
||||
|
|
@ -1471,7 +1473,7 @@ class GServer
|
|||
|
||||
if (!empty($data['platform'])) {
|
||||
$serverdata['platform'] = strtolower($data['platform']);
|
||||
$serverdata['version'] = $data['version'] ?? 'N/A';
|
||||
$serverdata['version'] = $data['version'] ?? 'N/A';
|
||||
}
|
||||
|
||||
if (!empty($data['plugins'])) {
|
||||
|
|
@ -1547,17 +1549,17 @@ class GServer
|
|||
|
||||
$actor = JsonLD::compact($data, false);
|
||||
if (in_array(JsonLD::fetchElement($actor, '@type'), ActivityPub\Receiver::ACCOUNT_TYPES)) {
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['site_name'] = JsonLD::fetchElement($actor, 'as:name', '@value');
|
||||
$serverdata['info'] = JsonLD::fetchElement($actor, 'as:summary', '@value');
|
||||
$serverdata['info'] = JsonLD::fetchElement($actor, 'as:summary', '@value');
|
||||
if (self::isNomad($actor)) {
|
||||
$serverdata['platform'] = self::getNomadName($actor['@id']);
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$serverdata['platform'] = self::getNomadName($actor['@id']);
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
||||
} elseif (!empty($actor['as:generator'])) {
|
||||
$generator = explode(' ', JsonLD::fetchElement($actor['as:generator'], 'as:name', '@value'));
|
||||
$serverdata['platform'] = strtolower(array_shift($generator));
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$generator = explode(' ', JsonLD::fetchElement($actor['as:generator'], 'as:name', '@value'));
|
||||
$serverdata['platform'] = strtolower(array_shift($generator));
|
||||
$serverdata['version'] = self::getNomadVersion($actor['@id']);
|
||||
$serverdata['detection-method'] = self::DETECT_SYSTEM_ACTOR;
|
||||
} else {
|
||||
$serverdata['detection-method'] = self::DETECT_AP_ACTOR;
|
||||
|
|
@ -1565,8 +1567,8 @@ class GServer
|
|||
return ['server' => $serverdata, 'actor' => $actor['@id']];
|
||||
} elseif ((JsonLD::fetchElement($actor, '@type') == 'as:Collection')) {
|
||||
// By now only Ktistec seems to provide collections this way
|
||||
$serverdata['platform'] = 'ktistec';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['platform'] = 'ktistec';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['detection-method'] = self::DETECT_AP_COLLECTION;
|
||||
|
||||
$actors = JsonLD::fetchElementArray($actor, 'as:items');
|
||||
|
|
@ -1610,7 +1612,7 @@ class GServer
|
|||
*/
|
||||
private static function getNomadName(string $url): string
|
||||
{
|
||||
$name = 'nomad';
|
||||
$name = 'nomad';
|
||||
$curlResult = DI::httpClient()->get($url . '/manifest', 'application/manifest+json', [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess() || ($curlResult->getBodyString() == '')) {
|
||||
if ($curlResult->getReturnCode() == 418) {
|
||||
|
|
@ -1729,7 +1731,7 @@ class GServer
|
|||
private static function validHostMeta(string $url): bool
|
||||
{
|
||||
$xrd_timeout = DI::config()->get('system', 'xrd_timeout');
|
||||
$curlResult = DI::httpClient()->get($url . Probe::HOST_META, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$curlResult = DI::httpClient()->get($url . Probe::HOST_META, HttpClientAccept::XRD_XML, [HttpClientOptions::TIMEOUT => $xrd_timeout, HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1828,10 +1830,10 @@ class GServer
|
|||
}
|
||||
|
||||
if (!empty($data['totalResults'])) {
|
||||
$registeredUsers = $serverdata['registered-users'] ?? 0;
|
||||
$registeredUsers = $serverdata['registered-users'] ?? 0;
|
||||
$serverdata['registered-users'] = max($data['totalResults'], $registeredUsers, 1);
|
||||
$serverdata['directory-type'] = self::DT_POCO;
|
||||
$serverdata['poco'] = $url . '/poco';
|
||||
$serverdata['directory-type'] = self::DT_POCO;
|
||||
$serverdata['poco'] = $url . '/poco';
|
||||
}
|
||||
|
||||
return $serverdata;
|
||||
|
|
@ -1886,8 +1888,8 @@ class GServer
|
|||
|
||||
if (!empty($data['instance']) && !empty($data['serverVersion'])) {
|
||||
$serverdata['platform'] = 'peertube';
|
||||
$serverdata['version'] = $data['serverVersion'];
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['version'] = $data['serverVersion'];
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
||||
if (!empty($data['instance']['name'])) {
|
||||
$serverdata['site_name'] = $data['instance']['name'];
|
||||
|
|
@ -1934,7 +1936,7 @@ class GServer
|
|||
|
||||
if (!empty($data['version'])) {
|
||||
$serverdata['platform'] = 'nextcloud';
|
||||
$serverdata['version'] = $data['version'];
|
||||
$serverdata['version'] = $data['version'];
|
||||
|
||||
if ($validHostMeta) {
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
|
|
@ -2012,9 +2014,9 @@ class GServer
|
|||
|
||||
if (!empty($data['version'])) {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['version'] = $data['version'] ?? '';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$valid = true;
|
||||
$serverdata['version'] = $data['version'] ?? '';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($data['title'])) {
|
||||
|
|
@ -2023,8 +2025,8 @@ class GServer
|
|||
|
||||
if (!empty($data['title']) && empty($serverdata['platform']) && ($serverdata['network'] == Protocol::PHANTOM)) {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$valid = true;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($data['description'])) {
|
||||
|
|
@ -2037,20 +2039,20 @@ class GServer
|
|||
|
||||
if (!empty($serverdata['version']) && preg_match('/.*?\(compatible;\s(.*)\s(.*)\)/ism', $serverdata['version'], $matches)) {
|
||||
$serverdata['platform'] = strtolower($matches[1]);
|
||||
$serverdata['version'] = $matches[2];
|
||||
$valid = true;
|
||||
$serverdata['version'] = $matches[2];
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($serverdata['version']) && strstr(strtolower($serverdata['version']), 'pleroma')) {
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$valid = true;
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if (!empty($serverdata['platform']) && strstr($serverdata['platform'], 'pleroma')) {
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['platform']));
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
$valid = true;
|
||||
$valid = true;
|
||||
}
|
||||
|
||||
if ($valid && in_array($serverdata['detection-method'], self::DETECT_UNSPECIFIC)) {
|
||||
|
|
@ -2086,14 +2088,14 @@ class GServer
|
|||
|
||||
if (!empty($data['site']['platform'])) {
|
||||
$serverdata['platform'] = strtolower($data['site']['platform']['PLATFORM_NAME']);
|
||||
$serverdata['version'] = $data['site']['platform']['STD_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
$serverdata['version'] = $data['site']['platform']['STD_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
}
|
||||
|
||||
if (!empty($data['site']['hubzilla'])) {
|
||||
$serverdata['platform'] = strtolower($data['site']['hubzilla']['PLATFORM_NAME']);
|
||||
$serverdata['version'] = $data['site']['hubzilla']['RED_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
$serverdata['version'] = $data['site']['hubzilla']['RED_VERSION'];
|
||||
$serverdata['network'] = Protocol::ZOT;
|
||||
}
|
||||
|
||||
if (!empty($data['site']['redmatrix'])) {
|
||||
|
|
@ -2107,9 +2109,9 @@ class GServer
|
|||
$serverdata['network'] = Protocol::ZOT;
|
||||
}
|
||||
|
||||
$private = false;
|
||||
$private = false;
|
||||
$inviteonly = false;
|
||||
$closed = false;
|
||||
$closed = false;
|
||||
|
||||
if (!empty($data['site']['closed'])) {
|
||||
$closed = self::toBoolean($data['site']['closed']);
|
||||
|
|
@ -2196,11 +2198,11 @@ class GServer
|
|||
|
||||
if (!empty($serverdata['version']) && strtolower(substr($serverdata['version'], 0, 7)) == 'pleroma') {
|
||||
$serverdata['platform'] = 'pleroma';
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['version'] = trim(str_ireplace('pleroma', '', $serverdata['version']));
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
} else {
|
||||
$serverdata['platform'] = 'statusnet';
|
||||
$serverdata['network'] = Protocol::OSTATUS;
|
||||
$serverdata['network'] = Protocol::OSTATUS;
|
||||
}
|
||||
|
||||
if (in_array($serverdata['detection-method'], self::DETECT_UNSPECIFIC)) {
|
||||
|
|
@ -2226,11 +2228,11 @@ class GServer
|
|||
$curlResult = DI::httpClient()->get($url . '/friendica/json', HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
if (!$curlResult->isSuccess()) {
|
||||
$curlResult = DI::httpClient()->get($url . '/friendika/json', HttpClientAccept::DEFAULT, [HttpClientOptions::REQUEST => HttpClientRequest::SERVERINFO]);
|
||||
$friendika = true;
|
||||
$platform = 'Friendika';
|
||||
$friendika = true;
|
||||
$platform = 'Friendika';
|
||||
} else {
|
||||
$friendika = false;
|
||||
$platform = 'Friendica';
|
||||
$platform = 'Friendica';
|
||||
}
|
||||
|
||||
if (!$curlResult->isSuccess()) {
|
||||
|
|
@ -2316,14 +2318,14 @@ class GServer
|
|||
|
||||
$doc = new DOMDocument();
|
||||
@$doc->loadHTML($curlResult->getBodyString());
|
||||
$xpath = new DOMXPath($doc);
|
||||
$xpath = new DOMXPath($doc);
|
||||
$assigned = false;
|
||||
|
||||
// We can only detect honk via some HTML element on their page
|
||||
if ($xpath->query('//div[@id="honksonpage"]')->count() == 1) {
|
||||
$serverdata['platform'] = 'honk';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$assigned = true;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$assigned = true;
|
||||
}
|
||||
|
||||
$title = trim(XML::getFirstNodeValue($xpath, '//head/title/text()'));
|
||||
|
|
@ -2356,11 +2358,11 @@ class GServer
|
|||
|
||||
if (in_array($attr['name'], ['application-name', 'al:android:app_name', 'al:ios:app_name',
|
||||
'twitter:app:name:googleplay', 'twitter:app:name:iphone', 'twitter:app:name:ipad', 'generator'])) {
|
||||
$platform = str_ireplace(array_keys($platforms), array_values($platforms), $attr['content']);
|
||||
$platform = str_replace('/', ' ', $platform);
|
||||
$platform = str_ireplace(array_keys($platforms), array_values($platforms), $attr['content']);
|
||||
$platform = str_replace('/', ' ', $platform);
|
||||
$platform_parts = explode(' ', $platform);
|
||||
if ((count($platform_parts) >= 2) && in_array(strtolower($platform_parts[0]), array_values($platforms))) {
|
||||
$platform = $platform_parts[0];
|
||||
$platform = $platform_parts[0];
|
||||
$serverdata['version'] = $platform_parts[1];
|
||||
}
|
||||
if (in_array($platform, array_values($grouped_platforms['dfrn_platforms']))) {
|
||||
|
|
@ -2372,7 +2374,7 @@ class GServer
|
|||
}
|
||||
if (in_array($platform, array_values($platforms))) {
|
||||
$serverdata['platform'] = $platform;
|
||||
$assigned = true;
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2407,7 +2409,7 @@ class GServer
|
|||
if (in_array($attr['property'], ['og:platform', 'generator'])) {
|
||||
if (in_array($attr['content'], array_keys($platforms))) {
|
||||
$serverdata['platform'] = $platforms[$attr['content']];
|
||||
$assigned = true;
|
||||
$assigned = true;
|
||||
}
|
||||
|
||||
if (in_array($attr['content'], array_keys($grouped_platforms['ap_platforms']))) {
|
||||
|
|
@ -2422,10 +2424,10 @@ class GServer
|
|||
foreach ($list as $node) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
if (parse_url(trim($attribute->value), PHP_URL_HOST) == 'micro.blog') {
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['platform'] = 'microblog';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$assigned = true;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2435,10 +2437,10 @@ class GServer
|
|||
foreach ($list as $node) {
|
||||
foreach ($node->attributes as $attribute) {
|
||||
if (trim($attribute->value) == 'https://micro.blog/micropub') {
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['version'] = trim($serverdata['platform'] . ' ' . $serverdata['version']);
|
||||
$serverdata['platform'] = 'microblog';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$assigned = true;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$assigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2463,15 +2465,15 @@ class GServer
|
|||
{
|
||||
if ($curlResult->getHeader('server') == 'Mastodon') {
|
||||
$serverdata['platform'] = 'mastodon';
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
$serverdata['network'] = Protocol::ACTIVITYPUB;
|
||||
} elseif ($curlResult->inHeader('x-diaspora-version')) {
|
||||
$serverdata['platform'] = 'diaspora';
|
||||
$serverdata['network'] = Protocol::DIASPORA;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-diaspora-version')[0] ?? '';
|
||||
$serverdata['network'] = Protocol::DIASPORA;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-diaspora-version')[0] ?? '';
|
||||
} elseif ($curlResult->inHeader('x-friendica-version')) {
|
||||
$serverdata['platform'] = 'friendica';
|
||||
$serverdata['network'] = Protocol::DFRN;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-friendica-version')[0] ?? '';
|
||||
$serverdata['network'] = Protocol::DFRN;
|
||||
$serverdata['version'] = $curlResult->getHeader('x-friendica-version')[0] ?? '';
|
||||
} else {
|
||||
return $serverdata;
|
||||
}
|
||||
|
|
@ -2501,9 +2503,12 @@ class GServer
|
|||
|
||||
$last_update = date('c', time() - (60 * 60 * 24 * $requery_days));
|
||||
|
||||
$gservers = DBA::select('gserver', ['id', 'url', 'nurl', 'network', 'poco', 'directory-type'],
|
||||
$gservers = DBA::select(
|
||||
'gserver',
|
||||
['id', 'url', 'nurl', 'network', 'poco', 'directory-type'],
|
||||
["NOT `blocked` AND NOT `failed` AND `directory-type` != ? AND `last_poco_query` < ?", GServer::DT_NONE, $last_update],
|
||||
['order' => ['RAND()']]);
|
||||
['order' => ['RAND()']]
|
||||
);
|
||||
|
||||
while ($gserver = DBA::fetch($gservers)) {
|
||||
DI::logger()->info('Update peer list', ['server' => $gserver['url'], 'id' => $gserver['id']]);
|
||||
|
|
@ -2541,7 +2546,7 @@ class GServer
|
|||
// Discover federated servers
|
||||
$protocols = ['activitypub', 'diaspora', 'dfrn', 'ostatus'];
|
||||
foreach ($protocols as $protocol) {
|
||||
$query = '{nodes(protocol:"' . $protocol . '"){host}}';
|
||||
$query = '{nodes(protocol:"' . $protocol . '"){host}}';
|
||||
$curlResult = DI::httpClient()->fetch('https://the-federation.info/graphql?query=' . urlencode($query), HttpClientAccept::JSON, 0, '', HttpClientRequest::SERVERDISCOVER);
|
||||
if (!empty($curlResult)) {
|
||||
$data = json_decode($curlResult, true);
|
||||
|
|
@ -2558,7 +2563,7 @@ class GServer
|
|||
$accesstoken = DI::config()->get('system', 'instances_social_key');
|
||||
|
||||
if (!empty($accesstoken)) {
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
$api = 'https://instances.social/api/1.0/instances/list?count=0';
|
||||
$curlResult = DI::httpClient()->get($api, HttpClientAccept::JSON, [HttpClientOptions::HEADERS => ['Authorization' => ['Bearer ' . $accesstoken], HttpClientOptions::REQUEST => HttpClientRequest::SERVERDISCOVER]]);
|
||||
if ($curlResult->isSuccess()) {
|
||||
$servers = json_decode($curlResult->getBodyString(), true);
|
||||
|
|
|
|||
|
|
@ -45,38 +45,38 @@ use LanguageDetection\Language;
|
|||
class Item
|
||||
{
|
||||
// Posting types, inspired by https://www.w3.org/TR/activitystreams-vocabulary/#object-types
|
||||
const PT_ARTICLE = 0;
|
||||
const PT_NOTE = 1;
|
||||
const PT_PAGE = 2;
|
||||
const PT_IMAGE = 16;
|
||||
const PT_AUDIO = 17;
|
||||
const PT_VIDEO = 18;
|
||||
const PT_DOCUMENT = 19;
|
||||
const PT_EVENT = 32;
|
||||
const PT_POLL = 33;
|
||||
const PT_ARTICLE = 0;
|
||||
const PT_NOTE = 1;
|
||||
const PT_PAGE = 2;
|
||||
const PT_IMAGE = 16;
|
||||
const PT_AUDIO = 17;
|
||||
const PT_VIDEO = 18;
|
||||
const PT_DOCUMENT = 19;
|
||||
const PT_EVENT = 32;
|
||||
const PT_POLL = 33;
|
||||
const PT_PERSONAL_NOTE = 128;
|
||||
|
||||
// Posting reasons (Why had a post been stored for a user?)
|
||||
const PR_NONE = 0;
|
||||
const PR_TAG = 64;
|
||||
const PR_TO = 65;
|
||||
const PR_CC = 66;
|
||||
const PR_BTO = 67;
|
||||
const PR_BCC = 68;
|
||||
const PR_FOLLOWER = 69;
|
||||
const PR_NONE = 0;
|
||||
const PR_TAG = 64;
|
||||
const PR_TO = 65;
|
||||
const PR_CC = 66;
|
||||
const PR_BTO = 67;
|
||||
const PR_BCC = 68;
|
||||
const PR_FOLLOWER = 69;
|
||||
const PR_ANNOUNCEMENT = 70;
|
||||
const PR_COMMENT = 71;
|
||||
const PR_STORED = 72;
|
||||
const PR_GLOBAL = 73;
|
||||
const PR_RELAY = 74;
|
||||
const PR_FETCHED = 75;
|
||||
const PR_COMPLETION = 76;
|
||||
const PR_DIRECT = 77;
|
||||
const PR_ACTIVITY = 78;
|
||||
const PR_DISTRIBUTE = 79;
|
||||
const PR_PUSHED = 80;
|
||||
const PR_LOCAL = 81;
|
||||
const PR_AUDIENCE = 82;
|
||||
const PR_COMMENT = 71;
|
||||
const PR_STORED = 72;
|
||||
const PR_GLOBAL = 73;
|
||||
const PR_RELAY = 74;
|
||||
const PR_FETCHED = 75;
|
||||
const PR_COMPLETION = 76;
|
||||
const PR_DIRECT = 77;
|
||||
const PR_ACTIVITY = 78;
|
||||
const PR_DISTRIBUTE = 79;
|
||||
const PR_PUSHED = 80;
|
||||
const PR_LOCAL = 81;
|
||||
const PR_AUDIENCE = 82;
|
||||
|
||||
// system.accept_only_sharer setting values
|
||||
const COMPLETION_NONE = 1;
|
||||
|
|
@ -145,8 +145,8 @@ class Item
|
|||
];
|
||||
|
||||
// Privacy levels
|
||||
const PUBLIC = 0;
|
||||
const PRIVATE = 1;
|
||||
const PUBLIC = 0;
|
||||
const PRIVATE = 1;
|
||||
const UNLISTED = 2;
|
||||
|
||||
// Item weight for query ordering
|
||||
|
|
@ -492,7 +492,7 @@ class Item
|
|||
|
||||
// Is it in the format data@host.tld? - Used for mail contacts
|
||||
if (empty($prefix_host) && !empty($item['author-link']) && strstr($item['author-link'], '@')) {
|
||||
$mailparts = explode('@', $item['author-link']);
|
||||
$mailparts = explode('@', $item['author-link']);
|
||||
$prefix_host = array_pop($mailparts);
|
||||
}
|
||||
}
|
||||
|
|
@ -596,7 +596,7 @@ class Item
|
|||
}
|
||||
|
||||
$condition = [
|
||||
'uri-id' => $item['uri-id'], 'uid' => $item['uid'],
|
||||
'uri-id' => $item['uri-id'], 'uid' => $item['uid'],
|
||||
'network' => [$item['network'], Protocol::DFRN]
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
|
|
@ -681,7 +681,7 @@ class Item
|
|||
}
|
||||
|
||||
$condition = [
|
||||
'verb' => Activity::FOLLOW, 'uid' => $item['uid'],
|
||||
'verb' => Activity::FOLLOW, 'uid' => $item['uid'],
|
||||
'parent-uri' => $item['parent-uri'], 'author-id' => $item['author-id']
|
||||
];
|
||||
if (Post::exists($condition)) {
|
||||
|
|
@ -716,10 +716,10 @@ class Item
|
|||
// We only log the entries with a different user id than 0. Otherwise we would have too many false positives
|
||||
if ($item['uid'] != 0) {
|
||||
DI::logger()->notice('Item already existed for user', [
|
||||
'uri-id' => $item['uri-id'],
|
||||
'uid' => $item['uid'],
|
||||
'network' => $item['network'],
|
||||
'existing_id' => $existing['id'],
|
||||
'uri-id' => $item['uri-id'],
|
||||
'uid' => $item['uid'],
|
||||
'network' => $item['network'],
|
||||
'existing_id' => $existing['id'],
|
||||
'existing_network' => $existing['network']
|
||||
]);
|
||||
}
|
||||
|
|
@ -766,8 +766,8 @@ class Item
|
|||
'wall', 'private', 'origin', 'author-id'
|
||||
];
|
||||
$condition = ['uri-id' => [$item['thr-parent-id'], $item['parent-uri-id']], 'uid' => $item['uid']];
|
||||
$params = ['order' => ['id' => false]];
|
||||
$parent = Post::selectFirst($fields, $condition, $params);
|
||||
$params = ['order' => ['id' => false]];
|
||||
$parent = Post::selectFirst($fields, $condition, $params);
|
||||
|
||||
if (!DBA::isResult($parent) && Post::exists(['uri-id' => [$item['thr-parent-id'], $item['parent-uri-id']], 'uid' => 0])) {
|
||||
$stored = Item::storeForUserByUriId($item['thr-parent-id'], $item['uid'], ['post-reason' => Item::PR_COMPLETION]);
|
||||
|
|
@ -795,11 +795,11 @@ class Item
|
|||
}
|
||||
|
||||
$condition = [
|
||||
'uri-id' => $parent['parent-uri-id'],
|
||||
'uri-id' => $parent['parent-uri-id'],
|
||||
'parent-uri-id' => $parent['parent-uri-id'],
|
||||
'uid' => $parent['uid']
|
||||
'uid' => $parent['uid']
|
||||
];
|
||||
$params = ['order' => ['id' => false]];
|
||||
$params = ['order' => ['id' => false]];
|
||||
$toplevel_parent = Post::selectFirst($fields, $condition, $params);
|
||||
|
||||
if (!DBA::isResult($toplevel_parent) && $item['origin']) {
|
||||
|
|
@ -884,7 +884,7 @@ class Item
|
|||
$uid = intval($item['uid']);
|
||||
|
||||
$item['guid'] = self::guid($item, $notify);
|
||||
$item['uri'] = substr(trim($item['uri'] ?? '') ?: self::newURI($item['guid']), 0, 255);
|
||||
$item['uri'] = substr(trim($item['uri'] ?? '') ?: self::newURI($item['guid']), 0, 255);
|
||||
|
||||
// Store URI data
|
||||
$item['uri-id'] = ItemURI::insert(['uri' => $item['uri'], 'guid' => $item['guid']]);
|
||||
|
|
@ -990,13 +990,13 @@ class Item
|
|||
$item['gravity'] = self::getGravity($item);
|
||||
|
||||
$default = [
|
||||
'url' => $item['author-link'], 'name' => $item['author-name'],
|
||||
'url' => $item['author-link'], 'name' => $item['author-name'],
|
||||
'photo' => $item['author-avatar'], 'network' => $item['network']
|
||||
];
|
||||
$item['author-id'] = ($item['author-id'] ?? 0) ?: Contact::getIdForURL($item['author-link'], 0, null, $default);
|
||||
|
||||
$default = [
|
||||
'url' => $item['owner-link'], 'name' => $item['owner-name'],
|
||||
'url' => $item['owner-link'], 'name' => $item['owner-name'],
|
||||
'photo' => $item['owner-avatar'], 'network' => $item['network']
|
||||
];
|
||||
$item['owner-id'] = ($item['owner-id'] ?? 0) ?: Contact::getIdForURL($item['owner-link'], 0, null, $default);
|
||||
|
|
@ -1072,7 +1072,7 @@ class Item
|
|||
// Update the contact relations
|
||||
Contact\Relation::store($toplevel_parent['author-id'], $item['author-id'], $item['created']);
|
||||
} else {
|
||||
$parent_id = 0;
|
||||
$parent_id = 0;
|
||||
$parent_origin = $item['origin'];
|
||||
|
||||
if ($item['wall'] && empty($item['context'])) {
|
||||
|
|
@ -1120,7 +1120,7 @@ class Item
|
|||
}
|
||||
|
||||
if ($notify && $post_local) {
|
||||
$item['edit'] = false;
|
||||
$item['edit'] = false;
|
||||
$item['parent'] = $parent_id;
|
||||
|
||||
// Trigger automatic reactions for addons
|
||||
|
|
@ -1131,8 +1131,8 @@ class Item
|
|||
// We have to tell the hooks who we are - this really should be improved
|
||||
if (!DI::userSession()->getLocalUserId()) {
|
||||
$_SESSION['authenticated'] = true;
|
||||
$_SESSION['uid'] = $uid;
|
||||
$dummy_session = true;
|
||||
$_SESSION['uid'] = $uid;
|
||||
$dummy_session = true;
|
||||
} else {
|
||||
$dummy_session = false;
|
||||
}
|
||||
|
|
@ -1250,9 +1250,9 @@ class Item
|
|||
$ev['guid'] = $item['guid'];
|
||||
$ev['plink'] = $item['plink'];
|
||||
$ev['network'] = $item['network'];
|
||||
$ev['protocol'] = $item['protocol'] ?? Conversation::PARCEL_UNKNOWN;
|
||||
$ev['protocol'] = $item['protocol'] ?? Conversation::PARCEL_UNKNOWN;
|
||||
$ev['direction'] = $item['direction'] ?? Conversation::UNKNOWN;
|
||||
$ev['source'] = $item['source'] ?? '';
|
||||
$ev['source'] = $item['source'] ?? '';
|
||||
|
||||
$event = DBA::selectFirst('event', ['id'], ['uri' => $item['uri'], 'uid' => $item['uid']]);
|
||||
if (DBA::isResult($event)) {
|
||||
|
|
@ -1260,7 +1260,7 @@ class Item
|
|||
}
|
||||
|
||||
$event_id = Event::store($ev);
|
||||
$item = Event::getItemArrayForImportedId($event_id, $item);
|
||||
$item = Event::getItemArrayForImportedId($event_id, $item);
|
||||
|
||||
DI::logger()->info('Event was stored', ['id' => $event_id]);
|
||||
}
|
||||
|
|
@ -1542,7 +1542,7 @@ class Item
|
|||
$count = 0;
|
||||
foreach (DI::userDefinedChannel()->getMatchingChannelUsers($engagement['searchtext'], $language, $tags, $engagement['media-type'], $item['owner-id'], $reshare_id) as $uid) {
|
||||
$condition = [
|
||||
'verb' => Activity::ANNOUNCE, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'verb' => Activity::ANNOUNCE, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'author-id' => Contact::getPublicIdByUserId($uid), 'uid' => $uid, 'thr-parent-id' => $uri_id
|
||||
];
|
||||
if (!Post::exists($condition)) {
|
||||
|
|
@ -1632,7 +1632,7 @@ class Item
|
|||
}
|
||||
|
||||
$self_contact = Contact::selectFirst(['id'], ['uid' => $item['uid'], 'self' => true]);
|
||||
$self = !empty($self_contact) ? $self_contact['id'] : 0;
|
||||
$self = !empty($self_contact) ? $self_contact['id'] : 0;
|
||||
|
||||
$cid = Contact::getIdForURL($author['url'], $item['uid']);
|
||||
if (empty($cid) || (!Contact::isSharing($cid, $item['uid']) && ($cid != $self))) {
|
||||
|
|
@ -1671,7 +1671,7 @@ class Item
|
|||
|
||||
foreach (Tag::getUIDListByURIId($item['uri-id']) as $uid => $tags) {
|
||||
if (!empty($languages)) {
|
||||
$keep = false;
|
||||
$keep = false;
|
||||
$user_languages = User::getWantedLanguages($uid);
|
||||
foreach ($user_languages as $language) {
|
||||
if (in_array($language, $languages)) {
|
||||
|
|
@ -1705,7 +1705,7 @@ class Item
|
|||
public static function distribute(int $itemid, string $signed_text = '')
|
||||
{
|
||||
$condition = ["`id` IN (SELECT `parent` FROM `post-user-view` WHERE `id` = ?)", $itemid];
|
||||
$parent = Post::selectFirst(['owner-id'], $condition);
|
||||
$parent = Post::selectFirst(['owner-id'], $condition);
|
||||
if (!DBA::isResult($parent)) {
|
||||
DI::logger()->warning('Item not found', ['condition' => $condition]);
|
||||
return;
|
||||
|
|
@ -1713,7 +1713,7 @@ class Item
|
|||
|
||||
// Only distribute public items from native networks
|
||||
$condition = [
|
||||
'id' => $itemid, 'uid' => 0,
|
||||
'id' => $itemid, 'uid' => 0,
|
||||
'network' => array_merge(Protocol::FEDERATED, ['']),
|
||||
'visible' => true, 'deleted' => false, 'private' => [self::PUBLIC, self::UNLISTED]
|
||||
];
|
||||
|
|
@ -1734,7 +1734,7 @@ class Item
|
|||
}
|
||||
|
||||
$condition = ['nurl' => $owner['nurl'], 'rel' => [Contact::SHARING, Contact::FRIEND]];
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
if ($contact['uid'] == 0) {
|
||||
continue;
|
||||
|
|
@ -1745,7 +1745,7 @@ class Item
|
|||
DBA::close($contacts);
|
||||
|
||||
$condition = ['alias' => $owner['url'], 'rel' => [Contact::SHARING, Contact::FRIEND]];
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
if ($contact['uid'] == 0) {
|
||||
continue;
|
||||
|
|
@ -1757,7 +1757,7 @@ class Item
|
|||
|
||||
if (!empty($owner['alias'])) {
|
||||
$condition = ['nurl' => Strings::normaliseLink($owner['alias']), 'rel' => [Contact::SHARING, Contact::FRIEND]];
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
$contacts = DBA::select('contact', ['uid'], $condition);
|
||||
while ($contact = DBA::fetch($contacts)) {
|
||||
if ($contact['uid'] == 0) {
|
||||
continue;
|
||||
|
|
@ -1979,21 +1979,21 @@ class Item
|
|||
unset($item['postopts']);
|
||||
unset($item['inform']);
|
||||
|
||||
$item['uid'] = $uid;
|
||||
$item['uid'] = $uid;
|
||||
$item['origin'] = 0;
|
||||
$item['wall'] = 0;
|
||||
$item['wall'] = 0;
|
||||
|
||||
$notify = false;
|
||||
if ($item['gravity'] == self::GRAVITY_PARENT) {
|
||||
$contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'self' => false]);
|
||||
if (DBA::isResult($contact)) {
|
||||
$notify = self::isRemoteSelf($contact, $item);
|
||||
$notify = self::isRemoteSelf($contact, $item);
|
||||
$item['wall'] = (bool)$notify;
|
||||
}
|
||||
}
|
||||
|
||||
$item['contact-id'] = self::contactId($item);
|
||||
$distributed = self::insert($item, $notify);
|
||||
$distributed = self::insert($item, $notify);
|
||||
|
||||
if (!$distributed) {
|
||||
DI::logger()->info("Distributed item wasn't stored", ['uri-id' => $item['uri-id'], 'user' => $uid]);
|
||||
|
|
@ -2015,9 +2015,9 @@ class Item
|
|||
*/
|
||||
private static function addShadow(int $itemid)
|
||||
{
|
||||
$fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id'];
|
||||
$fields = ['uid', 'private', 'visible', 'deleted', 'network', 'uri-id'];
|
||||
$condition = ['id' => $itemid, 'gravity' => self::GRAVITY_PARENT];
|
||||
$item = Post::selectFirst($fields, $condition);
|
||||
$item = Post::selectFirst($fields, $condition);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
return;
|
||||
|
|
@ -2029,7 +2029,7 @@ class Item
|
|||
}
|
||||
|
||||
// Is it a visible public post?
|
||||
if (!$item["visible"] || $item["deleted"] || ($item["private"] == self::PRIVATE)) {
|
||||
if (!$item["visible"] || $item["deleted"] || ($item["private"] == self::PRIVATE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2146,7 +2146,7 @@ class Item
|
|||
}
|
||||
|
||||
$transmitted = [];
|
||||
foreach ($item['transmitted-languages'] ?? [] as $language) {
|
||||
foreach ($item['transmitted-languages'] ?? [] as $language) {
|
||||
$transmitted[$language] = 0;
|
||||
}
|
||||
|
||||
|
|
@ -2279,10 +2279,10 @@ class Item
|
|||
$previous_block = self::getBlockCode($previous);
|
||||
}
|
||||
|
||||
$block = (($next != '') && \IntlChar::isalpha($next)) ? self::getBlockCode($next) : $previous_block;
|
||||
$block = (($next != '') && \IntlChar::isalpha($next)) ? self::getBlockCode($next) : $previous_block;
|
||||
$blocks[$block] = ($blocks[$block] ?? '') . $character;
|
||||
} else {
|
||||
$block = self::getBlockCode($character);
|
||||
$block = self::getBlockCode($character);
|
||||
$blocks[$block] = ($blocks[$block] ?? '') . $character;
|
||||
}
|
||||
}
|
||||
|
|
@ -2329,7 +2329,7 @@ class Item
|
|||
|
||||
public static function getLanguageMessage(array $item): string
|
||||
{
|
||||
$iso639 = new \Matriphe\ISO639\ISO639;
|
||||
$iso639 = new \Matriphe\ISO639\ISO639();
|
||||
|
||||
$used_languages = '';
|
||||
foreach (json_decode($item['language'], true) as $language => $reliability) {
|
||||
|
|
@ -2532,7 +2532,7 @@ class Item
|
|||
}
|
||||
|
||||
$basetag = str_replace('_', ' ', substr($tag, 1));
|
||||
$newtag = '#[url=' . DI::baseUrl() . '/search?tag=' . urlencode($basetag) . ']' . $basetag . '[/url]';
|
||||
$newtag = '#[url=' . DI::baseUrl() . '/search?tag=' . urlencode($basetag) . ']' . $basetag . '[/url]';
|
||||
|
||||
$body = str_replace($tag, $newtag, $body);
|
||||
}
|
||||
|
|
@ -2694,8 +2694,8 @@ class Item
|
|||
|
||||
$datarray['contact-id'] = $self['id'];
|
||||
|
||||
$datarray['author-name'] = $datarray['owner-name'] = $self['name'];
|
||||
$datarray['author-link'] = $datarray['owner-link'] = $self['url'];
|
||||
$datarray['author-name'] = $datarray['owner-name'] = $self['name'];
|
||||
$datarray['author-link'] = $datarray['owner-link'] = $self['url'];
|
||||
$datarray['author-avatar'] = $datarray['owner-avatar'] = $self['thumb'];
|
||||
|
||||
unset($datarray['edited']);
|
||||
|
|
@ -2705,14 +2705,14 @@ class Item
|
|||
unset($datarray['author-id']);
|
||||
|
||||
if ($contact['network'] != Protocol::FEED) {
|
||||
$old_uri_id = $datarray['uri-id'] ?? 0;
|
||||
$old_uri_id = $datarray['uri-id'] ?? 0;
|
||||
$datarray['guid'] = System::createUUID();
|
||||
unset($datarray['plink']);
|
||||
$datarray['uri'] = self::newURI($datarray['guid']);
|
||||
$datarray['uri'] = self::newURI($datarray['guid']);
|
||||
$datarray['uri-id'] = ItemURI::getIdByURI($datarray['uri']);
|
||||
$datarray['extid'] = Protocol::DFRN;
|
||||
$urlpart = parse_url($datarray2['author-link']);
|
||||
$datarray['app'] = $urlpart['host'];
|
||||
$datarray['extid'] = Protocol::DFRN;
|
||||
$urlpart = parse_url($datarray2['author-link']);
|
||||
$datarray['app'] = $urlpart['host'];
|
||||
if (!empty($old_uri_id)) {
|
||||
Post\Media::copy($old_uri_id, $datarray['uri-id']);
|
||||
}
|
||||
|
|
@ -2725,7 +2725,7 @@ class Item
|
|||
DI::logger()->info('remote-self post original item', ['contact' => $contact['url'], 'result' => $result, 'item' => $datarray2]);
|
||||
} else {
|
||||
$datarray['app'] = 'Feed';
|
||||
$result = true;
|
||||
$result = true;
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
|
|
@ -2755,11 +2755,11 @@ class Item
|
|||
$site = substr(DI::baseUrl(), strpos(DI::baseUrl(), '://'));
|
||||
|
||||
$orig_body = $s;
|
||||
$new_body = '';
|
||||
$new_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_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
|
||||
$img_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
|
||||
|
||||
while (($img_st_close !== false) && ($img_len !== false)) {
|
||||
$img_st_close++; // make it point to AFTER the closing bracket
|
||||
|
|
@ -2770,13 +2770,13 @@ class Item
|
|||
if (stristr($image, $site . '/photo/')) {
|
||||
// Only embed locally hosted photos
|
||||
$replace = false;
|
||||
$i = basename($image);
|
||||
$i = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $i);
|
||||
$x = strpos($i, '-');
|
||||
$i = basename($image);
|
||||
$i = str_replace(['.jpg', '.png', '.gif'], ['', '', ''], $i);
|
||||
$x = strpos($i, '-');
|
||||
|
||||
if ($x) {
|
||||
$res = substr($i, $x + 1);
|
||||
$i = substr($i, 0, $x);
|
||||
$res = substr($i, $x + 1);
|
||||
$i = substr($i, 0, $x);
|
||||
$photo = Photo::getPhotoForUser($uid, $i, $res);
|
||||
if (DBA::isResult($photo)) {
|
||||
/*
|
||||
|
|
@ -2806,7 +2806,7 @@ class Item
|
|||
if (preg_match("/\[img\=([0-9]*)x([0-9]*)\]/is", substr($orig_body, $img_start, $img_st_close), $match)) {
|
||||
DI::logger()->info('scaling photo');
|
||||
|
||||
$width = intval($match[1]);
|
||||
$width = intval($match[1]);
|
||||
$height = intval($match[2]);
|
||||
|
||||
$photo_img->scaleDown(max($width, $height));
|
||||
|
|
@ -2823,15 +2823,15 @@ class Item
|
|||
}
|
||||
}
|
||||
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start + $img_st_close) . $image . '[/img]';
|
||||
$new_body = $new_body . substr($orig_body, 0, $img_start + $img_st_close) . $image . '[/img]';
|
||||
$orig_body = substr($orig_body, $img_start + $img_st_close + $img_len + strlen('[/img]'));
|
||||
if ($orig_body === false) {
|
||||
$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_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
|
||||
$img_len = ($img_start !== false ? strpos(substr($orig_body, $img_start + $img_st_close + 1), '[/img]') : false);
|
||||
}
|
||||
|
||||
$new_body = $new_body . $orig_body;
|
||||
|
|
@ -2936,9 +2936,9 @@ class Item
|
|||
$expire_items = true;
|
||||
}
|
||||
|
||||
$expire_notes = (bool)DI::pConfig()->get($uid, 'expire', 'notes', true);
|
||||
$expire_notes = (bool)DI::pConfig()->get($uid, 'expire', 'notes', true);
|
||||
$expire_starred = (bool)DI::pConfig()->get($uid, 'expire', 'starred', true);
|
||||
$expire_photos = (bool)DI::pConfig()->get($uid, 'expire', 'photos', false);
|
||||
$expire_photos = (bool)DI::pConfig()->get($uid, 'expire', 'photos', false);
|
||||
|
||||
$expired = 0;
|
||||
|
||||
|
|
@ -3114,7 +3114,7 @@ class Item
|
|||
}
|
||||
|
||||
$condition = [
|
||||
'vid' => $vids, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'vid' => $vids, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'author-id' => $author_id, 'uid' => $uid, 'thr-parent-id' => $uri_id
|
||||
];
|
||||
$like_item = Post::selectFirst(['id', 'guid', 'verb'], $condition);
|
||||
|
|
@ -3160,29 +3160,29 @@ class Item
|
|||
$objtype = $item['resource-id'] ? Activity\ObjectType::IMAGE : Activity\ObjectType::NOTE;
|
||||
|
||||
$new_item = [
|
||||
'guid' => System::createUUID(),
|
||||
'uri' => self::newURI(),
|
||||
'uid' => $uid,
|
||||
'contact-id' => $owner['id'],
|
||||
'wall' => $item['wall'],
|
||||
'origin' => 1,
|
||||
'network' => Protocol::DFRN,
|
||||
'protocol' => Conversation::PARCEL_DIRECT,
|
||||
'direction' => Conversation::PUSH,
|
||||
'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'parent' => $item['id'],
|
||||
'thr-parent' => $item['uri'],
|
||||
'owner-id' => $author_id,
|
||||
'author-id' => $author_id,
|
||||
'body' => $activity,
|
||||
'verb' => $activity,
|
||||
'object-type' => $objtype,
|
||||
'allow_cid' => $allow_cid ?? $item['allow_cid'],
|
||||
'allow_gid' => $allow_gid ?? $item['allow_gid'],
|
||||
'deny_cid' => $deny_cid ?? $item['deny_cid'],
|
||||
'deny_gid' => $deny_gid ?? $item['deny_gid'],
|
||||
'visible' => 1,
|
||||
'unseen' => 1,
|
||||
'guid' => System::createUUID(),
|
||||
'uri' => self::newURI(),
|
||||
'uid' => $uid,
|
||||
'contact-id' => $owner['id'],
|
||||
'wall' => $item['wall'],
|
||||
'origin' => 1,
|
||||
'network' => Protocol::DFRN,
|
||||
'protocol' => Conversation::PARCEL_DIRECT,
|
||||
'direction' => Conversation::PUSH,
|
||||
'gravity' => self::GRAVITY_ACTIVITY,
|
||||
'parent' => $item['id'],
|
||||
'thr-parent' => $item['uri'],
|
||||
'owner-id' => $author_id,
|
||||
'author-id' => $author_id,
|
||||
'body' => $activity,
|
||||
'verb' => $activity,
|
||||
'object-type' => $objtype,
|
||||
'allow_cid' => $allow_cid ?? $item['allow_cid'],
|
||||
'allow_gid' => $allow_gid ?? $item['allow_gid'],
|
||||
'deny_cid' => $deny_cid ?? $item['deny_cid'],
|
||||
'deny_gid' => $deny_gid ?? $item['deny_gid'],
|
||||
'visible' => 1,
|
||||
'unseen' => 1,
|
||||
];
|
||||
|
||||
if (in_array($activity, [Activity::LIKE, Activity::DISLIKE])) {
|
||||
|
|
@ -3210,7 +3210,7 @@ class Item
|
|||
*/
|
||||
public static function getPermissionsConditionArrayByUserId(int $owner_id): array
|
||||
{
|
||||
$local_user = DI::userSession()->getLocalUserId();
|
||||
$local_user = DI::userSession()->getLocalUserId();
|
||||
$remote_user = DI::userSession()->getRemoteContactID($owner_id);
|
||||
|
||||
// default permissions - anonymous user
|
||||
|
|
@ -3244,7 +3244,7 @@ class Item
|
|||
*/
|
||||
public static function getPermissionsSQLByUserId(int $owner_id, string $table = ''): string
|
||||
{
|
||||
$local_user = DI::userSession()->getLocalUserId();
|
||||
$local_user = DI::userSession()->getLocalUserId();
|
||||
$remote_user = DI::userSession()->getRemoteContactID($owner_id);
|
||||
|
||||
if (!empty($table)) {
|
||||
|
|
@ -3372,7 +3372,7 @@ class Item
|
|||
public static function prepareBody(array &$item, bool $attach = false, bool $is_preview = false, bool $only_cache = false): string
|
||||
{
|
||||
$appHelper = DI::appHelper();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
Hook::callAll('prepare_body_init', $item);
|
||||
|
||||
// In order to provide theme developers more possibilities, event items
|
||||
|
|
@ -3384,7 +3384,7 @@ class Item
|
|||
|
||||
$tags = Tag::populateFromItem($item);
|
||||
|
||||
$item['tags'] = $tags['tags'];
|
||||
$item['tags'] = $tags['tags'];
|
||||
$item['hashtags'] = $tags['hashtags'];
|
||||
$item['mentions'] = $tags['mentions'];
|
||||
|
||||
|
|
@ -3408,12 +3408,12 @@ class Item
|
|||
|
||||
$shared = DI::contentItem()->getSharedPost($item, $fields);
|
||||
if (!empty($shared['post'])) {
|
||||
$shared_item = $shared['post'];
|
||||
$shared_item = $shared['post'];
|
||||
$shared_item['body'] = Post\Media::removeFromEndOfBody($shared_item['body']);
|
||||
$shared_item['body'] = Post\Media::replaceImage($shared_item['body']);
|
||||
$quote_uri_id = $shared['post']['uri-id'];
|
||||
$shared_links[] = strtolower($shared['post']['uri']);
|
||||
$item['body'] = BBCode::removeSharedData($item['body']);
|
||||
$quote_uri_id = $shared['post']['uri-id'];
|
||||
$shared_links[] = strtolower($shared['post']['uri']);
|
||||
$item['body'] = BBCode::removeSharedData($item['body']);
|
||||
} elseif (empty($shared_item['uri-id']) && empty($item['quote-uri-id']) && ($item['network'] != Protocol::DIASPORA)) {
|
||||
$media = Post\Media::getByURIId($item['uri-id'], [Post\Media::ACTIVITY]);
|
||||
if (!empty($media) && ($media[0]['media-uri-id'] != $item['uri-id'])) {
|
||||
|
|
@ -3425,7 +3425,7 @@ class Item
|
|||
}
|
||||
|
||||
if (empty($shared_item['uri-id'])) {
|
||||
$shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
|
||||
$shared_item = Post::selectFirst($fields, ['uri' => $media[0]['url'], 'uid' => [$item['uid'], 0]]);
|
||||
$shared_links[] = strtolower($media[0]['url']);
|
||||
}
|
||||
|
||||
|
|
@ -3451,21 +3451,21 @@ class Item
|
|||
$sharedSplitAttachments = [];
|
||||
|
||||
if (!empty($shared_item['uri-id'])) {
|
||||
$shared_uri_id = $shared_item['uri-id'];
|
||||
$shared_links[] = strtolower($shared_item['plink']);
|
||||
$shared_uri_id = $shared_item['uri-id'];
|
||||
$shared_links[] = strtolower($shared_item['plink']);
|
||||
$sharedSplitAttachments = DI::postMediaRepository()->splitAttachments($shared_uri_id, [], $shared_item['has-media']);
|
||||
$shared_links = array_merge($shared_links, $sharedSplitAttachments['visual']->column('url'));
|
||||
$shared_links = array_merge($shared_links, $sharedSplitAttachments['link']->column('url'));
|
||||
$shared_links = array_merge($shared_links, $sharedSplitAttachments['additional']->column('url'));
|
||||
$item['body'] = self::replaceVisualAttachments($sharedSplitAttachments['visual'], $item['body']);
|
||||
$shared_links = array_merge($shared_links, $sharedSplitAttachments['visual']->column('url'));
|
||||
$shared_links = array_merge($shared_links, $sharedSplitAttachments['link']->column('url'));
|
||||
$shared_links = array_merge($shared_links, $sharedSplitAttachments['additional']->column('url'));
|
||||
$item['body'] = self::replaceVisualAttachments($sharedSplitAttachments['visual'], $item['body']);
|
||||
}
|
||||
|
||||
$itemSplitAttachments = DI::postMediaRepository()->splitAttachments($item['uri-id'], $shared_links, $item['has-media'] ?? false);
|
||||
$item['body'] = self::replaceVisualAttachments($itemSplitAttachments['visual'], $item['body'] ?? '');
|
||||
$item['body'] = self::replaceVisualAttachments($itemSplitAttachments['visual'], $item['body'] ?? '');
|
||||
|
||||
self::putInCache($item);
|
||||
$item['body'] = $body;
|
||||
$s = $item["rendered-html"];
|
||||
$s = $item["rendered-html"];
|
||||
|
||||
if ($only_cache) {
|
||||
return '';
|
||||
|
|
@ -3489,7 +3489,7 @@ class Item
|
|||
$item['attachments'] = $itemSplitAttachments;
|
||||
|
||||
$hook_data = [
|
||||
'item' => $item,
|
||||
'item' => $item,
|
||||
'filter_reasons' => $filter_reasons
|
||||
];
|
||||
Hook::callAll('prepare_body_content_filter', $hook_data);
|
||||
|
|
@ -3502,9 +3502,9 @@ class Item
|
|||
}
|
||||
|
||||
$hook_data = [
|
||||
'item' => $item,
|
||||
'html' => $s,
|
||||
'preview' => $is_preview,
|
||||
'item' => $item,
|
||||
'html' => $s,
|
||||
'preview' => $is_preview,
|
||||
'filter_reasons' => $filter_reasons
|
||||
];
|
||||
Hook::callAll('prepare_body', $hook_data);
|
||||
|
|
@ -3515,22 +3515,22 @@ class Item
|
|||
if (!$attach) {
|
||||
// Replace the blockquotes with quotes that are used in mails.
|
||||
$mailquote = '<blockquote type="cite" class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">';
|
||||
$s = str_replace(['<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'], [$mailquote, $mailquote, $mailquote], $s);
|
||||
$s = str_replace(['<blockquote>', '<blockquote class="spoiler">', '<blockquote class="author">'], [$mailquote, $mailquote, $mailquote], $s);
|
||||
return $s;
|
||||
}
|
||||
|
||||
if (!empty($sharedSplitAttachments)) {
|
||||
$s = self::addGallery($s, $sharedSplitAttachments['visual']);
|
||||
$s = self::addVisualAttachments($sharedSplitAttachments['visual'], $shared_item, $s, true);
|
||||
$s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $sharedSplitAttachments, $body, $s, true, $quote_shared_links);
|
||||
$s = self::addNonVisualAttachments($sharedSplitAttachments['additional'], $item, $s);
|
||||
$s = self::addGallery($s, $sharedSplitAttachments['visual']);
|
||||
$s = self::addVisualAttachments($sharedSplitAttachments['visual'], $shared_item, $s, true);
|
||||
$s = self::addLinkAttachment($shared_uri_id ?: $item['uri-id'], $sharedSplitAttachments, $body, $s, true, $quote_shared_links);
|
||||
$s = self::addNonVisualAttachments($sharedSplitAttachments['additional'], $item, $s);
|
||||
$body = BBCode::removeSharedData($body);
|
||||
}
|
||||
|
||||
$pos = strpos($s, BBCode::SHARED_ANCHOR);
|
||||
if ($pos) {
|
||||
$shared_html = substr($s, $pos + strlen(BBCode::SHARED_ANCHOR));
|
||||
$s = substr($s, 0, $pos);
|
||||
$s = substr($s, 0, $pos);
|
||||
}
|
||||
|
||||
$s = self::addGallery($s, $itemSplitAttachments['visual']);
|
||||
|
|
@ -3550,7 +3550,7 @@ class Item
|
|||
// Replace friendica image url size with theme preference.
|
||||
if (!empty($appHelper->getThemeInfoValue('item_image_size'))) {
|
||||
$ps = $appHelper->getThemeInfoValue('item_image_size');
|
||||
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
|
||||
$s = preg_replace('|(<img[^>]+src="[^"]+/photo/[0-9a-f]+)-[0-9]|', "$1-" . $ps, $s);
|
||||
}
|
||||
|
||||
if (!empty($shared_html)) {
|
||||
|
|
@ -3592,7 +3592,7 @@ class Item
|
|||
continue;
|
||||
}
|
||||
$element_html = $element->ownerDocument->saveHTML($element);
|
||||
$html = str_replace($element_html, str_replace($src, $svg, $element_html), $html);
|
||||
$html = str_replace($element_html, str_replace($src, $svg, $element_html), $html);
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
|
@ -3616,8 +3616,8 @@ class Item
|
|||
|
||||
$s = preg_replace_callback($pattern, function () use ($PostMedia) {
|
||||
return Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image/single_with_height_allocation.tpl'), [
|
||||
'$image' => $PostMedia,
|
||||
'$allocated_height' => $PostMedia->getAllocatedHeight(),
|
||||
'$image' => $PostMedia,
|
||||
'$allocated_height' => $PostMedia->getAllocatedHeight(),
|
||||
'$allocated_max_width' => ($PostMedia->previewWidth ?? $PostMedia->width) . 'px',
|
||||
]);
|
||||
}, $s);
|
||||
|
|
@ -3741,10 +3741,10 @@ class Item
|
|||
|
||||
if ($PostMedia->mimetype->type == 'image' || $PostMedia->preview) {
|
||||
$preview_size = Proxy::SIZE_MEDIUM;
|
||||
$preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
|
||||
$preview_url = DI::baseUrl() . $PostMedia->getPreviewPath($preview_size);
|
||||
} else {
|
||||
$preview_size = 0;
|
||||
$preview_url = '';
|
||||
$preview_url = '';
|
||||
}
|
||||
|
||||
if ($preview_url && self::containsLink($item['body'], $preview_url)) {
|
||||
|
|
@ -3780,10 +3780,10 @@ class Item
|
|||
} elseif ($PostMedia->mimetype->type == 'audio') {
|
||||
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/audio.tpl'), [
|
||||
'$audio' => [
|
||||
'id' => $PostMedia->id,
|
||||
'src' => (string)$PostMedia->url,
|
||||
'name' => $PostMedia->name ?: $PostMedia->url,
|
||||
'mime' => (string)$PostMedia->mimetype,
|
||||
'id' => $PostMedia->id,
|
||||
'src' => (string)$PostMedia->url,
|
||||
'name' => $PostMedia->name ?: $PostMedia->url,
|
||||
'mime' => (string)$PostMedia->mimetype,
|
||||
],
|
||||
]);
|
||||
if (($item['post-type'] ?? null) == Item::PT_AUDIO) {
|
||||
|
|
@ -3847,7 +3847,7 @@ class Item
|
|||
{
|
||||
DI::profiler()->startRecording('rendering');
|
||||
// Don't show a preview when there is a visual attachment (audio or video)
|
||||
$types = $attachments['visual']->column('type');
|
||||
$types = $attachments['visual']->column('type');
|
||||
$preview = !in_array(PostMedia::TYPE_IMAGE, $types) && !in_array(PostMedia::TYPE_VIDEO, $types);
|
||||
|
||||
/** @var ?PostMedia $attachment */
|
||||
|
|
@ -3870,18 +3870,18 @@ class Item
|
|||
|
||||
if (!empty($attachment)) {
|
||||
$data = [
|
||||
'after' => '',
|
||||
'author_name' => $attachment->authorName ?? '',
|
||||
'author_url' => (string)($attachment->authorUrl ?? ''),
|
||||
'description' => $attachment->description ?? '',
|
||||
'image' => '',
|
||||
'preview' => '',
|
||||
'after' => '',
|
||||
'author_name' => $attachment->authorName ?? '',
|
||||
'author_url' => (string)($attachment->authorUrl ?? ''),
|
||||
'description' => $attachment->description ?? '',
|
||||
'image' => '',
|
||||
'preview' => '',
|
||||
'provider_name' => $attachment->publisherName ?? '',
|
||||
'provider_url' => (string)($attachment->publisherUrl ?? ''),
|
||||
'text' => '',
|
||||
'title' => $attachment->name ?? '',
|
||||
'type' => 'link',
|
||||
'url' => (string)$attachment->url,
|
||||
'provider_url' => (string)($attachment->publisherUrl ?? ''),
|
||||
'text' => '',
|
||||
'title' => $attachment->name ?? '',
|
||||
'type' => 'link',
|
||||
'url' => (string)$attachment->url,
|
||||
];
|
||||
|
||||
if ($preview && $attachment->preview) {
|
||||
|
|
@ -4022,7 +4022,7 @@ class Item
|
|||
$options = Post\QuestionOption::getByURIId($item['uri-id']);
|
||||
foreach ($options as $key => $option) {
|
||||
if ($question['voters'] > 0) {
|
||||
$percent = $option['replies'] / $question['voters'] * 100;
|
||||
$percent = $option['replies'] / $question['voters'] * 100;
|
||||
$options[$key]['vote'] = DI::l10n()->tt('%2$s (%3$d%%, %1$d vote)', '%2$s (%3$d%%, %1$d votes)', $option['replies'] ?? 0, $option['name'], round($percent, 1));
|
||||
} else {
|
||||
$options[$key]['vote'] = DI::l10n()->tt('%2$s (%1$d vote)', '%2$s (%1$d votes)', $option['replies'] ?? 0, $option['name']);
|
||||
|
|
@ -4073,9 +4073,9 @@ class Item
|
|||
|
||||
if (DI::userSession()->getLocalUserId()) {
|
||||
$ret = [
|
||||
'href' => "display/" . $item['guid'],
|
||||
'orig' => "display/" . $item['guid'],
|
||||
'title' => DI::l10n()->t('View on separate page'),
|
||||
'href' => "display/" . $item['guid'],
|
||||
'orig' => "display/" . $item['guid'],
|
||||
'title' => DI::l10n()->t('View on separate page'),
|
||||
'orig_title' => DI::l10n()->t('View on separate page'),
|
||||
];
|
||||
|
||||
|
|
@ -4091,14 +4091,14 @@ class Item
|
|||
}
|
||||
|
||||
if (!empty($plink)) {
|
||||
$ret['href'] = DI::baseUrl()->remove($plink);
|
||||
$ret['href'] = DI::baseUrl()->remove($plink);
|
||||
$ret['title'] = DI::l10n()->t('Link to source');
|
||||
}
|
||||
} elseif (!empty($plink) && ($item['private'] != self::PRIVATE)) {
|
||||
$ret = [
|
||||
'href' => $plink,
|
||||
'orig' => $plink,
|
||||
'title' => DI::l10n()->t('Link to source'),
|
||||
'href' => $plink,
|
||||
'orig' => $plink,
|
||||
'title' => DI::l10n()->t('Link to source'),
|
||||
'orig_title' => DI::l10n()->t('Link to source'),
|
||||
];
|
||||
} else {
|
||||
|
|
@ -4143,7 +4143,7 @@ class Item
|
|||
public static function searchByLink(string $uri, int $uid = 0): int
|
||||
{
|
||||
$ssl_uri = str_replace('http://', 'https://', $uri);
|
||||
$uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)];
|
||||
$uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)];
|
||||
|
||||
$item = Post::selectFirst(['id'], ['uri' => $uris, 'uid' => $uid]);
|
||||
if (DBA::isResult($item)) {
|
||||
|
|
@ -4168,7 +4168,7 @@ class Item
|
|||
public static function getURIByLink(string $uri): string
|
||||
{
|
||||
$ssl_uri = str_replace('http://', 'https://', $uri);
|
||||
$uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)];
|
||||
$uris = [$uri, $ssl_uri, Strings::normaliseLink($uri)];
|
||||
|
||||
$item = Post::selectFirst(['uri'], ['uri' => $uris]);
|
||||
if (DBA::isResult($item)) {
|
||||
|
|
@ -4222,7 +4222,7 @@ class Item
|
|||
if (!$mimetype) {
|
||||
try {
|
||||
$curlResult = DI::httpClient()->head($uri, [HttpClientOptions::ACCEPT_CONTENT => HttpClientAccept::JSON_AS, HttpClientOptions::REQUEST => HttpClientRequest::ACTIVITYPUB]);
|
||||
$mimetype = $curlResult->getContentType();
|
||||
$mimetype = $curlResult->getContentType();
|
||||
} catch (\Throwable $th) {
|
||||
DI::logger()->info('Error while fetching HTTP link via HEAD', ['uid' => $uid, 'uri' => $uri, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return 0;
|
||||
|
|
@ -4233,7 +4233,7 @@ class Item
|
|||
try {
|
||||
// Issue 14126: Workaround for Mastodon servers that return "application/json" on a "head" request.
|
||||
$curlResult = HTTPSignature::fetchRaw($uri, $uid);
|
||||
$mimetype = $curlResult->getContentType();
|
||||
$mimetype = $curlResult->getContentType();
|
||||
} catch (\Throwable $th) {
|
||||
DI::logger()->info('Error while fetching HTTP link via signed GET', ['uid' => $uid, 'uri' => $uri, 'code' => $th->getCode(), 'message' => $th->getMessage()]);
|
||||
return 0;
|
||||
|
|
@ -4305,7 +4305,7 @@ class Item
|
|||
}
|
||||
|
||||
$url = $shared['message_id'] ?: $shared['link'];
|
||||
$id = self::fetchByLink($url, 0, ActivityPub\Receiver::COMPLETION_ASYNC);
|
||||
$id = self::fetchByLink($url, 0, ActivityPub\Receiver::COMPLETION_ASYNC);
|
||||
if (!$id) {
|
||||
DI::logger()->notice('Post could not be fetched.', ['url' => $url, 'uid' => $uid]);
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -137,15 +137,15 @@ class Mail
|
|||
Photo::setPermissionFromBody($body, $sender_uid, $me['id'], '<' . $contact['id'] . '>', '', '', '');
|
||||
|
||||
$guid = System::createUUID();
|
||||
$uri = Item::newURI($guid);
|
||||
$uri = Item::newURI($guid);
|
||||
|
||||
$convid = 0;
|
||||
$reply = false;
|
||||
$reply = false;
|
||||
|
||||
// look for any existing conversation structure
|
||||
|
||||
if (strlen($replyto)) {
|
||||
$reply = true;
|
||||
$reply = true;
|
||||
$condition = ["`uid` = ? AND (`uri` = ? OR `parent-uri` = ?)",
|
||||
$sender_uid, $replyto, $replyto];
|
||||
$mail = DBA::selectFirst('mail', ['convid'], $condition);
|
||||
|
|
@ -158,11 +158,11 @@ class Mail
|
|||
if (!$convid) {
|
||||
// create a new conversation
|
||||
$conv_guid = System::createUUID();
|
||||
$convuri = $contact['addr'] . ':' . $conv_guid;
|
||||
$convuri = $contact['addr'] . ':' . $conv_guid;
|
||||
|
||||
$fields = ['uid' => $sender_uid, 'guid' => $conv_guid, 'creator' => $me['addr'],
|
||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
||||
'created' => DateTimeFormat::utcNow(), 'updated' => DateTimeFormat::utcNow(),
|
||||
'subject' => $subject, 'recips' => $contact['addr'] . ';' . $me['addr']];
|
||||
if (DBA::insert('conv', $fields)) {
|
||||
$convid = DBA::lastInsertId();
|
||||
}
|
||||
|
|
@ -179,21 +179,21 @@ class Mail
|
|||
|
||||
$post_id = self::insert(
|
||||
[
|
||||
'uid' => $sender_uid,
|
||||
'guid' => $guid,
|
||||
'convid' => $convid,
|
||||
'from-name' => $me['name'],
|
||||
'uid' => $sender_uid,
|
||||
'guid' => $guid,
|
||||
'convid' => $convid,
|
||||
'from-name' => $me['name'],
|
||||
'from-photo' => $me['thumb'],
|
||||
'from-url' => $me['url'],
|
||||
'from-url' => $me['url'],
|
||||
'contact-id' => $recipient,
|
||||
'title' => $subject,
|
||||
'body' => $body,
|
||||
'seen' => 1,
|
||||
'reply' => $reply,
|
||||
'replied' => 0,
|
||||
'uri' => $uri,
|
||||
'title' => $subject,
|
||||
'body' => $body,
|
||||
'seen' => 1,
|
||||
'reply' => $reply,
|
||||
'replied' => 0,
|
||||
'uri' => $uri,
|
||||
'parent-uri' => $replyto,
|
||||
'created' => DateTimeFormat::utcNow()
|
||||
'created' => DateTimeFormat::utcNow()
|
||||
],
|
||||
false
|
||||
);
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class Post
|
|||
public static function selectOriginal(array $fields = [], array $condition = [], array $params = [])
|
||||
{
|
||||
$original_fields = $fields;
|
||||
$remove = [];
|
||||
$remove = [];
|
||||
if (!empty($fields)) {
|
||||
foreach (['gravity', 'verb', 'thr-parent-id', 'uid'] as $field) {
|
||||
if (!in_array($field, $fields)) {
|
||||
|
|
@ -447,7 +447,8 @@ class Post
|
|||
$selected = Item::DISPLAY_FIELDLIST;
|
||||
}
|
||||
|
||||
$condition = DBA::mergeConditions($condition,
|
||||
$condition = DBA::mergeConditions(
|
||||
$condition,
|
||||
["`visible` AND NOT `deleted`
|
||||
AND NOT `author-blocked` AND NOT `owner-blocked`
|
||||
AND (NOT `causer-blocked` OR `causer-id` = ? OR `causer-id` IS NULL) AND NOT `contact-blocked`
|
||||
|
|
@ -456,7 +457,8 @@ class Post
|
|||
AND NOT EXISTS(SELECT `uri-id` FROM `post-user` WHERE `uid` = ? AND `uri-id` = " . DBA::quoteIdentifier($view) . ".`uri-id` AND `hidden`)
|
||||
AND NOT EXISTS(SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` IN (`author-id`, `owner-id`) AND (`blocked` OR `ignored` OR `is-blocked`))
|
||||
AND NOT EXISTS(SELECT `gsid` FROM `user-gserver` WHERE `uid` = ? AND `gsid` IN (`author-gsid`, `owner-gsid`, `causer-gsid`) AND `ignored`)",
|
||||
0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid]);
|
||||
0, Contact::SHARING, Contact::FRIEND, 0, $uid, $uid, $uid]
|
||||
);
|
||||
|
||||
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
|
||||
|
||||
|
|
@ -581,7 +583,7 @@ class Post
|
|||
public static function selectOriginalForUser(int $uid, array $selected = [], array $condition = [], array $params = [])
|
||||
{
|
||||
$original_selected = $selected;
|
||||
$remove = [];
|
||||
$remove = [];
|
||||
if (!empty($selected)) {
|
||||
foreach (['gravity', 'verb', 'thr-parent-id'] as $field) {
|
||||
if (!in_array($field, $selected)) {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class Delayed
|
|||
|
||||
$last_publish = DI::pConfig()->get($item['uid'], 'system', 'last_publish', 0, true);
|
||||
$next_publish = max($last_publish + (60 * $min_posting), time());
|
||||
$delayed = date(DateTimeFormat::MYSQL, $next_publish);
|
||||
$delayed = date(DateTimeFormat::MYSQL, $next_publish);
|
||||
DI::pConfig()->set($item['uid'], 'system', 'last_publish', $next_publish);
|
||||
}
|
||||
|
||||
|
|
@ -151,13 +151,13 @@ class Delayed
|
|||
}
|
||||
|
||||
return [
|
||||
'parameters' => $delayed,
|
||||
'item' => $parameters[0],
|
||||
'notify' => $parameters[1],
|
||||
'taglist' => $parameters[2],
|
||||
'parameters' => $delayed,
|
||||
'item' => $parameters[0],
|
||||
'notify' => $parameters[1],
|
||||
'taglist' => $parameters[2],
|
||||
'attachments' => $parameters[3],
|
||||
'unprepared' => $parameters[4],
|
||||
'uri' => $parameters[5],
|
||||
'unprepared' => $parameters[4],
|
||||
'uri' => $parameters[5],
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ class Engagement
|
|||
const KEYWORDS = ['source', 'server', 'from', 'to', 'group', 'application', 'tag', 'network', 'platform', 'visibility', 'language', 'media'];
|
||||
const SHORTCUTS = ['lang' => 'language', 'net' => 'network', 'relay' => 'application'];
|
||||
const ALTERNATIVES = ['source:news' => 'source:service', 'source:relay' => 'source:application',
|
||||
'media:picture' => 'media:image', 'media:photo' => 'media:image',
|
||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
||||
'network:diaspora' => 'network:dspr', 'network:discourse' => 'network:dscs',
|
||||
'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
||||
const MEDIA_NONE = 0;
|
||||
'media:picture' => 'media:image', 'media:photo' => 'media:image',
|
||||
'network:activitypub' => 'network:apub', 'network:friendica' => 'network:dfrn',
|
||||
'network:diaspora' => 'network:dspr', 'network:discourse' => 'network:dscs',
|
||||
'network:tumblr' => 'network:tmbl', 'network:bluesky' => 'network:bsky'];
|
||||
const MEDIA_NONE = 0;
|
||||
const MEDIA_IMAGE = 1;
|
||||
const MEDIA_VIDEO = 2;
|
||||
const MEDIA_AUDIO = 4;
|
||||
const MEDIA_CARD = 8;
|
||||
const MEDIA_POST = 16;
|
||||
const MEDIA_CARD = 8;
|
||||
const MEDIA_POST = 16;
|
||||
|
||||
/**
|
||||
* Store engagement data from an item array
|
||||
|
|
@ -51,11 +51,13 @@ class Engagement
|
|||
return 0;
|
||||
}
|
||||
|
||||
$parent = Post::selectFirst(['uri-id', 'created', 'uid', 'private', 'quote-uri-id',
|
||||
'contact-contact-type', 'network', 'title', 'content-warning', 'body', 'language',
|
||||
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid',
|
||||
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'],
|
||||
['uri-id' => $item['parent-uri-id']]);
|
||||
$parent = Post::selectFirst(
|
||||
['uri-id', 'created', 'uid', 'private', 'quote-uri-id',
|
||||
'contact-contact-type', 'network', 'title', 'content-warning', 'body', 'language',
|
||||
'author-id', 'author-contact-type', 'author-nick', 'author-addr', 'author-gsid',
|
||||
'owner-id', 'owner-contact-type', 'owner-nick', 'owner-addr', 'owner-gsid'],
|
||||
['uri-id' => $item['parent-uri-id']]
|
||||
);
|
||||
|
||||
if ($parent['created'] < self::getCreationDateLimit(false)) {
|
||||
DI::logger()->debug('Post is too old', ['uri-id' => $item['uri-id'], 'parent-uri-id' => $item['parent-uri-id'], 'created' => $parent['created']]);
|
||||
|
|
@ -134,7 +136,7 @@ class Engagement
|
|||
$body = BBCode::removeSharedData($body);
|
||||
$body = preg_replace('/[^@!#]\[url\=.*?\].*?\[\/url\]/ism', '', $body);
|
||||
$body = BBCode::removeLinks($body);
|
||||
$msg = BBCode::toPlaintext($body, false);
|
||||
$msg = BBCode::toPlaintext($body, false);
|
||||
|
||||
return mb_strlen($msg);
|
||||
}
|
||||
|
|
@ -203,7 +205,7 @@ class Engagement
|
|||
$body = '[nosmile]network_' . $item['network'];
|
||||
|
||||
if (!empty($item['author-gsid'])) {
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['author-gsid']]);
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['author-gsid']]);
|
||||
$platform = preg_replace('/[\W]/', '', $gserver['platform'] ?? '');
|
||||
if (!empty($platform)) {
|
||||
$body .= ' platform_' . $platform;
|
||||
|
|
@ -212,7 +214,7 @@ class Engagement
|
|||
}
|
||||
|
||||
if (($item['owner-contact-type'] == Contact::TYPE_COMMUNITY) && !empty($item['owner-gsid']) && ($item['owner-gsid'] != ($item['author-gsid'] ?? 0))) {
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['owner-gsid']]);
|
||||
$gserver = DBA::selectFirst('gserver', ['platform', 'nurl'], ['id' => $item['owner-gsid']]);
|
||||
$platform = preg_replace('/[\W]/', '', $gserver['platform'] ?? '');
|
||||
if (!empty($platform) && !strpos($body, 'platform_' . $platform)) {
|
||||
$body .= ' platform_' . $platform;
|
||||
|
|
@ -252,7 +254,7 @@ class Engagement
|
|||
$body .= ' from_' . $item['author-nick'] . ' from_' . $item['author-addr'];
|
||||
}
|
||||
|
||||
if ($item['author-id'] != $item['owner-id']) {
|
||||
if ($item['author-id'] != $item['owner-id']) {
|
||||
if ($item['owner-contact-type'] == Contact::TYPE_COMMUNITY) {
|
||||
$body .= ' group_' . $item['owner-nick'] . ' group_' . $item['owner-addr'];
|
||||
} elseif (in_array($item['owner-contact-type'], [Contact::TYPE_PERSON, Contact::TYPE_NEWS, Contact::TYPE_ORGANISATION])) {
|
||||
|
|
@ -314,8 +316,10 @@ class Engagement
|
|||
|
||||
private static function addResharers(string $text, int $uri_id): string
|
||||
{
|
||||
$result = Post::selectPosts(['author-addr', 'author-nick', 'author-contact-type'],
|
||||
['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]);
|
||||
$result = Post::selectPosts(
|
||||
['author-addr', 'author-nick', 'author-contact-type'],
|
||||
['thr-parent-id' => $uri_id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE, 'author-contact-type' => [Contact::TYPE_RELAY, Contact::TYPE_COMMUNITY]]
|
||||
);
|
||||
while ($reshare = Post::fetch($result)) {
|
||||
$prefix = '';
|
||||
|
||||
|
|
@ -392,11 +396,11 @@ class Engagement
|
|||
|
||||
public static function escapeKeywords(string $fullTextSearch): string
|
||||
{
|
||||
foreach (SELF::SHORTCUTS as $search => $replace) {
|
||||
foreach (self::SHORTCUTS as $search => $replace) {
|
||||
$fullTextSearch = preg_replace('~' . $search . ':(.[\w\*@\.-]+)~', $replace . ':$1', $fullTextSearch);
|
||||
}
|
||||
|
||||
foreach (SELF::ALTERNATIVES as $search => $replace) {
|
||||
foreach (self::ALTERNATIVES as $search => $replace) {
|
||||
$fullTextSearch = str_replace($search, $replace, $fullTextSearch);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,9 +61,9 @@ class Link
|
|||
$id = $link['id'];
|
||||
DI::logger()->info('Found', ['id' => $id, 'uri-id' => $uriId, 'url' => $url]);
|
||||
} else {
|
||||
$fields = self::fetchMimeType($url);
|
||||
$fields = self::fetchMimeType($url);
|
||||
$fields['uri-id'] = $uriId;
|
||||
$fields['url'] = Network::sanitizeUrl($url);
|
||||
$fields['url'] = Network::sanitizeUrl($url);
|
||||
|
||||
DBA::insert('post-link', $fields, Database::INSERT_IGNORE);
|
||||
$id = DBA::lastInsertId();
|
||||
|
|
@ -126,7 +126,7 @@ class Link
|
|||
|
||||
if (Images::isSupportedMimeType($fields['mimetype'])) {
|
||||
$img_str = $curlResult->getBodyString();
|
||||
$image = new Image($img_str, $fields['mimetype'], $url, false);
|
||||
$image = new Image($img_str, $fields['mimetype'], $url, false);
|
||||
if ($image->isValid()) {
|
||||
$fields['mimetype'] = $image->getType();
|
||||
$fields['width'] = $image->getWidth();
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ class UserNotification
|
|||
$fields = ['id', 'uri-id', 'parent-uri-id', 'uid', 'body', 'parent', 'gravity', 'vid', 'gravity',
|
||||
'contact-id', 'author-id', 'author-gsid', 'owner-id', 'owner-gsid', 'causer-id', 'causer-gsid',
|
||||
'private', 'thr-parent', 'thr-parent-id', 'parent-uri-id', 'parent-uri', 'verb'];
|
||||
$item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]);
|
||||
$item = Post::selectFirst($fields, ['uri-id' => $uri_id, 'uid' => $uid, 'origin' => false]);
|
||||
if (!DBA::isResult($item)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ class Profile
|
|||
*/
|
||||
public static function getVCardHtml(array $profile, bool $block, bool $show_contacts): string
|
||||
{
|
||||
$o = '';
|
||||
$o = '';
|
||||
$location = false;
|
||||
|
||||
$profile_contact = [];
|
||||
|
|
@ -293,8 +293,8 @@ class Profile
|
|||
|
||||
$cid = $contact['id'];
|
||||
|
||||
$follow_link = null;
|
||||
$unfollow_link = null;
|
||||
$follow_link = null;
|
||||
$unfollow_link = null;
|
||||
$wallmessage_link = null;
|
||||
|
||||
// Who is the logged-in user to this profile?
|
||||
|
|
@ -303,13 +303,11 @@ class Profile
|
|||
$visitor_contact = Contact::selectFirst(['rel'], ['uid' => $profile['uid'], 'nurl' => Strings::normaliseLink(DI::userSession()->getMyUrl())]);
|
||||
}
|
||||
|
||||
$local_user_is_self = DI::userSession()->getMyUrl() && ($profile['url'] == DI::userSession()->getMyUrl());
|
||||
$local_user_is_self = DI::userSession()->getMyUrl() && ($profile['url'] == DI::userSession()->getMyUrl());
|
||||
$visitor_is_authenticated = (bool)DI::userSession()->getMyUrl();
|
||||
$visitor_is_following =
|
||||
in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
|
||||
$visitor_is_following = in_array($visitor_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND])
|
||||
|| in_array($profile_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND]);
|
||||
$visitor_is_followed =
|
||||
in_array($visitor_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND])
|
||||
$visitor_is_followed = in_array($visitor_contact['rel'] ?? 0, [Contact::SHARING, Contact::FRIEND])
|
||||
|| in_array($profile_contact['rel'] ?? 0, [Contact::FOLLOWER, Contact::FRIEND]);
|
||||
$visitor_base_path = DI::userSession()->getMyUrl() ? preg_replace('=/profile/(.*)=ism', '', DI::userSession()->getMyUrl()) : '';
|
||||
|
||||
|
|
@ -341,15 +339,15 @@ class Profile
|
|||
$profile['edit'] = [DI::baseUrl() . '/settings/profile', DI::l10n()->t('Edit profile'), '', DI::l10n()->t('Edit profile')];
|
||||
$profile['menu'] = [
|
||||
'chg_photo' => DI::l10n()->t('Change profile photo'),
|
||||
'cr_new' => null,
|
||||
'entries' => [],
|
||||
'cr_new' => null,
|
||||
'entries' => [],
|
||||
];
|
||||
}
|
||||
|
||||
// Fetch the account type
|
||||
$account_type = Contact::getAccountType($profile['account-type']);
|
||||
|
||||
if (!empty($profile['address']) || !empty($profile['location'])) {
|
||||
if (!empty($profile['address']) || !empty($profile['location'])) {
|
||||
$location = DI::l10n()->t('Location:');
|
||||
}
|
||||
|
||||
|
|
@ -363,8 +361,8 @@ class Profile
|
|||
}
|
||||
|
||||
$split_name = Diaspora::splitName($profile['name']);
|
||||
$firstname = $split_name['first'];
|
||||
$lastname = $split_name['last'];
|
||||
$firstname = $split_name['first'];
|
||||
$lastname = $split_name['last'];
|
||||
|
||||
if (!empty($profile['guid'])) {
|
||||
$diaspora = [
|
||||
|
|
@ -384,7 +382,7 @@ class Profile
|
|||
}
|
||||
|
||||
$contact_block = '';
|
||||
$updated = '';
|
||||
$updated = '';
|
||||
$contact_count = 0;
|
||||
|
||||
if (!empty($profile['last-item'])) {
|
||||
|
|
@ -415,7 +413,7 @@ class Profile
|
|||
'upubkey' => null,
|
||||
];
|
||||
foreach ($profile as $k => $v) {
|
||||
$k = str_replace('-', '_', $k);
|
||||
$k = str_replace('-', '_', $k);
|
||||
$p[$k] = $v;
|
||||
}
|
||||
|
||||
|
|
@ -444,35 +442,35 @@ class Profile
|
|||
$mention_url = 'compose/0?body=@' . $profile['addr'];
|
||||
$network_label = DI::l10n()->t('Network Posts');
|
||||
}
|
||||
$network_url = 'contact/' . $cid . '/conversations';
|
||||
$network_url = 'contact/' . $cid . '/conversations';
|
||||
|
||||
$tpl = Renderer::getMarkupTemplate('profile/vcard.tpl');
|
||||
$o .= Renderer::replaceMacros($tpl, [
|
||||
'$profile' => $p,
|
||||
'$xmpp' => $xmpp,
|
||||
'$matrix' => $matrix,
|
||||
'$follow' => DI::l10n()->t('Follow'),
|
||||
'$follow_link' => $follow_link,
|
||||
'$unfollow' => DI::l10n()->t('Unfollow'),
|
||||
'$unfollow_link' => $unfollow_link,
|
||||
'$subscribe_feed' => DI::l10n()->t('Atom feed'),
|
||||
'$profile' => $p,
|
||||
'$xmpp' => $xmpp,
|
||||
'$matrix' => $matrix,
|
||||
'$follow' => DI::l10n()->t('Follow'),
|
||||
'$follow_link' => $follow_link,
|
||||