10 defined(
'JPATH_PLATFORM') or die;
28 protected $regex =
'^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$';
45 public function test(SimpleXMLElement $element, $value, $group = null,
JRegistry $input = null,
JForm $form = null)
48 $required = ((string) $element[
'required'] ==
'true' || (
string) $element[
'required'] ==
'required');
50 if (!$required && empty($value))
56 $tld = ((string) $element[
'tld'] ==
'tld' || (
string) $element[
'tld'] ==
'required');
60 $this->regex =
'^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]{2,})$';
64 $multiple = ((string) $element[
'multiple'] ==
'true' || (
string) $element[
'multiple'] ==
'multiple');
72 if (!parent::test($element, $value, $group, $input, $form))
79 $values = explode(
',', $value);
81 foreach ($values as $value)
87 if (!parent::test($element, $value, $group, $input, $form))
95 $unique = ((string) $element[
'unique'] ==
'true' || (
string) $element[
'unique'] ==
'unique');
97 if ($unique && !$multiple)
102 $query = $db->getQuery(
true);
105 $query->select(
'COUNT(*)')
107 ->where(
'email = ' . $db->quote($value));
110 $userId = ($form instanceof
JForm) ? $form->getValue(
'id') :
'';
111 $query->where($db->quoteName(
'id') .
' <> ' . (int) $userId);
114 $db->setQuery($query);
115 $duplicate = (bool) $db->loadResult();