Somehow the password must be handled specially (also because of the hashing) which causes problems at the moment.
41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\Form\Form;
|
|
use Joomla\CMS\Form\FormRule;
|
|
use Joomla\Registry\Registry;
|
|
|
|
// No direct access.
|
|
defined('_JEXEC') or die;
|
|
|
|
class JFormRuleClubUserName extends FormRule
|
|
{
|
|
|
|
public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null)
|
|
{
|
|
// Get the database object and a new query object.
|
|
$db = Factory::getDbo();
|
|
$query = $db->getQuery(true);
|
|
|
|
// Build the query.
|
|
$query->select('COUNT(*)')
|
|
->from('#__club_users')
|
|
->where('user = ' . $db->quote($value));
|
|
|
|
// Get the extra field check attribute.
|
|
$userId = $input->get('id');
|
|
$query->where($db->quoteName('id') . ' <> ' . (int) $userId);
|
|
|
|
// Set and query the database.
|
|
$db->setQuery($query);
|
|
$duplicate = (bool) $db->loadResult();
|
|
|
|
if ($duplicate)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
} |