コード例 #1
0
ファイル: ImportHandler.php プロジェクト: sintattica/atk
 /**
  * The real import function actually imports the importfile.
  *
  * @param bool $nopost
  */
 public function doImport($nopost = false)
 {
     ini_set('max_execution_time', 300);
     $db = $this->m_importNode->getDb();
     $fileid = $this->m_postvars['fileid'];
     $file = $this->getTmpFileDestination($fileid);
     $validated = $this->getValidatedRecords($file);
     if (!$this->m_postvars['novalidatefirst'] && $this->showErrors($validated['importerrors'])) {
         $db->rollback();
         return;
     }
     $this->addRecords($validated['importerrors'], $validated['validatedrecs']);
     if (!$this->m_postvars['novalidatefirst'] && $this->showErrors($validated['importerrors'])) {
         $db->rollback();
         return;
     }
     $db->commit();
     // clean-up
     @unlink($file);
     // clear recordlist cache
     $this->clearCache();
     // register message
     $messageQueue = MessageQueue::getInstance();
     $count = count((array) $validated['validatedrecs']['add']) + count((array) $validated['validatedrecs']['update']);
     if ($count == 0) {
         $messageQueue->addMessage(sprintf($this->m_node->text('no_records_to_import'), $count), MessageQueue::AMQ_GENERAL);
     } else {
         if ($count == 1) {
             $messageQueue->addMessage($this->m_node->text('successfully_imported_one_record'), MessageQueue::AMQ_SUCCESS);
         } else {
             $messageQueue->addMessage(sprintf($this->m_node->text('successfully_imported_x_records'), $count), MessageQueue::AMQ_SUCCESS);
         }
     }
     $this->m_node->redirect();
 }