public function getPreparedProperties()
 {
     $data = $this->form->getData();
     $elementsProperties = array();
     if ($this->fieldsUppercase) {
         $data = array_change_key_case($data, CASE_UPPER);
         $files = array_change_key_case($_FILES, CASE_UPPER);
     }
     foreach (cp_get_ib_properties($this->iBlockId) as $key => $property) {
         $elementsProperties[$property['ID']] = $data[$key];
         if ($property['PROPERTY_TYPE'] == 'S') {
             $elementsProperties[$property['ID']] = $property['USER_TYPE'] == 'HTML' ? array('VALUE' => array('TEXT' => $data[$key], 'TYPE' => 'TEXT')) : $data[$key];
         } else {
             if ($property['PROPERTY_TYPE'] == 'F') {
                 if ($property['MULTIPLE'] == 'Y') {
                     for ($i = 0; $i < count($files[$key]['name']); $i++) {
                         $elementsProperties[$property['ID']]['n' . $i] = array('name' => $files[$key]['name'][$i], 'size' => $files[$key]['size'][$i], 'type' => $files[$key]['type'][$i], 'tmp_name' => $files[$key]['tmp_name'][$i]);
                     }
                 } else {
                     $elementsProperties[$property['ID']] = $files[$key];
                 }
             }
         }
     }
     return $elementsProperties;
 }
 public function execute(Form $form)
 {
     $sendData = $form->getData();
     if ($this->fieldsUppercase) {
         $submitArray = array_change_key_case($sendData, CASE_UPPER);
     }
     $result = \CEvent::Send($this->emailEvent, $this->siteId, $submitArray);
     if (!$result && $this->isCritical) {
         throw new \Exception('CEvent::Send false');
     } elseif (!$result && !$this->isCritical) {
         $form->setErrors(array($this->getErrorMessage('ошибка отправки почты (CEvent::Send)')));
     }
 }
Esempio n. 3
0
 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)));
     }
 }