Browse code

Change the way how the original tl_member dca data is restored.

Benjamin Roth authored on09/10/2019 16:53:25
Showing1 changed files
... ...
@@ -29,12 +29,12 @@ namespace eSM_formilicious;
29 29
  */
30 30
 class ModuleRegistration extends \Contao\ModuleRegistration
31 31
 {
32
+  protected $originalDca;
33
+
32 34
   public function generate()
33 35
   {
34
-    $this->loadDataContainer('tl_member');
35
-    $originalDca = $GLOBALS['TL_DCA']['tl_member'];
36 36
     $return = parent::generate();
37
-    $GLOBALS['TL_DCA']['tl_member'] = $originalDca;
37
+    $GLOBALS['TL_DCA']['tl_member'] = $this->originalDca;
38 38
 
39 39
     return $return;
40 40
   }
... ...
@@ -52,7 +52,7 @@ class ModuleRegistration extends \Contao\ModuleRegistration
52 52
 
53 53
     \System::loadLanguageFile('tl_member');
54 54
     $this->loadDataContainer('tl_member');
55
-
55
+    $this->originalDca = $GLOBALS['TL_DCA']['tl_member'];
56 56
 
57 57
     $arrEditable = [];
58 58
     foreach ($this->editable as $key=>$fielddata)
Browse code

Restore Contao 4.5+ user registration modifications

Benjamin Roth authored on17/03/2019 20:51:03
Showing1 changed files
... ...
@@ -29,6 +29,16 @@ namespace eSM_formilicious;
29 29
  */
30 30
 class ModuleRegistration extends \Contao\ModuleRegistration
31 31
 {
32
+  public function generate()
33
+  {
34
+    $this->loadDataContainer('tl_member');
35
+    $originalDca = $GLOBALS['TL_DCA']['tl_member'];
36
+    $return = parent::generate();
37
+    $GLOBALS['TL_DCA']['tl_member'] = $originalDca;
38
+
39
+    return $return;
40
+  }
41
+
32 42
 
33 43
   /**
34 44
    * Generate the module
... ...
@@ -43,292 +53,26 @@ class ModuleRegistration extends \Contao\ModuleRegistration
43 53
     \System::loadLanguageFile('tl_member');
44 54
     $this->loadDataContainer('tl_member');
45 55
 
46
-    // Call onload_callback (e.g. to check permissions)
47
-    if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback']))
48
-    {
49
-      foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback)
50
-      {
51
-        if (is_array($callback))
52
-        {
53
-          $this->import($callback[0]);
54
-          $this->{$callback[0]}->{$callback[1]}();
55
-        }
56
-        elseif (is_callable($callback))
57
-        {
58
-          $callback();
59
-        }
60
-      }
61
-    }
62
-
63
-    // Activate account
64
-    if (\Input::get('token') != '')
65
-    {
66
-      $this->activateAcount();
67
-
68
-      return;
69
-    }
70
-
71
-    if ($this->memberTpl != '')
72
-    {
73
-      /** @var \FrontendTemplate|object $objTemplate */
74
-      $objTemplate = new \FrontendTemplate($this->memberTpl);
75
-
76
-      $this->Template = $objTemplate;
77
-      $this->Template->setData($this->arrData);
78
-    }
79
-
80
-    $this->Template->fields = '';
81
-    $this->Template->tableless = $this->tableless;
82
-    $objCaptcha = null;
83
-    $doNotSubmit = false;
84
-
85
-    // Predefine the group order (other groups will be appended automatically)
86
-    $arrGroups = array
87
-    (
88
-      'personal' => array(),
89
-      'address'  => array(),
90
-      'contact'  => array(),
91
-      'login'    => array(),
92
-      'profile'  => array()
93
-    );
94
-
95
-    // Captcha
96
-    if (!$this->disableCaptcha)
97
-    {
98
-      $arrCaptcha = array
99
-      (
100
-        'id' => 'registration',
101
-        'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
102
-        'type' => 'captcha',
103
-        'mandatory' => true,
104
-        'required' => true,
105
-        'tableless' => $this->tableless
106
-      );
107
-
108
-      /** @var \FormCaptcha $strClass */
109
-      $strClass = $GLOBALS['TL_FFL']['captcha'];
110
-
111
-      // Fallback to default if the class is not defined
112
-      if (!class_exists($strClass))
113
-      {
114
-        $strClass = 'FormCaptcha';
115
-      }
116
-
117
-      /** @var \FormCaptcha $objCaptcha */
118
-      $objCaptcha = new $strClass($arrCaptcha);
119
-
120
-      if (\Input::post('FORM_SUBMIT') == 'tl_registration')
121
-      {
122
-        $objCaptcha->validate();
123
-
124
-        if ($objCaptcha->hasErrors())
125
-        {
126
-          $doNotSubmit = true;
127
-        }
128
-      }
129
-    }
130
-
131
-    $arrUser = array();
132
-    $arrFields = array();
133
-    $hasUpload = false;
134
-    $i = 0;
135 56
 
136
-    // Build form
137
-    foreach ($this->editable as $fielddata)
57
+    $arrEditable = [];
58
+    foreach ($this->editable as $key=>$fielddata)
138 59
     {
139 60
       // Split formilicious editable data in single vars
140
-      list($field,$fieldWidth,$fieldClr,$fieldMandatory) = array_values($fielddata);
141
-
142
-      $arrData = $GLOBALS['TL_DCA']['tl_member']['fields'][$field];
143
-
144
-      // Map checkboxWizards to regular checkbox widgets
145
-      if ($arrData['inputType'] == 'checkboxWizard')
146
-      {
147
-        $arrData['inputType'] = 'checkbox';
148
-      }
149
-
150
-      // Map fileTrees to upload widgets (see #8091)
151
-      if ($arrData['inputType'] == 'fileTree')
152
-      {
153
-        $arrData['inputType'] = 'upload';
154
-      }
155
-
156
-      /** @var \Widget $strClass */
157
-      $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
158
-
159
-      // Continue if the class is not defined
160
-      if (!class_exists($strClass))
161
-      {
162
-        continue;
163
-      }
164
-
165
-      $arrData['eval']['tableless'] = $this->tableless;
166
-      $arrData['eval']['required'] = $arrData['eval']['mandatory'];
167
-
168
-      $objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $arrData['default'], '', '', $this));
169
-
170
-      $objWidget->storeValues = true;
171
-      $objWidget->rowClass = 'row_' . $i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
172
-
173
-      // Extend with formilicious data
174
-      $objWidget->eSM_fl_width = $fieldWidth;
175
-      $objWidget->eSM_fl_clear = $fieldClr;
61
+      list($field, $fieldWidth, $fieldClr, $fieldMandatory) = array_values($fielddata);
62
+      $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_width'] = $fieldWidth;
63
+      $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['eSM_fl_clear'] = $fieldClr;
176 64
       if ($fieldMandatory)
177 65
       {
178
-        $objWidget->required = $fieldMandatory;
179
-        $objWidget->mandatory = $fieldMandatory;
66
+        $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['mandatory'] = $fieldMandatory;
180 67
       } else {
181
-        $objWidget->required = false;
182
-        $objWidget->mandatory = false;
183
-      }
184
-      if (in_array($arrData['eval']['rgxp'], array('date','time','datim')))
185
-      {
186
-        $strDateFormatFunc = 'getNumeric'.ucfirst($arrData['eval']['rgxp']).'Format';
187
-        $objWidget->placeholder = \Date::getInputFormat(\Date::$strDateFormatFunc());
188
-        $objWidget->maxlength = strlen($objWidget->placeholder);
189
-      }
190
-
191
-      // Increase the row count if its a password field
192
-      if ($objWidget instanceof \FormPassword)
193
-      {
194
-        $objWidget->rowClassConfirm = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
195
-      }
196
-
197
-      // Validate input
198
-      if (\Input::post('FORM_SUBMIT') == 'tl_registration')
199
-      {
200
-        $objWidget->validate();
201
-        $varValue = $objWidget->value;
202
-
203
-        // Check whether the password matches the username
204
-        if ($objWidget instanceof \FormPassword && \Encryption::verify(\Input::post('username'), $varValue))
205
-        {
206
-          $objWidget->addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
207
-        }
208
-
209
-        $rgxp = $arrData['eval']['rgxp'];
210
-
211
-        // Convert date formats into timestamps (check the eval setting first -> #3063)
212
-        if ($varValue != '' && in_array($rgxp, array('date', 'time', 'datim')))
213
-        {
214
-          try
215
-          {
216
-            $objDate = new \Date($varValue, \Date::getFormatFromRgxp($rgxp));
217
-            $varValue = $objDate->tstamp;
218
-          }
219
-          catch (\OutOfBoundsException $e)
220
-          {
221
-            $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
222
-          }
223
-        }
224
-
225
-        // Make sure that unique fields are unique (check the eval setting first -> #3063)
226
-        if ($arrData['eval']['unique'] && $varValue != '' && !$this->Database->isUniqueValue('tl_member', $field, $varValue))
227
-        {
228
-          $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $field));
229
-        }
230
-
231
-        // Save callback
232
-        if ($objWidget->submitInput() && !$objWidget->hasErrors() && is_array($arrData['save_callback']))
233
-        {
234
-          foreach ($arrData['save_callback'] as $callback)
235
-          {
236
-            try
237
-            {
238
-              if (is_array($callback))
239
-              {
240
-                $this->import($callback[0]);
241
-                $varValue = $this->{$callback[0]}->{$callback[1]}($varValue, null);
242
-              }
243
-              elseif (is_callable($callback))
244
-              {
245
-                $varValue = $callback($varValue, null);
246
-              }
247
-            }
248
-            catch (\Exception $e)
249
-            {
250
-              $objWidget->class = 'error';
251
-              $objWidget->addError($e->getMessage());
252
-            }
253
-          }
254
-        }
68
+        $GLOBALS['TL_DCA']['tl_member']['fields'][$field]['eval']['mandatory'] = false;
255 69
 
256
-        // Store the current value
257
-        if ($objWidget->hasErrors())
258
-        {
259
-          $doNotSubmit = true;
260
-        }
261
-        elseif ($objWidget->submitInput())
262
-        {
263
-          // Set the correct empty value (see #6284, #6373)
264
-          if ($varValue === '')
265
-          {
266
-            $varValue = $objWidget->getEmptyValue();
267
-          }
268
-
269
-          // Encrypt the value (see #7815)
270
-          if ($arrData['eval']['encrypt'])
271
-          {
272
-            $varValue = \Encryption::encrypt($varValue);
273
-          }
274
-
275
-          // Set the new value
276
-          $arrUser[$field] = $varValue;
277
-        }
278
-      }
279
-
280
-      if ($objWidget instanceof \uploadable)
281
-      {
282
-        $hasUpload = true;
283 70
       }
284
-
285
-      $temp = $objWidget->parse();
286
-
287
-      $this->Template->fields .= $temp;
288
-      $arrFields[$arrData['eval']['feGroup']][$field] .= $temp;
289
-
290
-      ++$i;
291
-    }
292
-
293
-    // Captcha
294
-    if (!$this->disableCaptcha)
295
-    {
296
-      $objCaptcha->rowClass = 'row_'.$i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
297
-      $strCaptcha = $objCaptcha->parse();
298
-
299
-      $this->Template->fields .= $strCaptcha;
300
-      $arrFields['captcha']['captcha'] .= $strCaptcha;
301
-    }
302
-
303
-    $this->Template->rowLast = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
304
-    $this->Template->enctype = $hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
305
-    $this->Template->hasError = $doNotSubmit;
306
-
307
-    // Create new user if there are no errors
308
-    if (\Input::post('FORM_SUBMIT') == 'tl_registration' && !$doNotSubmit)
309
-    {
310
-      $this->createNewUser($arrUser);
71
+      $arrEditable[$key] = $field;
311 72
     }
73
+    $this->editable = $arrEditable;
312 74
 
313
-    $this->Template->loginDetails = $GLOBALS['TL_LANG']['tl_member']['loginDetails'];
314
-    $this->Template->addressDetails = $GLOBALS['TL_LANG']['tl_member']['addressDetails'];
315
-    $this->Template->contactDetails = $GLOBALS['TL_LANG']['tl_member']['contactDetails'];
316
-    $this->Template->personalData = $GLOBALS['TL_LANG']['tl_member']['personalData'];
317
-    $this->Template->captchaDetails = $GLOBALS['TL_LANG']['MSC']['securityQuestion'];
318
-
319
-    // Add the groups
320
-    foreach ($arrFields as $k=>$v)
321
-    {
322
-      $this->Template->$k = $v; // backwards compatibility
323
-
324
-      $key = $k . (($k == 'personal') ? 'Data' : 'Details');
325
-      $arrGroups[$GLOBALS['TL_LANG']['tl_member'][$key]] = $v;
326
-    }
75
+    parent::compile();
327 76
 
328
-    $this->Template->categories = $arrGroups;
329
-    $this->Template->formId = 'tl_registration';
330
-    $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['register']);
331
-    $this->Template->action = \Environment::get('indexFreeRequest');
332
-    $this->Template->captcha = $arrFields['captcha']['captcha']; // backwards compatibility
333 77
   }
334 78
 }
Browse code

Some 3.5.x optimizations and bugfixes

Benjamin Roth authored on05/10/2016 11:48:38
Showing1 changed files
... ...
@@ -30,291 +30,305 @@ namespace eSM_formilicious;
30 30
 class ModuleRegistration extends \Contao\ModuleRegistration
31 31
 {
32 32
 
33
-	/**
34
-	 * Generate the module
35
-	 */
36
-	protected function compile()
37
-	{
38
-		global $objPage;
39
-
40
-		$GLOBALS['TL_LANGUAGE'] = $objPage->language;
41
-
42
-		\System::loadLanguageFile('tl_member');
43
-		$this->loadDataContainer('tl_member');
44
-
45
-		// Call onload_callback (e.g. to check permissions)
46
-		if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback']))
47
-		{
48
-			foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback)
49
-			{
50
-				if (is_array($callback))
51
-				{
52
-					$this->import($callback[0]);
53
-					$this->$callback[0]->$callback[1]();
54
-				}
55
-				elseif (is_callable($callback))
56
-				{
57
-					$callback();
58
-				}
59
-			}
60
-		}
61
-
62
-		// Activate account
63
-		if (\Input::get('token') != '')
64
-		{
65
-			$this->activateAcount();
66
-			return;
67
-		}
68
-
69
-		if ($this->memberTpl != '')
70
-		{
71
-			$this->Template = new \FrontendTemplate($this->memberTpl);
72
-			$this->Template->setData($this->arrData);
73
-		}
74
-
75
-		$this->Template->fields = '';
76
-		$this->Template->tableless = $this->tableless;
77
-		$objCaptcha = null;
78
-		$doNotSubmit = false;
79
-
80
-		// Captcha
81
-		if (!$this->disableCaptcha)
82
-		{
83
-			$arrCaptcha = array
84
-			(
85
-				'id' => 'registration',
86
-				'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
87
-				'type' => 'captcha',
88
-				'mandatory' => true,
89
-				'required' => true,
90
-				'tableless' => $this->tableless
91
-			);
92
-
93
-			$strClass = $GLOBALS['TL_FFL']['captcha'];
94
-
95
-			// Fallback to default if the class is not defined
96
-			if (!class_exists($strClass))
97
-			{
98
-				$strClass = 'FormCaptcha';
99
-			}
100
-
101
-			$objCaptcha = new $strClass($arrCaptcha);
102
-
103
-			if (\Input::post('FORM_SUBMIT') == 'tl_registration')
104
-			{
105
-				$objCaptcha->validate();
106
-
107
-				if ($objCaptcha->hasErrors())
108
-				{
109
-					$doNotSubmit = true;
110
-				}
111
-			}
112
-		}
113
-
114
-		$arrUser = array();
115
-		$arrFields = array();
116
-		$hasUpload = false;
117
-		$i = 0;
118
-
119
-		// Build form
120
-		foreach ($this->editable as $fielddata)
121
-		{
122
-			// Split formilicious editable data in single vars
123
-			list($field,$fieldWidth,$fieldClr,$fieldMandatory) = array_values($fielddata);
124
-
125
-			$arrData = $GLOBALS['TL_DCA']['tl_member']['fields'][$field];
126
-
127
-			// Map checkboxWizard to regular checkbox widget
128
-			if ($arrData['inputType'] == 'checkboxWizard')
129
-			{
130
-				$arrData['inputType'] = 'checkbox';
131
-			}
132
-
133
-			$strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
134
-
135
-			// Continue if the class is not defined
136
-			if (!class_exists($strClass))
137
-			{
138
-				continue;
139
-			}
140
-
141
-			$arrData['eval']['tableless'] = $this->tableless;
142
-			$arrData['eval']['required'] = $arrData['eval']['mandatory'];
143
-
144
-			$objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $arrData['default'], '', '', $this));
145
-
146
-			$objWidget->storeValues = true;
147
-			$objWidget->rowClass = 'row_' . $i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
148
-
149
-			// Extend with formilicious data
150
-			$objWidget->eSM_fl_width = $fieldWidth;
151
-			$objWidget->eSM_fl_clear = $fieldClr;
152
-			if ($fieldMandatory)
153
-			{
154
-				$objWidget->required = $fieldMandatory;
155
-				$objWidget->mandatory = $fieldMandatory;
156
-			} else {
157
-				$objWidget->required = false;
158
-				$objWidget->mandatory = false;
159
-			}
160
-			if (in_array($arrData['eval']['rgxp'], array('date','time','datim')))
161
-			{
162
-				$strDateFormatFunc = 'getNumeric'.ucfirst($arrData['eval']['rgxp']).'Format';
163
-				$objWidget->placeholder = \Date::getInputFormat(\Date::$strDateFormatFunc());
164
-				$objWidget->maxlength = strlen($objWidget->placeholder);
165
-			}
166
-
167
-			// Increase the row count if its a password field
168
-			if ($objWidget instanceof \FormPassword)
169
-			{
170
-				$objWidget->rowClassConfirm = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
171
-			}
172
-
173
-			// Validate input
174
-			if (\Input::post('FORM_SUBMIT') == 'tl_registration')
175
-			{
176
-				$objWidget->validate();
177
-				$varValue = $objWidget->value;
178
-
179
-				// Check whether the password matches the username
180
-				if ($objWidget instanceof \FormPassword && $varValue == \Input::post('username'))
181
-				{
182
-					$objWidget->addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
183
-				}
184
-
185
-				$rgxp = $arrData['eval']['rgxp'];
186
-
187
-				// Convert date formats into timestamps (check the eval setting first -> #3063)
188
-				if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
189
-				{
190
-					try
191
-					{
192
-						$objDate = new \Date($varValue);
193
-						$varValue = $objDate->tstamp;
194
-					}
195
-					catch (\OutOfBoundsException $e)
196
-					{
197
-						$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
198
-					}
199
-				}
200
-
201
-				// Make sure that unique fields are unique (check the eval setting first -> #3063)
202
-				if ($arrData['eval']['unique'] && $varValue != '' && !$this->Database->isUniqueValue('tl_member', $field, $varValue))
203
-				{
204
-					$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $field));
205
-				}
206
-
207
-				// Save callback
208
-				if ($objWidget->submitInput() && !$objWidget->hasErrors() && is_array($arrData['save_callback']))
209
-				{
210
-					foreach ($arrData['save_callback'] as $callback)
211
-					{
212
-						try
213
-						{
214
-							if (is_array($callback))
215
-							{
216
-								$this->import($callback[0]);
217
-								$varValue = $this->$callback[0]->$callback[1]($varValue, null);
218
-							}
219
-							elseif (is_callable($callback))
220
-							{
221
-								$varValue = $callback($varValue, null);
222
-							}
223
-						}
224
-						catch (\Exception $e)
225
-						{
226
-							$objWidget->class = 'error';
227
-							$objWidget->addError($e->getMessage());
228
-						}
229
-					}
230
-				}
231
-
232
-				// Store the current value
233
-				if ($objWidget->hasErrors())
234
-				{
235
-					$doNotSubmit = true;
236
-				}
237
-				elseif ($objWidget->submitInput())
238
-				{
239
-					// Set the correct empty value (see #6284, #6373)
240
-					if ($varValue === '')
241
-					{
242
-						$varValue = $objWidget->getEmptyValue();
243
-					}
244
-
245
-					$arrUser[$field] = $varValue;
246
-				}
247
-			}
248
-
249
-			if ($objWidget instanceof \uploadable)
250
-			{
251
-				$hasUpload = true;
252
-			}
253
-
254
-			$temp = $objWidget->parse();
255
-
256
-			$this->Template->fields .= $temp;
257
-			$arrFields[$arrData['eval']['feGroup']][$field] .= $temp;
258
-
259
-			++$i;
260
-		}
261
-
262
-		// Captcha
263
-		if (!$this->disableCaptcha)
264
-		{
265
-			$objCaptcha->rowClass = 'row_'.$i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
266
-			$strCaptcha = $objCaptcha->parse();
267
-
268
-			$this->Template->fields .= $strCaptcha;
269
-			$arrFields['captcha'] .= $strCaptcha;
270
-		}
271
-
272
-		$this->Template->rowLast = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
273
-		$this->Template->enctype = $hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
274
-		$this->Template->hasError = $doNotSubmit;
275
-
276
-		// Create new user if there are no errors
277
-		if (\Input::post('FORM_SUBMIT') == 'tl_registration' && !$doNotSubmit)
278
-		{
279
-			$this->createNewUser($arrUser);
280
-		}
281
-
282
-		$this->Template->loginDetails = $GLOBALS['TL_LANG']['tl_member']['loginDetails'];
283
-		$this->Template->addressDetails = $GLOBALS['TL_LANG']['tl_member']['addressDetails'];
284
-		$this->Template->contactDetails = $GLOBALS['TL_LANG']['tl_member']['contactDetails'];
285
-		$this->Template->personalData = $GLOBALS['TL_LANG']['tl_member']['personalData'];
286
-		$this->Template->captchaDetails = $GLOBALS['TL_LANG']['MSC']['securityQuestion'];
287
-
288
-		// Add groups
289
-		foreach ($arrFields as $k=>$v)
290
-		{
291
-			$this->Template->$k = $v;
292
-		}
293
-
294
-		$this->Template->captcha = $arrFields['captcha'];
295
-		$this->Template->formId = 'tl_registration';
296
-		$this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['register']);
297
-		$this->Template->action = \Environment::get('indexFreeRequest');
298
-
299
-		// HOOK: add memberlist fields
300
-		if (in_array('memberlist', \ModuleLoader::getActive()))
301
-		{
302
-			$this->Template->profile = $arrFields['profile'];
303
-			$this->Template->profileDetails = $GLOBALS['TL_LANG']['tl_member']['profileDetails'];
304
-		}
305
-
306
-		// HOOK: add newsletter fields
307
-		if (in_array('newsletter', \ModuleLoader::getActive()))
308
-		{
309
-			$this->Template->newsletter = $arrFields['newsletter'];
310
-			$this->Template->newsletterDetails = $GLOBALS['TL_LANG']['tl_member']['newsletterDetails'];
311
-		}
312
-
313
-		// HOOK: add helpdesk fields
314
-		if (in_array('helpdesk', \ModuleLoader::getActive()))
315
-		{
316
-			$this->Template->helpdesk = $arrFields['helpdesk'];
317
-			$this->Template->helpdeskDetails = $GLOBALS['TL_LANG']['tl_member']['helpdeskDetails'];
318
-		}
319
-	}
33
+  /**
34
+   * Generate the module
35
+   */
36
+  protected function compile()
37
+  {
38
+    /** @var \PageModel $objPage */
39
+    global $objPage;
40
+
41
+    $GLOBALS['TL_LANGUAGE'] = $objPage->language;
42
+
43
+    \System::loadLanguageFile('tl_member');
44
+    $this->loadDataContainer('tl_member');
45
+
46
+    // Call onload_callback (e.g. to check permissions)
47
+    if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback']))
48
+    {
49
+      foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback)
50
+      {
51
+        if (is_array($callback))
52
+        {
53
+          $this->import($callback[0]);
54
+          $this->{$callback[0]}->{$callback[1]}();
55
+        }
56
+        elseif (is_callable($callback))
57
+        {
58
+          $callback();
59
+        }
60
+      }
61
+    }
62
+
63
+    // Activate account
64
+    if (\Input::get('token') != '')
65
+    {
66
+      $this->activateAcount();
67
+
68
+      return;
69
+    }
70
+
71
+    if ($this->memberTpl != '')
72
+    {
73
+      /** @var \FrontendTemplate|object $objTemplate */
74
+      $objTemplate = new \FrontendTemplate($this->memberTpl);
75
+
76
+      $this->Template = $objTemplate;
77
+      $this->Template->setData($this->arrData);
78
+    }
79
+
80
+    $this->Template->fields = '';
81
+    $this->Template->tableless = $this->tableless;
82
+    $objCaptcha = null;
83
+    $doNotSubmit = false;
84
+
85
+    // Predefine the group order (other groups will be appended automatically)
86
+    $arrGroups = array
87
+    (
88
+      'personal' => array(),
89
+      'address'  => array(),
90
+      'contact'  => array(),
91
+      'login'    => array(),
92
+      'profile'  => array()
93
+    );
94
+
95
+    // Captcha
96
+    if (!$this->disableCaptcha)
97
+    {
98
+      $arrCaptcha = array
99
+      (
100
+        'id' => 'registration',
101
+        'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
102
+        'type' => 'captcha',
103
+        'mandatory' => true,
104
+        'required' => true,
105
+        'tableless' => $this->tableless
106
+      );
107
+
108
+      /** @var \FormCaptcha $strClass */
109
+      $strClass = $GLOBALS['TL_FFL']['captcha'];
110
+
111
+      // Fallback to default if the class is not defined
112
+      if (!class_exists($strClass))
113
+      {
114
+        $strClass = 'FormCaptcha';
115
+      }
116
+
117
+      /** @var \FormCaptcha $objCaptcha */
118
+      $objCaptcha = new $strClass($arrCaptcha);
119
+
120
+      if (\Input::post('FORM_SUBMIT') == 'tl_registration')
121
+      {
122
+        $objCaptcha->validate();
123
+
124
+        if ($objCaptcha->hasErrors())
125
+        {
126
+          $doNotSubmit = true;
127
+        }
128
+      }
129
+    }
130
+
131
+    $arrUser = array();
132
+    $arrFields = array();
133
+    $hasUpload = false;
134
+    $i = 0;
135
+
136
+    // Build form
137
+    foreach ($this->editable as $fielddata)
138
+    {
139
+      // Split formilicious editable data in single vars
140
+      list($field,$fieldWidth,$fieldClr,$fieldMandatory) = array_values($fielddata);
141
+
142
+      $arrData = $GLOBALS['TL_DCA']['tl_member']['fields'][$field];
143
+
144
+      // Map checkboxWizards to regular checkbox widgets
145
+      if ($arrData['inputType'] == 'checkboxWizard')
146
+      {
147
+        $arrData['inputType'] = 'checkbox';
148
+      }
149
+
150
+      // Map fileTrees to upload widgets (see #8091)
151
+      if ($arrData['inputType'] == 'fileTree')
152
+      {
153
+        $arrData['inputType'] = 'upload';
154
+      }
155
+
156
+      /** @var \Widget $strClass */
157
+      $strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
158
+
159
+      // Continue if the class is not defined
160
+      if (!class_exists($strClass))
161
+      {
162
+        continue;
163
+      }
164
+
165
+      $arrData['eval']['tableless'] = $this->tableless;
166
+      $arrData['eval']['required'] = $arrData['eval']['mandatory'];
167
+
168
+      $objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $arrData['default'], '', '', $this));
169
+
170
+      $objWidget->storeValues = true;
171
+      $objWidget->rowClass = 'row_' . $i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
172
+
173
+      // Extend with formilicious data
174
+      $objWidget->eSM_fl_width = $fieldWidth;
175
+      $objWidget->eSM_fl_clear = $fieldClr;
176
+      if ($fieldMandatory)
177
+      {
178
+        $objWidget->required = $fieldMandatory;
179
+        $objWidget->mandatory = $fieldMandatory;
180
+      } else {
181
+        $objWidget->required = false;
182
+        $objWidget->mandatory = false;
183
+      }
184
+      if (in_array($arrData['eval']['rgxp'], array('date','time','datim')))
185
+      {
186
+        $strDateFormatFunc = 'getNumeric'.ucfirst($arrData['eval']['rgxp']).'Format';
187
+        $objWidget->placeholder = \Date::getInputFormat(\Date::$strDateFormatFunc());
188
+        $objWidget->maxlength = strlen($objWidget->placeholder);
189
+      }
190
+
191
+      // Increase the row count if its a password field
192
+      if ($objWidget instanceof \FormPassword)
193
+      {
194
+        $objWidget->rowClassConfirm = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
195
+      }
196
+
197
+      // Validate input
198
+      if (\Input::post('FORM_SUBMIT') == 'tl_registration')
199
+      {
200
+        $objWidget->validate();
201
+        $varValue = $objWidget->value;
202
+
203
+        // Check whether the password matches the username
204
+        if ($objWidget instanceof \FormPassword && \Encryption::verify(\Input::post('username'), $varValue))
205
+        {
206
+          $objWidget->addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
207
+        }
208
+
209
+        $rgxp = $arrData['eval']['rgxp'];
210
+
211
+        // Convert date formats into timestamps (check the eval setting first -> #3063)
212
+        if ($varValue != '' && in_array($rgxp, array('date', 'time', 'datim')))
213
+        {
214
+          try
215
+          {
216
+            $objDate = new \Date($varValue, \Date::getFormatFromRgxp($rgxp));
217
+            $varValue = $objDate->tstamp;
218
+          }
219
+          catch (\OutOfBoundsException $e)
220
+          {
221
+            $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
222
+          }
223
+        }
224
+
225
+        // Make sure that unique fields are unique (check the eval setting first -> #3063)
226
+        if ($arrData['eval']['unique'] && $varValue != '' && !$this->Database->isUniqueValue('tl_member', $field, $varValue))
227
+        {
228
+          $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $field));
229
+        }
230
+
231
+        // Save callback
232
+        if ($objWidget->submitInput() && !$objWidget->hasErrors() && is_array($arrData['save_callback']))
233
+        {
234
+          foreach ($arrData['save_callback'] as $callback)
235
+          {
236
+            try
237
+            {
238
+              if (is_array($callback))
239
+              {
240
+                $this->import($callback[0]);
241
+                $varValue = $this->{$callback[0]}->{$callback[1]}($varValue, null);
242
+              }
243
+              elseif (is_callable($callback))
244
+              {
245
+                $varValue = $callback($varValue, null);
246
+              }
247
+            }
248
+            catch (\Exception $e)
249
+            {
250
+              $objWidget->class = 'error';
251
+              $objWidget->addError($e->getMessage());
252
+            }
253
+          }
254
+        }
255
+
256
+        // Store the current value
257
+        if ($objWidget->hasErrors())
258
+        {
259
+          $doNotSubmit = true;
260
+        }
261
+        elseif ($objWidget->submitInput())
262
+        {
263
+          // Set the correct empty value (see #6284, #6373)
264
+          if ($varValue === '')
265
+          {
266
+            $varValue = $objWidget->getEmptyValue();
267
+          }
268
+
269
+          // Encrypt the value (see #7815)
270
+          if ($arrData['eval']['encrypt'])
271
+          {
272
+            $varValue = \Encryption::encrypt($varValue);
273
+          }
274
+
275
+          // Set the new value
276
+          $arrUser[$field] = $varValue;
277
+        }
278
+      }
279
+
280
+      if ($objWidget instanceof \uploadable)
281
+      {
282
+        $hasUpload = true;
283
+      }
284
+
285
+      $temp = $objWidget->parse();
286
+
287
+      $this->Template->fields .= $temp;
288
+      $arrFields[$arrData['eval']['feGroup']][$field] .= $temp;
289
+
290
+      ++$i;
291
+    }
292
+
293
+    // Captcha
294
+    if (!$this->disableCaptcha)
295
+    {
296
+      $objCaptcha->rowClass = 'row_'.$i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
297
+      $strCaptcha = $objCaptcha->parse();
298
+
299
+      $this->Template->fields .= $strCaptcha;
300
+      $arrFields['captcha']['captcha'] .= $strCaptcha;
301
+    }
302
+
303
+    $this->Template->rowLast = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
304
+    $this->Template->enctype = $hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
305
+    $this->Template->hasError = $doNotSubmit;
306
+
307
+    // Create new user if there are no errors
308
+    if (\Input::post('FORM_SUBMIT') == 'tl_registration' && !$doNotSubmit)
309
+    {
310
+      $this->createNewUser($arrUser);
311
+    }
312
+
313
+    $this->Template->loginDetails = $GLOBALS['TL_LANG']['tl_member']['loginDetails'];
314
+    $this->Template->addressDetails = $GLOBALS['TL_LANG']['tl_member']['addressDetails'];
315
+    $this->Template->contactDetails = $GLOBALS['TL_LANG']['tl_member']['contactDetails'];
316
+    $this->Template->personalData = $GLOBALS['TL_LANG']['tl_member']['personalData'];
317
+    $this->Template->captchaDetails = $GLOBALS['TL_LANG']['MSC']['securityQuestion'];
318
+
319
+    // Add the groups
320
+    foreach ($arrFields as $k=>$v)
321
+    {
322
+      $this->Template->$k = $v; // backwards compatibility
323
+
324
+      $key = $k . (($k == 'personal') ? 'Data' : 'Details');
325
+      $arrGroups[$GLOBALS['TL_LANG']['tl_member'][$key]] = $v;
326
+    }
327
+
328
+    $this->Template->categories = $arrGroups;
329
+    $this->Template->formId = 'tl_registration';
330
+    $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['register']);
331
+    $this->Template->action = \Environment::get('indexFreeRequest');
332
+    $this->Template->captcha = $arrFields['captcha']['captcha']; // backwards compatibility
333
+  }
320 334
 }
Browse code

Initial commit

Benjamin Roth authored on27/03/2015 10:45:40
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,320 @@
1
+<?php
2
+
3
+/**
4
+ * eSales Media Formilicious for Contao Open Source CMS
5
+ *
6
+ * Copyright (C) 2013-2014 eSalesMedia
7
+ *
8
+ * @package    eSM_formilicious
9
+ * @link       http://www.esales-media.de
10
+ * @license    http://www.gnu.org/licenses/lgpl-3.0.html LGPL
11
+ *
12
+ * @author     Benjamin Roth <benjamin@esales-media.de>
13
+ */
14
+
15
+
16
+/**
17
+ * Run in a custom namespace, so the class can be replaced
18
+ */
19
+namespace eSM_formilicious;
20
+
21
+
22
+/**
23
+ * Class ModuleRegistration
24
+ *
25
+ * Front end module "registration".
26
+ * @copyright  Leo Feyer 2005-2014
27
+ * @author     Leo Feyer <https://contao.org>
28
+ * @package    Core
29
+ */
30
+class ModuleRegistration extends \Contao\ModuleRegistration
31
+{
32
+
33
+	/**
34
+	 * Generate the module
35
+	 */
36
+	protected function compile()
37
+	{
38
+		global $objPage;
39
+
40
+		$GLOBALS['TL_LANGUAGE'] = $objPage->language;
41
+
42
+		\System::loadLanguageFile('tl_member');
43
+		$this->loadDataContainer('tl_member');
44
+
45
+		// Call onload_callback (e.g. to check permissions)
46
+		if (is_array($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback']))
47
+		{
48
+			foreach ($GLOBALS['TL_DCA']['tl_member']['config']['onload_callback'] as $callback)
49
+			{
50
+				if (is_array($callback))
51
+				{
52
+					$this->import($callback[0]);
53
+					$this->$callback[0]->$callback[1]();
54
+				}
55
+				elseif (is_callable($callback))
56
+				{
57
+					$callback();
58
+				}
59
+			}
60
+		}
61
+
62
+		// Activate account
63
+		if (\Input::get('token') != '')
64
+		{
65
+			$this->activateAcount();
66
+			return;
67
+		}
68
+
69
+		if ($this->memberTpl != '')
70
+		{
71
+			$this->Template = new \FrontendTemplate($this->memberTpl);
72
+			$this->Template->setData($this->arrData);
73
+		}
74
+
75
+		$this->Template->fields = '';
76
+		$this->Template->tableless = $this->tableless;
77
+		$objCaptcha = null;
78
+		$doNotSubmit = false;
79
+
80
+		// Captcha
81
+		if (!$this->disableCaptcha)
82
+		{
83
+			$arrCaptcha = array
84
+			(
85
+				'id' => 'registration',
86
+				'label' => $GLOBALS['TL_LANG']['MSC']['securityQuestion'],
87
+				'type' => 'captcha',
88
+				'mandatory' => true,
89
+				'required' => true,
90
+				'tableless' => $this->tableless
91
+			);
92
+
93
+			$strClass = $GLOBALS['TL_FFL']['captcha'];
94
+
95
+			// Fallback to default if the class is not defined
96
+			if (!class_exists($strClass))
97
+			{
98
+				$strClass = 'FormCaptcha';
99
+			}
100
+
101
+			$objCaptcha = new $strClass($arrCaptcha);
102
+
103
+			if (\Input::post('FORM_SUBMIT') == 'tl_registration')
104
+			{
105
+				$objCaptcha->validate();
106
+
107
+				if ($objCaptcha->hasErrors())
108
+				{
109
+					$doNotSubmit = true;
110
+				}
111
+			}
112
+		}
113
+
114
+		$arrUser = array();
115
+		$arrFields = array();
116
+		$hasUpload = false;
117
+		$i = 0;
118
+
119
+		// Build form
120
+		foreach ($this->editable as $fielddata)
121
+		{
122
+			// Split formilicious editable data in single vars
123
+			list($field,$fieldWidth,$fieldClr,$fieldMandatory) = array_values($fielddata);
124
+
125
+			$arrData = $GLOBALS['TL_DCA']['tl_member']['fields'][$field];
126
+
127
+			// Map checkboxWizard to regular checkbox widget
128
+			if ($arrData['inputType'] == 'checkboxWizard')
129
+			{
130
+				$arrData['inputType'] = 'checkbox';
131
+			}
132
+
133
+			$strClass = $GLOBALS['TL_FFL'][$arrData['inputType']];
134
+
135
+			// Continue if the class is not defined
136
+			if (!class_exists($strClass))
137
+			{
138
+				continue;
139
+			}
140
+
141
+			$arrData['eval']['tableless'] = $this->tableless;
142
+			$arrData['eval']['required'] = $arrData['eval']['mandatory'];
143
+
144
+			$objWidget = new $strClass($strClass::getAttributesFromDca($arrData, $field, $arrData['default'], '', '', $this));
145
+
146
+			$objWidget->storeValues = true;
147
+			$objWidget->rowClass = 'row_' . $i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
148
+
149
+			// Extend with formilicious data
150
+			$objWidget->eSM_fl_width = $fieldWidth;
151
+			$objWidget->eSM_fl_clear = $fieldClr;
152
+			if ($fieldMandatory)
153
+			{
154
+				$objWidget->required = $fieldMandatory;
155
+				$objWidget->mandatory = $fieldMandatory;
156
+			} else {
157
+				$objWidget->required = false;
158
+				$objWidget->mandatory = false;
159
+			}
160
+			if (in_array($arrData['eval']['rgxp'], array('date','time','datim')))
161
+			{
162
+				$strDateFormatFunc = 'getNumeric'.ucfirst($arrData['eval']['rgxp']).'Format';
163
+				$objWidget->placeholder = \Date::getInputFormat(\Date::$strDateFormatFunc());
164
+				$objWidget->maxlength = strlen($objWidget->placeholder);
165
+			}
166
+
167
+			// Increase the row count if its a password field
168
+			if ($objWidget instanceof \FormPassword)
169
+			{
170
+				$objWidget->rowClassConfirm = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
171
+			}
172
+
173
+			// Validate input
174
+			if (\Input::post('FORM_SUBMIT') == 'tl_registration')
175
+			{
176
+				$objWidget->validate();
177
+				$varValue = $objWidget->value;
178
+
179
+				// Check whether the password matches the username
180
+				if ($objWidget instanceof \FormPassword && $varValue == \Input::post('username'))
181
+				{
182
+					$objWidget->addError($GLOBALS['TL_LANG']['ERR']['passwordName']);
183
+				}
184
+
185
+				$rgxp = $arrData['eval']['rgxp'];
186
+
187
+				// Convert date formats into timestamps (check the eval setting first -> #3063)
188
+				if (($rgxp == 'date' || $rgxp == 'time' || $rgxp == 'datim') && $varValue != '')
189
+				{
190
+					try
191
+					{
192
+						$objDate = new \Date($varValue);
193
+						$varValue = $objDate->tstamp;
194
+					}
195
+					catch (\OutOfBoundsException $e)
196
+					{
197
+						$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
198
+					}
199
+				}
200
+
201
+				// Make sure that unique fields are unique (check the eval setting first -> #3063)
202
+				if ($arrData['eval']['unique'] && $varValue != '' && !$this->Database->isUniqueValue('tl_member', $field, $varValue))
203
+				{
204
+					$objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['unique'], $arrData['label'][0] ?: $field));
205
+				}
206
+
207
+				// Save callback
208
+				if ($objWidget->submitInput() && !$objWidget->hasErrors() && is_array($arrData['save_callback']))
209
+				{
210
+					foreach ($arrData['save_callback'] as $callback)
211
+					{
212
+						try
213
+						{
214
+							if (is_array($callback))
215
+							{
216
+								$this->import($callback[0]);
217
+								$varValue = $this->$callback[0]->$callback[1]($varValue, null);
218
+							}
219
+							elseif (is_callable($callback))
220
+							{
221
+								$varValue = $callback($varValue, null);
222
+							}
223
+						}
224
+						catch (\Exception $e)
225
+						{
226
+							$objWidget->class = 'error';
227
+							$objWidget->addError($e->getMessage());
228
+						}
229
+					}
230
+				}
231
+
232
+				// Store the current value
233
+				if ($objWidget->hasErrors())
234
+				{
235
+					$doNotSubmit = true;
236
+				}
237
+				elseif ($objWidget->submitInput())
238
+				{
239
+					// Set the correct empty value (see #6284, #6373)
240
+					if ($varValue === '')
241
+					{
242
+						$varValue = $objWidget->getEmptyValue();
243
+					}
244
+
245
+					$arrUser[$field] = $varValue;
246
+				}
247
+			}
248
+
249
+			if ($objWidget instanceof \uploadable)
250
+			{
251
+				$hasUpload = true;
252
+			}
253
+
254
+			$temp = $objWidget->parse();
255
+
256
+			$this->Template->fields .= $temp;
257
+			$arrFields[$arrData['eval']['feGroup']][$field] .= $temp;
258
+
259
+			++$i;
260
+		}
261
+
262
+		// Captcha
263
+		if (!$this->disableCaptcha)
264
+		{
265
+			$objCaptcha->rowClass = 'row_'.$i . (($i == 0) ? ' row_first' : '') . ((($i % 2) == 0) ? ' even' : ' odd');
266
+			$strCaptcha = $objCaptcha->parse();
267
+
268
+			$this->Template->fields .= $strCaptcha;
269
+			$arrFields['captcha'] .= $strCaptcha;
270
+		}
271
+
272
+		$this->Template->rowLast = 'row_' . ++$i . ((($i % 2) == 0) ? ' even' : ' odd');
273
+		$this->Template->enctype = $hasUpload ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
274
+		$this->Template->hasError = $doNotSubmit;
275
+
276
+		// Create new user if there are no errors
277
+		if (\Input::post('FORM_SUBMIT') == 'tl_registration' && !$doNotSubmit)
278
+		{
279
+			$this->createNewUser($arrUser);
280
+		}
281
+
282
+		$this->Template->loginDetails = $GLOBALS['TL_LANG']['tl_member']['loginDetails'];
283
+		$this->Template->addressDetails = $GLOBALS['TL_LANG']['tl_member']['addressDetails'];
284
+		$this->Template->contactDetails = $GLOBALS['TL_LANG']['tl_member']['contactDetails'];
285
+		$this->Template->personalData = $GLOBALS['TL_LANG']['tl_member']['personalData'];
286
+		$this->Template->captchaDetails = $GLOBALS['TL_LANG']['MSC']['securityQuestion'];
287
+
288
+		// Add groups
289
+		foreach ($arrFields as $k=>$v)
290
+		{
291
+			$this->Template->$k = $v;
292
+		}
293
+
294
+		$this->Template->captcha = $arrFields['captcha'];
295
+		$this->Template->formId = 'tl_registration';
296
+		$this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['register']);
297
+		$this->Template->action = \Environment::get('indexFreeRequest');
298
+
299
+		// HOOK: add memberlist fields
300
+		if (in_array('memberlist', \ModuleLoader::getActive()))
301
+		{
302
+			$this->Template->profile = $arrFields['profile'];
303
+			$this->Template->profileDetails = $GLOBALS['TL_LANG']['tl_member']['profileDetails'];
304
+		}
305
+
306
+		// HOOK: add newsletter fields
307
+		if (in_array('newsletter', \ModuleLoader::getActive()))
308
+		{
309
+			$this->Template->newsletter = $arrFields['newsletter'];
310
+			$this->Template->newsletterDetails = $GLOBALS['TL_LANG']['tl_member']['newsletterDetails'];
311
+		}
312
+
313
+		// HOOK: add helpdesk fields
314
+		if (in_array('helpdesk', \ModuleLoader::getActive()))
315
+		{
316
+			$this->Template->helpdesk = $arrFields['helpdesk'];
317
+			$this->Template->helpdeskDetails = $GLOBALS['TL_LANG']['tl_member']['helpdeskDetails'];
318
+		}
319
+	}
320
+}