ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilUserLoginInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28{
29 protected string $value = "";
30 protected int $size = 40;
31 protected int $max_length = 80;
32 protected int $checkunused = 0;
36 protected bool $autocomplete_disabled = false;
37
38 public function __construct(
39 string $a_title = "",
40 string $a_postvar = ""
41 ) {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 parent::__construct($a_title, $a_postvar);
46 }
47
48 public function setValue(string $a_value): void
49 {
50 $this->value = $a_value;
51 }
52
53 public function getValue(): string
54 {
55 return $this->value;
56 }
57
58 public function setValueByArray(array $a_values): void
59 {
60 $this->setValue($a_values[$this->getPostVar()] ?? '');
61 }
62
63 public function setCurrentUserId(int $a_user_id): void
64 {
65 $this->checkunused = $a_user_id;
66 }
67
68 public function getCurrentUserId(): int
69 {
70 return $this->checkunused;
71 }
72
73 public function setDisableHtmlAutoComplete(bool $a_value): void
74 {
75 $this->autocomplete_disabled = $a_value;
76 }
77
78 public function isHtmlAutoCompleteDisabled(): bool
79 {
81 }
82
83 public function checkInput(): bool
84 {
86
87 $value = $this->getInput();
88 if ($this->getRequired() && $value == "") {
89 $this->setAlert($lng->txt("msg_input_is_required"));
90 return false;
91 }
92 if (!ilUtil::isLogin($value)) {
93 $this->setAlert($lng->txt("login_invalid"));
94 return false;
95 }
96
97 if (ilObjUser::_loginExists($value, $this->getCurrentUserId())) {
98 $this->setAlert($lng->txt("login_exists"));
99 return false;
100 }
101
102 return true;
103 }
104
105 public function getInput(): string
106 {
107 return trim($this->str($this->getPostVar()));
108 }
109
110 public function insert(ilTemplate $a_tpl): void
111 {
112 $a_tpl->setCurrentBlock("prop_login");
113 $a_tpl->setVariable("POST_VAR", $this->getPostVar());
114 $a_tpl->setVariable("ID", $this->getFieldId());
115 $a_tpl->setVariable("PROPERTY_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($this->getValue()));
116 $a_tpl->setVariable("SIZE", $this->size);
117 $a_tpl->setVariable("MAXLENGTH", $this->max_length);
118 if ($this->getDisabled()) {
119 $a_tpl->setVariable(
120 "HIDDEN_INPUT",
121 $this->getHiddenTag($this->getPostVar(), $this->getValue())
122 );
123 $a_tpl->setVariable(
124 "DISABLED",
125 " disabled=\"disabled\""
126 );
127 }
128 if ($this->isHtmlAutoCompleteDisabled()) {
129 $a_tpl->setVariable("AUTOCOMPLETE", "autocomplete=\"off\"");
130 }
131 if ($this->getRequired()) {
132 $a_tpl->setVariable("REQUIRED", "required=\"required\"");
133 }
134 $a_tpl->parseCurrentBlock();
135 }
136}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
This class represents a property in a property form.
getHiddenTag(string $a_post_var, string $a_value)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static prepareFormOutput($a_str, bool $a_strip=false)
static _loginExists(string $a_login, int $a_user_id=0)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a user login property in a property form.
setDisableHtmlAutoComplete(bool $a_value)
checkInput()
Check input, strip slashes etc.
__construct(string $a_title="", string $a_postvar="")
static isLogin(string $a_login)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26