Exemplo n.º 1
0
 public static function getExecute($sIniFile)
 {
     $config = new ConfigReader($sIniFile);
     $config_data = $config->getConfig();
     $database_class = key($config_data) . '_spdo';
     include_once $database_class . '.php';
     $exec = BaseDatosFactory::getExecute($database_class);
     return $exec;
 }
Exemplo n.º 2
0
 public function set(ConfigReader $config)
 {
     $config_data = $config->getConfig();
     $keybd = key($config_data);
     $this->host = $config_data[$keybd]['host'];
     $this->port = $config_data[$keybd]['port'];
     $this->dbname = $config_data[$keybd]['dbname'];
     $this->user = $config_data[$keybd]['username'];
     $this->password = trim($config_data[$keybd]['password']);
 }
 public function createRecords()
 {
     $adb = PearDatabase::getInstance();
     $moduleName = $this->module;
     $focus = CRMEntity::getInstance($moduleName);
     $moduleHandler = vtws_getModuleHandlerFromName($moduleName, $this->user);
     $moduleMeta = $moduleHandler->getMeta();
     $moduleObjectId = $moduleMeta->getEntityId();
     $moduleFields = $moduleMeta->getModuleFields();
     $tableName = Import_Utils::getDbTableName($this->user);
     $sql = 'SELECT * FROM ' . $tableName . ' WHERE status = ' . Import_Data_Controller::$IMPORT_RECORD_NONE;
     if ($this->batchImport) {
         $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig');
         $importBatchLimit = $configReader->getConfig('importBatchLimit');
         $sql .= ' LIMIT ' . $importBatchLimit;
     }
     $result = $adb->query($sql);
     $numberOfRecords = $adb->num_rows($result);
     if ($numberOfRecords <= 0) {
         return;
     }
     $fieldMapping = $this->fieldMapping;
     $fieldColumnMapping = $moduleMeta->getFieldColumnMapping();
     for ($i = 0; $i < $numberOfRecords; ++$i) {
         $row = $adb->raw_query_result_rowdata($result, $i);
         $rowId = $row['id'];
         $entityInfo = null;
         $fieldData = array();
         foreach ($fieldMapping as $fieldName => $index) {
             $fieldData[$fieldName] = $row[$fieldName];
         }
         $mergeType = $this->mergeType;
         $createRecord = false;
         if (method_exists($focus, 'importRecord')) {
             $entityInfo = $focus->importRecord($this, $fieldData);
         } else {
             if (!empty($mergeType) && $mergeType != Import_Utils::$AUTO_MERGE_NONE) {
                 $queryGenerator = new QueryGenerator($moduleName, $this->user);
                 $queryGenerator->initForDefaultCustomView();
                 $fieldsList = array('id');
                 $queryGenerator->setFields($fieldsList);
                 $mergeFields = $this->mergeFields;
                 foreach ($mergeFields as $index => $mergeField) {
                     if ($index != 0) {
                         $queryGenerator->addConditionGlue(QueryGenerator::$AND);
                     }
                     $comparisonValue = $fieldData[$mergeField];
                     $fieldInstance = $moduleFields[$mergeField];
                     if ($fieldInstance->getFieldDataType() == 'owner') {
                         $userId = getUserId_Ol($comparisonValue);
                         $comparisonValue = getUserFullName($userId);
                     }
                     if ($fieldInstance->getFieldDataType() == 'reference') {
                         if (strpos($comparisonValue, '::::') > 0) {
                             $referenceFileValueComponents = explode('::::', $comparisonValue);
                         } else {
                             $referenceFileValueComponents = explode(':::', $comparisonValue);
                         }
                         if (count($referenceFileValueComponents) > 1) {
                             $comparisonValue = trim($referenceFileValueComponents[1]);
                         }
                     }
                     $queryGenerator->addCondition($mergeField, $comparisonValue, 'e');
                 }
                 $query = $queryGenerator->getQuery();
                 $duplicatesResult = $adb->query($query);
                 $noOfDuplicates = $adb->num_rows($duplicatesResult);
                 if ($noOfDuplicates > 0) {
                     if ($mergeType == Import_Utils::$AUTO_MERGE_IGNORE) {
                         $entityInfo['status'] = self::$IMPORT_RECORD_SKIPPED;
                     } elseif ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE || $mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) {
                         for ($index = 0; $index < $noOfDuplicates - 1; ++$index) {
                             $duplicateRecordId = $adb->query_result($duplicatesResult, $index, $fieldColumnMapping['id']);
                             $entityId = vtws_getId($moduleObjectId, $duplicateRecordId);
                             vtws_delete($entityId, $this->user);
                         }
                         $baseRecordId = $adb->query_result($duplicatesResult, $noOfDuplicates - 1, $fieldColumnMapping['id']);
                         $baseEntityId = vtws_getId($moduleObjectId, $baseRecordId);
                         if ($mergeType == Import_Utils::$AUTO_MERGE_OVERWRITE) {
                             $fieldData = $this->transformForImport($fieldData, $moduleMeta);
                             $fieldData['id'] = $baseEntityId;
                             $entityInfo = vtws_update($fieldData, $this->user);
                             $entityInfo['status'] = self::$IMPORT_RECORD_UPDATED;
                             //Prepare data for event handler
                             $entityData = array();
                             $entityData['rowId'] = $rowId;
                             $entityData['tableName'] = $tableName;
                             $entityData['entityInfo'] = $entityInfo;
                             $entityData['fieldData'] = $fieldData;
                             $entityData['moduleName'] = $moduleName;
                             $entityData['user'] = $this->user;
                             cbEventHandler::do_action('corebos.entity.import.overwrite', $entityData);
                         }
                         if ($mergeType == Import_Utils::$AUTO_MERGE_MERGEFIELDS) {
                             $filteredFieldData = array();
                             $defaultFieldValues = $this->getDefaultFieldValues($moduleMeta);
                             foreach ($fieldData as $fieldName => $fieldValue) {
                                 if (!empty($fieldValue)) {
                                     $filteredFieldData[$fieldName] = $fieldValue;
                                 }
                             }
                             $existingFieldValues = vtws_retrieve($baseEntityId, $this->user);
                             foreach ($existingFieldValues as $fieldName => $fieldValue) {
                                 if (empty($fieldValue) && empty($filteredFieldData[$fieldName]) && !empty($defaultFieldValues[$fieldName])) {
                                     $filteredFieldData[$fieldName] = $fieldValue;
                                 }
                             }
                             $filteredFieldData = $this->transformForImport($filteredFieldData, $moduleMeta, false, true);
                             $filteredFieldData['id'] = $baseEntityId;
                             $entityInfo = vtws_revise($filteredFieldData, $this->user);
                             $entityInfo['status'] = self::$IMPORT_RECORD_MERGED;
                             //Prepare data for event handler
                             $entityData = array();
                             $entityData['rowId'] = $rowId;
                             $entityData['tableName'] = $tableName;
                             $entityData['entityInfo'] = $entityInfo;
                             $entityData['fieldData'] = $fieldData;
                             $entityData['moduleName'] = $moduleName;
                             $entityData['user'] = $this->user;
                             cbEventHandler::do_action('corebos.entity.import.merge', $entityData);
                         }
                     } else {
                         $createRecord = true;
                     }
                 } else {
                     $createRecord = true;
                 }
             } else {
                 $createRecord = true;
             }
             if ($createRecord) {
                 $fieldData = $this->transformForImport($fieldData, $moduleMeta);
                 if ($fieldData == null) {
                     $entityInfo = null;
                 } else {
                     $entityInfo = vtws_create($moduleName, $fieldData, $this->user);
                     $entityInfo['status'] = self::$IMPORT_RECORD_CREATED;
                     //Prepare data for event handler
                     $entityData = array();
                     $entityData['rowId'] = $rowId;
                     $entityData['tableName'] = $tableName;
                     $entityData['entityInfo'] = $entityInfo;
                     $entityData['fieldData'] = $fieldData;
                     $entityData['moduleName'] = $moduleName;
                     $entityData['user'] = $this->user;
                     cbEventHandler::do_action('corebos.entity.import.create', $entityData);
                 }
             }
         }
         if ($entityInfo == null) {
             $entityInfo = array('id' => null, 'status' => self::$IMPORT_RECORD_FAILED);
         }
         $this->importedRecordInfo[$rowId] = $entityInfo;
         $this->updateImportStatus($rowId, $entityInfo);
     }
     unset($result);
     return true;
 }
Exemplo n.º 4
0
 public function queueDataImport()
 {
     $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig');
     $immediateImportRecordLimit = $configReader->getConfig('immediateImportLimit');
     $numberOfRecordsToImport = $this->numberOfRecords;
     if ($numberOfRecordsToImport > $immediateImportRecordLimit) {
         $this->userInputObject->set('is_scheduled', true);
     }
     Import_Queue_Controller::add($this->userInputObject, $this->user);
 }
Exemplo n.º 5
0
<?php

include_once "classes/API/RutrackerAPI.php";
include_once "classes/API/RutorAPI.php";
include "ConfigReader.php";
include_once "classes/Utils.php";
$c = new ConfigReader();
$config = $c->getConfig();
$rt = new RutrackerAPI();
$rt->init_action($config['rutracker']['username'], $config['rutracker']['password']);
$rt->parse_user_params();
$flist = $rt->getFutureList();
$rutor = new RutorAPI();
$rt_result = $rutor_search = [];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Rtracker search
        <?php 
if (isset($_GET['search'])) {
    echo " - " . trim($_GET['search']);
}
?>
    </title>

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
Exemplo n.º 6
0
<?php

require_once "defines.php";
if ($devMod) {
    error_reporting(E_ALL);
    ini_set('display_errors', true);
}
require_once 'ConfigReader.php';
//init config reader
$configReader = new ConfigReader($mainFolderName, $templateName);
$userConfigs = $configReader->getConfig();
//so beautifull code <3
if ($userConfigs) {
    foreach ($userConfigs as $configName => $userConfig) {
        if (!empty(${$configName})) {
            ${$configName} = $configReader->getConfig($configName);
        }
    }
}
require_once "config_smarty.php";
require_once CLASS_DIR . "/Controller.php";
require_once CLASS_DIR . "/FrontController.php";
if (file_exists(CLASS_DIR . "/" . $configReader->getControllerName() . ".php")) {
    require_once CLASS_DIR . "/" . $configReader->getControllerName() . ".php";
}
Exemplo n.º 7
0
 public static function getDbTableName($user)
 {
     $configReader = new ConfigReader('modules/Import/config.inc', 'ImportConfig');
     $userImportTablePrefix = $configReader->getConfig('userImportTablePrefix');
     return $userImportTablePrefix . $user->id;
 }