/** * Generate the module */ protected function compile() { $this->import('FrontendUser', 'User'); // Initialize the password widget $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless)); $objWidget = new \FormTextField(\FormTextField::getAttributesFromDca($arrField, $arrField['name'])); $objWidget->rowClass = 'row_0 row_first even'; // Validate widget if (\Input::post('FORM_SUBMIT') == 'tl_close_account') { $objWidget->validate(); // Validate the password if (!$objWidget->hasErrors()) { // The password has been generated with crypt() if (\Encryption::test($this->User->password)) { $blnAuthenticated = \Encryption::verify($objWidget->value, $this->User->password); } else { list($strPassword, $strSalt) = explode(':', $this->User->password); $blnAuthenticated = $strSalt == '' ? $strPassword === sha1($objWidget->value) : $strPassword === sha1($strSalt . $objWidget->value); } if (!$blnAuthenticated) { $objWidget->value = ''; $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']); } } // Close account if (!$objWidget->hasErrors()) { // HOOK: send account ID if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) { foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this); } } $objMember = \MemberModel::findByPk($this->User->id); // Remove the account if ($this->reg_close == 'close_delete') { $objMember->delete(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', __METHOD__, TL_ACCESS); } else { $objMember->disable = 1; $objMember->tstamp = time(); $objMember->save(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', __METHOD__, TL_ACCESS); } $this->User->logout(); // Check whether there is a jumpTo page if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) { $this->jumpToOrReload($objJumpTo->row()); } $this->reload(); } } $this->Template->fields = $objWidget->parse(); $this->Template->formId = 'tl_close_account'; $this->Template->action = \Environment::get('indexFreeRequest'); $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']); $this->Template->rowLast = 'row_1 row_last odd'; $this->Template->tableless = $this->tableless; }
/** * Generate the module */ protected function compile() { $this->import('FrontendUser', 'User'); // Initialize the password widget $arrField = array('name' => 'password', 'inputType' => 'text', 'label' => $GLOBALS['TL_LANG']['MSC']['password'][0], 'eval' => array('hideInput' => true, 'mandatory' => true, 'required' => true, 'tableless' => $this->tableless)); $objWidget = new \FormTextField($this->prepareForWidget($arrField, $arrField['name'])); $objWidget->rowClass = 'row_0 row_first even'; // Validate widget if (\Input::post('FORM_SUBMIT') == 'tl_close_account') { $objWidget->validate(); // Validate password if (!$objWidget->hasErrors()) { list(, $strSalt) = explode(':', $this->User->password); if (!strlen($strSalt) || sha1($strSalt . $objWidget->value) . ':' . $strSalt != $this->User->password) { $objWidget->value = ''; $objWidget->addError($GLOBALS['TL_LANG']['ERR']['invalidPass']); } } // Close account if (!$objWidget->hasErrors()) { // HOOK: send account ID if (isset($GLOBALS['TL_HOOKS']['closeAccount']) && is_array($GLOBALS['TL_HOOKS']['closeAccount'])) { foreach ($GLOBALS['TL_HOOKS']['closeAccount'] as $callback) { $this->import($callback[0]); $this->{$callback}[0]->{$callback}[1]($this->User->id, $this->reg_close, $this); } } $objMember = \MemberModel::findByPk($this->User->id); // Remove the account if ($this->reg_close == 'close_delete') { $objMember->delete(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deleted', 'ModuleCloseAccount compile()', TL_ACCESS); } else { $objMember->disable = 1; $objMember->save(); $this->log('User account ID ' . $this->User->id . ' (' . $this->User->email . ') has been deactivated', 'ModuleCloseAccount compile()', TL_ACCESS); } $this->User->logout(); $this->jumpToOrReload($this->objModel->getRelated('jumpTo')->row()); } } $this->Template->fields = $objWidget->parse(); $this->Template->formId = 'tl_close_account'; $this->Template->action = $this->getIndexFreeRequest(); $this->Template->slabel = specialchars($GLOBALS['TL_LANG']['MSC']['closeAccount']); $this->Template->rowLast = 'row_1 row_last odd'; $this->Template->tableless = $this->tableless; }
public function __set($strKey, $varValue) { if ($varValue == '') { return; } switch ($strKey) { case 'category': case 'bounds': case 'componentRestrictions': case 'callback': case 'use_route_type': case 'use_street_number_type': case 'use_locality_type': case 'use_administrative_area_level_1_type': case 'use_country_type': case 'use_postal_code_type': case 'use_lat_long': $this->options[$strKey] = $varValue; break; case 'use_route': case 'use_street_number': case 'use_locality': case 'use_administrative_area_level_1': case 'use_country': case 'use_postal_code': $this->useFields[substr($strKey, 4)] = $varValue; break; default: parent::__set($strKey, $varValue); break; } }
public function __construct($arrAttributes = null) { parent::__construct($arrAttributes); $this->evals = $arrAttributes; if (!$this->dateExcludeCSS) { $GLOBALS['TL_CSS'][] = 'composer/vendor/eternicode/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css'; } // include jquery into backend if (TL_MODE == 'BE') { if (!is_array($GLOBALS['TL_JAVASCRIPT'])) { $GLOBALS['TL_JAVASCRIPT'] = array(); } array_unshift($GLOBALS['TL_JAVASCRIPT'], 'system/modules/bootstrap-datepicker/assets/jquery.noconflict.js'); $jquery_src = 'assets/jquery/core/' . reset(scandir(TL_ROOT . '/assets/jquery/core', 1)) . '/jquery.min.js'; array_unshift($GLOBALS['TL_JAVASCRIPT'], $jquery_src); } if (!$this->dateExcludeJS) { $GLOBALS['TL_JAVASCRIPT'][] = 'composer/vendor/eternicode/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js'; $GLOBALS['TL_JAVASCRIPT'][] = 'composer/vendor/eternicode/bootstrap-datepicker/dist/locales/bootstrap-datepicker.de.min.js'; } }
/** * Parse the template file and return it as string * @param array * @return string */ public function parse($arrAttributes = null) { if ($this->formcontrol_template) { $this->strTemplate = $this->formcontrol_template; // Hide the Punycode format (see #2750) if ($this->rgxp == 'email' || $this->rgxp == 'friendly' || $this->rgxp == 'url') { $this->varValue = \Idna::decode($this->varValue); } if ($this->hideInput) { $strType = 'password'; } elseif ($this->strFormat != 'xhtml') { // Use the HTML5 types (see #4138) // but not the date, time and datetime types (see #5918) switch ($this->rgxp) { case 'digit': $strType = 'number'; break; case 'phone': $strType = 'tel'; break; case 'email': $strType = 'email'; break; case 'url': $strType = 'url'; break; default: $strType = 'text'; break; } } else { $strType = 'text'; } $this->type = $strType; } return parent::parse($arrAttributes); }
/** * Feld generieren * @return <type> */ public function generate() { $strBuffer = parent::generate(); if ($this->readonly || $this->disabled) { return $strBuffer; } //CSS und JAVACRIPT laden $GLOBALS['TL_CSS'][] = 'plugins/datepicker/dashboard.css'; $GLOBALS['TL_JAVASCRIPT'][] = 'plugins/datepicker/datepicker.js'; //Datumsformat setzen $dateFormat = strlen($this->xdateformat) ? $this->xdateformat : $GLOBALS['TL_CONFIG']['dateFormat']; $dateFormat_kalender = "%d.%m.%Y"; if (strlen($this->xdateformat) == 5) { $dateFormat_kalender = str_replace('d', '%d', $this->xdateformat); $dateFormat_kalender = str_replace('m', '%m', $dateFormat_kalender); $dateFormat_kalender = str_replace('Y', '%Y', $dateFormat_kalender); } //Startwert aufarbeiten $xstartwertset = $this->setzteXWert($this->xstartwert, $dateFormat); //Stopwert setzen $xstopwertset = $this->setzteXWert($this->xstopwert, $dateFormat); //---------------------------------------------------------------------- //Picker zusammenbauen //---------------------------------------------------------------------- $strBuffer = str_replace('class', 'class', $strBuffer); if ($this->varValue == "") { $strBuffer = str_replace('value="', 'value="' . ($xstartwertset == "" ? date($dateFormat) : $xstartwertset), $strBuffer); } $strBuffer .= '<img src="plugins/datepicker/icon.gif" id="xdate_toggler' . $this->strId . '" class="xdate_toggler' . $this->strId . '" alt="calenderbild" style="position: relative; top: 3px; margin-left: 4px;" />'; //Keine Abhänignkeit da if ($this->xdepend == "none") { $objTE = $this->Database->prepare("SELECT id FROM tl_form_field WHERE xdepend=?")->execute($this->strId); if ($objTE->numRows == 0) { $strBuffer .= ' <script type="text/javascript"> <!--//--><![CDATA[//><!-- window.addEvent("load", function() { new Picker.Date($$("#ctrl_' . $this->strId . '"), { draggable:false, toggle:$$("#xdate_toggler' . $this->strId . '"), format:"' . $dateFormat_kalender . '", timePicker:false, pickerClass:"datepicker_dashboard", days_abbr: ' . $GLOBALS['TL_LANG']['FFL']['xdependentcalendarfields']['days'] . ', months_abbr: ' . $GLOBALS['TL_LANG']['FFL']['xdependentcalendarfields']['month'] . ', useFadeInOut:!Browser.ie, startDay:1, allowEmpty:false, titleFormat:"%d. %B %Y" '; //Startwert if ($xstartwertset != "") { $strBuffer .= ',minDate : "' . $xstartwertset . '"'; } //Stopwert if ($xstopwertset != "") { $strBuffer .= ',maxDate : "' . $xstopwertset . '"'; } $strBuffer .= "});});//--><!]]></script>"; } } else { //Erster Kalender $objDatenxdepend = $this->Database->prepare("SELECT xstartwert,xstopwert FROM tl_form_field WHERE id=?")->execute($this->xdepend); $xstartwertset_depend = $xstartwertset; $xstopwertset_depend = $xstopwertset; if ($objDatenxdepend->numRows > 0) { $ergobjDatenxdepend = $objDatenxdepend->fetchAssoc(); $xstartwertset_depend = $this->setzteXWert($ergobjDatenxdepend['xstartwert'], $dateFormat); $xstopwertset_depend = $this->setzteXWert($ergobjDatenxdepend['xstopwert'], $dateFormat); } $strBuffer .= ' <script type="text/javascript"> <!--//--><![CDATA[//><!-- window.addEvent("load", function() { var xdatepicker' . $this->xdepend . ' = new Picker.Date($$("#ctrl_' . $this->xdepend . '"), { draggable:false, toggle:$$("#xdate_toggler' . $this->xdepend . '"), format:"' . $dateFormat_kalender . '", timePicker:false, pickerClass:"datepicker_dashboard", days_abbr: ' . $GLOBALS['TL_LANG']['FFL']['xdependentcalendarfields']['days'] . ', months_abbr: ' . $GLOBALS['TL_LANG']['FFL']['xdependentcalendarfields']['month'] . ', useFadeInOut:!Browser.ie, allowEmpty:false, startDay:1, titleFormat:"%d. %B %Y" '; //Startwert if ($xstartwertset_depend != "") { $strBuffer .= ',minDate : "' . $xstartwertset_depend . '"'; } //Stopwert if ($xstopwertset_depend != "") { $strBuffer .= ',maxDate : "' . $xstopwertset_depend . '"'; } $strBuffer .= '});'; //Zweiter Kalender $strBuffer .= ' new Picker.Date($$("#ctrl_' . $this->strId . '"), { draggable:false, toggle:$$("#xdate_toggler' . $this->strId . '"), format:"' . $dateFormat_kalender . '", timePicker:false, pickerClass:"datepicker_dashboard", days_abbr: ' . $GLOBALS['TL_LANG']['FFL']['xdependentcalendarfields']['days'] . ', months_abbr: ' . $GLOBALS['TL_LANG']['FFL']['xdependentcalendarfields']['month'] . ', useFadeInOut:!Browser.ie, startDay:1, allowEmpty:false, titleFormat:"%d. %B %Y" '; //Startwert if ($xstartwertset != "") { $strBuffer .= ',minDate : "' . $xstartwertset . '"'; } //Stopwert if ($xstopwertset != "") { $strBuffer .= ',maxDate : "' . $xstopwertset . '"'; } $strBuffer .= ',maxDate : "' . $xstopwertset . '"'; $strBuffer .= "\r\n ,onSelect: function(d){ \r\n var xtime = Math.floor(d.valueOf()); \r\n var date = new Date(xtime);\r\n "; $strBuffer .= ' xdatepicker' . $this->xdepend . '.options.minDate = new Date(xtime); $("ctrl_' . $this->xdepend . '").value = new Date(xtime).format("' . $dateFormat_kalender . '"); } }); });//--><!]]></script>'; } return $strBuffer; }
function __construct($Name, $Label, $Minimum, $Maximum, $Value = NULL) { parent::__construct($Name, $Label, 4, $Value); $this->InputType = 'number'; $this->Attributes['min'] = $Minimum; $this->Attributes['max'] = $Maximum; $this->Pattern = "/^[0-9]*\$/"; }
public function validator($varInput) { $objToday = new \Date(); $intTstamp = 0; $dateFormat = $this->dateFormat ?: $GLOBALS['TL_CONFIG'][$this->rgxp . 'Format']; if ($varInput != '') { // Validate date format if ($this->dateFormat) { // Disable regular date validation $this->rgxp = ''; if (strlen($varInput) && !preg_match('/' . $this->getRegexp($this->dateFormat) . '/i', $varInput)) { $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $objToday->getInputFormat($this->dateFormat))); } } // Convert timestamps try { $objDate = new \Date($varInput, $dateFormat); $intTstamp = $objDate->tstamp; } catch (\Exception $e) { $this->addError($e->getMessage()); } switch ($this->dateDirection) { case 'ltToday': if ($intTstamp >= $objToday->dayBegin) { $this->addError($GLOBALS['TL_LANG']['ERR']['calendarfield_direction_ltToday']); } break; case 'leToday': if ($intTstamp > $objToday->dayBegin) { $this->addError($GLOBALS['TL_LANG']['ERR']['calendarfield_direction_leToday']); } break; case 'geToday': if ($intTstamp < $objToday->dayBegin) { $this->addError($GLOBALS['TL_LANG']['ERR']['calendarfield_direction_geToday']); } break; case 'gtToday': if ($intTstamp <= $objToday->dayBegin) { $this->addError($GLOBALS['TL_LANG']['ERR']['calendarfield_direction_+1']); } break; } } return parent::validator($varInput); }