Файловый менеджер - Редактировать - /var/www/html/components/com_kunena/src/Controllers/AnnouncementController.php
Ðазад
<?php /** * Kunena Component * * @package Kunena.Site * @subpackage Controllers * * @copyright Copyright (C) 2008 - 2026 Kunena Team. All rights reserved. * @license https://www.gnu.org/copyleft/gpl.html GNU/GPL * @link https://www.kunena.org **/ namespace Kunena\Forum\Site\Controllers; \defined('_JEXEC') or die(); use Exception; use Joomla\CMS\Date\Date; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Session\Session; use Joomla\Utilities\ArrayHelper; use Kunena\Forum\Libraries\Controller\KunenaController; use Kunena\Forum\Libraries\Forum\Announcement\KunenaAnnouncementHelper; use Kunena\Forum\Libraries\Log\KunenaLog; /** * Kunena Announcements Controller * * @since Kunena 2.0 */ class AnnouncementController extends KunenaController { /** * @return void * * @since Kunena 6.0 * * @throws Exception * @throws null */ public function none() { // FIXME: This is workaround for task=none on edit. $this->edit(); } /** * @return void * * @since Kunena 6.0 * * @throws Exception * @throws null */ public function edit() { $cid = $this->input->get('cid', [], 'array'); $cid = ArrayHelper::toInteger($cid, []); $announcement = KunenaAnnouncementHelper::get(array_pop($cid)); $this->setRedirect($announcement->getUrl('edit', false)); } /** * @return void * * @since Kunena 6.0 * * @throws Exception * @throws null */ public function publish() { if (!Session::checkToken('post')) { $this->app->enqueueMessage(Text::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $cid = $this->input->get('cid', [], 'array'); $cid = ArrayHelper::toInteger($cid, []); foreach ($cid as $id) { $announcement = KunenaAnnouncementHelper::get($id); $date_today = Factory::getDate(); if ($announcement->published == 1 && $announcement->publish_up > $date_today && $announcement->publish_down > $date_today) { continue; } $announcement->published = 1; try { $announcement->isAuthorised('edit'); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); } try { $announcement->save(); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); $this->setRedirectBack(); return; } if ($announcement->isAuthorised('edit') || $announcement->save()) { if ($this->config->logModeration) { KunenaLog::log(KunenaLog::TYPE_MODERATION, KunenaLog::LOG_ANNOUNCEMENT_PUBLISH, ['id' => $announcement->id]); } $this->app->enqueueMessage(Text::sprintf('COM_KUNENA_ANN_SUCCESS_PUBLISH', $this->escape($announcement->title)), 'success'); } } $this->setRedirectBack(); } /** * @return void * * @since Kunena 6.0 * * @throws Exception * @throws null */ public function unpublish() { if (!Session::checkToken('post')) { $this->app->enqueueMessage(Text::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $cid = $this->input->get('cid', [], 'array'); $cid = ArrayHelper::toInteger($cid, []); foreach ($cid as $id) { $announcement = KunenaAnnouncementHelper::get($id); $date_today = Factory::getDate(); if ($announcement->published == 0 && $announcement->publish_down > $date_today && $announcement->publish_down > $date_today) { continue; } $announcement->published = 0; try { $announcement->isAuthorised('edit'); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); } try { $announcement->save(); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); $this->setRedirectBack(); return; } if ($announcement->isAuthorised('edit') || !$announcement->save()) { if ($this->config->logModeration) { KunenaLog::log(KunenaLog::TYPE_MODERATION, KunenaLog::LOG_ANNOUNCEMENT_UNPUBLISH, ['id' => $announcement->id]); } $this->app->enqueueMessage(Text::sprintf('COM_KUNENA_ANN_SUCCESS_UNPUBLISH', $this->escape($announcement->title)), 'success'); } } $this->setRedirectBack(); } /** * @return void * * @since Kunena 6.0 * * @throws Exception * @throws null */ public function delete() { if (!Session::checkToken('request')) { $this->app->enqueueMessage(Text::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $cid = $this->app->getInput()->get('cid', (array) $this->app->getInput()->getInt('id'), 'post', 'array'); $cid = ArrayHelper::toInteger($cid); foreach ($cid as $id) { $announcement = KunenaAnnouncementHelper::get($id); try { $announcement->isAuthorised('delete'); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); } try { $announcement->delete(); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); $this->setRedirectBack(); return; } if ($announcement->isAuthorised('delete') || $announcement->delete()) { if ($this->config->logModeration) { KunenaLog::log( KunenaLog::TYPE_MODERATION, KunenaLog::LOG_ANNOUNCEMENT_DELETE, ['id' => $announcement->id] ); } $this->app->enqueueMessage(Text::_('COM_KUNENA_ANN_DELETED'), 'success'); } } $this->setRedirect(KunenaAnnouncementHelper::getUrl('listing', false)); } /** * @return void * * @since Kunena 6.0 * * @throws Exception * @throws null */ public function save() { if (!Session::checkToken('post')) { $this->app->enqueueMessage(Text::_('COM_KUNENA_ERROR_TOKEN'), 'error'); $this->setRedirectBack(); return; } $now = new Date(); $fields = []; $fields['title'] = $this->app->getInput()->getString('title', ''); $fields['description'] = $this->app->getInput()->getString('description', ''); $fields['sdescription'] = $this->app->getInput()->getString('sdescription', ''); $fields['created'] = $this->app->getInput()->getString('created'); $fields['publish_up'] = $this->app->getInput()->getString('publish_up'); $fields['publish_down'] = $this->app->getInput()->getString('publish_down'); $fields['published'] = $this->app->getInput()->getInt('published', 1); $fields['showdate'] = $this->app->getInput()->getInt('showdate', 1); $id = $this->app->getInput()->getInt('id'); $announcement = KunenaAnnouncementHelper::get($id); if ($fields['created'] == null) { $fields['created'] = $now->toSql(); } if ($fields['publish_up'] == null) { $fields['publish_up'] = $now->toSql(); } if ($fields['publish_down'] == null) { $fields['publish_down'] = '1000-01-01 00:00:00'; } $announcement->bind($fields); try { $announcement->isAuthorised($id ? 'edit' : 'create'); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); $this->setRedirectBack(); return; } try { $announcement->save(); } catch (Exception $e) { $this->app->enqueueMessage($e->getMessage(), 'error'); $this->setRedirectBack(); return; } if ($this->config->logModeration) { KunenaLog::log( KunenaLog::TYPE_MODERATION, $id ? KunenaLog::LOG_ANNOUNCEMENT_EDIT : KunenaLog::LOG_ANNOUNCEMENT_CREATE, ['id' => $announcement->id] ); } $this->app->enqueueMessage(Text::_($id ? 'COM_KUNENA_ANN_SUCCESS_EDIT' : 'COM_KUNENA_ANN_SUCCESS_ADD'), 'success'); $this->setRedirect($announcement->getUrl('default', false)); } }
| ver. 1.1 | |
.
| PHP 8.4.18 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка