예제 #1
0
 protected function parseAttachments()
 {
     $upload = new Am_Upload(Am_Di::getInstance(), EmailTemplate::ATTACHMENT_FILE_PREFIX);
     $upload->unserialize($this->template['attachments']);
     foreach ($upload->getUploads() as $file) {
         $f = @fopen($file->getFullPath(), 'r');
         if (!$f) {
             trigger_error("Could not open attachment [" . $file->getName() . "] for EmailTemplate#{$this->email_template_id}", E_USER_WARNING);
             continue;
         }
         $this->getMail()->createAttachment($f, $file->getType(), Zend_Mime::DISPOSITION_ATTACHMENT, Zend_Mime::ENCODING_BASE64, $file->getName());
     }
 }
 public function importAction()
 {
     $this->getDi()->hook->toggleDisableAll(true);
     $this->dataSource->setOffset($this->getStartOffset());
     if (!$this->getStartOffset()) {
         //first chunk
         $this->session->timeStart = time();
         if ($this->session->importOptions['skip']) {
             $this->dataSource->getNextLineParsed();
             //skip first line;
         }
     }
     $batch = new Am_BatchProcessor(array($this, 'doImport'));
     $context = null;
     if (!$batch->run($context)) {
         $this->sendRedirect();
     }
     $this->updateImportHistory(true);
     if (@$this->session->uploadSerialized) {
         $this->upload->unserialize($this->session->uploadSerialized);
         $this->upload->removeFiles();
     }
     $this->reportAction();
 }