ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserLoginInputGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
32 {
33  protected $value;
34  protected $size = 40;
35  protected $max_length = 80;
36  protected $checkunused = 0;
37 
44  function __construct($a_title = "", $a_postvar = "")
45  {
46  parent::__construct($a_title, $a_postvar);
47  }
48 
54  function setValue($a_value)
55  {
56  $this->value = $a_value;
57  }
58 
64  function getValue()
65  {
66  return $this->value;
67  }
68 
74  function setValueByArray($a_values)
75  {
76  $this->setValue($a_values[$this->getPostVar()]);
77  }
78 
84  function setCurrentUserId($a_user_id)
85  {
86  $this->checkunused = $a_user_id;
87  }
88 
94  function getCurrentUserId()
95  {
96  return $this->checkunused;
97  }
98 
104  function checkInput()
105  {
106  global $lng;
107 
108  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
109  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
110  {
111  $this->setAlert($lng->txt("msg_input_is_required"));
112 
113  return false;
114  }
115  if (!ilUtil::isLogin($_POST[$this->getPostVar()]))
116  {
117  $this->setAlert($lng->txt("login_invalid"));
118 
119  return false;
120  }
121 
122  if (ilObjUser::_loginExists($_POST[$this->getPostVar()],$this->getCurrentUserId()))
123  {
124  $this->setAlert($lng->txt("login_exists"));
125 
126  return false;
127  }
128 
129 
130  return true;
131  }
132 
136  function insert(&$a_tpl)
137  {
138  global $lng;
139 
140  $a_tpl->setCurrentBlock("prop_login");
141  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
142  $a_tpl->setVariable("ID", $this->getFieldId());
143  $a_tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
144  $a_tpl->setVariable("SIZE", $this->size);
145  $a_tpl->setVariable("MAXLENGTH", $this->maxlength);
146  if ($this->getDisabled())
147  {
148  $a_tpl->setVariable("DISABLED",
149  " disabled=\"disabled\"");
150  }
151  $a_tpl->parseCurrentBlock();
152  }
153 }