ILIAS  release_7 Revision v7.30-3-g800a261c036
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{
35 protected $lng;
36
37 protected $value;
38 protected $size = 30;
39 protected $max_length = 80;
40 protected $allowRFC822 = false; // [bool]
41
45 protected $retype = false;
46
50 protected $retypevalue = '';
51
57 public function __construct($a_title = "", $a_postvar = "")
58 {
59 global $DIC;
60
61 $this->lng = $DIC->language();
62 parent::__construct($a_title, $a_postvar);
63 $this->setRetype(false);
64 }
65
70 public function setValue($a_value)
71 {
72 $this->value = $a_value;
73 }
74
79 public function getValue()
80 {
81 return $this->value;
82 }
83
88 public function setValueByArray($a_values)
89 {
90 $this->setValue($a_values[$this->getPostVar()]);
91 $this->setRetypeValue($a_values[$this->getPostVar() . '_retype']);
92 }
93
101 public function allowRFC822($a_value)
102 {
103 $this->allowRFC822 = (bool) $a_value;
104 }
105
110 public function checkInput()
111 {
113
114 $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()], !(bool) $this->allowRFC822);
115 $_POST[$this->getPostVar() . '_retype'] = ilUtil::stripSlashes($_POST[$this->getPostVar() . '_retype'], !(bool) $this->allowRFC822);
116 if ($this->getRequired() && trim($_POST[$this->getPostVar()]) == "") {
117 $this->setAlert($lng->txt("msg_input_is_required"));
118
119 return false;
120 }
121 if ($this->getRetype() && ($_POST[$this->getPostVar()] != $_POST[$this->getPostVar() . '_retype'])) {
122 $this->setAlert($lng->txt('email_not_match'));
123
124 return false;
125 }
126 if (!ilUtil::is_email($_POST[$this->getPostVar()]) &&
127 trim($_POST[$this->getPostVar()]) != ""
128 ) {
129 $this->setAlert($lng->txt("email_not_valid"));
130
131 return false;
132 }
133
134
135 return true;
136 }
137
141 public function insert(ilTemplate $a_tpl)
142 {
144
145 $ptpl = new ilTemplate('tpl.prop_email.html', true, true, 'Services/Form');
146
147 if ($this->getRetype()) {
148 $ptpl->setCurrentBlock('retype_email');
149 $ptpl->setVariable('RSIZE', $this->getSize());
150 $ptpl->setVariable('RID', $this->getFieldId());
151 $ptpl->setVariable('RMAXLENGTH', $this->getMaxLength());
152 $ptpl->setVariable('RPOST_VAR', $this->getPostVar());
153
154 $retype_value = $this->getRetypeValue();
155 $ptpl->setVariable('PROPERTY_RETYPE_VALUE', ilUtil::prepareFormOutput($retype_value));
156 if ($this->getDisabled()) {
157 $ptpl->setVariable('RDISABLED', ' disabled="disabled"');
158 }
159 $ptpl->setVariable('TXT_RETYPE', $lng->txt('form_retype_email'));
160 $ptpl->parseCurrentBlock();
161 }
162
163 $ptpl->setVariable('POST_VAR', $this->getPostVar());
164 $ptpl->setVariable('ID', $this->getFieldId());
165 $ptpl->setVariable('PROPERTY_VALUE', ilUtil::prepareFormOutput($this->getValue()));
166 $ptpl->setVariable('SIZE', $this->getSize());
167 $ptpl->setVariable('MAXLENGTH', $this->getMaxLength());
168 if ($this->getDisabled()) {
169 $ptpl->setVariable('DISABLED', ' disabled="disabled"');
170 $ptpl->setVariable('HIDDEN_INPUT', $this->getHiddenTag($this->getPostVar(), $this->getValue()));
171 }
172
173 if ($this->getRequired()) {
174 $ptpl->setVariable("REQUIRED", "required=\"required\"");
175 }
176
177 $a_tpl->setCurrentBlock('prop_generic');
178 $a_tpl->setVariable('PROP_GENERIC', $ptpl->get());
179 $a_tpl->parseCurrentBlock();
180 }
181
185 public function setRetype($a_val)
186 {
187 $this->retype = $a_val;
188 }
189
193 public function getRetype()
194 {
195 return $this->retype;
196 }
197
201 public function setRetypeValue($a_retypevalue)
202 {
203 $this->retypevalue = $a_retypevalue;
204 }
205
209 public function getRetypeValue()
210 {
211 return $this->retypevalue;
212 }
213
217 public function setSize($size)
218 {
219 $this->size = $size;
220 }
221
225 public function getSize()
226 {
227 return $this->size;
228 }
229
233 public function setMaxLength($max_length)
234 {
235 $this->max_length = $max_length;
236 }
237
241 public function getMaxLength()
242 {
243 return $this->max_length;
244 }
245}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:615
This class represents a email property in a property form.
setRetypeValue($a_retypevalue)
allowRFC822($a_value)
Allow extended email address format.
setValue($a_value)
Set Value.
setValueByArray($a_values)
Set value by array.
insert(ilTemplate $a_tpl)
checkInput()
Check input, strip slashes etc.
__construct($a_title="", $a_postvar="")
Constructor.
This class represents a property in a property form.
getPostVar()
Get Post Variable.
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
setAlert($a_alert)
Set Alert Text.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt @access public.
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc