ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPasswordInputGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 {
13  protected $value;
14  protected $size = 20;
15  protected $validateauthpost = "";
16  protected $requiredonauth = false;
17  protected $maxlength = false;
18  protected $use_strip_slashes = true;
19 
23  protected $autocomplete_disabled = true;
24 
31  public function __construct($a_title = "", $a_postvar = "")
32  {
33  global $DIC;
34 
35  $this->lng = $DIC->language();
36  parent::__construct($a_title, $a_postvar);
37  $this->setRetype(true);
38  $this->setSkipSyntaxCheck(false);
39  }
40 
46  public function setValue($a_value)
47  {
48  $this->value = $a_value;
49  }
50 
56  public function getValue()
57  {
58  return $this->value;
59  }
60 
66  public function setRetype($a_val)
67  {
68  $this->retype = $a_val;
69  }
70 
76  public function getRetype()
77  {
78  return $this->retype;
79  }
80 
86  public function setRetypeValue($a_retypevalue)
87  {
88  $this->retypevalue = $a_retypevalue;
89  }
90 
96  public function getRetypeValue()
97  {
98  return $this->retypevalue;
99  }
100 
106  public function setMaxLength($a_maxlength)
107  {
108  $this->maxlength = $a_maxlength;
109  }
110 
116  public function getMaxLength()
117  {
118  return $this->maxlength;
119  }
120 
126  public function setSize($a_size)
127  {
128  $this->size = $a_size;
129  }
130 
136  public function setValueByArray($a_values)
137  {
138  $this->setValue($a_values[$this->getPostVar()]);
139  $this->setRetypeValue($a_values[$this->getPostVar() . "_retype"]);
140  }
141 
147  public function getSize()
148  {
149  return $this->size;
150  }
151 
157  public function setValidateAuthPost($a_validateauthpost)
158  {
159  $this->validateauthpost = $a_validateauthpost;
160  }
161 
167  public function getValidateAuthPost()
168  {
170  }
171 
177  public function setRequiredOnAuth($a_requiredonauth)
178  {
179  $this->requiredonauth = $a_requiredonauth;
180  }
181 
187  public function getRequiredOnAuth()
188  {
189  return $this->requiredonauth;
190  }
191 
197  public function setSkipSyntaxCheck($a_val)
198  {
199  $this->skip_syntax_check = $a_val;
200  }
201 
207  public function getSkipSyntaxCheck()
208  {
209  return $this->skip_syntax_check;
210  }
211 
217  public function setDisableHtmlAutoComplete($a_value)
218  {
219  $this->autocomplete_disabled = (bool) $a_value;
220  }
221 
227  public function isHtmlAutoCompleteDisabled()
228  {
230  }
231 
238  public function setUseStripSlashes($a_stat)
239  {
240  $this->use_strip_slashes = $a_stat;
241  }
242 
247  public function getUseStripSlashes()
248  {
250  }
251 
257  public function checkInput()
258  {
259  $lng = $this->lng;
260 
261  if ($this->getUseStripSlashes()) {
262  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
263  $_POST[$this->getPostVar() . "_retype"] = ilUtil::stripSlashes($_POST[$this->getPostVar() . "_retype"]);
264  }
265  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
266  $this->setAlert($lng->txt("msg_input_is_required"));
267 
268  return false;
269  }
270  if ($this->getValidateAuthPost() != "") {
272 
273  // check, if password is required dependent on auth mode
275  && trim($_POST[$this->getPostVar()]) == "") {
276  $this->setAlert($lng->txt("form_password_required_for_auth"));
277 
278  return false;
279  }
280 
281  // check, if password is allowed to be set for given auth mode
282  if (trim($_POST[$this->getPostVar()]) != "" &&
284  $this->setAlert($lng->txt("form_password_not_allowed_for_auth"));
285 
286  return false;
287  }
288  }
289  if ($this->getRetype() &&
290  ($_POST[$this->getPostVar()] != $_POST[$this->getPostVar() . "_retype"])) {
291  $this->setAlert($lng->txt("passwd_not_match"));
292 
293  return false;
294  }
295  if (!$this->getSkipSyntaxCheck() &&
296  !ilUtil::isPassword($_POST[$this->getPostVar()], $custom_error) &&
297  $_POST[$this->getPostVar()] != "") {
298  if ($custom_error != '') {
299  $this->setAlert($custom_error);
300  } else {
301  $this->setAlert($lng->txt("passwd_invalid"));
302  }
303 
304  return false;
305  }
306 
307  return $this->checkSubItemsInput();
308  }
309 
313  public function render()
314  {
315  $lng = $this->lng;
316 
317  $ptpl = new ilTemplate("tpl.prop_password.html", true, true, "Services/Form");
318 
319  if ($this->getRetype()) {
320  $ptpl->setCurrentBlock("retype");
321  $ptpl->setVariable("RSIZE", $this->getSize());
322  $ptpl->setVariable("RID", $this->getFieldId());
323  if ($this->getMaxLength() > 0) {
324  $ptpl->setCurrentBlock("rmaxlength");
325  $ptpl->setVariable("RMAXLENGTH", $this->getMaxLength());
326  $ptpl->parseCurrentBlock();
327  }
328  $ptpl->setVariable("RPOST_VAR", $this->getPostVar());
329 
330  if ($this->isHtmlAutoCompleteDisabled()) {
331  $ptpl->setVariable("RAUTOCOMPLETE", "autocomplete=\"off\"");
332  }
333 
334  // this is creating an "auto entry" in the setup, if the retype is missing
335  /*$retype_value = ($this->getRetypeValue() != "")
336  ? $this->getRetypeValue()
337  : $this->getValue();*/
338  $retype_value = $this->getRetypeValue();
339  $ptpl->setVariable("PROPERTY_RETYPE_VALUE", ilUtil::prepareFormOutput($retype_value));
340  if ($this->getDisabled()) {
341  $ptpl->setVariable(
342  "RDISABLED",
343  " disabled=\"disabled\""
344  );
345  }
346  $ptpl->setVariable("TXT_RETYPE", $lng->txt("form_retype_password"));
347  $ptpl->parseCurrentBlock();
348  }
349 
350  if (strlen($this->getValue())) {
351  $ptpl->setCurrentBlock("prop_password_propval");
352  $ptpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
353  $ptpl->parseCurrentBlock();
354  }
355  $ptpl->setVariable("POST_VAR", $this->getPostVar());
356  $ptpl->setVariable("ID", $this->getFieldId());
357  $ptpl->setVariable("SIZE", $this->getSize());
358  if ($this->getMaxLength() > 0) {
359  $ptpl->setCurrentBlock("maxlength");
360  $ptpl->setVariable("MAXLENGTH", $this->getMaxLength());
361  $ptpl->parseCurrentBlock();
362  }
363  if ($this->getDisabled()) {
364  $ptpl->setVariable(
365  "DISABLED",
366  " disabled=\"disabled\""
367  );
368  }
369  if ($this->isHtmlAutoCompleteDisabled()) {
370  $ptpl->setVariable("AUTOCOMPLETE", "autocomplete=\"off\"");
371  }
372  if ($this->getRequired()) {
373  $ptpl->setVariable("REQUIRED", "required=\"required\"");
374  }
375  return $ptpl->get();
376  }
377 
383  public function insert($a_tpl)
384  {
385  $html = $this->render();
386 
387  $a_tpl->setCurrentBlock("prop_generic");
388  $a_tpl->setVariable("PROP_GENERIC", $html);
389  $a_tpl->parseCurrentBlock();
390  }
391 }
getMaxLength()
Get Max Length.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
setValidateAuthPost($a_validateauthpost)
Set Validate required status against authentication POST var.
global $DIC
Definition: saml.php:7
getPostVar()
Get Post Variable.
getSkipSyntaxCheck()
Get skip syntax check.
getRetypeValue()
Get Retype Value.
getRetype()
Get retype on/off.
static _getAuthMode($a_auth_mode, $a_db_handler='')
static isPassword($a_passwd, &$customError=null)
validates a password public
setRetype($a_val)
Set retype on/off.
setDisableHtmlAutoComplete($a_value)
Set autocomplete.
$auth
Definition: fileserver.php:48
setValueByArray($a_values)
Set value by array.
setAlert($a_alert)
Set Alert Text.
static _allowPasswordModificationByAuthMode($a_auth_mode)
Allow password modification.
setRetypeValue($a_retypevalue)
Set Retype Value.
setUseStripSlashes($a_stat)
En/disable use of stripslashes.
setRequiredOnAuth($a_requiredonauth)
Set input required, if authentication mode allows password setting.
getValidateAuthPost()
Get Validate required status against authentication POST var.
isHtmlAutoCompleteDisabled()
Get autocomplete.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
setSkipSyntaxCheck($a_val)
Set skip syntax check.
This class represents a password property in a property form.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setValue($a_value)
Set Value.
insert($a_tpl)
Insert property html.
checkInput()
Check input, strip slashes etc.
font size
Definition: langcheck.php:162
This class represents a property that may include a sub form.
setMaxLength($a_maxlength)
Set Max Length.
getRequiredOnAuth()
Get input required, if authentication mode allows password setting.
$_POST["username"]
$html
Definition: example_001.php:87
__construct($a_title="", $a_postvar="")
Constructor.