[Managed ENUM numbers with multiple mappings Adrian Georgescu **20070910082530] hunk ./provisioning_logic.phtml 114 + if (!class_exists($this->soapClass)) return ; + hunk ./provisioning_logic.phtml 718 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 1052 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 1316 + hunk ./provisioning_logic.phtml 1559 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 1884 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 2240 + hunk ./provisioning_logic.phtml 2286 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 2344 + $_url = $this->url.sprintf("&service=%s&action=Delete&number_filter=%s&tld_filter=%s&mapto_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($number->id->number), + urlencode($number->id->tld), + urlencode($_mapping->mapto) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['number_filter'] == $number->id->number && + $_REQUEST['tld_filter'] == $number->id->tld && + $_REQUEST['mapto_filter'] == $_mapping->mapto) { + $_url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + hunk ./provisioning_logic.phtml 2363 - $_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 2409 + %s hunk ./provisioning_logic.phtml 2415 - $_mapping->priority + $_mapping->priority, + $_url, + $actionText hunk ./provisioning_logic.phtml 2419 - hunk ./provisioning_logic.phtml 2441 + function getLastNumber() { + + // Filter + $filter=array('number' => '' + ); + // Range + $range=array('start' => 0, + 'count' => 1 + ); + + // Order + if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'changeDate'; + if (!$this->sorting['sortOrder']) $this->sorting['sortOrder'] = 'DESC'; + + $orderBy = array('attribute' => $this->sorting['sortBy'], + 'direction' => $this->sorting['sortOrder'] + ); + + // Compose query + $Query=array('filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclient->getNumbers($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + + if ($result->total) { + $number = array('number' => $result->numbers[0]->id->number, + 'tld' => $result->numbers[0]->id->tld, + 'mappings' => $result->numbers[0]->mappings + ); + + return $number; + } + + } + + return false; + } + hunk ./provisioning_logic.phtml 2544 - $function=array('commit' => array('name' => 'deleteNumber', - 'parameters' => array($enum_id), - 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been deleted',$this->filters['number'],$this->filters['tld']) - ) - ) + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getNumber($enum_id); hunk ./provisioning_logic.phtml 2547 - ); + if (!PEAR::isError($result)) { + // the number exists and we make an update + $result_new=$result; hunk ./provisioning_logic.phtml 2551 - if ($this->SOAPEngine->execute($function)) { - unset($this->filters); + if (count($result->mappings) > 1) { + foreach ($result->mappings as $_mapping) { + if ($_mapping->mapto != $this->filters['mapto']) { + $mappings_new[]=array('type' => $_mapping->type, + 'mapto' => $_mapping->mapto, + 'ttl' => $_mapping->ttl, + 'priority' => $_mapping->priority + ); + } + } + + $result_new->mappings=$mappings_new; + + $function=array('commit' => array('name' => 'updateNumber', + 'parameters' => array($result_new), + 'logs' => array('success' => sprintf('

ENUM mapping %s has been deleted',$this->filters['mapto']))), + 'rollback' => array('name' => 'updateNumber', + 'parameters' => array($result)) + ); + + } else { + $function=array('commit' => array('name' => 'deleteNumber', + 'parameters' => array($enum_id), + 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been deleted',$this->filters['number'],$this->filters['tld']))), + 'rollback' => array('name' => 'addNumber', + 'parameters' => array($result)) + ); + } + + $this->SOAPEngine->execute($function); + + unset($this->filters); + + } else { + return false; hunk ./provisioning_logic.phtml 2643 + printf (" Prio: "); hunk ./provisioning_logic.phtml 2687 - $tld = trim($_REQUEST['tld']); - $number = trim($_REQUEST['number']); + $tld = trim($_REQUEST['tld']); + $number = trim($_REQUEST['number']); hunk ./provisioning_logic.phtml 2721 + if (!trim($_REQUEST['priority'])) { + $priority=5; + } else { + $priority=intval(trim($_REQUEST['priority'])); + } + hunk ./provisioning_logic.phtml 2743 + if (!$_value) { + $lastNumber=$this->getLastNumber(); + foreach($lastNumber['mappings'] as $_mapping) { + if ($_mapping->type == trim($_REQUEST['type'])) { + if (preg_match("/^(.*)@(.*)$/",$_mapping->mapto,$m)) { + $_value = $number.'@'.$m[2]; + break; + } + } + } + } + hunk ./provisioning_logic.phtml 2765 - 'mappings' => array(array('type' => trim($_REQUEST['type']), - 'mapto' => $mapto, - 'ttl' => intval(trim($_REQUEST['ttl'])) + 'mappings' => array(array('type' => trim($_REQUEST['type']), + 'mapto' => $mapto, + 'ttl' => $ttl, + 'priority' => $priority hunk ./provisioning_logic.phtml 2794 - printf ("

Error: ENUM number %s already exists",$number); + $result_new=$result; + foreach ($result->mappings as $_mapping) { + $mappings_new[]=array('type' => $_mapping->type, + 'mapto' => $_mapping->mapto, + 'ttl' => $_mapping->ttl, + 'priority' => $_mapping->priority + ); + + if ($_mapping->mapto == $mapto) { + printf ("

Info: ENUM mapping %s for number %s already exists",$mapto,$number); + return true; + break; + } + } + + $mappings_new[]=array('type' => trim($_REQUEST['type']), + 'mapto' => $mapto, + 'ttl' => intval(trim($_REQUEST['ttl'])), + 'priority'=> intval(trim($_REQUEST['priority'])), + + ); + // add mapping + $result_new->mappings=$mappings_new; + + $function=array('commit' => array('name' => 'updateNumber', + 'parameters' => array($result_new), + 'logs' => array('success' => sprintf('

ENUM number +%s under %s has been updated',$number,$tld))), + 'rollback' => array('name' => 'updateNumber', + 'parameters' => array($result)) + ); + + $this->SOAPEngine->execute($function); + hunk ./provisioning_logic.phtml 2939 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 4292 - if ($this->rows && $_REQUEST['action'] != 'PerformActions') { + if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { hunk ./provisioning_logic.phtml 4424 +} + +class recordsGenerator { + function recordsGenerator() { + } + + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + $this->printHiddenFormElements(); + + print " + + +
+ "; + + print " + + "; + + printf (" Name: "); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups(); + + printf (" Group: "); + + // Compose query + $Query=array('filter' => array('name'=>''), + 'orderBy' => array('attribute' => 'name', + 'direction' => 'ASC' + ), + 'range' => array('start' => 0, + 'count' => 1000) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + $result = $this->SOAPEngine->soapclient->getGatewayGroups($Query); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + printf ("

Error from %s: %s (%s): %s",$this->SOAPEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + return false; + } else { + print ""); + } + printf (" Address: "); + printf (" Strip: "; + printf (" Prefix: "); + + print " +

+ "; + print " +
+ "; + } +