|
|
|
@ -1781,68 +1781,68 @@ function fedora_repository_solution_packs_page() {
|
|
|
|
|
* Check for installed objects and add a 'Update' or 'Install' button if some objects are missing. |
|
|
|
|
* @param array $solution_pack |
|
|
|
|
*/ |
|
|
|
|
function fedora_repository_solution_pack_form($form, $solution_pack_module, $solution_pack_name, $objects = array()) { |
|
|
|
|
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { |
|
|
|
|
// Check each object to see if it is in the repository. |
|
|
|
|
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); |
|
|
|
|
$form = array(); |
|
|
|
|
$form['solution_pack'] = array( |
|
|
|
|
'#type' => 'fieldset', |
|
|
|
|
'#title' => $solution_pack_name, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$needs_update = FALSE; |
|
|
|
|
$needs_install = FALSE; |
|
|
|
|
$form = array(); |
|
|
|
|
$form['solution_pack_module'] = array( |
|
|
|
|
'#type' => 'hidden', |
|
|
|
|
'#value' => $solution_pack_module, |
|
|
|
|
); |
|
|
|
|
$form['solution_pack']['objects'] = array( |
|
|
|
|
'#type' => 'fieldset', |
|
|
|
|
'#title' => "Objects", |
|
|
|
|
'#weight' => 10, |
|
|
|
|
'#attributes' => array('class' => 'collapsed'), |
|
|
|
|
'#collapsible' => TRUE, |
|
|
|
|
'#collapsed' => TRUE, |
|
|
|
|
); |
|
|
|
|
$table_header = array('PID', 'Status'); |
|
|
|
|
$table_rows = array(); |
|
|
|
|
|
|
|
|
|
if (!$form_state['submitted']) { |
|
|
|
|
|
|
|
|
|
foreach($objects as $object) { |
|
|
|
|
if (isset($object['pid'])) { |
|
|
|
|
$pid = $object['pid']; |
|
|
|
|
$form['objects'] = array( |
|
|
|
|
'#type' => 'fieldset', |
|
|
|
|
'#title' => "Objects", |
|
|
|
|
'#weight' => 10, |
|
|
|
|
'#attributes' => array('class' => 'collapsed'), |
|
|
|
|
'#collapsible' => TRUE, |
|
|
|
|
'#collapsed' => TRUE, |
|
|
|
|
); |
|
|
|
|
$table_header = array('PID', 'Status'); |
|
|
|
|
$table_rows = array(); |
|
|
|
|
|
|
|
|
|
$item = new Fedora_Item($pid); |
|
|
|
|
$table_row = array($object['pid']); |
|
|
|
|
$object_status = t('Up-to-date'); |
|
|
|
|
if (!$item->exists()) { |
|
|
|
|
$object_status = 'Missing'; |
|
|
|
|
$needs_install = TRUE; |
|
|
|
|
} |
|
|
|
|
elseif (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { |
|
|
|
|
// Check if the datastream is versioned and needs updating. |
|
|
|
|
$installed_version = fedora_repository_get_islandora_datastream_version($item, $object['dsid']); |
|
|
|
|
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $object['datastream_file']); |
|
|
|
|
if ($available_version > $installed_version) { |
|
|
|
|
$needs_update = TRUE; |
|
|
|
|
$object_status = 'Out of date'; |
|
|
|
|
|
|
|
|
|
foreach($objects as $object) { |
|
|
|
|
if (isset($object['pid'])) { |
|
|
|
|
$pid = $object['pid']; |
|
|
|
|
|
|
|
|
|
$item = new Fedora_Item($pid); |
|
|
|
|
$table_row = array($object['pid']); |
|
|
|
|
$object_status = t('Up-to-date'); |
|
|
|
|
if (!$item->exists()) { |
|
|
|
|
$object_status = 'Missing'; |
|
|
|
|
$needs_install = TRUE; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
array_push($table_row, $object_status); |
|
|
|
|
elseif (isset($object['dsid']) && isset($object['datastream_file']) && isset($object['dsversion'])) { |
|
|
|
|
// Check if the datastream is versioned and needs updating. |
|
|
|
|
$installed_version = fedora_repository_get_islandora_datastream_version($item, $object['dsid']); |
|
|
|
|
$available_version = fedora_repository_get_islandora_datastream_version(NULL, NULL, $object['datastream_file']); |
|
|
|
|
if ($available_version > $installed_version) { |
|
|
|
|
$needs_update = TRUE; |
|
|
|
|
$object_status = 'Out of date'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
array_push($table_row, $object_status); |
|
|
|
|
|
|
|
|
|
$table_rows[] = $table_row; |
|
|
|
|
$table_rows[] = $table_row; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$form['solution_pack']['objects']['table'] = array( |
|
|
|
|
$form['objects']['table'] = array( |
|
|
|
|
'#type' => 'markup', |
|
|
|
|
'#value' => theme_table($table_header, $table_rows), |
|
|
|
|
); |
|
|
|
|
$form['install'] = array( |
|
|
|
|
'#name' => 'install', |
|
|
|
|
'#value' => theme_table($table_header, $table_rows), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
$form['submit'] = array( |
|
|
|
|
'#value' => t('Install'), |
|
|
|
|
'#disabled' => !$needs_install, |
|
|
|
|
'#type' => 'submit', |
|
|
|
|
'#action' => 'install', |
|
|
|
|
'#name' => 'ingest', |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
return $form; |
|
|
|
@ -1864,7 +1864,6 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
|
|
|
|
|
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); |
|
|
|
|
} |
|
|
|
|
batch_set($batch); |
|
|
|
|
batch_process(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function fedora_repository_batch_reingest_object($object, &$context) { |
|
|
|
|