forked from Islandora/islandora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
islandora.module
1866 lines (1752 loc) · 63.9 KB
/
islandora.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* @file
* Defines all the hooks this module implements.
*
* islandora.module: defines paths (drupal menu items) as entry points and acts
* as a hub for dispatching tasks to other modules.
*
* This file is part of Islandora.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the program. If not, see <http ://www.gnu.org/licenses/>.
*/
// Common datastreams.
define('ISLANDORA_DS_COMP_STREAM', 'DS-COMPOSITE-MODEL');
// Permissions.
define('ISLANDORA_VIEW_OBJECTS', 'view fedora repository objects');
define('ISLANDORA_METADATA_EDIT', 'edit fedora metadata');
define('ISLANDORA_ADD_DS', 'add fedora datastreams');
define('ISLANDORA_INGEST', 'ingest fedora objects');
define('ISLANDORA_PURGE', 'delete fedora objects and datastreams');
define('ISLANDORA_MANAGE_PROPERTIES', 'manage object properties');
define('ISLANDORA_VIEW_DATASTREAM_HISTORY', 'view old datastream versions');
define('ISLANDORA_MANAGE_DELETED_OBJECTS', 'manage deleted objects');
define('ISLANDORA_REVERT_DATASTREAM', 'revert to old datastream');
define('ISLANDORA_REGENERATE_DERIVATIVES', 'regenerate derivatives for an object');
// Hooks.
define('ISLANDORA_VIEW_HOOK', 'islandora_view_object');
define('ISLANDORA_PRINT_HOOK', 'islandora_view_print_object');
define('ISLANDORA_EDIT_HOOK', 'islandora_edit_object');
define('ISLANDORA_OVERVIEW_HOOK', 'islandora_overview_object');
define('ISLANDORA_PRE_INGEST_HOOK', 'islandora_ingest_pre_ingest');
define('ISLANDORA_POST_INGEST_HOOK', 'islandora_ingest_post_ingest');
define('ISLANDORA_PRE_PURGE_OBJECT_HOOK', 'islandora_pre_purge_object');
define('ISLANDORA_POST_PURGE_OBJECT_HOOK', 'islandora_post_purge_object');
define('ISLANDORA_UPDATE_RELATED_OBJECTS_PROPERTIES_HOOK', 'islandora_update_related_objects_properties');
// @todo Add Documentation.
define('ISLANDORA_OBJECT_INGESTED_HOOK', 'islandora_object_ingested');
define('ISLANDORA_OBJECT_MODIFIED_HOOK', 'islandora_object_modified');
define('ISLANDORA_OBJECT_PURGED_HOOK', 'islandora_object_purged');
define('ISLANDORA_DATASTREAM_INGESTED_HOOK', 'islandora_datastream_ingested');
define('ISLANDORA_DATASTREAM_MODIFIED_HOOK', 'islandora_datastream_modified');
define('ISLANDORA_DATASTREAM_PURGED_HOOK', 'islandora_datastream_purged');
define('ISLANDORA_INGEST_STEP_HOOK', 'islandora_ingest_steps');
define('ISLANDORA_DERVIATIVE_CREATION_HOOK', 'islandora_derivative');
// Autocomplete paths.
define('ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE', 'islandora/autocomplete/content-models');
define('ISLANDORA_MIME_TYPES_AUTOCOMPLETE', 'islandora/autocomplete/mime-types');
/**
* @deprecated Constants.
*/
// @codingStandardsIgnoreStart
define('DS_COMP_STREAM', ISLANDORA_DS_COMP_STREAM);
define('FEDORA_VIEW_OBJECTS', ISLANDORA_VIEW_OBJECTS);
define('FEDORA_METADATA_EDIT', ISLANDORA_METADATA_EDIT);
define('FEDORA_ADD_DS', ISLANDORA_ADD_DS);
define('FEDORA_INGEST', ISLANDORA_INGEST);
define('FEDORA_PURGE', ISLANDORA_PURGE);
define('FEDORA_MANAGE_PROPERTIES', ISLANDORA_MANAGE_PROPERTIES);
// @codingStandardsIgnoreEnd
/**
* Implements hook_menu().
*
* We need some standard entry points so we can have consistent urls for
* different Object actions
*/
function islandora_menu() {
$items = array();
$items['admin/islandora'] = array(
'title' => 'Islandora',
'description' => "Configure settings associated with Islandora.",
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/islandora/configure'] = array(
'title' => 'Configuration',
'description' => 'Configure settings for Islandora.',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_repository_admin'),
'file' => 'includes/admin.form.inc',
'access arguments' => array('administer site configuration'),
'type' => MENU_NORMAL_ITEM,
'weight' => -1,
);
$items['admin/islandora/metadata'] = array(
'title' => 'Metadata Display',
'description' => 'Configure settings for metadata display on Islandora objects',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_metadata_display_form'),
'file' => 'includes/metadata.inc',
'access arguments' => array('administer site configuration'),
);
$items['admin/islandora/solution_packs'] = array(
'title' => 'Solution packs',
'description' => 'Install content models and collections required by installed solution packs.',
'page callback' => 'islandora_solution_packs_admin',
'access arguments' => array(ISLANDORA_ADD_DS),
'file' => 'includes/solution_packs.inc',
'type' => MENU_NORMAL_ITEM,
);
$items['islandora'] = array(
'title' => 'Islandora Repository',
'page callback' => 'islandora_view_default_object',
'type' => MENU_NORMAL_ITEM,
'access arguments' => array(ISLANDORA_VIEW_OBJECTS),
);
$items['islandora/object/%islandora_object'] = array(
'title callback' => 'islandora_drupal_title',
'title arguments' => array(2),
'page callback' => 'islandora_view_object',
'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM,
'access callback' => 'islandora_object_access_callback',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
);
$items['islandora/object/%islandora_object/print_object'] = array(
'page callback' => 'islandora_printer_object',
'page arguments' => array(2),
'type' => MENU_NORMAL_ITEM,
'access callback' => 'islandora_object_access',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
);
$items['islandora/object/%islandora_object/print'] = array(
'title' => 'Print Object',
'page callback' => 'islandora_print_object',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/view'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
);
$items['islandora/object/%islandora_object/view/default'] = array(
'title' => 'View',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -1,
);
$items['islandora/object/%islandora_object/manage'] = array(
'title' => 'Manage',
'page callback' => 'islandora_manage_overview_object',
'page arguments' => array(2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array(
array(
ISLANDORA_MANAGE_PROPERTIES,
ISLANDORA_METADATA_EDIT,
ISLANDORA_ADD_DS,
ISLANDORA_PURGE,
ISLANDORA_INGEST,
), 2),
);
$items['islandora/object/%islandora_object/manage/overview'] = array(
'title' => 'Overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -20,
);
$items['islandora/object/%islandora_object/manage/datastreams'] = array(
'title' => 'Datastreams',
'type' => MENU_LOCAL_TASK,
'page callback' => 'islandora_edit_object',
'page arguments' => array(2),
'access callback' => 'islandora_object_manage_access_callback',
'access arguments' => array(
array(
ISLANDORA_METADATA_EDIT,
ISLANDORA_ADD_DS,
ISLANDORA_PURGE,
), 2),
'weight' => -10,
);
$items['islandora/object/%islandora_object/manage/properties'] = array(
'title' => 'Properties',
'page callback' => 'drupal_get_form',
'file' => 'includes/object_properties.form.inc',
'page arguments' => array('islandora_object_properties_form', 2),
'type' => MENU_LOCAL_TASK,
'access callback' => 'islandora_object_access_callback',
'access arguments' => array(ISLANDORA_MANAGE_PROPERTIES, 2),
'weight' => -5,
);
$items['islandora/object/%islandora_object/delete'] = array(
'title' => 'Delete object',
'file' => 'includes/delete_object.form.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_delete_object_form', 2),
'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access_callback',
'access arguments' => array(ISLANDORA_PURGE, 2),
);
$items['islandora/object/%islandora_object/regenerate'] = array(
'title' => 'Regenerate all derivatives on an object',
'file' => 'includes/regenerate_derivatives.form.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_regenerate_object_derivatives_form', 2),
'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access_callback',
'access arguments' => array(ISLANDORA_REGENERATE_DERIVATIVES, 2),
);
$items['islandora/object/%islandora_object/manage/datastreams/add'] = array(
'title' => 'Add a datastream',
'file' => 'includes/add_datastream.form.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_add_datastream_form', 2),
'type' => MENU_LOCAL_ACTION,
'access callback' => 'islandora_object_access_callback',
'access arguments' => array(ISLANDORA_ADD_DS, 2),
);
$items['islandora/object/%islandora_object/manage/datastreams/add/autocomplete'] = array(
'file' => 'includes/add_datastream.form.inc',
'page callback' => 'islandora_add_datastream_form_autocomplete_callback',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access_callback',
'access arguments' => array(ISLANDORA_ADD_DS, 2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream'] = array(
'title' => 'View datastream',
'page callback' => 'islandora_view_datastream',
'page arguments' => array(4, FALSE, NULL),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 4),
'load arguments' => array(2),
);
// This menu item uses token authentication in islandora_tokened_object.
$items['islandora/object/%islandora_tokened_object/datastream/%islandora_tokened_datastream/view'] = array(
'title' => 'View datastream',
'load arguments' => array('%map'),
'access callback' => 'islandora_object_datastream_tokened_access_callback',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2, 4),
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/download'] = array(
'title' => 'Download datastream',
'page callback' => 'islandora_download_datastream',
'page arguments' => array(4),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/edit'] = array(
'title' => 'Edit datastream',
'page callback' => 'islandora_edit_datastream',
'page arguments' => array(4),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_METADATA_EDIT, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/delete'] = array(
'title' => 'Delete data stream',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_delete_datastream_form', 4),
'file' => 'includes/delete_datastream.form.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_PURGE, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version'] = array(
'title' => 'Datastream Versions',
'page arguments' => array(4),
'page callback' => 'islandora_datastream_version_table',
'file' => 'includes/datastream.version.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/delete'] = array(
'title' => 'Delete datastream version',
'page arguments' => array('islandora_delete_datastream_version_form', 4, 6),
'page callback' => 'drupal_get_form',
'file' => 'includes/datastream.version.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_PURGE, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/revert'] = array(
'title' => 'Revert to datastream version',
'page arguments' => array('islandora_revert_datastream_version_form', 4, 6),
'page callback' => 'drupal_get_form',
'file' => 'includes/datastream.version.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_REVERT_DATASTREAM, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/version/%/view'] = array(
'title' => 'View datastream version',
'page callback' => 'islandora_view_datastream',
'page arguments' => array(4, FALSE, 6),
'type' => MENU_CALLBACK,
'file' => 'includes/datastream.inc',
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_VIEW_DATASTREAM_HISTORY, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/datastream/%islandora_datastream/regenerate'] = array(
'title' => 'Regenrate datastream derivative',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_regenerate_datastream_derivative_form', 4),
'file' => 'includes/regenerate_derivatives.form.inc',
'type' => MENU_CALLBACK,
'access callback' => 'islandora_datastream_access',
'access arguments' => array(ISLANDORA_REGENERATE_DERIVATIVES, 4),
'load arguments' => array(2),
);
$items['islandora/object/%islandora_object/download_clip'] = array(
'page callback' => 'islandora_download_clip',
'page arguments' => array(2),
'type' => MENU_CALLBACK,
'access callback' => 'islandora_object_access',
'access arguments' => array(ISLANDORA_VIEW_OBJECTS, 2),
'load arguments' => array(2),
);
$items['islandora/event-status'] = array(
'title' => 'Event Status',
'page callback' => 'islandora_event_status',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
'file' => 'includes/utilities.inc',
);
$items[ISLANDORA_CONTENT_MODELS_AUTOCOMPLETE] = array(
'title' => 'Autocomplete callback',
'description' => 'Autocomplete a Fedora content model PID.',
'file' => 'includes/content_model.autocomplete.inc',
'page callback' => 'islandora_content_model_autocomplete',
'page arguments' => array(3),
'access arguments' => array('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items[ISLANDORA_MIME_TYPES_AUTOCOMPLETE] = array(
'title' => 'Autocomplete callback',
'description' => 'Autocomplete MIME Types.',
'file' => 'includes/mime_type.autocomplete.inc',
'page callback' => 'islandora_mime_type_autocomplete',
'page arguments' => array(3),
'access arguments' => array('administer site configuration'),
'type' => MENU_CALLBACK,
);
$items['admin/islandora/restore/prep'] = array(
'description' => 'Restore or permanantly remove objects with Deleted status',
'title' => 'Manage Deleted Objects',
'file' => 'includes/manage_deleted_objects.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_deleted_objects_prep_form'),
'type' => MENU_NORMAL_ITEM,
'access arguments' => array(ISLANDORA_MANAGE_DELETED_OBJECTS),
);
$items['admin/islandora/restore/manage'] = array(
'description' => 'Restore or permanantly remove objects with Deleted status',
'title' => 'Manage Deleted Objects',
'file' => 'includes/manage_deleted_objects.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_deleted_objects_manage_form'),
'type' => MENU_SUGGESTED_ITEM,
'access arguments' => array(ISLANDORA_MANAGE_DELETED_OBJECTS),
);
return $items;
}
/**
* Implements hook_admin_paths().
*/
function islandora_admin_paths() {
$paths = array();
$paths['islandora/object/*/manage*'] = TRUE;
$paths['islandora/object/*/delete*'] = TRUE;
$paths['islandora/object/*/datastream/*/edit'] = TRUE;
$paths['islandora/object/*/datastream/*/versions'] = TRUE;
return $paths;
}
/**
* Implements hook_theme().
*/
function islandora_theme() {
return array(
// Default object template.
'islandora_default' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-object',
'variables' => array('islandora_object' => NULL),
),
// Default edit page.
'islandora_default_edit' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-object-edit',
'variables' => array('islandora_object' => NULL),
),
// Admin table for solution pack viewer selection.
'islandora_viewers_table' => array(
'file' => 'includes/solution_packs.inc',
'render element' => 'form',
),
// Print used by the clipper.
'islandora_object_print' => array(
'file' => 'theme/theme.inc',
'variables' => array('object' => NULL, 'content' => array()),
),
// Print object view, prints islandora objects.
'islandora_object_print_object' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-object-print',
'variables' => array(
'object' => NULL,
'content' => NULL,
'islandora_content' => NULL),
),
// Render a bunch of objects as either a grid or a list.
'islandora_objects' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-objects',
'variables' => array(
'objects' => NULL,
'display' => NULL,
'page_size' => 20,
'limit' => 10,
),
),
// Render a bunch of objects as a grid.
'islandora_objects_grid' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-objects-grid',
'variables' => array('objects' => NULL),
),
// Render a bunch of objects as a list.
'islandora_objects_list' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-objects-list',
'variables' => array('objects' => NULL),
),
'islandora_datastream_edit_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_delete_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL, 'version' => NULL),
),
'islandora_datastream_revert_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL, 'version' => NULL),
),
'islandora_datastream_view_link' => array(
'file' => 'theme/theme.inc',
'variables' => array(
'datastream' => NULL,
'version' => NULL,
'label' => NULL,
),
),
'islandora_datastream_download_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_version_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_datastream_regenerate_link' => array(
'file' => 'theme/theme.inc',
'variables' => array('datastream' => NULL),
),
'islandora_dublin_core_display' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-dublin-core-display',
// We can add PIDs to the end of this pattern in our preprocess function
// and templates will be able to have have a pid appended to the
// template name to overide a template on a per object basis.
// An example template might be named:
// "islandora-dublin-core-display--islandora-27.tpl.php".
'pattern' => 'islandora_dublin_core_display__',
'variables' => array(
'islandora_object' => NULL,
'print' => NULL,
),
),
'islandora_dublin_core_description' => array(
'file' => 'theme/theme.inc',
'template' => 'theme/islandora-dublin-core-description',
// We can add PIDs to the end of this pattern in our preprocess function
// and templates will be able to have have a pid appended to the
// template name to overide a template on a per object basis.
// An example template might be named:
// "islandora-dublin-core-description--islandora-27.tpl.php".
'pattern' => 'islandora_dublin_core_description__',
'variables' => array('islandora_object' => NULL),
),
// Table for install/reinstall content model and collections.
'islandora_solution_pack_table' => array(
'file' => 'includes/solution_packs.inc',
'render element' => 'form',
),
);
}
/**
* Implements hook_permission().
*/
function islandora_permission() {
return array(
ISLANDORA_VIEW_OBJECTS => array(
'title' => t('View repository objects'),
'description' => t('View objects in the repository. Note: Fedora XACML security policies may override this permission.'),
),
ISLANDORA_ADD_DS => array(
'title' => t('Add datastreams to repository objects'),
'description' => t('Add datastreams to objects in the repository. Note: Fedora XACML security policies may override this position.'),
),
ISLANDORA_METADATA_EDIT => array(
'title' => t('Edit metadata'),
'description' => t('Edit metadata for objects in the repository.'),
),
ISLANDORA_INGEST => array(
'title' => t('Create new repository objects'),
'description' => t('Create new objects in the repository.'),
),
ISLANDORA_PURGE => array(
'title' => t('Permanently remove objects from the repository'),
'description' => t('Permanently remove objects from the repository.'),
),
ISLANDORA_MANAGE_PROPERTIES => array(
'title' => t('Manage object properties'),
'description' => t('Modify object labels, owner IDs, and states.'),
),
ISLANDORA_VIEW_DATASTREAM_HISTORY => array(
'title' => t('View datastream history'),
'description' => t('View all previous versions of a datastream.'),
),
ISLANDORA_REVERT_DATASTREAM => array(
'title' => t('Revert datastream history'),
'description' => t('Revert to a previous version of a datastream.'),
),
ISLANDORA_MANAGE_DELETED_OBJECTS => array(
'title' => t('Manage deleted objects'),
'description' => t('Purge or revert deleted objects.'),
),
ISLANDORA_REGENERATE_DERIVATIVES => array(
'title' => t('Regenerate derivatives'),
'description' => t('Regenerate derivatives for an object or per datastream.'),
),
);
}
/**
* Implements hook_i18n_string_info().
*/
function islandora_i18n_string_info() {
return array(
'islandora' => array(
'title' => t('Islandora'),
'description' => t('Translatable Metadata labels, etc.'),
'format' => FALSE,
'list' => TRUE,
),
);
}
/**
* Implements islandora_i18n_string_list().
*/
function islandora_i18n_string_list($group) {
if ($group == 'islandora') {
return array(
'islandora' => array(
'dc' => array(
'title' => array('label' => 'Title'),
'creator' => array('label' => 'Creator'),
'subject' => array('label' => 'Subject'),
'description' => array('label' => 'Description'),
'publisher' => array('label' => 'Publisher'),
'contributor' => array('label' => 'Contributor'),
'date' => array('label' => 'Date'),
'type' => array('label' => 'Type'),
'format' => array('label' => 'Format'),
'identifier' => array('label' => 'Identifier'),
'source' => array('label' => 'Source'),
'language' => array('label' => 'Language'),
'relation' => array('label' => 'Relation'),
'coverage' => array('label' => 'Coverage'),
),
),
);
}
}
/**
* Renders the print page for the given object.
*
* Modules can either implement preprocess functions to append content onto the
* 'content' variable, or override the display by providing a theme suggestion.
*
* @param AbstractObject $object
* The object.
*
* @return array
* A renderable array.
*/
function islandora_print_object(AbstractObject $object) {
drupal_set_title($object->label);
return theme('islandora_object_print', array('object' => $object));
}
/**
* Implements hook_forms().
*/
function islandora_forms($form_id) {
$forms = array();
if (strpos($form_id, 'islandora_solution_pack_form_') !== FALSE) {
$forms[$form_id] = array('callback' => 'islandora_solution_pack_form');
}
return $forms;
}
/**
* Checks whether the user can access the given object.
*
* Checks for repository access, object/datastream existance, namespace access,
* user permissions, content models.
*
* Will check the given user or the user repersented by the GET token parameter,
* failing that it will use the global user.
*
* @global $user
*
* @param mixed $object_or_datastream
* The AbstractObject or AbstractDatastream to test for accessibility, if NULL
* is given the object is assumed to not exist or be inaccessible.
* @param array $permissions
* The required user permissions.
* @param array $content_models
* The required content models.
* @param bool $access_any
* (optional) TRUE to grant access if any single requirement is met from both
* the permissions and content models parameters. FALSE if all requirements
* must be met from both the permissions and content model parameters.
* @param object $user
* (optional) The account to check, if not given check the GET parameters for
* a token to restore the user. If no GET parameter is present use currently
* logged in user.
*
* @return bool
* TRUE if the user is allowed to access this object/datastream, FALSE
* otherwise.
*/
function islandora_user_access($object_or_datastream, array $permissions, $content_models = array(), $access_any = TRUE, $user = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$is_repository_accessible = &drupal_static(__FUNCTION__);
// If the repository is inaccessible then access always fails.
if (!isset($is_repository_accessible)) {
$is_repository_accessible = islandora_describe_repository();
if (!$is_repository_accessible) {
// Only display the inaccessible message once.
islandora_display_repository_inaccessible_message();
return FALSE;
}
}
if (!$is_repository_accessible || !is_object($object_or_datastream) || empty($permissions)) {
return FALSE;
}
// Determine what has been passed as $object.
if (is_subclass_of($object_or_datastream, 'AbstractObject')) {
$object = $object_or_datastream;
$datastream = NULL;
}
elseif (is_subclass_of($object_or_datastream, 'AbstractDatastream')) {
$datastream = $object_or_datastream;
$object = $datastream->parent;
}
// Determine the user account to test against.
if (!isset($user)) {
$token = filter_input(INPUT_GET, 'token', FILTER_SANITIZE_STRING);
if ($token) {
module_load_include('inc', 'islandora', 'includes/authtokens');
$token_user = islandora_validate_object_token($object->id, $datastream->id, $token);
if ($user) {
$user = user_load($token_user->uid);
}
}
else {
global $user;
}
}
// Check for access.
if ($access_any) {
$has_required_content_models = empty($content_models) ? TRUE : count(array_intersect($object->models, $content_models)) > 0;
if ($has_required_content_models) {
foreach ($permissions as $p) {
if ($datastream !== NULL) {
$check = islandora_datastream_access($p, $datastream, $user);
}
else {
$check = islandora_object_access($p, $object, $user);
}
if ($check) {
return TRUE;
}
}
return FALSE;
}
}
else {
$has_required_content_models = count(array_diff($content_models, $object->models)) == 0;
if ($has_required_content_models) {
foreach ($permissions as $p) {
if ($datastream !== NULL) {
$check = islandora_datastream_access($p, $datastream, $user);
}
else {
$check = islandora_object_access($p, $object, $user);
}
if (!$check) {
return FALSE;
}
}
// Should already have failed if there are no $permissions.
return TRUE;
}
}
return FALSE;
}
/**
* Checks whether the user can access the given object.
*
* Checks for object existance, accessiblitly, namespace permissions,
* and user permissions
*
* @param string $perm
* User permission to test for.
* @param AbstractObject $object
* The object to test, if NULL given the object doesn't exist or is
* inaccessible.
*
* @return bool
* TRUE if the user is allowed to access this object, FALSE otherwise.
*/
function islandora_object_access_callback($perm, $object = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
if (!$object && !islandora_describe_repository()) {
islandora_display_repository_inaccessible_message();
return FALSE;
}
return islandora_object_access($perm, $object);
}
/**
* Checks whether the user can access the given object and datastream.
*
* Checks for object existance, accessiblitly, namespace permissions,
* and user permissions
*
* @param string $perm
* The user permission to test for.
* @param AbstractObject $object
* The object to test, if NULL given the object doesn't exist or is
* inaccessible.
* @param AbstractDatastream $datastream
* The datastream to test, if NULL given the datastream doesn't exist
* or is inaccessible.
* @param StdObject $account
* The account to test permissions as or NULL for current user.
*
* @return bool
* TRUE if the user is allowed to access this object, FALSE otherwise.
*/
function islandora_object_datastream_access_callback($perm, $object = NULL, $datastream = NULL, $account = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$message = islandora_deprecated('7.x-1.2', 'Use islandora_datastream_access().');
trigger_error(filter_xss($message), E_USER_DEPRECATED);
return islandora_datastream_access($perm, $datastream, $account);
}
/**
* Checks whether the user can access the given object and datastream.
*
* This function will validate and use a token if present in the GET parameters.
*
* Checks for object existance, accessibility, namespace permissions,
* and user permissions
*/
function islandora_object_datastream_tokened_access_callback($perm, $object = NULL, $datastream = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
$token_account = NULL;
$token = filter_input(INPUT_GET, 'token', FILTER_SANITIZE_STRING);
if ($token) {
$user = islandora_validate_object_token($object->id, $datastream->id, $token);
if ($user) {
$token_account = user_load($user->uid);
}
}
return islandora_datastream_access($perm, $datastream, $token_account);
}
/**
* Checks whether the user can access the given object's manage tab.
*
* Checks for object existance, accessiblitly, namespace permissions,
* and user permissions
*
* @param array $perms
* Array of user permission to test for.
* @param AbstractObject $object
* The object to test, if NULL given the object doesn't exist or is
* inaccessible.
*
* @return bool
* TRUE if the user is allowed to access this object, FALSE otherwise.
*/
function islandora_object_manage_access_callback($perms, $object = NULL) {
module_load_include('inc', 'islandora', 'includes/utilities');
if (!$object && !islandora_describe_repository()) {
islandora_display_repository_inaccessible_message();
return FALSE;
}
$has_access = FALSE;
for ($i = 0; $i < count($perms) && !$has_access; $i++) {
$has_access = $has_access || islandora_object_access($perms[$i], $object);
}
return $has_access;
}
/**
* Renders the given objects manage overview page.
*
* @param AbstractObject $object
* The object to manage.
*
* @return string
* The HTML repersentation of the manage object page.
*/
function islandora_manage_overview_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/utilities');
$output = array();
$hooks = islandora_build_hook_list(ISLANDORA_OVERVIEW_HOOK, $object->models);
foreach ($hooks as $hook) {
$temp = module_invoke_all($hook, $object);
islandora_as_renderable_array($temp);
if (!empty($temp)) {
$output = array_merge_recursive($output, $temp);
}
}
if (empty($output)) {
// Add in the default, if we did not get any results.
$output = islandora_default_islandora_manage_overview_object($object);
}
arsort($output);
drupal_alter($hooks, $object, $output);
islandora_as_renderable_array($output);
return $output;
}
/**
* Renders the default manage object page for the given object.
*
* @param AbstractObject $object
* The object used to render the manage object page.
*
* @return array
* The default rendering of the object manage page, indexed at
* 'Default Edit output'.
*/
function islandora_default_islandora_manage_overview_object(AbstractObject $object) {
$output = theme('islandora_default_overview', array('islandora_object' => $object));
return array('Default overview output' => array('#markup' => $output));
}
/**
* Renders the given objects manage page.
*
* Its possible to modify the output of this function if 'ISLANDORA_EDIT_HOOK'
* is implemented in other modules.
*
* If no modules implement 'ISLANDORA_EDIT_HOOK' then this function returns the
* default manage view.
*
* @param AbstractObject $object
* The object to manage.
*
* @return string
* The HTML repersentation of the manage object page.
*/
function islandora_edit_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb');
module_load_include('inc', 'islandora', 'includes/utilities');
drupal_set_title($object->label);
drupal_set_breadcrumb(islandora_get_breadcrumbs($object));
$output = array();
foreach (islandora_build_hook_list(ISLANDORA_EDIT_HOOK, $object->models) as $hook) {
$temp = module_invoke_all($hook, $object);
islandora_as_renderable_array($temp);
if (!empty($temp)) {
$output = array_merge_recursive($output, $temp);
}
}
if (empty($output)) {
// Add in the default, if we did not get any results.
$output = islandora_default_islandora_edit_object($object);
}
arsort($output);
drupal_alter(ISLANDORA_EDIT_HOOK, $object, $output);
islandora_as_renderable_array($output);
return $output;
}
/**
* Renders the default manage object page for the given object.
*
* @param AbstractObject $object
* The object used to render the manage object page.
*
* @return array
* The default rendering of the object manage page, indexed at
* 'Default Edit output'.
*/
function islandora_default_islandora_edit_object(AbstractObject $object) {
$output = theme('islandora_default_edit', array('islandora_object' => $object));
return array('Default Edit output' => array('#markup' => $output));
}
/**
* Page callback for the path "islandora".
*
* Redirects to the view of the object indicated by the Drupal variable
* 'islandora_repository_pid'.
*/
function islandora_view_default_object() {
$pid = variable_get('islandora_repository_pid', 'islandora:root');
drupal_goto("islandora/object/$pid");
}
/**
* Renders the default view object page for the given object.
*
* Modules should implement ISLANDORA_VIEW_HOOK for the Fedora Content
* models that their modules want to provide a view for.
*
* If no modules implement the hook then the default view object page
* will be rendered.
*
* @param AbstractObject $object
* The object to view.
*
* @return string
* The html repersentation of this object.
*/
function islandora_view_object(AbstractObject $object) {
module_load_include('inc', 'islandora', 'includes/breadcrumb');
module_load_include('inc', 'islandora', 'includes/utilities');
// Add the print button via JavaScript.
$path = drupal_get_path('module', 'islandora');