function people_dial(&$call) { global $db; $extension = $call->get_extension(); $callerId = $call->get_cid(); $callerIdFull = $call->get_cidFull(); $query = "select Context " . " from AsteriskGoto " . " where Extension = {$extension} "; $query = $db->query($query); check_db($query); if ($row = $query->fetchRow(DB_FETCHMODE_ORDERED)) { // ceci boycott complètement le fonctionnement d'obelisk agi_goto($row[0]); } return agi_notFound($call); }
function geo_dial(&$call) { global $db; $extension = $call->get_extension(); $callerId = $call->get_cid(); $callerIdFull = $call->get_cidFull(); $query = "select destination.People_Extension " . "from Geographical_Alias as caller, " . " \tGeographical_Alias as destination, " . "\tGeographical_Group as grp " . "where caller.People_Extension = '" . $callerId . "' " . " and caller.Geographical_Group_ID = grp.ID " . " and grp.ID = destination.Geographical_Group_ID " . " and destination.Extension = '" . $extension . "' "; $query = $db->query($query); check_db($query); if (!($row = $query->fetchRow(DB_FETCHMODE_ORDERED))) { agi_log(DEBUG_ERR, "geo/dial.inc.php: extension : " . $extension . " not found"); return agi_notFound($call); } agi_log(DEBUG_INFO, "geo/dial.inc.php: {$extension} -> " . "People : " . $row[0]); $call->set_extension($row[0]); include_once 'modules/people/dial.inc.php'; return people_dial($call); }
function people_dial(&$call) { global $db; $extension = $call->get_extension(); $callerId = $call->get_cid(); $callerIdFull = $call->get_cidFull(); $query = "select ChanType, username, VoIPAccount.ID " . " from People, VoIPAccount, VoIPChannel " . " where People.Extension = {$extension} " . " and VoIPAccount.People_Extension = {$extension} " . " and VoIPAccount.VoIPChannel_ID = VoIPChannel.ID " . " and VoIPAccount.Enable = true "; $query = $db->query($query); check_db($query); if ($row = $query->fetchRow(DB_FETCHMODE_ORDERED)) { $dialStr = $row[0] . "/" . $row[1] . "-" . $row[2]; while ($row = $query->fetchRow(DB_FETCHMODE_ORDERED)) { $dialStr .= "&"; $dialStr .= $row[0] . "/" . $row[1] . "-" . $row[2]; } agi_log(DEBUG_DEBUG, "people_dial(): {$callerId} : " . "{$extension} -> '{$dialStr}'"); return agi_call($call, $dialStr, "r", 0, 0); } return agi_notFound($call); }
function sample_dial(&$call) { agi_log(DEBUG_ERR, "sample/dial.inc.php: Not yet implemented"); return agi_notFound($call); }
/** * agi_dial - write asterisk AGI code in order to call $extension as $callerID * using the table dialplan * * PRE: $call : a complete ObjCall * * POST: look the extension & the caller Id in the database in order to write * (agi_write) the AGI script * si l'extension n'est pas joignable ^ annonce vocale ^ * return a negative number. * v joingnable ^ ouverture de communication ^ * return a positive value (incl. 0) which is * the price of the call * joignable = existe, traitée par un module et que le caller a le * droit de joindre */ function agi_dial(&$call) { global $db; $extension = $call->get_extension(); $callerId = $call->get_cid(); $callerIdFull = $call->get_cidFull(); agi_log(DEBUG_DEBUG, "agi_dial({$extension}, {$callerId}, " . "{$callerIdFull})"); // on recherche a quel module appartient l'extension et si le // responsable peut joindre cette extension $query = "Select name " . "from Extension, Module, Rights, Grp_has_People " . "where ((ext_end is not null and " . "extension_type_comp(extension, '{$extension}') <= 0 " . "and extension_type_comp(ext_end, '{$extension}') >= 0) or " . " (ext_end is null and extension = '{$extension}'))" . " and Extension.Module_ID = Module.ID " . "and Grp_has_People.People_Extension = " . $call->get_responsable() . " " . "and Grp_has_People.Grp_ID = Rights.Grp_ID " . "and Rights.Module_Action_ID = 0" . "and Rights.Module_ID = Module.ID"; $query = $db->query($query); check_db($query); if ($row = $query->fetchRow(DB_FETCHMODE_ORDERED)) { agi_log(DEBUG_INFO, "agi_dial(): extension " . $extension . " is handeled by : " . $row[0]); // on tente d'inclure le dial du module en question include 'modules/' . $row[0] . '/dial.inc.php'; // on génère le nom de la fonction dial $fct = $row[0] . '_dial'; return $fct($call); agi_log(DEBUG_INF, "agi_obelisk.php: DONE"); } else { return agi_notFound($call); } }
function outside_dial(&$call) { global $db; // 1°) trouver à quel réseau appartient l'extension $net = outside_getNetworkId($call); agi_log(DEBUG_DEBUG, 'outside_dial() : ' . $call->get_extension() . " -> {$net}"); if ($net < 0) { return agi_notFound($call); } // 2°) faut-il annoncer le prix à l'utilisateur ? // faut-il continuer plus cher ? $query = "select P.Announce, P.AskHigherCost " . " from People_PrePay_Settings as P " . " where People_Extension = " . $call->get_responsable(); $query = $db->query($query); check_db($query); if (!($row = $query->fetchRow(DB_FETCHMODE_ORDERED))) { // not found : paramètre par défaut : $askHigher = false; $announce = true; agi_log(DEBUG_INFO, "outside_dial() : account not found"); } else { $askHigher = $row[1]; $announce = $row[0]; } agi_log(DEBUG_DEBUG, "outside_dial() : {$announce} - {$askHigher}"); // 3°) récupérer la liste des providers et leur prix $query = "select N.Name, N.channel, P.ConnectionPrice, P.Price, " . " P.RmDigits, P.AddDigits, N.DialOpts " . " from NetworkProvider as N, Price as P, " . "\t NetworkTimeZone_details as T " . " where P.Network_ID = {$net} " . " and P.NetworkProvider_ID = N.ID " . " and P.NetworkTimeZone_ID = T.NetworkTimeZone_ID " . " and (" . date("i") . " between start_min and end_min )" . " and (" . date("G") . " between start_hour and end_hour )" . " and (" . date("n") . " between start_month and end_month )" . " and (" . date("j") . " between start_dom and end_dom )" . " and (" . date("w") . " between start_dow and end_dow )" . " order by P.Price, P.ConnectionPrice "; $query = $db->query($query); check_db($query); /* 0 : name * 1 : channel * 2 : priceConn * 3 : price/min * 4 : RmDigits * 5 : AddDigits * 6 : DialOpts */ if ($query->numRows() == 0) { return agi_notFound($call); } $provider = $query->fetchRow(DB_FETCHMODE_ORDERED); // 4°) on tente d'appeler $isFirst = true; // première tentative au prix le plus bas while (($isFirst || $askHigher) && $provider != NULL) { $price = $provider[3]; // 5°) on annonce au besoin : if ($announce) { agi_play_soundSet(SOUNDSET_PRICE_ANNOUNCE, ""); agi_sayNumber(ceil($price * 100)); agi_play_soundSet(SOUNDSET_CURRENCY, ""); } // on teste l'un à la suite de l'autre tout les providers // qui ont le même prix d'appel while ($provider[3] == $price && $provider != NULL) { $callStr = $provider[1] . $provider[5] . substr($call->get_extension(), $provider[4]); agi_log(DEBUG_DEBUG, "outside_dial() : trying : {$callStr}"); $result = agi_call($call, $callStr, $provider[6], $provider[2], $provider[3], false); if ($result >= 0 || $call->get_lastTryStatus() != "CHANUNAVIL") { // succeed return $result; } $provider = $query->fetchRow(DB_FETCHMODE_ORDERED); } // annonce qu'il est impossible d'effectuer l'appel au prix // annoncé précédement agi_play_soundSet(SOUNDSET_UNAVAIL_AT_PRICE, ""); $first = false; // téléchargement du provider suivant $provider = $query->fetchRow(DB_FETCHMODE_ORDERED); } agi_logCall($call, 0, 0, "NOT ROUTABLE"); return -1; }