コード例 #1
0
 /**
  * Ritorna vero se la playlist ha una data di schedulazione inferiore alla
  * data attuale
  * 
  * @param int $parentNodeID
  * @return boolean
  */
 public static function checkPlaylistImportScheduled($parentNodeID)
 {
     $limit = 1000;
     $offset = 0;
     $imports = SQLIScheduledImport::fetchList($offset, $limit);
     foreach ($imports as $import) {
         if ($import instanceof SQLIScheduledImport) {
             $options = $import->getOptions();
             if ($options->hasAttribute('parentnodeid')) {
                 $_parentNodeID = $options->attribute('parentnodeid');
                 if ($parentNodeID == $_parentNodeID) {
                     // Legge la data della prossima shedulazione
                     $currentNextTime = $import->attribute('next');
                     $currentTime = time();
                     if ($currentNextTime < $currentTime) {
                         return true;
                     } else {
                         return false;
                     }
                 }
             }
         }
     }
     return false;
 }
コード例 #2
0
 /**
  * Returns options form and js modules list for handler
  * @param array $args First value: handler id, optional second value: scheduled import id
  * @throws SQLIImportRuntimeException
  * @return array
  */
 public static function options($args)
 {
     $scheduledImport = null;
     $currentOptions = null;
     $handler = $args[0];
     //arg 2 may be a scheduled import id
     if (count($args) > 1) {
         $scheduledImport = SQLIScheduledImport::fetch($args[1]);
         if (!$scheduledImport) {
             throw new SQLIImportRuntimeException('Invalid scheduled import ID ' . $args[1]);
         }
         $currentOptions = $scheduledImport->attribute('options');
     }
     $tpl = SQLIImportUtils::templateInit();
     $importINI = eZINI::instance('sqliimport.ini');
     $handlerSection = $handler . '-HandlerSettings';
     if (!$importINI->hasSection($handlerSection)) {
         throw new SQLIImportRuntimeException('No config for handler ' . $handler);
     }
     if ($importINI->hasVariable($handlerSection, 'Options')) {
         $aHandlerOptions = array();
         $optionsList = $importINI->variable($handlerSection, 'Options');
         $optionsLabels = $importINI->variable($handlerSection, 'OptionsLabels');
         $optionsTypes = $importINI->variable($handlerSection, 'OptionsTypes');
         $optionsDefaults = $importINI->variable($handlerSection, 'OptionsDefaults');
         foreach ($optionsList as $optionAlias) {
             $value = '';
             if ($currentOptions && isset($currentOptions->{$optionAlias})) {
                 $value = $currentOptions->{$optionAlias};
             } elseif (isset($optionsDefaults[$optionAlias])) {
                 $value = $optionsDefaults[$optionAlias];
             }
             $aHandlerOptions[$optionAlias] = array('label' => isset($optionsLabels[$optionAlias]) ? $optionsLabels[$optionAlias] : $optionAlias, 'type' => isset($optionsTypes[$optionAlias]) ? $optionsTypes[$optionAlias] : 'string', 'value' => $value);
         }
         $tpl->setVariable('handler', $handler);
         $tpl->setVariable('handlerOptions', $aHandlerOptions);
         $tpl->setVariable('jsModules', array());
         return array('form' => $tpl->fetch('design:sqliimport/parts/options.tpl'), 'modules' => $tpl->variable('jsModules'));
     }
     return '';
 }
コード例 #3
0
 /**
  * Returns related scheduled import if it exists, or null if not
  * @return SQLIScheduledImport
  */
 public function getScheduledImport()
 {
     $scheduledImport = null;
     if ($this->attribute('scheduled_id')) {
         $scheduledImport = SQLIScheduledImport::fetch($this->attribute('scheduled_id'));
     }
     return $scheduledImport;
 }
コード例 #4
0
ファイル: addscheduled.php プロジェクト: heliopsis/SQLIImport
     } 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');
         }
         $importOptions = $scheduledImport->attribute('options')->toText();
         $nextTime = $scheduledImport->attribute('next');
         if (!$nextTime) {
             $nextTime = $scheduledImport->attribute('requested_time');
         }
         $importDate = date('Y-m-d', $nextTime);
         $importHour = date('H', $nextTime);
コード例 #5
0
     $importFactory = SQLIImportFactory::instance();
     $importFactory->runImport($aImmediateImports);
     $importFactory->cleanup();
 }
 unset($aImmediateImports);
 // ##########
 // ##### End Immediate imports
 // ##########
 // ####################################################
 // ##########
 // ##### Scheduled imports
 // ##########
 // First fetch all scheduled imports to be processed
 $currentTimestamp = time();
 $conds = array('is_active' => 1, 'next' => array('<=', $currentTimestamp));
 $aScheduledImports = SQLIScheduledImport::fetchList(0, null, $conds);
 // Then create a pending SQLIImportItem for each scheduled import
 if (count($aScheduledImports) > 0) {
     $cli->output('Now handling scheduled imports');
     $aImportItems = array();
     foreach ($aScheduledImports as $scheduledImport) {
         // Create pending import
         $aImportItems[] = SQLIImportItem::fromScheduledImport($scheduledImport);
     }
     $importFactory = SQLIImportFactory::instance();
     $importFactory->setScheduledImports($aScheduledImports);
     $importFactory->runImport($aImportItems);
     $importFactory->cleanup();
     unset($aImportItems, $aScheduledImports);
 }
 // ##########
コード例 #6
0
 * @licence http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2
 * @author Jerome Vieilledent
 * @version @@@VERSION@@@
 * @package sqliimport
 */
$Module = $Params['Module'];
$Result = array();
$tpl = SQLIImportUtils::templateInit();
try {
    $offset = isset($Params['UserParameters']['offset']) ? (int) $Params['UserParameters']['offset'] : 0;
    // Offset for pagination
    $limit = eZPreferences::value('sqliimport_import_limit');
    $limit = $limit ? $limit : 10;
    // Default limit is 10
    $imports = SQLIScheduledImport::fetchList($offset, $limit);
    $importCount = SQLIScheduledImport::count(SQLIScheduledImport::definition());
    $currentURI = '/' . $Module->currentModule() . '/' . $Module->currentView();
    $tpl->setVariable('imports', $imports);
    $tpl->setVariable('offset', $offset);
    $tpl->setVariable('limit', $limit);
    $tpl->setVariable('uri', $currentURI);
    $tpl->setVariable('import_count', $importCount);
    $tpl->setVariable('view_parameters', $Params['UserParameters']);
} catch (Exception $e) {
    $errMsg = $e->getMessage();
    SQLIImportLogger::writeError($errMsg);
    $tpl->setVariable('error_message', $errMsg);
}
$Result['path'] = array(array('url' => false, 'text' => SQLIImportUtils::translate('extension/sqliimport', 'Scheduled import list')));
$Result['left_menu'] = 'design:sqliimport/parts/leftmenu.tpl';
$Result['content'] = $tpl->fetch('design:sqliimport/scheduledlist.tpl');
コード例 #7
0
 * @licence http://www.gnu.org/licenses/gpl-2.0.txt GNU GPLv2
 * @author Jerome Vieilledent
 * @version @@@VERSION@@@
 * @package sqliimport
 */
$Module = $Params['Module'];
$Result = array();
$tpl = SQLIImportUtils::templateInit();
$db = eZDB::instance();
try {
    $user = eZUser::currentUser();
    $userID = $user->attribute('contentobject_id');
    $userLogin = $user->attribute('login');
    $importID = $Params['ImportID'];
    $db->begin();
    $import = SQLIScheduledImport::fetch($importID);
    if (!$import instanceof SQLIScheduledImport) {
        throw new SQLIImportBaseException(SQLIImportUtils::translate('extension/sqliimport/error', "No import item found with ID #%importID", null, array('%importID' => $importID)));
    }
    // Check if user has access to handler alteration
    $aLimitation = array('SQLIImport_Type' => $import->attribute('handler'));
    $hasAccess = SQLIImportUtils::hasAccessToLimitation($Module->currentModule(), 'manageimports', $aLimitation);
    if ($hasAccess) {
        SQLIImportLogger::logNotice('User "' . $userLogin . '" (#' . $userID . ') removed scheduled import #' . $importID . ' on ' . date('Y-m-d H:i'), false);
        $import->remove();
        $db->commit();
        $Module->redirectToView('scheduledlist');
    } else {
        $db->rollback();
        return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
    }