-
Notifications
You must be signed in to change notification settings - Fork 3
/
islandora_pid_list.module
167 lines (146 loc) · 4.82 KB
/
islandora_pid_list.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
<?php
/**
* @file
* Module used to track and manage user defined lists of pids.
*
*/
/*
* Implementation of hook_perm().
*/
function islandora_pid_list_perm() {
return array("Manage other users' pidlists", "Adminisiter islandora_pid_list module");
}
/*
* Implementation of hook_user().
*
* Checks to see if the user was anonymous and created PidList objects before
* they logged in. Iterates through the session and adds these records to the
* database.
*/
function islandora_pid_list_user($op, &$edit, &$account, $category = NULL) {
global $user;
module_load_include('inc', 'islandora_pid_list', 'pidlist');
if ($op == 'login') {
if (!empty($_SESSION['islandora_pid_list'])) {
foreach ($_SESSION['islandora_pid_list'] as $key => $value) {
$pidlistsession = unserialize($value);
$anonindex = array_search(0, $pidlistsession->userlist, TRUE);
// Replace the anon who's logged in with their associated user uid
$pidlistsession->useruid = $user->uid;
$pidlistsession->userlist[$anonindex] = $user->uid;
$pidlistsession->session = FALSE;
$pidlistsession->create_list();
unset($_SESSION['islandora_pid_list'][$key]);
}
}
}
}
/*
* Implementation of hook_menu().
*/
function islandora_pid_list_menu() {
$items['pidlist'] = array(
'title' => 'Islandora Pid List',
'description' => "Track and manage list of pids",
'type' => MENU_NORMAL_ITEM,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_pid_list_list_form'),
'access arguments' => array('access content'),
'file' => 'pid_list_form.inc',
);
$items['pidlist/lists'] = array(
'title' => 'Lists',
'type' => MENU_DEFAULT_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_pid_list_list_form'),
'access arguments' => array('access content'),
'file' => 'pid_list_form.inc',
);
$items['pidlist/add'] = array(
'title' => 'Add',
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_pid_list_add_form'),
'access arguments' => array('access content'),
'file' => 'pid_list_form.inc',
);
$items['admin/settings/islandora_pid_list'] = array(
'title' => 'Islandora Pid List',
'description' => 'Settings for the Islandora Pid List module.',
'page callback' => 'drupal_get_form',
'page arguments' => array('islandora_pid_list_settings'),
'access arguments' => array(t('Adminisiter islandora_pid_list module')),
'file' => 'pid_list_form.inc'
);
$items['pidlist/ahah/add/pid'] = array(
'page callback' => 'islandora_pid_list_add_pid_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/add/user'] = array(
'page callback' => 'islandora_pid_list_add_user_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/add/listassociation'] = array(
'page callback' => 'islandora_pid_list_add_association_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/remove/user'] = array(
'page callback' => 'islandora_pid_list_remove_user_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/remove/pid'] = array(
'page callback' => 'islandora_pid_list_remove_pid_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/remove/list'] = array(
'page callback' => 'islandora_pid_list_remove_list_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/remove/listassociation'] = array(
'page callback' => 'islandora_pid_list_remove_association_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/updatename'] = array(
'page callback' => 'islandora_pid_list_update_name_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
$items['pidlist/ahah/remove/noremove'] = array(
'page callback' => 'islandora_pid_list_no_remove_js',
'access callback' => TRUE,
'type' => MENU_CALLBACK,
'file' => 'pid_list_form.inc',
);
return $items;
}
/**
* Implementation of hook_islandora_tabs().
*/
function islandora_pid_list_islandora_tabs($content_models, $pid) {
module_load_include('inc', 'islandora_pid_list', 'pid_list_form');
$tabs = array();
if (variable_get('islandora_pid_list_show_tabs', TRUE)) {
// Drupal 7 uses MENU_LOCAL_TASKS
$tabs['islandora_pid_list'] = array(
'#type' => 'tabpage',
'#title' => 'Lists',
'#content' => drupal_get_form('islandora_pid_list_pid_form', $pid),
);
return $tabs;
}
}