Ejemplo n.º 1
0
     if ($importFrequency == SQLIScheduledImport::FREQUENCY_MANUAL) {
         $manualFrequency = (int) $Module->actionParameter('ManualScheduledFrequency');
         if ($manualFrequency < 5) {
             throw new SQLIImportBaseException(SQLIImportUtils::translate('extension/sqliimport/error', 'Please choose a frequency greater than 5min'));
         }
         $row['manual_frequency'] = $manualFrequency;
     }
     $scheduledImport = SQLIScheduledImport::fetch($importID);
     if (!$scheduledImport instanceof SQLIScheduledImport) {
         $scheduledImport = new SQLIScheduledImport($row);
     } else {
         $scheduledImport->fromArray($row);
     }
     if ($importOptions) {
         if (is_array($importOptions)) {
             $scheduledImport->setAttribute('options', SQLIImportHandlerOptions::fromHTTPInput($importOptions));
         } else {
             //backwards compatibility mode : options are set in a textarea
             $scheduledImport->setAttribute('options', SQLIImportHandlerOptions::fromText($importOptions));
         }
     }
     $scheduledImport->store();
     $Module->redirectToView('scheduledlist');
 } else {
     if ($Params['ScheduledImportID']) {
         $scheduledImport = SQLIScheduledImport::fetch($Params['ScheduledImportID']);
         $importID = $Params['ScheduledImportID'];
         $currentImportHandler = $scheduledImport->attribute('handler');
         // Check if user has access to handler alteration
         $aLimitation = array('SQLIImport_Type' => $currentImportHandler);
         $hasAccess = SQLIImportUtils::hasAccessToLimitation($Module->currentModule(), 'manageimports', $aLimitation);
Ejemplo n.º 2
0
$http = eZHTTPTool::instance();
try {
    $userLimitations = SQLIImportUtils::getSimplifiedUserAccess('sqliimport', 'manageimports');
    $simplifiedLimitations = $userLimitations['simplifiedLimitations'];
    if ($Module->isCurrentAction('RequestImport')) {
        // Check if user has access to handler alteration
        $aLimitation = array('SQLIImport_Type' => $Module->actionParameter('ImportHandler'));
        $hasAccess = SQLIImportUtils::hasAccessToLimitation($Module->currentModule(), 'manageimports', $aLimitation);
        if (!$hasAccess) {
            return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
        }
        $importOptions = $Module->actionParameter('ImportOptions');
        $pendingImport = new SQLIImportItem(array('handler' => $Module->actionParameter('ImportHandler'), 'user_id' => eZUser::currentUserID()));
        if ($importOptions) {
            if (is_array($importOptions)) {
                $pendingImport->setAttribute('options', SQLIImportHandlerOptions::fromHTTPInput($importOptions));
            } else {
                //backwards compatibility mode : options are set in a textarea
                $pendingImport->setAttribute('options', SQLIImportHandlerOptions::fromText($importOptions));
            }
        }
        $pendingImport->store();
        $Module->redirectToView('list');
    }
    $importHandlers = $importINI->variable('ImportSettings', 'AvailableSourceHandlers');
    $aValidHandlers = array();
    // Check if import handlers are enabled
    foreach ($importHandlers as $handler) {
        $handlerSection = $handler . '-HandlerSettings';
        if ($importINI->variable($handlerSection, 'Enabled') === 'true') {
            $handlerName = $importINI->hasVariable($handlerSection, 'Name') ? $importINI->variable($handlerSection, 'Name') : $handler;