* Returns the data array for the photo menu of a given contact
*
* @param array $contact contact
- * @param int $uid optional, default 0
+ * @param int $uid Visitor user id
* @return array
* @throws HTTPException\InternalServerErrorException
* @throws \ImagickException
*/
- public static function photoMenu(array $contact, int $uid = 0): array
+ public static function photoMenu(array $contact, int $uid): array
{
- $pm_url = '';
- $status_link = '';
- $photos_link = '';
-
- if ($uid == 0) {
- $uid = DI::userSession()->getLocalUserId();
+ // Anonymous visitor
+ if (!$uid) {
+ return ['profile' => [DI::l10n()->t('View Profile'), self::magicLinkByContact($contact), true]];
}
- if (empty($contact['uid']) || ($contact['uid'] != $uid)) {
- if ($uid == 0) {
- $profile_link = self::magicLinkByContact($contact);
- $menu = ['profile' => [DI::l10n()->t('View Profile'), $profile_link, true]];
-
- return $menu;
- }
-
- // Look for our own contact if the uid doesn't match and isn't public
- $contact_own = DBA::selectFirst('contact', [], ['nurl' => $contact['nurl'], 'network' => $contact['network'], 'uid' => $uid]);
- if (DBA::isResult($contact_own)) {
- return self::photoMenu($contact_own, $uid);
- }
- }
+ $pm_url = '';
+ $status_link = '';
+ $photos_link = '';
$sparkle = false;
if (($contact['network'] === Protocol::DFRN) && !$contact['self'] && empty($contact['pending'])) {
- $sparkle = true;
+ $sparkle = true;
$profile_link = 'contact/redir/' . $contact['id'];
} else {
$profile_link = $contact['url'];
}
if ($sparkle) {
- $status_link = $profile_link . '/status';
- $photos_link = $profile_link . '/photos';
+ $status_link = $profile_link . '/status';
+ $photos_link = $profile_link . '/photos';
$profile_link = $profile_link . '/profile';
}
}
$contact_url = 'contact/' . $contact['id'];
-
$posts_link = 'contact/' . $contact['id'] . '/conversations';
- $follow_link = '';
+ $follow_link = '';
$unfollow_link = '';
if (!$contact['self'] && Protocol::supportsFollow($contact['network'])) {
if ($contact['uid'] && in_array($contact['rel'], [self::SHARING, self::FRIEND])) {
$unfollow_link = 'contact/unfollow?url=' . urlencode($contact['url']) . '&auto=1';
- } elseif(!$contact['pending']) {
+ } elseif (!$contact['pending']) {
$follow_link = 'contact/follow?url=' . urlencode($contact['url']) . '&auto=1';
}
}
*/
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'])) {
try {
- $intro = DI::intro()->selectForContact($contact['id']);
+ $intro = DI::intro()->selectForContact($contact['id']);
$menu['follow'] = [DI::l10n()->t('Approve'), 'notifications/intros/' . $intro->id, true];
} catch (IntroductionNotFoundException $exception) {
DI::logger()->error('Pending contact doesn\'t have an introduction.', ['exception' => $exception]);
use Friendica\Model;
use Friendica\Model\User;
use Friendica\Module\Security\Login;
+use Friendica\Network\HTTPException\InternalServerErrorException;
use Friendica\Network\HTTPException\NotFoundException;
/**
*
* @param array $contact Contact array
* @return array Template fields
+ * @throws InternalServerErrorException
+ * @throws \ImagickException
*/
- public static function getContactTemplateVars(array $contact)
+ public static function getContactTemplateVars(array $contact): array
{
$alt_text = '';
if (!empty($contact['url']) && isset($contact['uid']) && ($contact['uid'] == 0) && DI::userSession()->getLocalUserId()) {
$personal = Model\Contact::getByURL($contact['url'], false, ['uid', 'rel', 'self'], DI::userSession()->getLocalUserId());
if (!empty($personal)) {
- $contact['uid'] = $personal['uid'];
- $contact['rel'] = $personal['rel'];
+ $contact['uid'] = $personal['uid'];
+ $contact['rel'] = $personal['rel'];
$contact['self'] = $personal['self'];
}
}
if ($contact['self']) {
$alt_text = DI::l10n()->t('This is you');
- $url = $contact['url'];
- $sparkle = '';
+ $url = $contact['url'];
+ $sparkle = '';
}
return [
'id' => $contact['id'],
'url' => $url,
'img_hover' => DI::l10n()->t('Visit %s\'s profile [%s]', $contact['name'], $contact['url']),
- 'photo_menu' => Model\Contact::photoMenu($contact),
+ 'photo_menu' => Model\Contact::photoMenu($contact, DI::userSession()->getLocalUserId()),
'thumb' => Model\Contact::getThumb($contact, true),
'alt_text' => $alt_text,
'name' => $contact['name'],