3 * Finish Mass-adding users.
5 * Copyright 2004 (c) GForge LLC
7 * @author Tim Perdue tim@gforge.org
10 * This file is part of GForge.
12 * GForge is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * GForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with GForge; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 require_once('../../env.inc.php');
28 require_once $gfwww.'include/pre.php';
29 require_once $gfwww.'project/admin/project_admin_utils.php';
30 require_once $gfwww.'include/role_utils.php';
32 $group_id = getIntFromRequest('group_id');
33 session_require(array('group'=>$group_id,'admin_flags'=>'A'));
35 $accumulated_ids = getStringFromRequest("accumulated_ids");
37 $group =& group_get_object($group_id);
38 if (!$group || !is_object($group)) {
39 exit_error('Error','Could Not Get Group');
40 } elseif ($group->isError()) {
41 exit_error('Error',$group->getErrorMessage());
44 if (getStringFromRequest('finished')) {
45 $addrole = getStringFromRequest('addrole');
46 $keys=array_keys($addrole);
47 for ($i=0; $i<count($keys); $i++) {
48 $group->addUser($keys[$i],$addrole[$keys[$i]]);
50 //change assistant for webcal
51 $params[0] = $keys[$i];
52 $params[1] = $group_id;
53 plugin_hook('change_cal_permission',$params);
55 Header("Location: index.php?group_id=$group_id&feedback=Successful");
58 if (!$accumulated_ids) {
59 exit_error('Error','No IDs Were Passed');
61 $arr=explode(',',$accumulated_ids);
62 $res=db_query("SELECT user_id,user_name,realname FROM users
63 WHERE status='A' and type_id='1' and user_id IN ('". implode('\',\'',$arr) ."')
64 ORDER BY realname ASC");
67 project_admin_header(array('title'=>_('Edit Role'),'group'=>$group_id));
70 <h2>'._('Add Users From List').'</h2>
72 '._('Choose the role for each user and then press "Add All".').'
74 <form action="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'" method="post">';
76 if (!$res || db_numrows($res) < 1) {
77 echo "No Matching Users Found";
80 $titles[]=_('Real name');
81 $titles[]=_('Unix name');
84 echo $HTML->listTableTop($titles);
87 // Everything is built on the multi-dimensial arrays in the Role object
89 for ($i=0; $i<db_numrows($res); $i++) {
91 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '>
92 <td>'.db_result($res,$i,'realname').'</td>
93 <td>'.db_result($res,$i,'user_name').'</td>
94 <td>'.role_box($group_id,'addrole['. db_result($res,$i,'user_id') .']','').'</td></tr>';
98 echo $HTML->listTableBottom();
102 echo '<input type="submit" name="finished" value="Add All">
105 project_admin_footer(array());
109 // c-file-style: "bsd"