diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS.pm | 4 | ||||
-rw-r--r-- | FS/FS/AccessRight.pm | 5 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 14 | ||||
-rw-r--r-- | FS/FS/msg_template.pm | 144 | ||||
-rw-r--r-- | FS/MANIFEST | 2 | ||||
-rw-r--r-- | FS/t/msg_template.t | 5 |
6 files changed, 172 insertions, 2 deletions
@@ -326,7 +326,9 @@ L<FS::queue_arg> - Job arguments L<FS::queue_depend> - Job dependencies -L<FS::msgcat> - Message catalogs +L<FS::msg_template> - Message templates (customer notices) + +L<FS::msgcat> - Message catalogs (error messages) L<FS::clientapi_session> diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index fbe549693..322fa3d12 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -268,7 +268,10 @@ tie my %rights, 'Tie::IxHash', 'Edit billing events', { rightname=>'Edit global billing events', global=>1 }, - + + 'Edit templates', + { rightname=>'Edit global templates', global=>1 }, + { rightname=>'Dialup configuration' }, { rightname=>'Dialup global configuration', global=>1 }, diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 84ca0a744..531a3ca0b 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2677,6 +2677,20 @@ sub tables_hashref { 'index' => [['listnum'],['svcnum'],['email']], }, + 'msg_template' => { + 'columns' => [ + 'msgnum', 'serial', '', '', '', '', + 'msgname', 'varchar', '', $char_d, '', '', + 'agentnum', 'int', 'NULL', '', '', '', + 'mime_type', 'varchar', '', $char_d, '', '', + 'body', 'blob', 'NULL', '', '', '', + 'disabled', 'char', 'NULL', 1, '', '', + ], + 'primary_key' => 'msgnum', + 'unique' => [ ['msgname', 'mime_type'] ], + 'index' => [ ['agentnum'], ] + }, + # name type nullability length default local diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm new file mode 100644 index 000000000..7bf050441 --- /dev/null +++ b/FS/FS/msg_template.pm @@ -0,0 +1,144 @@ +package FS::msg_template; + +use strict; +use base qw( FS::Record ); +use FS::Record qw( qsearch qsearchs ); + +=head1 NAME + +FS::msg_template - Object methods for msg_template records + +=head1 SYNOPSIS + + use FS::msg_template; + + $record = new FS::msg_template \%hash; + $record = new FS::msg_template { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::msg_template object represents a customer message template. +FS::msg_template inherits from FS::Record. The following fields are currently +supported: + +=over 4 + +=item msgnum + +primary key + +=item msgname + +msgname + +=item agentnum + +agentnum + +=item mime_type + +mime_type + +=item body + +body + +=item disabled + +disabled + + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new template. To add the template to the database, see L<"insert">. + +Note that this stores the hash reference, not a distinct copy of the hash it +points to. You can ask the object for a copy with the I<hash> method. + +=cut + +# the new method can be inherited from FS::Record, if a table method is defined + +sub table { 'msg_template'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=cut + +# the insert method can be inherited from FS::Record + +=item delete + +Delete this record from the database. + +=cut + +# the delete method can be inherited from FS::Record + +=item replace OLD_RECORD + +Replaces the OLD_RECORD with this one in the database. If there is an error, +returns the error, otherwise returns false. + +=cut + +# the replace method can be inherited from FS::Record + +=item check + +Checks all fields to make sure this is a valid template. If there is +an error, returns the error, otherwise returns false. Called by the insert +and replace methods. + +=cut + +# the check method should currently be supplied - FS::Record contains some +# data checking routines + +sub check { + my $self = shift; + + my $error = + $self->ut_numbern('msgnum') + || $self->ut_text('msgname') + || $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum') + || $self->ut_textn('mime_type') + || $self->ut_anything('body') + || $self->ut_enum('disabled', [ '', 'Y' ] ) + ; + return $error if $error; + + $self->mime_type('text/html') unless $self->mime_type; + + $self->SUPER::check; +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L<FS::Record>, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/MANIFEST b/FS/MANIFEST index f491b6cd7..f21105d2e 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -494,3 +494,5 @@ FS/cgp_rule_condition.pm t/cgp_rule_condition.t FS/cgp_rule_action.pm t/cgp_rule_action.t +FS/msg_template.pm +t/msg_template.t diff --git a/FS/t/msg_template.t b/FS/t/msg_template.t new file mode 100644 index 000000000..cec1d41af --- /dev/null +++ b/FS/t/msg_template.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::msg_template; +$loaded=1; +print "ok 1\n"; |