-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPersonToGroup.php
147 lines (128 loc) · 4.14 KB
/
PersonToGroup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/*******************************************************************************
*
* filename : PersonToGroup.php
* last change : 2003-06-23
* description : Add a person record to a group after selection of group
* and role. This is a companion script to the Group Assign Helper.
*
* http://www.infocentral.org/
* Copyright 2003 Chris Gebhardt
*
* InfoCentral is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
******************************************************************************/
// Include the function library
require "Include/Config.php";
require "Include/Functions.php";
// Security: User must have Manage Groups & Roles permission
if (!$_SESSION['bManageGroups'])
{
Redirect("Menu.php");
exit;
}
$iPersonID = FilterInput($_GET["PersonID"],'int');
// Was the form submitted?
if (isset($_POST["Submit"]))
{
// Get the GroupID
$iGroupID = FilterInput($_POST["GroupID"],'int');
$iGroupRole = FilterInput($_POST["GroupRole"],'int');
$sPreviousQuery = strip_tags($_POST["prevquery"]);
AddToGroup($iPersonID,$iGroupID,$iGroupRole);
Redirect("SelectList.php?$sPreviousQuery");
}
else
$sPreviousQuery = strip_tags(rawurldecode($_GET["prevquery"]));
// Get all the groups
$sSQL = "SELECT * FROM group_grp ORDER BY grp_Name";
$rsGroups = RunQuery($sSQL);
// Set the page title and include HTML header
$sPageTitle = gettext("Add Person to Group");
require "Include/Header.php";
?>
<script type="text/javascript">
var IFrameObj; // our IFrame object
function UpdateRoles()
{
var group_ID = document.getElementById('GroupID').value;
if (!document.createElement) {return true};
var IFrameDoc;
var URL = 'RPCdummy.php?mode=GroupRolesSelect&data=' + group_ID;
if (!IFrameObj && document.createElement) {
var tempIFrame=document.createElement('iframe');
tempIFrame.setAttribute('id','RSIFrame');
tempIFrame.style.border='0px';
tempIFrame.style.width='0px';
tempIFrame.style.height='0px';
IFrameObj = document.body.appendChild(tempIFrame);
if (document.frames) {
// For IE5 Mac
IFrameObj = document.frames['RSIFrame'];
}
}
if (navigator.userAgent.indexOf('Gecko') !=-1
&& !IFrameObj.contentDocument) {
// For NS6
setTimeout('AddToCart()',10);
return false;
}
if (IFrameObj.contentDocument) {
// For NS6
IFrameDoc = IFrameObj.contentDocument;
} else if (IFrameObj.contentWindow) {
// For IE5.5 and IE6
IFrameDoc = IFrameObj.contentWindow.document;
} else if (IFrameObj.document) {
// For IE5
IFrameDoc = IFrameObj.document;
} else {
return true;
}
IFrameDoc.location.replace(URL);
return false;
}
function updateGroupRoles(generated_html)
{
if (generated_html == "invalid") {
document.getElementById('GroupRoles').innerHTML = '<p class="LargeError"><?php echo gettext("Invalid Group or No Roles Available!"); ?><p>';
} else {
document.getElementById('GroupRoles').innerHTML = generated_html;
}
}
</script>
<p align="center"><?php echo gettext("Select the group to add this person to:"); ?></p>
<form method="post" action="PersonToGroup.php?PersonID=<?php echo $iPersonID;?>">
<input type="hidden" name="prevquery" value="<?php echo $sPreviousQuery;?>">
<table align="center">
<tr>
<td class="LabelColumn"><?php echo gettext("Select Group:"); ?></td>
<td class="TextColumn">
<?php
// Create the group select drop-down
echo "<select id=\"GroupID\" name=\"GroupID\" onChange=\"UpdateRoles();\"><option value=\"0\">" . gettext("None") . "</option>";
while ($aRow = mysql_fetch_array($rsGroups)) {
extract($aRow);
echo "<option value=\"" . $grp_ID . "\">" . $grp_Name . "</option>";
}
echo "</select>";
?>
</td>
</tr>
<tr>
<td class="LabelColumn"><?php echo gettext("Select Role:"); ?></td>
<td class="TextColumn"><span id="GroupRoles"><?php echo gettext("No Group Selected"); ?></span></td>
</tr>
</table>
<p align="center">
<BR>
<input type="submit" class="icButton" name="Submit" value="<?php echo gettext("Add to Group"); ?>">
<BR><BR>
</p>
</form>
<?php
require "Include/Footer.php";
?>