<commit_before>package CCNQ::Proxy::aliases;
# Copyright (C) 2006, 2007  <NAME>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#
# For more information visit http://carrierclass.net/
#
use strict; use warnings;

use base qw(CCNQ::Proxy::Base);

sub doc
{
    return <<'HTML';
    Aliases are used to define the following services:
    <ul>
    <li>N11 Easily Recognizable Codes
    <li>*XX Vertical Services Codes
    </ul>
    For Username, enter for example "911", and for Contact the SIP URI
    that emergency calls should follow (e.g. "sip:<EMAIL>").
HTML
}

sub form
{
    my $self = shift;
    return (
        'Username' => 'text',
        'Domain'   => 'text',
        'Target_Username' => 'text',
        'Target_Domain'   => 'text',
    );
}

sub insert
{
    my $self = shift;
    my %params = @_;

    my $alias_username = $params{username};
    my $alias_domain   = $params{domain};
    my $username = $params{target_username};
    my $domain   = $params{taregt_domain};

    return ()
        unless defined $username and $username ne ''
        and    defined $domain   and $domain ne ''
        and    defined $alias_username and $alias_username ne ''
        and    defined $alias_domain   and $alias_domain ne '';

    return (<<'SQL',[$username,$domain,$alias_username,$alias_domain]);
        INSERT INTO aliases(username,domain,alias_username,alias_domain) VALUES (?,?,?,?)
SQL
}

sub delete
{
    my $self = shift;
    my %params = @_;
    my $alias_username = $params{username};
    my $alias_domain   = $params{domain};
    my $username = $params{target_username};
    my $domain   = $params{taregt_domain};

    return (<<'SQL',[$username,$domain,$alias_username,$alias_domain]);
        DELETE FROM aliases WHERE username = ? AND domain = ? AND alias_username = ? AND alias_domain = ?
SQL
}

sub list
{
    my $self = shift;
    return (<<'SQL',[],undef);
        SELECT alias_username AS Username, alias_domain AS Domain, username AS Target_Username, domain AS Target_Domain
        FROM aliases
        ORDER BY username, domain, alias_username, alias_domain ASC
SQL
}

1;<commit_msg>Aliases field should be reversed<commit_after>package CCNQ::Proxy::aliases;
# Copyright (C) 2006, 2007  <NAME>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

#
# For more information visit http://carrierclass.net/
#
use strict; use warnings;

use base qw(CCNQ::Proxy::Base);

sub doc
{
    return <<'HTML';
    Aliases are used to define the following services:
    <ul>
    <li>N11 Easily Recognizable Codes
    <li>*XX Vertical Services Codes
    </ul>
    For Username, enter for example "911", and for Contact the SIP URI
    that emergency calls should follow (e.g. "sip:<EMAIL>").
HTML
}

sub form
{
    my $self = shift;
    return (
        'Username' => 'text',
        'Domain'   => 'text',
        'Target_Username' => 'text',
        'Target_Domain'   => 'text',
    );
}

sub insert
{
    my $self = shift;
    my %params = @_;

    my $alias_username = $params{username};
    my $alias_domain   = $params{domain};
    my $username = $params{target_username};
    my $domain   = $params{target_domain};

    return ()
        unless defined $username and $username ne ''
        and    defined $domain   and $domain ne ''
        and    defined $alias_username and $alias_username ne ''
        and    defined $alias_domain   and $alias_domain ne '';

    return (<<'SQL',[$username,$domain,$alias_username,$alias_domain]);
        INSERT INTO aliases(username,domain,alias_username,alias_domain) VALUES (?,?,?,?)
SQL
}

sub delete
{
    my $self = shift;
    my %params = @_;
    my $alias_username = $params{username};
    my $alias_domain   = $params{domain};
    my $username = $params{target_username};
    my $domain   = $params{target_domain};

    return (<<'SQL',[$username,$domain,$alias_username,$alias_domain]);
        DELETE FROM aliases WHERE username = ? AND domain = ? AND alias_username = ? AND alias_domain = ?
SQL
}

sub list
{
    my $self = shift;
    return (<<'SQL',[],undef);
        SELECT alias_username AS Username, alias_domain AS Domain, username AS Target_Username, domain AS Target_Domain
        FROM aliases
        ORDER BY username, domain, alias_username, alias_domain ASC
SQL
}

1;
{'fraction_non_alphanumeric': 0.11051759071652238, 'fraction_numerical': 0.005525879535826119, 'mean_word_length': 3.3061062648691513, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2196526', 'n_tokens_mistral': 1645, 'n_tokens_neox': 1588, 'n_words': 581}