diff --git a/Controller/BackendController.php b/Controller/BackendController.php index 1d96028..b542a1e 100755 --- a/Controller/BackendController.php +++ b/Controller/BackendController.php @@ -21,6 +21,7 @@ use Modules\Profile\Models\SettingsEnum; use phpOMS\Asset\AssetType; use phpOMS\Contract\RenderableInterface; use phpOMS\Localization\NullLocalization; +use phpOMS\Message\Http\RequestStatusCode; use phpOMS\Message\RequestAbstract; use phpOMS\Message\ResponseAbstract; use phpOMS\Views\View; @@ -109,6 +110,25 @@ final class BackendController extends Controller { $view = new View($this->app->l11nManager, $request, $response); + $mapperQuery = ProfileMapper::get() + ->with('account') + ->with('account/addresses') + ->with('image'); + + /** @var \Modules\Profile\Models\Profile $profile */ + $profile = $request->hasData('for') + ? $mapperQuery->where('account', (int) $request->getData('for'))->execute() + : $mapperQuery->where('id', (int) $request->getData('id'))->execute(); + + $view->data['account'] = $profile; + + if ($profile->id === 0) { + $response->header->status = RequestStatusCode::R_404; + $view->setTemplate('/Web/Backend/Error/404'); + + return $view; + } + /** @var \phpOMS\Model\Html\Head $head */ $head = $response->data['Content']->head; $head->addAsset(AssetType::CSS, '/Modules/Calendar/Theme/Backend/css/styles.css?v=' . self::VERSION); @@ -124,18 +144,6 @@ final class BackendController extends Controller $calendarView->setTemplate('/Modules/Calendar/Theme/Backend/Components/Calendar/mini'); $view->data['calendar'] = $calendarView; - $mapperQuery = ProfileMapper::get() - ->with('account') - ->with('account/addresses') - ->with('image'); - - /** @var \Modules\Profile\Models\Profile $profile */ - $profile = $request->hasData('for') - ? $mapperQuery->where('account', (int) $request->getData('for'))->execute() - : $mapperQuery->where('id', (int) $request->getData('id'))->execute(); - - $view->data['account'] = $profile; - $l11n = null; if ($profile->account->id === $request->header->account) { /** @var \phpOMS\Localization\Localization $l11n */ diff --git a/Theme/Backend/profile-list.tpl.php b/Theme/Backend/profile-list.tpl.php index 4cae7c5..ad32a72 100755 --- a/Theme/Backend/profile-list.tpl.php +++ b/Theme/Backend/profile-list.tpl.php @@ -64,7 +64,7 @@ $next = empty($accounts) ? '{/base}/profile/list' : '{/base}/profile/list?{? <?= $this->getHtml('IMG_alt_user'); ?> printHtml($account->account->name3 . ' ' . $account->account->name2 . ' ' . $account->account->name1); ?> printHtml($account->account->getLastActive()->format('Y-m-d')); ?> diff --git a/Theme/Backend/profile-view.tpl.php b/Theme/Backend/profile-view.tpl.php index 3289fa1..70982af 100644 --- a/Theme/Backend/profile-view.tpl.php +++ b/Theme/Backend/profile-view.tpl.php @@ -60,7 +60,7 @@ echo $this->data['nav']->render(); alt="getHtml('ProfileImage'); ?>" itemprop="logo" loading="lazy" src="image->id === 0 - ? UriFactory::build($this->getData('defaultImage')->getPath()) + ? UriFactory::build($this->data['defaultImage']->getPath()) : UriFactory::build($profile->image->getPath()); ?>" width="100px"> request->header->account === $profile->account->id) : ?>