Skip to content

Commit

Permalink
fixxed errors & typos
Browse files Browse the repository at this point in the history
  • Loading branch information
mxkmp29 authored and mxkmp29 committed Aug 9, 2016
1 parent 365a130 commit cc283cd
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 132 deletions.
22 changes: 11 additions & 11 deletions administrator/language/en-GB/en-GB.com_users.ini
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ COM_USERS_CONFIG_FIELD_USERACTIVATION_DESC="If set to None the user will be regi
COM_USERS_CONFIG_FIELD_USERACTIVATION_LABEL="New User Account Activation"
COM_USERS_CONFIG_FIELD_USERACTIVATION_OPTION_ADMINACTIVATION="Administrator"
COM_USERS_CONFIG_FIELD_USERACTIVATION_OPTION_SELFACTIVATION="Self"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_LABEL="Characters preset"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_DESC="Specify from the select list if you want disable this check or allow/forbid CUSTOM characters filling the CUSTOM text box. You can also select some of the specified character presettings: alphanumeric, latin, email,..."
COM_USERS_CONFIG_FIELD_USERNAME_MINNUMCHARS_LABEL="Min. number of characters"
COM_USERS_CONFIG_FIELD_USERNAME_MINNUMCHARS_DESC="Minimum number of characters required for username field. Zero indicates no limit."
COM_USERS_CONFIG_FIELD_USERNAME_MAXNUMCHARS_LABEL="Max. number of characters"
COM_USERS_CONFIG_FIELD_USERNAME_MAXNUMCHARS_DESC="Maximum number of characters required for username field. Zero indicates no limit."
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_LABEL="Character Preset"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_DESC="Specify from the select list if you want disable this check or allow/forbid CUSTOM character filling the CUSTOM text box. You can also select some of the specified character presettings: alphanumeric, latin, email,..."
COM_USERS_CONFIG_FIELD_USERNAME_MINNUMCHARS_LABEL="Min. number of character"
COM_USERS_CONFIG_FIELD_USERNAME_MINNUMCHARS_DESC="Minimum number of character required for username field. Zero indicates no limit."
COM_USERS_CONFIG_FIELD_USERNAME_MAXNUMCHARS_LABEL="Max. number of character"
COM_USERS_CONFIG_FIELD_USERNAME_MAXNUMCHARS_DESC="Maximum number of character required for username field. Zero indicates no limit."
COM_USERS_CONFIG_FIELD_USERNAME_CHARSET_LABEL="Custom character set"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSET_DESC="CUSTOM character set ALLOWED/FORBIDDEN/REGEXP for username field. Select the appropriate behaviour in previous select list. If other than 'CUSTOM' is selected, this text box is not operational. Example allow/forbid: write 'abc' (without quotations) to allow/forbid these characters. For 'CUSTOM REGEXP' case, write a pattern to use inside a preg_match_all() function and all that match will be forbidden. Example regExp for 'latin only': '/[^\\\\\\\\p{Common}\\\\\\\\p{Latin}]/u' (without quotations)."
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_DISABLECHECK="DISABLE characters check"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_CUSTOM_ALLOWED="CUSTOM is characters allowed"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_CUSTOM_FORBIDDEN="CUSTOM is characters forbidden"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_DISABLECHECK="DISABLE character check"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_CUSTOM_ALLOWED="CUSTOM is character allowed"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_CUSTOM_FORBIDDEN="CUSTOM is character forbidden"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_CUSTOM_REGEXP="CUSTOM is a regular expression"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_ALPHANUMERIC="Alphanumeric Only"
COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_LATIN="Latin Only"
Expand All @@ -88,9 +88,9 @@ COM_USERS_CONFIG_FIELD_USERNAME_CHARSPRESET_OPTION_UNICODE_HIGHLY_RESTRICTIVE="U
COM_USERS_CONFIG_IMPORT_FAILED="An error was encountered while importing the configuration: %s."
COM_USERS_CONFIG_PASSWORD_OPTIONS="Password Options"
COM_USERS_CONFIG_SAVE_FAILED="An error was encountered while saving the configuration: %s."
COM_USERS_CONFIG_PASSWORD_OPTIONS="Password options"
COM_USERS_CONFIG_PASSWORD_OPTIONS="Password Options"
COM_USERS_CONFIG_USER_OPTIONS="User Options"
COM_USERS_CONFIG_USERNAME_OPTIONS="Username options"
COM_USERS_CONFIG_USERNAME_OPTIONS="Username Options"
COM_USERS_CONFIGURATION="Users: Options"
COM_USERS_COUNT_ENABLED_USERS="Enabled users"
COM_USERS_COUNT_DISABLED_USERS="Disabled users"
Expand Down
97 changes: 48 additions & 49 deletions components/com_users/controllers/registration.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,58 +17,57 @@
*/
class UsersControllerRegistration extends UsersController
{
/**
*
* Method to validate a username.
* @return void
* @since 3.7
*
*/
/**
* Method to validate a username.
*
* @return JResponseJson Array with the information of the user/email
*
* @since
*/
public function validate()
{
// Read username from ajax
$username = $this->input->get('username', '', 'username');
$email = $this->input->get('email', '', 'email');

public function validate()
{
//read username from ajax
$username = $this->input->get('username', '', 'username');
$email = $this->input->get('email', '', 'email');
if (!empty($username))
{
$fieldname = 'username';
$field = $username;
}
elseif (!empty($email))
{
$fieldname = 'email';
$field = $email;
}

//check
if(!empty($username))
{
$fieldname = 'username';
$field = $username;
}
else if(!empty($email))
{
$fieldname = 'email';
$field = $email;
}
if (isset($fieldname) && isset($field))
{
$db = JFactory::getDbo();

if(isset($fieldname) && isset($field))
{
$db = JFactory::getDbo();
$valid = $db->setQuery(
$db->getQuery(true)
->select($fieldname)
->from('#__users')
->where($fieldname . ' = ' . $db->quote($field))
)->loadResult();

$valid = $db->setQuery(
$db->getQuery(true)
->select($fieldname)
->from('#__users')
->where($fieldname . ' = ' . $db->quote($field))
)->loadResult();
// Return jsonarray with results
$msg = null;

//return jsonarray with results
$msg = null;
if(!is_null($valid))
{
if($fieldname == 'username')
{
$msg = JText::_('COM_USERS_REGISTER_USERNAME_MESSAGE');
}else if($fieldname == 'email')
{
$msg = JText::_('COM_USERS_PROFILE_EMAIL1_MESSAGE');
}
}
echo new JResponseJson($valid, $msg, is_null($valid));
}
if (!is_null($valid))
{
if ($fieldname == 'username')
{
$msg = JText::_('COM_USERS_REGISTER_USERNAME_MESSAGE');
}
elseif ($fieldname == 'email')
{
$msg = JText::_('COM_USERS_PROFILE_EMAIL1_MESSAGE');
}
}


}
}
echo new JResponseJson($valid, $msg, is_null($valid));
}
}
}
1 change: 0 additions & 1 deletion components/com_users/views/registration/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ protected function prepareDocument()
}

$this->document->setTitle($title);
//this->document
if ($this->params->get('menu-meta_description'))
{
$this->document->setDescription($this->params->get('menu-meta_description'));
Expand Down
39 changes: 21 additions & 18 deletions libraries/joomla/form/rule/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JFormRuleEmail extends JFormRule
* @since 11.1
* @see http://www.w3.org/TR/html-markup/input.email.html
*/
protected $regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$';
protected $regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_ `{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$';

/**
* Method to test the email address and optionally check for uniqueness.
Expand Down Expand Up @@ -92,23 +92,26 @@ public function test(SimpleXMLElement $element, $value, $group = null, Registry
}
}

//Check if the email is blacklisted by the user
$params = JComponentHelper::getParams('com_users');
$emailPreset = $params->get('custom_chars_email');
$presets = preg_split ('/\r\n|\n|\r/', $emailPreset);

//check all entries
foreach ($presets as $regex)
{
if($regex != '' && $regex != '*') { //skip new lines
$regex = '/(.*)@' . $regex . '/';
preg_match($regex, $value, $output);

if ($output) {
return false;
}
}
}
// Check if the email is blacklisted by the user
$params = JComponentHelper::getParams('com_users');
$emailPreset = $params->get('custom_chars_email');
$presets = preg_split('/\r\n|\n|\r/', $emailPreset);

// Check all entries
foreach ($presets as $regex)
{
if ($regex != '' && $regex != '*')
{
// Skip new lines
$regex = '/(.*)@' . $regex . '/';
preg_match($regex, $value, $output);

if ($output)
{
return false;
}
}
}

// Check if we should test for uniqueness. This only can be used if multiple is not true
$unique = ((string) $element['unique'] == 'true' || (string) $element['unique'] == 'unique');
Expand Down

0 comments on commit cc283cd

Please sign in to comment.