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
|
<?php
global $form,$listid,$groups;
if (preg_match("/\/includes\//", $PHP_SELF)) {
die ("You can't access this file directly!");
}
$form = clean_word($form);
$listid = clean_int($listid);
?>
<script type="text/javascript">
<!-- <![CDATA[
function OkButton () {
var parentlist = window.opener.document.<?php echo $form?>.elements[<?php echo $listid?>];
var thislist = document.forms[0].elements[0];
var found = "";
// select/deselect all elements
for ( i = 0; i < parentlist.length; i++ ) {
var state = false;
for ( j = 0; j < thislist.length; j++ ) {
if ( thislist.options[j].value == parentlist.options[i].value ) {
state = thislist.options[i].selected;
found += " " + thislist.options[j].value;
}
}
parentlist.options[i].selected = state;
}
//alert ( "Found: " + found );
window.close ();
}
function selectAll() {
var list = document.forms[0].elements[0];
var i;
for ( i = 0; i < list.options.length; i++ ) {
list.options[i].selected = true;
}
}
function selectNone() {
var list = document.forms[0].elements[0];
var i;
for ( i = 0; i < list.options.length; i++ ) {
list.options[i].selected = false;
}
}
// set the state (selected or unselected) if a single
// user in the list of users
function selectByLogin ( login, state ) {
//alert ( "selectByLogin ( " + login + ", " + state + " )" );
var list = document.forms[0].elements[0];
var i;
for ( i = 0; i < list.options.length; i++ ) {
//alert ( "text: " + list.options[i].text );
if ( list.options[i].value == login ) {
list.options[i].selected = state;
return;
}
}
}
function toggleGroup ( state ) {
var list = document.forms[0].elements[4];
var selNum = list.selectedIndex;
<?php
for ( $i = 0; $i < count ( $groups ); $i++ ) {
print "\n if ( selNum == $i ) {\n";
$res = dbi_query ( "SELECT cal_login from webcal_group_user " .
"WHERE cal_group_id = " . $groups[$i]["cal_group_id"] );
if ( $res ) {
while ( $row = dbi_fetch_row ( $res ) ) {
print " selectByLogin ( \"$row[0]\", state );\n";
}
dbi_free_result ( $res );
print " }\n";
}
}
?>
}
// Select users from a group
function selectGroupMembers () {
toggleGroup ( true );
}
// De-select users from a group
function deselectGroupMembers () {
toggleGroup ( false );
}
//]]> -->
</script>
|