[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Site 5 * @subpackage com_contact 6 * 7 * @copyright (C) 2017 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\Component\Contact\Site\Rule; 12 13 use Joomla\CMS\Component\ComponentHelper; 14 use Joomla\CMS\Form\Form; 15 use Joomla\CMS\Form\Rule\EmailRule; 16 use Joomla\Registry\Registry; 17 use Joomla\String\StringHelper; 18 19 // phpcs:disable PSR1.Files.SideEffects 20 \defined('_JEXEC') or die; 21 // phpcs:enable PSR1.Files.SideEffects 22 23 /** 24 * FormRule for com_contact to make sure the email address is not blocked. 25 * 26 * @since 1.6 27 */ 28 class ContactEmailRule extends EmailRule 29 { 30 /** 31 * Method to test for banned email addresses 32 * 33 * @param \SimpleXMLElement $element The SimpleXMLElement object representing the <field /> tag for the form field object. 34 * @param mixed $value The form field value to validate. 35 * @param string $group The field name group control value. This acts as an array container for the field. 36 * For example if the field has name="foo" and the group value is set to "bar" then the 37 * full field name would end up being "bar[foo]". 38 * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. 39 * @param Form $form The form object for which the field is being tested. 40 * 41 * @return boolean True if the value is valid, false otherwise. 42 */ 43 public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) 44 { 45 if (!parent::test($element, $value, $group, $input, $form)) { 46 return false; 47 } 48 49 $params = ComponentHelper::getParams('com_contact'); 50 $banned = $params->get('banned_email'); 51 52 if ($banned) { 53 foreach (explode(';', $banned) as $item) { 54 if ($item != '' && StringHelper::stristr($value, $item) !== false) { 55 return false; 56 } 57 } 58 } 59 60 return true; 61 } 62 }
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 |