1<?php
2
3/**
4 * Script to add users to group
5 *************************************************/
6
7/* functions */
8require_once( dirname(__FILE__) . '/../../../functions/functions.php' );
9
10# initialize user object
11$Database 	= new Database_PDO;
12$User 		= new User ($Database);
13$Admin	 	= new Admin ($Database);
14$Result 	= new Result ();
15
16# verify that user is logged in
17$User->check_user_session();
18
19
20# id must be numeric
21if(!is_numeric($_POST['g_id']))		{ $Result->show("danger", _("Invalid ID"), true, true); }
22
23# get group details
24$group   = $Admin->fetch_object("userGroups", "g_id", $_POST['g_id']);
25# users in group - array of ids
26$existing = $Admin->group_fetch_users ($_POST['g_id']);
27?>
28
29
30<!-- header -->
31<div class="pHeader"><?php print _('Remove users from group'); ?> <?php print $group->g_name; ?></div>
32
33
34<!-- content -->
35<div class="pContent">
36
37	<?php if(sizeof($existing) > 0) { ?>
38
39	<form id="groupRemoveUsers" name="groupRemoveUsers">
40	<table class="groupEdit table table-condensed table-top">
41
42	<tr>
43		<th>
44			<input type="hidden" name="gid" value="<?php print $_POST['g_id']; ?>">
45		</th>
46		<th><?php print _('Name'); ?></th>
47		<th><?php print _('Username'); ?></th>
48		<th><?php print _('Email'); ?></th>
49	</tr>
50
51	<?php
52	# show existing
53	foreach($existing as $m) {
54		# get user details
55		$u = (array) $Admin->fetch_object("users", "id", $m);
56
57		print "<tr>";
58
59		print "	<td>";
60		print "	<input type='checkbox' name='user$u[id]'>";
61		print "	</td>";
62
63		print "	<td>$u[real_name]</td>";
64		print "	<td>$u[username]</td>";
65		print "	<td>$u[email]</td>";
66
67		print "</tr>";
68	}
69	?>
70
71    </table>
72    </form>
73
74    <?php } else { $Result->show("info", _('No users in this group'), false);  } ?>
75</div>
76
77
78<!-- footer -->
79<div class="pFooter">
80	<div class="btn-group">
81		<button class="btn btn-sm btn-default hidePopups"><?php print _('Cancel'); ?></button>
82		<?php if(sizeof($existing) > 0) { ?>
83		<button class='btn btn-sm btn-success submit_popup' data-script="app/admin/groups/remove-users-result.php" data-result_div="groupRemoveUsersResult" data-form='groupRemoveUsers'><?php print _('Remove selected users'); ?></button>
84		<?php } ?>
85	</div>
86
87	<!-- Result -->
88	<div id="groupRemoveUsersResult"></div>
89</div>
90