ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
31 {
32  protected $value;
33  protected $size = 30;
34  protected $max_length = 80;
35  protected $allowRFC822 = false; // [bool]
36 
40  protected $retype = false;
41 
45  protected $retypevalue = '';
46 
52  function __construct($a_title = "", $a_postvar = "")
53  {
54  parent::__construct($a_title, $a_postvar);
55  $this->setRetype(false);
56  }
57 
62  function setValue($a_value)
63  {
64  $this->value = $a_value;
65  }
66 
71  function getValue()
72  {
73  return $this->value;
74  }
75 
80  function setValueByArray($a_values)
81  {
82  $this->setValue($a_values[$this->getPostVar()]);
83  $this->setRetypeValue($a_values[$this->getPostVar() . '_retype']);
84  }
85 
93  function allowRFC822($a_value)
94  {
95  $this->allowRFC822 = (bool)$a_value;
96  }
97 
102  function checkInput()
103  {
104  global $lng;
105 
106  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()], !(bool)$this->allowRFC822);
107  $_POST[$this->getPostVar() . '_retype'] = ilUtil::stripSlashes($_POST[$this->getPostVar() . '_retype'], !(bool)$this->allowRFC822);
108  if($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
109  {
110  $this->setAlert($lng->txt("msg_input_is_required"));
111 
112  return false;
113  }
114  if($this->getRetype() && ($_POST[$this->getPostVar()] != $_POST[$this->getPostVar() . '_retype']))
115  {
116  $this->setAlert($lng->txt('email_not_match'));
117 
118  return false;
119  }
120  if(!ilUtil::is_email($_POST[$this->getPostVar()]) &&
121  trim($_POST[$this->getPostVar()]) != ""
122  )
123  {
124  $this->setAlert($lng->txt("email_not_valid"));
125 
126  return false;
127  }
128 
129 
130  return true;
131  }
132 
136  function insert(ilTemplate $a_tpl)
137  {
138  global $lng;
139 
140  $ptpl = new ilTemplate('tpl.prop_email.html', true, true, 'Services/Form');
141 
142  if($this->getRetype())
143  {
144  $ptpl->setCurrentBlock('retype_email');
145  $ptpl->setVariable('RSIZE', $this->getSize());
146  $ptpl->setVariable('RID', $this->getFieldId());
147  $ptpl->setVariable('RMAXLENGTH', $this->getMaxLength());
148  $ptpl->setVariable('RPOST_VAR', $this->getPostVar());
149 
150  $retype_value = $this->getRetypeValue();
151  $ptpl->setVariable('PROPERTY_RETYPE_VALUE', ilUtil::prepareFormOutput($retype_value));
152  if($this->getDisabled())
153  {
154  $ptpl->setVariable('RDISABLED', ' disabled="disabled"');
155  }
156  $ptpl->setVariable('TXT_RETYPE', $lng->txt('form_retype_email'));
157  $ptpl->parseCurrentBlock();
158  }
159 
160  $ptpl->setVariable('POST_VAR', $this->getPostVar());
161  $ptpl->setVariable('ID', $this->getFieldId());
162  $ptpl->setVariable('PROPERTY_VALUE', ilUtil::prepareFormOutput($this->getValue()));
163  $ptpl->setVariable('SIZE', $this->getSize());
164  $ptpl->setVariable('MAXLENGTH', $this->getMaxLength());
165  if($this->getDisabled())
166  {
167  $ptpl->setVariable('DISABLED', ' disabled="disabled"');
168  $ptpl->setVariable('HIDDEN_INPUT', $this->getHiddenTag($this->getPostVar(), $this->getValue()));
169  }
170 
171  if($this->getRequired())
172  {
173  $ptpl->setVariable("REQUIRED", "required=\"required\"");
174  }
175 
176  $a_tpl->setCurrentBlock('prop_generic');
177  $a_tpl->setVariable('PROP_GENERIC', $ptpl->get());
178  $a_tpl->parseCurrentBlock();
179  }
180 
184  public function setRetype($a_val)
185  {
186  $this->retype = $a_val;
187  }
188 
192  public function getRetype()
193  {
194  return $this->retype;
195  }
196 
200  public function setRetypeValue($a_retypevalue)
201  {
202  $this->retypevalue = $a_retypevalue;
203  }
204 
208  public function getRetypeValue()
209  {
210  return $this->retypevalue;
211  }
212 
216  public function setSize($size)
217  {
218  $this->size = $size;
219  }
220 
224  public function getSize()
225  {
226  return $this->size;
227  }
228 
232  public function setMaxLength($max_length)
233  {
234  $this->max_length = $max_length;
235  }
236 
240  public function getMaxLength()
241  {
242  return $this->max_length;
243  }
244 }
setValue($a_value)
Set Value.
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
insert(ilTemplate $a_tpl)
getPostVar()
Get Post Variable.
static is_email($a_email)
This preg-based function checks whether an e-mail address is formally valid.
This class represents a email property in a property form.
__construct($a_title="", $a_postvar="")
Constructor.
setAlert($a_alert)
Set Alert Text.
setRetypeValue($a_retypevalue)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:613
font size
Definition: langcheck.php:162
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
setValueByArray($a_values)
Set value by array.
checkInput()
Check input, strip slashes etc.
This class represents a property in a property form.
global $lng
Definition: privfeed.php:17
allowRFC822($a_value)
Allow extended email address format.
$_POST["username"]
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...