Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
password.inc
1 <?php
18 require_once SQ_ATTRIBUTES_PATH.'/text/text.inc';
19 
35 {
36 
37 
45  function Asset_Attribute_Password($attributeid=0, $value=null)
46  {
47  $this->Asset_Attribute_Text($attributeid, $value);
48 
49  }//end constructor
50 
51 
61  function setEditParams(&$node)
62  {// TODO TOF TEST
63  if (!parent::setEditParams($node)) return false;
64 
65  $this->_edit_params['min_length'] = isset($node->attributes()->min_length) ? (int) $node->attributes()->min_length : 0;
66  if(isset($node->attributes()->autocomplete)){
67  $this->_edit_params['autocomplete'] = $node->attributes()->autocomplete;
68  }
69  return true;
70 
71  }//end setEditParams()
72 
73 
82  function paint($prefix, $read_only=false)
83  {
84  if ($read_only) {
85  echo translate('password_not_shown');
86  return;
87  }
88 
89  require_once SQ_LIB_PATH.'/html_form/html_form.inc';
90 
91  // NOTE: we deliberatly don't set the value
92  password_box($prefix.'_one', '', $this->_edit_params['width'], $this->_params['max_length'],isset($this->_edit_params['autocomplete']) ? 'autocomplete="'.$this->_edit_params['autocomplete'].'"' : '');
93  echo '<br />';
94  password_box($prefix.'_two', '', $this->_edit_params['width'], $this->_params['max_length'],isset($this->_edit_params['autocomplete']) ? 'autocomplete="'.$this->_edit_params['autocomplete'].'"' : '');
95 
96  return true;
97 
98  }//end paint()
99 
100 
108  function process($prefix)
109  {
110  if (!isset($_REQUEST[$prefix.'_one']) && !isset($_REQUEST[$prefix.'_two'])) {
111  return false;
112  }
113  $this->processed = false;
114 
115  $one = $_REQUEST[$prefix.'_one'];
116  $two = $_REQUEST[$prefix.'_two'];
117 
118  $this->validateValue($one);
119  $this->validateValue($two);
120 
121  if (!$one) return;
122 
123  if ($one == $two) {
124  if ($this->setValue($one)) {
125  $this->processed = true;
126  } else {
127  $this->processed = false;
128  }
129  } else {
130  trigger_localised_error('SYS0017', E_USER_WARNING);
131  $this->processed = false;
132  }
133 
134  }//end process()
135 
136 
145  function validateValue(&$value)
146  {
147  $value = trim($value);
148  $new_value = (string)$value;
149  if ($new_value != $value) return false;
150  return true;
151 
152  }//end validateValue()
153 
154 
155 }//end class
156 
157 ?>