0 ) ) { ZM\Error('No monitor ids given in snapshot creation request'); return; } $snapshot = new ZM\Snapshot(); $snapshot->save(array('CreatedBy'=>$user['Id'])); foreach ( $_REQUEST['monitor_ids'] as $monitor_id ) { $snapshot_event = new ZM\Snapshot_Event(); $monitor = new ZM\Monitor($monitor_id); $event_id = $monitor->TriggerOn(); ZM\Debug("Have event $event_id for monitor $monitor_id"); if ( $event_id ) { $snapshot_event->save(array( 'SnapshotId'=>$snapshot->Id(), 'EventId'=>$event_id )); } } # end foreach monitor foreach ( $_REQUEST['monitor_ids'] as $monitor_id ) { $monitor = new ZM\Monitor($monitor_id); $monitor->TriggerOff(); } $redirect = '?view=snapshot&id='.$snapshot->Id(); return; } // Event scope actions, view permissions only required if ( isset($_REQUEST['id']) ) { $snapshot = new ZM\Snapshot($_REQUEST['id']); if ( ($action == 'save') ) { if ( canEdit('Events') or $snapshot->CreatedBy() == $user['Id'] ) { $changes = $snapshot->changes($_REQUEST['snapshot']); if ( count($changes) ) { $snapshot->save($changes); } $redirect = '?view=snapshots'; } } else if ( $action == 'delete' ) { if ( canEdit('Events') ) { $snapshot->delete(); $redirect = '?view=snapshots'; } } } // end if canEdit(Events) ?>