Questo è quello che ho adesso:
<?php
define('DRUPAL_ROOT', '/var/www/clients/client1/web15/web');
include_once(DRUPAL_ROOT . '/includes/bootstrap.inc');
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
// drupal_flush_all_caches();
$users = views_get_view_result('userlist', 'uid_list');
$i = 0;
foreach ($users as $user) {
$filename = 'sites/default/files/generated_pdfs/individual_pdf_report_' . $user->uid . '.pdf';
generate_employee_pdf($user->uid, $filename);
error_log('Generated ' . $filepath);
$i++;
}
// create object
$zip = new ZipArchive();
// open archive
if ($zip->open("sites/default/files/generated_zips/individual-reports.zip", ZIPARCHIVE::CREATE) !== TRUE) {
die ("Could not open archive");
}
// initialize an iterator
// pass it the directory to be processed
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("sites/default/files/generated_pdfs/"));
// iterate over the directory
// add each file found to the archive
foreach ($iterator as $key=>$value) {
$zip->addFile(realpath($key), $value->getFilename()) or die ("ERROR: Could not add file: $key");
}
// close and save archive
$zip->close();
?>
Ricevo un sacco di errori da quanto sopra quando eseguito autonomo. Funziona bene nel mio modulo. Alcuni degli errori sono:
Warning: Invalid argument supplied for foreach() in drupal_depth_first_search() (line 56 of /var/www/clients/client1/web15/web/includes/graph.inc).
Warning: Invalid argument supplied for foreach() in _module_build_dependencies() (line 229 of /var/www/clients/client1/web15/web/includes/module.inc).
Warning: include_once(sites/all/modules/views_bulk_operations/actions/archive.action.inc): failed to open stream: No such file or directory in views_bulk_operations_load_action_includes() (line 56 of /var/www/clients/client1/web15/web/sites/all/modules/views_bulk_operations/views_bulk_operations.module).