[Improve sip settings page display Adrian Georgescu **20091004103214] hunk ./library/sip_settings.php 149 - if ($loginCredentials['login_type']) { - $this->login_type = $loginCredentials['login_type']; + if ($_SERVER[SSL_CLIENT_CERT]) { + $this->login_type = 'subscriber'; hunk ./library/sip_settings.php 152 - $this->login_type = 'subscriber'; + if ($loginCredentials['login_type']) { + $this->login_type = $loginCredentials['login_type']; + } else { + $this->login_type = 'subscriber'; + } hunk ./library/sip_settings.php 266 - "WEBName" =>sprintf (_("Reject anonymous")), + "WEBName" =>sprintf (_("Reject Anonymous")), hunk ./library/sip_settings.php 275 - $this->tabs=array('info'=>_('Info'), + $this->tabs=array('identity'=>_('Identity'), hunk ./library/sip_settings.php 303 - "FUNC"=>sprintf(_("All calls")), + "FUNC"=>sprintf(_("All Calls")), hunk ./library/sip_settings.php 766 - if ($this->tab=="info") $this->showInfoTab(); + if ($this->tab=="identity") $this->showIdentityTab(); hunk ./library/sip_settings.php 1109 - printf (" Home node %s",$this->homeNode); + printf (" Home Node %s",$this->homeNode); hunk ./library/sip_settings.php 1546 - function showInfoTab() { + function showIdentityTab() { hunk ./library/sip_settings.php 1550 - $chapter=sprintf(_("SIP account")); + $chapter=sprintf(_("SIP Account")); hunk ./library/sip_settings.php 1556 - print _("Address"); + print _("SIP Address"); hunk ./library/sip_settings.php 1559 - sip:$this->account + $this->account hunk ./library/sip_settings.php 1563 + + /* hunk ./library/sip_settings.php 1568 - print _("Full name"); + print _("Full Name"); hunk ./library/sip_settings.php 1574 + "; + */ + + print " hunk ./library/sip_settings.php 1590 - print _("Domain"); + print _("Domain/Realm"); hunk ./library/sip_settings.php 1601 - print _("Outbound proxy"); + print _("Outbound Proxy"); hunk ./library/sip_settings.php 1607 - - - hunk ./library/sip_settings.php 1609 - if ($this->enrollment_url) { - include("/etc/cdrtool/enrollment/config.ini"); - - if (is_array($enrollment)) { - $chapter=sprintf(_("Client certificates")); - $this->showChapter($chapter); - if ($this->sip_settings_api_url) { - print " - - "; - printf (_("You can use the certificate for changing settings using SIP Settings API"),$this->sip_settings_api_url); - printf (" - - - "); - - } - - print " - - "; - print _("X.509 PEM format"); - printf (" - - %s.crt - - - - - ",$this->url, $this->account); - print " - - "; - print _("PKCS#12 store format"); - printf (" - - %s.p12 - - - - - ",$this->url, $this->account); - } - } - - hunk ./library/sip_settings.php 1610 + /* hunk ./library/sip_settings.php 1613 + */ hunk ./library/sip_settings.php 1615 + /* hunk ./library/sip_settings.php 1623 + "; + */ + + print " hunk ./library/sip_settings.php 1628 - XCAP root URL + XCAP Root hunk ./library/sip_settings.php 1637 - $chapter=sprintf(_("ENUM and aliases")); + + + $chapter=sprintf(_("Aliases")); hunk ./library/sip_settings.php 1647 - ENUM $t + Phone Number $t hunk ./library/sip_settings.php 1652 + /* hunk ./library/sip_settings.php 1656 - ENUM + Phone Number hunk ./library/sip_settings.php 1664 - + */ hunk ./library/sip_settings.php 1677 - print _("Alias"); + print _("SIP Alias"); hunk ./library/sip_settings.php 1688 - print _("New alias"); + print _("New Alias"); hunk ./library/sip_settings.php 1714 - hunk ./library/sip_settings.php 1718 - $chapter=sprintf(_("Notifications address")); - $this->showChapter($chapter); - - print " - - "; - print _("Email address"); - print " - - "; + if ($this->enrollment_url) { + include("/etc/cdrtool/enrollment/config.ini"); + + if (is_array($enrollment)) { + $chapter=sprintf(_("TLS Certificate")); + $this->showChapter($chapter); + if ($this->sip_settings_api_url) { + print " + + "; + printf (_("You can use the certificate for changing settings using SIP Settings API"),$this->sip_settings_api_url); + printf (" + + + "); + + } hunk ./library/sip_settings.php 1736 - if ($this->email) { - print "$this->email"; - } else { - print _("Unassigned"); - } - print " - - - "; - print " - - - - "; + print " + + "; + print _("X.509 PEM format"); + printf (" + + %s.crt + + + + + ",$this->url, $this->account); + print " + + "; + print _("PKCS#12 store format"); + printf (" + + %s.p12 + + + + + ",$this->url, $this->account); + } + } hunk ./library/sip_settings.php 1833 - $chapter=sprintf(_("SIP account")); + $chapter=sprintf(_("SIP Account")); hunk ./library/sip_settings.php 1858 - print _("First name"); + print _("First Name"); hunk ./library/sip_settings.php 1873 - print _("Last name"); + print _("Last Name"); hunk ./library/sip_settings.php 2240 - $chapter=sprintf(_("Notifications address")); + $chapter=sprintf(_("Notifications Address")); hunk ./library/sip_settings.php 2246 - print _("Email address"); + print _("Email Address"); hunk ./library/sip_settings.php 2297 - $chapter=sprintf(_("Call diversions")); + $chapter=sprintf(_("Call Diversions")); hunk ./library/sip_settings.php 2581 - $chapter=sprintf(_("Blocked destinations")); + $chapter=sprintf(_("Blocked PSTN Destinations")); hunk ./library/sip_settings.php 3391 - $chapter=sprintf(_("Current balance")); + $chapter=sprintf(_("Current Balance")); hunk ./library/sip_settings.php 3414 - $chapter=sprintf(_("Add balance (admin)")); + $chapter=sprintf(_("Add Balance (admin)")); hunk ./library/sip_settings.php 3449 - $chapter=sprintf(_("Add balance")); + $chapter=sprintf(_("Add Balance")); hunk ./library/sip_settings.php 3560 - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - if ($error_fault->detail->exception->errorcode != "2000") { - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - } - } - hunk ./library/sip_settings.php 3564 - $chapter=sprintf(_("Balance history")); + $chapter=sprintf(_("Balance History")); hunk ./library/sip_settings.php 3676 - print "

url&tab=prepaid&export=1 target=_new>Export history to CSV file"; + print "

url&tab=prepaid&action=get_balance_history&csv=1 target=_new>Export history to CSV file"; hunk ./library/sip_settings.php 3686 - $this->getBalanceHistory(); - - $this->SipPort->addHeader($this->SoapAuth); - - $result = $this->SipPort->getCreditHistory($this->sipId,200); - - if (PEAR::isError($result)) { - $error_msg = $result->getMessage(); - $error_fault= $result->getFault(); - $error_code = $result->getCode(); - if ($error_fault->detail->exception->errorcode != "2000") { - printf ("

Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); - } - } - hunk ./library/sip_settings.php 4002 - print _("Quick dial"); + print _("Quick Dial"); hunk ./library/sip_settings.php 4029 - print _("Mobile number"); + print _("Mobile Number"); hunk ./library/sip_settings.php 4084 - $chapter=sprintf(_("Last received calls")); + $chapter=sprintf(_("Last Received Calls")); hunk ./library/sip_settings.php 4124 - $chapter=sprintf(_("Last placed calls")); + $chapter=sprintf(_("Last Placed Calls")); hunk ./library/sip_settings.php 4904 - $chapter=sprintf(_("Accept rules")); + $chapter=sprintf(_("Accept Rules")); hunk ./library/sip_settings.php 4959 - $chapter=sprintf(_("Temporary rule")); + $chapter=sprintf(_("Temporary Rule")); hunk ./library/sip_settings.php 5097 - $chapter=sprintf(_("Permanent rules")); + $chapter=sprintf(_("Permanent Rules")); hunk ./library/sip_settings.php 5292 - $chapter=sprintf(_("Rejected callers")); + $chapter=sprintf(_("Rejected Callers")); hunk ./library/sip_settings.php 5536 - $chapter=sprintf(_("Published information")); + $chapter=sprintf(_("Activity")); hunk ./library/sip_settings.php 5940 - $chapter=sprintf(_("Billing profiles")); + $chapter=sprintf(_("Billing Profiles")); hunk ./library/sip_settings.php 6076 - print _("Extra groups"); + print _("Extra Groups"); hunk ./library/sip_settings.php 6347 - if (!$_REQUEST['export']) { + if (!strstr($_REQUEST['action'],'get_') && + !strstr($_REQUEST['action'],'set_') && + !strstr($_REQUEST['action'],'add_')) { hunk ./library/sip_settings.php 6390 - } else if ($_REQUEST['action']=="export_balance_history") { - $SipSettings->exportBalanceHistory(); + } else if ($_REQUEST['action'] == 'get_balance_history') { + $SipSettings->getBalanceHistory(); + if ($_REQUEST['csv']) { + $SipSettings->exportBalanceHistory(); + } else { + print json_encode($SipSettings->balance_history); + } hunk ./library/sip_settings.php 6410 - } else if ($_REQUEST['action'] == 'get_balance_history') { - $SipSettings->getBalanceHistory(); - print json_encode($SipSettings->balance_history); - return true; hunk ./library/sip_settings.php 6434 + } else if ($_REQUEST['action'] == 'add_balance'){ + + if (!$_REQUEST['id'] || !$_REQUEST['number']) { + $return=array('success' => false, + 'error_message' => 'Missing id or number' + ); + print (json_encode($return)); + return false; + } + + $card = array('id' => intval($_REQUEST['id']), + 'number' => $_REQUEST['number'] + ); + + $SipSettings->SipPort->addHeader($SipSettings->SoapAuth); + $result = $SipSettings->SipPort->addBalanceFromVoucher($SipSettings->sipId,$card); + + if (PEAR::isError($result)) { + $error_msg = $result->getMessage(); + $error_fault= $result->getFault(); + $error_code = $result->getCode(); + $_msg=sprintf ("Error (SipPort): %s (%s): %s",$error_msg, $error_fault->detail->exception->errorcode,$error_fault->detail->exception->errorstring); + $return=array('success' => false, + 'error_message' => $_msg + ); + print (json_encode($return)); + return false; + } else { + $return=array('success' => true, + 'error_message' => 'Added balance succeeded' + ); + print (json_encode($return)); + return true; + } +