[Added Add and Delete operations Adrian Georgescu **20070311134037] hunk ./provisioning.phtml 28 + +if ($_REQUEST['action']=='Add') $RECORDS->addRecord(); +if ($_REQUEST['action']=='Delete') $RECORDS->deleteRecord(); + hunk ./provisioning.phtml 206 + + if ($_REQUEST['action'] != 'Delete') $this->showAddForm(); + hunk ./provisioning.phtml 214 + function addRecord() { + } + + function deleteRecord() { + } + hunk ./provisioning.phtml 243 + function showAddForm() { + } + hunk ./provisioning.phtml 254 - print " Sort by: "; + //print " Sort "; hunk ./provisioning.phtml 268 + + function showTimezones() { + if (!$fp = fopen("timezones", "r")) { + print _("Failed to open timezone file."); + return false; + } + print ""; + } hunk ./provisioning.phtml 417 - + hunk ./provisioning.phtml 429 + $bgcolor, hunk ./provisioning.phtml 443 - + hunk ./provisioning.phtml 455 + $bgcolor, hunk ./provisioning.phtml 498 + $this->filters = array('ip' => trim($_REQUEST['ip_filter']) + ); hunk ./provisioning.phtml 535 - Max sessions hunk ./provisioning.phtml 537 + Action hunk ./provisioning.phtml 569 + $this->url .= sprintf("?service=%s&action=Delete&ip_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($peer->ip) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['ip_filter'] == $peer->ip) { + $this->url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + hunk ./provisioning.phtml 583 - - %s + hunk ./provisioning.phtml 590 + %s hunk ./provisioning.phtml 592 + $bgcolor, hunk ./provisioning.phtml 597 - $peer->maxSessions, hunk ./provisioning.phtml 598 - $peer->info + $peer->owner, + $this->url, + $actionText hunk ./provisioning.phtml 621 + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + printf("",$this->SOAPEngine->service); + print " + + +
+ "; + + print " + + "; + + printf (" IP address: "); + printf (" Description: "); + printf (" Owner: "); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $ipaddress = trim($_REQUEST['ipaddress']); + $description = trim($_REQUEST['description']); + $owner = trim($_REQUEST['owner']); + + if (!strlen($ipaddress) || !strlen($description)) { + printf ("

Error: Missing IP or description. "); + return false; + } + + $peer=array( + 'ip' => $ipaddress, + 'description' => $description, + 'owner' => intval($_REQUEST['owner']) + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addTrustedPeer($peer); + + 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 ("

Trusted peers %s has been added. ",$ipaddress); + return 1; + } + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

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

Error: missing IP address. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteTrustedPeer($this->filters['ip']); + + 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 ("

Trusted peer %s has been deleted. ",$this->filters['ip']); + unset($this->filters); + return 1; + } + } + hunk ./provisioning.phtml 821 + Action hunk ./provisioning.phtml 854 + $this->url .= sprintf("&service=%s&action=Delete&username_filter=%s&domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($account->id->username), + urlencode($account->id->domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['username_filter'] == $account->id->username && + $_REQUEST['domain_filter'] == $account->id->domain) { + $this->url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + hunk ./provisioning.phtml 870 + hunk ./provisioning.phtml 872 - + hunk ./provisioning.phtml 880 + %s hunk ./provisioning.phtml 883 - + $bgcolor, hunk ./provisioning.phtml 891 - $account->changeDate + $account->changeDate, + $this->url, + $actionText hunk ./provisioning.phtml 897 - hunk ./provisioning.phtml 910 - printf (" Username: ",$this->filters['username']); + printf (" Username: ",$this->filters['username']); hunk ./provisioning.phtml 922 - printf ("",$this->filters['domain']); + printf ("",$this->filters['domain']); + } + + printf (" Full name: ",$this->filters['fullname']); + } + + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

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

Error: missing SIP account username or domain. "; + return 0; + } + + $account=array('username' => $this->filters['username'], + 'domain' => $this->filters['domain'] + ); + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteAccount($account); + + 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 ("

SIP account %s@%s has been deleted. ",$this->filters['username'],$this->filters['domain']); + unset($this->filters); + return 1; hunk ./provisioning.phtml 958 + } + + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + printf("",$this->SOAPEngine->service); + print " + + +
+ "; hunk ./provisioning.phtml 971 - printf (" Full name: ",$this->filters['fullname']); + print " + + "; + + printf (" SIP: ",$_REQUEST['account']); + printf (" Pass: ",$_REQUEST['password']); + printf (" Name: ",$_REQUEST['fullname']); + printf (" Email: ",$_REQUEST['email']); + printf (" Owner: ",$_REQUEST['owner']); + print " TZ: "; + + global $CDRTool; + if ($_REQUEST['timezone']) { + $this->timezone=$_REQUEST['timezone']; + } else { + $this->timezone=$CDRTool['provider']['timezone']; + } + + $this->showTimezones(); + + print " + + "; + print " +
+ "; hunk ./provisioning.phtml 1005 + + function addRecord() { + $account_els = explode("@", trim($_REQUEST['account'])); + $name_els = explode(" ", trim($_REQUEST['fullname'])); + + if (!strlen($account_els[0]) || !strlen($account_els[1])) { + printf ("

Error: Missing SIP account username or domain. "); + return false; + } + + $account=array( + 'id' => array('username' => $account_els[0], + 'domain' => $account_els[1] + ), + 'firstName' => $name_els[0], + 'lastName' => $name_els[1], + 'password' => trim($_REQUEST['password']), + 'timezone' => trim($_REQUEST['timezone']), + 'email' => trim($_REQUEST['email']), + 'owner' => intval($_REQUEST['owner']) + ); + + //print_r($account); + + // check if domain exists + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addAccount($account); + + 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 ("

SIP account %s@%s has been added. ",$alias_els[0],$alias_els[1]); + return 1; + } + } + hunk ./provisioning.phtml 1050 - 'aliasUsername' => 'Alias username', + 'aliasUsername' => 'Alias user', hunk ./provisioning.phtml 1052 - 'taregtUsername' => 'Target username', + 'targetUsername' => 'Target user', hunk ./provisioning.phtml 1151 + Action hunk ./provisioning.phtml 1184 + $this->url .= sprintf("&service=%s&action=Delete&alias_username_filter=%s&alias_domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($alias->id->username), + urlencode($alias->id->domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['alias_username_filter'] == $alias->id->username && + $_REQUEST['alias_domain_filter'] == $alias->id->domain) { + $this->url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + hunk ./provisioning.phtml 1200 - + hunk ./provisioning.phtml 1205 + %s hunk ./provisioning.phtml 1208 - + $bgcolor, hunk ./provisioning.phtml 1214 - $alias->owner + $alias->owner, + $this->url, + $actionText hunk ./provisioning.phtml 1233 + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

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

Error: missing SIP alias username or domain. "; + return 0; + } + + $alias=array('username' => $this->filters['aliasUsername'], + 'domain' => $this->filters['aliasDomain'] + ); + + //print_r($alias); + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteAlias($alias); + + 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 ("

SIP alias %s@%s has been deleted. ",$this->filters['aliasUsername'],$this->filters['aliasDomain']); + unset($this->filters); + $this->recordDeleted=1; + return 1; + } + } + hunk ./provisioning.phtml 1268 - printf (" Alias: ",$this->filters['aliasUsername']); + printf (" User: ",$this->filters['aliasUsername']); hunk ./provisioning.phtml 1284 - printf (" Target username: ",$this->filters['targetUsername']); + printf (" Target user: ",$this->filters['targetUsername']); hunk ./provisioning.phtml 1289 + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + printf("",$this->SOAPEngine->service); + print " + + +
+ "; + + print " + + "; + + printf (" SIP alias: "); + printf (" SIP target: "); + printf (" Owner: "); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + $alias_els = explode("@", trim($_REQUEST['alias'])); + $target_els = explode("@", trim($_REQUEST['target'])); + + if (!strlen($alias_els[0]) || !strlen($alias_els[1])) { + print "

Error: missing SIP alias username or domain. "; + return 0; + } + + if (!strlen($target_els[0]) || !strlen($target_els[1])) { + print "

Error: missing SIP target username or domain. "; + return 0; + } + + $alias=array( + 'id' => array('username' => $alias_els[0], + 'domain' => $alias_els[1] + ), + 'target' => array('username' => $target_els[0], + 'domain' => $target_els[1] + ), + 'owner' => intval($_REQUEST['owner']) + ); + + //print_r($alias); + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->addAlias($alias); + + 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 ("

SIP alias %s@%s has been added. ",$alias_els[0],$alias_els[1]); + return 1; + } + } hunk ./provisioning.phtml 1398 + //print_r($result); + hunk ./provisioning.phtml 1412 + Action hunk ./provisioning.phtml 1431 - if (!$domain->domain) break; + if (!strlen($domain->users)) break; hunk ./provisioning.phtml 1444 + $this->url .= sprintf("?service=%s&action=Delete&domain_filter=%s", + urlencode($this->SOAPEngine->service), + urlencode($domain->domain) + ); + + if ($_REQUEST['action'] == 'Delete' && + $_REQUEST['domain_filter'] == $domain->domain) { + $this->url .= "&confirm=1"; + $actionText = "Confirm"; + } else { + $actionText = "Delete"; + } + hunk ./provisioning.phtml 1458 - + hunk ./provisioning.phtml 1464 + %s hunk ./provisioning.phtml 1466 + $bgcolor, hunk ./provisioning.phtml 1471 - $domain->onlineDevices + $domain->onlineDevices, + $this->url, + $actionText hunk ./provisioning.phtml 1476 - printf(" - - "); - hunk ./provisioning.phtml 1477 - hunk ./provisioning.phtml 1490 - printf (" Domain: ",$this->filters['domain']); + printf (" Domain: ",$this->filters['domain']); hunk ./provisioning.phtml 1494 -} + function deleteRecord() { + if (!$_REQUEST['confirm']) { + print "

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

Error: missing SIP domain. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); + + $result = $this->SOAPEngine->soapclient->deleteDomain($this->filters['domain']); + + 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 ("

SIP domain %s has been deleted. ",$this->filters['domain']); + unset($this->filters); + return 1; + } + } + + function showAddForm() { + print " +

+ + + "; + printf ("",$_SERVER['PHP_SELF']); + print " + + + "; + printf("",$this->SOAPEngine->service); + print " + + +
+ "; + + print " + + "; + + printf (" Domain: "); + + print " + + "; + print " +
+ "; + } + + function addRecord() { + + $domain=trim($_REQUEST['domain']); + + if (!strlen($domain)) { + print "

Error: missing SIP domain. "; + return 0; + } + + $this->SOAPEngine->soapclient->addHeader($this->SOAPEngine->SoapAuth); hunk ./provisioning.phtml 1565 + $result = $this->SOAPEngine->soapclient->addDomain($domain); + + 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 ("

SIP domain %s has been added. ",$domain); + return 1; + } + } +}