From 811929bedb4c12e649f5cb8877f9ca2f8bbc5af2 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Wed, 4 Sep 2013 15:50:51 +0200 Subject: [PATCH] Add display name and shared roster visibility. --- lib/NGCP/Panel/Controller/Customer.pm | 10 ++++++++-- lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm | 2 +- .../Panel/Form/Customer/PbxExtensionSubscriber.pm | 2 +- .../Form/Customer/PbxExtensionSubscriberEdit.pm | 2 +- lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm | 13 ++++++++++++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Customer.pm b/lib/NGCP/Panel/Controller/Customer.pm index d0e4cde4ce..a51a17fbe2 100644 --- a/lib/NGCP/Panel/Controller/Customer.pm +++ b/lib/NGCP/Panel/Controller/Customer.pm @@ -170,6 +170,7 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) { my $pbx = 0; my $pbxadmin = 0; $pbx = 1 if $c->stash->{product}->class eq 'pbxaccount'; my $form; + my $posted = ($c->request->method eq 'POST'); my $admin_subscribers = NGCP::Panel::Utils::Subscriber::get_admin_subscribers( voip_subscribers => $c->stash->{subscribers}); @@ -189,7 +190,7 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) { my $params = {}; $params = $params->merge($c->session->{created_objects}); $form->process( - posted => ($c->request->method eq 'POST'), + posted => $posted, params => $c->request->params, item => $params, ); @@ -207,7 +208,7 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) { fields => $fields, back_uri => $c->req->uri, ); - if($form->validated) { + if($posted && $form->validated) { my $billing_subscriber; try { my $schema = $c->model('DB'); @@ -231,7 +232,12 @@ sub subscriber_create :Chained('base') :PathPart('subscriber/create') :Args(0) { } if($pbx) { $preferences->{cloud_pbx} = 1; + # TODO: only if it's not a fax/conf extension: + $preferences->{shared_buddylist_visibility} = 1; + $preferences->{display_name} = $form->params->{display_name} + if($form->params->{display_name}); } + use Data::Printer; p $preferences; $billing_subscriber = NGCP::Panel::Utils::Subscriber::create_subscriber( c => $c, schema => $schema, diff --git a/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm b/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm index 2407ebf3ce..5f94a26811 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxAdminSubscriber.pm @@ -54,7 +54,7 @@ has_field 'domain' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/domain webusername webpassword e164 username password status external_id/ ], + render_list => [qw/domain e164 display_name webusername webpassword username password status external_id/ ], ); sub validate { diff --git a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm index 1cb5332853..d15a738f85 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriber.pm @@ -22,7 +22,7 @@ has_field 'extension' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/group webusername webpassword extension username password status external_id/ ], + render_list => [qw/group extension display_name webusername webpassword username password status external_id/ ], ); sub field_list { diff --git a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberEdit.pm b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberEdit.pm index 398d013746..1ed55d4214 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberEdit.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxExtensionSubscriberEdit.pm @@ -22,7 +22,7 @@ has_field 'extension' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/group webusername webpassword extension password status external_id/ ], + render_list => [qw/group extension display_name webusername webpassword password status external_id/ ], ); sub field_list { diff --git a/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm b/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm index 390718b256..37bdd82780 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxSubscriber.pm @@ -13,6 +13,17 @@ has_field 'submitid' => ( type => 'Hidden' ); sub build_render_list {[qw/submitid fields actions/]} sub build_form_element_class { [qw/form-horizontal/] } +has_field 'display_name' => ( + type => 'Text', + element_attr => { + rel => ['tooltip'], + title => ['The human-readable display name (e.g. John Doe)'] + }, + required => 0, + label => 'Display Name', +); + + has_field 'webusername' => ( type => 'Text', label => 'Web Username', @@ -90,7 +101,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/webusername webpassword username password status external_id/ ], + render_list => [qw/display_name webusername webpassword username password status external_id/ ], ); has_block 'actions' => (