[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage mod_privacy_status 6 * 7 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Module\PrivacyStatus\Administrator\Helper; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\Language\Multilanguage; 16 use Joomla\CMS\Plugin\PluginHelper; 17 use Joomla\CMS\Router\Route; 18 19 // phpcs:disable PSR1.Files.SideEffects 20 \defined('_JEXEC') or die; 21 // phpcs:enable PSR1.Files.SideEffects 22 23 /** 24 * Helper class for admin privacy status module 25 * 26 * @since 4.0.0 27 */ 28 class PrivacyStatusHelper 29 { 30 /** 31 * Get the information about the published privacy policy 32 * 33 * @return array Array containing a status of whether a privacy policy is set and a link to the policy document for editing 34 * 35 * @since 4.0.0 36 */ 37 public static function getPrivacyPolicyInfo() 38 { 39 $policy = [ 40 'published' => false, 41 'articlePublished' => false, 42 'editLink' => '', 43 ]; 44 45 /* 46 * Prior to 3.9.0 it was common for a plugin such as the User - Profile plugin to define a privacy policy or 47 * terms of service article, therefore we will also import the user plugin group to process this event. 48 */ 49 PluginHelper::importPlugin('privacy'); 50 PluginHelper::importPlugin('user'); 51 52 Factory::getApplication()->triggerEvent('onPrivacyCheckPrivacyPolicyPublished', [&$policy]); 53 54 return $policy; 55 } 56 57 /** 58 * Check whether there is a menu item for the request form 59 * 60 * @return array Array containing a status of whether a menu is published for the request form and its current link 61 * 62 * @since 4.0.0 63 */ 64 public static function getRequestFormPublished() 65 { 66 $status = [ 67 'exists' => false, 68 'published' => false, 69 'link' => '', 70 ]; 71 72 $db = Factory::getDbo(); 73 $query = $db->getQuery(true) 74 ->select( 75 [ 76 $db->quoteName('id'), 77 $db->quoteName('published'), 78 $db->quoteName('language'), 79 ] 80 ) 81 ->from($db->quoteName('#__menu')) 82 ->where( 83 [ 84 $db->quoteName('client_id') . ' = 0', 85 $db->quoteName('link') . ' = ' . $db->quote('index.php?option=com_privacy&view=request'), 86 ] 87 ) 88 ->setLimit(1); 89 $db->setQuery($query); 90 91 $menuItem = $db->loadObject(); 92 93 // Check if the menu item exists in database 94 if ($menuItem) { 95 $status['exists'] = true; 96 97 // Check if the menu item is published 98 if ($menuItem->published == 1) { 99 $status['published'] = true; 100 } 101 102 // Add language to the url if the site is multilingual 103 if (Multilanguage::isEnabled() && $menuItem->language && $menuItem->language !== '*') { 104 $lang = '&lang=' . $menuItem->language; 105 } else { 106 $lang = ''; 107 } 108 } 109 110 $linkMode = Factory::getApplication()->get('force_ssl', 0) == 2 ? Route::TLS_FORCE : Route::TLS_IGNORE; 111 112 if (!$menuItem) { 113 if (Multilanguage::isEnabled()) { 114 // Find the Itemid of the home menu item tagged to the site default language 115 $params = ComponentHelper::getParams('com_languages'); 116 $defaultSiteLanguage = $params->get('site'); 117 118 $db = Factory::getDbo(); 119 $query = $db->getQuery(true) 120 ->select($db->quoteName('id')) 121 ->from($db->quoteName('#__menu')) 122 ->where( 123 [ 124 $db->quoteName('client_id') . ' = 0', 125 $db->quoteName('home') . ' = 1', 126 $db->quoteName('language') . ' = :language', 127 ] 128 ) 129 ->bind(':language', $defaultSiteLanguage) 130 ->setLimit(1); 131 $db->setQuery($query); 132 133 $homeId = (int) $db->loadResult(); 134 $itemId = $homeId ? '&Itemid=' . $homeId : ''; 135 } else { 136 $itemId = ''; 137 } 138 139 $status['link'] = Route::link('site', 'index.php?option=com_privacy&view=request' . $itemId, true, $linkMode); 140 } else { 141 $status['link'] = Route::link('site', 'index.php?Itemid=' . $menuItem->id . $lang, true, $linkMode); 142 } 143 144 return $status; 145 } 146 147 /** 148 * Method to return number privacy requests older than X days. 149 * 150 * @return integer 151 * 152 * @since 4.0.0 153 */ 154 public static function getNumberUrgentRequests() 155 { 156 // Load the parameters. 157 $params = ComponentHelper::getComponent('com_privacy')->getParams(); 158 $notify = (int) $params->get('notify', 14); 159 $now = Factory::getDate()->toSql(); 160 $period = '-' . $notify; 161 162 $db = Factory::getDbo(); 163 $query = $db->getQuery(true); 164 $query->select('COUNT(*)') 165 ->from($db->quoteName('#__privacy_requests')) 166 ->where( 167 [ 168 $db->quoteName('status') . ' = 1', 169 $query->dateAdd($db->quote($now), $period, 'DAY') . ' > ' . $db->quoteName('requested_at'), 170 ] 171 ); 172 $db->setQuery($query); 173 174 return (int) $db->loadResult(); 175 } 176 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |