<%pre>

#include <exception.h>
#include <tasks.h>
#include <tools.h>
#include <users.h>

using namespace vdrlive;

</%pre>
<%args>
	std::string param;
	std::string async;
</%args>
<%cpp>
	tChannelID paramID;
        paramID = paramID.FromString(param.c_str());
	bool ajaxReq = !async.empty() && (lexical_cast<int>(async) != 0);
	std::string referrer;

	if (!cUser::CurrentUserHasRightTo(UR_SWITCHCHNL))
		throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );

	if (ajaxReq) {
		reply.setContentType( "application/xml" );
	}
	else {
		referrer = request.getHeader("Referer:");
	}

	SwitchChannelTask task( paramID );
	LiveTaskManager().Execute( task );

	if (!ajaxReq) {
		if (!referrer.empty()) {
			return reply.redirect(referrer);
		}
</%cpp>
Normale Seite:<br/>
channel: <$ paramID $><br/>
result: <$ (task.Result()) $><br/>
error: <$ (task.Error()) $><br />
Seitenende!
<%cpp>
	}
	else {
</%cpp>
<& xmlresponse.ajax name=("switch_channel") pname=("channel") value=(paramID) result=(task.Result()) error=(task.Error()) &>
<%cpp>
	}
</%cpp>
