diff --git a/library/NGNPro/Records/SipAliases.php b/library/NGNPro/Records/SipAliases.php index 0e3ac23..0854a60 100644 --- a/library/NGNPro/Records/SipAliases.php +++ b/library/NGNPro/Records/SipAliases.php @@ -1,509 +1,525 @@ 1) { $target_domain=$target_filters_els[1]; } $this->filters = array( 'alias_username' => strtolower(trim($_REQUEST['alias_username_filter'])), 'alias_domain' => strtolower(trim($_REQUEST['alias_domain_filter'])), 'target_username' => strtolower($target_username), 'target_domain' => strtolower($target_domain) ); parent::__construct($SoapEngine); $this->sortElements=array( 'changeDate' => 'Change date', 'aliasUsername' => 'Alias user', 'aliasDomain' => 'Alias domain', 'targetUsername' => 'Target user', 'targetDomain' => 'Target domain', ); } function getRecordKeys() { // Filter $filter=array('aliasUsername' => $this->filters['alias_username'], 'aliasDomain' => $this->filters['alias_domain'], 'targetUsername' => $this->filters['target_username'], 'targetDomain' => $this->filters['target_domain'], 'owner' => intval($this->filters['owner']), 'customer' => intval($this->filters['customer']), 'reseller' => intval($this->filters['reseller']) ); // Range $range=array('start' => 0, 'count' => 500 ); // Order if (!$this->sorting['sortBy']) $this->sorting['sortBy'] = 'aliasUsername'; 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 ); //dprint_r($Query); // Insert credetials $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); $this->log_action('getAliases'); // Call function $result = $this->SoapEngine->soapclient->getAliases($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { foreach ($result->aliases as $alias) { $this->selectionKeys[]=array('username' => $alias->id->username, 'domain' => $alias->id->domain); } return true; } } function listRecords() { $this->getAllowedDomains(); // Make sure we apply the domain filter from the login credetials $this->showSeachForm(); // Filter $filter=array('aliasUsername' => $this->filters['alias_username'], 'aliasDomain' => $this->filters['alias_domain'], 'targetUsername' => $this->filters['target_username'], 'targetDomain' => $this->filters['target_domain'], 'owner' => intval($this->filters['owner']), 'customer' => intval($this->filters['customer']), 'reseller' => intval($this->filters['reseller']) ); // Range $range=array('start' => intval($this->next), 'count' => intval($this->maxrowsperpage) ); // 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); $this->log_action('getAliases'); // Call function $result = $this->SoapEngine->soapclient->getAliases($Query); 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 | SIP alias | Redirect target | Owner | Change date | Actions |
---|---|---|---|---|---|
%s | %s@%s | %s@%s | %s | %s | %s |
Please press on Confirm to confirm the delete. "; return true; } if ($dictionary['alias_username']) { $alias_username=$dictionary['alias_username']; } else { $alias_username=$this->filters['alias_username']; } if ($dictionary['alias_domain']) { $alias_domain=$dictionary['alias_domain']; } else { $alias_domain=$this->filters['alias_domain']; } if (!strlen($alias_username) || !strlen($alias_domain)) { print "
Error: missing SIP alias username or domain. "; return false; } $alias=array('username' => $alias_username, 'domain' => $alias_domain ); $function=array('commit' => array('name' => 'deleteAlias', 'parameters' => array($alias), 'logs' => array('success' => sprintf('SIP alias %s@%s has been deleted',$this->filters['alias_username'], $this->filters['alias_domain']) ) ) ); unset($this->filters); return $this->SoapEngine->execute($function, $this->html); } function showSeachFormCustom() { printf ("
You must create at least one SIP domain before adding SIP aliases"; return false; } printf ("
"; } function addRecord($dictionary=array()) { if ($dictionary['alias']) { $alias_els = explode("@", $dictionary['alias']); $this->skipSaveProperties=true; } else { $alias_els = explode("@", trim($_REQUEST['alias'])); } if ($dictionary['target']) { $target_els = explode("@", $dictionary['target']); } else { $target_els = explode("@", trim($_REQUEST['target'])); } if ($dictionary['owner']) { $owner = $dictionary['owner']; } else { $owner = $_REQUEST['owner']; } if (preg_match("/:(.*)$/",$target_els[0], $m)) { $target_username=$m[1]; } else { $target_username=$target_els[0]; } if (preg_match("/:(.*)$/",$alias_els[0], $m)) { $username=$m[1]; } else { $username=$alias_els[0]; } if (strlen($alias_els[1])) { $domain=$alias_els[1]; } else if (trim($_REQUEST['domain'])) { $domain=trim($_REQUEST['domain']); } else { if ($this->html) { printf ("Error: Missing SIP domain"); } return false; } if (!$this->validDomain($domain)) { if ($this->html) { print "Error: invalid domain name"; } return false; } list($customer, $reseller)=$this->customerFromLogin($dictionary); if (!$this->skipSaveProperties=true) { $_p=array( array('name' => 'sip_aliases_last_domain', 'category' => 'web', 'value' => strtolower($domain), 'permission' => 'customer' ) ); $this->setCustomerProperties($_p); } $alias=array( 'id' => array('username' => strtolower($username), 'domain' => strtolower($domain) ), 'target' => array('username' => strtolower($target_username), 'domain' => strtolower($target_els[1]) ), 'owner' => intval($owner) ); $deleteAlias=array('username' => strtolower($username), 'domain' => strtolower($domain) ); $function=array('commit' => array('name' => 'addAlias', 'parameters' => array($alias), 'logs' => array('success' => sprintf('SIP alias %s@%s has been added',$username, $domain))) ); return $this->SoapEngine->execute($function, $this->html); } function getAllowedDomains() { // Filter $filter=array( 'domain' => '' ); // Range $range=array('start' => 0, 'count' => 500 ); $orderBy = array('attribute' => 'domain', 'direction' => 'ASC' ); // Compose query $Query=array('filter' => $filter, 'orderBy' => $orderBy, 'range' => $range ); $this->SoapEngine->soapclient->addHeader($this->SoapEngine->SoapAuth); $this->log_action('getDomains'); $result = $this->SoapEngine->soapclient->getDomains($Query); if ($this->checkLogSoapError($result, true)) { return false; } else { foreach ($result->domains as $_domain) { if ($this->validDomain($_domain->domain)) { $this->allowedDomains[]=$_domain->domain; } } } } function showTextBeforeCustomerSelection() { print _("Domain owner"); } }