ILIAS  Release_4_4_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 
31 {
32  protected $value;
33  protected $size = 30;
34  protected $max_length = 80;
35 
39  protected $retype = false;
40 
44  protected $retypevalue = '';
45 
51  function __construct($a_title = "", $a_postvar = "")
52  {
53  parent::__construct($a_title, $a_postvar);
54  $this->setRetype(false);
55  }
56 
61  function setValue($a_value)
62  {
63  $this->value = $a_value;
64  }
65 
70  function getValue()
71  {
72  return $this->value;
73  }
74 
79  function setValueByArray($a_values)
80  {
81  $this->setValue($a_values[$this->getPostVar()]);
82  $this->setRetypeValue($a_values[$this->getPostVar() . '_retype']);
83  }
84 
89  function checkInput()
90  {
91  global $lng;
92 
94  $_POST[$this->getPostVar() . '_retype'] = ilUtil::stripSlashes($_POST[$this->getPostVar() . '_retype']);
95  if($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
96  {
97  $this->setAlert($lng->txt("msg_input_is_required"));
98 
99  return false;
100  }
101  if($this->getRetype() && ($_POST[$this->getPostVar()] != $_POST[$this->getPostVar() . '_retype']))
102  {
103  $this->setAlert($lng->txt('email_not_match'));
104 
105  return false;
106  }
107  if(!ilUtil::is_email($_POST[$this->getPostVar()]) &&
108  trim($_POST[$this->getPostVar()]) != ""
109  )
110  {
111  $this->setAlert($lng->txt("email_not_valid"));
112 
113  return false;
114  }
115 
116 
117  return true;
118  }
119 
123  function insert(ilTemplate $a_tpl)
124  {
125  global $lng;
126 
127  $ptpl = new ilTemplate('tpl.prop_email.html', true, true, 'Services/Form');
128 
129  if($this->getRetype())
130  {
131  $ptpl->setCurrentBlock('retype_email');
132  $ptpl->setVariable('RSIZE', $this->getSize());
133  $ptpl->setVariable('RID', $this->getFieldId());
134  $ptpl->setVariable('RMAXLENGTH', $this->getMaxLength());
135  $ptpl->setVariable('RPOST_VAR', $this->getPostVar());
136 
137  $retype_value = $this->getRetypeValue();
138  $ptpl->setVariable('PROPERTY_RETYPE_VALUE', ilUtil::prepareFormOutput($retype_value));
139  if($this->getDisabled())
140  {
141  $ptpl->setVariable('RDISABLED', ' disabled="disabled"');
142  }
143  $ptpl->setVariable('TXT_RETYPE', $lng->txt('form_retype_email'));
144  $ptpl->parseCurrentBlock();
145  }
146 
147  $ptpl->setVariable('POST_VAR', $this->getPostVar());
148  $ptpl->setVariable('ID', $this->getFieldId());
149  $ptpl->setVariable('PROPERTY_VALUE', ilUtil::prepareFormOutput($this->getValue()));
150  $ptpl->setVariable('SIZE', $this->getSize());
151  $ptpl->setVariable('MAXLENGTH', $this->getMaxLength());
152  if($this->getDisabled())
153  {
154  $ptpl->setVariable('DISABLED', ' disabled="disabled"');
155  $ptpl->setVariable('HIDDEN_INPUT', $this->getHiddenTag($this->getPostVar(), $this->getValue()));
156  }
157 
158  $a_tpl->setCurrentBlock('prop_generic');
159  $a_tpl->setVariable('PROP_GENERIC', $ptpl->get());
160  $a_tpl->parseCurrentBlock();
161  }
162 
166  public function setRetype($a_val)
167  {
168  $this->retype = $a_val;
169  }
170 
174  public function getRetype()
175  {
176  return $this->retype;
177  }
178 
182  public function setRetypeValue($a_retypevalue)
183  {
184  $this->retypevalue = $a_retypevalue;
185  }
186 
190  public function getRetypeValue()
191  {
192  return $this->retypevalue;
193  }
194 
198  public function setSize($size)
199  {
200  $this->size = $size;
201  }
202 
206  public function getSize()
207  {
208  return $this->size;
209  }
210 
214  public function setMaxLength($max_length)
215  {
216  $this->max_length = $max_length;
217  }
218 
222  public function getMaxLength()
223  {
224  return $this->max_length;
225  }
226 }