/** * Processa dados crus da tabela no banco para instanciação de objetos de * ramais. * * @param Object $data Resultado de um select com todas as colunas no banco * de dados dos ramais. * @return Snep_Exten ramal criado a partir dos dados. */ private function processExten($data) { $tech = substr($data->canal, 0, strpos($data->canal, '/')); if ($tech == "SIP" || $tech == "IAX2") { $config = array("username" => $data->name, "secret" => $data->secret, "allow" => $data->allow, "type" => $data->type, "qualify" => $data->qualify, "dtmfmode" => $data->dtmfmode, "nat" => $data->nat, "call-limit" => $data->{'call-limit'}); if ($tech == "SIP") { $interface = new PBX_Asterisk_Interface_SIP($config); } else { $interface = new PBX_Asterisk_Interface_IAX2($config); } } else { if ($tech == "VIRTUAL") { $trunk = PBX_Trunks::get(substr($data->canal, strpos($data->canal, '/') + 1)); $interface = new PBX_Asterisk_Interface_VIRTUAL(array("channel" => $trunk->getInterface()->getCanal() . "/" . $exten_id)); } else { if ($tech == "MANUAL") { $interface = new PBX_Asterisk_Interface_VIRTUAL(array("channel" => substr($data->canal, strpos($data->canal, '/') + 1))); } else { if ($tech == "KHOMP") { $khomp_id = substr($data->canal, strpos($data->canal, '/') + 1); $khomp_board = substr($khomp_id, 1, strpos($khomp_id, 'c') - 1); $khomp_channel = substr($khomp_id, strpos($khomp_id, 'c') + 1); $interface = new PBX_Asterisk_Interface_KHOMP(array("board" => $khomp_board, "channel" => $khomp_channel)); } else { throw new Exception("Tecnologia {$tech} desconhecida ou invalida."); } } } } $exten = new Snep_Exten($data->name, $data->password, $data->callerid, $interface); $exten->setChannel($data->canal); $exten->setGroup($data->group); if ($data->authenticate) { $exten->lock(); } if ($data->dnd) { $exten->DNDEnable(); } if ($data->sigame != "") { $exten->setFollowMe($data->sigame); } if (is_numeric($data->pickupgroup)) { $exten->setPickupGroup($data->pickupgroup); } if ($data->usa_vc == 'yes') { $exten->setMailBox($data->mailbox); $exten->setEmail($data->email); } if ($data->time_total != NULL) { $exten->setTimeTotal($data->time_total); $exten->setCtrlType($data->time_chargeby); } return $exten; }