[Added updateDomain function Adrian Georgescu **20071209032129] hunk ./debian/changelog 1 -cdrtool (5.4) unstable; urgency=low +cdrtool (6.0) unstable; urgency=low hunk ./debian/changelog 15 - * Must apply database structure changes from setup/mysql/alter_tables.mysql + * Must apply database structure changes from setup/mysql/alter_tables.mysql + * NGNPro client completed hunk ./debian/changelog 18 - -- Adrian Georgescu Thu, 22 Nov 2007 10:51:01 +0100 + -- Adrian Georgescu Sun, 09 Dec 2007 04:20:50 +0100 hunk ./provisioning/ngnpro_client_lib.phtml 1268 + var $FieldsAdminOnly=array( + 'reseller' => array('type'=>'integer'), + ); + + var $Fields=array( + 'customer' => array('type'=>'integer') + ); hunk ./provisioning/ngnpro_client_lib.phtml 1493 - if ($this->version > 1) { + if ($this->rows == 1 && $this->version > 1) { + $this->showRecord($domain); + } else { hunk ./provisioning/ngnpro_client_lib.phtml 1660 - } + } + + function getRecord($domain) { + if ($this->version < 2) return false; + + // Filter + $filter=array( + 'domain' => $domain + ); + + // Range + $range=array('start' => 0, + 'count' => 1 + ); + + $orderBy = array('attribute' => 'changeDate', + 'direction' => 'DESC' + ); + + // Compose query + $Query=array('filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); + dprint_r($Query); + + // Insert credetials + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + // Call function + $result = $this->SOAPEngine->soapclient->getDomains($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->domains[0]){ + return $result->domains[0]; + } else { + return false; + } + } + } + + function showRecord($domain) { + + print ""; + print " + +
+ "; + printf ("",$_SERVER['PHP_SELF']); + print ""; + + print " + "; + + if ($this->adminonly) { + + foreach (array_keys($this->FieldsAdminOnly) as $item) { + if ($this->FieldsAdminOnly[$item]['name']) { + $item_name=$this->FieldsAdminOnly[$item]['name']; + } else { + $item_name=ucfirst($item); + } + + if ($this->FieldsAdminOnly[$item]['type'] == 'text') { + printf (" + + + ", + $item_name, + $item, + $domain->$item + ); + } else { + printf (" + + + ", + $item_name, + $item, + $domain->$item + ); + } + } + } + + foreach (array_keys($this->Fields) as $item) { + if ($this->Fields[$item]['name']) { + $item_name=$this->Fields[$item]['name']; + } else { + $item_name=ucfirst($item); + } + + if ($this->Fields[$item]['type'] == 'text') { + printf (" + + + ", + $item_name, + $item, + $domain->$item + ); + } else { + printf (" + + + ", + $item_name, + $item, + $domain->$item + ); + } + } + + printf ("domain); + $this->printFiltersToForm(); + $this->printHiddenFormElements(); + + print ""; + print " +
+
%s
%s
%s
%s
+ "; + } + + function updateRecord () { + //print "

Updating domain ..."; + + if (!$_REQUEST['domain_filter']) return false; + + if (!$domain = $this->getRecord($_REQUEST['domain_filter'])) { + return false; + } + + $domain_old=$domain; + + foreach (array_keys($this->Fields) as $item) { + $var_name=$item.'_form'; + //printf ("
%s=%s",$var_name,$_REQUEST[$var_name]); + if ($this->Fields[$item]['type'] == 'integer') { + $domain->$item = intval($_REQUEST[$var_name]); + } else { + $domain->$item = trim($_REQUEST[$var_name]); + } + } + + if ($this->adminonly) { + foreach (array_keys($this->FieldsAdminOnly) as $item) { + $var_name=$item.'_form'; + //printf ("
%s=%s",$var_name,$_REQUEST[$var_name]); + if ($this->FieldsAdminOnly[$item]['type'] == 'integer') { + $domain->$item = intval($_REQUEST[$var_name]); + } else { + $domain->$item = trim($_REQUEST[$var_name]); + } + } + } + + $function=array('commit' => array('name' => 'updateDomain', + 'parameters' => array($domain), + 'logs' => array('success' => sprintf('

Domain %s has been updated',$domain->domain))), + 'rollback' => array('name' => 'updateDomain', + 'parameters' => array($domain_old)) + ); + + return $this->SOAPEngine->execute($function); + + } hunk ./provisioning/ngnpro_soap_library.phtml 51 + } + function &updateDomain($domain) { + // domain is a ComplexType SipDomain, + //refer to wsdl for more info + $domain =& new SOAP_Value('domain','{urn:AGProjects:NGNPro}SipDomain',$domain); + return $this->call("updateDomain", + $v = array("domain"=>$domain), + array('namespace'=>'urn:AGProjects:NGNPro:Sip', + 'soapaction'=>'', + 'style'=>'rpc', + 'use'=>'encoded' )); hunk ./version 1 -5.4 +6.0