3 * Finish Mass-adding users.
5 * Copyright 2004 (c) Tim Perdue - GForge LLC
6 * Copyright 2010 (c) Franck Villaume - Capgemini
7 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once '../../env.inc.php';
27 require_once $gfcommon.'include/pre.php';
28 require_once $gfwww.'project/admin/project_admin_utils.php';
29 require_once $gfwww.'include/role_utils.php';
31 $group_id = getIntFromRequest('group_id');
32 session_require_perm ('project_admin', $group_id) ;
34 $accumulated_ids = getStringFromRequest("accumulated_ids");
36 $group = group_get_object($group_id);
37 if (!$group || !is_object($group)) {
39 } elseif ($group->isError()) {
40 exit_error($group->getErrorMessage(),'admin');
43 if (getStringFromRequest('finished')) {
44 $addrole = getStringFromRequest('addrole');
45 $keys=array_keys($addrole);
46 for ($i=0; $i<count($keys); $i++) {
47 $group->addUser($keys[$i],$addrole[$keys[$i]]);
49 //change assistant for webcal
50 $params[0] = $keys[$i];
51 $params[1] = $group_id;
52 plugin_hook('change_cal_permission',$params);
54 $feedback = _('Successful');
55 session_redirect('/project/admin/index.php?group_id='.$group_id.'&feedback='.urlencode($feedback));
58 if (!$accumulated_ids) {
59 exit_error(_('No IDs Were Passed'),'admin');
61 $arr=explode(',',$accumulated_ids);
62 $res=db_query_params("SELECT user_id,user_name,realname FROM users
63 WHERE status='A' and type_id='1' and user_id = ANY ($1)
64 ORDER BY realname ASC", array(db_int_array_to_any_clause($arr)));
67 project_admin_header(array('title'=>_('Add Users From List'),'group'=>$group_id));
71 '._('Choose the role for each user and then press "Add All".').'
73 <form action="'.getStringFromServer('PHP_SELF').'?group_id='.$group_id.'" method="post">';
75 if (!$res || db_numrows($res) < 1) {
76 echo "No Matching Users Found";
79 $titles[]=_('Real name');
80 $titles[]=_('Unix name');
83 echo $HTML->listTableTop($titles);
86 // Everything is built on the multi-dimensial arrays in the Role object
88 for ($i=0; $i<db_numrows($res); $i++) {
90 echo '<tr '. $HTML->boxGetAltRowStyle($i) . '>
91 <td>'.db_result($res,$i,'realname').'</td>
92 <td>'.db_result($res,$i,'user_name').'</td>
93 <td>'.role_box($group_id,'addrole['. db_result($res,$i,'user_id') .']','').'</td></tr>';
97 echo $HTML->listTableBottom();
101 echo '<p><input type="submit" name="finished" value="'._('Add All').'" /></p>
104 project_admin_footer(array());
108 // c-file-style: "bsd"