-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsopac_admin.php
More file actions
438 lines (386 loc) · 18.7 KB
/
sopac_admin.php
File metadata and controls
438 lines (386 loc) · 18.7 KB
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
<?php
/**
* SOPAC is The Social OPAC: a Drupal module that serves as a wholly integrated web OPAC for the Drupal CMS
* This file contains the Drupal include functions for all the SOPAC admin pieces and configuration options
* This file is called via hook_menu
*
* @package SOPAC
* @version 2.1
* @author John Blyberg
*/
/**
* Sets up administrative options for SOPAC and returns a systems settings form
*
* @return string Settings form HTML
*/
function sopac_admin() {
$form = array();
$current_ils = variable_get( 'sopac_ils', FALSE );
if ( !$current_ils ) {
$form['starter_instruction'] = array(
'#type' => 'markup',
'#value' => 'Please select your ILS, then submit this form to continue setup.',
);
}
$form['sopac_general'] = array(
'#type' => 'fieldset',
'#title' => t( 'General Settings' ),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['sopac_general']['sopac_ils'] = array(
'#type' => 'select',
'#title' => t( 'Your ILS name' ),
'#default_value' => variable_get( 'sopac_ils', 'polaris' ),
'#options' => array( 'polaris' => 'polaris', 'iii' => 'iii', 'koha' => 'koha', 'sirsi' => 'sirsi' ),
'#required' => TRUE,
);
// Start admin with only choice of ILS.
if ( !$current_ils ) {
$form['sopac_general']['#collapsed'] = FALSE;
// This will call sopac_admin_submit() to clear menu cache
$form = system_settings_form( $form );
$form['#submit'][] = 'sopac_admin_submit';
return $form;
}
$form['sopac_general']['sopac_lib_name'] = array(
'#type' => 'textfield',
'#title' => t( 'Your Institution\'s name' ),
'#default_value' => variable_get( 'sopac_lib_name', 'Anytown Public Library' ),
'#size' => 32,
'#maxlength' => 254,
'#description' => t( "The name of your library or institution." ),
'#required' => TRUE,
);
$locum_path = trim( variable_get( 'sopac_locum_path', '/usr/local/include/locum' ) );
if ( $locum_path[0] != '/' ) {
$locum_path = '/' . $locum_path;
}
if ( substr( $locum_path, -1 ) != '/' ) {
$locum_path .= '/';
}
if ( !file_exists( $locum_path . 'locum-client.php' ) ) {
$locum_error = '<br /><span style="color: red;">NOTE: ' . $locum_path . 'locum-client.php does not seem to exist!</span>' ;
}
$form['sopac_general']['sopac_locum_path'] = array(
'#type' => 'textfield',
'#title' => t( 'Path to the Locum Client Library' ),
'#default_value' => variable_get( 'sopac_locum_path', '/usr/local/include/locum' ),
'#size' => 32,
'#maxlength' => 128,
'#description' => t( "The path to where you have installed Locum." . $locum_error ),
'#required' => TRUE,
);
$insurge_path = trim( variable_get( 'sopac_insurge_path', '/usr/local/include/insurge' ) );
if ( $insurge_path[0] != '/' ) {
$insurge_path = '/' . $insurge_path;
}
if ( substr( $insurge_path, -1 ) != '/' ) {
$insurge_path .= '/';
}
if ( !file_exists( $insurge_path . 'insurge-client.php' ) ) {
$insurge_error = '<br /><span style="color: red;">NOTE: ' . $insurge_path . 'insurge-client.php does not seem to exist!</span>' ;
}
$form['sopac_general']['sopac_insurge_path'] = array(
'#type' => 'textfield',
'#title' => t( 'Path to the Insurge Client Library' ),
'#default_value' => variable_get( 'sopac_insurge_path', '/usr/local/include/insurge' ),
'#size' => 32,
'#maxlength' => 128,
'#description' => t( "The path to where you have installed Insurge." . $insurge_error ),
'#required' => TRUE,
);
$form['sopac_general']['sopac_url_prefix'] = array(
'#type' => 'textfield',
'#title' => t( 'SOPAC URL prefix' ),
'#default_value' => variable_get( 'sopac_url_prefix', 'cat/seek' ),
'#size' => 24,
'#maxlength' => 72,
'#description' => t( "This is the URL prefix you wish SOPAC to use within the site, for example, to use www.yoursite.com/cat/seek as the base URL for SOPAC, enter 'cat/seek' without the leading or trailing slash. If you change this, you will likely need to clear your site cache in your " ) . l( t( 'performance settings' ), 'admin/settings/performance' ),
'#required' => TRUE,
);
$form['sopac_general']['sopac_results_per_page'] = array(
'#type' => 'textfield',
'#title' => t( 'Max # of results per page' ),
'#default_value' => variable_get( 'sopac_results_per_page', 20 ),
'#size' => 10,
'#maxlength' => 4,
'#description' => t( "This is the maxumum number of results that will be displayed per page in the catalog hit-list." ),
'#required' => TRUE,
);
$form['sopac_general']['sopac_search_form_cfg'] = array(
'#type' => 'select',
'#title' => t( 'Default Search Form Display' ),
'#default_value' => variable_get( 'sopac_search_form_cfg', 'both' ),
'#description' => t( "This option allows you to configure how you want the search form to be displayed from within the SOPAC context. You can Display Just the basic search box, or the basic search box and the advanced search form drop-down option." ),
'#options' => array( 'basic' => t( 'Display just the basic form' ), 'both' => t( 'Display both basic and advanced forms' ) )
);
$form['sopac_general']['sopac_multi_branch_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable Multi-Branch Support' ),
'#default_value' => variable_get( 'sopac_multi_branch_enable', 0 ),
'#description' => t( 'Select this option if you plan to operate SOPAC in a multi-branch environment.' ),
);
// the next two settings to support giving users ability to select a home branch
$description = t( 'Check this box if your library has multiple branches, and you would like each user to be able to select a home branch.' );
$description .= t( '<br />NOTE: this feature requires that branches are set up in the locum config.' );
$description .= t( '<br />NOTE: the user option will be set up during the first cron job after checking this box.' );
$form['sopac_general']['sopac_home_branch_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Allow Users to Select a Home Branch' ),
'#default_value' => variable_get( 'sopac_home_branch_enable', 0 ),
'#description' => $description,
);
$form['sopac_general']['sopac_ssl_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable SSL for Account Management' ),
'#default_value' => variable_get( 'sopac_ssl_enable', 0 ),
'#description' => t( "Selecting this option will cause SOPAC to redirect browsers to an encrypted page if the user is accesing their personal information. You will need to have SSL enabled on your web server. This is HIGHLY RECCOMENDED. If you enable this option, you must put the following setting in your Apache vhost configuration for this site's <VirtualHost *:443> section: SetEnv HTTPS TRUE" ),
);
$form['sopac_general']['sopac_ssl_port'] = array(
'#type' => 'textfield',
'#title' => t( 'SSL Connection Port' ),
'#default_value' => variable_get( 'sopac_ssl_port', 443 ),
'#size' => 6,
'#maxlength' => 4,
'#description' => t( "This is the port that your Apache SSL process is listening on." ),
'#required' => TRUE,
);
$form['sopac_fines'] = array(
'#type' => 'fieldset',
'#title' => t( 'Fines Settings' ),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['sopac_fines']['sopac_fines_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable Fines Management' ),
'#default_value' => variable_get( 'sopac_fines_enable', 1 ),
'#description' => t( "Check this box to allow users to access their fines through SOPAC." ),
);
$form['sopac_fines']['sopac_payments_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable Payments Management' ),
'#default_value' => variable_get( 'sopac_payments_enable', 1 ),
'#description' => t( "Check this box to allow users to pay their fines through SOPAC." ),
);
$form['sopac_social_features'] = array(
'#type' => 'fieldset',
'#title' => t( 'Social Feature Settings' ),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// This really isn't implemented yet and is here are a reminder
$form['sopac_social_features']['sopac_social_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable the Social Catalog Components' ),
'#default_value' => variable_get( 'sopac_social_enable', 1 ),
'#description' => t( "Check this box if you would like to enable community-driven reviews, ratings, comments, and tagging in the catalog." ),
);
$form['sopac_social_features']['sopac_random_tags'] = array(
'#type' => 'checkbox',
'#title' => t( 'Random Tags' ),
'#default_value' => variable_get( 'sopac_random_tags', 1 ),
'#description' => t( "Check this box if you would like to display tags in random order." ),
);
$form['sopac_social_features']['sopac_tag_limit'] = array(
'#type' => 'textfield',
'#title' => t( 'Tag Limit' ),
'#default_value' => variable_get( 'sopac_tag_limit', 100 ),
'#size' => 6,
'#maxlength' => 5,
'#description' => t( "This is the maximum number of tags to display in the tag cloud." ),
);
$form['sopac_social_features']['sopac_tag_sort'] = array(
'#type' => 'select',
'#title' => t( 'Tag Cloud Sorting' ),
'#default_value' => variable_get( 'sopac_tag_sort', 'ORDER BY count DESC' ),
'#description' => t( "How to sort tags in tag cloud if Random Tags is not checked." ),
'#options' => array(
'ORDER BY count ASC' => t( 'By count, ascending' ),
'ORDER BY count DESC' => t( 'By count, descending' ),
'ORDER BY tag ASC' => t( 'Alphabeticaly, ascending' ),
'ORDER BY tag DESC' => t( 'Alphabeticaly, descending' ),
),
);
$form['sopac_account'] = array(
'#type' => 'fieldset',
'#title' => t( 'Account Page Settings' ),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['sopac_account']['sopac_summary_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable the Account Summary on the Account page' ),
'#default_value' => variable_get( 'sopac_summary_enable', 1 ),
'#description' => t( "Check this box if you would like to enable the Account Summary on the Account page. You probably want this." ),
);
$form['sopac_account']['sopac_pname_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display Patron Name in the Account Summary' ),
'#default_value' => variable_get( 'sopac_pname_enable', 1 ),
'#description' => t( "Check this box if you would like to have patron names appear in the Account Summary." ),
);
$form['sopac_account']['sopac_lcard_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display Library Card Number in the Account Summary' ),
'#default_value' => variable_get( 'sopac_lcard_enable', 1 ),
'#description' => t( "Check this box if you would like to have library card numbers appear in the Account Summary." ),
);
$form['sopac_account']['sopac_numco_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display # of checkouts in the Account Summary' ),
'#default_value' => variable_get( 'sopac_numco_enable', 1 ),
'#description' => t( "Check this box if you would like # of checkouts appear in the Account Summary." ),
);
$form['sopac_account']['sopac_checkout_history_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display checkout history in the user area' ),
'#default_value' => variable_get( 'sopac_checkout_history_enable', 0 ),
'#description' => t( "Check this box if you would like checkout history to appear in the user area." ),
);
$form['sopac_account']['sopac_checkout_history_wipe'] = array(
'#type' => 'checkbox',
'#title' => t( 'Delete checkout history from ILS after harvest' ),
'#default_value' => variable_get( 'sopac_checkout_history_wipe', 1 ),
'#description' => t( "Check this box if you would like to purge checkout history from the ILS after it's imported into SOPAC." ),
);
$form['sopac_account']['sopac_checkout_history_cache_time'] = array(
'#type' => 'textfield',
'#title' => t( 'Checkout history cache time' ),
'#default_value' => variable_get( 'sopac_checkout_history_cache_time', 60 ),
'#description' => t( "How many minutes should SOPAC wait before checking the ILS for checkout history again?" ),
'#size' => 6,
'#maxlength' => 5,
);
$form['sopac_account']['sopac_hold_freezes_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Enable freezing holds' ),
'#default_value' => variable_get( 'sopac_hold_freezes_enable', 1 ),
'#description' => t( "Check this box if you would like users to be able to freeze holds." ),
);
if ( variable_get( 'sopac_fines_enable', 1 ) ) {
$form['sopac_account']['sopac_fines_display'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display Fine Amounts in the Account Summary' ),
'#default_value' => variable_get( 'sopac_fines_display', 1 ),
'#description' => t( "Check this box if you would like fine amounts to appear in the Account Summary." ),
);
}
$form['sopac_account']['sopac_cardexp_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display Library Card Expiration Date in the Account Summary' ),
'#default_value' => variable_get( 'sopac_cardexp_enable', 1 ),
'#description' => t( "Check this box if you would like to have library card expiration dates appear in the Account Summary." ),
);
$form['sopac_account']['sopac_tel_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display telephone # in the Account Summary' ),
'#default_value' => variable_get( 'sopac_tel_enable', 1 ),
'#description' => t( "Check this box if you would like the patron telephone # to appear in the Account Summary." ),
);
$form['sopac_account']['sopac_email_enable'] = array(
'#type' => 'checkbox',
'#title' => t( 'Display Email Address in the Account Summary' ),
'#default_value' => variable_get( 'sopac_email_enable', 1 ),
'#description' => t( "Check this box if you would like the patron email address to appear in the Account Summary." ),
);
$form['sopac_account']['sopac_invalid_cardnum'] = array(
'#type' => 'textarea',
'#title' => t( 'Invalid Library Card Message' ),
'#default_value' => variable_get( 'sopac_invalid_cardnum', 'It appears that your card number is invalid. If you feel that this is in error, please contact us.' ),
'#description' => t( "This is the message that is displayed to users if they have entered an invalid library card number. HTML is OK." ),
'#required' => TRUE,
);
$form['sopac_cardnum_verify'] = array(
'#type' => 'fieldset',
'#title' => t( 'Card Number Verification Requirements' ),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['sopac_cardnum_verify']['sopac_require_cfg'] = array(
'#type' => 'select',
'#title' => t( 'Require Patrons to Meet All or One of the Requirements' ),
'#default_value' => variable_get( 'sopac_require_cfg', 'one' ),
'#description' => t( "This option allows you to tell SOPAC if you would like to require users to fulfill all of the following enabled requirements, or just one. For example, if this is set to just 'One', users would have to enter one correct value instead of all corect values in order to have their library card verified." ),
'#options' => array( 'one' => t( 'Just One' ), 'all' => t( 'All Requirements' ) )
);
$form['sopac_cardnum_verify']['sopac_require_name'] = array(
'#type' => 'checkbox',
'#title' => t( 'Require Patron name for Verification' ),
'#default_value' => variable_get( 'sopac_require_name', 1 ),
'#description' => t( "Check this box if you would like to require the patron to type in their name in order to verify their library card number." ),
);
$form['sopac_cardnum_verify']['sopac_require_tel'] = array(
'#type' => 'checkbox',
'#title' => t( 'Require Telephone Number for Verification' ),
'#default_value' => variable_get( 'sopac_require_tel', 1 ),
'#description' => t( "Check this box if you would like to require the patron to type in their telephone number in order to verify their library card number." ),
);
$form['sopac_cardnum_verify']['sopac_require_streetname'] = array(
'#type' => 'checkbox',
'#title' => t( 'Use Address Street Name for Verification' ),
'#default_value' => variable_get( 'sopac_require_streetname', 1 ),
'#description' => t( "Check this box if you would like to use the street name of the patron's address to verify their library card number." ),
);
$form['sopac_cardnum_verify']['sopac_uv_cardnum'] = array(
'#type' => 'textarea',
'#title' => t( 'Unvalidated Library Card Message' ),
'#default_value' => variable_get( 'sopac_uv_cardnum', 'The card number you have provided has not yet been verified by you. In order to make sure that you are the rightful owner of this library card number, we need to ask you some simple questions.' ),
'#description' => t( "This is the message that is displayed to users on their account page if they have not yet verified their library card number. HTML is OK." ),
'#required' => TRUE,
);
if ( $current_ils == 'sirsi' ) {
$form['core']['sopac_changeable_pickup_location'] = array(
'#type' => 'hidden',
'#value' => TRUE,
);
$form['core']['sopac_suspend_holds'] = array(
'#type' => 'hidden',
'#value' => TRUE,
);
}
else {
$form['core']['sopac_changeable_pickup_location'] = array(
'#type' => 'hidden',
'#value' => FALSE,
);
$form['core']['sopac_suspend_holds'] = array(
'#type' => 'hidden',
'#value' => FALSE,
);
}
// This will call sopac_admin_submit() to clear menu cache
$form = system_settings_form( $form );
$form['#submit'][] = 'sopac_admin_submit';
// Return the SOPAC configuration form
return $form;
}
// Part of supporting user home branch in multibranch situation
function sopac_setup_user_home_selector() {
if ( !variable_get( 'sopac_home_branch_enable', 0 ) || variable_get( 'sopac_home_selector_options', FALSE ) ) {
return FALSE;
}
$locum = sopac_get_locum();
$branches = $locum->locum_config['branches'];
if ( !( is_array( $branches ) && count( $branches ) ) ) {
return FALSE;
}
$options = array_values( $branches );
$options = join( "\n\r", $options );
$description = t( 'Choose a branch as your home. This will be the default pickup location when you place holds.' );
$result = db_query( "
INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page)
VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')",
'Home Branch', 'profile_pref_home_branch', $description, 'Preferences', 'selection', 1, 0, 1, 1, 0, $options, ''
);
if ( $result ) {
variable_set( 'sopac_home_selector_options', TRUE );
return TRUE;
}
return FALSE;
}
// Rebuild menu cache
function sopac_admin_submit( $form, &$form_state ) {
menu_rebuild();
}