-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora_vault.module
150 lines (135 loc) · 5.41 KB
/
islandora_vault.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<?php
define('ISLANDORA_VAULT_MANAGE_ITEMS', 'manage islandora vault items');
define('ISLANDORA_VAULT_MANAGE', 'manage islandora vault admin');
/**
* Implementation of hook_menu.
* we need some standard entry points so we can have consistent urls for different Object actions
*/
function islandora_vault_menu() {
$items = array();
$items['admin/islandora/islandora_vault/configure'] = array(
'title' => 'Islandora Vault',
'description' => 'Configure settings for Islandora Duracloud cloudsync.',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_vault_admin'),
'file' => 'admin/islandora_vault.admin.inc',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'weight' => -1,
);
$items['islandora_vault/%/manage/vault/logcontent'] = array(
'title' => 'Islandora Vault Serivce Log Content',
//'description' => 'Configure settings for Islandora Duracloud cloudsync.',
'page callback' => 'islandora_vault_cloudsync_log_content',
'file' => 'includes/islandora_vault.cloudsync.service.inc',
'page arguments' => array('islandora_vault_admin'),
'access arguments' => array('islandora_vault_access'),
'page arguments' => array(1),
'type' => MENU_CALLBACK,
'weight' => -1,
);
$items['islandora/object/%islandora_object/manage/vault'] = array(
'title' => 'Vault',
'page callback' => 'islandora_vault_manage_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_vault_access',
'file' => 'includes/islandora_vault.forms.inc',
'access arguments' => array(2),
);
$items['islandora_vault/test'] = array(
'title' => 'foo',
'access callback' => 'user_access',
'page callback' => 'islandora_vault_test',
'type' => MENU_CALLBACK,
'access arguments' => array('administer site configuration'),
);
return $items;
}
function islandora_vault_test() {
module_load_include('inc', 'islandora_vault', 'includes/islandora_vault.duracloud.service');
module_load_include('inc', 'islandora_vault', 'islandora_vault.api');
$duraboss = DuraBoss::getInstance();
$report = islandora_vault_get_latest_report_id($duraboss);
$report = substr($report, 14); //don't want the x-service-out part of the path
return $duraboss->getItemContent($report);
}
/**
* determines whether or not to show this modules vault tab
* @global object $user
* @param string $object_id
* @return boolean
*/
function islandora_vault_access($fedora_object) {
if (!isset($fedora_object)) {
return FALSE;
}
return user_access(ISLANDORA_VAULT_MANAGE);
}
/* function islandora_vault_admin_paths(){
$paths = array(
'islandora_vault/service/logcontent*' => TRUE,
);
return $paths;
} */
function islandora_vault_permission() {
return array(
ISLANDORA_VAULT_MANAGE_ITEMS => array(
'title' => t('Manage items in Islandora Vault'),
'description' => t('Allow users to add items to Duracloud')
)
);
}
/**
* preprocess the edit template add the vault column
* @global string $base_url
* @param array $variables
* theme variables for the edit template
*/
function islandora_vault_preprocess_islandora_default_edit(&$variables) {
$islandora_object = $variables['islandora_object'];
module_load_include('inc', 'islandora_vault', 'includes/islandora_vault.utils');
global $base_url;
module_load_include('inc', 'islandora', 'includes/datastream');
module_load_include('inc', 'islandora', 'includes/utilities');
$table = &$variables['datastream_table'];
$rows = &$table['rows'];
foreach ($rows as &$row) {
foreach ($row as &$column) {
foreach ($islandora_object as $ds) {
if ($column['class'] == 'datastream-label' && $column['data'] == $ds->label) {
$rt_value = "";
if ($ds->controlGroup == 'M') {
try {
$headers = islandora_vault_get_duracloud_item_properties($ds->location);
$chksum = $ds->checksum;
if ($chksum == 'none') {
$rt_value = '<div class="islandora-vault-unknown" label="File exists in both Fedora and Duracloud but does not have a checksum in Fedora">Missing Checksum </div>';
}
else {
$rt_value = ($ds->checksum == $headers['Content-Md5']) ? '<div class="islandora-vault-match" label="checksums in Fedora and Duracloud are the same">Match</div>'
: '<div class="islandora-vault-mismatch" label="checksums in Fedora and Duracloud are not the same">Mismatch</div>';
}
} catch (Exception $e) {
$rt_value = '<div class="islandora-vault-missing" label="File does not exist in Duracloud">Missing File</div>';
}
}
}
}
}
$vault_row = array('class' => 'vault-datastream', 'data' => $rt_value);
array_unshift($row, $vault_row);
}
$headers = &$table['header'];
$vault_header = array('data' => t('Vault'));
array_unshift($headers, $vault_header);
//$table = array('colgroups' => NULL, 'sticky' => TRUE, 'empty' => 'Error loading datastreams', 'caption' => $caption, 'header' => $header, 'rows' => $rows, 'attributes' => $table_attributes);
//$variables['datastream_table'] = $table;
}
/*
function islandora_vault_islandora_pre_purge_object($object){
if(isset($object['CLOUDSYNC'])){
//TODO: maybe delete cloudsync tasks etc.
// we may want to leave the task in case we want to restore
}
}*/