00001 <?php
00002 # This file is part of the Savane project
00003 # <http://gna.org/projects/savane/>
00004 #
00005 # $Id: useradmin.php 5429 2006-02-17 22:59:20Z toddy $
00006 #
00007 # Copyright 2003-2005 (c) Frederik Orellana <frederik.orellana--cern.ch>
00008 # Derek Feichtinger <derek.feichtinger--cern.ch>
00009 # Mathieu Roy <yeupou--gnu.org>
00010 #
00011 # The Savane project is free software; you can redistribute it and/or
00012 # modify it under the terms of the GNU General Public License
00013 # as published by the Free Software Foundation; either version 2
00014 # of the License, or (at your option) any later version.
00015 #
00016 # The Savane project is distributed in the hope that it will be useful,
00017 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 # GNU General Public License for more details.
00020 #
00021 # You should have received a copy of the GNU General Public License
00022 # along with the Savane project; if not, write to the Free Software
00023 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024
00025 require "../../include/pre.php";
00026
00027 session_require(array('group'=>$group_id,'admin_flags'=>'A'));
00028 if (!$group_id)
00029 {
00030 exit_no_group();
00031 }
00032
00033 function show_pending_users_list ($result, $group_id)
00034 {
00035 global $PHP_SELF;
00036 print "<h3>"._("Users Pending for Group")."</h3>
00037 <p>
00038 "._("Users that have requested to be member of the group are listed here. To approve their requests, select their name and click on the button below. To discard requests, go to the next section called \"Removing users from group\".")."
00039 <form action=\"$PHP_SELF\" method=\"post\">
00040 <input type=\"HIDDEN\" name=\"action\" VALUE=\"approve_for_group\" />
00041 <select name=\"user_id[]\" size=\"10\" multiple>\n";
00042
00043 while ($usr = db_fetch_array($result)) {
00044 print "<option value=".$usr[user_id].">".$usr[realname].
00045 " <".$usr[user_name]."></option>\n";
00046 $exists=1;
00047 }
00048
00049 if (!$exists)
00050 {
00051 # Show none if the list is empty
00052 print '<option>'._("None found").'</option>';
00053 }
00054
00055 print "</select>
00056 <input type=\"HIDDEN\" name=\"group_id\" VALUE=\"$group_id\" />
00057 <P>
00058 <input type=\"submit\" name=\"Submit\" value=\""._("Approve users for group")."\" />
00059 </form>";
00060 }
00061
00062
00063 function show_all_users_remove_list ($result, $result2, $group_id)
00064 {
00065 global $PHP_SELF;
00066 print "
00067 <h3>"._("Removing users from group")."</h3>
00068 <p>
00069 "._("To remove users, select their name and click on the button below. The administrators of a project cannot be removed unless they quit. Pending users are at the bottom of the list.")."
00070 <form action=\"$PHP_SELF\" method=\"post\">
00071 <input type=\"HIDDEN\" name=\"action\" VALUE=\"remove_from_group\" />
00072 <select name=\"user_id[]\" size=\"10\" multiple>\n";
00073
00074 while ($usr = db_fetch_array($result)) {
00075 if (!member_check($usr[user_id], $group_id, "A"))
00076 {
00077 print "<option value=".$usr[user_id].">".$usr[realname].
00078 " <".$usr[user_name]."></option>\n";
00079 $exists=1;
00080 }
00081 }
00082
00083 while ($usr = db_fetch_array($result2)) {
00084 if (!member_check($usr[user_id], $group_id, "A"))
00085 {
00086 print "<option value=".$usr[user_id].">"._("Pending:")." ".$usr[realname].
00087 " <".$usr[user_name]."></option>\n";
00088 $exists=1;
00089 }
00090 }
00091
00092 if (!$exists) {
00093 # Show none if the list is empty
00094 print '<option>'._("None found").'</option>';
00095 }
00096
00097 print "</select>
00098 <br />
00099 <input type=\"HIDDEN\" name=\"group_id\" VALUE=\"$group_id\" />
00100 <p>
00101 <input type=\"submit\" name=\"Submit\" value=\""._("Remove users from group")."\" />
00102 </form>";
00103
00104 }
00105
00106 function show_all_users_add_searchbox ($group_id, $previous_search)
00107 {
00108 global $PHP_SELF;
00109 print '
00110 <h3><a name="searchuser"></a>'._("Adding users to group").'</h3>
00111 <p>
00112 '._("You can search one or several users to add in the whole users database with the following search tool. A list of users, depending on the names you'll type in this form, will be generated.").'
00113
00114 <form action="'.$PHP_SELF.'#searchuser" method="post">
00115 <input type="hidden" name="action" value="add_to_group_list" />
00116 <input type="text" size="35" name="words" value="'.$previous_search.'" /><br />
00117 <p>
00118 <input type="hidden" name="group_id" value="'.$group_id.'" />
00119 <input type="submit" name="Submit" value="'._("Search users").'" />
00120 </form>';
00121 }
00122
00123
00124
00125 function show_all_users_add_list ($result, $group_id)
00126 {
00127 global $PHP_SELF;
00128 print _("Below is the result of your search in the users database.")."
00129
00130 <P></P>
00131 <form action=\"$PHP_SELF\" method=\"post\">
00132 <input type=\"HIDDEN\" name=\"action\" VALUE=\"add_to_group\" />
00133 <select name=\"user_id[]\" size=\"10\" multiple>\n";
00134
00135 while ($usr = db_fetch_array($result)) {
00136 print "<option value=".$usr[user_id].">".$usr[realname].
00137 " <".$usr[user_name]."></option>\n";
00138 $exists=1;
00139 }
00140
00141 if (!$exists) {
00142 # Show none if the list is empty
00143 print '<option>'._("None found").'</option>';
00144 }
00145
00146 print "</select>
00147 <br />
00148 <input type=\"HIDDEN\" name=\"group_id\" VALUE=\"$group_id\" />
00149 <p>
00150 <input type=\"submit\" name=\"Submit\" value=\""._("Add users to group")."\" />
00151 </form>";
00152 }
00153
00154
00155
00156 function show_bulk_add_users ($group_id)
00157 {
00158 print "<h3>"._("Have your file checked")."</h3>\n\n";
00159
00160 print _("By submitting your file here, the format of the file and each user name, etc. will be checked. No modifications will be made to the user database. Feedback will be given on screen and by email.");
00161 print "
00162 <br />
00163
00164 <form action=\"bulk_admin_users.php?action=test&group_id=".$group_id."\" method=\"post\" enctype=\"multipart/form-data\">
00165 <input type=\"HIDDEN\" name=\"action\" VALUE=\"check\" />
00166 <input type=\"file\" name=\"file\" size=\"40\" />
00167 <P>
00168 <input type=\"submit\" name=\"Submit\" value=\""._("Submit")."\" />
00169 </P>
00170 </form>
00171 <br />
00172
00173 </td></tr><tr><td class=\"boxitemalt\">
00174
00175 <h3>"._("Have your file executed")."</h3>\n\n";
00176
00177 print _("By submitting your file here, modifications will be made to the user database. Feedback will be given on screen and by email.");
00178 print "
00179 <br />
00180
00181 <form action=\"bulk_admin_users.php?action=execute&group_id=".$group_id."\" method=\"post\" enctype=\"multipart/form-data\">
00182 <input type=\"HIDDEN\" name=\"action\" VALUE=\"check\" />
00183 <input type=\"file\" name=\"file\" size=\"40\" />
00184 <P>
00185 <input type=\"submit\" name=\"Submit\" value=\""._("Submit")."\" />
00186 </P>
00187 </form>";
00188 }
00189
00190 # Administrative functions
00191
00192 # Add a user to this group
00193 if ($action=='add_to_group' && $user_id) {
00194 $sys_approved_user_permissions = $GLOBALS['sys_approved_user_permissions'];
00195 foreach ($user_id as $user) {
00196 member_add($user, $group_id);
00197 sprintf(' '._("User %s added to the project."), user_getname($user));
00198 }
00199 }
00200
00201 # Remove a user from this group
00202 if ($action=='remove_from_group' && $user_id) {
00203 foreach ($user_id as $user) {
00204 # Check if the users about to be removed are not admins
00205 if (!member_check($user, $group_id, "A")) {
00206 member_remove($user, $group_id);
00207 sprintf(' '._("User %s deleted from the project."), user_getname($user));;
00208 }
00209 }
00210 }
00211
00212 # Approve a user for this group
00213 if ($action=='approve_for_group' && $user_id) {
00214 foreach ($user_id as $user) {
00215 member_approve($user, $group_id);
00216 if($email=user_get_email($user)){
00217 # As mail content sent to a user different from the one browsing the
00218 # page, this cannot be translated.
00219 $title = "Project membership approved";
00220 $message = sprintf("You've been approved as a member of the group %s on %s,\nwhere you are registered as %s.", group_getname($group_id), $GLOBALS['sys_name'], user_getname($user)) . "\n\n".
00221 sprintf("-- the %s team.", $GLOBALS['sys_name'])."\n";
00222 $message = sprintf("You've been approved as a member of the group %s on %s,\nwhere you are registered as %s.", group_getname($group_id), $GLOBALS['sys_name'], user_getname($user)) . "\n\n".
00223 sprintf("-- the %s team.",$GLOBALS['sys_name'])."\n";
00224 # $title = _("Project membership approved");
00225 # $message = sprintf(_("You've been approved as a member of the group %s on %s,\nwhere you are registered as %s."), group_getname($group_id), $GLOBALS['sys_name'], user_getname($user)) . "\n\n".
00226 # sprintf(_("-- the %s team."),$GLOBALS['sys_name'])."\n";
00227 # $message = sprintf(_("You've been approved as a member of the group %s on %s,\nwhere you are registered as %s."), group_getname($group_id), $GLOBALS['sys_name'], user_getname($user)) . "\n\n".
00228 # sprintf(_("-- the %s team."),$GLOBALS['sys_name'])."\n";
00229
00230 sendmail_mail($GLOBALS['sys_replyto'] . "@".$GLOBALS['sys_lists_domain'],
00231 $email,
00232 $title,
00233 $message);
00234 }
00235 }
00236 }
00237
00238 ############
00239 # Start the page
00240 site_project_header(array('title'=>_("Manage Members"),'group'=>$group_id,'context'=>'ahome'));
00241
00242
00243 # Show a form so a user can be approved for this group
00244
00245 $result = db_query("SELECT user.user_id AS user_id, "
00246 . "user.user_name AS user_name, "
00247 . "user.realname AS realname "
00248 . "FROM user,user_group "
00249 . "WHERE user.user_id=user_group.user_id AND user_group.group_id='$group_id' AND admin_flags='P'"
00250 . "ORDER BY user.user_name");
00251
00252 show_pending_users_list($result, $group_id);
00253
00254 print '<br />';
00255
00256 # Show a form so a user can be removed from this group
00257 $result = db_query("SELECT user.user_id AS user_id, "
00258 . "user.user_name AS user_name, "
00259 . "user.realname AS realname "
00260 . "FROM user,user_group "
00261 . "WHERE user.user_id=user_group.user_id AND user_group.group_id=$group_id AND admin_flags<>'A' AND admin_flags<>'P'"
00262 . "ORDER BY user.user_name");
00263
00264 $result2 = db_query("SELECT user.user_id AS user_id, "
00265 . "user.user_name AS user_name, "
00266 . "user.realname AS realname "
00267 . "FROM user,user_group "
00268 . "WHERE user.user_id=user_group.user_id AND user_group.group_id=$group_id AND admin_flags='P'"
00269 . "ORDER BY user.user_name");
00270
00271 show_all_users_remove_list($result, $result2, $group_id);
00272
00273 print '<br />';
00274
00275 # Show a form so a user can be added to this group
00276
00277 # Query to find users
00278 $array = explode(" ",$words);
00279 $words1=implode($array,"%' OR user_name LIKE '%");
00280 $words2=implode($array,"%' OR realname LIKE '%");
00281 $result = db_query("SELECT user_id, user_name, realname "
00282 . "FROM user "
00283 . "WHERE ((user_name LIKE '%$words1%') OR (realname LIKE '%$words2%')) AND (status='A') ORDER BY user_name LIMIT 0,26");
00284
00285 show_all_users_add_searchbox($group_id, $words);
00286
00287 if ($words) {
00288 show_all_users_add_list($result, $group_id);
00289 }
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 site_project_footer(array());
00305
00306 ?>