<?php
if ( !defined( 'SMARTY_DIR' ) ) {
	include_once( '../init.php' );
}

include ( 'sessioninc.php' );

define( 'PAGE_ID', 'calendar_mgt' );
if ( !checkAdminPermission( PAGE_ID ) ) {
	header( 'location: not_authorize.php' );
	exit;
}

$arr = $_POST[ 'txtcheck' ];
if ( count( $arr ) == 0 ) {
	header( 'location: calendarevents.php?calendarid=' . $_POST['calendarid'] . '&msg=' . urlencode(get_lang('no_select_msg')) );
	exit;
}
switch ( $_POST['groupaction'] ) {
	case get_lang('enable_selected'):
		foreach ( $arr as $id ) {
			$result = $osDB->query( 'UPDATE ! SET enabled = ? WHERE id = ?', array( EVENTS_TABLE, 'Y', $id ) );
		}

	case get_lang('disable_selected'):
		foreach ( $arr as $id ) {
			$result = $osDB->query( 'UPDATE ! SET enabled = ? WHERE id = ?', array( EVENTS_TABLE, 'N', $id ) );
		}
}
header ( "location: calendarevents.php?calendarid=" . $_POST['calendarid'] );
exit;
?>