2011-12-17 16:25:54 +01:00
< ? php
function admin_free () {
global $privileges ;
$search = " " ;
if ( isset ( $_REQUEST [ 'search' ]))
$search = strip_request_item ( 'search' );
2012-12-26 18:14:23 +01:00
$angeltypesearch = " " ;
if ( empty ( $_REQUEST [ 'angeltype' ]))
$_REQUEST [ 'angeltype' ] = '' ;
else {
$angeltypesearch = " INNER JOIN `UserAngelTypes` ON (`UserAngelTypes`.`angeltype_id` = ' " . sql_escape ( $_REQUEST [ 'angeltype' ]) . " ' AND `UserAngelTypes`.`user_id` = `User`.`UID` " ;
if ( isset ( $_REQUEST [ 'confirmed_only' ]))
$angeltypesearch .= " AND `UserAngelTypes`.`confirm_user_id` " ;
$angeltypesearch .= " ) " ;
}
$angel_types_source = sql_select ( " SELECT `id`, `name` FROM `AngelTypes` ORDER BY `name` " );
$angel_types = array ( '' => 'alle Typen' );
foreach ( $angel_types_source as $angel_type )
$angel_types [ $angel_type [ 'id' ]] = $angel_type [ 'name' ];
$users = sql_select ( " SELECT `User`.* FROM `User` ${ angeltypesearch } LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID` AND `Shifts`.`start` < " . sql_escape ( time ()) . " AND `Shifts`.`end` > " . sql_escape ( time ()) . " ) WHERE `User`.`Gekommen` = 1 AND `Shifts`.`SID` IS NULL GROUP BY `User`.`UID` ORDER BY `Nick` " );
2011-12-17 16:25:54 +01:00
$table = " " ;
if ( $search == " " )
$tokens = array ();
else
$tokens = explode ( " " , $search );
foreach ( $users as $usr ) {
if ( count ( $tokens ) > 0 ) {
$match = false ;
$index = join ( " " , $usr );
foreach ( $tokens as $t )
2012-12-27 14:24:05 +01:00
if ( stristr ( $index , trim ( $t ))) {
2011-12-17 16:25:54 +01:00
$match = true ;
break ;
}
if ( ! $match )
continue ;
}
$table .= '<tr>' ;
if ( in_array ( 'user_shifts_admin' , $privileges ))
$table .= '<td><a href="' . page_link_to ( 'user_myshifts' ) . '&id=' . $usr [ 'UID' ] . '">' . $usr [ 'Nick' ] . '</a></td>' ;
else
$table .= '<td>' . $usr [ 'Nick' ] . '</td>' ;
$table .= '<td>' . $usr [ 'DECT' ] . '</td>' ;
$table .= '<td>' . $usr [ 'jabber' ] . '</td>' ;
if ( in_array ( 'admin_user' , $privileges ))
$table .= '<td><a href="' . page_link_to ( 'admin_user' ) . '&id=' . $usr [ 'UID' ] . '">edit</a></td>' ;
else
$table .= '<td>' . $usr [ 'Nick' ] . '</td>' ;
$table .= '</tr>' ;
}
return template_render ( '../templates/admin_free.html' , array (
'search' => $search ,
2012-12-26 18:14:23 +01:00
'angeltypes' => html_select_key ( 'angeltype' , 'angeltype' , $angel_types , $_REQUEST [ 'angeltype' ]),
2012-12-27 02:54:57 +01:00
'confirmed_only' => isset ( $_REQUEST [ 'confirmed_only' ]) ? 'checked' : '' ,
2011-12-17 16:25:54 +01:00
'table' => $table ,
'link' => page_link_to ( 'admin_free' )
));
}
2012-12-26 18:14:23 +01:00
?>