2 'post_url' => popurl(1).'process/upload_target.html',
3 'name' => 'Upload target',
4 'table' => 'upload_target',
5 'viewall_url' => "${p}browse/upload_target.html",
6 'labels' => { targetnum => 'Target',
7 protocol => 'Protocol',
8 handling => 'Special handling',
11 { field => 'protocol',
12 type => 'selectlayers',
13 options => [ '', 'sftp', 'ftp', 'email' ],
19 layer_fields => \%protocol_fields,
20 layer_values_callback => \&values_callback,
22 { field => 'handling',
24 options => [ FS::upload_target->handling_types ],
27 'menubar' => \@menubar,
28 'edit_callback' => $edit_callback,
32 my $curuser = $FS::CurrentUser::CurrentUser;
35 unless $curuser->access_right('Configuration');
37 my @menubar = ('View all FTP targets' => $p.'browse/upload_target.html');
38 my $edit_callback = sub {
39 my ($cgi, $object) = @_;
40 if ( $object->targetnum ) {
41 push @menubar, 'Delete this target',
42 $p.'misc/delete-upload_target.html?'.$object->targetnum;
46 my %protocol_fields = (
49 'hostname' => { label => 'Server' },
50 'username' => { label => 'Username' },
51 'password' => { label => 'Password' },
52 'port' => { label => 'Port', size => 8 },
53 'path' => { label => 'Path', size => 30 },
56 'username' => { label => 'To:' },
57 'hostname' => { label => '@' },
58 'subject' => { label => 'Subject:' },
61 $protocol_fields{'ftp'} = [ @{ $protocol_fields{'sftp'} } ];
62 foreach my $k (keys %protocol_fields) {
63 # disambiguate the field names
64 foreach (@{ $protocol_fields{$k} }) {
65 $_ = $k.'_'.$_ unless ref $_;
70 my ($cgi, $object) = @_;
72 # really simple, the interpretation of the fields is the same for all
74 foreach my $l (qw(email ftp sftp)) {
75 $layer_values->{$l} = { map { $l.'_'.$_ => ($cgi->param($l.'_'.$_) ||