[freeside-commits] freeside/FS/FS cust_attachment.pm, NONE, 1.1 AccessRight.pm, 1.40, 1.41 Conf.pm, 1.307, 1.308 Record.pm, 1.191, 1.192 Schema.pm, 1.161, 1.162 Mason.pm, 1.14, 1.15
Mark Wells
mark at wavetail.420.am
Sun Aug 9 02:05:40 PDT 2009
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv5591/FS/FS
Modified Files:
AccessRight.pm Conf.pm Record.pm Schema.pm Mason.pm
Added Files:
cust_attachment.pm
Log Message:
Add cust_attachment stuff
Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.307
retrieving revision 1.308
diff -u -d -r1.307 -r1.308
--- Conf.pm 7 Aug 2009 23:08:02 -0000 1.307
+++ Conf.pm 9 Aug 2009 09:05:38 -0000 1.308
@@ -736,6 +736,20 @@
},
{
+ 'key' => 'disable_cust_attachment',
+ 'section' => '',
+ 'description' => 'Disable customer file attachments',
+ 'type' => 'checkbox',
+ },
+
+ {
+ 'key' => 'max_attachment_size',
+ 'section' => '',
+ 'description' => 'Maximum size for customer file attachments (leave blank for unlimited)',
+ 'type' => 'text',
+ },
+
+ {
'key' => 'disable_customer_referrals',
'section' => 'UI',
'description' => 'Disable new customer-to-customer referrals in the web interface',
Index: Mason.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Mason.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Mason.pm 28 Jul 2009 21:17:45 -0000 1.14
+++ Mason.pm 9 Aug 2009 09:05:38 -0000 1.15
@@ -186,6 +186,7 @@
use FS::part_pkg_taxrate;
use FS::tax_rate;
use FS::part_pkg_report_option;
+ use FS::cust_attachment;
use FS::h_cust_pkg;
use FS::h_svc_acct;
use FS::h_svc_broadband;
--- NEW FILE: cust_attachment.pm ---
package FS::cust_attachment;
use strict;
use base qw( FS::Record );
use FS::Record qw( qsearch qsearchs );
use FS::Conf;
=head1 NAME
FS::cust_attachment - Object methods for cust_attachment records
=head1 SYNOPSIS
use FS::cust_attachment;
$record = new FS::cust_attachment \%hash;
$record = new FS::cust_attachment { 'column' => 'value' };
$error = $record->insert;
$error = $new_record->replace($old_record);
$error = $record->delete;
$error = $record->check;
=head1 DESCRIPTION
An FS::cust_attachment object represents a file attached to a L<FS::cust_main>
object. FS::cust_attachment inherits from FS::Record. The following fields
are currently supported:
=over 4
=item attachnum
Primary key (assigned automatically).
=item custnum
Customer number (see L<FS::cust_main>).
=item _date
The date the record was last updated.
=item otaker
Order taker (assigned automatically; see L<FS::UID>).
=item filename
The file's name.
=item mime_type
The Content-Type of the file.
=item body
The contents of the file.
=item disabled
If the attachment was disabled, this contains the date it was disabled.
=back
=head1 METHODS
=over 4
=item new HASHREF
Creates a new attachment object.
=cut
# the new method can be inherited from FS::Record, if a table method is defined
sub table { 'cust_attachment'; }
sub nohistory_fields { 'body'; }
=item insert
Adds this record to the database. If there is an error, returns the error,
otherwise returns false.
=cut
=item delete
Delete this record from the database.
=cut
=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 example. 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 $conf = new FS::Conf;
my $error;
if($conf->config('disable_cust_attachment') ) {
$error = 'Attachments disabled (see configuration)';
}
$error =
$self->ut_numbern('attachnum')
|| $self->ut_number('custnum')
|| $self->ut_numbern('_date')
|| $self->ut_text('otaker')
|| $self->ut_text('filename')
|| $self->ut_text('mime_type')
|| $self->ut_numbern('disabled')
|| $self->ut_anything('body')
;
if($conf->config('max_attachment_size')
and $self->size > $conf->config('max_attachment_size') ) {
$error = 'Attachment too large'
}
return $error if $error;
$self->SUPER::check;
}
=item size
Returns the size of the attachment in bytes.
=cut
sub size {
my $self = shift;
return length($self->body);
}
=back
=head1 BUGS
Doesn't work on non-Postgres systems.
=head1 SEE ALSO
L<FS::Record>, schema.html from the base documentation.
=cut
1;
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- Record.pm 25 Jul 2009 07:57:14 -0000 1.191
+++ Record.pm 9 Aug 2009 09:05:38 -0000 1.192
@@ -55,14 +55,13 @@
$conf_encryption = $conf->exists('encryption');
$File::CounterFile::DEFAULT_DIR = $conf->base_dir . "/counters.". datasrc;
if ( driver_name eq 'Pg' ) {
- eval "use DBD::Pg qw(:pg_types);";
+ eval "use DBD::Pg ':pg_types'";
die $@ if $@;
} else {
eval "sub PG_BYTEA { die 'guru meditation #9: calling PG_BYTEA when not running Pg?'; }";
}
} );
-
=head1 NAME
FS::Record - Database record objects
@@ -2718,7 +2717,10 @@
)
{
no strict 'subs';
- dbh->quote($value, PG_BYTEA);
+# dbh->quote($value, { pg_type => PG_BYTEA() }); # doesn't work right
+ # Pg binary string quoting: convert each character to 3-digit octal prefixed with \\,
+ # single-quote the whole mess, and put an "E" in front.
+ return ("E'" . join('', map { sprintf('\\\\%03o', ord($_)) } split(//, $value) ) . "'");
} else {
dbh->quote($value);
}
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.161
retrieving revision 1.162
diff -u -d -r1.161 -r1.162
--- Schema.pm 1 Aug 2009 19:16:47 -0000 1.161
+++ Schema.pm 9 Aug 2009 09:05:38 -0000 1.162
@@ -372,6 +372,22 @@
'index' => [ ['typenum'] ],
},
+ 'cust_attachment' => {
+ 'columns' => [
+ 'attachnum', 'serial', '', '', '', '',
+ 'custnum', 'int', '', '', '', '',
+ '_date', @date_type, '', '',
+ 'otaker', 'varchar', '', 32, '', '',
+ 'filename', 'varchar', '', 32, '', '',
+ 'mime_type', 'varchar', '', 32, '', '',
+ 'body', 'blob', 'NULL', '', '', '',
+ 'disabled', @date_type, '', '',
+ ],
+ 'primary_key' => 'attachnum',
+ 'unique' => [],
+ 'index' => [ ['custnum'] ],
+ },
+
'cust_bill' => {
'columns' => [
'invnum', 'serial', '', '', '', '',
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- AccessRight.pm 28 Jul 2009 21:17:45 -0000 1.40
+++ AccessRight.pm 9 Aug 2009 09:05:38 -0000 1.41
@@ -100,6 +100,9 @@
{ rightname=>'Delete customer', desc=>"Enable customer deletions. Be very careful! Deleting a customer will remove all traces that this customer ever existed! It should probably only be used when auditing a legacy database. Normally, you cancel all of a customer's packages if they cancel service." }, #aka. deletecustomers
'Add customer note', #NEW
'Edit customer note', #NEW
+ 'Download attachment', #NEW
+ 'Add attachment', #NEW
+ 'Edit attachment', #NEW
'Bill customer now', #NEW
'Bulk send customer notices', #NEW
],
More information about the freeside-commits
mailing list