ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  function __construct($a_title = "", $a_postvar = "")
32  {
33  parent::__construct($a_title, $a_postvar);
34  $this->setRetype(true);
35  $this->setSkipSyntaxCheck(false);
36  }
37 
43  function setValue($a_value)
44  {
45  $this->value = $a_value;
46  }
47 
53  function getValue()
54  {
55  return $this->value;
56  }
57 
63  function setRetype($a_val)
64  {
65  $this->retype = $a_val;
66  }
67 
73  function getRetype()
74  {
75  return $this->retype;
76  }
77 
83  function setRetypeValue($a_retypevalue)
84  {
85  $this->retypevalue = $a_retypevalue;
86  }
87 
93  function getRetypeValue()
94  {
95  return $this->retypevalue;
96  }
97 
103  function setMaxLength($a_maxlength)
104  {
105  $this->maxlength = $a_maxlength;
106  }
107 
113  function getMaxLength()
114  {
115  return $this->maxlength;
116  }
117 
123  function setSize($a_size)
124  {
125  $this->size = $a_size;
126  }
127 
133  function setValueByArray($a_values)
134  {
135  $this->setValue($a_values[$this->getPostVar()]);
136  $this->setRetypeValue($a_values[$this->getPostVar()."_retype"]);
137  }
138 
144  function getSize()
145  {
146  return $this->size;
147  }
148 
154  function setValidateAuthPost($a_validateauthpost)
155  {
156  $this->validateauthpost = $a_validateauthpost;
157  }
158 
165  {
167  }
168 
174  function setRequiredOnAuth($a_requiredonauth)
175  {
176  $this->requiredonauth = $a_requiredonauth;
177  }
178 
184  function getRequiredOnAuth()
185  {
186  return $this->requiredonauth;
187  }
188 
194  function setSkipSyntaxCheck($a_val)
195  {
196  $this->skip_syntax_check = $a_val;
197  }
198 
205  {
206  return $this->skip_syntax_check;
207  }
208 
214  function setDisableHtmlAutoComplete($a_value)
215  {
216  $this->autocomplete_disabled = (bool)$a_value;
217  }
218 
225  {
227  }
228 
235  public function setUseStripSlashes($a_stat)
236  {
237  $this->use_strip_slashes = $a_stat;
238  }
239 
244  public function getUseStripSlashes()
245  {
247  }
248 
254  function checkInput()
255  {
256  global $lng;
257 
258  if($this->getUseStripSlashes())
259  {
260  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
261  $_POST[$this->getPostVar()."_retype"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_retype"]);
262  }
263  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
264  {
265  $this->setAlert($lng->txt("msg_input_is_required"));
266 
267  return false;
268  }
269  if ($this->getValidateAuthPost() != "")
270  {
272 
273  // check, if password is required dependent on auth mode
275  && trim($_POST[$this->getPostVar()]) == "")
276  {
277  $this->setAlert($lng->txt("form_password_required_for_auth"));
278 
279  return false;
280  }
281 
282  // check, if password is allowed to be set for given auth mode
283  if (trim($_POST[$this->getPostVar()]) != "" &&
285  {
286  $this->setAlert($lng->txt("form_password_not_allowed_for_auth"));
287 
288  return false;
289  }
290  }
291  if ($this->getRetype() &&
292  ($_POST[$this->getPostVar()] != $_POST[$this->getPostVar()."_retype"]))
293  {
294  $this->setAlert($lng->txt("passwd_not_match"));
295 
296  return false;
297  }
298  if (!$this->getSkipSyntaxCheck() &&
299  !ilUtil::isPassword($_POST[$this->getPostVar()],$custom_error) &&
300  $_POST[$this->getPostVar()] != "")
301  {
302  if($custom_error != '') $this->setAlert($custom_error);
303  else $this->setAlert($lng->txt("passwd_invalid"));
304 
305  return false;
306  }
307 
308  return $this->checkSubItemsInput();
309  }
310 
314  function render()
315  {
316  global $lng;
317 
318  $ptpl = new ilTemplate("tpl.prop_password.html", true, true, "Services/Form");
319 
320  if ($this->getRetype())
321  {
322  $ptpl->setCurrentBlock("retype");
323  $ptpl->setVariable("RSIZE", $this->getSize());
324  $ptpl->setVariable("RID", $this->getFieldId());
325  $ptpl->setVariable("RMAXLENGTH", $this->getMaxLength());
326  $ptpl->setVariable("RPOST_VAR", $this->getPostVar());
327 
328  if($this->isHtmlAutoCompleteDisabled())
329  {
330  $ptpl->setVariable("RAUTOCOMPLETE", "autocomplete=\"off\"");
331  }
332 
333  // this is creating an "auto entry" in the setup, if the retype is missing
334  /*$retype_value = ($this->getRetypeValue() != "")
335  ? $this->getRetypeValue()
336  : $this->getValue();*/
337  $retype_value = $this->getRetypeValue();
338  $ptpl->setVariable("PROPERTY_RETYPE_VALUE", ilUtil::prepareFormOutput($retype_value));
339  if ($this->getDisabled())
340  {
341  $ptpl->setVariable("RDISABLED",
342  " disabled=\"disabled\"");
343  }
344  $ptpl->setVariable("TXT_RETYPE", $lng->txt("form_retype_password"));
345  $ptpl->parseCurrentBlock();
346  }
347 
348  if (strlen($this->getValue()))
349  {
350  $ptpl->setCurrentBlock("prop_password_propval");
351  $ptpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
352  $ptpl->parseCurrentBlock();
353  }
354  $ptpl->setVariable("POST_VAR", $this->getPostVar());
355  $ptpl->setVariable("ID", $this->getFieldId());
356  $ptpl->setVariable("SIZE", $this->getSize());
357  $ptpl->setVariable("MAXLENGTH", $this->getMaxLength());
358  if ($this->getDisabled())
359  {
360  $ptpl->setVariable("DISABLED",
361  " disabled=\"disabled\"");
362  }
363  if($this->isHtmlAutoCompleteDisabled())
364  {
365  $ptpl->setVariable("AUTOCOMPLETE", "autocomplete=\"off\"");
366  }
367  if($this->getRequired())
368  {
369  $ptpl->setVariable("REQUIRED", "required=\"required\"");
370  }
371  return $ptpl->get();
372  }
373 
379  function insert($a_tpl)
380  {
381  $html = $this->render();
382 
383  $a_tpl->setCurrentBlock("prop_generic");
384  $a_tpl->setVariable("PROP_GENERIC", $html);
385  $a_tpl->parseCurrentBlock();
386  }
387 }
388 ?>
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.
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.
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.
font size
Definition: langcheck.php:162
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.
This class represents a property that may include a sub form.
global $lng
Definition: privfeed.php:17
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.