From b5bb1a07a26d5666cb059b5299a6ca2883f2153a Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 12 Mar 2010 21:56:32 +0000 Subject: [PATCH] add svc_phone-phone_name-max_length config, RT#7047 --- FS/FS/Conf.pm | 7 +++++++ FS/FS/svc_phone.pm | 7 ++++++- httemplate/edit/svc_phone.cgi | 5 ++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index aa6ad1bcf..94ecf0e2d 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -3305,6 +3305,13 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'svc_phone-phone_name-max_length', + 'section' => '', + 'description' => 'Maximum length of the phone service "Name" field (svc_phone.phone_name). Sometimes useful to limit this (to 15?) when exporting as Caller ID data.', + 'type' => 'text', + }, + + { 'key' => 'default_phone_countrycode', 'section' => '', 'description' => 'Default countrcode', diff --git a/FS/FS/svc_phone.pm b/FS/FS/svc_phone.pm index 5d102ce2a..30572ecc0 100644 --- a/FS/FS/svc_phone.pm +++ b/FS/FS/svc_phone.pm @@ -2,7 +2,7 @@ package FS::svc_phone; use strict; use base qw( FS::svc_Domain_Mixin FS::location_Mixin FS::svc_Common ); -use vars qw( $DEBUG $me @pw_set $conf ); +use vars qw( $DEBUG $me @pw_set $conf $phone_name_max ); use Data::Dumper; use Scalar::Util qw( blessed ); use FS::Conf; @@ -23,6 +23,7 @@ $DEBUG = 0; #ask FS::UID to run this stuff for us later $FS::UID::callback{'FS::svc_acct'} = sub { $conf = new FS::Conf; + $phone_name_max = $conf->config('svc_phone-phone_name-max_length'); }; =head1 NAME @@ -383,6 +384,10 @@ sub check { ; return $error if $error; + return 'Name ('. $self->phone_name. + ") is longer than $phone_name_max characters" + if $phone_name_max && length($self->phone_name) > $phone_name_max; + $self->countrycode(1) unless $self->countrycode; unless ( length($self->sip_password) ) { diff --git a/httemplate/edit/svc_phone.cgi b/httemplate/edit/svc_phone.cgi index 4715ec146..b77d96233 100644 --- a/httemplate/edit/svc_phone.cgi +++ b/httemplate/edit/svc_phone.cgi @@ -44,7 +44,10 @@ push @fields, { field => 'pbxsvc', }, 'sip_password', 'pin', - 'phone_name', + { field => 'phone_name', + type => 'text', + maxlength => $conf->config('svc_phone-phone_name-max_length'), + }, { value => 'E911 Information', type => 'tablebreak-tr-title', -- 2.11.0