<?php /* * This file is part of fof/cookie-consent. * * Copyright (c) FriendsOfFlarum. * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Ubuntuhu\Map\Listeners; use Flarum\Api\Serializer\ForumSerializer; use Flarum\User\User; use Flarum\Settings\SettingsRepositoryInterface; class LoadSettingsFromDatabase { /** * @var string */ /** * @var array */ /** * @var SettingsRepositoryInterface */ /** * LoadSettingsFromDatabase constructor. * * @param SettingsRepositoryInterface $settings */ protected $settings; public function __construct(SettingsRepositoryInterface $settings) { $this->settings = $settings; } public function __invoke(ForumSerializer $serializer): array { $attributes = []; $actor = $serializer->getActor(); $date = time(); $nickname = (!empty($actor->nickname))?$actor->nickname:$actor->username; $secret = $this->settings->get('ubuntuhu-map.gidSecret'); $sig = sha1($actor->id.' '.$nickname.' '.$date.' '.$secret); $attributes['url'] = 'https://nostupidgifts.com/UbuntuMap/ubuntumap.php?uid='.$actor->id.'&name='.$nickname.'&ts='.$date.'&sig='.$sig; $attributes['consentText'] = $this->settings->get('ubuntuhu-map.consentText'); $attributes['contentTitle'] = $this->settings->get('ubuntuhu-map.contentTitle'); $attributes['contentTitleIcon'] = $this->settings->get('ubuntuhu-map.contentTitleIcon'); $attributes['contentMenuTitle'] = $this->settings->get('ubuntuhu-map.contentMenuTitle'); $attributes['contentMenuTitleIcon'] = $this->settings->get('ubuntuhu-map.contentMenuTitleIcon'); $attributes['formButtonTitle'] = $this->settings->get('ubuntuhu-map.formButtonTitle'); return $attributes; } }