diff --git a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php index b2c8fe1a..5a27e3b8 100644 --- a/public_html/conf/LSobjects/config.LSobjects.LSpeople.php +++ b/public_html/conf/LSobjects/config.LSobjects.LSpeople.php @@ -463,6 +463,7 @@ $GLOBALS['LSobjects']['LSpeople'] = array ( 'html_type' => 'password', 'html_options' => array( 'generationTool' => true, + 'viewHash' => true, 'autoGenerate' => false, 'lenght' => 8, 'chars' => array ( diff --git a/public_html/images/default/view_hash.png b/public_html/images/default/view_hash.png new file mode 100644 index 00000000..d8e23ec9 Binary files /dev/null and b/public_html/images/default/view_hash.png differ diff --git a/public_html/includes/class/class.LSformElement_password.php b/public_html/includes/class/class.LSformElement_password.php index dce28f98..b59d9d58 100644 --- a/public_html/includes/class/class.LSformElement_password.php +++ b/public_html/includes/class/class.LSformElement_password.php @@ -124,6 +124,7 @@ class LSformElement_password extends LSformElement { 'generate' => _('Generate a password.'), 'verify' => _('Compare with stored password.'), 'view' => _('Display password.'), + 'viewHash' => _('Display hashed password.'), 'hide' => _('Hide password.'), 'mail' => _("The password will be sent by mail if changed. Click to disable automatic notification."), 'nomail' => _("The password will not be sent if changed. Click to enable automatic notification."), @@ -137,6 +138,7 @@ class LSformElement_password extends LSformElement { $params = array( 'generate' => ($this -> params['html_options']['generationTool']==True), + 'viewHash' => ($this -> params['html_options']['viewHash']==True), 'verify' => (!$this -> attr_html -> attribute -> ldapObject-> isNew()) ); if (isset($this -> params['html_options']['mail'])) { @@ -233,6 +235,24 @@ class LSformElement_password extends LSformElement { } } } + + public static function ajax_viewHash(&$data) { + if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) ) { + if (LSsession ::loadLSobject($_REQUEST['objecttype'])) { + $object = new $_REQUEST['objecttype'](); + $object -> loadData($_REQUEST['objectdn']); + if (LSsession::canAccess($_REQUEST['objecttype'],$_REQUEST['objectdn'],null,$_REQUEST['attribute'])) { + $values = $object -> getValue($_REQUEST['attribute']); + if (is_string($values[0])) { + $data = array ( + 'hash' => $values[0] + ); + } + } + } + } + } + } ?> diff --git a/public_html/includes/js/LSformElement_password_field.js b/public_html/includes/js/LSformElement_password_field.js index 4d6e3883..c447bfbd 100644 --- a/public_html/includes/js/LSformElement_password_field.js +++ b/public_html/includes/js/LSformElement_password_field.js @@ -7,6 +7,16 @@ var LSformElement_password_field = new Class({ }, initialiseLSformElement_password_field: function() { + // ViewHashBtn + if (this.params['viewHash'] && varLSform.objectdn!= "") { + this.viewHashBtn = new Element('img'); + this.viewHashBtn.src = varLSdefault.imagePath('view_hash.png'); + this.viewHashBtn.addClass('btn'); + this.viewHashBtn.addEvent('click',this.onViewHashBtnClick.bind(this)); + this.viewHashBtn.injectAfter(this.input); + varLSdefault.addHelpInfo(this.viewHashBtn,'LSformElement_password','viewHash'); + } + // Mail if (this.params['mail']) { if ((this.params.mail['canEdit']==1)||(!$type(this.params.mail['canEdit']))) { @@ -209,5 +219,28 @@ var LSformElement_password_field = new Class({ } (function(){this.verifyFx.start(this.bgColor);}).delay(1000, this); } + }, + + onViewHashBtnClick: function() { + var data = { + template: 'LSformElement_password', + action: 'viewHash', + attribute: this.name, + objecttype: varLSform.objecttype, + objectdn: varLSform.objectdn + }; + data.imgload=varLSdefault.loadingImgDisplay(this.viewHashBtn); + new Request({url: 'index_ajax.php', data: data, onSuccess: this.onViewHashBtnClickComplete.bind(this)}).send(); + }, + + onViewHashBtnClickComplete: function(responseText, responseXML) { + var data = JSON.decode(responseText); + if ( varLSdefault.checkAjaxReturn(data) ) { + if (data.hash) { + // ok + this.input.value=data.hash; + this.changeInputType('view'); + } + } } });