/**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user;
     global $sugar_config;
     if ($this->importSource === FALSE) {
         $GLOBALS['log']->fatal("Found invalid adapter");
         $this->handleImportError($mod_strings['LBL_EXTERNAL_ERROR_NO_SOURCE']);
     }
     $columncount = isset($_REQUEST['columncount']) ? $_REQUEST['columncount'] : '';
     $fieldKeyTranslator = $this->getSugarToExternalFieldMapping($columncount);
     try {
         $this->importSource->loadDataSet($this->recordsPerImport);
     } catch (Exception $e) {
         $GLOBALS['log']->fatal("Unable to import external feed, exception: " . $e->getMessage());
         $this->handleImportError($mod_strings['LBL_EXTERNAL_ERROR_FEED_CORRUPTED']);
     }
     if (!ImportCacheFiles::ensureWritable()) {
         $GLOBALS['log']->fatal($mod_strings['LBL_ERROR_IMPORT_CACHE_NOT_WRITABLE']);
         $this->handleImportError($mod_strings['LBL_ERROR_IMPORT_CACHE_NOT_WRITABLE']);
     }
     $importer = new Importer($this->importSource, $this->bean);
     $importer->setFieldKeyTranslator($fieldKeyTranslator);
     $importer->import();
     //Send back our results.
     $metaResult = array('done' => FALSE, 'totalRecordCount' => $this->importSource->getTotalRecordCount());
     echo json_encode($metaResult);
     sugar_cleanup(TRUE);
 }
Beispiel #2
0
 function testShouldImportName()
 {
     $csv = "name\n";
     $csv .= 'foo';
     $importer = new Importer($this->db);
     $importer->importFromText($csv);
     $categoryMapper = new \Metator\Category\DataMapper($this->db);
     $categories = $categoryMapper->findAll();
     $this->assertEquals('foo', $categories[0]['name'], 'should add a new category by name');
 }
Beispiel #3
0
 public function testImport()
 {
     $results = [[['id' => 1, 'madeIn' => 'China', 'title' => 'Phone'], ['id' => 2, 'madeIn' => 'USA', 'title' => 'Chicken wings'], ['id' => 3, 'madeIn' => 'Russia', 'title' => 'Topol-M']], [['id' => 4, 'madeIn' => 'France', 'title' => 'Wine'], ['id' => 5, 'madeIn' => 'Germany', 'title' => 'Audi'], ['id' => 6, 'madeIn' => 'Denmark', 'title' => 'Tulip']]];
     $reader = $this->getReaderMock($this, $results);
     $fields = ['madeIn' => ['name' => 'two'], 'id' => ['name' => 'one'], 'title' => ['name' => 'three']];
     $importer = new Importer($this->db, $this->table, $fields);
     $tableName = $importer->import($reader);
     $this->assertEquals(6, $this->db->execute('SELECT COUNT(*) count FROM ?F', [$tableName])->fetchResult());
     $this->assertEquals('USA', $this->db->execute("SELECT two FROM ?F WHERE one = '2'", [$tableName])->fetchResult());
     $this->assertEquals('Tulip', $this->db->execute("SELECT three FROM ?F WHERE one = '6'", [$tableName])->fetchResult());
 }
 public function testNoNewTweets()
 {
     // model with all current tweets
     $model = $this->getMockBuilder('AMWhalen\\ArchiveMyTweets\\Model')->disableOriginalConstructor()->getMock();
     // Calling $model->addTweets() will now return 0
     $model->expects($this->any())->method('addTweets')->will($this->returnValue(0));
     // expect model to not add any new tweets
     $importer = new Importer();
     $output = $importer->importJSON(dirname(__FILE__) . '/json', $model);
     $this->assertTrue($this->didFindString($output, 'No new tweets found.'));
 }
Beispiel #5
0
 /**
  * @group bug45963
  */
 public function testGetImportableModules()
 {
     $modules = Importer::getImportableModules();
     $this->assertTrue(empty($modules['Groups']));
     $this->assertNotEmpty($modules['Contacts']);
     $this->assertNotEmpty($modules['Accounts']);
 }
 /** 
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $sugar_config;
     // Check to be sure we are getting an import file that is in the right place
     if (realpath(dirname($_REQUEST['tmp_file']) . '/') != realpath($sugar_config['upload_dir'])) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     // Open the import file
     $importSource = new ImportFile($_REQUEST['tmp_file'], $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
     //Ensure we have a valid file.
     if (!$importSource->fileExists()) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     $importer = new Importer($importSource, $this->bean);
     $importer->import();
 }
Beispiel #7
0
function getImporterList()
{
    static $availableImporter;
    global $io;
    if (is_null($availableImporter)) {
        $availableImporter = Importer::getAvailableImporter();
    }
    $io->writeln('Liste des importers existants :');
    foreach ($availableImporter as $importer) {
        $io->writeln('  - ' . $importer['name'] . ' (' . $importer['version'] . ') : ' . $importer['description']);
    }
    $io->writeln();
    $io->writeln('Lister les importateurs à utiliser (séparer les par une virgule) :');
    $importerListStr = $io->read('list-importer');
    $importerList = explode(',', $importerListStr);
    $importerList = array_map(function ($str) {
        return trim($str);
    }, $importerList);
    foreach ($importerList as $importer) {
        if (!array_key_exists($importer, $availableImporter)) {
            return false;
        }
    }
    define('IMPORTER_LIST', implode(',', $importerList));
    return true;
}
Beispiel #8
0
 protected function initItemCollector()
 {
     parent::initItemCollector();
     $this->itemCollector->setRequestModel($this->requestModel);
     $this->itemCollector->setResponseDataConverter($this->responseDataConverter);
     $this->itemCollector->setAllowanceValidator($this->allowanceValidator);
     $this->itemCollector->setClient($this->clientAdapter);
 }
Beispiel #9
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $sugar_config;
     // Check to be sure we are getting an import file that is in the right place
     $uploadFile = "upload://" . basename($_REQUEST['tmp_file']);
     if (!file_exists($uploadFile)) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     // Open the import file
     $importSource = new ImportFile($uploadFile, $_REQUEST['custom_delimiter'], html_entity_decode($_REQUEST['custom_enclosure'], ENT_QUOTES));
     //Ensure we have a valid file.
     if (!$importSource->fileExists()) {
         trigger_error($mod_strings['LBL_CANNOT_OPEN'], E_USER_ERROR);
     }
     if (!ImportCacheFiles::ensureWritable()) {
         trigger_error($mod_strings['LBL_ERROR_IMPORT_CACHE_NOT_WRITABLE'], E_USER_ERROR);
     }
     $importer = new Importer($importSource, $this->bean);
     $importer->import();
 }
 /**
  * @todo: docs
  */
 public function __construct()
 {
     parent::__construct();
     if (!file_exists(dirname(__FILE__) . '/config.ini')) {
         // for now we bail out if there is no config.ini with login and password details
         throw new RuntimeException('Please create config.ini file with "apihost", "apiprotocol", "repohost", "repoprotocol", "login", "password", and optionally "wget" set to true if you want to use wget for HTTP operations');
     } else {
         $this->api = new com_meego_obsconnector_API($this->config['apiprotocol'], $this->config['apihost'], $this->config['login'], $this->config['password'], $this->config['wget'], $this->config['wget_options']);
         $this->download_repo_host = $this->config['repohost'];
         $this->download_repo_protocol = $this->config['repoprotocol'];
     }
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     // Create files
     if (\Input::post('FORM_SUBMIT') == 'tl_entity_import') {
         $objModel = EntityImportConfigModel::findByPk($this->objDc->id);
         if ($objModel === null) {
             return;
         }
         if (class_exists($objModel->importerClass)) {
             // use a particular importer (e.g. NewsImporter)
             \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['importerInfo'], $objModel->importerClass));
             $importer = new $objModel->importerClass($objModel);
         } else {
             \Message::addInfo(sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['importerInfo'], 'Importer'));
             $importer = new Importer($objModel);
         }
         if ($importer->run(\Input::post('dry-run'))) {
             // Confirm and reload
             $strMessage = $GLOBALS['TL_LANG']['tl_entity_import_config']['confirm'];
             if (\Input::post('dry-run')) {
                 $strMessage = $GLOBALS['TL_LANG']['tl_entity_import_config']['confirmDry'];
             }
             \Message::addConfirmation($strMessage);
             \Controller::reload();
         }
     }
     $this->Template->base = \Environment::get('base');
     $this->Template->href = \Controller::getReferer(true);
     $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']);
     $this->Template->action = ampersand(\Environment::get('request'));
     $this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll'];
     $this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT'];
     $this->Template->message = \Message::generate();
     $this->Template->submit = specialchars($GLOBALS['TL_LANG']['tl_entity_import_config']['import'][0]);
     $this->Template->dryRun = specialchars($GLOBALS['TL_LANG']['tl_entity_import_config']['dryRun'][0]);
     $this->Template->headline = sprintf($GLOBALS['TL_LANG']['tl_entity_import_config']['headline'], \Input::get('id'));
     $this->Template->explain = $GLOBALS['TL_LANG']['tl_entity_import_config']['make'][1];
     $this->Template->label = $GLOBALS['TL_LANG']['tl_entity_import_config']['label'];
 }
Beispiel #12
0
 public static function cbd_run()
 {
     $proc = new XSLTProcessor();
     $proc->importStyleSheet(DOMDocument::load('xsl/cbd.xsl'));
     global $registerPHPFunctions;
     if ($registerPHPFunctions) {
         $proc->registerPHPFunctions($registerPHPFunctions);
     }
     $cbd_xml = $proc->transformToDoc(DOMDocument::load('db://?all-data'));
     $xml = simplexml_import_dom($cbd_xml) or die('import failed');
     global $cbd_host, $cbd_db, $cbd_user, $cbd_pwd;
     $conn_pg = pg_connect("host='{$cbd_host}' dbname={$cbd_db} user={$cbd_user} password={$cbd_pwd}") or die("error on connection to {$cbd_db}");
     Importer::_run($xml, $conn_pg);
 }
Beispiel #13
0
 /**
  * @see SugarView::display()
  */
 public function display()
 {
     global $mod_strings, $app_strings, $current_user;
     global $sugar_config;
     $this->ss->assign("MODULE_TITLE", $this->getModuleTitle(false));
     $this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LNK_DELETE']));
     $this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" border="0"', null, null, '.gif', $mod_strings['LBL_PUBLISH']));
     $this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" border="0"', null, null, '.gif', $mod_strings['LBL_UNPUBLISH']));
     $this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
     $showModuleSelection = $this->importModule == 'Administration';
     $importableModulesOptions = array();
     $importablePersonModules = array();
     //If we are coming from the admin link, get the module list.
     if ($showModuleSelection) {
         $tmpImportable = Importer::getImportableModules();
         $importableModulesOptions = get_select_options_with_id($tmpImportable, '');
         $importablePersonModules = $this->getImportablePersonModulesJS();
         $this->ss->assign("IMPORT_MODULE", key($tmpImportable));
     } else {
         $this->instruction = 'LBL_SELECT_DS_INSTRUCTION';
         $this->ss->assign('INSTRUCTION', $this->getInstruction());
     }
     $this->ss->assign("FROM_ADMIN", $showModuleSelection);
     $this->ss->assign("PERSON_MODULE_LIST", json_encode($importablePersonModules));
     $this->ss->assign("showModuleSelection", $showModuleSelection);
     $this->ss->assign("IMPORTABLE_MODULES_OPTIONS", $importableModulesOptions);
     $this->ss->assign("EXTERNAL_APIS", $this->getExternalApis());
     $this->ss->assign("EXTERNAL_SOURCES", $this->getAllImportableExternalEAPMs());
     $this->ss->assign("EXTERNAL_AUTHENTICATED_SOURCES", json_encode($this->getAuthenticatedImportableExternalEAPMs()));
     $selectExternal = !empty($_REQUEST['application']) ? $_REQUEST['application'] : '';
     $this->ss->assign("selectExternalSource", $selectExternal);
     $content = $this->ss->fetch('modules/Import/tpls/step1.tpl');
     $submitContent = "<table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"right\">";
     $submitContent .= "<input title=\"" . $mod_strings['LBL_IMPORT_COMPLETE'] . "\" onclick=\"SUGAR.importWizard.closeDialog();\" class=\"button\" type=\"submit\" name=\"finished\" value=\"  " . $mod_strings['LBL_IMPORT_COMPLETE'] . "  \" id=\"finished\">";
     $submitContent .= "<input title=\"" . $mod_strings['LBL_NEXT'] . "\" class=\"button primary\" type=\"submit\" name=\"button\" value=\"  " . $mod_strings['LBL_NEXT'] . "  \"  id=\"gonext\"></td></tr></table>";
     $this->ss->assign("JAVASCRIPT", $this->_getJS());
     $this->ss->assign("CONTENT", $content);
     $this->ss->display('modules/Import/tpls/wizardWrapper.tpl');
 }
Beispiel #14
0
 public function __construct($engine, $fileSegment)
 {
     $this->fileSegment = $fileSegment;
     parent::__construct($engine);
 }
Beispiel #15
0
        $sth->bindParam('is_satellite_provider', $values['is_satellite_provider'], \PDO::PARAM_INT);
        $sth->execute();
    });
    Importer::csvRead($files['GeoLite2-Country-Locations-en.csv'], function ($values) use($dbh) {
        $sth = $dbh->prepare('
			INSERT INTO country_locations (
				geoname_id,
				locale_code,
				continent_code,
				continent_name,
				country_iso_code,
				country_name
			) VALUES (
				:geoname_id,
				:locale_code,
				:continent_code,
				:continent_name,
				:country_iso_code,
				:country_name
			)
			');
        $sth->bindParam('geoname_id', $values['geoname_id'], \PDO::PARAM_INT);
        $sth->bindParam('locale_code', $values['locale_code'], \PDO::PARAM_STR);
        $sth->bindParam('continent_code', $values['continent_code'], \PDO::PARAM_STR);
        $sth->bindParam('continent_name', $values['continent_name'], \PDO::PARAM_STR);
        $sth->bindParam('country_iso_code', $values['country_iso_code'], \PDO::PARAM_STR);
        $sth->bindParam('country_name', $values['country_name'], \PDO::PARAM_STR);
        $sth->execute();
    });
} catch (\Exception $e) {
    echo $e->getMessage() . "\n";
    exit(1);
Beispiel #16
0
 public function __construct(ConnectionInterface $db, $table, array $fields)
 {
     parent::__construct($db, $table, $fields, true);
 }
Beispiel #17
0
 public function __construct(ConnectionInterface $db, $table, array $fields)
 {
     $fields['full_number'] = ['name' => 'full_number'];
     parent::__construct($db, $table, $fields, true);
 }
Beispiel #18
0
 public function saveImportBean($focus, $newRecord)
 {
     return parent::saveImportBean($focus, $newRecord);
 }
Beispiel #19
0
 public function __construct()
 {
     parent::__construct();
     $this->getDrupalCommentIdByWpIdStatement = $this->dbhImport->prepare("SELECT cid FROM comments WHERE wp_comment_id = :wp_comment_id");
     $this->getDruaplNodeIdByWpPostIdStatement = $this->dbhImport->prepare("SELECT nid FROM posts WHERE post_id = :wp_post_id");
 }
 /**
  * @dataProvider providerCsvData
  */
 public function testDateTimeImport($content_idx, $expected_datetime, $date_format, $time_format)
 {
     $file = $GLOBALS['sugar_config']['upload_dir'] . 'test.csv';
     $ret = file_put_contents($file, self::$CsvContent[$content_idx]);
     $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . $content_idx);
     $importSource = new ImportFile($file, ',', '"');
     $bean = loadBean($this->_importModule);
     $_REQUEST['columncount'] = 2;
     $_REQUEST['colnum_0'] = 'date_entered';
     $_REQUEST['colnum_1'] = 'last_name';
     $_REQUEST['import_module'] = 'Contacts';
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_dateformat'] = $date_format;
     $_REQUEST['importlocale_timeformat'] = $time_format;
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     $importer = new Importer($importSource, $bean);
     $importer->import();
     $query = "SELECT date_entered from contacts where created_by='{$GLOBALS['current_user']->id}'";
     $result = $GLOBALS['db']->query($query);
     $row = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertEquals($expected_datetime, $GLOBALS['db']->fromConvert($row['date_entered'], 'datetime'), 'Got incorrect date_entered.');
 }
 public function __construct(&$parent)
 {
     parent::__construct($parent);
 }
Beispiel #22
0
<?php

session_start();
include "../../Includes.php";
function redirect()
{
    header("location: ../../index.php?info=admin/vartotojai");
}
$login = new Session(1);
if (!$login->isLogedin()) {
    die("You must loged in!");
}
$file = $_FILES['file'];
if ($file['error'] != 0) {
    die("<p style='color:red;'>Ivyko klaida ikeliant faila! Error nr: " . $file['error'] . "</p>");
}
if ($file['type'] != "application/vnd.ms-excel") {
    die("<p style='color:red;'>Blogas failo formatas!</p>");
}
$importer = new Importer($file['tmp_name']);
$importer->import();
echo "<p style='color:green;'>Importuota.</p>";
Beispiel #23
0
            $this->commitData($sheet);
        }
    }
    public function commitData($sheet = null)
    {
        if (is_null($sheet)) {
            foreach (array_keys($this->_pending_data) as $sheet) {
                $this->commitData($sheet);
            }
            return;
        }
        error_log("commiting {$sheet} {$this->_pending_data[$sheet][0][0]}");
        $curl = curl_init("https://sheethub.com{$sheet}/insert?access_token=" . getenv('access_token'));
        $params = array();
        $params[] = 'data=' . urlencode(json_encode($this->_pending_data[$sheet], JSON_UNESCAPED_UNICODE));
        $params[] = 'unique_columns[]=' . $this->_unique_column_id[$sheet];
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, implode('&', $params));
        $content = curl_exec($curl);
        $obj = json_decode($content);
        error_log($content);
        if (is_null($obj->data->count)) {
            error_log('count null, retry');
            $this->commitData($sheet);
            return;
        }
        $this->_pending_data[$sheet] = array();
    }
}
$i = new Importer();
$i->main();
 /**
  * Check if semi-colon separated non-primary mails
  * are being imported properly
  *
  * @dataProvider providerEmailImport
  */
 public function testEmailImport($module, $lastName, $expected, $test)
 {
     $fileCreated = sugar_file_put_contents($this->_file, $test);
     $this->assertGreaterThan(0, $fileCreated, 'Failed to write to ' . $this->_file);
     // Create the ImportFile the Importer uses from our CSV
     $importSource = new ImportFile($this->_file, ',', '"');
     // Create the bean type we're importing
     $this->_importObject = $bean = new $module();
     // Setup needed $_REQUEST data
     $_REQUEST['columncount'] = 2;
     $_REQUEST['colnum_0'] = 'email_addresses_non_primary';
     $_REQUEST['colnum_1'] = 'last_name';
     // A few changed for Accounts module
     if ($module == "Account") {
         $_REQUEST['columncount'] = 3;
         $_REQUEST['colnum_1'] = 'name';
         $_REQUEST['colnum_2'] = 'team_id';
     }
     $_REQUEST['import_module'] = $bean->module_dir;
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_dateformat'] = "m/d/Y";
     $_REQUEST['importlocale_timeformat'] = "h:i a";
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     // Create the Importer and try importing
     $importer = new Importer($importSource, $bean);
     $importer->import();
     // Check if the Lead is created
     $query = "SELECT id FROM {$bean->table_name} WHERE {$_REQUEST['colnum_1']} = '{$lastName}'";
     $result = $GLOBALS['db']->query($query);
     $row = $GLOBALS['db']->fetchByAssoc($result);
     $this->assertNotEmpty($row['id'], $module . ' not created');
     // Save Lead id for easier cleanup after test
     $this->_cleanId = $row['id'];
     // Check if all of the mails got created and linked properly
     foreach ($expected as $mail) {
         // Check if the mail got created
         $query = "SELECT id FROM email_addresses WHERE email_address = '{$mail}'";
         $result = $GLOBALS['db']->query($query);
         $row = $GLOBALS['db']->fetchByAssoc($result);
         $this->assertNotEmpty($row['id'], 'Mail not created');
         $mailId = $row['id'];
         // Check if the mail is linked
         $query = "SELECT id FROM email_addr_bean_rel WHERE email_address_id = '{$mailId}' AND bean_module = '{$bean->module_dir}' AND deleted = 0 AND primary_address = 0";
         $result = $GLOBALS['db']->query($query);
         $row = $GLOBALS['db']->fetchByAssoc($result);
         $this->assertNotEmpty($row['id'], 'Mail not linked');
     }
 }
Beispiel #25
0
 ** STATE OF THE CODE
 ** -----------------
 ** - Currently only works when importing Tiki forums from an SQL file.
 ** - SQL file dump must be set to escape single quotes with \' instead of ''
 ** - If you get timeout problems, you may need to increase your php.ini
 **   'max_execution_time' to something like 120 or more, depending on the
 **   size of your SQL file.  120 is good for a file around 20Mb.
 **
 ****************************************************************************/
// Initialization
$inputConfiguration = array(array('staticKeyFilters' => array('step1' => 'word', 'step2' => 'word', 'step3' => 'word', 'import' => 'word', 'fForumid' => 'digits', 'tForumid' => 'digits', 'ftype' => 'word', 'prefix' => 'word', 'server' => 'striptags')));
require_once 'tiki-setup.php';
$access->check_feature('feature_forums');
$access->check_permission('tiki_p_admin_forum');
include_once 'lib/importerlib.php';
$import = new Importer($dbTiki);
global $prefs;
// Which iteration of the process are we in?
// Step 0 - Select Import Method
// Step 1 - Test Import Method Succeeded
// Step 2 - Select Forum to Import From/To
// Step 3 - Migration Complete - Do Again?
if (isset($_POST["step4"])) {
} else {
    if (isset($_POST["step3"])) {
        if ($_POST["import"] == 'same') {
            // Same db and server
        } else {
            if ($_POST["import"] == 'other') {
                // Different db & server
            } else {
Beispiel #26
0
 /**
  * @dataProvider errorSet
  */
 public function testHandleImportErrors($errno, $errstr, $errfile, $errline)
 {
     $old_error_reporting = error_reporting(E_ALL);
     Importer::handleImportErrors($errno, $errstr, $errfile, $errline);
     switch ($errno) {
         case E_USER_WARNING:
         case E_WARNING:
             //$this->assertEquals("WARNING: [$errno] $errstr on line $errline in file $errfile<br />",$output);
             break;
         case E_USER_NOTICE:
         case E_NOTICE:
             //$this->assertEquals("NOTICE: [$errno] $errstr on line $errline in file $errfile<br />",$output);
             break;
         case E_STRICT:
             //$this->assertEquals('',$output);
             break;
         default:
             $this->expectOutputString("Unknown error type: [{$errno}] {$errstr} on line {$errline} in file {$errfile}<br />\n");
             break;
     }
     error_reporting($old_error_reporting);
 }
Beispiel #27
0
 public function saveMappingFile()
 {
     parent::saveMappingFile();
 }
Beispiel #28
0
function error($code)
{
    header("Location: index.php?error={$code}");
    Importer::log("error", $code);
}
Beispiel #29
0
 public function testParentsAreRelatedDuringImport()
 {
     $file = 'upload://test50438.csv';
     $ret = file_put_contents($file, $this->fileArr);
     $this->assertGreaterThan(0, $ret, 'Failed to write to ' . $file . ' for content ' . var_export($this->fileArr, true));
     $importSource = new ImportFile($file, ',', '"');
     $bean = loadBean('Calls');
     $_REQUEST['columncount'] = 5;
     $_REQUEST['colnum_0'] = 'id';
     $_REQUEST['colnum_1'] = 'subject';
     $_REQUEST['colnum_2'] = 'status';
     $_REQUEST['colnum_3'] = 'parent_type';
     $_REQUEST['colnum_4'] = 'parent_id';
     $_REQUEST['import_module'] = 'Contacts';
     $_REQUEST['importlocale_charset'] = 'UTF-8';
     $_REQUEST['importlocale_timezone'] = 'GMT';
     $_REQUEST['importlocale_default_currency_significant_digits'] = '2';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_dec_sep'] = '.';
     $_REQUEST['importlocale_currency'] = '-99';
     $_REQUEST['importlocale_default_locale_name_format'] = 's f l';
     $_REQUEST['importlocale_num_grp_sep'] = ',';
     $_REQUEST['importlocale_dateformat'] = 'm/d/y';
     $_REQUEST['importlocale_timeformat'] = 'h:i:s';
     $importer = new Importer($importSource, $bean);
     $importer->import();
     //fetch the bean using the passed in id and get related contacts
     require_once 'modules/Calls/Call.php';
     $call = new Call();
     $call->retrieve($this->call_id);
     $call->load_relationship('contacts');
     $related_contacts = $call->contacts->get();
     //test that the contact id is in the array of related contacts.
     $this->assertContains($this->contact->id, $related_contacts, ' Contact was not related during simulated import despite being set in related parent id');
     unset($call);
     /*
     if (is_file($file)) {
         unlink($file);
     }
     */
 }
Beispiel #30
0
 public function __construct(Importer $importer)
 {
     $this->importer = $importer;
     $this->token = $importer->get('token');
     $this->host = get_record('host', 'wwwroot', $importer->get('host'));
 }