move code up one directory
[atutor.git] / mods / _core / users / user_status.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2010                                      */
6 /* Inclusive Design Institute                                   */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 /* linked from admin/users.php                                  */
14 /* deletes a user from the system.                              */
15 /****************************************************************/
16 // $Id$
17
18 define('AT_INCLUDE_PATH', '../../../include/');
19 require(AT_INCLUDE_PATH.'vitals.inc.php');
20 admin_authenticate(AT_ADMIN_PRIV_USERS);
21
22 $ids = explode(',', $_REQUEST['ids']);
23 $status = intval($_REQUEST['status']);
24
25 if (isset($_POST['submit_yes'])) {
26
27         foreach ($ids as $id) {
28                 //make sure not instructor of a course
29                 $id = intval($id);
30                 $sql    = "SELECT course_id FROM ".TABLE_PREFIX."courses WHERE member_id=$id";
31                 $result = mysql_query($sql, $db);
32                 if (!mysql_fetch_assoc($result)) {
33                         $sql2 = "UPDATE ".TABLE_PREFIX."members SET status=".$status.", creation_date = creation_date WHERE member_id=$id";
34                         $result2 = mysql_query($sql2,$db);
35                 }
36         }
37
38         $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
39         header('Location: '.AT_BASE_HREF.'mods/_core/users/users.php');
40         exit;
41
42 } else if (isset($_POST['submit_no'])) {
43         $msg->addFeedback('CANCELLED');
44         header('Location: '.AT_BASE_HREF.'mods/_core/users/users.php');
45         exit;
46 }
47
48
49 require(AT_INCLUDE_PATH.'header.inc.php'); 
50
51 $names = get_login($ids);
52 $names_html = '<ul>'.html_get_list($names).'</ul>';
53 $status_name = get_status_name($status);
54
55 $hidden_vars['ids'] = implode(',', array_keys($names));
56 $hidden_vars['status'] = $status;
57
58 $confirm = array('EDIT_STATUS', $status_name, $names_html);
59 $msg->addConfirm($confirm, $hidden_vars);
60 $msg->printConfirm();
61
62 require(AT_INCLUDE_PATH.'footer.inc.php'); 
63 ?>