-
Notifications
You must be signed in to change notification settings - Fork 7
/
sel_auth.php
161 lines (122 loc) · 4.66 KB
/
sel_auth.php
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
<?php
/*
This file is part of the Legal Case Management System (LCM).
(C) 2004-2005 Free Software Foundation, Inc.
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 2 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 this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
$Id: sel_auth.php,v 1.12 2006/02/20 03:25:03 mlutfy Exp $
*/
include('inc/inc.php');
include_lcm('inc_acc');
global $prefs;
$case = intval($_REQUEST['case']);
if (! ($case > 0)) {
lcm_page_start(_T('title_error'));
echo "<p>" . _T('error_no_case_specified') . "</p>\n";
lcm_page_end();
exit;
}
$destination = "case_det.php?id_case=" . $case;
if (isset($_SERVER['HTTP_REFERER']))
$destination = $_SERVER['HTTP_REFERER'];
$dest_link = new Link($destination);
if (! allowed($case,'a'))
die("You don't have permission to add users to this case!");
$q = "SELECT *
FROM lcm_case_author
WHERE id_case=$case";
$result = lcm_query($q);
$q = "SELECT id_author, name_first, name_middle, name_last, status
FROM lcm_author
WHERE id_author NOT IN (0";
// Add clients to NOT IN list
while ($row = lcm_fetch_array($result)) {
$q .= ',' . $row['id_author'];
}
$q .= ')';
// Add search criteria if any
if (isset($_REQUEST['find_author_string']) && strlen($_REQUEST['find_author_string']) > 1) {
$find_author_string = $_REQUEST['find_author_string'];
$q .= " AND ((name_first LIKE '%$find_author_string%')"
. " OR (name_middle LIKE '%$find_author_string%')"
. " OR (name_last LIKE '%$find_author_string%'))";
} else {
$find_author_string = "";
}
// Sort authors by status
$order_set = false;
$order_status = '';
if (isset($_REQUEST['order_status']))
if ($_REQUEST['order_status'] == 'ASC' || $_REQUEST['order_status'] == 'DESC') {
$order_status = $_REQUEST['order_status'];
$q .= " ORDER BY status " . $order_status;
$order_set = true;
}
// Sort by name_first
$order_name = 'ASC';
if (isset($_REQUEST['order_name']))
if ($_REQUEST['order_name'] == 'ASC' || $_REQUEST['order_name'] == 'DESC')
$order_name = $_REQUEST['order_name'];
$q .= ($order_set ? " , " : " ORDER BY ");
$q .= " name_first " . $order_name;
$result = lcm_query($q);
$number_of_rows = lcm_num_rows($result);
// Check for correct start position of the list
$list_pos = 0;
if (isset($_REQUEST['list_pos']))
$list_pos = $_REQUEST['list_pos'];
if ($list_pos >= $number_of_rows)
$list_pos = 0;
// Position to the page info start
if ($list_pos > 0)
if (!lcm_data_seek($result,$list_pos))
lcm_panic("Error seeking position $list_pos in the result");
// Check if any author(s) available for selection
if ($find_author_string || lcm_num_rows($result) > 0)
lcm_page_start(_T('title_case_add_author'), '', '', 'cases_participants');
else {
// TODO: add $_SESSION['errors']['generic'] message?
header('Location: ' . $dest_link->getUrlForHeader());
exit;
}
show_context_start();
show_context_case_title($case);
show_context_case_involving($case);
show_context_end();
show_find_box('author', $find_author_string, '__self__');
echo '<form action="add_auth.php" method="post">' . "\n";
$headers = array();
$headers[0]['title'] = '';
$headers[0]['order'] = 'no_order';
$headers[1]['title'] = _Th('person_input_name');
$headers[1]['order'] = 'order_name';
$headers[2]['title'] = _Th('authoredit_input_status');
$headers[2]['order'] = 'order_status';
show_list_start($headers);
for ($i = 0; (($i < $prefs['page_rows']) && ($row = lcm_fetch_array($result))) ; $i++) {
echo "<tr>\n";
echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">';
echo '<input type="checkbox" name="authors[]" value="' . $row['id_author'] . '" />';
echo "</td>\n";
echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . get_person_name($row) . "</td>\n";
echo '<td class="tbl_cont_' . ($i % 2 ? "dark" : "light") . '">' . _T('authoredit_input_status_' . $row['status']) . "</td>\n";
echo "</tr>\n";
}
show_list_end($list_pos, $number_of_rows);
?>
<input type="hidden" name="case" value="<?php echo $case; ?>" />
<input type="hidden" name="ref_sel_auth" value="<?php echo $dest_link->getUrl(); ?>" />
<button name="submit" type="submit" value="submit" class="simple_form_btn"><?php echo _T('button_validate'); ?></button>
</form>
<?php
lcm_page_end();
?>