$tpl = Renderer::getMarkupTemplate("photos_head.tpl");
- DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl,[
+ DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$ispublic' => DI::l10n()->t('everybody')
]);
}
// get the list of photos we are about to delete
if ($visitor) {
- $r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = ? AND `uid` = ? AND `album` = ?",
+ $r = DBA::toArray(DBA::p(
+ "SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `contact-id` = ? AND `uid` = ? AND `album` = ?",
$visitor,
$page_owner_uid,
$album
));
} else {
- $r = DBA::toArray(DBA::p("SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
+ $r = DBA::toArray(DBA::p(
+ "SELECT distinct(`resource-id`) as `rid` FROM `photo` WHERE `uid` = ? AND `album` = ?",
DI::userSession()->getLocalUserId(),
$album
));
// same as above but remove single photo
if ($visitor) {
$condition = ['contact-id' => $visitor, 'uid' => $page_owner_uid, 'resource-id' => DI::args()->getArgv()[3]];
-
} else {
$condition = ['uid' => DI::userSession()->getLocalUserId(), 'resource-id' => DI::args()->getArgv()[3]];
}
if (strpos($tag, '@') === 0) {
$profile = '';
$contact = null;
- $name = substr($tag,1);
+ $name = substr($tag, 1);
if ((strpos($name, '@')) || (strpos($name, 'http://'))) {
$newname = $name;
if ($tagcid) {
$contact = DBA::selectFirst('contact', [], ['id' => $tagcid, 'uid' => $page_owner_uid]);
} else {
- $newname = str_replace('_',' ',$name);
+ $newname = str_replace('_', ' ', $name);
//select someone from this user's contacts by name
$contact = DBA::selectFirst('contact', [], ['name' => $newname, 'uid' => $page_owner_uid]);
if (!DBA::isResult($contact)) {
//select someone by attag or nick and the name passed in
- $contact = DBA::selectFirst('contact', [],
+ $contact = DBA::selectFirst(
+ 'contact',
+ [],
['(`attag` = ? OR `nick` = ?) AND `uid` = ?', $name, $name, $page_owner_uid],
['order' => ['attag' => true]]
);
$uploader = '';
- $ret = ['post_url' => 'profile/' . $user['nickname'] . '/photos',
- 'addon_text' => $uploader,
- 'default_upload' => true];
+ $ret = [
+ 'post_url' => 'profile/' . $user['nickname'] . '/photos',
+ 'addon_text' => $uploader,
+ 'default_upload' => true
+ ];
- Hook::callAll('photo_upload_form',$ret);
+ Hook::callAll('photo_upload_form', $ret);
$default_upload_box = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_box.tpl'), []);
$default_upload_submit = Renderer::replaceMacros(Renderer::getMarkupTemplate('photos_default_uploader_submit.tpl'), [
$umf_bytes = Strings::getBytesFromShorthand(ini_get('upload_max_filesize'));
// Per Friendica definition a value of '0' means unlimited:
- If ($mis_bytes == 0) {
+ if ($mis_bytes == 0) {
$mis_bytes = INF;
}
$aclselect_e = ($visitor ? '' : ACL::getFullSelectorHTML(DI::page(), $a->getLoggedInUserId()));
- $o .= Renderer::replaceMacros($tpl,[
+ $o .= Renderer::replaceMacros($tpl, [
'$pagename' => DI::l10n()->t('Upload Photos'),
'$sessid' => session_id(),
'$usage' => $usage_message,
if ($datatype === 'album') {
// if $datum is not a valid hex, redirect to the default page
if (is_null($datum) || !Strings::isHex($datum)) {
- DI::baseUrl()->redirect('photos/' . $user['nickname']. '/album');
+ DI::baseUrl()->redirect('photos/' . $user['nickname'] . '/album');
}
$album = hex2bin($datum);
}
$total = 0;
- $r = DBA::toArray(DBA::p("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = ? AND `album` = ?
+ $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,
$album
$order = 'DESC';
}
- $r = DBA::toArray(DBA::p("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
+ $r = DBA::toArray(DBA::p(
+ "SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
ANY_VALUE(`type`) AS `type`, max(`scale`) AS `scale`, ANY_VALUE(`desc`) as `desc`,
ANY_VALUE(`created`) as `created`
FROM `photo` WHERE `uid` = ? AND `album` = ?
$album_e = $album;
- $o .= Renderer::replaceMacros($edit_tpl,[
+ $o .= Renderer::replaceMacros($edit_tpl, [
'$nametext' => DI::l10n()->t('New album name: '),
'$nickname' => $user['nickname'],
'$album' => $album_e,
$desc_e = $rr['desc'];
$photos[] = [
- 'id' => $rr['id'],
- 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2,4),
- 'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id']
+ 'id' => $rr['id'],
+ 'twist' => ' ' . ($twist ? 'rotleft' : 'rotright') . rand(2, 4),
+ 'link' => 'photos/' . $user['nickname'] . '/image/' . $rr['resource-id']
. ($order_field === 'created' ? '?order=created' : ''),
'title' => DI::l10n()->t('View Photo'),
- 'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' .$ext,
- 'alt' => $imgalt_e,
- 'desc'=> $desc_e,
- 'ext' => $ext,
- 'hash'=> $rr['resource-id'],
+ 'src' => 'photo/' . $rr['resource-id'] . '-' . $rr['scale'] . '.' . $ext,
+ 'alt' => $imgalt_e,
+ 'desc' => $desc_e,
+ 'ext' => $ext,
+ 'hash' => $rr['resource-id'],
];
}
}
]);
return $o;
-
}
// Display one photo
}
$tpl = Renderer::getMarkupTemplate('photo_edit_head.tpl');
- DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl,[
+ DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
'$prevlink' => $prevlink,
'$nextlink' => $nextlink
]);
if ($nextlink) {
$nextlink = [$nextlink, '<div class="icon next"></div>'];
}
- }
+ }
}
if (count($ph) == 1) {
}
$photo = [
- 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
- 'title'=> DI::l10n()->t('View Full Size'),
- 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?_u=' . DateTimeFormat::utcNow('ymdhis'),
- 'height' => $hires['height'],
- 'width' => $hires['width'],
- 'album' => $hires['album'],
+ 'href' => 'photo/' . $hires['resource-id'] . '-' . $hires['scale'] . '.' . $phototypes[$hires['type']],
+ 'title' => DI::l10n()->t('View Full Size'),
+ 'src' => 'photo/' . $lores['resource-id'] . '-' . $lores['scale'] . '.' . $phototypes[$lores['type']] . '?_u=' . DateTimeFormat::utcNow('ymdhis'),
+ 'height' => $hires['height'],
+ 'width' => $hires['width'],
+ 'album' => $hires['album'],
'filename' => $hires['filename'],
];
$edit = Renderer::replaceMacros($edit_tpl, [
'$id' => $ph[0]['id'],
- '$album' => ['albname', DI::l10n()->t('New album name'), $album_e,''],
+ '$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_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, ''],
'$nickname' => $user['nickname'],
'$resource_id' => $ph[0]['resource-id'],
$qcomment = $words ? explode("\n", $words) : [];
}
- $comments .= Renderer::replaceMacros($cmnt_tpl,[
+ $comments .= Renderer::replaceMacros($cmnt_tpl, [
'$return_path' => '',
'$jsreload' => $return_path,
'$id' => $link_item['id'],
$activity = DI::activity();
if (($activity->match($item['verb'], Activity::LIKE) ||
- $activity->match($item['verb'], Activity::DISLIKE)) &&
- ($item['gravity'] != Item::GRAVITY_PARENT)) {
+ $activity->match($item['verb'], Activity::DISLIKE)) &&
+ ($item['gravity'] != Item::GRAVITY_PARENT)
+ ) {
continue;
}
- $author = ['uid' => 0, 'id' => $item['author-id'],
- 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $author = [
+ 'uid' => 0,
+ 'id' => $item['author-id'],
+ 'network' => $item['author-network'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias']
+ ];
$profile_url = Contact::magicLinkByContact($author);
if (strpos($profile_url, 'contact/redir/') === 0) {
$sparkle = ' sparkle';
$title_e = $item['title'];
$body_e = BBCode::convertForUriId($item['uri-id'], $item['body']);
- $comments .= Renderer::replaceMacros($template,[
+ $comments .= Renderer::replaceMacros($template, [
'$id' => $item['id'],
'$profile_url' => $profile_url,
'$name' => $item['author-name'],
'uid' => 0,
'id' => $activity['author-id'],
'network' => $activity['author-network'],
- 'url' => $activity['author-link']
+ 'url' => $activity['author-link'],
+ 'alias' => $activity['author-alias'],
];
$url = Contact::magicLinkByContact($author);
if (strpos($url, 'contact/redir/') === 0) {
$phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> attends', '<button type="button" %2$s>%1$d people</button> attend', $total, $spanatts);
break;
case 'attendno':
- $phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> doesn\'t attend','<button type="button" %2$s>%1$d people</button> don\'t attend', $total, $spanatts);
+ $phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> doesn\'t attend', '<button type="button" %2$s>%1$d people</button> don\'t attend', $total, $spanatts);
break;
case 'attendmaybe':
$phrase = $this->l10n->tt('<button type="button" %2$s>%1$d person</button> attends maybe', '<button type="button" %2$s>%1$d people</button> attend maybe', $total, $spanatts);
if (!$update) {
$live_update_div = '<div id="live-contact"></div>' . "\r\n"
. "<script> var profile_uid = -1; var netargs = '" . substr($this->args->getCommand(), 8)
- ."?f='; </script>\r\n";
+ . "?f='; </script>\r\n";
}
} elseif ($mode === self::MODE_SEARCH) {
$live_update_div = '<div id="live-search"></div>' . "\r\n";
$tags = Tag::populateFromItem($item);
- $author = ['uid' => 0, 'id' => $item['author-id'], 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $author = [
+ 'uid' => 0,
+ 'id' => $item['author-id'],
+ 'network' => $item['author-network'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias'],
+ ];
$profile_link = Contact::magicLinkByContact($author);
$sparkle = '';
$row['causer-avatar'] = $contact['thumb'];
$row['causer-name'] = $contact['name'];
} elseif (($row['gravity'] == ItemModel::GRAVITY_ACTIVITY) && ($row['verb'] == Activity::ANNOUNCE) &&
- ($row['author-id'] == $activity['causer-id'])) {
+ ($row['author-id'] == $activity['causer-id'])
+ ) {
return $row;
}
}
}
if (in_array($row['gravity'], [ItemModel::GRAVITY_PARENT, ItemModel::GRAVITY_COMMENT]) && !empty($row['causer-id'])) {
- $causer = ['uid' => 0, 'id' => $row['causer-id'], 'network' => $row['causer-network'], 'url' => $row['causer-link']];
+ $causer = [
+ 'uid' => 0,
+ 'id' => $row['causer-id'],
+ 'network' => $row['causer-network'],
+ 'url' => $row['causer-link'],
+ 'alias' => $row['causer-alias'],
+ ];
- $row['reshared'] = $this->l10n->t('%s reshared this.', '<a href="'. htmlentities(Contact::magicLinkByContact($causer)) .'">' . htmlentities($row['causer-name']) . '</a>');
+ $row['reshared'] = $this->l10n->t('%s reshared this.', '<a href="' . htmlentities(Contact::magicLinkByContact($causer)) . '">' . htmlentities($row['causer-name']) . '</a>');
}
$row['direction'] = ['direction' => 3, 'title' => (empty($row['causer-id']) ? $this->l10n->t('Reshared') : $this->l10n->t('Reshared by %s <%s>', $row['causer-name'], $row['causer-link']))];
break;
$condition = DBA::mergeConditions($condition, ["(`gravity` != ? OR `origin`)", ItemModel::GRAVITY_ACTIVITY]);
}
- $condition = DBA::mergeConditions($condition,
- ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]);
+ $condition = DBA::mergeConditions(
+ $condition,
+ ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]
+ );
$condition = DBA::mergeConditions($condition, ["(`uid` != ? OR `private` != ?)", 0, ItemModel::PRIVATE]);
- $condition = DBA::mergeConditions($condition,
- ["`visible` AND NOT `deleted` AND NOT `author-blocked` AND NOT `owner-blocked`
+ $condition = DBA::mergeConditions(
+ $condition,
+ [
+ "`visible` AND NOT `deleted` AND NOT `author-blocked` AND NOT `owner-blocked`
AND ((NOT `contact-pending` AND (`contact-rel` IN (?, ?))) OR `self` OR `contact-uid` = ?)",
- Contact::SHARING, Contact::FRIEND, 0]);
+ Contact::SHARING, Contact::FRIEND, 0
+ ]
+ );
$thread_parents = Post::select(['uri-id', 'causer-id'], $condition, ['order' => ['uri-id' => false, 'uid']]);
$items[$key]['user-collapsed-author'] = !$always_display && in_array($row['author-id'], $collapses);
$items[$key]['user-collapsed-owner'] = !$always_display && in_array($row['owner-id'], $collapses);
- if (in_array($mode, [self::MODE_COMMUNITY, self::MODE_NETWORK]) &&
- (in_array($row['author-id'], $blocks) || in_array($row['owner-id'], $blocks) || in_array($row['author-id'], $ignores) || in_array($row['owner-id'], $ignores))) {
+ if (
+ in_array($mode, [self::MODE_COMMUNITY, self::MODE_NETWORK]) &&
+ (in_array($row['author-id'], $blocks) || in_array($row['owner-id'], $blocks) || in_array($row['author-id'], $ignores) || in_array($row['owner-id'], $ignores))
+ ) {
unset($items[$key]);
}
}
$condition = DBA::mergeConditions(['parent-uri-id' => $uriids, 'gravity' => ItemModel::GRAVITY_ACTIVITY, 'verb' => $verbs], ["NOT `deleted`"]);
$separator = chr(255) . chr(255) . chr(255);
- $sql = "SELECT `thr-parent-id`, `body`, `verb`, COUNT(*) AS `total`, GROUP_CONCAT(REPLACE(`author-name`, '" . $separator . "', ' ') SEPARATOR '". $separator ."' LIMIT 50) AS `title` FROM `post-view` WHERE " . array_shift($condition) . " GROUP BY `thr-parent-id`, `verb`, `body`";
+ $sql = "SELECT `thr-parent-id`, `body`, `verb`, COUNT(*) AS `total`, GROUP_CONCAT(REPLACE(`author-name`, '" . $separator . "', ' ') SEPARATOR '" . $separator . "' LIMIT 50) AS `title` FROM `post-view` WHERE " . array_shift($condition) . " GROUP BY `thr-parent-id`, `verb`, `body`";
$emojis = [];
// Searches the post item in the children
$j = 0;
while ($child['children'][$j]['verb'] !== Activity::POST && $j < count($child['children'])) {
- $j ++;
+ $j++;
}
$moved_item = $child['children'][$j];
* items and add them as children of their top-level post.
*/
foreach ($parents as $i => $parent) {
- $parents[$i]['children'] = array_merge($this->getItemChildren($item_array, $parent, true),
- $this->getItemChildren($item_array, $parent, false));
+ $parents[$i]['children'] = array_merge(
+ $this->getItemChildren($item_array, $parent, true),
+ $this->getItemChildren($item_array, $parent, false)
+ );
}
foreach ($parents as $i => $parent) {
$groupList = [];
- $fields = ['id', 'url', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid'];
+ $fields = ['id', 'url', 'alias', 'name', 'micro', 'thumb', 'avatar', 'network', 'uid'];
$contacts = DBA::select('account-user-view', $fields, $condition, $params);
if (!$contacts) {
return $groupList;
while ($contact = DBA::fetch($contacts)) {
$groupList[] = [
'url' => $contact['url'],
+ 'alias' => $contact['alias'],
'name' => $contact['name'],
'id' => $contact['id'],
'micro' => $contact['micro'],
}
$author_arr = [
- 'uid' => 0,
- 'id' => $item['author-id'],
+ 'uid' => 0,
+ 'id' => $item['author-id'],
'network' => $item['author-network'],
- 'url' => $item['author-link'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-lias'],
];
$author = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $item['author-name'] . '[/url]';
$author_arr = [
- 'uid' => 0,
- 'id' => $obj['author-id'],
+ 'uid' => 0,
+ 'id' => $obj['author-id'],
'network' => $obj['author-network'],
- 'url' => $obj['author-link'],
+ 'url' => $obj['author-link'],
+ 'alias' => $obj['author-alias'],
];
$objauthor = '[url=' . Contact::magicLinkByContact($author_arr) . ']' . $obj['author-name'] . '[/url]';
}
$author = [
- 'uid' => 0,
- 'id' => $item['author-id'],
+ 'uid' => 0,
+ 'id' => $item['author-id'],
'network' => $item['author-network'],
- 'url' => $item['author-link'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias'],
];
$profile_link = Contact::magicLinkByContact($author, $item['author-link']);
if (strpos($profile_link, 'contact/redir/') === 0) {
{
$URLSearchString = "^\[\]";
- $matches = ["/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
+ $matches = [
+ "/\[url\=([$URLSearchString]*)\].*?\[\/url\]/ism",
"/\[url\]([$URLSearchString]*)\[\/url\]/ism",
"/\[img\=[0-9]*x[0-9]*\](.*?)\[\/img\]/ism",
"/\[img\](.*?)\[\/img\]/ism",
$ignore = false;
// A list of some links that should be ignored
- $list = ["/user/", "/tag/", "/group/", "/circle/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
- "//plus.google.com/", "//twitter.com/"];
+ $list = [
+ "/user/", "/tag/", "/group/", "/circle/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
+ "//plus.google.com/", "//twitter.com/"
+ ];
foreach ($list as $listitem) {
if (strpos($treffer[1], $listitem) !== false) {
$ignore = true;
$domain = '(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.)*' . preg_quote(trim($domain, '/'), '%');
});
- $config->set('URI.SafeIframeRegexp',
+ $config->set(
+ 'URI.SafeIframeRegexp',
'%^https://(?:
' . implode('|', $allowedIframeDomains) . '
)
if (isset($mediaType->parameters['charset'])) {
return strtolower($mediaType->parameters['charset']);
}
- } catch(\InvalidArgumentException $e) {}
+ } catch (\InvalidArgumentException $e) {
+ }
return null;
}
$thisday = substr($dnow, 4);
$dnow = substr($dnow, 0, 8) . '01';
$dthen = substr($dthen, 0, 8) . '01';
-
/*
* Starting with the current month, get the first and last days of every
$ret[$dyear][] = [$str, $end_month, $start_month];
$dnow = DateTimeFormat::utc($dnow . ' -1 month', 'Y-m-d');
-
}
}
$cutoff_year = intval(DateTimeFormat::localNow('Y')) - $visible_years;
$cutoff = array_key_exists($cutoff_year, $ret);
- $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'),[
+ $o = Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/posted_date.tpl'), [
'$title' => DI::l10n()->t('Archives'),
'$size' => $visible_years,
'$cutoff_year' => $cutoff_year,
['ref' => 'community', 'name' => DI::l10n()->t('Groups')],
];
- return self::filter('accounttype', DI::l10n()->t('Account Types'), '',
- DI::l10n()->t('All'), $base, $accounts, $accounttype);
+ return self::filter(
+ 'accounttype',
+ DI::l10n()->t('Account Types'),
+ '',
+ DI::l10n()->t('All'),
+ $base,
+ $accounts,
+ $accounttype
+ );
}
}
$contact_uriids = array_column($personal_contacts, 'uri-id');
if (!empty($contact_uriids)) {
- $contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'avatar', 'network'], ['uri-id' => $contact_uriids, 'uid' => $contact_uid]);
+ $contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'alias', 'name', 'thumb', 'avatar', 'network'], ['uri-id' => $contact_uriids, 'uid' => $contact_uid]);
if (DBA::isResult($contacts_stmt)) {
$contacts_title = DI::l10n()->tt('%d Contact', '%d Contacts', $total);
use Friendica\Core\System;
use Friendica\DI;
use Friendica\Model\Contact;
+use Friendica\Util\Network;
use Friendica\Util\Strings;
/**
Logger::warning('Incomplete contact', ['contact' => $contact ?? [], 'callstack' => System::callstack(20)]);
}
+ if (!Network::isValidHttpUrl($contact['url']) && Network::isValidHttpUrl($contact['alias'])) {
+ $url = $contact['alias'];
+ } else {
+ $url = $contact['url'];
+ }
+
if ($contact['network'] != '') {
- $network_link = Strings::formatNetworkName($contact['network'], $contact['url']);
- $network_avatar = ContactSelector::networkToIcon($contact['network'], $contact['url']);
+ $network_link = Strings::formatNetworkName($contact['network'], $url);
+ $network_avatar = ContactSelector::networkToIcon($contact['network'], $url);
} else {
$network_link = '';
$network_avatar = '';
if (empty($contact['self']) && Protocol::supportsFollow($contact['network'])) {
if (in_array($rel, [Contact::SHARING, Contact::FRIEND])) {
- $unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
+ $unfollow_link = 'contact/unfollow?url=' . urlencode($url) . '&auto=1';
} elseif (!$pending) {
- $follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
+ $follow_link = 'contact/follow?url=' . urlencode($url) . '&auto=1';
}
}
return Renderer::replaceMacros(Renderer::getMarkupTemplate('widget/vcard.tpl'), [
'$contact' => $contact,
'$photo' => $photo,
- '$url' => Contact::magicLinkByContact($contact, $contact['url']),
+ '$url' => Contact::magicLinkByContact($contact, $url),
'$about' => BBCode::convertForUriId($contact['uri-id'] ?? 0, $contact['about'] ?? ''),
'$xmpp' => DI::l10n()->t('XMPP:'),
'$matrix' => DI::l10n()->t('Matrix:'),
use Friendica\Contact\Avatar;
use Friendica\Contact\Introduction\Exception\IntroductionNotFoundException;
-use Friendica\Content\Conversation As ConversationContent;
+use Friendica\Content\Conversation as ConversationContent;
use Friendica\Content\Pager;
use Friendica\Content\Text\HTML;
use Friendica\Core\Hook;
* @}
*/
- const MIRROR_DEACTIVATED = 0;
- const MIRROR_FORWARDED = 1; // Deprecated, now does the same like MIRROR_OWN_POST
- const MIRROR_OWN_POST = 2;
- const MIRROR_NATIVE_RESHARE = 3;
+ const MIRROR_DEACTIVATED = 0;
+ const MIRROR_FORWARDED = 1; // Deprecated, now does the same like MIRROR_OWN_POST
+ const MIRROR_OWN_POST = 2;
+ const MIRROR_NATIVE_RESHARE = 3;
- /**
+ /**
* @param array $fields Array of selected fields, empty for all
* @param array $condition Array of fields for condition
* @param array $params Array of several parameters
*/
public static function createSelfFromUserId(int $uid): bool
{
- $user = DBA::selectFirst('user', ['uid', 'username', 'nickname', 'pubkey', 'prvkey'],
- ['uid' => $uid, 'account_expired' => false]);
+ $user = DBA::selectFirst(
+ 'user',
+ ['uid', 'username', 'nickname', 'pubkey', 'prvkey'],
+ ['uid' => $uid, 'account_expired' => false]
+ );
if (!DBA::isResult($user)) {
return false;
}
*/
public static function updateSelfFromUserID(int $uid, bool $update_avatar = false): bool
{
- $fields = ['id', 'uri-id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey', 'manually-approve',
+ $fields = [
+ 'id', 'uri-id', 'name', 'nick', 'location', 'about', 'keywords', 'avatar', 'prvkey', 'pubkey', 'manually-approve',
'xmpp', 'matrix', 'contact-type', 'forum', 'prv', 'avatar-date', 'url', 'nurl', 'unsearchable',
- 'photo', 'thumb', 'micro', 'header', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco', 'network'];
+ 'photo', 'thumb', 'micro', 'header', 'addr', 'request', 'notify', 'poll', 'confirm', 'poco', 'network'
+ ];
$self = DBA::selectFirst('contact', $fields, ['uid' => $uid, 'self' => true]);
if (!DBA::isResult($self)) {
return false;
return false;
}
- $fields = ['name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
- 'country-name', 'pub_keywords', 'xmpp', 'matrix', 'net-publish'];
+ $fields = [
+ 'name', 'photo', 'thumb', 'about', 'address', 'locality', 'region',
+ 'country-name', 'pub_keywords', 'xmpp', 'matrix', 'net-publish'
+ ];
$profile = DBA::selectFirst('profile', $fields, ['uid' => $uid]);
if (!DBA::isResult($profile)) {
return false;
'addr' => $user['nickname'] . '@' . substr(DI::baseUrl(), strpos(DI::baseUrl(), '://') + 3),
'request' => DI::baseUrl() . '/dfrn_request/' . $user['nickname'],
'notify' => DI::baseUrl() . '/dfrn_notify/' . $user['nickname'],
- 'poll' => DI::baseUrl() . '/dfrn_poll/'. $user['nickname'],
+ 'poll' => DI::baseUrl() . '/dfrn_poll/' . $user['nickname'],
'confirm' => DI::baseUrl() . '/dfrn_confirm/' . $user['nickname'],
];
// We are adding a timestamp value so that other systems won't use cached content
$timestamp = strtotime($fields['avatar-date']);
- $prefix = DI::baseUrl() . '/photo/' .$avatar['resource-id'] . '-';
+ $prefix = DI::baseUrl() . '/photo/' . $avatar['resource-id'] . '-';
$suffix = '.' . $file_suffix . '?ts=' . $timestamp;
$fields['photo'] = $prefix . '4' . $suffix;
*/
if (empty($contact['uid'])) {
$menu = [
- 'profile' => [DI::l10n()->t('View Profile') , $profile_link , true ],
- 'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
- 'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
- 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true ],
- 'unfollow' => [DI::l10n()->t('Unfollow') , $unfollow_link, true ],
+ 'profile' => [DI::l10n()->t('View Profile'), $profile_link, true],
+ 'network' => [DI::l10n()->t('Network Posts'), $posts_link, false],
+ 'edit' => [DI::l10n()->t('View Contact'), $contact_url, false],
+ 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link, true],
+ 'unfollow' => [DI::l10n()->t('Unfollow'), $unfollow_link, true],
];
} else {
$menu = [
- 'status' => [DI::l10n()->t('View Status') , $status_link , true ],
- 'profile' => [DI::l10n()->t('View Profile') , $profile_link , true ],
- 'photos' => [DI::l10n()->t('View Photos') , $photos_link , true ],
- 'network' => [DI::l10n()->t('Network Posts') , $posts_link , false],
- 'edit' => [DI::l10n()->t('View Contact') , $contact_url , false],
- 'pm' => [DI::l10n()->t('Send PM') , $pm_url , false],
- 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link , true ],
- 'unfollow' => [DI::l10n()->t('Unfollow') , $unfollow_link, true ],
+ 'status' => [DI::l10n()->t('View Status'), $status_link, true],
+ 'profile' => [DI::l10n()->t('View Profile'), $profile_link, true],
+ 'photos' => [DI::l10n()->t('View Photos'), $photos_link, true],
+ 'network' => [DI::l10n()->t('Network Posts'), $posts_link, false],
+ 'edit' => [DI::l10n()->t('View Contact'), $contact_url, false],
+ 'pm' => [DI::l10n()->t('Send PM'), $pm_url, false],
+ 'follow' => [DI::l10n()->t('Connect/Follow'), $follow_link, true],
+ 'unfollow' => [DI::l10n()->t('Unfollow'), $unfollow_link, true],
];
if (!empty($contact['pending'])) {
if (($uid == 0) && (empty($data['network']) || ($data['network'] == Protocol::PHANTOM))) {
// Fetch data for the public contact via the first found personal contact
/// @todo Check if this case can happen at all (possibly with mail accounts?)
- $fields = ['name', 'nick', 'url', 'addr', 'alias', 'avatar', 'header', 'contact-type',
+ $fields = [
+ 'name', 'nick', 'url', 'addr', 'alias', 'avatar', 'header', 'contact-type',
'keywords', 'location', 'about', 'unsearchable', 'batch', 'notify', 'poll',
- 'request', 'confirm', 'poco', 'subscribe', 'network', 'baseurl', 'gsid'];
+ 'request', 'confirm', 'poco', 'subscribe', 'network', 'baseurl', 'gsid'
+ ];
$personal_contact = DBA::selectFirst('contact', $fields, ["`addr` = ? AND `uid` != 0", $url]);
if (!DBA::isResult($personal_contact)) {
if (!empty($contact['batch'])) {
$condition = ['archive' => true, 'uid' => 0, 'network' => Protocol::FEDERATED, 'batch' => $contact['batch'], 'contact-type' => self::TYPE_RELAY];
return DBA::exists('contact', $condition);
- }
+ }
return false;
}
$contact_field = ((($contact["contact-type"] == self::TYPE_COMMUNITY) || ($contact['network'] == Protocol::MAIL)) ? 'owner-id' : 'author-id');
if ($thread_mode) {
- $condition = ["((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `protocol` != ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
- $cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA, DI::userSession()->getLocalUserId()];
+ $condition = [
+ "((`$contact_field` = ? AND `gravity` = ?) OR (`author-id` = ? AND `gravity` = ? AND `vid` = ? AND `protocol` != ? AND `thr-parent-id` = `parent-uri-id`)) AND " . $sql,
+ $cid, Item::GRAVITY_PARENT, $cid, Item::GRAVITY_ACTIVITY, Verb::getID(Activity::ANNOUNCE), Conversation::PARCEL_DIASPORA, DI::userSession()->getLocalUserId()
+ ];
} else {
- $condition = ["`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
- $cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, DI::userSession()->getLocalUserId()];
+ $condition = [
+ "`$contact_field` = ? AND `gravity` IN (?, ?) AND " . $sql,
+ $cid, Item::GRAVITY_PARENT, Item::GRAVITY_COMMENT, DI::userSession()->getLocalUserId()
+ ];
}
if (!empty($parent)) {
}
if ($only_media) {
- $condition = DBA::mergeConditions($condition, ["`uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `type` IN (?, ?, ?))",
- Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO]);
+ $condition = DBA::mergeConditions($condition, [
+ "`uri-id` IN (SELECT `uri-id` FROM `post-media` WHERE `type` IN (?, ?, ?))",
+ Post\Media::AUDIO, Post\Media::IMAGE, Post\Media::VIDEO
+ ]);
}
if (DI::mode()->isMobile()) {
- $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_mobile_network',
- DI::config()->get('system', 'itemspage_network_mobile'));
+ $itemsPerPage = DI::pConfig()->get(
+ DI::userSession()->getLocalUserId(),
+ 'system',
+ 'itemspage_mobile_network',
+ DI::config()->get('system', 'itemspage_network_mobile')
+ );
} else {
- $itemsPerPage = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'itemspage_network',
- DI::config()->get('system', 'itemspage_network'));
+ $itemsPerPage = DI::pConfig()->get(
+ DI::userSession()->getLocalUserId(),
+ 'system',
+ 'itemspage_network',
+ DI::config()->get('system', 'itemspage_network')
+ );
}
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
if ($pager->getStart() == 0) {
$cdata = self::getPublicAndUserContactID($cid, DI::userSession()->getLocalUserId());
if (!empty($cdata['public'])) {
- $condition = ["`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
- $cdata['public'], Post\Collection::FEATURED];
+ $condition = [
+ "`uri-id` IN (SELECT `uri-id` FROM `collection-view` WHERE `cid` = ? AND `type` = ?)",
+ $cdata['public'], Post\Collection::FEATURED
+ ];
$pinned = Post::toArray(Post::selectForUser(DI::userSession()->getLocalUserId(), $fields, $condition, $params));
$items = array_merge($pinned, $items);
}
} elseif (DI::config()->get('system', 'avatar_cache') && (empty($contact['photo']) || empty($contact['thumb']) || empty($contact['micro']))) {
Logger::info('Adding avatar cache file', ['id' => $cid, 'contact' => $contact]);
self::updateAvatar($cid, $contact['avatar'], true);
- return;
+ return;
}
}
*/
public static function getAvatarUrlForUrl(string $url, int $uid, string $size = ''): string
{
- $condition = ["`nurl` = ? AND ((`uid` = ? AND `network` IN (?, ?)) OR `uid` = ?)",
- Strings::normaliseLink($url), $uid, Protocol::FEED, Protocol::MAIL, 0];
+ $condition = [
+ "`nurl` = ? AND ((`uid` = ? AND `network` IN (?, ?)) OR `uid` = ?)",
+ Strings::normaliseLink($url), $uid, Protocol::FEED, Protocol::MAIL, 0
+ ];
$contact = self::selectFirst(['id', 'updated'], $condition, ['order' => ['uid' => true]]);
return self::getAvatarUrlForId($contact['id'] ?? 0, $size, $contact['updated'] ?? '');
}
*/
public static function updateAvatar(int $cid, string $avatar, bool $force = false, bool $create_cache = false)
{
- $contact = DBA::selectFirst('contact', ['uid', 'avatar', 'photo', 'thumb', 'micro', 'blurhash', 'xmpp', 'addr', 'nurl', 'url', 'network', 'uri-id'],
- ['id' => $cid, 'self' => false]);
+ $contact = DBA::selectFirst(
+ 'contact',
+ ['uid', 'avatar', 'photo', 'thumb', 'micro', 'blurhash', 'xmpp', 'addr', 'nurl', 'url', 'network', 'uri-id'],
+ ['id' => $cid, 'self' => false]
+ );
if (!DBA::isResult($contact)) {
return;
}
}
if ($default_avatar && Proxy::isLocalImage($avatar)) {
- $fields = ['avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
+ $fields = [
+ 'avatar' => $avatar, 'avatar-date' => DateTimeFormat::utcNow(),
'photo' => $avatar,
'thumb' => self::getDefaultAvatar($contact, Proxy::SIZE_THUMB),
- 'micro' => self::getDefaultAvatar($contact, Proxy::SIZE_MICRO)];
+ 'micro' => self::getDefaultAvatar($contact, Proxy::SIZE_MICRO)
+ ];
Logger::debug('Use default avatar', ['id' => $cid, 'uid' => $uid]);
}
$uids = [];
if (($uid == 0) && !in_array($contact['network'], [Protocol::FEED, Protocol::MAIL])) {
// Collect all user contacts of the given public contact
- $personal_contacts = DBA::select('contact', ['id', 'uid'],
- ["`nurl` = ? AND `id` != ? AND NOT `self`", $contact['nurl'], $cid]);
+ $personal_contacts = DBA::select(
+ 'contact',
+ ['id', 'uid'],
+ ["`nurl` = ? AND `id` != ? AND NOT `self`", $contact['nurl'], $cid]
+ );
while ($personal_contact = DBA::fetch($personal_contacts)) {
$cids[] = $personal_contact['id'];
$uids[] = $personal_contact['uid'];
// These fields aren't updated by this routine:
// 'sensitive'
- $fields = ['uid', 'uri-id', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
+ $fields = [
+ 'uid', 'uri-id', 'avatar', 'header', 'name', 'nick', 'location', 'keywords', 'about', 'subscribe',
'manually-approve', 'unsearchable', 'url', 'addr', 'batch', 'notify', 'poll', 'request', 'confirm', 'poco',
'network', 'alias', 'baseurl', 'gsid', 'forum', 'prv', 'contact-type', 'pubkey', 'last-item', 'xmpp', 'matrix',
- 'created', 'last-update'];
+ 'created', 'last-update'
+ ];
$contact = DBA::selectFirst('contact', $fields, ['id' => $id]);
if (!DBA::isResult($contact)) {
return false;
return true;
}
- $has_local_data = self::hasLocalData($id, $contact);
+ $has_local_data = self::hasLocalData($id, $contact);
$uid = $contact['uid'];
unset($contact['uid']);
// We must not try to update relay contacts via probe. They are no real contacts.
// We check after the probing to be able to correct falsely detected contact types.
if (($contact['contact-type'] == self::TYPE_RELAY) &&
- (!Strings::compareLink($ret['url'], $contact['url']) || in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]))) {
+ (!Strings::compareLink($ret['url'], $contact['url']) || in_array($ret['network'], [Protocol::FEED, Protocol::PHANTOM]))
+ ) {
self::updateContact($id, $uid, $uriid, $contact['url'], ['failed' => false, 'local-data' => $has_local_data, 'last-update' => $updated, 'next-update' => $success_next_update, 'success_update' => $updated]);
Logger::info('Not updating relais', ['id' => $id, 'url' => $contact['url']]);
return true;
'protocol' => $protocol,
'pubkey' => $ret['pubkey'],
'rel' => $new_relation,
- 'priority'=> $ret['priority'],
- 'writable'=> $writeable,
+ 'priority' => $ret['priority'],
+ 'writable' => $writeable,
'hidden' => $hidden,
'blocked' => 0,
- 'readonly'=> 0,
+ 'readonly' => 0,
'pending' => $pending,
'subhub' => $subhub
]);
}
// Contact is blocked at user-level
- if (!empty($contact['id']) && !empty($importer['id']) &&
- Contact\User::isBlocked($contact['id'], $importer['id'])) {
+ if (
+ !empty($contact['id']) && !empty($importer['id']) &&
+ Contact\User::isBlocked($contact['id'], $importer['id'])
+ ) {
return false;
}
self::unmarkForArchival($contact);
if (($contact['rel'] == self::SHARING)
- || ($sharing && $contact['rel'] == self::FOLLOWER)) {
- self::update(['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
- ['id' => $contact['id'], 'uid' => $importer['uid']]);
+ || ($sharing && $contact['rel'] == self::FOLLOWER)
+ ) {
+ self::update(
+ ['rel' => self::FRIEND, 'writable' => true, 'pending' => false],
+ ['id' => $contact['id'], 'uid' => $importer['uid']]
+ );
}
// Ensure to always have the correct network type, independent from the connection request method
*/
public static function magicLinkById(int $cid, string $url = ''): string
{
- $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], ['id' => $cid]);
+ $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'alias', 'uid'], ['id' => $cid]);
return self::magicLinkByContact($contact, $url);
}
*/
public static function magicLinkByContact(array $contact, string $url = ''): string
{
- $destination = $url ?: $contact['url'];
+ $destination = $url ?: (!Network::isValidHttpUrl($contact['url']) && !empty($contact['alias']) && Network::isValidHttpUrl($contact['alias']) ? $contact['alias'] : $contact['url']);
if (!DI::userSession()->isAuthenticated()) {
return $destination;
$params['limit'] = $limit;
}
- $condition = DBA::mergeConditions($condition,
- ["(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)", $search, $search, $search]);
+ $condition = DBA::mergeConditions(
+ $condition,
+ ["(`addr` LIKE ? OR `name` LIKE ? OR `nick` LIKE ?)", $search, $search, $search]
+ );
return DBA::selectToArray('account-user-view', [], $condition, $params);
}
*/
public static function getRandomContact(): array
{
- $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'uid'], [
+ $contact = DBA::selectFirst('contact', ['id', 'network', 'url', 'alias', 'uid'], [
"`uid` = ? AND `network` = ? AND NOT `failed` AND `last-item` > ?",
0, Protocol::DFRN, DateTimeFormat::utc('now - 1 month'),
], ['order' => ['RAND()']]);
WHERE `event`.`id` = ?
AND `event`.`uid` = ?
$sql_perms",
- $event_id, $owner_uid
+ $event_id,
+ $owner_uid
));
if (empty($events)) {
throw new HTTPException\NotFoundException(DI::l10n()->t('Event not found.'));
AND `start` <= ?
$sql_perms",
$owner_uid,
- $start, $start,
+ $start,
+ $start,
$finish
));
$copy = null;
$drop = null;
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') , '', ''];
+ $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'), '', ''];
}
$title = BBCode::convertForUriId($event['uri-id'], Strings::escapeHtml($event['summary']));
}
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;
}
break;
- // Format the exported data as a ics file.
+ // Format the exported data as a ics file.
case "ical":
$o = 'BEGIN:VCALENDAR' . PHP_EOL
. 'VERSION:2.0' . PHP_EOL
$location = self::locationToArray($item['event-location']);
// Construct the profile link (magic-auth).
- $author = ['uid' => 0, 'id' => $item['author-id'],
- 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $author = [
+ 'uid' => 0,
+ 'id' => $item['author-id'],
+ 'network' => $item['author-network'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias']
+ ];
$profile_link = Contact::magicLinkByContact($author);
$tpl = Renderer::getMarkupTemplate('event_stream_item.tpl');
];
// Field list that is used to deliver items via the protocols
- const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
- 'parent-guid', 'conversation', 'received', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
- 'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app',
- 'inform', 'deleted', 'extid', 'post-type', 'post-reason', 'gravity',
- 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
- 'author-id', 'author-addr', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
- 'signed_text', 'network', 'wall', 'contact-id', 'plink', 'origin',
- 'thr-parent-id', 'parent-uri-id', 'quote-uri', 'quote-uri-id', 'postopts', 'pubmail',
- 'event-created', 'event-edited', 'event-start', 'event-finish',
- 'event-summary', 'event-desc', 'event-location', 'event-type',
- 'event-nofinish', 'event-ignore', 'event-id'];
+ const DELIVER_FIELDLIST = [
+ 'uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid',
+ 'parent-guid', 'conversation', 'received', 'created', 'edited', 'verb', 'object-type', 'object', 'target',
+ 'private', 'title', 'body', 'raw-body', 'location', 'coord', 'app',
+ 'inform', 'deleted', 'extid', 'post-type', 'post-reason', 'gravity',
+ 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
+ 'author-id', 'author-addr', 'author-link', 'author-name', 'author-avatar', 'owner-id', 'owner-link', 'contact-uid',
+ 'signed_text', 'network', 'wall', 'contact-id', 'plink', 'origin',
+ 'thr-parent-id', 'parent-uri-id', 'quote-uri', 'quote-uri-id', 'postopts', 'pubmail',
+ 'event-created', 'event-edited', 'event-start', 'event-finish',
+ 'event-summary', 'event-desc', 'event-location', 'event-type',
+ 'event-nofinish', 'event-ignore', 'event-id'
+ ];
// All fields in the item table
- const ITEM_FIELDLIST = ['id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent',
- 'guid', 'uri-id', 'parent-uri-id', 'thr-parent-id', 'conversation', 'vid',
- 'quote-uri', 'quote-uri-id', 'contact-id', 'wall', 'gravity', 'extid', 'psid',
- 'created', 'edited', 'commented', 'received', 'changed', 'verb',
- 'postopts', 'plink', 'resource-id', 'event-id', 'inform',
- 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', 'post-reason',
- 'private', 'pubmail', 'visible', 'starred',
- 'unseen', 'deleted', 'origin', 'mention', 'global', 'network',
- 'title', 'content-warning', 'body', 'location', 'coord', 'app',
- 'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target',
- 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
- 'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'causer-id'];
+ const ITEM_FIELDLIST = [
+ 'id', 'uid', 'parent', 'uri', 'parent-uri', 'thr-parent',
+ 'guid', 'uri-id', 'parent-uri-id', 'thr-parent-id', 'conversation', 'vid',
+ 'quote-uri', 'quote-uri-id', 'contact-id', 'wall', 'gravity', 'extid', 'psid',
+ 'created', 'edited', 'commented', 'received', 'changed', 'verb',
+ 'postopts', 'plink', 'resource-id', 'event-id', 'inform',
+ 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type', 'post-reason',
+ 'private', 'pubmail', 'visible', 'starred',
+ 'unseen', 'deleted', 'origin', 'mention', 'global', 'network',
+ 'title', 'content-warning', 'body', 'location', 'coord', 'app',
+ 'rendered-hash', 'rendered-html', 'object-type', 'object', 'target-type', 'target',
+ 'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
+ 'owner-id', 'owner-link', 'owner-name', 'owner-avatar', 'causer-id'
+ ];
// List of all verbs that don't need additional content data.
// Never reorder or remove entries from this list. Just add new ones at the end, if needed.
Activity::LIKE, Activity::DISLIKE,
Activity::ATTEND, Activity::ATTENDNO, Activity::ATTENDMAYBE,
Activity::FOLLOW,
- Activity::ANNOUNCE];
+ Activity::ANNOUNCE
+ ];
// Privacy levels
const PUBLIC = 0;
}
// We only need to call the line by line update for specific fields
- if (empty($fields['body']) && empty($fields['file']) &&
- empty($fields['attach']) && empty($fields['edited'])) {
+ if (
+ empty($fields['body']) && empty($fields['file']) &&
+ empty($fields['attach']) && empty($fields['edited'])
+ ) {
return $rows;
}
{
Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
// locate item to be deleted
- $fields = ['id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri-id', 'origin',
+ $fields = [
+ 'id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri-id', 'origin',
'deleted', 'resource-id', 'event-id',
- 'verb', 'object-type', 'object', 'target', 'contact-id', 'psid', 'gravity'];
+ 'verb', 'object-type', 'object', 'target', 'contact-id', 'psid', 'gravity'
+ ];
$item = Post::selectFirst($fields, ['id' => $item_id]);
if (!DBA::isResult($item)) {
Logger::info('Item not found.', ['id' => $item_id]);
// If item has attachments, drop them
$attachments = Post\Media::getByURIId($item['uri-id'], [Post\Media::DOCUMENT]);
- foreach($attachments as $attachment) {
+ foreach ($attachments as $attachment) {
if (preg_match('|attach/(\d+)|', $attachment['url'], $matches)) {
Attach::delete(['id' => $matches[1], 'uid' => $item['uid']]);
}
private static function contactId(array $item): int
{
if ($item['uid'] == 0) {
- return $item['author-id'];
+ return $item['owner-id'];
}
if ($item['origin']) {
}
}
- if ($item['gravity'] == self::GRAVITY_PARENT) {
- if (Contact::isSharingByURL($item['owner-link'], $item['uid'], true)) {
- $contact_id = Contact::getIdForURL($item['owner-link'], $item['uid']);
+ foreach (['owner-link', 'author-link', 'causer-link'] as $field) {
+ if (empty($item[$field])) {
+ continue;
+ }
+ if (Contact::isSharingByURL($item[$field], $item['uid'], true)) {
+ $contact_id = Contact::getIdForURL($item[$field], $item['uid']);
} else {
- $contact_id = Contact::getIdForURL($item['owner-link']);
+ $contact_id = Contact::getIdForURL($item[$field]);
}
if (!empty($contact_id)) {
return $contact_id;
}
}
- if (Contact::isSharingByURL($item['author-link'], $item['uid'], true)) {
- $contact_id = Contact::getIdForURL($item['author-link'], $item['uid']);
- } else {
- $contact_id = Contact::getIdForURL($item['author-link']);
- }
-
- if (!empty($contact_id)) {
- return $contact_id;
- }
-
Logger::warning('contact-id could not be fetched, using self contact instead.', ['uid' => $item['uid'], 'item' => $item]);
$self = Contact::selectFirst(['id'], ['self' => true, 'uid' => $item['uid']]);
return $self['id'];
return true;
}
- $condition = ['uri-id' => $item['uri-id'], 'uid' => $item['uid'],
- 'network' => [$item['network'], Protocol::DFRN]];
+ $condition = [
+ 'uri-id' => $item['uri-id'], 'uid' => $item['uid'],
+ 'network' => [$item['network'], Protocol::DFRN]
+ ];
if (Post::exists($condition)) {
Logger::notice('duplicated item with the same uri found.', $condition);
return true;
}
} elseif ($item['network'] == Protocol::OSTATUS) {
// Check for an existing post with the same content. There seems to be a problem with OStatus.
- $condition = ["`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?",
- $item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']];
+ $condition = [
+ "`body` = ? AND `network` = ? AND `created` = ? AND `contact-id` = ? AND `uid` = ?",
+ $item['body'], $item['network'], $item['created'], $item['contact-id'], $item['uid']
+ ];
if (Post::exists($condition)) {
Logger::notice('duplicated item with the same body found.', $item);
return true;
return false;
}
- $condition = ['verb' => Activity::FOLLOW, 'uid' => $item['uid'],
- 'parent-uri' => $item['parent-uri'], 'author-id' => $item['author-id']];
+ $condition = [
+ 'verb' => Activity::FOLLOW, 'uid' => $item['uid'],
+ 'parent-uri' => $item['parent-uri'], 'author-id' => $item['author-id']
+ ];
if (Post::exists($condition)) {
// It happens that we receive multiple follow requests by the same author - we only store one.
Logger::info('Follow: Found existing follow request from author', ['author-id' => $item['author-id'], 'parent-uri' => $item['parent-uri']]);
private static function getDuplicateID(array $item): int
{
if (empty($item['network']) || in_array($item['network'], Protocol::FEDERATED)) {
- $condition = ['`uri-id` = ? AND `uid` = ? AND `network` IN (?, ?, ?, ?)',
+ $condition = [
+ '`uri-id` = ? AND `uid` = ? AND `network` IN (?, ?, ?, ?)',
$item['uri-id'],
$item['uid'],
Protocol::ACTIVITYPUB,
*/
private static function getTopLevelParent(array $item): array
{
- $fields = ['uid', 'uri', 'parent-uri', 'id', 'deleted',
+ $fields = [
+ 'uid', 'uri', 'parent-uri', 'id', 'deleted',
'uri-id', 'parent-uri-id',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
- 'wall', 'private', 'origin', 'author-id'];
+ '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);
return $parent;
}
- $condition = ['uri-id' => $parent['parent-uri-id'],
+ $condition = [
+ 'uri-id' => $parent['parent-uri-id'],
'parent-uri-id' => $parent['parent-uri-id'],
- 'uid' => $parent['uid']];
+ 'uid' => $parent['uid']
+ ];
$params = ['order' => ['id' => false]];
$toplevel_parent = Post::selectFirst($fields, $condition, $params);
// Communities aren't working with the Diaspora protocol
if (($uid != 0) && ($item['network'] == Protocol::DIASPORA)) {
$user = User::getById($uid, ['account-type']);
- if ($user['account-type'] == Contact::TYPE_COMMUNITY) {
+ if ($user['account-type'] == Contact::TYPE_COMMUNITY) {
Logger::info('Community posts are not supported via Diaspora');
return 0;
}
$item['gravity'] = self::getGravity($item);
- $default = ['url' => $item['author-link'], 'name' => $item['author-name'],
- 'photo' => $item['author-avatar'], 'network' => $item['network']];
+ $default = [
+ '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'],
- 'photo' => $item['owner-avatar'], 'network' => $item['network']];
+ $default = [
+ '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);
$item['post-reason'] = self::getPostReason($item);
$item['contact-id'] = self::contactId($item);
- if (!empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
- empty($item['origin']) && self::isTooOld($item)) {
+ if (
+ !empty($item['direction']) && in_array($item['direction'], [Conversation::PUSH, Conversation::RELAY]) &&
+ empty($item['origin']) && self::isTooOld($item)
+ ) {
Logger::info('Item is too old', ['item' => $item]);
return 0;
}
$item['allow_gid'],
$item['deny_cid'],
$item['deny_gid']
- ))->id;
+ )
+ )->id;
if (!empty($item['extid'])) {
$item['external-id'] = ItemURI::getIdByURI($item['extid']);
// Don't relay participation messages
if (($posted_item['verb'] == Activity::FOLLOW) &&
- (!$posted_item['origin'] || ($posted_item['author-id'] != Contact::getPublicIdByUserId($uid)))) {
+ (!$posted_item['origin'] || ($posted_item['author-id'] != Contact::getPublicIdByUserId($uid)))
+ ) {
Logger::info('Participation messages will not be relayed', ['item' => $posted_item['id'], 'uri' => $posted_item['uri'], 'verb' => $posted_item['verb']]);
$transmit = false;
}
*/
private static function setOwnerforResharedItem(array $item)
{
- $parent = Post::selectFirst(['id', 'causer-id', 'owner-id', 'author-id', 'author-link', 'origin', 'post-reason'],
- ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
+ $parent = Post::selectFirst(
+ ['id', 'causer-id', 'owner-id', 'author-id', 'author-link', 'origin', 'post-reason'],
+ ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]
+ );
if (!DBA::isResult($parent)) {
Logger::error('Parent not found', ['uri-id' => $item['thr-parent-id'], 'uid' => $item['uid']]);
return;
}
// Only distribute public items from native networks
- $condition = ['id' => $itemid, 'uid' => 0,
- 'network' => array_merge(Protocol::FEDERATED ,['']),
- 'visible' => true, 'deleted' => false, 'private' => [self::PUBLIC, self::UNLISTED]];
+ $condition = [
+ 'id' => $itemid, 'uid' => 0,
+ 'network' => array_merge(Protocol::FEDERATED, ['']),
+ 'visible' => true, 'deleted' => false, 'private' => [self::PUBLIC, self::UNLISTED]
+ ];
$item = Post::selectFirst(array_merge(self::ITEM_FIELDLIST, ['protocol']), $condition);
if (!DBA::isResult($item)) {
Logger::warning('Item not found', ['condition' => $condition]);
if (($uid != 0) && (($item['gravity'] == self::GRAVITY_PARENT) || $is_reshare) &&
DI::pConfig()->get($uid, 'system', 'accept_only_sharer') == self::COMPLETION_NONE &&
- !in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC, self::PR_ACTIVITY, self::PR_AUDIENCE])) {
+ !in_array($item['post-reason'], [self::PR_FOLLOWER, self::PR_TAG, self::PR_TO, self::PR_CC, self::PR_ACTIVITY, self::PR_AUDIENCE])
+ ) {
Logger::info('Contact is not a follower, thread will not be stored', ['author' => $item['author-link'], 'uid' => $uid, 'uri-id' => $uri_id, 'post-reason' => $item['post-reason']]);
return 0;
}
}
// is it an entry from a connector? Only add an entry for natively connected networks
- if (!in_array($item["network"], array_merge(Protocol::FEDERATED ,['']))) {
+ if (!in_array($item["network"], array_merge(Protocol::FEDERATED, ['']))) {
return;
}
}
// Now do the same for the system wide contacts with uid=0
if ($arr['private'] != self::PRIVATE) {
- Contact::update(['failed' => false, 'local-data' => true, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
- ['id' => $arr['owner-id']]);
+ Contact::update(
+ ['failed' => false, 'local-data' => true, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
+ ['id' => $arr['owner-id']]
+ );
if ($arr['owner-id'] != $arr['author-id']) {
- Contact::update(['failed' => false, 'local-data' => true, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
- ['id' => $arr['author-id']]);
+ Contact::update(
+ ['failed' => false, 'local-data' => true, 'success_update' => $arr['received'], 'last-item' => $arr['received']],
+ ['id' => $arr['author-id']]
+ );
}
}
}
// All hashtags should point to the home server if "local_tags" is activated
if (DI::config()->get('system', 'local_tags')) {
- $body = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
- "#[url=" . DI::baseUrl() . "/search?tag=$2]$2[/url]", $body);
+ $body = preg_replace(
+ "/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ "#[url=" . DI::baseUrl() . "/search?tag=$2]$2[/url]",
+ $body
+ );
}
// mask hashtags inside of url, bookmarks and attachments to avoid urls in urls
- $body = preg_replace_callback("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ $body = preg_replace_callback(
+ "/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
function ($match) {
return ("[url=" . str_replace("#", "#", $match[1]) . "]" . str_replace("#", "#", $match[2]) . "[/url]");
- }, $body);
+ },
+ $body
+ );
- $body = preg_replace_callback("/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",
+ $body = preg_replace_callback(
+ "/\[bookmark\=([$URLSearchString]*)\](.*?)\[\/bookmark\]/ism",
function ($match) {
return ("[bookmark=" . str_replace("#", "#", $match[1]) . "]" . str_replace("#", "#", $match[2]) . "[/bookmark]");
- }, $body);
+ },
+ $body
+ );
- $body = preg_replace_callback("/\[attachment (.*?)\](.*?)\[\/attachment\]/ism",
+ $body = preg_replace_callback(
+ "/\[attachment (.*?)\](.*?)\[\/attachment\]/ism",
function ($match) {
return ("[attachment " . str_replace("#", "#", $match[1]) . "]" . $match[2] . "[/attachment]");
- }, $body);
+ },
+ $body
+ );
// Repair recursive urls
- $body = preg_replace("/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
- "#$2", $body);
+ $body = preg_replace(
+ "/#\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+ "#$2",
+ $body
+ );
foreach ($tags as $tag) {
if ((strpos($tag, '#') !== 0) || strpos($tag, '[url=') || strlen($tag) < 2 || $tag[1] == '#') {
}
$datarray2 = $datarray;
- Logger::info('remote-self start', ['contact' => $contact['url'], 'remote_self'=> $contact['remote_self'], 'item' => $datarray]);
+ Logger::info('remote-self start', ['contact' => $contact['url'], 'remote_self' => $contact['remote_self'], 'item' => $datarray]);
- $self = DBA::selectFirst('contact', ['id', 'name', 'url', 'thumb'],
- ['uid' => $contact['uid'], 'self' => true]);
+ $self = DBA::selectFirst(
+ 'contact',
+ ['id', 'name', 'url', 'thumb'],
+ ['uid' => $contact['uid'], 'self' => true]
+ );
if (!DBA::isResult($self)) {
Logger::error('Self contact not found', ['uid' => $contact['uid']]);
return false;
// Store the original post
$result = self::insert($datarray2);
- Logger::info('remote-self post original item', ['contact' => $contact['url'], 'result'=> $result, 'item' => $datarray2]);
+ Logger::info('remote-self post original item', ['contact' => $contact['url'], 'result' => $result, 'item' => $datarray2]);
} else {
$datarray['private'] = self::PUBLIC;
$datarray['app'] = 'Feed';
if (($obj1['allow_cid'] == $obj2['allow_cid'])
&& ($obj1['allow_gid'] == $obj2['allow_gid'])
&& ($obj1['deny_cid'] == $obj2['deny_cid'])
- && ($obj1['deny_gid'] == $obj2['deny_gid'])) {
+ && ($obj1['deny_gid'] == $obj2['deny_gid'])
+ ) {
return true;
}
return;
}
- $condition = ["`uid` = ? AND NOT `deleted` AND `gravity` = ?",
- $uid, self::GRAVITY_PARENT];
+ $condition = [
+ "`uid` = ? AND NOT `deleted` AND `gravity` = ?",
+ $uid, self::GRAVITY_PARENT
+ ];
/*
* $expire_network_only = save your own wall posts
return false;
}
- $condition = ["`uid` = ? AND `wall` = ? AND NOT `deleted` AND `visible` AND `received` >= ?",
- $uid, $wall, $user['register_date']];
+ $condition = [
+ "`uid` = ? AND `wall` = ? AND NOT `deleted` AND `visible` AND `received` >= ?",
+ $uid, $wall, $user['register_date']
+ ];
$params = ['order' => ['received' => false]];
$thread = Post::selectFirstThread(['received'], $condition, $params);
if (DBA::isResult($thread)) {
$vids = Verb::getID($activity);
}
- $condition = ['vid' => $vids, 'deleted' => false, 'gravity' => self::GRAVITY_ACTIVITY,
- 'author-id' => $author_id, 'uid' => $uid, 'thr-parent-id' => $uri_id];
+ $condition = [
+ '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);
if (DBA::isResult($like_item)) {
// Profile owner - everything is visible
$condition = [];
} elseif ($remote_user) {
- // Authenticated visitor - fetch the matching permissionsets
+ // Authenticated visitor - fetch the matching permissionsets
$permissionSets = DI::permissionSet()->selectByContactId($remote_user, $owner_id);
if (!empty($set)) {
- $condition = ["(`private` != ? OR (`private` = ? AND `wall`
+ $condition = [
+ "(`private` != ? OR (`private` = ? AND `wall`
AND `psid` IN (" . implode(', ', array_fill(0, count($set), '?')) . ")))",
- self::PRIVATE, self::PRIVATE];
+ self::PRIVATE, self::PRIVATE
+ ];
$condition = array_merge($condition, $permissionSets->column('id'));
}
}
$rendered_hash = $item['rendered-hash'] ?? '';
$rendered_html = $item['rendered-html'] ?? '';
- if ($rendered_hash == ''
+ if (
+ $rendered_hash == ''
|| $rendered_html == ''
|| $rendered_hash != hash('md5', BBCode::VERSION . '::' . $body)
|| DI::config()->get('system', 'ignore_cache')
}
foreach ([0, 1, 2] as $size) {
- if (preg_match('#/photo/.*-' . $size . '\.#ism', $url) &&
- strpos(preg_replace('#(/photo/.*)-[012]\.#ism', '$1-' . $size . '.', $body), $url)) {
+ if (
+ preg_match('#/photo/.*-' . $size . '\.#ism', $url) &&
+ strpos(preg_replace('#(/photo/.*)-[012]\.#ism', '$1-' . $size . '.', $body), $url)
+ ) {
return true;
}
}
'text' => '',
'title' => $attachment['name'] ?? '',
'type' => 'link',
- 'url' => $attachment['url']];
+ 'url' => $attachment['url']
+ ];
if ($preview && !empty($attachment['preview'])) {
if ($attachment['preview-width'] >= 500) {
continue;
}
- $author = ['uid' => 0, 'id' => $item['author-id'],
- 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $author = [
+ 'uid' => 0,
+ 'id' => $item['author-id'],
+ 'network' => $item['author-network'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias']
+ ];
$the_url = Contact::magicLinkByContact($author, $attachment['url']);
$title = Strings::escapeHtml(trim(($attachment['description'] ?? '') ?: $attachment['url']));
$summary = DI::l10n()->tt('%d voter.', '%d voters.', $question['voters']);
} elseif (!empty($question['endtime'])) {
$summary = DI::l10n()->t('Poll end: %s', Temporal::getRelativeDate($question['endtime']));
- } else {
+ } else {
$summary = '';
}
'$options' => $options,
'$summary' => $summary,
]);
- }
+ }
DI::profiler()->stopRecording();
return $content;
}
];
if (!empty($plink) && ($item['private'] == self::PRIVATE)) {
- $author = ['uid' => 0, 'id' => $item['author-id'],
- 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $author = [
+ 'uid' => 0,
+ 'id' => $item['author-id'],
+ 'network' => $item['author-network'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias'],
+ ];
$plink = Contact::magicLinkByContact($author, $plink);
}
DI::page()['aside'] .= $vcard_widget . $findpeople_widget . $follow_widget . $rel_widget . $circles_widget . $networks_widget . $account_widget;
$tpl = Renderer::getMarkupTemplate('contacts-head.tpl');
- DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
- ]);
+ DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, []);
$o = '';
Nav::setSelected('contact');
$tabs_html = Renderer::replaceMacros($tabs_tpl, ['$tabs' => $tabs]);
switch ($rel) {
- case 'followers': $header = DI::l10n()->t('Followers'); break;
- case 'following': $header = DI::l10n()->t('Following'); break;
- case 'mutuals': $header = DI::l10n()->t('Mutual friends'); break;
- case 'nothing': $header = DI::l10n()->t('No relationship'); break;
- default: $header = DI::l10n()->t('Contacts');
+ case 'followers':
+ $header = DI::l10n()->t('Followers');
+ break;
+ case 'following':
+ $header = DI::l10n()->t('Following');
+ break;
+ case 'mutuals':
+ $header = DI::l10n()->t('Mutual friends');
+ break;
+ case 'nothing':
+ $header = DI::l10n()->t('No relationship');
+ break;
+ default:
+ $header = DI::l10n()->t('Contacts');
}
switch ($type) {
- case 'pending': $header .= ' - ' . DI::l10n()->t('Pending'); break;
- case 'blocked': $header .= ' - ' . DI::l10n()->t('Blocked'); break;
- case 'hidden': $header .= ' - ' . DI::l10n()->t('Hidden'); break;
- case 'ignored': $header .= ' - ' . DI::l10n()->t('Ignored'); break;
- case 'collapsed': $header .= ' - ' . DI::l10n()->t('Collapsed'); break;
- case 'archived': $header .= ' - ' . DI::l10n()->t('Archived'); break;
+ case 'pending':
+ $header .= ' - ' . DI::l10n()->t('Pending');
+ break;
+ case 'blocked':
+ $header .= ' - ' . DI::l10n()->t('Blocked');
+ break;
+ case 'hidden':
+ $header .= ' - ' . DI::l10n()->t('Hidden');
+ break;
+ case 'ignored':
+ $header .= ' - ' . DI::l10n()->t('Ignored');
+ break;
+ case 'collapsed':
+ $header .= ' - ' . DI::l10n()->t('Collapsed');
+ break;
+ case 'archived':
+ $header .= ' - ' . DI::l10n()->t('Archived');
+ break;
}
$header .= $nets ? ' - ' . ContactSelector::networkToName($nets) : '';
'id' => 'media-tab',
'accesskey' => 'd',
],
- ['label' => DI::l10n()->t('Contacts'),
+ [
+ 'label' => DI::l10n()->t('Contacts'),
'url' => 'contact/' . $pcid . '/contacts',
'sel' => (($active_tab == self::TAB_CONTACTS) ? 'active' : ''),
'title' => DI::l10n()->t('View all known contacts'),
];
if (!empty($contact['network']) && in_array($contact['network'], [Protocol::FEED, Protocol::MAIL]) && ($cid != $pcid)) {
- $tabs[] = ['label' => DI::l10n()->t('Advanced'),
+ $tabs[] = [
+ 'label' => DI::l10n()->t('Advanced'),
'url' => 'contact/' . $cid . '/advanced/',
'sel' => (($active_tab == self::TAB_ADVANCED) ? 'active' : ''),
'title' => DI::l10n()->t('Advanced Contact Settings'),
Strings::normaliseLink($url), Strings::normaliseLink($url), $url,
];
- $contact = $this->database->selectFirst('contact', ['url', 'id', 'uid', 'network', 'addr', 'name'], $condition);
+ $contact = $this->database->selectFirst('contact', ['url', 'alias', 'id', 'uid', 'network', 'addr', 'name'], $condition);
if (!$this->database->isResult($contact)) {
$this->systemMessages->addNotice($this->t("You aren't following this contact."));
$this->baseUrl->redirect($base_return_path);
}
$this->writable = $this->getDataValue('writable') || $this->getDataValue('self');
- $author = ['uid' => 0, 'id' => $this->getDataValue('author-id'),
+ $author = [
+ 'uid' => 0,
+ 'id' => $this->getDataValue('author-id'),
'network' => $this->getDataValue('author-network'),
- 'url' => $this->getDataValue('author-link')];
+ 'url' => $this->getDataValue('author-link'),
+ 'alias' => $this->getDataValue('author-alias')
+ ];
$this->redirect_url = Contact::magicLinkByContact($author);
if (!$this->isToplevel()) {
$this->threaded = true;
}
if (DI::userSession()->isAuthenticated()) {
- $author = ['uid' => 0, 'id' => $item['author-id'],
- 'network' => $item['author-network'], 'url' => $item['author-link']];
+ $author = [
+ 'uid' => 0,
+ 'id' => $item['author-id'],
+ 'network' => $item['author-network'],
+ 'url' => $item['author-link'],
+ 'alias' => $item['author-alias'],
+ ];
$profile_link = Contact::magicLinkByContact($author);
} else {
$profile_link = $item['author-link'];
}
if ($conv->isWritable()) {
- $buttons['like'] = [DI::l10n()->t("I like this \x28toggle\x29") , DI::l10n()->t('Like')];
+ $buttons['like'] = [DI::l10n()->t("I like this \x28toggle\x29"), DI::l10n()->t('Like')];
$buttons['dislike'] = [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t('Dislike')];
if ($shareable) {
$buttons['share'] = [DI::l10n()->t('Quote share this'), DI::l10n()->t('Quote Share')];
// Fetching of Diaspora posts doesn't always work. There are issues with reshares and possibly comments
if (!DI::userSession()->getLocalUserId() && ($item['network'] != Protocol::DIASPORA) && !empty(DI::session()->get('remote_comment'))) {
- $remote_comment = [DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('Remote comment'),
- str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))];
+ $remote_comment = [
+ DI::l10n()->t('Comment this item on your system'), DI::l10n()->t('Remote comment'),
+ str_replace('{uri}', urlencode($item['uri']), DI::session()->get('remote_comment'))
+ ];
// Ensure to either display the remote comment or the local activities
$buttons = [];
$title = DI::l10n()->t('Reacted with %s by: %s', $element['emoji'], $actors);
$icon = [];
break;
- break;
}
$emojis[$index] = ['emoji' => $element['emoji'], 'total' => $element['total'], 'title' => $title, 'icon' => $icon];
}
if ($item->getDataValue('network') === Protocol::MAIL && DI::userSession()->getLocalUserId() != $item->getDataValue('uid')) {
Logger::warning('Post object does not belong to local user', ['post' => $item, 'local_user' => DI::userSession()->getLocalUserId()]);
return false;
- } elseif (DI::activity()->match($item->getDataValue('verb'), Activity::LIKE) ||
- DI::activity()->match($item->getDataValue('verb'), Activity::DISLIKE)) {
+ } elseif (
+ DI::activity()->match($item->getDataValue('verb'), Activity::LIKE) ||
+ DI::activity()->match($item->getDataValue('verb'), Activity::DISLIKE)
+ ) {
Logger::warning('Post objects is a like/dislike', ['post' => $item]);
return false;
}
}
$profile = Contact::getByURL($term['url'], false, ['addr', 'contact-type']);
- if (!empty($profile['addr']) && (($profile['contact-type'] ?? Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
- ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])) {
+ if (
+ !empty($profile['addr']) && (($profile['contact-type'] ?? Contact::TYPE_UNKNOWN) != Contact::TYPE_COMMUNITY) &&
+ ($profile['addr'] != $owner['addr']) && !strstr($text, $profile['addr'])
+ ) {
$text .= '@' . $profile['addr'] . ' ';
}
}
'id' => $this->getDataValue('owner-id'),
'network' => $this->getDataValue('owner-network'),
'url' => $this->getDataValue('owner-link'),
+ 'alias' => $this->getDataValue('owner-alias'),
];
$this->owner_url = Contact::magicLinkByContact($owner);
}
// This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) {
- define('DB_UPDATE_VERSION', 1520);
+ define('DB_UPDATE_VERSION', 1521);
}
return [
"author-addr" => ["author", "addr"],
"author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
"author-nick" => ["author", "nick"],
+ "author-alias" => ["author", "alias"],
"author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
"author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"],
"owner-addr" => ["owner", "addr"],
"owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
"owner-nick" => ["owner", "nick"],
+ "owner-alias" => ["owner", "alias"],
"owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
"owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"],
"author-addr" => ["author", "addr"],
"author-name" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`name` != '', `contact`.`name`, `author`.`name`)",
"author-nick" => ["author", "nick"],
+ "author-alias" => ["author", "alias"],
"author-avatar" => "IF (`contact`.`url` = `author`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `author`.`thumb`)",
"author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"],
"owner-addr" => ["owner", "addr"],
"owner-name" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`name` != '', `contact`.`name`, `owner`.`name`)",
"owner-nick" => ["owner", "nick"],
+ "owner-alias" => ["owner", "alias"],
"owner-avatar" => "IF (`contact`.`url` = `owner`.`url` AND `contact`.`thumb` != '', `contact`.`thumb`, `owner`.`thumb`)",
"owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"],
"author-addr" => ["author", "addr"],
"author-name" => ["author", "name"],
"author-nick" => ["author", "nick"],
+ "author-alias" => ["author", "alias"],
"author-avatar" => ["author", "thumb"],
"author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"],
"owner-addr" => ["owner", "addr"],
"owner-name" => ["owner", "name"],
"owner-nick" => ["owner", "nick"],
+ "owner-alias" => ["owner", "alias"],
"owner-avatar" => ["owner", "thumb"],
"owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"],
"author-addr" => ["author", "addr"],
"author-name" => ["author", "name"],
"author-nick" => ["author", "nick"],
+ "author-alias" => ["author", "alias"],
"author-avatar" => ["author", "thumb"],
"author-network" => ["author", "network"],
"author-blocked" => ["author", "blocked"],
"owner-addr" => ["owner", "addr"],
"owner-name" => ["owner", "name"],
"owner-nick" => ["owner", "nick"],
+ "owner-alias" => ["owner", "alias"],
"owner-avatar" => ["owner", "thumb"],
"owner-network" => ["owner", "network"],
"owner-blocked" => ["owner", "blocked"],