/** * Run the IVR system * @param $ivrname Name of the initial IVR to start */ static function Run($ivrname) { global $yate_ivr_target; global $yate_ivr_current; if (IVR::Jump($ivrname)) { $init_id = true; while ($yate_ivr_current !== null) { $ev = Yate::GetEvent(); if ($ev === true) { continue; } if ($ev === false) { break; } if ($ev->type == "incoming" && $ev->name == "call.execute") { $yate_ivr_target = $ev->GetValue("id"); IVR::SetChannelID($ev->GetValue("ivrchanid")); } IVR::EventIVR($ev); if ($init_id && $yate_ivr_current !== null) { $init_id = false; Yate::SetLocal("id", IVR::ChannelID()); Yate::Install("chan.dtmf", 100, "targetid", IVR::ChannelID()); Yate::Install("chan.notify", 100, "targetid", IVR::ChannelID()); } if ($ev && $ev->type == "incoming") { if ($ev->handled && $ev->name == "call.execute") { $ev->SetParam("targetid", IVR::ChannelID()); } $ev->Acknowledge(); } } IVR::CleanupIVR(); } }