$cli->warning(implode(', ', $aAvailableSourceHandlers));
     } else {
         $cli->error('No source handler defined !');
     }
     $script->shutdown();
 } else {
     /*
      * Process requested import handlers
      * An SQLIImportItem object will be created and stored in DB for each handler
      */
     $requestedHandlers = $options['source-handlers'] ? $options['source-handlers'] : '';
     $aRequestedHandlers = $requestedHandlers ? explode(',', $requestedHandlers) : $importINI->variable('ImportSettings', 'AvailableSourceHandlers');
     $areValidHandlers = SQLIImportFactory::checkExistingHandlers($aRequestedHandlers);
     // An exception may be thrown if a handler is not defined in sqliimport.ini
     if ($aRequestedHandlers) {
         $aHandlersOptions = SQLIImportHandlerOptions::decodeHandlerOptionLine($options['options']);
         $importUser = eZUser::fetchByName('admin');
         // As this is a manual script, "Admin" user will be used to import
         $aImportItems = array();
         // First stores an SQLIImportItem for each handler to process
         foreach ($aRequestedHandlers as $handler) {
             $handlerOptions = isset($aHandlersOptions[$handler]) ? $aHandlersOptions[$handler] : null;
             $pendingImport = new SQLIImportItem(array('handler' => $handler, 'user_id' => $importUser->attribute('contentobject_id')));
             if ($handlerOptions instanceof SQLIImportHandlerOptions) {
                 $pendingImport->setAttribute('options', $handlerOptions);
             }
             $pendingImport->store();
             $aImportItems[] = $pendingImport;
         }
         $importFactory = SQLIImportFactory::instance();
         $importFactory->runImport($aImportItems);
Example #2
0
             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);
         if (!$hasAccess) {
             return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
         }
Example #3
0
 $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;
         /*
          * Policy limitations check.
          * User has access to handler if it appears in $simplifiedLimitations['SQLIImport_Type']