ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 {
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
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 {
260
261 if ($this->getUseStripSlashes()) {
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 {
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 $ptpl->setVariable("RMAXLENGTH", $this->getMaxLength());
324 $ptpl->setVariable("RPOST_VAR", $this->getPostVar());
325
326 if ($this->isHtmlAutoCompleteDisabled()) {
327 $ptpl->setVariable("RAUTOCOMPLETE", "autocomplete=\"off\"");
328 }
329
330 // this is creating an "auto entry" in the setup, if the retype is missing
331 /*$retype_value = ($this->getRetypeValue() != "")
332 ? $this->getRetypeValue()
333 : $this->getValue();*/
334 $retype_value = $this->getRetypeValue();
335 $ptpl->setVariable("PROPERTY_RETYPE_VALUE", ilUtil::prepareFormOutput($retype_value));
336 if ($this->getDisabled()) {
337 $ptpl->setVariable(
338 "RDISABLED",
339 " disabled=\"disabled\""
340 );
341 }
342 $ptpl->setVariable("TXT_RETYPE", $lng->txt("form_retype_password"));
343 $ptpl->parseCurrentBlock();
344 }
345
346 if (strlen($this->getValue())) {
347 $ptpl->setCurrentBlock("prop_password_propval");
348 $ptpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
349 $ptpl->parseCurrentBlock();
350 }
351 $ptpl->setVariable("POST_VAR", $this->getPostVar());
352 $ptpl->setVariable("ID", $this->getFieldId());
353 $ptpl->setVariable("SIZE", $this->getSize());
354 $ptpl->setVariable("MAXLENGTH", $this->getMaxLength());
355 if ($this->getDisabled()) {
356 $ptpl->setVariable(
357 "DISABLED",
358 " disabled=\"disabled\""
359 );
360 }
361 if ($this->isHtmlAutoCompleteDisabled()) {
362 $ptpl->setVariable("AUTOCOMPLETE", "autocomplete=\"off\"");
363 }
364 if ($this->getRequired()) {
365 $ptpl->setVariable("REQUIRED", "required=\"required\"");
366 }
367 return $ptpl->get();
368 }
369
375 public function insert($a_tpl)
376 {
377 $html = $this->render();
378
379 $a_tpl->setCurrentBlock("prop_generic");
380 $a_tpl->setVariable("PROP_GENERIC", $html);
381 $a_tpl->parseCurrentBlock();
382 }
383}
$auth
Definition: metadata.php:48
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static _allowPasswordModificationByAuthMode($a_auth_mode)
Allow password modification.
static _getAuthMode($a_auth_mode, $a_db_handler='')
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
This class represents a password property in a property form.
setValueByArray($a_values)
Set value by array.
checkInput()
Check input, strip slashes etc.
getRetypeValue()
Get Retype Value.
isHtmlAutoCompleteDisabled()
Get autocomplete.
getRetype()
Get retype on/off.
setRequiredOnAuth($a_requiredonauth)
Set input required, if authentication mode allows password setting.
getValidateAuthPost()
Get Validate required status against authentication POST var.
setDisableHtmlAutoComplete($a_value)
Set autocomplete.
getRequiredOnAuth()
Get input required, if authentication mode allows password setting.
insert($a_tpl)
Insert property html.
setRetype($a_val)
Set retype on/off.
__construct($a_title="", $a_postvar="")
Constructor.
setUseStripSlashes($a_stat)
En/disable use of stripslashes.
getSkipSyntaxCheck()
Get skip syntax check.
setRetypeValue($a_retypevalue)
Set Retype Value.
setSkipSyntaxCheck($a_val)
Set skip syntax check.
setValue($a_value)
Set Value.
setMaxLength($a_maxlength)
Set Max Length.
setValidateAuthPost($a_validateauthpost)
Set Validate required status against authentication POST var.
This class represents a property that may include a sub form.
special template class to simplify handling of ITX/PEAR
static isPassword($a_passwd, &$customError=null)
validates a password @access public
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$html
Definition: example_001.php:87
global $DIC
Definition: saml.php:7