function addgroup($account, $grplist, $grpstrategy, $grptime, $grppre, $goto, $callerannounce, $alertinfo, $ringing, $description) { global $db; $devices = group_list(); if (is_array($devices)) { foreach ($devices as $device) { if ($device[0] === $account) { echo "<script>javascript:alert('" . _("This RingGroup [") . $device[0] . "] is already in use" . "');</script>"; return false; } } } if ($ringing == 'Ring' || empty($ringing)) { $ringing = '${DIAL_OPTIONS}'; } else { // We need the DIAL_OPTIONS variable $sops = sql("SELECT value from globals where variable='DIAL_OPTIONS'", "getRow"); $ringing = "m(" . $ringing . ")" . str_replace('r', '', $sops[0]); } $addarray = array('ext-group', $account, '1', 'Macro', 'rg-group,' . $grpstrategy . ',' . $grptime . ',' . $grppre . ',' . $grplist . ',' . $callerannounce . ',' . $alertinfo . ',' . $ringing, '' . $description . '', '0'); addextensions($addarray); setGoto($account, 'ext-group', '2', $goto, 0); return true; }
function addIncoming($incoming) { global $db; foreach ($incoming as $key => $val) { ${$key} = addslashes($val); } // create variables from request $existing = getIncomingInfo($extension, $cidnum, $channel); if (empty($existing)) { $destination = buildActualGoto($incoming, 0); $destination_only_numba = explode(",", $destination); if ($destination_only_numba[1] == "s") { $destination_only_numba = ""; } $alertinfofix = mysql_escape_string($alertinfo); $sql = "INSERT INTO incoming (cidnum,extension,destination,faxexten,faxemail,faxemail2,answer,wait,CIDName,privacyman,alertinfo,channel,ringing,addprefix,phonebook) values ('{$cidnum}','{$extension}','{$destination}','{$faxexten}','{$faxemail}','{$faxemail2}','{$answer}','{$wait}','{$CIDName}','{$privacyman}','{$alertinfofix}','{$channel}','{$ringing}','{$ADDPrefix}','{$phonebook}')"; $results = $db->query($sql); if (DB::IsError($result)) { die($result->getMessage()); } $extension = empty($extension) ? "s" : $extension; $account = $extension . (empty($cidnum) ? "" : "/" . $cidnum); $i = 1; $catchall = false; if (empty($channel)) { $context = "ext-did"; } else { $context = "macro-from-zaptel-{$channel}"; if (!isset($zapchan[$channel])) { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'NoOp', $context . ' with DID = ${DID}', $destination_only_numba[1], '0'); $zapchan[$channel] = "unfinished"; } } $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Set', 'FROM_DID=' . $account, $destination_only_numba[1], '0'); if ($ringing == "CHECKED") { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Ringing', '', $destination_only_numba[1], '0'); } if ($extension == "s" && $context == "ext-did") { $catchaccount = "_X." . (empty($cidnum) ? "" : "/" . $cidnum); if ($catchaccount == "_X.") { $catchall = true; $addarray[] = array($context, $catchaccount, "1", 'NoOp', 'Catch-All DID Match - Found ${EXTEN} - You probably want a DID for this.', $destination_only_numba[1], '0'); $addarray[] = array($context, $catchaccount, "2", 'Goto', 'ext-did,s,1', $destination_only_numba[1], '0'); } } if ($faxexten != "default") { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Set', 'FAX_RX=' . $faxexten, $destination_only_numba[1], '0'); } if (!empty($faxemail)) { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Set', 'FAX_RX_EMAIL=' . $faxemail, $destination_only_numba[1], '0'); $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Set', 'FAX_RX_EMAIL2=' . $faxemail2, $destination_only_numba[1], '0'); } if ($answer == "1") { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Answer', '', $destination_only_numba[1], '0'); $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Wait', $wait, $destination_only_numba[1], '0'); } if (!empty($CIDName)) { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Set', 'CALLERID(name)=' . $CIDName, $destination_only_numba[1], '0'); } if ($phonebook == "CHECKED") { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Macro', 'inboundphonebook', $destination_only_numba[1], '0'); } if ($ADDPrefix != "") { $xcounter = $i; $true = $xcounter + 1; $false = $xcounter + 2; $addarray[] = array($context, $account, sprintf('%02s', $i++), 'GotoIf', '$[$[${LEN(${CALLERID(num)})} > 2] & $["${CALLERID(num)}" != "anonymous" ] & $["${CALLERID(num)}" != "unknown" ]]?' . $true . ':' . $false, $destination_only_numba[1], '0'); $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Set', 'CALLERID(number)=' . $ADDPrefix . '${CALLERID(number)}', $destination_only_numba[1], '0'); } if ($privacyman == "1") { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Macro', 'privacy-mgr', $destination_only_numba[1], '0'); } if (!empty($alertinfo)) { $addarray[] = array($context, $account, sprintf('%02s', $i++), 'SIPAddHeader', '"' . $alertinfo . '"', $destination_only_numba[1], '0'); } $zapchan[$channel] = "set"; $addarray[] = array($context, $account, sprintf('%02s', $i++), 'Goto', $destination, $destination_only_numba[1], '0'); foreach ($addarray as $add) { addextensions($add); } } else { echo "<script>javascript:alert('" . _("A route for this DID/CID already exists!") . "')</script>"; } }