public function addElement($elementsProperties) { if (empty($this->elementName)) { $this->elementName = date('Y.m.d H:i'); } $el = new \CIBlockElement(); $id = $el->Add(array('IBLOCK_ID' => $this->iBlockId, 'PROPERTY_VALUES' => $elementsProperties, 'NAME' => $this->elementName, "DATE_ACTIVE_FROM" => ConvertTimeStamp(time(), "FULL"))); if (!$id) { if ($this->isCritical) { throw new \Exception($el->LAST_ERROR); } else { $this->form->setErrors($this->getErrorMessage($el->LAST_ERROR)); } } return $id; }
public function execute(Form $form) { $sendData = $form->getData(); if ($this->fieldsUppercase) { $submitArray = array_change_key_case($sendData, CASE_UPPER); } $result = \CEvent::Send($this->emailEvent, SITE_ID, $submitArray); if (!$result && $this->isCritical) { throw new \Exception('CEvent::Send false'); } elseif (!$result && !$this->isCritical) { $form->setErrors(array($this->getErrorMessage('ошибка отправки почты (CEvent::Send)'))); } }
public function execute(Form $form) { $this->data = array_change_key_case($form->getData(), CASE_UPPER); $body = preg_replace_callback('#{([A-Z_]+)}#i', array($this, 'replaceCallback'), $this->body_template); $this->mailer->CharSet = 'UTF-8'; $this->mailer->setFrom($this->from[0], $this->from[1]); $this->mailer->addAddress($this->to[0], $this->to[1]); $this->mailer->Subject = $this->subject; $this->mailer->msgHTML($body); foreach ($this->files as $file) { if (file_exists($file) && is_readable($file)) { $this->mailer->addAttachment($file); } } $result = $this->mailer->send(); if (!$result && $this->isCritical) { throw new \Exception('Email::Send false'); } elseif (!$result && !$this->isCritical) { $form->setErrors(array($this->getErrorMessage($this->mailer->ErrorInfo))); } }