1 | <?php
|
---|
2 | /*
|
---|
3 | $Id: usergroup_edit.php 2296 2009-08-24 09:44:14Z andrewsimpson $
|
---|
4 |
|
---|
5 | (c) 2002 - 2009 Andrew Simpson <andrew.simpson at paradise.net.nz>
|
---|
6 |
|
---|
7 | WebCollab
|
---|
8 | ---------------------------------------
|
---|
9 |
|
---|
10 | This program is free software; you can redistribute it and/or modify it under the
|
---|
11 | terms of the GNU General Public License as published by the Free Software Foundation;
|
---|
12 | either version 2 of the License, or (at your option) any later version.
|
---|
13 |
|
---|
14 | This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
---|
15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
---|
16 | PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
---|
17 |
|
---|
18 | You should have received a copy of the GNU General Public License along with this
|
---|
19 | program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
|
---|
20 | Cambridge, MA 02139, USA.
|
---|
21 |
|
---|
22 | Function:
|
---|
23 | ---------
|
---|
24 |
|
---|
25 | Edit usergroups
|
---|
26 |
|
---|
27 | */
|
---|
28 |
|
---|
29 | //security check
|
---|
30 | if(! defined('UID' ) ) {
|
---|
31 | die('Direct file access not permitted' );
|
---|
32 | }
|
---|
33 |
|
---|
34 | //admins only
|
---|
35 | if( ! ADMIN ) {
|
---|
36 | error('Unauthorised access', 'This function is for admins only.' );
|
---|
37 | }
|
---|
38 |
|
---|
39 | //secure vars
|
---|
40 | $content = '';
|
---|
41 | $member_array = array();
|
---|
42 |
|
---|
43 | //secure input
|
---|
44 | if(! @safe_integer($_GET['usergroupid'] ) ) {
|
---|
45 | error('Usergroup edit', 'Not a valid value for usergroupid.' );
|
---|
46 | }
|
---|
47 | $usergroupid = $_GET['usergroupid'];
|
---|
48 |
|
---|
49 | //get usergroup information
|
---|
50 | if(! ($q = db_query('SELECT * FROM '.PRE.'usergroups WHERE id='.$usergroupid, 0 ) ) ) {
|
---|
51 | error('Usergroup edit', 'There was an error in the data query.' );
|
---|
52 | }
|
---|
53 |
|
---|
54 | if(! ($row = db_fetch_array( $q, 0 ) ) ) {
|
---|
55 | error('Usergroup edit', 'Usergroup does not exist' );
|
---|
56 | }
|
---|
57 |
|
---|
58 | //set private usergroup checkbox
|
---|
59 | if($row['private'] ){
|
---|
60 | $private = "checked=\"checked\"";
|
---|
61 | }
|
---|
62 | else {
|
---|
63 | $private = "";
|
---|
64 | }
|
---|
65 |
|
---|
66 | $content = "<form method=\"post\" action=\"usergroups.php\">\n".
|
---|
67 | "<fieldset><input type=\"hidden\" name=\"x\" value=\"".X."\" />\n".
|
---|
68 | "<input type=\"hidden\" name=\"action\" value=\"submit_edit\" />\n".
|
---|
69 | "<input type=\"hidden\" name=\"usergroupid\" value=\"".$usergroupid."\" />\n".
|
---|
70 | "<input type=\"hidden\" name=\"token\" value=\"".TOKEN."\" /></fieldset>\n".
|
---|
71 | "<table class=\"celldata\">\n".
|
---|
72 | "<tr><td>".$lang['usergroup_name']."</td><td><input type=\"text\" name=\"name\" value=\"".$row['name']."\" size=\"30\" /></td></tr>\n".
|
---|
73 | "<tr><td>".$lang['usergroup_description']."</td><td><input type=\"text\" name=\"description\" value=\"".$row['description']."\" size=\"30\" /></td></tr>\n".
|
---|
74 | "<tr><td> </td></tr>\n".
|
---|
75 | "<tr><td><label for=\"private\">".$lang['private_usergroup'].":</label></td><td><input type=\"checkbox\" name=\"private_group\" id=\"private\" ".$private." /></td></tr>\n".
|
---|
76 | "<tr><td> </td></tr>\n";
|
---|
77 |
|
---|
78 | //add users
|
---|
79 | $q = db_query('SELECT '.PRE.'users.id AS id
|
---|
80 | FROM '.PRE.'users
|
---|
81 | LEFT JOIN '.PRE.'usergroups_users ON ('.PRE.'usergroups_users.userid='.PRE.'users.id)
|
---|
82 | WHERE usergroupid='.$row['id'].'
|
---|
83 | AND '.PRE.'users.deleted=\'f\'' );
|
---|
84 |
|
---|
85 | //put groups in an array
|
---|
86 | for( $i=0 ; $row = @db_fetch_array($q, $i ) ; ++$i ) {
|
---|
87 | $member_array[] = $row['id'];
|
---|
88 | }
|
---|
89 |
|
---|
90 | $q = db_query('SELECT fullname, id FROM '.PRE.'users WHERE deleted=\'f\' ORDER BY fullname' );
|
---|
91 |
|
---|
92 | $content .= "<tr><td>".$lang['members']."</td><td><select name=\"member[]\" multiple=\"multiple\" size=\"4\">\n";
|
---|
93 |
|
---|
94 | for( $i=0 ; $user_row = @db_fetch_array($q, $i ) ; ++$i ) {
|
---|
95 | $content .= "<option value=\"".$user_row['id']."\"";
|
---|
96 |
|
---|
97 | //highlight occupied groups
|
---|
98 | if(in_array($user_row['id'], $member_array ) ) {
|
---|
99 | $content .= " selected=\"selected\"";
|
---|
100 | }
|
---|
101 |
|
---|
102 | $content .= ">".$user_row['fullname']."</option>\n";
|
---|
103 | }
|
---|
104 |
|
---|
105 | $content .= "</select><small><i>".$lang['select_instruct']."</i></small></td></tr>\n".
|
---|
106 | "</table>\n".
|
---|
107 | "<p><input type=\"submit\" value=\"".$lang['submit_changes']."\" /></p>\n".
|
---|
108 | "</form>\n".
|
---|
109 | "<form method=\"post\" action=\"usergroups.php\" ".
|
---|
110 | "onclick=\"return confirm( '".$lang['confirm_del_javascript']."')\">\n".
|
---|
111 | "<fieldset><input type=\"hidden\" name=\"x\" value=\"".X."\" />\n".
|
---|
112 | "<input type=\"hidden\" name=\"action\" value=\"submit_del\" />\n".
|
---|
113 | "<input type=\"hidden\" name=\"usergroupid\" value=\"".$usergroupid."\" />\n".
|
---|
114 | "<input type=\"hidden\" name=\"token\" value=\"".TOKEN."\" /></fieldset>\n".
|
---|
115 | "<p><input type=\"submit\" value=\"".$lang['delete']."\" /></p>\n".
|
---|
116 | "</form>\n";
|
---|
117 |
|
---|
118 | new_box( $lang['edit_usergroup'], $content );
|
---|
119 |
|
---|
120 | ?>
|
---|