[Added more provisioning logic Adrian Georgescu **20070830165459] hunk ./cdrlib_ser.phtml 4274 - hunk ./cdrlib_ser.phtml 4313 - and traced_user = ''"; + and traced_user = '' order by id asc"; hunk ./provisioning_logic.phtml 138 - $this->getAllowedDomains(); hunk ./provisioning_logic.phtml 314 - // Insert credetials - $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); - $result = $this->SOAPEngine->soapclient->getDomains(); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - return false; - } else { - $this->allowedDomains=$result; - } hunk ./provisioning_logic.phtml 336 + $this->getAllowedDomains(); hunk ./provisioning_logic.phtml 406 + Action hunk ./provisioning_logic.phtml 442 + + $_url = $this->url.sprintf("&service=%s&action=Delete&number_filter=%s&tld_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($number->id->number), + urlencode($number->id->tld) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['number_filter'] == $number->id->number && + $_REQUEST['tld_filter'] == $number->id->tld) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + hunk ./provisioning_logic.phtml 470 + %s hunk ./provisioning_logic.phtml 482 - $number->info + $number->info, + $_url, + $actionText hunk ./provisioning_logic.phtml 531 - printf (" E.164 number: ",$this->filters['number']); - printf (" TLD: ",$this->filters['tld']); + printf (" E.164 number: ",$this->filters['number']); + printf (" TLD:"); + if ($this->allowedDomains) { + $selected_tld[$this->filters['tld_filter']]='selected'; + printf (" + "; + printf (" Number: +"); + printf (" Top level domain:"); + if (is_array($this->allowedDomains)) { + print ""; + } else { + print ""; + } + printf (" Service: "); + printf (" Map to: "); + + printf (" TTL: "); + printf (" Owner: "); + + print " + + + "; + print " + + "; + + $this->printHiddenFormElements(); + + print " + + + + "; + } + function getAllowedDomains() { + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclient->getRanges(); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + foreach($result as $range) { + if (in_array($range->id->tld,$this->allowedDomains)) continue; + $this->allowedDomains[]=$range->id->tld; + } + } + } + + function addRecord() { + $tld = trim($_REQUEST['tld']); + $number = trim($_REQUEST['number']); + + if (!strlen($tld) || !strlen($number)) { + printf ("

Error: Missing TLD or number. "); + return false; + } + + if (!trim($_REQUEST['ttl'])) { + $ttl=3600; + } else { + $ttl=intval(trim($_REQUEST['ttl'])); + } + + $enum_id=array('number' => $number, + 'tld' => $tld); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getNumber($enum_id); + + if (PEAR::isError($result)) { + $error_msg=$result->getMessage(); + $error_fault=$result->getFault(); + $error_code=$result->getCode(); + + if ($error_fault->detail->exception->errorcode == "3002") { + // addNumber() + $enum_number=array('id' => $enum_id, + 'owner' => intval(trim($_REQUEST['owner'])), + 'mappings' => array(array('type'=>trim($_REQUEST['type']), + 'mapto'=>trim($_REQUEST['mapto']), + 'ttl'=>intval(trim($_REQUEST['ttl'])) + ) + ) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->addNumber($enum_number); + + if (PEAR::isError($result)) { + $error_msg=$result->getMessage(); + $error_fault=$result->getFault(); + $error_code=$result->getCode(); + printf ("

Error1: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + dprint("SOAP addNumber() OK"); + } + + } else { + // other error is not allowed + printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } + } else { + // the number exists and we make an update + printf ("

Error: The number already exists"); + return 1; + } + } + hunk ./provisioning_logic.phtml 722 - $this->filters = array('number' => trim($_REQUEST['number_filter']), - 'tld' => trim($_REQUEST['tld_filter']), - 'type' => trim($_REQUEST['type_filter']), - 'mapto' => trim($_REQUEST['mapto_filter']), - 'owner' => trim($_REQUEST['owner_filter']) + $this->filters = array('prefix' => trim($_REQUEST['prefix_filter']), + 'tld' => trim($_REQUEST['tld_filter']) hunk ./provisioning_logic.phtml 747 - $this->rows = $result->total; + $this->rows = count($result); hunk ./provisioning_logic.phtml 763 - DNS name hunk ./provisioning_logic.phtml 769 + Action hunk ./provisioning_logic.phtml 787 - if (!$result->numbers[$i]) break; - - $number = $result->numbers[$i]; + $range = $result[$i]; hunk ./provisioning_logic.phtml 800 - $j=1; - foreach ($number->mappings as $_mapping) { - if ($j==1) { + $_url = $this->url.sprintf("&service=%s&action=Delete&prefix_filter=%s&tld_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($range->id->prefix), + urlencode($range->id->tld) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['prefix_filter'] == $range->id->prefix && + $_REQUEST['tld_filter'] == $range->id->tld) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } hunk ./provisioning_logic.phtml 825 - %s + %s hunk ./provisioning_logic.phtml 829 - $number->id->number, - $number->id->tld, - $this->tel2enum($number->id->number,$number->id->tld), - ucfirst($_mapping->type), - $_mapping->mapto, - $_mapping->ttl, - $_mapping->priority, - $number->owner, - $number->info - ); - } else { - printf(" - - - - - - %s - %s - %s - %s - - - ", - $bgcolor, - ucfirst($_mapping->type), - $_mapping->mapto, - $_mapping->ttl, - $_mapping->priority + $range->id->prefix, + $range->id->tld, + $range->ttl, + $range->minDigits, + $range->maxDigits, + $range->used, + $range->owner, + $range->info, + $_url, + $actionText hunk ./provisioning_logic.phtml 841 - } - $j++; - } - hunk ./provisioning_logic.phtml 859 - function showSeachFormCustom() { + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

Please press on Confirm to confirm the delete. "; + return 1; + } + + if (!strlen($this->filters['prefix']) || !strlen($this->filters['tld'])) { + print "

Error: missing ENUM range id "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); hunk ./provisioning_logic.phtml 872 + $rangeId=array('prefix'=>$this->filters['prefix'], + 'tld'=>$this->filters['tld']); + $result = $this->SOAPEngine->soapclient->deleteRange($rangeId); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

ENUM range %s under %s has been deleted. ",$this->filters['prefix'],$this->filters['tld']); + unset($this->filters); + return 1; + } hunk ./provisioning_logic.phtml 889 + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + printf (" Prefix: +"); + printf (" Top level domain: "); + printf (" TTL: "); + printf (" Min Digits: "); + printf (" Max Digits: "); + printf (" Owner: "); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $tld = trim($_REQUEST['tld']); + $prefix = trim($_REQUEST['prefix']); + + if (!strlen($tld) || !strlen($prefix)) { + printf ("

Error: Missing TLD or prefix. "); + return false; + } + + if (!trim($_REQUEST['ttl'])) { + $ttl=3600; + } else { + $ttl=intval(trim($_REQUEST['ttl'])); + } + $range=array( + 'id' => array('prefix' => $prefix, + 'tld' => $tld), + 'ttl' => $ttl, + 'minDigits' => intval(trim($_REQUEST['minDigits'])), + 'maxDigits' => intval(trim($_REQUEST['maxDigits'])), + 'owner' => intval($_REQUEST['owner']) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addRange($range); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + printf ("

Range %s under %s has been added. ",$prefix,$tld); + return 1; + } + } + + function showSeachFormCustom() { + /* + printf (" Prefix: ",$this->filters['prefix']); + printf (" TLD: ",$this->filters['tld']); + printf (" Owner: ",$this->filters['owner']); + */ + } hunk ./provisioning_logic.phtml 2232 - Caller Id + PSTN CLI + Quota hunk ./provisioning_logic.phtml 2313 + %s hunk ./provisioning_logic.phtml 2327 + $account->quota, hunk ./provisioning_logic.phtml 2548 + function getAllowedDomains() { + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains(); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + $this->allowedDomains=$result; + } + } + hunk ./provisioning_logic.phtml 2893 + function getAllowedDomains() { + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getDomains(); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error: %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + $this->allowedDomains=$result; + } + } + hunk ./provisioning_logic.phtml 3163 - SIP domain + Domain + Reseller hunk ./provisioning_logic.phtml 3212 + %s hunk ./provisioning_logic.phtml 3218 + $reseller,