'Import project from saisie projets', ); return $items; } /** * Callback for the drush-demo-command command */ function drush_oieau_import_projects_import_projects() { include_once(drupal_get_path('module', 'oieau_import_projects') . '/oieau_import_projects.module'); // oieau_import_get_taxonomy_hierarchy_format(4); // var_export($GLOBALS['user']); //for import and taxonomy, user must be 1 if ($GLOBALS['user']->uid != 1 ) { throw new Exception("This command must be run on admin. use --user=1."); } // $user = user_load(1); // $GLOBALS['user'] = $user; // var_export(taxonomy_get_tree(4)); // return; $path_data_import = download_file_from_saisie_reference(); if ($path_data_import === false) { return 'Error downloaded file.'; } $path_data_control = download_file_control_from_saisie_reference(); if ($path_data_control === false) { return 'Error downloaded control file.'; } //récupére la liste des projet à insérer / mettre à jour // $a = get_array_node_from_project_file_downloaded($path_data_import); // //récupére la liste des nid qui devrait être sur le site oieau (pour dépublié ceuxw qui ne devrait plus y être) // $nids = get_array_nid_from_nid_file_downloaded($path_data_control); // // dsm($a); $operations = []; $a = get_array_node_from_project_file_downloaded($path_data_import); if (!empty($a)) { $operations[] = array('oieau_import_projects_batch', array($a, get_file_path_to_projet_saisie_reference_import_log())); } //récupére la liste des nid qui devrait être sur le site oieau (pour dépublié ceuxw qui ne devrait plus y être) $nids = get_array_nid_from_nid_file_downloaded($path_data_control); if (!empty($nids)) { $operations[] = array('oieau_control_projects_batch', array($nids, get_file_path_to_projet_saisie_reference_control_log())); } // var_export($a); // return 'ok'; //appel fonction du module en batch // $batch = dms_notification_mail_sendout_batch($nid); // batch_set($batch); // $batch =& batch_get(); // $batch['progressive'] = FALSE; // drush_backend_batch_process(); $batch = array( 'operations' => $operations, // array( // array('oieau_import_projects_batch', array($a, get_file_path_to_projet_saisie_reference_import_log())), // array('oieau_control_projects_batch', array($nids, get_file_path_to_projet_saisie_reference_control_log())), // ), 'finished' => 'oieau_import_projects_batch_finish', 'title' => t('Processing import project Batch'), 'init_message' => t('Import project is starting.'), 'progress_message' => t('Processed @current out of @total.'), 'error_message' => t('Import project has encountered an error.'), 'file' => drupal_get_path('module', 'oieau_import_projects') . '/oieau_import_projects.module', // 'progressive' => false, ); // // return 'po'; batch_set($batch); // $batch =& batch_get(); $batch['progressive'] = FALSE; drush_backend_batch_process(); // echo 'ok ca marche' . "\n"; }