Revert "Fix sql query when user is limited to specific monitors"

This reverts commit 41b581552e.
This commit is contained in:
Isaac Connor 2015-02-23 14:10:53 -05:00
parent 41b581552e
commit 851a246cf2
1 changed files with 6 additions and 8 deletions

View File

@ -27,15 +27,13 @@ if ( !canView( 'Events' ) )
$eid = validInt( $_REQUEST['eid'] );
$fid = !empty($_REQUEST['fid'])?validInt($_REQUEST['fid']):1;
$sql = 'SELECT E.*,M.Name AS MonitorName,M.Width,M.Height,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?';
$sql_values = array( $eid );
if ( $user['MonitorIds'] )
$midSql = " and MonitorId in (".join( ",", preg_split( '/["\'\s]*,["\'\s]*/', dbEscape($user['MonitorIds']) ) ).")";
else
$midSql = '';
if ( $user['MonitorIds'] ) {
$monitor_ids = preg_split( '/,/', $user['MonitorIds'] );
$sql .= ' AND MonitorId IN (' .implode( ',', array_fill(0,count($monitor_ids),'?') ) . ')';
$sql_values = array_merge( $sql_values, $monitor_ids );
}
$event = dbFetchOne( $sql, NULL, $sql_values );
$sql = 'SELECT E.*,M.Name AS MonitorName,M.DefaultRate,M.DefaultScale FROM Events AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id WHERE E.Id = ?'.$midSql;
$event = dbFetchOne( $sql, NULL, array($eid) );
if ( isset( $_REQUEST['rate'] ) )
$rate = validInt($_REQUEST['rate']);