ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 $max_length = 40;
16 protected $validateauthpost = "";
17 protected $requiredonauth = false;
18 protected $preselection = false;
19 protected $maxlength = false;
20
24 protected $autocomplete_disabled = true;
25
32 function __construct($a_title = "", $a_postvar = "")
33 {
34 parent::__construct($a_title, $a_postvar);
35 $this->setRetype(true);
36 $this->setSkipSyntaxCheck(false);
37 }
38
44 function setValue($a_value)
45 {
46 $this->value = $a_value;
47 }
48
54 function getValue()
55 {
56 return $this->value;
57 }
58
64 function setRetype($a_val)
65 {
66 $this->retype = $a_val;
67 }
68
74 function getRetype()
75 {
76 return $this->retype;
77 }
78
84 function setRetypeValue($a_retypevalue)
85 {
86 $this->retypevalue = $a_retypevalue;
87 }
88
94 function getRetypeValue()
95 {
96 return $this->retypevalue;
97 }
98
104 function setMaxLength($a_maxlength)
105 {
106 $this->maxlength = $a_maxlength;
107 }
108
114 function getMaxLength()
115 {
116 return $this->maxlength;
117 }
118
124 function setSize($a_size)
125 {
126 $this->size = $a_size;
127 }
128
134 function setPreSelection($a_val)
135 {
136 $this->preselection = $a_val;
137 }
138
145 {
146 return $this->preselection;
147 }
148
154 function setValueByArray($a_values)
155 {
156 $this->setValue($a_values[$this->getPostVar()]);
157 $this->setRetypeValue($a_values[$this->getPostVar()."_retype"]);
158 }
159
165 function getSize()
166 {
167 return $this->size;
168 }
169
175 function setValidateAuthPost($a_validateauthpost)
176 {
177 $this->validateauthpost = $a_validateauthpost;
178 }
179
186 {
188 }
189
195 function setRequiredOnAuth($a_requiredonauth)
196 {
197 $this->requiredonauth = $a_requiredonauth;
198 }
199
206 {
208 }
209
215 function setSkipSyntaxCheck($a_val)
216 {
217 $this->skip_syntax_check = $a_val;
218 }
219
226 {
227 return $this->skip_syntax_check;
228 }
229
235 function setDisableHtmlAutoComplete($a_value)
236 {
237 $this->autocomplete_disabled = (bool)$a_value;
238 }
239
246 {
248 }
249
255 function checkInput()
256 {
257 global $lng;
258
260 $_POST[$this->getPostVar()."_retype"] = ilUtil::stripSlashes($_POST[$this->getPostVar()."_retype"]);
261 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
262 {
263 $this->setAlert($lng->txt("msg_input_is_required"));
264
265 return false;
266 }
267 if ($this->getValidateAuthPost() != "")
268 {
270
271 // check, if password is required dependent on auth mode
273 && trim($_POST[$this->getPostVar()]) == "")
274 {
275 $this->setAlert($lng->txt("form_password_required_for_auth"));
276
277 return false;
278 }
279
280 // check, if password is allowed to be set for given auth mode
281 if (trim($_POST[$this->getPostVar()]) != "" &&
283 {
284 $this->setAlert($lng->txt("form_password_not_allowed_for_auth"));
285
286 return false;
287 }
288 }
289 if ($this->getRetype() && !$this->getPreSelection() &&
290 ($_POST[$this->getPostVar()] != $_POST[$this->getPostVar()."_retype"]))
291 {
292 $this->setAlert($lng->txt("passwd_not_match"));
293
294 return false;
295 }
296 if (!$this->getSkipSyntaxCheck() &&
297 !ilUtil::isPassword($_POST[$this->getPostVar()],$custom_error) &&
298 $_POST[$this->getPostVar()] != "")
299 {
300 if($custom_error != '') $this->setAlert($custom_error);
301 else $this->setAlert($lng->txt("passwd_invalid"));
302
303 return false;
304 }
305
306 return $this->checkSubItemsInput();
307 }
308
312 function render()
313 {
314 global $lng;
315
316 $ptpl = new ilTemplate("tpl.prop_password.html", true, true, "Services/Form");
317
318 if (!$this->getPreSelection())
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 }
368 else
369 {
370 // preselection
371 $passwd_list = ilUtil::generatePasswords(5);
372 foreach ($passwd_list as $passwd)
373 {
374 $i++;
375 $ptpl->setCurrentBlock("select_input");
376 $ptpl->setVariable("POST_VAR", $this->getPostVar());
377 $ptpl->setVariable("OP_ID", $this->getPostVar()."_".$i);
378 $ptpl->setVariable("VAL_RADIO_OPTION", $passwd);
379 $ptpl->setVariable("TXT_RADIO_OPTION", $passwd);
380 $ptpl->parseCurrentBlock();
381 }
382
383 }
384 return $ptpl->get();
385 }
386
392 function insert(&$a_tpl)
393 {
394 $html = $this->render();
395
396 $a_tpl->setCurrentBlock("prop_generic");
397 $a_tpl->setVariable("PROP_GENERIC", $html);
398 $a_tpl->parseCurrentBlock();
399 }
400}
401?>
static _allowPasswordModificationByAuthMode($a_auth_mode)
Allow password modification.
_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.
setPreSelection($a_val)
Set preselection.
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.
getPreSelection()
Get preselection.
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 generatePasswords($a_number)
Generate a number of passwords.
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
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40