|
|
@ -3,6 +3,7 @@
|
|
|
|
namespace Engelsystem\Controllers\Admin;
|
|
|
|
namespace Engelsystem\Controllers\Admin;
|
|
|
|
|
|
|
|
|
|
|
|
use Engelsystem\Controllers\BaseController;
|
|
|
|
use Engelsystem\Controllers\BaseController;
|
|
|
|
|
|
|
|
use Engelsystem\Controllers\CleanupModel;
|
|
|
|
use Engelsystem\Controllers\HasUserNotifications;
|
|
|
|
use Engelsystem\Controllers\HasUserNotifications;
|
|
|
|
use Engelsystem\Helpers\Authenticator;
|
|
|
|
use Engelsystem\Helpers\Authenticator;
|
|
|
|
use Engelsystem\Http\Redirector;
|
|
|
|
use Engelsystem\Http\Redirector;
|
|
|
@ -14,6 +15,7 @@ use Psr\Log\LoggerInterface;
|
|
|
|
class NewsController extends BaseController
|
|
|
|
class NewsController extends BaseController
|
|
|
|
{
|
|
|
|
{
|
|
|
|
use HasUserNotifications;
|
|
|
|
use HasUserNotifications;
|
|
|
|
|
|
|
|
use CleanupModel;
|
|
|
|
|
|
|
|
|
|
|
|
/** @var Authenticator */
|
|
|
|
/** @var Authenticator */
|
|
|
|
protected $auth;
|
|
|
|
protected $auth;
|
|
|
@ -58,6 +60,7 @@ class NewsController extends BaseController
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param Request $request
|
|
|
|
* @param Request $request
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function edit(Request $request): Response
|
|
|
|
public function edit(Request $request): Response
|
|
|
@ -66,6 +69,17 @@ class NewsController extends BaseController
|
|
|
|
$news = $this->news->find($id);
|
|
|
|
$news = $this->news->find($id);
|
|
|
|
$isMeeting = $request->get('meeting', false);
|
|
|
|
$isMeeting = $request->get('meeting', false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->showEdit($news, $isMeeting);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param News|null $news
|
|
|
|
|
|
|
|
* @param bool $isMeetingDefault
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return Response
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected function showEdit(?News $news, bool $isMeetingDefault = false): Response
|
|
|
|
|
|
|
|
{
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
$news
|
|
|
|
$news
|
|
|
|
&& !$this->auth->can('admin_news_html')
|
|
|
|
&& !$this->auth->can('admin_news_html')
|
|
|
@ -74,14 +88,22 @@ class NewsController extends BaseController
|
|
|
|
$this->addNotification('news.edit.contains-html', 'warnings');
|
|
|
|
$this->addNotification('news.edit.contains-html', 'warnings');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($news) {
|
|
|
|
|
|
|
|
$this->cleanupModelNullValues($news);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $this->response->withView(
|
|
|
|
return $this->response->withView(
|
|
|
|
'pages/news/edit.twig',
|
|
|
|
'pages/news/edit.twig',
|
|
|
|
['news' => $news, 'is_meeting' => $news ? $news->is_meeting : $isMeeting] + $this->getNotifications(),
|
|
|
|
[
|
|
|
|
|
|
|
|
'news' => $news,
|
|
|
|
|
|
|
|
'is_meeting' => $news ? $news->is_meeting : $isMeetingDefault
|
|
|
|
|
|
|
|
] + $this->getNotifications(),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param Request $request
|
|
|
|
* @param Request $request
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public function save(Request $request): Response
|
|
|
|
public function save(Request $request): Response
|
|
|
@ -95,6 +117,7 @@ class NewsController extends BaseController
|
|
|
|
'text' => 'required',
|
|
|
|
'text' => 'required',
|
|
|
|
'is_meeting' => 'optional|checked',
|
|
|
|
'is_meeting' => 'optional|checked',
|
|
|
|
'delete' => 'optional|checked',
|
|
|
|
'delete' => 'optional|checked',
|
|
|
|
|
|
|
|
'preview' => 'optional|checked',
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_null($data['delete'])) {
|
|
|
|
if (!is_null($data['delete'])) {
|
|
|
@ -123,6 +146,11 @@ class NewsController extends BaseController
|
|
|
|
$news->title = $data['title'];
|
|
|
|
$news->title = $data['title'];
|
|
|
|
$news->text = $data['text'];
|
|
|
|
$news->text = $data['text'];
|
|
|
|
$news->is_meeting = !is_null($data['is_meeting']);
|
|
|
|
$news->is_meeting = !is_null($data['is_meeting']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!is_null($data['preview'])) {
|
|
|
|
|
|
|
|
return $this->showEdit($news);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$news->save();
|
|
|
|
$news->save();
|
|
|
|
|
|
|
|
|
|
|
|
$this->log->info(
|
|
|
|
$this->log->info(
|
|
|
|