forked from sbromle/RefBase-Fork
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser_options.php
More file actions
829 lines (686 loc) · 31 KB
/
user_options.php
File metadata and controls
829 lines (686 loc) · 31 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
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
<?php
// Project: Web Reference Database (refbase) <http://www.refbase.net>
// Copyright: Matthias Steffens <mailto:refbase@extracts.de> and the file's
// original author(s).
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY. Please see the GNU General Public
// License for more details.
//
// File: ./user_options.php
// Repository: $HeadURL$
// Author(s): Matthias Steffens <mailto:refbase@extracts.de>
//
// Created: 24-Oct-04, 19:31
// Modified: $Date$
// $Author$
// $Revision$
// This script provides options which are individual for each user.
//
// TODO: - I18n, more encodeHTML fixes?
// Incorporate some include files:
include 'initialize/db.inc.php'; // 'db.inc.php' is included to hide username and password
include 'includes/header.inc.php'; // include header
include 'includes/footer.inc.php'; // include footer
include 'includes/include.inc.php'; // include common functions
include 'initialize/ini.inc.php'; // include common variables
// --------------------------------------------------------------------
// START A SESSION:
// call the 'start_session()' function (from 'include.inc.php') which will also read out available session variables:
start_session(true);
// --------------------------------------------------------------------
// Initialize preferred display language:
// (note that 'locales.inc.php' has to be included *after* the call to the 'start_session()' function)
include 'includes/locales.inc.php'; // include the locales
// --------------------------------------------------------------------
// Extract session variables (only necessary if register globals is OFF!):
if (isset($_SESSION['errors']))
$errors = $_SESSION['errors'];
else
$errors = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages)
if (isset($_SESSION['formVars']))
$formVars = $_SESSION['formVars'];
else
$formVars = array(); // initialize variable (in order to prevent 'Undefined index/variable...' messages)
// The current values of the session variables 'errors' and 'formVars' get stored in '$errors' or '$formVars', respectively. (either automatically if
// register globals is ON, or explicitly if register globals is OFF).
// We need to clear these session variables here, since they would otherwise be there even if 'user_options.php' gets called with a different userID!
// Note: though we clear the session variables, the current error message (or form variables) is still available to this script via '$errors' (or '$formVars', respectively).
deleteSessionVariable("errors"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
deleteSessionVariable("formVars");
// --------------------------------------------------------------------
// (1) OPEN CONNECTION, (2) SELECT DATABASE
connectToMySQLDatabase(); // function 'connectToMySQLDatabase()' is defined in 'include.inc.php'
// --------------------------------------------------------------------
// A user must be logged in in order to call 'user_options.php':
if (!isset($_SESSION['loginEmail']))
{
// save an error message:
$HeaderString = "<b><span class=\"warning\">You must login to view your user account options!</span></b>";
// save the URL of the currently displayed page:
$referer = $_SERVER['HTTP_REFERER'];
// Write back session variables:
saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
saveSessionVariable("referer", $referer);
header("Location: user_login.php");
exit;
}
// --------------------------------------------------------------------
// Set the '$userID' variable:
if (isset($_REQUEST['userID']) AND preg_match("/^[0-9]+$/", $_REQUEST['userID'])) // for normal users NOT being logged in -OR- for the admin:
$userID = $_REQUEST['userID'];
else
$userID = NULL; // '$userID = ""' wouldn't be correct here, since then any later 'isset($userID)' statement would resolve to true!
if (isset($_SESSION['loginEmail']) && ($loginEmail != $adminLoginEmail)) // a normal user IS logged in ('$adminLoginEmail' is specified in 'ini.inc.php')
// Check this user matches the userID (viewing and modifying other user's account options is only allowed to the admin)
if ($userID != getUserID($loginEmail)) // (function 'getUserID()' is defined in 'include.inc.php')
{
// save an error message:
$HeaderString = "<b><span class=\"warning\">You can only edit your own user data!</span></b>";
// Write back session variables:
saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
$userID = getUserID($loginEmail); // re-establish the user's correct user_id
}
// --------------------------------------------------------------------
// Check the correct parameters have been passed
if ($userID == "") // note that we can't use 'empty($userID)' here, since 'userID=0' must be allowed so that the admin can edit options for the default user (= no user logged in)
{
// save an error message:
$HeaderString = "<b><span class=\"warning\">Missing parameters for script 'user_options.php'!</span></b>";
// Write back session variables:
saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
// Redirect the browser back to the calling page
header("Location: " . $referer); // variable '$referer' is globally defined in function 'start_session()' in 'include.inc.php'
exit;
}
// --------------------------------------------------------------------
// Check if the logged-in user is allowed to modify his account options:
if (isset($_SESSION['loginEmail']) AND preg_match("/^\d+$/", $userID) AND isset($_SESSION['user_permissions']) AND !preg_match("/allow_modify_options/", $_SESSION['user_permissions'])) // if a user is logged in but the 'user_permissions' session variable does NOT contain 'allow_modify_options'...
{
// save an error message:
$HeaderString = "<b><span class=\"warning\">You have no permission to modify your user account options!</span></b>";
// Write back session variables:
saveSessionVariable("HeaderString", $HeaderString); // function 'saveSessionVariable()' is defined in 'include.inc.php'
// Redirect the browser back to the calling page
header("Location: " . $referer);
exit;
}
// --------------------------------------------------------------------
// Set header message:
if (!isset($_SESSION['HeaderString'])) // if there's no stored message available
{
if (empty($errors)) // provide the default messages:
$HeaderString = "Modify your account options:";
else // -> there were errors validating the user's options
$HeaderString = "<b><span class=\"warning\">There were validation errors regarding the options you selected. Please check the comments above the respective fields:</span></b>";
}
else
{
$HeaderString = $_SESSION['HeaderString']; // extract 'HeaderString' session variable (only necessary if register globals is OFF!)
// Note: though we clear the session variable, the current message is still available to this script via '$HeaderString':
deleteSessionVariable("HeaderString"); // function 'deleteSessionVariable()' is defined in 'include.inc.php'
}
// Extract the view type requested by the user (either 'Mobile', 'Print', 'Web' or ''):
// ('' will produce the default 'Web' output style)
if (isset($_REQUEST['viewType']))
$viewType = $_REQUEST['viewType'];
else
$viewType = "";
// CONSTRUCT SQL QUERY:
$query = "SELECT first_name, last_name, email, language FROM $tableUsers WHERE user_id = " . quote_smart($userID);
// (3a) RUN the query on the database through the connection:
$result = queryMySQLDatabase($query); // function 'queryMySQLDatabase()' is defined in 'include.inc.php'
// (3b) EXTRACT results:
$row = mysql_fetch_array($result); // fetch the current row into the array $row
// If the admin is logged in AND the displayed user data are NOT his own, we overwrite the default header message:
// (Since the admin is allowed to view and edit account data from other users, we have to provide a dynamic header message in that case)
if (($loginEmail == $adminLoginEmail) && (!empty($userID)) && ($userID != getUserID($loginEmail))) // ('$adminLoginEmail' is specified in 'ini.inc.php')
$HeaderString = "Edit account options for <b>" . encodeHTML($row["first_name"]) . " " . encodeHTML($row["last_name"]) . " (" . $row["email"] . ")</b>:";
elseif (empty($userID))
$HeaderString = "Edit account options for anyone who isn't logged in:";
// Show the login status:
showLogin(); // (function 'showLogin()' is defined in 'include.inc.php')
// (4) DISPLAY header:
// call the 'displayHTMLhead()' and 'showPageHeader()' functions (which are defined in 'header.inc.php'):
displayHTMLhead(encodeHTML($officialDatabaseName) . " -- User Options", "noindex,nofollow", "User options offered by the " . encodeHTML($officialDatabaseName), "\n\t<meta http-equiv=\"expires\" content=\"0\">", true, "", $viewType, array());
showPageHeader($HeaderString);
// --------------------------------------------------------------------
if (empty($errors))
{
// Reset the '$formVars' variable (since we're loading from the user tables):
$formVars = array();
// Reset the '$errors' variable:
$errors = array();
// Load all the form variables with user data & options:
$formVars["language"] = $row["language"];
}
// Initialize variables which will set form elements according to the current user's options:
// Get all user options for the current user:
$userOptionsArray = getUserOptions($userID); // function 'getUserOptions()' is defined in 'include.inc.php'
// Display Options:
if (!empty($userID))
{
// Get all languages that were setup and enabled by the admin:
$languagesArray = getLanguages(""); // function 'getLanguages()' is defined in 'include.inc.php'
$fieldDisabled = "";
}
else // if '$userID == 0' which indicates a user not being logged in
{
$languagesArray = array($defaultLanguage); // for a user who's not logged in, we fall back to the default language (defined in 'ini.inc.php')
$fieldDisabled = " disabled"; // disable some fields if the user isn't logged in (in which case the display language, no. of records per page, show auto-completions & the "main fields" search option will be taken from global variables in 'ini.inc.php')
}
$languageOptionTags = buildSelectMenuOptions($languagesArray, " *; *", "\t\t\t", false); // build properly formatted <option> tag elements from language items returned by function 'getLanguages()'
$userLanguage = getLanguages($userID); // get the preferred language for the current user
$languageOptionTags = preg_replace("/<option>$userLanguage[0]/", "<option selected>$userLanguage[0]", $languageOptionTags); // select the user's preferred language
// Get the default number of records per page preferred by the current user:
// 'records_per_page' option:
$recordsPerPage = getDefaultNumberOfRecords($userID); // function 'getDefaultNumberOfRecords()' is defined in 'include.inc.php'
// Get the user's preference for displaying auto-completions:
// 'show_auto_completions' option:
$showAutoCompletions = getPrefAutoCompletions($userID); // function 'getPrefAutoCompletions()' is defined in 'include.inc.php'
if ($showAutoCompletions == "yes")
{
$showAutoCompletionsChecked = " checked";
$dontShowAutoCompletionsChecked = "";
}
else
{
$showAutoCompletionsChecked = "";
$dontShowAutoCompletionsChecked = " checked";
}
// Get all reference types that are available (admin logged in) or which were enabled for the current user (normal user logged in):
$typeOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "type", ""); // function 'returnFormatsStylesTypesAsOptionTags()' is defined in 'include.inc.php'
// Get all citation styles that are available (admin logged in) or which were enabled for the current user (normal user logged in):
$styleOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "style", "");
// Get all citation formats that are available (admin logged in) or which were enabled for the current user (normal user logged in):
$citeFormatOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "format", "cite");
// Get all export formats that are available (admin logged in) or which were enabled for the current user (normal user logged in):
$exportFormatOptionTags = returnFormatsStylesTypesAsOptionTags($userID, "format", "export");
if ($loginEmail == $adminLoginEmail) // if the admin is logged in
$selectListIdentifier = "Enabled";
else // if ($loginEmail != $adminLoginEmail) // if a normal user is logged in
$selectListIdentifier = "Show";
// Map MySQL field names to localized column names:
$fieldNamesArray = mapFieldNames(true); // function 'mapFieldNames()' is defined in 'include.inc.php'
$mainFieldsArray = array();
// Define fields that can be designated as "main fields":
foreach ($availableMainFields as $field) // variable '$availableMainFields' is defined in 'ini.inc.php'
if (isset($fieldNamesArray[$field]))
$mainFieldsArray[$field] = $fieldNamesArray[$field];
// Build properly formatted <option> tag elements from array items given in '$mainFieldsArray':
$mainFieldsOptionTags = buildSelectMenuOptions($mainFieldsArray, "", "\t\t\t", true); // function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
// Get the list of "main fields" preferred by the current user:
// 'main_fields' option:
$userMainFieldsArray = getMainFields($userID);
// select all fields that shall be searched when the "main fields" search option is chosen:
// (these fields will also be included as separate entries in the "Quick Search drop-down menu)
foreach($userMainFieldsArray as $userMainField)
$mainFieldsOptionTags = preg_replace("/<option([^>]*)>" . $mainFieldsArray[$userMainField] . "<\/option>/", "<option\\1 selected>" . $mainFieldsArray[$userMainField] . "</option>", $mainFieldsOptionTags);
// Cite Options:
// 'use_custom_text_citation_format' option:
if (!empty($userOptionsArray) AND ($userOptionsArray['use_custom_text_citation_format'] == "yes"))
$useCustomTextCitationFormatChecked = " checked";
else
$useCustomTextCitationFormatChecked = "";
// 'text_citation_format' option:
if (!empty($userOptionsArray['text_citation_format']))
$textCitationFormat = $userOptionsArray['text_citation_format'];
else
$textCitationFormat = "";
// Export Options:
// 'export_cite_keys' option:
if (!empty($userOptionsArray) AND ($userOptionsArray['export_cite_keys'] == "yes"))
$exportCiteKeysChecked = " checked";
else
$exportCiteKeysChecked = "";
// 'autogenerate_cite_keys' option:
if (!empty($userOptionsArray) AND ($userOptionsArray['autogenerate_cite_keys'] == "yes"))
$autogenerateCiteKeysChecked = " checked";
else
$autogenerateCiteKeysChecked = "";
// 'prefer_autogenerated_cite_keys' option:
if (!empty($userOptionsArray) AND ($userOptionsArray['prefer_autogenerated_cite_keys'] == "yes"))
{
$preferAutogeneratedCiteKeysChecked = " checked";
$dontPreferAutogeneratedCiteKeysChecked = "";
}
else
{
$preferAutogeneratedCiteKeysChecked = "";
$dontPreferAutogeneratedCiteKeysChecked = " checked";
}
// 'use_custom_cite_key_format' option:
if (!empty($userOptionsArray) AND ($userOptionsArray['use_custom_cite_key_format'] == "yes"))
$useCustomCiteKeyFormatChecked = " checked";
else
$useCustomCiteKeyFormatChecked = "";
// 'cite_key_format' option:
if (!empty($userOptionsArray['cite_key_format']))
$citeKeyFormat = $userOptionsArray['cite_key_format'];
else
$citeKeyFormat = "";
// 'uniquify_duplicate_cite_keys' option:
if (!empty($userOptionsArray) AND ($userOptionsArray['uniquify_duplicate_cite_keys'] == "yes"))
$uniquifyDuplicateCiteKeysChecked = " checked";
else
$uniquifyDuplicateCiteKeysChecked = "";
// define variable holding drop-down elements:
$dropDownItemArray = array("transliterate" => "transliterate",
"strip" => "strip",
"keep" => "keep");
// build properly formatted <option> tag elements from array items given in '$dropDownItemArray':
$nonASCIICharsInCiteKeysOptionTags = buildSelectMenuOptions($dropDownItemArray, "", "\t\t\t", true); // function 'buildSelectMenuOptions()' is defined in 'include.inc.php'
// 'nonascii_chars_in_cite_keys' option:
if (!empty($userOptionsArray['nonascii_chars_in_cite_keys']))
{
$useCustomHandlingOfNonASCIICharsInCiteKeysChecked = " checked";
// select the drop down option chosen by the current user:
$nonASCIICharsInCiteKeysOptionTags = preg_replace("/<option([^>]*)>" . $userOptionsArray['nonascii_chars_in_cite_keys'] . "/", "<option\\1 selected>" . $userOptionsArray['nonascii_chars_in_cite_keys'], $nonASCIICharsInCiteKeysOptionTags);
}
else
$useCustomHandlingOfNonASCIICharsInCiteKeysChecked = "";
// Start <form> and <table> holding all the form elements:
?>
<form method="POST" action="user_options_modify.php" name="userOptions">
<input type="hidden" name="userID" value="<?php echo encodeHTML($userID) ?>">
<table align="center" border="0" cellpadding="0" cellspacing="10" width="95%" summary="This table holds a form with user options">
<tr>
<td align="left" width="169"><b><a id="display">Display Options:</a></b></td>
<td align="left" width="169">Use language:</td>
<td><?php echo fieldError("languageName", $errors); ?>
<select name="languageName"<?php echo $fieldDisabled; ?>><?php echo $languageOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left">Show records per page:</td>
<td><?php echo fieldError("recordsPerPageNo", $errors); ?>
<input type="text" name="recordsPerPageNo" value="<?php echo encodeHTML($recordsPerPage); ?>" size="5"<?php echo $fieldDisabled; ?>>
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left">Show auto-completions:</td>
<td>
<input type="radio" name="showAutoCompletionsRadio" value="yes"<?php echo $showAutoCompletionsChecked . $fieldDisabled; ?>> yes
<input type="radio" name="showAutoCompletionsRadio" value="no"<?php echo $dontShowAutoCompletionsChecked . $fieldDisabled; ?>> no
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left" valign="top"><?php echo $selectListIdentifier; ?> reference types:</td>
<td valign="top"><?php echo fieldError("referenceTypeSelector", $errors); ?>
<select name="referenceTypeSelector[]" multiple><?php echo $typeOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left" valign="top"><?php echo $selectListIdentifier; ?> citation styles:</td>
<td valign="top"><?php echo fieldError("citationStyleSelector", $errors); ?>
<select name="citationStyleSelector[]" multiple><?php echo $styleOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left" valign="top"><?php echo $selectListIdentifier; ?> citation formats:</td>
<td valign="top"><?php echo fieldError("citationFormatSelector", $errors); ?>
<select name="citationFormatSelector[]" multiple><?php echo $citeFormatOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left" valign="top"><?php echo $selectListIdentifier; ?> export formats:</td>
<td valign="top"><?php echo fieldError("exportFormatSelector", $errors); ?>
<select name="exportFormatSelector[]" multiple><?php echo $exportFormatOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td align="left" valign="top">"Main fields" searches:</td>
<td valign="top"><?php echo fieldError("mainFieldsSelector", $errors); ?>
<select name="mainFieldsSelector[]" multiple<?php echo $fieldDisabled; ?>><?php echo $mainFieldsOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="submit" value="Submit">
</td>
</tr>
<tr>
<td align="left" height="15"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"><b><a id="cite">Cite Options:</a></b></td>
<td colspan="2">
<input type="checkbox" name="use_custom_text_citation_format" value="yes"<?php echo $useCustomTextCitationFormatChecked; ?>> Use custom text citation format:
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="text" name="text_citation_format" value="<?php echo encodeHTML($textCitationFormat); ?>" size="46">
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="submit" value="Submit">
</td>
</tr>
<tr>
<td align="left" height="15"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"><b><a id="export">Import/Export Options:</a></b></td>
<td colspan="2">
<input type="checkbox" name="export_cite_keys" value="yes"<?php echo $exportCiteKeysChecked; ?>> Include or generate cite keys
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="checkbox" name="autogenerate_cite_keys" value="yes"<?php echo $autogenerateCiteKeysChecked; ?>> Auto-generate cite keys for:
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="radio" name="prefer_autogenerated_cite_keys" value="yes"<?php echo $preferAutogeneratedCiteKeysChecked; ?>> all records
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="radio" name="prefer_autogenerated_cite_keys" value="no"<?php echo $dontPreferAutogeneratedCiteKeysChecked; ?>> records with empty 'Cite Key' (ID) field
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="checkbox" name="use_custom_cite_key_format" value="yes"<?php echo $useCustomCiteKeyFormatChecked; ?>> Use custom format for auto-generated cite keys:
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="text" name="cite_key_format" value="<?php echo encodeHTML($citeKeyFormat); ?>" size="46">
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="checkbox" name="use_custom_handling_of_nonascii_chars_in_cite_keys" value="yes"<?php echo $useCustomHandlingOfNonASCIICharsInCiteKeysChecked; ?>> Use custom handling of non-ASCII characters in cite keys:
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<select name="nonascii_chars_in_cite_keys"><?php echo $nonASCIICharsInCiteKeysOptionTags; ?>
</select>
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="checkbox" name="uniquify_duplicate_cite_keys" value="yes"<?php echo $uniquifyDuplicateCiteKeysChecked; ?>> Append incrementing numbers to duplicate cite keys
</td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="submit" value="Submit">
</td>
</tr><?php
if ($loginEmail == $adminLoginEmail) // if the admin is logged in, add form elements to set the user's permissions:
{
// Get the user permissions for the current user:
$userPermissionsArray = getPermissions($userID, "user", false); // function 'getPermissions()' is defined in 'include.inc.php'
// Setup variables to mark the checkboxes according to the user's permissions:
if ($userPermissionsArray['allow_add'] == 'yes')
$allowAddChecked = " checked";
else
$allowAddChecked = "";
if ($userPermissionsArray['allow_edit'] == 'yes')
$allowEditChecked = " checked";
else
$allowEditChecked = "";
if ($userPermissionsArray['allow_delete'] == 'yes')
$allowDeleteChecked = " checked";
else
$allowDeleteChecked = "";
if ($userPermissionsArray['allow_download'] == 'yes')
$allowDownloadChecked = " checked";
else
$allowDownloadChecked = "";
if ($userPermissionsArray['allow_upload'] == 'yes')
$allowUploadChecked = " checked";
else
$allowUploadChecked = "";
if ($userPermissionsArray['allow_list_view'] == 'yes')
$allowListViewChecked = " checked";
else
$allowListViewChecked = "";
if ($userPermissionsArray['allow_details_view'] == 'yes')
$allowDetailsViewChecked = " checked";
else
$allowDetailsViewChecked = "";
if ($userPermissionsArray['allow_print_view'] == 'yes')
$allowPrintViewChecked = " checked";
else
$allowPrintViewChecked = "";
if ($userPermissionsArray['allow_browse_view'] == 'yes') // 'Browse view' isn't presented as visible option yet
$allowBrowseViewChecked = " checked";
else
$allowBrowseViewChecked = "";
if ($userPermissionsArray['allow_sql_search'] == 'yes')
$allowSQLSearchChecked = " checked";
else
$allowSQLSearchChecked = "";
if ($userPermissionsArray['allow_user_groups'] == 'yes')
$allowUserGroupsChecked = " checked";
else
$allowUserGroupsChecked = "";
if ($userPermissionsArray['allow_user_queries'] == 'yes')
$allowUserQueriesChecked = " checked";
else
$allowUserQueriesChecked = "";
if ($userPermissionsArray['allow_rss_feeds'] == 'yes')
$allowRSSFeedsChecked = " checked";
else
$allowRSSFeedsChecked = "";
if ($userPermissionsArray['allow_import'] == 'yes')
$allowImportChecked = " checked";
else
$allowImportChecked = "";
if ($userPermissionsArray['allow_batch_import'] == 'yes')
$allowBatchImportChecked = " checked";
else
$allowBatchImportChecked = "";
if ($userPermissionsArray['allow_export'] == 'yes')
$allowExportChecked = " checked";
else
$allowExportChecked = "";
if ($userPermissionsArray['allow_batch_export'] == 'yes')
$allowBatchExportChecked = " checked";
else
$allowBatchExportChecked = "";
if ($userPermissionsArray['allow_cite'] == 'yes')
$allowCiteChecked = " checked";
else
$allowCiteChecked = "";
if ($userPermissionsArray['allow_modify_options'] == 'yes')
$allowChangePersonInfoChecked = " checked";
else
$allowChangePersonInfoChecked = "";
?>
<tr>
<td align="left" height="15"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"><b><a id="permissions">User Permissions:</a></b></td>
<td>
<input type="checkbox" name="allow_add" value="yes"<?php echo $allowAddChecked; ?>> <?php echo $loc['UserPermission_AllowAdd']; ?>
</td>
<td>
<input type="checkbox" name="allow_download" value="yes"<?php echo $allowDownloadChecked; ?>> <?php echo $loc['UserPermission_AllowDownload']; ?>
</td>
</tr>
<tr>
<td align="left" class="small">
<!--<a href="JavaScript:checkall(true,'allow*')" title="select all permission options">Select All</a> -->
<!--<a href="JavaScript:checkall(false,'allow*')" title="deselect all permission options">Deselect All</a>-->
</td>
<td>
<input type="checkbox" name="allow_edit" value="yes"<?php echo $allowEditChecked; ?>> <?php echo $loc['UserPermission_AllowEdit']; ?>
</td>
<td>
<input type="checkbox" name="allow_upload" value="yes"<?php echo $allowUploadChecked; ?>> <?php echo $loc['UserPermission_AllowUpload']; ?>
</td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_delete" value="yes"<?php echo $allowDeleteChecked; ?>> <?php echo $loc['UserPermission_AllowDelete']; ?>
</td>
<td></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_list_view" value="yes"<?php echo $allowListViewChecked; ?>> <?php echo $loc['UserPermission_AllowListView']; ?>
</td>
<td>
<input type="checkbox" name="allow_print_view" value="yes"<?php echo $allowPrintViewChecked; ?>> <?php echo $loc['UserPermission_AllowPrintView']; ?>
</td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_details_view" value="yes"<?php echo $allowDetailsViewChecked; ?>> <?php echo $loc['UserPermission_AllowDetailsView']; ?>
</td>
<td></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_sql_search" value="yes"<?php echo $allowSQLSearchChecked; ?>> <?php echo $loc['UserPermission_AllowSQLSearch']; ?>
</td>
<td></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_user_groups" value="yes"<?php echo $allowUserGroupsChecked; ?>> <?php echo $loc['UserPermission_AllowUserGroups']; ?>
</td>
<td>
<input type="checkbox" name="allow_rss_feeds" value="yes"<?php echo $allowRSSFeedsChecked; ?>> <?php echo $loc['UserPermission_AllowRSSFeeds']; ?>
</td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_user_queries" value="yes"<?php echo $allowUserQueriesChecked; ?>> <?php echo $loc['UserPermission_AllowUserQueries']; ?>
</td>
<td></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_import" value="yes"<?php echo $allowImportChecked; ?>> <?php echo $loc['UserPermission_AllowImport']; ?>
</td>
<td>
<input type="checkbox" name="allow_batch_import" value="yes"<?php echo $allowBatchImportChecked; ?>> <?php echo $loc['UserPermission_AllowBatchImport']; ?>
</td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_export" value="yes"<?php echo $allowExportChecked; ?>> <?php echo $loc['UserPermission_AllowExport']; ?>
</td>
<td>
<input type="checkbox" name="allow_batch_export" value="yes"<?php echo $allowBatchExportChecked; ?>> <?php echo $loc['UserPermission_AllowBatchExport']; ?>
</td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_cite" value="yes"<?php echo $allowCiteChecked; ?>> <?php echo $loc['UserPermission_AllowCite']; ?>
</td>
<td></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td>
<input type="checkbox" name="allow_modify_options" value="yes"<?php echo $allowChangePersonInfoChecked; ?>> <?php echo $loc['UserPermission_AllowModifyOptions']; ?>
</td>
<td></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2"></td>
</tr>
<tr>
<td align="left"></td>
<td colspan="2">
<input type="submit" value="Submit">
</td>
</tr><?php
}
?>
</table>
</form><?php
// --------------------------------------------------------------------
// (5) CLOSE the database connection:
disconnectFromMySQLDatabase(); // function 'disconnectFromMySQLDatabase()' is defined in 'include.inc.php'
// SHOW ERROR IN RED:
function fieldError($fieldName, $errors)
{
if (isset($errors[$fieldName]))
echo "\n\t\t<b><span class=\"warning\">" . $errors[$fieldName] . "</span></b>\n\t\t<br>";
}
// --------------------------------------------------------------------
// DISPLAY THE HTML FOOTER:
// call the 'showPageFooter()' and 'displayHTMLfoot()' functions (which are defined in 'footer.inc.php')
showPageFooter($HeaderString);
displayHTMLfoot();
// --------------------------------------------------------------------
?>