forked from adam-vessey/islandora_book_batch
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathislandora_book_batch.module
57 lines (49 loc) · 1.73 KB
/
islandora_book_batch.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* @file
* Module used to handle book batches through the UI and drush.
*/
/**
* Implements hook_CMODEL_PID_islandora_object_ingested().
*/
function islandora_book_batch_islandora_bookCModel_islandora_object_ingested($object) {
if ($object->relationships->get(ISLANDORA_RELS_EXT_URI, 'book-batched', 'true', RELS_TYPE_PLAIN_LITERAL)) {
if (module_exists('rules')) {
// Allow rules to respond to this event. (To allow configurable messages
// for mailing and such).
rules_invoke_event('islandora_book_batch_ingested', $object->id);
}
$object->relationships->remove(ISLANDORA_RELS_EXT_URI, 'book-batched', 'true', RELS_TYPE_PLAIN_LITERAL);
$object->relationships->remove(ISLANDORA_RELS_EXT_URI, 'email-admin-when-ingested', 'true', RELS_TYPE_PLAIN_LITERAL);
}
}
/**
* Implements hook_menu().
*/
function islandora_book_batch_menu() {
$items = array();
$items['islandora/object/%islandora_object/manage/collection/book_batch'] = array(
'title' => 'Book Batch',
'access callback' => 'islandora_book_batch_menu_access',
'access arguments' => array(2),
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_book_batch_form', 2),
'file' => 'includes/batch.form.inc',
'type' => MENU_LOCAL_ACTION,
);
return $items;
}
/**
* Menu access callback.
*/
function islandora_book_batch_menu_access($object) {
if (!islandora_object_access(ISLANDORA_INGEST, $object)) {
return FALSE;
}
$c = 'COLLECTION_POLICY';
if (isset($object[$c]) && islandora_datastream_access(ISLANDORA_VIEW_OBJECTS, $object[$c])) {
$cp = new CollectionPolicy($object[$c]->content);
return array_key_exists('islandora:bookCModel', $cp->getContentModels());
}
return FALSE;
}