2009-09-09 00:26:12 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . org >
This program 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 , version 2.
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the GNU
General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
< ?
require_once ( '../common.inc.php' );
require_once ( '../user.inc.php' );
2010-01-15 15:39:36 +00:00
require_once ( '../judge.inc.php' );
2010-07-13 03:30:17 +00:00
user_auth_required ( 'admin' );
2009-09-09 00:26:12 +00:00
require_once ( 'judges.inc.php' );
2010-07-15 20:00:10 +00:00
$user_what = array ();
$query = mysql_query ( " SELECT `type`, `name` FROM roles " );
while ( $row = mysql_fetch_assoc ( $query )){
$user_what [ $row [ 'type' ]] = $row [ 'name' ];
}
2009-09-09 00:26:12 +00:00
$show_types = $_GET [ 'show_types' ];
2010-07-15 20:00:10 +00:00
if ( user_valid_role ( $show_types ) == false ) $show_types = array ( 'judge' );
2009-09-09 00:26:12 +00:00
$show_complete = ( $_GET [ 'show_complete' ] == 'yes' ) ? 'yes' : 'no' ;
2010-07-15 20:00:10 +00:00
$show_all = ( $_GET [ 'show_all' ] == 'yes' ) ? 'yes' : 'no' ;
2009-09-09 00:26:12 +00:00
$uid = intval ( $_GET [ 'uid' ]);
if ( $_GET [ 'action' ] == 'remove' ) {
if ( ! $uid ) {
echo " Invalid uid for delete " ;
exit ;
}
user_delete ( $uid );
message_push ( happy ( i18n ( 'User deleted.' )));
}
send_header ( " User Editor " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' )
);
?>
< script language = " javascript " type = " text/javascript " >
function openeditor ( id )
{
if ( id ) currentid = id ;
2009-10-29 17:07:56 +00:00
window . open ( " user_editor_window.php?id= " + currentid , " UserEditor " , " location=no,menubar=no,directories=no,toolbar=no,width=1000,height=640,scrollbars=yes " );
2009-09-09 00:26:12 +00:00
return false ;
}
function toggleoptions ()
{
if ( document . getElementById ( 'options' ) . style . display == 'none' ) {
document . getElementById ( 'options' ) . style . display = 'block' ;
document . getElementById ( 'optionstext' ) . innerHTML = '- <?=i18n(' Hide Display Options ')?>' ;
} else {
document . getElementById ( 'options' ) . style . display = 'none' ;
document . getElementById ( 'optionstext' ) . innerHTML = '+ <?=i18n(' Show Display Options ')?>' ;
}
}
function togglenew ()
{
if ( document . getElementById ( 'new' ) . style . display == 'none' ) {
document . getElementById ( 'new' ) . style . display = 'block' ;
document . getElementById ( 'newtext' ) . innerHTML = '<?=i18n(' Cancel New User ')?>' ;
} else {
document . getElementById ( 'new' ) . style . display = 'none' ;
document . getElementById ( 'newtext' ) . innerHTML = '<?=i18n(' Add New User ')?>' ;
}
}
function neweditor ()
{
var username = document . forms . newuser . new_email . value ;
var usertype = document . forms . newuser . new_type . value ;
2009-10-29 17:07:56 +00:00
window . open ( " user_editor_window.php?type= " + usertype + " &username= " + username , " UserEditor " , " location=no,menubar=no,directories=no,toolbar=no,width=770,height=500,scrollbars=yes " );
2009-09-09 00:26:12 +00:00
document . forms . newuser . new_email . value = " " ;
return false ;
}
</ script >
< ?
echo " <div class= \" notice \" > " ;
2010-09-03 16:59:05 +00:00
echo " <a id= \" optionstext \" onclick= \" toggleoptions();return false; \" >- " . i18n ( 'Show Display Options' ) . " </a> " ;
2009-09-09 00:26:12 +00:00
echo " <form method= \" GET \" action= \" $PHP_SELF\ " > " ;
2010-09-03 16:59:05 +00:00
echo " <div id= \" options \" style= \" display: none; \" > " ;
2009-09-09 00:26:12 +00:00
echo " <table><tr><td> " . i18n ( 'Type' ) . " :</td> " ;
$x = 0 ;
foreach ( $user_what as $k => $v ) {
$sel = ( in_array ( $k , $show_types )) ? 'checked="checked"' : '' ;
echo " <td><input type= \" checkbox \" name= \" show_types[] \" value= \" $k\ " $sel > " .i18n( $v ). " </ input ></ td > " ;
if ( $x ) echo " </tr><tr><td></td> " ;
$x = ~ $x ;
}
echo " </tr> " ;
echo " <tr><td> " . i18n ( 'Complete' ) . " :</td><td> " ;
echo " <select name= \" show_complete \" > " ;
$s = ( $show_complete == 'yes' ) ? 'selected="selected"' : '' ;
echo " <option value= \" yes \" $s > " . i18n ( 'Show only complete registrations' ) . " </option> " ;
$s = ( $show_complete == 'no' ) ? 'selected="selected"' : '' ;
echo " <option value= \" no \" $s > " . i18n ( 'Show ALL registrations' ) . " </option> " ;
echo " </select> " ;
echo " </tr> " ;
2010-07-15 20:00:10 +00:00
echo " <tr><td> " . i18n ( 'Conference' ) . " :</td><td> " ;
echo " <select name= \" show_all \" > " ;
$s = ( $show_all == 'no' ) ? 'selected="selected"' : '' ;
echo " <option value= \" no \" $s > " . i18n ( 'Show only registrations from this conference' ) . " </option> " ;
$s = ( $show_all == 'yes' ) ? 'selected="selected"' : '' ;
echo " <option value= \" yes \" $s > " . i18n ( 'Show ALL conferences' ) . " </option> " ;
2009-09-09 00:26:12 +00:00
echo " </select> " ;
echo " </td></tr></table> " ;
echo " <br /> " ;
echo " <input type=submit value= \" " . i18n ( 'Apply Filter' ) . " \" > " ;
echo " </div> " ;
echo " </form> " ;
echo " </div> " ;
echo " <br/><a id= \" newtext \" href= \" javascript:togglenew() \" > " . i18n ( 'Add New User' ) . " </a> " ;
echo '<div id="new" style="display: none;" class="notice">' ;
echo " <form name= \" newuser \" method= \" GET \" action= \" $PHP_SELF\ " > " ;
echo " <table><tr><td> " . i18n ( 'Type' ) . " :</td><td> " ;
echo " <select name= \" new_type \" > " ;
$x = 0 ;
foreach ( $user_what as $k => $v ) {
$sel = ( in_array ( $k , $show_types )) ? 'selected="selected"' : '' ;
echo " <option value= \" $k\ " $sel > " .i18n( $v ). " </ option > " ;
}
echo " </select> " ;
echo " </tr> " ;
echo " <tr><td> " . i18n ( 'Email' ) . " :</td><td> " ;
echo '<input type="text" name="new_email" value="" />' ;
echo '</td></tr>' ;
echo '</table>' ;
echo " <input type=submit onclick= \" neweditor(); \" value= \" " . i18n ( 'Create New User' ) . " \" > " ;
echo '</form>' ;
echo '</div>' ;
echo " <br /> " ;
echo " <br /> " ;
/* Grab a list of users */
2010-07-15 20:00:10 +00:00
$clauses = array ();
$roles = array ();
foreach ( $show_types as $t ){
$roles [] = " type = ' $t ' " ;
2009-09-09 00:26:12 +00:00
}
2010-07-15 20:00:10 +00:00
if ( count ( $roles ) > 0 ) $clauses [] = 'ur.roles_id IN(SELECT id FROM roles WHERE ' . implode ( ' OR ' , $roles ) . ')' ;
if ( $show_complete == 'yes' ) $clauses [] = 'ur.complete = "yes"' ;
if ( $show_all == 'no' ) $clauses [] = " u1.conferences_id= { $conference [ 'id' ] } " ;
$querystr =
" SELECT u1.id as userid, u1.*, ur.*, conferences.name AS conference_name " .
" FROM users u1 " .
" LEFT JOIN user_roles ur ON ur.users_id = u1.id " .
" JOIN conferences ON u1.conferences_id = conferences.id " ;
if ( count ( $clauses ) > 0 ){
$querystr .= " WHERE " . implode ( ' AND ' , $clauses ) . " " ;
2009-09-09 00:26:12 +00:00
}
2010-07-15 20:00:10 +00:00
$querystr .=
" GROUP BY u1.accounts_id " .
" HAVING u1.deleted = 'no' " .
" ORDER BY lastname ASC, firstname ASC, conferences_id DESC " ;
$q = mysql_query ( $querystr );
$num = mysql_num_rows ( $q );
echo i18n ( " Listing %1 people total. See the bottom for breakdown by complete status " , array ( $num ));
2009-09-09 00:26:12 +00:00
echo mysql_error ();
2010-07-15 20:00:10 +00:00
echo " <table class= \" tableview \" > " ;
2010-03-30 21:59:04 +00:00
echo " <thead> " ;
2009-09-09 00:26:12 +00:00
echo " <tr> " ;
echo " <th> " . i18n ( " Name " ) . " </th> " ;
echo " <th> " . i18n ( " Email Address " ) . " </th> " ;
2010-07-15 20:00:10 +00:00
echo " <th> " . i18n ( " Conference " ) . " </th> " ;
2009-09-09 00:26:12 +00:00
echo " <th> " . i18n ( " Type(s) " ) . " </th> " ;
echo " <th> " . i18n ( " Active " ) . " </th> " ;
echo " <th> " . i18n ( " Complete " ) . " </th> " ;
echo " <th> " . i18n ( " Actions " ) . " </th> " ;
echo " </tr> " ;
2010-03-30 21:59:04 +00:00
echo " </thead> " ;
2010-03-31 22:03:07 +00:00
$tally = array ();
$tally [ 'active' ] = array ();
$tally [ 'inactive' ] = array ();
$tally [ 'active' ][ 'complete' ] = 0 ;
$tally [ 'active' ][ 'incomplete' ] = 0 ;
2010-07-15 20:00:10 +00:00
$tally [ 'active' ][ 'na' ] = 0 ;
2010-03-31 22:03:07 +00:00
$tally [ 'inactive' ][ 'complete' ] = 0 ;
$tally [ 'inactive' ][ 'incomplete' ] = 0 ;
2010-07-15 20:00:10 +00:00
$tally [ 'inactive' ][ 'na' ] = 0 ;
2009-09-09 00:26:12 +00:00
while ( $r = mysql_fetch_assoc ( $q ))
{
2010-07-15 20:00:10 +00:00
// get the role data for this user
$roleData = array ();
$roleQuery = mysql_query ( " SELECT * FROM roles JOIN user_roles ON user_roles.roles_id = roles.id WHERE user_roles.users_id = " . $r [ 'userid' ]);
while ( $dat = mysql_fetch_assoc ( $roleQuery )){
//print_r($roleData);
$roleData [] = $dat ;
$roleTypes [] = $dat [ 'type' ];
2010-01-15 15:39:36 +00:00
}
2010-07-15 20:00:10 +00:00
$span = count ( $roleData ) > 1 ? " rowspan= \" " . count ( $roleData ) . " \" " : '' ;
2009-09-09 00:26:12 +00:00
echo " <tr><td $span > " ;
$name = " { $r [ 'firstname' ] } { $r [ 'lastname' ] } " ;
2010-07-15 20:00:10 +00:00
if ( in_array ( 'fair' , $roleTypes )) {
$qq = mysql_query ( " SELECT * FROM fairs WHERE id = " . $r [ 'fairs_id' ]);
echo $qq . " ;<br/> " ;
2009-09-09 00:26:12 +00:00
$rr = mysql_fetch_assoc ( $qq );
$name = " { $rr [ 'name' ] } " . (( trim ( $name ) == '' ) ? '' : " <br />( $name ) " );
2010-07-15 20:00:10 +00:00
}
if ( strlen ( trim ( $name )) == 0 ) $name = " < " . i18n ( " not specified " ) . " > " ;
2009-09-09 00:26:12 +00:00
echo " <a href= \" # \" onclick= \" return openeditor( { $r [ 'id' ] } ) \" > $name </a> " ;
echo " </td> " ;
echo " <td $span > { $r [ 'email' ] } </td> " ;
2010-07-15 20:00:10 +00:00
echo " <td $span > { $r [ 'conference_name' ] } </td> " ;
2009-09-09 00:26:12 +00:00
$first = true ;
2010-04-06 15:19:47 +00:00
$complete = false ;
$incomplete = false ;
2010-07-15 20:00:10 +00:00
foreach ( $roleData as $roleData ) {
2009-09-09 00:26:12 +00:00
if ( ! $first ) echo '</tr><tr>' ;
2010-07-15 20:00:10 +00:00
echo " <td> { $roleData [ 'name' ] } </td> " ;
2009-09-09 00:26:12 +00:00
echo " <td> " ;
2010-07-15 20:00:10 +00:00
if ( $roleData [ " active " ] == 'yes' ) {
2009-09-09 00:26:12 +00:00
echo " <div class= \" happy \" align= \" center \" > " . i18n ( " yes " ) . " </div> " ;
2010-03-31 22:03:07 +00:00
$userstate = 'active' ;
2009-09-09 00:26:12 +00:00
} else {
echo " <div class= \" error \" align= \" center \" > " . i18n ( " no " ) . " </div> " ;
2010-03-31 22:03:07 +00:00
$userstate = 'inactive' ;
2009-09-09 00:26:12 +00:00
}
echo " </td> " ;
echo " <td> " ;
2010-07-15 20:00:10 +00:00
if ( in_array ( $roleData [ 'type' ], array ( 'parent' , 'committee' , 'alumni' , 'mentor' , 'fair' ))) {
2010-04-06 15:19:47 +00:00
/* Do nothing, there's nothing to complete */
2010-07-15 20:00:10 +00:00
} else if ( $roleData [ " complete " ] == 'yes' ) {
2009-09-09 00:26:12 +00:00
echo " <div class= \" happy \" align= \" center \" > " . i18n ( " yes " ) . " </div> " ;
2010-04-06 15:19:47 +00:00
$complete = true ;
2009-09-09 00:26:12 +00:00
} else {
echo " <div class= \" error \" align= \" center \" > " . i18n ( " no " ) . " </div> " ;
2010-04-06 15:19:47 +00:00
$incomplete = true ;
2009-09-09 00:26:12 +00:00
}
echo " </td> " ;
if ( $first ) {
/* Finish off the the first line */
echo " <td $span align= \" center \" > " ;
echo " <a href= \" # \" onclick= \" return openeditor( { $r [ 'id' ] } ) \" ><img border=0 src= \" { $config [ 'SFIABDIRECTORY' ] } /images/16/edit. { $config [ 'icon_extension' ] } \" ></a> " ;
2010-03-30 16:08:57 +00:00
echo " <a onclick= \" return confirmClick('Are you sure you wish to completely delete this user?') \" href= \" user_list.php?action=remove&uid= { $r [ 'id' ] } \" ><img border=0 src= \" { $config [ 'SFIABDIRECTORY' ] } /images/16/button_cancel. { $config [ 'icon_extension' ] } \" ></a> " ;
2009-09-09 00:26:12 +00:00
echo " </td> " ;
}
$first = false ;
}
echo '</tr>' ;
2010-04-06 15:19:47 +00:00
if ( $complete ){
$tally [ $userstate ][ 'complete' ] ++ ;
} else if ( $incomplete ){
$tally [ $userstate ][ 'incomplete' ] ++ ;
2010-07-15 20:00:10 +00:00
} else {
$tally [ $userstate ][ 'na' ] ++ ;
2010-04-06 15:19:47 +00:00
}
2009-09-09 00:26:12 +00:00
}
echo " </table> " ;
echo i18n ( " Note: Deleting users from this list is a permanent operation and cannot be undone. Consider editting the user and deactivating or deleting roles in their account instead. " );
2010-03-31 22:03:07 +00:00
// let's make a table with the complete/incomplete counts and the active/inacteve states
?>
< table rules = " all " style = " border:solid 1px; margin:2em " >
< thead >
2010-07-15 20:00:10 +00:00
< tr >< td colspan = " 5 " align = " center " > List Totals </ td ></ tr >
2010-03-31 22:03:07 +00:00
< tr >
< th ></ th >
< th > Complete </ th >
< th > Incomplete </ th >
2010-07-15 20:00:10 +00:00
< th > N / A </ th >
2010-03-31 22:03:07 +00:00
< th > Total </ th >
</ tr >
</ thead >
< tbody >
< tr >
< td >< strong > Active </ strong ></ td >
< td >< ? = $tally [ 'active' ][ 'complete' ] ?> </td>
< td >< ? = $tally [ 'active' ][ 'incomplete' ] ?> </td>
2010-07-15 20:00:10 +00:00
< td >< ? = $tally [ 'active' ][ 'na' ] ?> </td>
< td >< ? = $tally [ 'active' ][ 'complete' ] + $tally [ 'active' ][ 'incomplete' ] + $tally [ 'active' ][ 'na' ] ?> </td>
2010-03-31 22:03:07 +00:00
</ tr >< tr >
< td >< strong > Inactive </ strong ></ td >
< td >< ? = $tally [ 'inactive' ][ 'complete' ] ?> </td>
< td >< ? = $tally [ 'inactive' ][ 'incomplete' ] ?> </td>
2010-07-15 20:00:10 +00:00
< td >< ? = $tally [ 'inactive' ][ 'na' ] ?> </td>
< td >< ? = $tally [ 'inactive' ][ 'complete' ] + $tally [ 'inactive' ][ 'incomplete' ] + $tally [ 'inactive' ][ 'na' ] ?> </td>
2010-03-31 22:03:07 +00:00
</ tr >< tr >
< td >< strong > Total </ strong ></ td >
< td >< ? = $tally [ 'active' ][ 'complete' ] + $tally [ 'inactive' ][ 'complete' ] ?> </td>
< td >< ? = $tally [ 'active' ][ 'incomplete' ] + $tally [ 'inactive' ][ 'incomplete' ] ?> </td>
2010-07-15 20:00:10 +00:00
< td >< ? = $tally [ 'active' ][ 'na' ] + $tally [ 'inactive' ][ 'na' ] ?> </td>
2010-03-31 22:03:07 +00:00
< td >< ? = $num ?> </td>
</ tr >
</ tbody >
</ table >
< ? php
2009-09-09 00:26:12 +00:00
send_footer ();
?>