X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FContact%2FPoke.php;h=23ec95a435ff9f60c96f9d5dad117e9263f48481;hb=23c56b108b43bd1964d78993fb7a164b09fc30f1;hp=9f2ae7bde684e76e3e7e8ad2d7fcc91e2ec4fc61;hpb=5e0b4b8a8f39f28fcfc2812e66223d95c92431a0;p=friendica.git diff --git a/src/Module/Contact/Poke.php b/src/Module/Contact/Poke.php index 9f2ae7bde6..23ec95a435 100644 --- a/src/Module/Contact/Poke.php +++ b/src/Module/Contact/Poke.php @@ -3,6 +3,7 @@ namespace Friendica\Module\Contact; use Friendica\BaseModule; +use Friendica\Content\Widget; use Friendica\Core\Hook; use Friendica\Core\Logger; use Friendica\Core\Renderer; @@ -10,15 +11,16 @@ use Friendica\Core\System; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model; +use Friendica\Model\Contact; use Friendica\Network\HTTPException; use Friendica\Protocol\Activity; use Friendica\Util\XML; class Poke extends BaseModule { - public static function post(array $parameters = []) + public function post() { - if (!local_user() || empty($parameters['id'])) { + if (!local_user() || empty($this->parameters['id'])) { return self::postReturn(false); } @@ -37,28 +39,29 @@ class Poke extends BaseModule $activity = Activity::POKE . '#' . urlencode($verbs[$verb][0]); - $contact_id = intval($parameters['id']); + $contact_id = intval($this->parameters['id']); if (!$contact_id) { return self::postReturn(false); } Logger::info('verb ' . $verb . ' contact ' . $contact_id); - $contact = DBA::selectFirst('contact', ['id', 'name'], ['id' => $parameters['id'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => $this->parameters['id'], 'uid' => local_user()]); if (!DBA::isResult($contact)) { return self::postReturn(false); } $a = DI::app(); - $private = (!empty($_GET['private']) ? intval($_GET['private']) : Model\Item::PUBLIC); + $private = !empty($_POST['private']) ? Model\Item::PRIVATE : Model\Item::PUBLIC; - $allow_cid = ($private ? '<' . $contact['id']. '>' : $a->user['allow_cid']); - $allow_gid = ($private ? '' : $a->user['allow_gid']); - $deny_cid = ($private ? '' : $a->user['deny_cid']); - $deny_gid = ($private ? '' : $a->user['deny_gid']); + $user = Model\User::getById($a->getLoggedInUserId()); + $allow_cid = ($private ? '<' . $contact['id']. '>' : $user['allow_cid']); + $allow_gid = ($private ? '' : $user['allow_gid']); + $deny_cid = ($private ? '' : $user['deny_cid']); + $deny_gid = ($private ? '' : $user['deny_gid']); - $actor = $a->contact; + $actor = Contact::getById($a->getContactId()); $uri = Model\Item::newURI($uid); @@ -67,7 +70,6 @@ class Poke extends BaseModule $arr['guid'] = System::createUUID(); $arr['uid'] = $uid; $arr['uri'] = $uri; - $arr['parent-uri'] = $uri; $arr['wall'] = 1; $arr['contact-id'] = $actor['id']; $arr['owner-name'] = $actor['name']; @@ -87,7 +89,7 @@ class Poke extends BaseModule $arr['object-type'] = Activity\ObjectType::PERSON; $arr['origin'] = 1; - $arr['body'] = '[url=' . $actor['url'] . ']' . $actor['name'] . '[/url]' . ' ' . $verbs[$verb][2] . ' ' . '[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; + $arr['body'] = '@[url=' . $actor['url'] . ']' . $actor['name'] . '[/url]' . ' ' . $verbs[$verb][2] . ' ' . '@[url=' . $contact['url'] . ']' . $contact['name'] . '[/url]'; $arr['object'] = '' . Activity\ObjectType::PERSON . '' . XML::escape($contact['name']) . '' . XML::escape($contact['url']) . ''; $arr['object'] .= '' . XML::escape('') . "\n"; @@ -121,22 +123,22 @@ class Poke extends BaseModule return $success; } - public static function content(array $parameters = []) + public function content(): string { if (!local_user()) { throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $parameters['id'], 'uid' => local_user()]); + $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $this->parameters['id'], 'uid' => local_user()]); if (!DBA::isResult($contact)) { throw new HTTPException\NotFoundException(); } - Model\Profile::load(DI::app(), '', Model\Contact::getByURL($contact["url"], false)); + DI::page()['aside'] = Widget\VCard::getHTML(Model\Contact::getByURL($contact["url"], false)); $verbs = []; foreach (DI::l10n()->getPokeVerbs() as $verb => $translations) {