ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilEMailInputGUI.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 = 30;
35  protected $max_length = 80;
36 
43  function __construct($a_title = "", $a_postvar = "")
44  {
45  parent::__construct($a_title, $a_postvar);
46  }
47 
53  function setValue($a_value)
54  {
55  $this->value = $a_value;
56  }
57 
63  function getValue()
64  {
65  return $this->value;
66  }
67 
73  function setValueByArray($a_values)
74  {
75  $this->setValue($a_values[$this->getPostVar()]);
76  }
77 
83  function checkInput()
84  {
85  global $lng;
86 
88  if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
89  {
90  $this->setAlert($lng->txt("msg_input_is_required"));
91 
92  return false;
93  }
94  if (!ilUtil::is_email($_POST[$this->getPostVar()]) &&
95  trim($_POST[$this->getPostVar()]) != "")
96  {
97  $this->setAlert($lng->txt("email_not_valid"));
98 
99  return false;
100  }
101 
102 
103  return true;
104  }
105 
109  function insert(&$a_tpl)
110  {
111  global $lng;
112 
113  $a_tpl->setCurrentBlock("prop_email");
114  $a_tpl->setVariable("POST_VAR", $this->getPostVar());
115  $a_tpl->setVariable("ID", $this->getFieldId());
116  $a_tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
117  $a_tpl->setVariable("SIZE", $this->size);
118  $a_tpl->setVariable("MAXLENGTH", $this->maxlength);
119  if ($this->getDisabled())
120  {
121  $a_tpl->setVariable("DISABLED",
122  " disabled=\"disabled\"");
123  }
124  $a_tpl->parseCurrentBlock();
125  }
126 }