Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / lib / form / passwordunmask.php
blob2b1ab6bb41487072b20cac85380603779a712582
1 <?php
2 if (!defined('MOODLE_INTERNAL')) {
3 die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
6 global $CFG;
7 require_once($CFG->libdir.'/form/password.php');
9 /**
10 * HTML class for a password type element with unmask option
12 * @author Petr Skoda
13 * @access public
15 class MoodleQuickForm_passwordunmask extends MoodleQuickForm_password {
17 function toHtml() {
18 if ($this->_flagFrozen) {
19 return $this->getFrozenHtml();
20 } else {
21 $id = $this->getAttribute('id');
22 $unmask = get_string('unmaskpassword', 'form');
23 $unmaskjs = '<script type="text/javascript">
24 //<![CDATA[
25 document.write(\'<div class="unmask"><input id="'.$id.'unmask" value="1" type="checkbox" onclick="unmaskPassword(\\\''.$id.'\\\')"/><label for="'.$id.'unmask">'.addslashes_js($unmask).'<\/label><\/div>\');
26 document.getElementById("'.$this->getAttribute('id').'").setAttribute("autocomplete", "off");
27 //]]>
28 </script>';
29 return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />'.$unmaskjs;
31 } //end func toHtml