diff --git a/library/NGNPro/Records/TrustedPeers.php b/library/NGNPro/Records/TrustedPeers.php index c7b364b..4e901f8 100644 --- a/library/NGNPro/Records/TrustedPeers.php +++ b/library/NGNPro/Records/TrustedPeers.php @@ -1,498 +1,602 @@ array('type'=>'boolean', 'name' => 'MS Teams'), - 'prepaid' => array('type'=>'boolean'), - 'tenant' => array('type'=>'string'), - 'callLimit' => array('type'=>'integer', 'name' => 'Capacity'), - 'blocked' => array('type'=>'integer') - ); - var $Fields=array( - 'description' => array('type'=>'string'), - 'authToken' => array('type'=>'string', 'name' => 'Authentication token') - ); + var $FieldsAdminOnly = array( + 'msteams' => array('type'=>'boolean', 'name' => 'MS Teams'), + 'prepaid' => array('type'=>'boolean'), + 'tenant' => array('type'=>'string'), + 'callLimit' => array('type'=>'integer', 'name' => 'Capacity'), + 'blocked' => array('type'=>'integer') + ); + var $Fields = array( + 'description' => array('type'=>'string'), + 'authToken' => array('type'=>'string', 'name' => 'Authentication token') + ); public function __construct($SoapEngine) { - $this->filters = array('ip' => trim($_REQUEST['ip_filter']), - 'tenant' => trim($_REQUEST['tenant_filter']), - 'description' => trim($_REQUEST['description_filter']), - 'msteams' => trim($_REQUEST['msteams_filter']) - ); + $this->filters = array( + 'ip' => trim($_REQUEST['ip_filter']), + 'tenant' => trim($_REQUEST['tenant_filter']), + 'description' => trim($_REQUEST['description_filter']), + 'msteams' => trim($_REQUEST['msteams_filter']) + ); parent::__construct($SoapEngine); - $this->sortElements=array( - 'changeDate' => 'Change date', - 'description' => 'Description', - 'ip' => 'Address' - ); + $this->sortElements = array( + 'changeDate' => 'Change date', + 'description' => 'Description', + 'ip' => 'Address' + ); } - function listRecords() { + function listRecords() + { $this->showSeachForm(); // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); // Filter - $filter=array('ip' => $this->filters['ip'], - 'description' => $this->filters['description'], - 'tenant' => $this->filters['tenant'], - 'msteams' => 1 == intval($this->filters['msteams']) - ); + $filter = array( + 'ip' => $this->filters['ip'], + 'description' => $this->filters['description'], + 'tenant' => $this->filters['tenant'], + 'msteams' => 1 == intval($this->filters['msteams']) + ); // Range - $range=array('start' => intval($this->next), - 'count' => intval($this->maxrowsperpage) - ); + $range = array( + 'start' => intval($this->next), + 'count' => intval($this->maxrowsperpage) + ); // Order if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'description'; if (!$this->sorting['sortOrder']) $this->sorting['sortOrder'] = 'ASC'; - $orderBy = array('attribute' => $this->sorting['sortBy'], - 'direction' => $this->sorting['sortOrder'] - ); + $orderBy = array( + 'attribute' => $this->sorting['sortBy'], + 'direction' => $this->sorting['sortOrder'] + ); // Compose query - $Query=array('filter' => $filter, - 'orderBy' => $orderBy, - 'range' => $range - ); + $Query = array( + 'filter' => $filter, + 'orderBy' => $orderBy, + 'range' => $range + ); // Call function $this->log_action('getTrustedPeers'); - $result = $this->SoapEngine->soapclient->getTrustedPeers($Query); + $result = $this->SoapEngine->soapclient->getTrustedPeers($Query); - if ((new PEAR)->isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - $log=sprintf("SOAP request error from %s: %s (%s): %s",$this->SoapEngine->SOAPurl,$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - syslog(LOG_NOTICE, $log); + if ($this->checkLogSoapError($result, true)) { return false; } else { $this->rows = $result->total; if ($this->rows && $_REQUEST['action'] != 'PerformActions' && $_REQUEST['action'] != 'Delete') { $this->showActionsForm(); } - print " -
Id - | Owner | -Trusted peer | -Prepaid | -Capacity | -MS Teams | -Tenant | -Description | -Blocked | -Change date | -Actions | -
Id + | Owner | +Trusted peer | +Prepaid | +Capacity | +MS Teams | +Tenant | +Description | +Blocked | +Change date | +Actions | +
%s | -%s | -%s | -%s | -%s | -%s | -%s | -%s | -%s | -%s | -%s | -
%s | +%s | +%s | +%s | +%s | +%s | +%s | +%s | +%s | +%s | +%s | +
-
- ";
-
- print "
-
- ";
+ printf("
+
+END;
$this->showCustomerTextBox();
if ($this->filters['msteams']) {
$checked = 'checked';
} else {
$checked = '';
}
- printf ("
- Address ");
- printf (" Call limit ");
- printf (" Description ");
- printf (" Tenant ", $this->filters['tenant']);
- printf (" MS Teams ", $checked);
+ print <<< END
+
+ Address
+
+
+ Call limit
+
+
+ Description
+
+END;
+ printf(
+ "
+
+ Tenant
+
+ ",
+ $this->filters['tenant']
+ );
+ printf(
+ "
+
+ MS Teams
+
+ ",
+ $checked
+ );
$this->printHiddenFormElements();
- print " |
Error: Missing IP or description. "); + print "
Error: Missing IP or description. "; return false; } - $peer=array( - 'ip' => $ipaddress, - 'description' => $description, - 'callLimit' => intval($callLimit), - 'msteams' => 1 == $msteams, - 'tenant' => $tenant, - 'blocked' => 0, - 'owner' => intval($_REQUEST['owner']), - 'customer' => intval($customer), - 'reseller' => intval($reseller) - ); - - $function=array('commit' => array('name' => 'addTrustedPeer', - 'parameters' => array($peer), - 'logs' => array('success' => sprintf('Trusted peer %s has been added',$ipaddress))) - ); - - return $this->SoapEngine->execute($function,$this->html); + $peer = array( + 'ip' => $ipaddress, + 'description' => $description, + 'callLimit' => intval($callLimit), + 'msteams' => 1 == $msteams, + 'tenant' => $tenant, + 'blocked' => 0, + 'owner' => intval($_REQUEST['owner']), + 'customer' => intval($customer), + 'reseller' => intval($reseller) + ); + + $function = array( + 'commit' => array( + 'name' => 'addTrustedPeer', + 'parameters' => array($peer), + 'logs' => array( + 'success' => sprintf('Trusted peer %s has been added', $ipaddress) + ) + ) + ); + + return $this->SoapEngine->execute($function, $this->html); } - function updateRecord() { - list($customer,$reseller)=$this->customerFromLogin($dictionary); + function updateRecord() + { + list($customer, $reseller)=$this->customerFromLogin($dictionary); if (!strlen($this->filters['ip'])) { print "
Error: missing peer address. "; return false; } - $peer=array( - 'ip' => $this->filters['ip'], - 'description' => $_REQUEST['description_form'], - 'authToken' => $_REQUEST['authToken_form'], - 'tenant' => $_REQUEST['tenant_form'], - 'callLimit' => intval($_REQUEST['callLimit_form']), - 'prepaid' => 1 == $_REQUEST['prepaid_form'], - 'blocked' => intval($_REQUEST['blocked_form']), - 'msteams' => 1 == $_REQUEST['msteams_form'], - 'customer' => intval($customer), - 'reseller' => intval($reseller) - ); - - $function=array('commit' => array('name' => 'updateTrustedPeer', - 'parameters' => array($peer), - 'logs' => array('success' => sprintf('Trusted peer %s has been updated',$this->filters['ip']))) - ); - - return $this->SoapEngine->execute($function,$this->html); + $peer = array( + 'ip' => $this->filters['ip'], + 'description' => $_REQUEST['description_form'], + 'authToken' => $_REQUEST['authToken_form'], + 'tenant' => $_REQUEST['tenant_form'], + 'callLimit' => intval($_REQUEST['callLimit_form']), + 'prepaid' => 1 == $_REQUEST['prepaid_form'], + 'blocked' => intval($_REQUEST['blocked_form']), + 'msteams' => 1 == $_REQUEST['msteams_form'], + 'customer' => intval($customer), + 'reseller' => intval($reseller) + ); + + $function = array( + 'commit' => array( + 'name' => 'updateTrustedPeer', + 'parameters' => array($peer), + 'logs' => array( + 'success' => sprintf('Trusted peer %s has been updated', $this->filters['ip']) + ) + ) + ); + + return $this->SoapEngine->execute($function, $this->html); } - function deleteRecord($dictionary=array()) { + function deleteRecord($dictionary = array()) + { if (!$dictionary['confirm'] && !$_REQUEST['confirm']) { print "
Please press on Confirm to confirm the delete. "; return true; } if (!strlen($this->filters['ip'])) { print "
Error: missing IP address. "; return false; } - $function=array('commit' => array('name' => 'deleteTrustedPeer', - 'parameters' => array($this->filters['ip']), - 'logs' => array('success' => sprintf('Trusted peer %s has been deleted',$this->filters['ip']))) - ); + $function = array( + 'commit' => array( + 'name' => 'deleteTrustedPeer', + 'parameters' => array($this->filters['ip']), + 'logs' => array( + 'success' => sprintf('Trusted peer %s has been deleted', $this->filters['ip']) + ) + ) + ); unset($this->filters); - return $this->SoapEngine->execute($function,$this->html); + return $this->SoapEngine->execute($function, $this->html); } - function showSeachFormCustom() { + function showSeachFormCustom() + { if (intval($this->filters['msteams']) == 1) { $checked_msteams = 'checked'; } else { $checked_msteams = ''; } - printf ("