CoreFiles by mySites.guru
MessageController.php140 lines, 2,942 bytes, from Joomla_4.1.5-Stable-Full_Package.zip
Raw History Compare with 4.1.4
md5
db7f7759d28b63a18554178dacfe740b
sha1
329aad06e2151dd2a1cfd13abb1fdfc9c9df6e20
sha256
fd298f1a2bd02db0cd1640c0770dd5462d07a2b615738f66a110344bf29b6473
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_postinstall
 *
 * @copyright   (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Postinstall\Administrator\Controller;

\defined('_JEXEC') or die;

use Joomla\CMS\Filesystem\File;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\Component\Postinstall\Administrator\Helper\PostinstallHelper;
use Joomla\Component\Postinstall\Administrator\Model\MessagesModel;

/**
 * Postinstall message controller.
 *
 * @since  3.2
 */
class MessageController extends BaseController
{
	/**
	 * Resets all post-installation messages of the specified extension.
	 *
	 * @return  void
	 *
	 * @since   3.2
	 */
	public function reset()
	{
		$this->checkToken('get');

		/** @var MessagesModel $model */
		$model = $this->getModel('Messages', '', array('ignore_request' => true));
		$eid = $this->input->getInt('eid');

		if (empty($eid))
		{
			$eid = $model->getJoomlaFilesExtensionId();
		}

		$model->resetMessages($eid);

		$this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
	}

	/**
	 * Unpublishes post-installation message of the specified extension.
	 *
	 * @return   void
	 *
	 * @since   3.2
	 */
	public function unpublish()
	{
		$model = $this->getModel('Messages', '', array('ignore_request' => true));

		$id = $this->input->get('id');

		$eid = (int) $model->getState('eid', $model->getJoomlaFilesExtensionId());

		if (empty($eid))
		{
			$eid = $model->getJoomlaFilesExtensionId();
		}

		$model->setState('published', 0);
		$model->unpublishMessage($id);

		$this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
	}

	/**
	 * Executes the action associated with an item.
	 *
	 * @return  void
	 *
	 * @since   3.2
	 */
	public function action()
	{
		$this->checkToken('get');

		$model = $this->getModel('Messages', '', array('ignore_request' => true));

		$id = $this->input->get('id');

		$item = $model->getItem($id);

		switch ($item->type)
		{
			case 'link':
				$this->setRedirect($item->action);

				return;

			case 'action':
				$helper = new PostinstallHelper;
				$file = $helper->parsePath($item->action_file);

				if (File::exists($file))
				{
					require_once $file;

					call_user_func($item->action);
				}
				break;
		}

		$this->setRedirect('index.php?option=com_postinstall');
	}

	/**
	 * Hides all post-installation messages of the specified extension.
	 *
	 * @return  void
	 *
	 * @since   3.8.7
	 */
	public function hideAll()
	{
		$this->checkToken();

		/** @var MessagesModel $model */
		$model = $this->getModel('Messages', '', array('ignore_request' => true));
		$eid = $this->input->getInt('eid');

		if (empty($eid))
		{
			$eid = $model->getJoomlaFilesExtensionId();
		}

		$model->hideMessages($eid);
		$this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
	}
}

The same content is in 10 releases, Joomla 4.1.3-rc1 to 4.2.0-beta1. See them all, or every version of this file.