Merge pull request #114 from brayanpereyra/BUG-9379
BUG 9379 Add username exist SOLVED
This commit is contained in:
@@ -564,5 +564,39 @@ switch($_POST['action'])
|
|||||||
$aFields['DESCRIPTION'] = $span . $gif . $aFields['DESCRIPTION'];
|
$aFields['DESCRIPTION'] = $span . $gif . $aFields['DESCRIPTION'];
|
||||||
print(G::json_encode($aFields));
|
print(G::json_encode($aFields));
|
||||||
break;
|
break;
|
||||||
|
case 'testUsername';
|
||||||
|
require_once 'classes/model/Users.php';
|
||||||
|
$_POST['NEW_USERNAME'] = trim($_POST['NEW_USERNAME']);
|
||||||
|
|
||||||
|
$response = array( "success" => true );
|
||||||
|
|
||||||
|
$oCriteria = new Criteria();
|
||||||
|
$oCriteria->addSelectColumn(UsersPeer::USR_USERNAME);
|
||||||
|
$oCriteria->add(UsersPeer::USR_USERNAME, $_POST['NEW_USERNAME']);
|
||||||
|
$oDataset = UsersPeer::doSelectRS($oCriteria);
|
||||||
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$oDataset->next();
|
||||||
|
$aRow = $oDataset->getRow();
|
||||||
|
|
||||||
|
if (is_array($aRow) || $_POST['NEW_USERNAME'] == '') {
|
||||||
|
$color = 'red';
|
||||||
|
$img = '/images/delete.png';
|
||||||
|
$dataVar['USER_ID'] = $_POST['NEW_USERNAME'];
|
||||||
|
$text = G::LoadTranslation('ID_USERNAME_ALREADY_EXISTS', $dataVar);
|
||||||
|
$text = ($_POST['NEW_USERNAME'] == '') ? G::LoadTranslation('ID_MSG_ERROR_USR_USERNAME') : $text;
|
||||||
|
$response['exists'] = true;
|
||||||
|
} else {
|
||||||
|
$color = 'green';
|
||||||
|
$img = '/images/dialog-ok-apply.png';
|
||||||
|
$text = G::LoadTranslation('ID_USERNAME_CORRECT');
|
||||||
|
$response['exists'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$span = '<span style="color: ' . $color . '; font: 9px tahoma,arial,helvetica,sans-serif;">';
|
||||||
|
$gif = '<img width="13" height="13" border="0" src="' . $img . '">';
|
||||||
|
$response['descriptionText'] = $span . $gif . $text . '</span>';
|
||||||
|
echo G::json_encode($response);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ var global = {};
|
|||||||
var readMode;
|
var readMode;
|
||||||
var canEdit = true;
|
var canEdit = true;
|
||||||
var flagPoliciesPassword = false;
|
var flagPoliciesPassword = false;
|
||||||
|
var flagValidateUsername = false;
|
||||||
//var rendeToPage='document.body';
|
//var rendeToPage='document.body';
|
||||||
global.IC_UID = '';
|
global.IC_UID = '';
|
||||||
global.IS_UID = '';
|
global.IS_UID = '';
|
||||||
@@ -397,7 +398,69 @@ Ext.onReady(function() {
|
|||||||
fieldLabel : _('ID_USER_ID'),
|
fieldLabel : _('ID_USER_ID'),
|
||||||
xtype : 'textfield',
|
xtype : 'textfield',
|
||||||
width : 260,
|
width : 260,
|
||||||
allowBlank : false
|
allowBlank : false,
|
||||||
|
listeners: {
|
||||||
|
blur : function(ob)
|
||||||
|
{
|
||||||
|
// trim
|
||||||
|
this.value = this.getValue().replace(/^\s+|\s+$/g,"");
|
||||||
|
document.getElementById('USR_USERNAME').value = this.getValue().replace(/^\s+|\s+$/g,"");
|
||||||
|
|
||||||
|
Ext.getCmp('saveB').disable();
|
||||||
|
Ext.getCmp('cancelB').disable();
|
||||||
|
|
||||||
|
var spanAjax = '<span style="font: 9px tahoma,arial,helvetica,sans-serif;">';
|
||||||
|
var imageAjax = '<img width="13" height="13" border="0" src="/images/ajax-loader.gif">';
|
||||||
|
var labelAjax = _('ID_USERNAME_TESTING');
|
||||||
|
|
||||||
|
Ext.getCmp('usernameReview').setText(spanAjax + imageAjax + labelAjax + '</span>', false);
|
||||||
|
Ext.getCmp('usernameReview').setVisible(true);
|
||||||
|
|
||||||
|
var usernameText = this.getValue();
|
||||||
|
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url : 'usersAjax',
|
||||||
|
method : 'POST',
|
||||||
|
params : {
|
||||||
|
'action' : 'testUsername',
|
||||||
|
'NEW_USERNAME' : usernameText
|
||||||
|
},
|
||||||
|
success: function(r,o){
|
||||||
|
var resp = Ext.util.JSON.decode(r.responseText);
|
||||||
|
|
||||||
|
if (resp.exists) {
|
||||||
|
flagValidateUsername = false;
|
||||||
|
} else {
|
||||||
|
flagValidateUsername = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ext.getCmp('usernameReview').setText(resp.descriptionText, false);
|
||||||
|
Ext.getCmp('saveB').enable();
|
||||||
|
Ext.getCmp('cancelB').enable();
|
||||||
|
},
|
||||||
|
failure: function () {
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: 'Error',
|
||||||
|
msg: 'Failed to store data',
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
animEl: 'mb9',
|
||||||
|
icon: Ext.MessageBox.ERROR
|
||||||
|
});
|
||||||
|
Ext.getCmp('saveB').enable();
|
||||||
|
Ext.getCmp('cancelB').enable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Ext.getCmp('usernameReview').setVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
xtype: 'label',
|
||||||
|
fieldLabel: ' ',
|
||||||
|
id:'usernameReview',
|
||||||
|
width: 300,
|
||||||
|
labelSeparator: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id : 'USR_EMAIL',
|
id : 'USR_EMAIL',
|
||||||
@@ -872,12 +935,17 @@ Ext.onReady(function() {
|
|||||||
|
|
||||||
Ext.getCmp('passwordReview').setVisible(false);
|
Ext.getCmp('passwordReview').setVisible(false);
|
||||||
Ext.getCmp('passwordConfirm').setVisible(false);
|
Ext.getCmp('passwordConfirm').setVisible(false);
|
||||||
|
Ext.getCmp('usernameReview').setVisible(false);
|
||||||
|
|
||||||
var spanAjax = '<span style="font: 9px tahoma,arial,helvetica,sans-serif;">';
|
var spanAjax = '<span style="font: 9px tahoma,arial,helvetica,sans-serif;">';
|
||||||
var imageAjax = '<img width="13" height="13" border="0" src="/images/ajax-loader.gif">';
|
var imageAjax = '<img width="13" height="13" border="0" src="/images/ajax-loader.gif">';
|
||||||
var labelAjax = _('ID_PASSWORD_TESTING');
|
var labelAjax = _('ID_PASSWORD_TESTING');
|
||||||
|
|
||||||
Ext.getCmp('passwordReview').setText(spanAjax + imageAjax + labelAjax + '</span>', false);
|
Ext.getCmp('passwordReview').setText(spanAjax + imageAjax + labelAjax + '</span>', false);
|
||||||
|
|
||||||
|
var labelAjax = _('ID_USERNAME_TESTING');
|
||||||
|
|
||||||
|
Ext.getCmp('usernameReview').setText(spanAjax + imageAjax + labelAjax + '</span>', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
function defineUserPanel()
|
function defineUserPanel()
|
||||||
@@ -916,8 +984,21 @@ function editUser()
|
|||||||
}
|
}
|
||||||
function saveUser()
|
function saveUser()
|
||||||
{
|
{
|
||||||
|
if (flagValidateUsername != true) {
|
||||||
|
if ( Ext.getCmp('USR_USERNAME').getValue() == '') {
|
||||||
|
Ext.Msg.alert( _('ID_ERROR'), _('ID_MSG_ERROR_USR_USERNAME'));
|
||||||
|
} else {
|
||||||
|
Ext.Msg.alert( _('ID_ERROR'), Ext.getCmp('usernameReview').html);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (flagPoliciesPassword != true) {
|
if (flagPoliciesPassword != true) {
|
||||||
|
if ( Ext.getCmp('USR_NEW_PASS').getValue() == '') {
|
||||||
|
Ext.Msg.alert( _('ID_ERROR'), _('ID_PASSWD_REQUIRED'));
|
||||||
|
} else {
|
||||||
Ext.Msg.alert( _('ID_ERROR'), Ext.getCmp('passwordReview').html);
|
Ext.Msg.alert( _('ID_ERROR'), Ext.getCmp('passwordReview').html);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user