ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilUserLoginInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
27 {
28  protected string $value = "";
29  protected int $size = 40;
30  protected int $max_length = 80;
31  protected int $checkunused = 0;
35  protected bool $autocomplete_disabled = false;
36 
37  public function __construct(
38  string $a_title = "",
39  string $a_postvar = ""
40  ) {
41  global $DIC;
42 
43  $this->lng = $DIC->language();
44  parent::__construct($a_title, $a_postvar);
45  }
46 
47  public function setValue(string $a_value): void
48  {
49  $this->value = $a_value;
50  }
51 
52  public function getValue(): string
53  {
54  return $this->value;
55  }
56 
57  public function setValueByArray(array $a_values): void
58  {
59  $this->setValue($a_values[$this->getPostVar()]);
60  }
61 
62  public function setCurrentUserId(int $a_user_id): void
63  {
64  $this->checkunused = $a_user_id;
65  }
66 
67  public function getCurrentUserId(): int
68  {
69  return $this->checkunused;
70  }
71 
72  public function setDisableHtmlAutoComplete(bool $a_value): void
73  {
74  $this->autocomplete_disabled = $a_value;
75  }
76 
77  public function isHtmlAutoCompleteDisabled(): bool
78  {
80  }
81 
82  public function checkInput(): bool
83  {
84  $lng = $this->lng;
85 
86  $value = $this->getInput();
87  if ($this->getRequired() && $value == "") {
88  $this->setAlert($lng->txt("msg_input_is_required"));
89  return false;
90  }
91  if (!ilUtil::isLogin($value)) {
92  $this->setAlert($lng->txt("login_invalid"));
93  return false;
94  }
95 
96  if (ilObjUser::_loginExists($value, $this->getCurrentUserId())) {
97  $this->setAlert($lng->txt("login_exists"));
98  return false;
99  }
100 
101  return true;
102  }
103 
104  public function getInput(): string
105  {
106  return trim($this->str($this->getPostVar()));
107  }
108 
109  public function insert(ilTemplate $a_tpl): void
110  {
111  $a_tpl->setCurrentBlock("prop_login");
112  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
113  $a_tpl->setVariable("ID", $this->getFieldId());
114  $a_tpl->setVariable("PROPERTY_VALUE", ilLegacyFormElementsUtil::prepareFormOutput($this->getValue()));
115  $a_tpl->setVariable("SIZE", $this->size);
116  $a_tpl->setVariable("MAXLENGTH", $this->max_length);
117  if ($this->getDisabled()) {
118  $a_tpl->setVariable(
119  "DISABLED",
120  " disabled=\"disabled\""
121  );
122  }
123  if ($this->isHtmlAutoCompleteDisabled()) {
124  $a_tpl->setVariable("AUTOCOMPLETE", "autocomplete=\"off\"");
125  }
126  if ($this->getRequired()) {
127  $a_tpl->setVariable("REQUIRED", "required=\"required\"");
128  }
129  $a_tpl->parseCurrentBlock();
130  }
131 }
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static prepareFormOutput($a_str, bool $a_strip=false)
global $DIC
Definition: feed.php:28
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
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)
__construct(string $a_title="", string $a_postvar="")
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a property in a property form.
__construct(Container $dic, ilPlugin $plugin)