_idItem) { $this->_idItem = abs(crc32(__CLASS__)); } if ('split' != $this->getConfig('nameType')) { $this->_userFieldRules['fullName'] = [$this, 'prepareUserName']; } return $this; } protected function prepareUserName(array $userData) { return $userData['firstName'] . ' ' . $userData['lastName']; } protected function _initFromForm(Qs_Form $form) { $data = $form->getValues(); if (empty($data['fullName'])) { $data['fullName'] = $data['firstName'] . ' ' . $data['lastName']; } $this->_getDataObj()->initFromForm($data); return $this; } protected function _getMailData(array $data) { $mailData = [ 'name' => htmlspecialchars($data['fullName']), 'email' => htmlspecialchars($data['email']), 'link' => Qs_SiteMap::findFirst(null, ['type' => 'Form_Newsletter_Admin_'], null, 'url') . '?action=view&id=' . $data['id'], ]; return $mailData; } protected function _sendNotifications($data) { parent::_sendNotifications($data); $this->_sendUserNotification($data); return $this; } protected function _sendUserNotification(array $data) { $to = $data['email']; $body = App_Settings_Obj::get($this->_settingsUserPrefix . 'Body'); if (empty($to) || empty($body)) { return false; } $subject = App_Settings_Obj::get($this->_settingsUserPrefix . 'Subject'); $from = App_Settings_Obj::getEmailFrom($this->_settingsUserPrefix . 'From'); $mailData = $this->_getMailData($data); foreach ($mailData as $field => $value) { $body = str_replace('{' . $field . '}', $value, $body); } $options = [ 'from' => $from, 'to' => $to, 'subject' => $subject, 'body' => $body, ]; $this->_sendMail($options); return $this; } }