Browse Source

ISLANDORA-743 Hook firing without session variable.

pull/164/head
William Panting 12 years ago
parent
commit
9c035ad593
  1. 28
      fedora_repository.module
  2. 22
      fedora_repository.solutionpacks.inc

28
fedora_repository.module

@ -2217,7 +2217,9 @@ function _is_added_to_basket($pid, $account = NULL) {
/** /**
* fedora repository display schema * fedora repository display schema
*
* @param type $file * @param type $file
*
* @return type * @return type
*/ */
function fedora_repository_display_schema($file) { function fedora_repository_display_schema($file) {
@ -2236,14 +2238,20 @@ function fedora_repository_display_schema($file) {
* *
* @param array $object * @param array $object
* An array defining an object to ingest. * An array defining an object to ingest.
* @param type $context * @param string $module_name
* @return type * The string needed in the finished callback to be
* sent out in the postprocess hook.
* @param array $context
* Variables shared between batch iterations
* and finished callback
*/ */
function fedora_repository_batch_reingest_object($object, &$context) { function fedora_repository_batch_reingest_object($object, $module_name, &$context) {
module_load_include('inc', 'fedora_repository', 'api/fedora_item'); module_load_include('inc', 'fedora_repository', 'api/fedora_item');
module_load_include('inc', 'fedora_repository', 'api/fedora_utils'); module_load_include('inc', 'fedora_repository', 'api/fedora_utils');
$context['results']['module_name'] = $module_name;
if (!empty($object) && is_array($object)) { if (!empty($object) && is_array($object)) {
$pid = $object['pid']; $pid = $object['pid'];
if (!valid_pid($pid)) { if (!valid_pid($pid)) {
@ -2316,8 +2324,8 @@ function fedora_repository_batch_reingest_object($object, &$context) {
function fedora_repository_solutionpack_send_postprocess($success, $results, $operations) { function fedora_repository_solutionpack_send_postprocess($success, $results, $operations) {
// Hook to let solution pack objects be modified. // Hook to let solution pack objects be modified.
// Not using module_invoke so solution packs can be expanded by other modules. // Not using module_invoke so solution packs can be expanded by other modules.
if($success) { if ($success) {
module_invoke_all('postprocess_solution_pack', $_SESSION['solution_pack_module_name']); module_invoke_all('postprocess_solution_pack', $results['module_name']);
} }
} }
@ -2341,7 +2349,7 @@ function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid
$doc = simplexml_load_file($datastream_file); $doc = simplexml_load_file($datastream_file);
} }
if (!empty($doc) && $version = (int)$doc->attributes()->version) { if (!empty($doc) && $version = (int) $doc->attributes()->version) {
$return = $version; $return = $version;
} }
@ -2350,7 +2358,9 @@ function fedora_repository_get_islandora_datastream_version($item = NULL, $dsid
/** /**
* theme fedora repository solution pack list * theme fedora repository solution pack list
*
* @param type $solution_packs * @param type $solution_packs
*
* @return string * @return string
*/ */
function theme_fedora_repository_solution_packs_list($solution_packs) { function theme_fedora_repository_solution_packs_list($solution_packs) {
@ -2365,8 +2375,10 @@ function theme_fedora_repository_solution_packs_list($solution_packs) {
} }
/** /**
* Implementation of hook_forms() * Implements hook_forms()
*
* @param string $form_id * @param string $form_id
*
* @return array * @return array
*/ */
function fedora_repository_forms($form_id) { function fedora_repository_forms($form_id) {
@ -2380,7 +2392,7 @@ function fedora_repository_forms($form_id) {
} }
/** /**
* Implementation of hook_imagecache_default_presets(). * Implements hook_imagecache_default_presets().
*/ */
function fedora_repository_imagecache_default_presets() { function fedora_repository_imagecache_default_presets() {
return array( return array(

22
fedora_repository.solutionpacks.inc

@ -58,8 +58,10 @@ function fedora_repository_solution_packs_page() {
* some objects are missing. * some objects are missing.
* *
* @param array &$form_state * @param array &$form_state
* @param array $solution_pack_module * @param unknown $solution_pack_module
* @param array $solution_pack_name * @param string $solution_pack_name
* @param array $objects
* Defaults to an empty array.
*/ */
function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) { function fedora_repository_solution_pack_form(&$form_state, $solution_pack_module, $solution_pack_name, $objects = array()) {
@ -200,12 +202,10 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
foreach ($solution_pack_info[$module_name]['objects'] as $object) { foreach ($solution_pack_info[$module_name]['objects'] as $object) {
// Add this object to the batch job queue. // Add this object to the batch job queue.
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object)); // Module name is needed in the finished callback.
$batch['operations'][] = array('fedora_repository_batch_reingest_object', array($object, $module_name));
} }
// Used in postprocess hook.
$_SESSION['solution_pack_module_name'] = $module_name;
// Tell the batch to call the function to send out a postprocess hook. // Tell the batch to call the function to send out a postprocess hook.
$batch['finished'] = 'fedora_repository_solutionpack_send_postprocess'; $batch['finished'] = 'fedora_repository_solutionpack_send_postprocess';
@ -216,8 +216,10 @@ function fedora_repository_solution_pack_form_submit($form, &$form_state) {
/** /**
* Writes a form entry into the database. * Writes a form entry into the database.
* *
* @param unknown_type $form_name * @param string $form_name
* The name of the form.
* @param unknown_type $form_xml * @param unknown_type $form_xml
* The form definition.
*/ */
function solution_pack_add_form($form_name, $form_xml) { function solution_pack_add_form($form_name, $form_xml) {
$result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name)); $result = db_result(db_query('Select name from {xml_forms} where name = "%s"', $form_name));
@ -233,8 +235,10 @@ function solution_pack_add_form($form_name, $form_xml) {
/** /**
* Writes a form association to the database * Writes a form association to the database
* *
* @param unknown_type $content_model * @param string $content_model
* @param unknown_type $form_name * content model PID
* @param string $form_name
* Name of the form
*/ */
function solution_pack_add_form_association($content_model, $form_name) { function solution_pack_add_form_association($content_model, $form_name) {
$result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"', $result = db_result(db_query('Select content_model from {islandora_content_model_forms} where content_model = "%s" and form_name = "%s"',

Loading…
Cancel
Save