ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilUserLoginInputGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  {
85  $lng = $this->lng;
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  "DISABLED",
121  " disabled=\"disabled\""
122  );
123  }
124  if ($this->isHtmlAutoCompleteDisabled()) {
125  $a_tpl->setVariable("AUTOCOMPLETE", "autocomplete=\"off\"");
126  }
127  if ($this->getRequired()) {
128  $a_tpl->setVariable("REQUIRED", "required=\"required\"");
129  }
130  $a_tpl->parseCurrentBlock();
131  }
132 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setDisableHtmlAutoComplete(bool $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...
This class represents a user login property in a property form.
static prepareFormOutput($a_str, bool $a_strip=false)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
static _loginExists(string $a_login, int $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
static isLogin(string $a_login)
global $DIC
Definition: shib_login.php:26
__construct(string $a_title="", string $a_postvar="")
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)