CoreFiles by mySites.guru
ReporterHelper.php79 lines, 1,772 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
608a9093d11e050ebdf0c49cc5ace91a
sha1
d20542ef6ab86ee3b775e7fd15f3e5058cbd017f
sha256
401d8621db71a3a110adc7dcd450aef62bedac2e78560a2b1da6cc62be77004b
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_csp
 *
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Csp\Administrator\Helper;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;

/**
 * Reporter component helper.
 *
 * @since  4.0.0
 */
class ReporterHelper
{
	/**
	 * Gets the httpheaders system plugin extension id.
	 *
	 * @return  integer  The httpheaders system plugin extension id.
	 *
	 * @since   4.0.0
	 */
	public static function getHttpHeadersPluginId()
	{
		$db = Factory::getDbo();
		$query = $db->getQuery(true)
			->select($db->quoteName('extension_id'))
			->from($db->quoteName('#__extensions'))
			->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
			->where($db->quoteName('element') . ' = ' . $db->quote('httpheaders'));
		$db->setQuery($query);

		try
		{
			$result = (int) $db->loadResult();
		}
		catch (\RuntimeException $e)
		{
			Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
		}

		return $result;
	}

	/**
	 * Check the com_csp trash to show a warning in this case
	 *
	 * @return  boolean  The status of the trash; Do items exists in the trash
	 *
	 * @since   4.0.0
	 */
	public static function getCspTrashStatus()
	{
		$db = Factory::getDbo();
		$query = $db->getQuery(true)
			->select('COUNT(*)')
			->from($db->quoteName('#__csp'))
			->where($db->quoteName('published') . ' = ' . $db->quote('-2'));
		$db->setQuery($query);

		try
		{
			$result = (int) $db->loadResult();
		}
		catch (\RuntimeException $e)
		{
			Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
		}

		return boolval($result);
	}
}

No other release has this exact content. See every version of this file.