have the new style notes be the default
[freeside.git] / FS / FS / Conf.pm
1 package FS::Conf;
2
3 use vars qw($default_dir @config_items $DEBUG );
4 use IO::File;
5 use File::Basename;
6 use FS::ConfItem;
7 use FS::ConfDefaults;
8
9 $DEBUG = 0;
10
11 =head1 NAME
12
13 FS::Conf - Freeside configuration values
14
15 =head1 SYNOPSIS
16
17   use FS::Conf;
18
19   $conf = new FS::Conf "/config/directory";
20
21   $FS::Conf::default_dir = "/config/directory";
22   $conf = new FS::Conf;
23
24   $dir = $conf->dir;
25
26   $value = $conf->config('key');
27   @list  = $conf->config('key');
28   $bool  = $conf->exists('key');
29
30   $conf->touch('key');
31   $conf->set('key' => 'value');
32   $conf->delete('key');
33
34   @config_items = $conf->config_items;
35
36 =head1 DESCRIPTION
37
38 Read and write Freeside configuration values.  Keys currently map to filenames,
39 but this may change in the future.
40
41 =head1 METHODS
42
43 =over 4
44
45 =item new [ DIRECTORY ]
46
47 Create a new configuration object.  A directory arguement is required if
48 $FS::Conf::default_dir has not been set.
49
50 =cut
51
52 sub new {
53   my($proto,$dir) = @_;
54   my($class) = ref($proto) || $proto;
55   my($self) = { 'dir' => $dir || $default_dir } ;
56   bless ($self, $class);
57 }
58
59 =item dir
60
61 Returns the directory.
62
63 =cut
64
65 sub dir {
66   my($self) = @_;
67   my $dir = $self->{dir};
68   -e $dir or die "FATAL: $dir doesn't exist!";
69   -d $dir or die "FATAL: $dir isn't a directory!";
70   -r $dir or die "FATAL: Can't read $dir!";
71   -x $dir or die "FATAL: $dir not searchable (executable)!";
72   $dir =~ /^(.*)$/;
73   $1;
74 }
75
76 =item config KEY
77
78 Returns the configuration value or values (depending on context) for key.
79
80 =cut
81
82 sub config {
83   my($self,$file)=@_;
84   my($dir)=$self->dir;
85   my $fh = new IO::File "<$dir/$file" or return;
86   if ( wantarray ) {
87     map {
88       /^(.*)$/
89         or die "Illegal line (array context) in $dir/$file:\n$_\n";
90       $1;
91     } <$fh>;
92   } else {
93     <$fh> =~ /^(.*)$/
94       or die "Illegal line (scalar context) in $dir/$file:\n$_\n";
95     $1;
96   }
97 }
98
99 =item config_binary KEY
100
101 Returns the exact scalar value for key.
102
103 =cut
104
105 sub config_binary {
106   my($self,$file)=@_;
107   my($dir)=$self->dir;
108   my $fh = new IO::File "<$dir/$file" or return;
109   local $/;
110   my $content = <$fh>;
111   $content;
112 }
113
114 =item exists KEY
115
116 Returns true if the specified key exists, even if the corresponding value
117 is undefined.
118
119 =cut
120
121 sub exists {
122   my($self,$file)=@_;
123   my($dir) = $self->dir;
124   -e "$dir/$file";
125 }
126
127 =item config_orbase KEY SUFFIX
128
129 Returns the configuration value or values (depending on context) for 
130 KEY_SUFFIX, if it exists, otherwise for KEY
131
132 =cut
133
134 sub config_orbase {
135   my( $self, $file, $suffix ) = @_;
136   if ( $self->exists("${file}_$suffix") ) {
137     $self->config("${file}_$suffix");
138   } else {
139     $self->config($file);
140   }
141 }
142
143 =item touch KEY
144
145 Creates the specified configuration key if it does not exist.
146
147 =cut
148
149 sub touch {
150   my($self, $file) = @_;
151   my $dir = $self->dir;
152   unless ( $self->exists($file) ) {
153     warn "[FS::Conf] TOUCH $file\n" if $DEBUG;
154     system('touch', "$dir/$file");
155   }
156 }
157
158 =item set KEY VALUE
159
160 Sets the specified configuration key to the given value.
161
162 =cut
163
164 sub set {
165   my($self, $file, $value) = @_;
166   my $dir = $self->dir;
167   $value =~ /^(.*)$/s;
168   $value = $1;
169   unless ( join("\n", @{[ $self->config($file) ]}) eq $value ) {
170     warn "[FS::Conf] SET $file\n" if $DEBUG;
171 #    warn "$dir" if is_tainted($dir);
172 #    warn "$dir" if is_tainted($file);
173     chmod 0644, "$dir/$file";
174     my $fh = new IO::File ">$dir/$file" or return;
175     chmod 0644, "$dir/$file";
176     print $fh "$value\n";
177   }
178 }
179 #sub is_tainted {
180 #             return ! eval { join('',@_), kill 0; 1; };
181 #         }
182
183 =item delete KEY
184
185 Deletes the specified configuration key.
186
187 =cut
188
189 sub delete {
190   my($self, $file) = @_;
191   my $dir = $self->dir;
192   if ( $self->exists($file) ) {
193     warn "[FS::Conf] DELETE $file\n";
194     unlink "$dir/$file";
195   }
196 }
197
198 =item config_items
199
200 Returns all of the possible configuration items as FS::ConfItem objects.  See
201 L<FS::ConfItem>.
202
203 =cut
204
205 sub config_items {
206   my $self = shift; 
207   #quelle kludge
208   @config_items,
209   ( map { 
210         my $basename = basename($_);
211         $basename =~ /^(.*)$/;
212         $basename = $1;
213         new FS::ConfItem {
214                            'key'         => $basename,
215                            'section'     => 'billing',
216                            'description' => 'Alternate template file for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
217                            'type'        => 'textarea',
218                          }
219       } glob($self->dir. '/invoice_template_*')
220   ),
221   ( map { 
222         my $basename = basename($_);
223         $basename =~ /^(.*)$/;
224         $basename = $1;
225         new FS::ConfItem {
226                            'key'         => $basename,
227                            'section'     => 'billing',
228                            'description' => 'Alternate HTML template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
229                            'type'        => 'textarea',
230                          }
231       } glob($self->dir. '/invoice_html_*')
232   ),
233   ( map { 
234         my $basename = basename($_);
235         $basename =~ /^(.*)$/;
236         $basename = $1;
237         ($latexname = $basename ) =~ s/latex/html/;
238         new FS::ConfItem {
239                            'key'         => $basename,
240                            'section'     => 'billing',
241                            'description' => "Alternate Notes section for HTML invoices.  Defaults to the same data in $latexname if not specified.",
242                            'type'        => 'textarea',
243                          }
244       } glob($self->dir. '/invoice_htmlnotes_*')
245   ),
246   ( map { 
247         my $basename = basename($_);
248         $basename =~ /^(.*)$/;
249         $basename = $1;
250         new FS::ConfItem {
251                            'key'         => $basename,
252                            'section'     => 'billing',
253                            'description' => 'Alternate LaTeX template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
254                            'type'        => 'textarea',
255                          }
256       } glob($self->dir. '/invoice_latex_*')
257   ),
258   ( map { 
259         my $basename = basename($_);
260         $basename =~ /^(.*)$/;
261         $basename = $1;
262         new FS::ConfItem {
263                            'key'         => $basename,
264                            'section'     => 'billing',
265                            'description' => 'Alternate Notes section for LaTeX typeset PostScript invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
266                            'type'        => 'textarea',
267                          }
268       } glob($self->dir. '/invoice_latexnotes_*')
269   );
270 }
271
272 =back
273
274 =head1 BUGS
275
276 If this was more than just crud that will never be useful outside Freeside I'd
277 worry that config_items is freeside-specific and icky.
278
279 =head1 SEE ALSO
280
281 "Configuration" in the web interface (config/config.cgi).
282
283 httemplate/docs/config.html
284
285 =cut
286
287 @config_items = map { new FS::ConfItem $_ } (
288
289   {
290     'key'         => 'address',
291     'section'     => 'deprecated',
292     'description' => 'This configuration option is no longer used.  See <a href="#invoice_template">invoice_template</a> instead.',
293     'type'        => 'text',
294   },
295
296   {
297     'key'         => 'alerter_template',
298     'section'     => 'billing',
299     'description' => 'Template file for billing method expiration alerts.  See the <a href="../docs/billing.html#invoice_template">billing documentation</a> for details.',
300     'type'        => 'textarea',
301   },
302
303   {
304     'key'         => 'apacheroot',
305     'section'     => 'deprecated',
306     'description' => '<b>DEPRECATED</b>, add a <i>www_shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead.  The directory containing Apache virtual hosts',
307     'type'        => 'text',
308   },
309
310   {
311     'key'         => 'apacheip',
312     'section'     => 'deprecated',
313     'description' => '<b>DEPRECATED</b>, add an <i>apache</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be the current IP address to assign to new virtual hosts',
314     'type'        => 'text',
315   },
316
317   {
318     'key'         => 'apachemachine',
319     'section'     => 'deprecated',
320     'description' => '<b>DEPRECATED</b>, add a <i>www_shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead.  A machine with the apacheroot directory and user home directories.  The existance of this file enables setup of virtual host directories, and, in conjunction with the `home\' configuration file, symlinks into user home directories.',
321     'type'        => 'text',
322   },
323
324   {
325     'key'         => 'apachemachines',
326     'section'     => 'deprecated',
327     'description' => '<b>DEPRECATED</b>, add an <i>apache</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be Apache machines, one per line.  This enables export of `/etc/apache/vhosts.conf\', which can be included in your Apache configuration via the <a href="http://www.apache.org/docs/mod/core.html#include">Include</a> directive.',
328     'type'        => 'textarea',
329   },
330
331   {
332     'key'         => 'bindprimary',
333     'section'     => 'deprecated',
334     'description' => '<b>DEPRECATED</b>, add a <i>bind</i> <a href="../browse/part_export.cgi">export</a> instead.  Your BIND primary nameserver.  This enables export of /var/named/named.conf and zone files into /var/named',
335     'type'        => 'text',
336   },
337
338   {
339     'key'         => 'bindsecondaries',
340     'section'     => 'deprecated',
341     'description' => '<b>DEPRECATED</b>, add a <i>bind_slave</i> <a href="../browse/part_export.cgi">export</a> instead.  Your BIND secondary nameservers, one per line.  This enables export of /var/named/named.conf',
342     'type'        => 'textarea',
343   },
344
345   {
346     'key'         => 'encryption',
347     'section'     => 'billing',
348     'description' => 'Enable encryption of credit cards.',
349     'type'        => 'checkbox',
350   },
351
352   {
353     'key'         => 'encryptionmodule',
354     'section'     => 'billing',
355     'description' => 'Use which module for encryption?',
356     'type'        => 'text',
357   },
358
359   {
360     'key'         => 'encryptionpublickey',
361     'section'     => 'billing',
362     'description' => 'Your RSA Public Key - Required if Encryption is turned on.',
363     'type'        => 'textarea',
364   },
365
366   {
367     'key'         => 'encryptionprivatekey',
368     'section'     => 'billing',
369     'description' => 'Your RSA Private Key - Including this will enable the "Bill Now" feature.  However if the system is compromised, a hacker can use this key to decode the stored credit card information.  This is generally not a good idea.',
370     'type'        => 'textarea',
371   },
372
373   {
374     'key'         => 'business-onlinepayment',
375     'section'     => 'billing',
376     'description' => '<a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> support, at least three lines: processor, login, and password.  An optional fourth line specifies the action or actions (multiple actions are separated with `,\': for example: `Authorization Only, Post Authorization\').    Optional additional lines are passed to Business::OnlinePayment as %processor_options.',
377     'type'        => 'textarea',
378   },
379
380   {
381     'key'         => 'business-onlinepayment-ach',
382     'section'     => 'billing',
383     'description' => 'Alternate <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> support for ACH transactions (defaults to regular <b>business-onlinepayment</b>).  At least three lines: processor, login, and password.  An optional fourth line specifies the action or actions (multiple actions are separated with `,\': for example: `Authorization Only, Post Authorization\').    Optional additional lines are passed to Business::OnlinePayment as %processor_options.',
384     'type'        => 'textarea',
385   },
386
387   {
388     'key'         => 'business-onlinepayment-description',
389     'section'     => 'billing',
390     'description' => 'String passed as the description field to <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a>.  Evaluated as a double-quoted perl string, with the following variables available: <code>$agent</code> (the agent name), and <code>$pkgs</code> (a comma-separated list of packages for which these charges apply)',
391     'type'        => 'text',
392   },
393
394   {
395     'key'         => 'business-onlinepayment-email-override',
396     'section'     => 'billing',
397     'description' => 'Email address used instead of customer email address when submitting a BOP transaction.',
398     'type'        => 'text',
399   },
400
401   {
402     'key'         => 'bsdshellmachines',
403     'section'     => 'deprecated',
404     'description' => '<b>DEPRECATED</b>, add a <i>bsdshell</i> <a href="../browse/part_export.cgi">export</a> instead.  Your BSD flavored shell (and mail) machines, one per line.  This enables export of `/etc/passwd\' and `/etc/master.passwd\'.',
405     'type'        => 'textarea',
406   },
407
408   {
409     'key'         => 'countrydefault',
410     'section'     => 'UI',
411     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
412     'type'        => 'text',
413   },
414
415   {
416     'key'         => 'date_format',
417     'section'     => 'UI',
418     'description' => 'format code for displaying dates with Date::Format::time2str',
419     'type'        => 'text',
420   },
421
422   {
423     'key'         => 'cyrus',
424     'section'     => 'deprecated',
425     'description' => '<b>DEPRECATED</b>, add a <i>cyrus</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to integrate with <a href="http://asg.web.cmu.edu/cyrus/imapd/">Cyrus IMAP Server</a>, three lines: IMAP server, admin username, and admin password.  Cyrus::IMAP::Admin should be installed locally and the connection to the server secured.',
426     'type'        => 'textarea',
427   },
428
429   {
430     'key'         => 'cp_app',
431     'section'     => 'deprecated',
432     'description' => '<b>DEPRECATED</b>, add a <i>cp</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to integrate with <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>, four lines: "host:port", username, password, and workgroup (for new users).',
433     'type'        => 'textarea',
434   },
435
436   {
437     'key'         => 'deletecustomers',
438     'section'     => 'UI',
439     'description' => '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 customers\' packages if they cancel service.',
440     'type'        => 'checkbox',
441   },
442
443   {
444     'key'         => 'deletepayments',
445     'section'     => 'billing',
446     'description' => 'Enable deletion of unclosed payments.  Really, with voids this is pretty much not recommended in any situation anymore.  Be very careful!  Only delete payments that were data-entry errors, not adjustments.  Optionally specify one or more comma-separated email addresses to be notified when a payment is deleted.',
447     'type'        => [qw( checkbox text )],
448   },
449
450   {
451     'key'         => 'deletecredits',
452     'section'     => 'deprecated',
453     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable deletion of unclosed credits.  Be very careful!  Only delete credits that were data-entry errors, not adjustments.  Optionally specify one or more comma-separated email addresses to be notified when a credit is deleted.',
454     'type'        => [qw( checkbox text )],
455   },
456
457   {
458     'key'         => 'unapplypayments',
459     'section'     => 'deprecated',
460     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable "unapplication" of unclosed payments.',
461     'type'        => 'checkbox',
462   },
463
464   {
465     'key'         => 'unapplycredits',
466     'section'     => 'deprecated',
467     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to nable "unapplication" of unclosed credits.',
468     'type'        => 'checkbox',
469   },
470
471   {
472     'key'         => 'dirhash',
473     'section'     => 'shell',
474     'description' => 'Optional numeric value to control directory hashing.  If positive, hashes directories for the specified number of levels from the front of the username.  If negative, hashes directories for the specified number of levels from the end of the username.  Some examples: <ul><li>1: user -> <a href="#home">/home</a>/u/user<li>2: user -> <a href="#home">/home</a>/u/s/user<li>-1: user -> <a href="#home">/home</a>/r/user<li>-2: user -> <a href="#home">home</a>/r/e/user</ul>',
475     'type'        => 'text',
476   },
477
478   {
479     'key'         => 'disable_customer_referrals',
480     'section'     => 'UI',
481     'description' => 'Disable new customer-to-customer referrals in the web interface',
482     'type'        => 'checkbox',
483   },
484
485   {
486     'key'         => 'editreferrals',
487     'section'     => 'UI',
488     'description' => 'Enable advertising source modification for existing customers',
489     'type'       => 'checkbox',
490   },
491
492   {
493     'key'         => 'emailinvoiceonly',
494     'section'     => 'billing',
495     'description' => 'Disables postal mail invoices',
496     'type'       => 'checkbox',
497   },
498
499   {
500     'key'         => 'disablepostalinvoicedefault',
501     'section'     => 'billing',
502     'description' => 'Disables postal mail invoices as the default option in the UI.  Be careful not to setup customers which are not sent invoices.  See <a href ="#emailinvoiceauto">emailinvoiceauto</a>.',
503     'type'       => 'checkbox',
504   },
505
506   {
507     'key'         => 'emailinvoiceauto',
508     'section'     => 'billing',
509     'description' => 'Automatically adds new accounts to the email invoice list',
510     'type'       => 'checkbox',
511   },
512
513   {
514     'key'         => 'exclude_ip_addr',
515     'section'     => '',
516     'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
517     'type'        => 'textarea',
518   },
519   
520   {
521     'key'         => 'erpcdmachines',
522     'section'     => 'deprecated',
523     'description' => '<b>DEPRECATED</b>, ERPCD is no longer supported.  Used to be ERPCD authentication machines, one per line.  This enables export of `/usr/annex/acp_passwd\' and `/usr/annex/acp_dialup\'',
524     'type'        => 'textarea',
525   },
526
527   {
528     'key'         => 'hidecancelledpackages',
529     'section'     => 'UI',
530     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
531     'type'        => 'checkbox',
532   },
533
534   {
535     'key'         => 'hidecancelledcustomers',
536     'section'     => 'UI',
537     'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
538     'type'        => 'checkbox',
539   },
540
541   {
542     'key'         => 'home',
543     'section'     => 'required',
544     'description' => 'For new users, prefixed to username to create a directory name.  Should have a leading but not a trailing slash.',
545     'type'        => 'text',
546   },
547
548   {
549     'key'         => 'icradiusmachines',
550     'section'     => 'deprecated',
551     'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to enable radcheck and radreply table population - by default in the Freeside database, or in the database specified by the <a href="http://rootwood.haze.st/aspside/config/config-view.cgi#icradius_secrets">icradius_secrets</a> config option (the radcheck and radreply tables needs to be created manually).  You do not need to use MySQL for your Freeside database to export to an ICRADIUS/FreeRADIUS MySQL database with this option.  <blockquote><b>ADDITIONAL DEPRECATED FUNCTIONALITY</b> (instead use <a href="http://www.mysql.com/documentation/mysql/bychapter/manual_MySQL_Database_Administration.html#Replication">MySQL replication</a> or point icradius_secrets to the external database) - your <a href="ftp://ftp.cheapnet.net/pub/icradius">ICRADIUS</a> machines or <a href="http://www.freeradius.org/">FreeRADIUS</a> (with MySQL authentication) machines, one per line.  Machines listed in this file will have the radcheck table exported to them.  Each line should contain four items, separted by whitespace: machine name, MySQL database name, MySQL username, and MySQL password.  For example: <CODE>"radius.isp.tld&nbsp;radius_db&nbsp;radius_user&nbsp;passw0rd"</CODE></blockquote>',
552     'type'        => [qw( checkbox textarea )],
553   },
554
555   {
556     'key'         => 'icradius_mysqldest',
557     'section'     => 'deprecated',
558     'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be the destination directory for the MySQL databases, on the ICRADIUS/FreeRADIUS machines.  Defaults to "/usr/local/var/".',
559     'type'        => 'text',
560   },
561
562   {
563     'key'         => 'icradius_mysqlsource',
564     'section'     => 'deprecated',
565     'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be the source directory for for the MySQL radcheck table files, on the Freeside machine.  Defaults to "/usr/local/var/freeside".',
566     'type'        => 'text',
567   },
568
569   {
570     'key'         => 'icradius_secrets',
571     'section'     => 'deprecated',
572     'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to specify a database for ICRADIUS/FreeRADIUS export.  Three lines: DBI data source, username and password.',
573     'type'        => 'textarea',
574   },
575
576   {
577     'key'         => 'invoice_from',
578     'section'     => 'required',
579     'description' => 'Return address on email invoices',
580     'type'        => 'text',
581   },
582
583   {
584     'key'         => 'invoice_template',
585     'section'     => 'required',
586     'description' => 'Required template file for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
587     'type'        => 'textarea',
588   },
589
590   {
591     'key'         => 'invoice_html',
592     'section'     => 'billing',
593     'description' => 'Optional HTML template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
594
595     'type'        => 'textarea',
596   },
597
598   {
599     'key'         => 'invoice_htmlnotes',
600     'section'     => 'billing',
601     'description' => 'Notes section for HTML invoices.  Defaults to the same data in invoice_latexnotes if not specified.',
602     'type'        => 'textarea',
603   },
604
605   {
606     'key'         => 'invoice_htmlfooter',
607     'section'     => 'billing',
608     'description' => 'Footer for HTML invoices.  Defaults to the same data in invoice_latexfooter if not specified.',
609     'type'        => 'textarea',
610   },
611
612   {
613     'key'         => 'invoice_htmlreturnaddress',
614     'section'     => 'billing',
615     'description' => 'Return address for HTML invoices.  Defaults to the same data in invoice_latexreturnaddress if not specified.',
616     'type'        => 'textarea',
617   },
618
619   {
620     'key'         => 'invoice_latex',
621     'section'     => 'billing',
622     'description' => 'Optional LaTeX template for typeset PostScript invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
623     'type'        => 'textarea',
624   },
625
626   {
627     'key'         => 'invoice_latexnotes',
628     'section'     => 'billing',
629     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
630     'type'        => 'textarea',
631   },
632
633   {
634     'key'         => 'invoice_latexfooter',
635     'section'     => 'billing',
636     'description' => 'Footer for LaTeX typeset PostScript invoices.',
637     'type'        => 'textarea',
638   },
639
640   {
641     'key'         => 'invoice_latexreturnaddress',
642     'section'     => 'billing',
643     'description' => 'Return address for LaTeX typeset PostScript invoices.',
644     'type'        => 'textarea',
645   },
646
647   {
648     'key'         => 'invoice_latexsmallfooter',
649     'section'     => 'billing',
650     'description' => 'Optional small footer for multi-page LaTeX typeset PostScript invoices.',
651     'type'        => 'textarea',
652   },
653
654   {
655     'key'         => 'invoice_email_pdf',
656     'section'     => 'billing',
657     'description' => 'Send PDF invoice as an attachment to emailed invoices.  By default, includes the plain text invoice as the email body, unless invoice_email_pdf_note is set.',
658     'type'        => 'checkbox'
659   },
660
661   {
662     'key'         => 'invoice_email_pdf_note',
663     'section'     => 'billing',
664     'description' => 'If defined, this text will replace the default plain text invoice as the body of emailed PDF invoices.',
665     'type'        => 'textarea'
666   },
667
668
669   { 
670     'key'         => 'invoice_default_terms',
671     'section'     => 'billing',
672     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
673     'type'        => 'select',
674     'select_enum' => [ '', 'Payable upon receipt', 'Net 0', 'Net 10', 'Net 15', 'Net 30', 'Net 45', 'Net 60' ],
675   },
676
677   {
678     'key'         => 'invoice_send_receipts',
679     'section'     => 'deprecated',
680     'description' => '<b>DEPRECATED</b>, this used to send an invoice copy on payments and credits.  See the payment_receipt_email and XXXX instead.',
681     'type'        => 'checkbox',
682   },
683
684   {
685     'key'         => 'payment_receipt_email',
686     'section'     => 'billing',
687     'description' => 'Template file for payment receipts.  Payment receipts are sent to the customer email invoice destination(s) when a payment is received.  See the <a href="http://search.cpan.org/~mjd/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available: <ul><li><code>$date</code> <li><code>$name</code> <li><code>$paynum</code> - Freeside payment number <li><code>$paid</code> - Amount of payment <li><code>$payby</code> - Payment type (Card, Check, Electronic check, etc.) <li><code>$payinfo</code> - Masked credit card number or check number <li><code>$balance</code> - New balance</ul>',
688     'type'        => 'textarea',
689   },
690
691   {
692     'key'         => 'lpr',
693     'section'     => 'required',
694     'description' => 'Print command for paper invoices, for example `lpr -h\'',
695     'type'        => 'text',
696   },
697
698   {
699     'key'         => 'maildisablecatchall',
700     'section'     => 'deprecated',
701     'description' => '<b>DEPRECATED</b>, now the default.  Turning this option on used to disable the requirement that each virtual domain have a catch-all mailbox.',
702     'type'        => 'checkbox',
703   },
704
705   {
706     'key'         => 'money_char',
707     'section'     => '',
708     'description' => 'Currency symbol - defaults to `$\'',
709     'type'        => 'text',
710   },
711
712   {
713     'key'         => 'mxmachines',
714     'section'     => 'deprecated',
715     'description' => 'MX entries for new domains, weight and machine, one per line, with trailing `.\'',
716     'type'        => 'textarea',
717   },
718
719   {
720     'key'         => 'nsmachines',
721     'section'     => 'deprecated',
722     'description' => 'NS nameservers for new domains, one per line, with trailing `.\'',
723     'type'        => 'textarea',
724   },
725
726   {
727     'key'         => 'defaultrecords',
728     'section'     => 'BIND',
729     'description' => 'DNS entries to add automatically when creating a domain',
730     'type'        => 'editlist',
731     'editlist_parts' => [ { type=>'text' },
732                           { type=>'immutable', value=>'IN' },
733                           { type=>'select',
734                             select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS TXT)} },
735                           { type=> 'text' }, ],
736   },
737
738   {
739     'key'         => 'arecords',
740     'section'     => 'deprecated',
741     'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
742     'type'        => 'textarea',
743   },
744
745   {
746     'key'         => 'cnamerecords',
747     'section'     => 'deprecated',
748     'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
749     'type'        => 'textarea',
750   },
751
752   {
753     'key'         => 'nismachines',
754     'section'     => 'deprecated',
755     'description' => '<b>DEPRECATED</b>.  Your NIS master (not slave master) machines, one per line.  This enables export of `/etc/global/passwd\' and `/etc/global/shadow\'.',
756     'type'        => 'textarea',
757   },
758
759   {
760     'key'         => 'passwordmin',
761     'section'     => 'password',
762     'description' => 'Minimum password length (default 6)',
763     'type'        => 'text',
764   },
765
766   {
767     'key'         => 'passwordmax',
768     'section'     => 'password',
769     'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
770     'type'        => 'text',
771   },
772
773   {
774     'key' => 'password-noampersand',
775     'section' => 'password',
776     'description' => 'Disallow ampersands in passwords',
777     'type' => 'checkbox',
778   },
779
780   {
781     'key' => 'password-noexclamation',
782     'section' => 'password',
783     'description' => 'Disallow exclamations in passwords (Not setting this could break old text Livingston or Cistron Radius servers)',
784     'type' => 'checkbox',
785   },
786
787   {
788     'key'         => 'qmailmachines',
789     'section'     => 'deprecated',
790     'description' => '<b>DEPRECATED</b>, add <i>qmail</i> and <i>shellcommands</i> <a href="../browse/part_export.cgi">exports</a> instead.  This option used to export `/var/qmail/control/virtualdomains\', `/var/qmail/control/recipientmap\', and `/var/qmail/control/rcpthosts\'.  Setting this option (even if empty) also turns on user `.qmail-extension\' file maintenance in conjunction with the <b>shellmachine</b> option.',
791     'type'        => [qw( checkbox textarea )],
792   },
793
794   {
795     'key'         => 'radiusmachines',
796     'section'     => 'deprecated',
797     'description' => '<b>DEPRECATED</b>, add an <i>sqlradius</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to export to be: your RADIUS authentication machines, one per line.  This enables export of `/etc/raddb/users\'.',
798     'type'        => 'textarea',
799   },
800
801   {
802     'key'         => 'referraldefault',
803     'section'     => 'UI',
804     'description' => 'Default referral, specified by refnum',
805     'type'        => 'text',
806   },
807
808 #  {
809 #    'key'         => 'registries',
810 #    'section'     => 'required',
811 #    'description' => 'Directory which contains domain registry information.  Each registry is a directory.',
812 #  },
813
814   {
815     'key'         => 'report_template',
816     'section'     => 'deprecated',
817     'description' => 'Deprecated template file for reports.',
818     'type'        => 'textarea',
819   },
820
821
822   {
823     'key'         => 'maxsearchrecordsperpage',
824     'section'     => 'UI',
825     'description' => 'If set, number of search records to return per page.',
826     'type'        => 'text',
827   },
828
829   {
830     'key'         => 'sendmailconfigpath',
831     'section'     => 'deprecated',
832     'description' => '<b>DEPRECATED</b>, add a <i>sendmail</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be sendmail configuration file path.  Defaults to `/etc\'.  Many newer distributions use `/etc/mail\'.',
833     'type'        => 'text',
834   },
835
836   {
837     'key'         => 'sendmailmachines',
838     'section'     => 'deprecated',
839     'description' => '<b>DEPRECATED</b>, add a <i>sendmail</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to be sendmail machines, one per line.  This enables export of `/etc/virtusertable\' and `/etc/sendmail.cw\'.',
840     'type'        => 'textarea',
841   },
842
843   {
844     'key'         => 'sendmailrestart',
845     'section'     => 'deprecated',
846     'description' => '<b>DEPRECATED</b>, add a <i>sendmail</i> <a href="../browse/part_export.cgi">export</a> instead.  Used to define the command which is run on sendmail machines after files are copied.',
847     'type'        => 'text',
848   },
849
850   {
851     'key'         => 'session-start',
852     'section'     => 'session',
853     'description' => 'If defined, the command which is executed on the Freeside machine when a session begins.  The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.',
854     'type'        => 'text',
855   },
856
857   {
858     'key'         => 'session-stop',
859     'section'     => 'session',
860     'description' => 'If defined, the command which is executed on the Freeside machine when a session ends.  The contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$ip</code>, <code>$nasip</code> and <code>$nasfqdn</code>, which are the IP address of the starting session, and the IP address and fully-qualified domain name of the NAS this session is on.',
861     'type'        => 'text',
862   },
863
864   {
865     'key'         => 'shellmachine',
866     'section'     => 'deprecated',
867     'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to contain a single machine with user home directories mounted.  This enables home directory creation, renaming and archiving/deletion.  In conjunction with `qmailmachines\', it also enables `.qmail-extension\' file maintenance.',
868     'type'        => 'text',
869   },
870
871   {
872     'key'         => 'shellmachine-useradd',
873     'section'     => 'deprecated',
874     'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to contain command(s) to run on shellmachine when an account is created.  If the <b>shellmachine</b> option is set but this option is not, <code>useradd -d $dir -m -s $shell -u $uid $username</code> is the default.  If this option is set but empty, <code>cp -pr /etc/skel $dir; chown -R $uid.$gid $dir</code> is the default instead.  Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: <code>$username</code>, <code>$uid</code>, <code>$gid</code>, <code>$dir</code>, and <code>$shell</code>.',
875     'type'        => [qw( checkbox text )],
876   },
877
878   {
879     'key'         => 'shellmachine-userdel',
880     'section'     => 'deprecated',
881     'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to contain command(s) to run on shellmachine when an account is deleted.  If the <b>shellmachine</b> option is set but this option is not, <code>userdel $username</code> is the default.  If this option is set but empty, <code>rm -rf $dir</code> is the default instead.  Otherwise the value is evaluated as a double-quoted perl string, with the following variables available: <code>$username</code> and <code>$dir</code>.',
882     'type'        => [qw( checkbox text )],
883   },
884
885   {
886     'key'         => 'shellmachine-usermod',
887     'section'     => 'deprecated',
888     'description' => '<b>DEPRECATED</b>, add a <i>shellcommands</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to contain command(s) to run on shellmachine when an account is modified.  If the <b>shellmachine</b> option is set but this option is empty, <code>[ -d $old_dir ] &amp;&amp; mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $uid.$gid $new_dir; rm -rf $old_dir )</code> is the default.  Otherwise the contents of the file are treated as a double-quoted perl string, with the following variables available: <code>$old_dir</code>, <code>$new_dir</code>, <code>$uid</code> and <code>$gid</code>.',
889     #'type'        => [qw( checkbox text )],
890     'type'        => 'text',
891   },
892
893   {
894     'key'         => 'shellmachines',
895     'section'     => 'deprecated',
896     'description' => '<b>DEPRECATED</b>, add a <i>sysvshell</i> <a href="../browse/part_export.cgi">export</a> instead.  Your Linux and System V flavored shell (and mail) machines, one per line.  This enables export of `/etc/passwd\' and `/etc/shadow\' files.',
897      'type'        => 'textarea',
898  },
899
900   {
901     'key'         => 'shells',
902     'section'     => 'required',
903     'description' => 'Legal shells (think /etc/shells).  You probably want to `cut -d: -f7 /etc/passwd | sort | uniq\' initially so that importing doesn\'t fail with `Illegal shell\' errors, then remove any special entries afterwords.  A blank line specifies that an empty shell is permitted.',
904     'type'        => 'textarea',
905   },
906
907   {
908     'key'         => 'showpasswords',
909     'section'     => 'UI',
910     'description' => 'Display unencrypted user passwords in the backend (employee) web interface',
911     'type'        => 'checkbox',
912   },
913
914   {
915     'key'         => 'signupurl',
916     'section'     => 'UI',
917     'description' => 'if you are using customer-to-customer referrals, and you enter the URL of your <a href="../docs/signup.html">signup server CGI</a>, the customer view screen will display a customized link to the signup server with the appropriate customer as referral',
918     'type'        => 'text',
919   },
920
921   {
922     'key'         => 'smtpmachine',
923     'section'     => 'required',
924     'description' => 'SMTP relay for Freeside\'s outgoing mail',
925     'type'        => 'text',
926   },
927
928   {
929     'key'         => 'soadefaultttl',
930     'section'     => 'BIND',
931     'description' => 'SOA default TTL for new domains.',
932     'type'        => 'text',
933   },
934
935   {
936     'key'         => 'soaemail',
937     'section'     => 'BIND',
938     'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
939     'type'        => 'text',
940   },
941
942   {
943     'key'         => 'soaexpire',
944     'section'     => 'BIND',
945     'description' => 'SOA expire for new domains',
946     'type'        => 'text',
947   },
948
949   {
950     'key'         => 'soamachine',
951     'section'     => 'BIND',
952     'description' => 'SOA machine for new domains, with trailing `.\'',
953     'type'        => 'text',
954   },
955
956   {
957     'key'         => 'soarefresh',
958     'section'     => 'BIND',
959     'description' => 'SOA refresh for new domains',
960     'type'        => 'text',
961   },
962
963   {
964     'key'         => 'soaretry',
965     'section'     => 'BIND',
966     'description' => 'SOA retry for new domains',
967     'type'        => 'text',
968   },
969
970   {
971     'key'         => 'statedefault',
972     'section'     => 'UI',
973     'description' => 'Default state or province (if not supplied, the default is `CA\')',
974     'type'        => 'text',
975   },
976
977   {
978     'key'         => 'radiusprepend',
979     'section'     => 'deprecated',
980     'description' => '<b>DEPRECATED</b>, real-time text radius now edits an existing file in place - just (turn off freeside-queued and) edit your RADIUS users file directly.  The contents used to be be prepended to the top of the RADIUS users file (text exports only).',
981     'type'        => 'textarea',
982   },
983
984   {
985     'key'         => 'textradiusprepend',
986     'section'     => 'deprecated',
987     'description' => '<b>DEPRECATED</b>, use RADIUS check attributes instead.  The contents used to be prepended to the first line of a user\'s RADIUS entry in text exports.',
988     'type'        => 'text',
989   },
990
991   {
992     'key'         => 'unsuspendauto',
993     'section'     => 'billing',
994     'description' => 'Enables the automatic unsuspension of suspended packages when a customer\'s balance due changes from positive to zero or negative as the result of a payment or credit',
995     'type'        => 'checkbox',
996   },
997
998   {
999     'key'         => 'usernamemin',
1000     'section'     => 'username',
1001     'description' => 'Minimum username length (default 2)',
1002     'type'        => 'text',
1003   },
1004
1005   {
1006     'key'         => 'usernamemax',
1007     'section'     => 'username',
1008     'description' => 'Maximum username length',
1009     'type'        => 'text',
1010   },
1011
1012   {
1013     'key'         => 'username-ampersand',
1014     'section'     => 'username',
1015     'description' => 'Allow the ampersand character (&amp;) in usernames.  Be careful when using this option in conjunction with <a href="../browse/part_export.cgi">exports</a> which execute shell commands, as the ampersand will be interpreted by the shell if not quoted.',
1016     'type'        => 'checkbox',
1017   },
1018
1019   {
1020     'key'         => 'username-letter',
1021     'section'     => 'username',
1022     'description' => 'Usernames must contain at least one letter',
1023     'type'        => 'checkbox',
1024   },
1025
1026   {
1027     'key'         => 'username-letterfirst',
1028     'section'     => 'username',
1029     'description' => 'Usernames must start with a letter',
1030     'type'        => 'checkbox',
1031   },
1032
1033   {
1034     'key'         => 'username-noperiod',
1035     'section'     => 'username',
1036     'description' => 'Disallow periods in usernames',
1037     'type'        => 'checkbox',
1038   },
1039
1040   {
1041     'key'         => 'username-nounderscore',
1042     'section'     => 'username',
1043     'description' => 'Disallow underscores in usernames',
1044     'type'        => 'checkbox',
1045   },
1046
1047   {
1048     'key'         => 'username-nodash',
1049     'section'     => 'username',
1050     'description' => 'Disallow dashes in usernames',
1051     'type'        => 'checkbox',
1052   },
1053
1054   {
1055     'key'         => 'username-uppercase',
1056     'section'     => 'username',
1057     'description' => 'Allow uppercase characters in usernames',
1058     'type'        => 'checkbox',
1059   },
1060
1061   { 
1062     'key'         => 'username-percent',
1063     'section'     => 'username',
1064     'description' => 'Allow the percent character (%) in usernames.',
1065     'type'        => 'checkbox',
1066   },
1067
1068   {
1069     'key'         => 'username_policy',
1070     'section'     => 'deprecated',
1071     'description' => 'This file controls the mechanism for preventing duplicate usernames in passwd/radius files exported from svc_accts.  This should be one of \'prepend domsvc\' \'append domsvc\' \'append domain\' or \'append @domain\'',
1072     'type'        => 'select',
1073     'select_enum' => [ 'prepend domsvc', 'append domsvc', 'append domain', 'append @domain' ],
1074     #'type'        => 'text',
1075   },
1076
1077   {
1078     'key'         => 'vpopmailmachines',
1079     'section'     => 'deprecated',
1080     'description' => '<b>DEPRECATED</b>, add a <i>vpopmail</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to contain your vpopmail pop toasters, one per line.  Each line is of the form "machinename vpopdir vpopuid vpopgid".  For example: <code>poptoaster.domain.tld /home/vpopmail 508 508</code>  Note: vpopuid and vpopgid are values taken from the vpopmail machine\'s /etc/passwd',
1081     'type'        => 'textarea',
1082   },
1083
1084   {
1085     'key'         => 'vpopmailrestart',
1086     'section'     => 'deprecated',
1087     'description' => '<b>DEPRECATED</b>, add a <i>vpopmail</i> <a href="../browse/part_export.cgi">export</a> instead.  This option used to define the shell commands to run on vpopmail machines after files are copied.  An example can be found in eg/vpopmailrestart of the source distribution.',
1088     'type'        => 'textarea',
1089   },
1090
1091   {
1092     'key'         => 'safe-part_pkg',
1093     'section'     => 'deprecated',
1094     'description' => '<b>DEPRECATED</b>, obsolete.  Used to validate package definition setup and recur expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
1095     'type'        => 'checkbox',
1096   },
1097
1098   {
1099     'key'         => 'safe-part_bill_event',
1100     'section'     => 'UI',
1101     'description' => 'Validates invoice event expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
1102     'type'        => 'checkbox',
1103   },
1104
1105   {
1106     'key'         => 'show_ss',
1107     'section'     => 'UI',
1108     'description' => 'Turns on display/collection of SS# in the web interface.',
1109     'type'        => 'checkbox',
1110   },
1111
1112   { 
1113     'key'         => 'agent_defaultpkg',
1114     'section'     => 'UI',
1115     'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
1116     'type'        => 'checkbox',
1117   },
1118
1119   {
1120     'key'         => 'legacy_link',
1121     'section'     => 'UI',
1122     'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
1123     'type'        => 'checkbox',
1124   },
1125
1126   {
1127     'key'         => 'legacy_link-steal',
1128     'section'     => 'UI',
1129     'description' => 'Allow "stealing" an already-audited service from one customer (or package) to another using the link function.',
1130     'type'        => 'checkbox',
1131   },
1132
1133   {
1134     'key'         => 'queue_dangerous_controls',
1135     'section'     => 'UI',
1136     'description' => 'Enable queue modification controls on account pages and for new jobs.  Unless you are a developer working on new export code, you should probably leave this off to avoid causing provisioning problems.',
1137     'type'        => 'checkbox',
1138   },
1139
1140   {
1141     'key'         => 'security_phrase',
1142     'section'     => 'password',
1143     'description' => 'Enable the tracking of a "security phrase" with each account.  Not recommended, as it is vulnerable to social engineering.',
1144     'type'        => 'checkbox',
1145   },
1146
1147   {
1148     'key'         => 'locale',
1149     'section'     => 'UI',
1150     'description' => 'Message locale',
1151     'type'        => 'select',
1152     'select_enum' => [ qw(en_US) ],
1153   },
1154
1155   {
1156     'key'         => 'selfservice_server-quiet',
1157     'section'     => 'deprecated',
1158     'description' => '<b>DEPRECATED</b>, the self-service server no longer sends superfluous decline and cancel emails.  Used to disable decline and cancel emails generated by transactions initiated by the selfservice server.',
1159     'type'        => 'checkbox',
1160   },
1161
1162   {
1163     'key'         => 'signup_server-quiet',
1164     'section'     => 'deprecated',
1165     'description' => '<b>DEPRECATED</b>, the signup server is now part of the self-service server and no longer sends superfluous decline and cancel emails.  Used to disable decline and cancel emails generated by transactions initiated by the signup server.  Does not disable welcome emails.',
1166     'type'        => 'checkbox',
1167   },
1168
1169   {
1170     'key'         => 'signup_server-payby',
1171     'section'     => '',
1172     'description' => 'Acceptable payment types for the signup server',
1173     'type'        => 'selectmultiple',
1174     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
1175   },
1176
1177   {
1178     'key'         => 'signup_server-email',
1179     'section'     => 'deprecated',
1180     'description' => '<b>DEPRECATED</b>, this feature is no longer available.  See the ***fill me in*** report instead.  Used to contain a comma-separated list of email addresses to receive notification of signups via the signup server.',
1181     'type'        => 'text',
1182   },
1183
1184   {
1185     'key'         => 'signup_server-default_agentnum',
1186     'section'     => '',
1187     'description' => 'Default agentnum for the signup server',
1188     'type'        => 'text',
1189   },
1190
1191   {
1192     'key'         => 'signup_server-default_refnum',
1193     'section'     => '',
1194     'description' => 'Default advertising source number for the signup server',
1195     'type'        => 'text',
1196   },
1197
1198   {
1199     'key'         => 'show-msgcat-codes',
1200     'section'     => 'UI',
1201     'description' => 'Show msgcat codes in error messages.  Turn this option on before reporting errors to the mailing list.',
1202     'type'        => 'checkbox',
1203   },
1204
1205   {
1206     'key'         => 'signup_server-realtime',
1207     'section'     => '',
1208     'description' => 'Run billing for signup server signups immediately, and do not provision accounts which subsequently have a balance.',
1209     'type'        => 'checkbox',
1210   },
1211   {
1212       key         => 'signup_server-classnum2',
1213       section     => '',
1214       description => 'Package Class for first optional purchase',
1215       type        => 'select-sub',
1216       options_sub => sub { my @o = map { $_->{classnum} => $_->{classname} }  map { $_->hashref } FS::Record::qsearch('pkg_class',{});
1217                            } ,
1218       option_sub => sub { return map { $_->hashref->{classname}}  FS::Record::qsearchs('pkg_class', { classnum => shift } );  }, 
1219
1220   },
1221
1222   {
1223       key         => 'signup_server-classnum3',
1224       section     => '',
1225       description => 'Package Class for second optional purchase',
1226       type        => 'select-sub',
1227       options_sub => sub { my @o = map { $_->{classnum} => $_->{classname} }  map { $_->hashref } FS::Record::qsearch('pkg_class',{});
1228                            } ,
1229       option_sub => sub { return map { $_->hashref->{classname}}  FS::Record::qsearchs('pkg_class', { classnum => shift } );  }, 
1230   },
1231
1232   {
1233     'key'         => 'backend-realtime',
1234     'section'     => '',
1235     'description' => 'Run billing for backend signups immediately.',
1236     'type'        => 'checkbox',
1237   },
1238
1239   {
1240     'key'         => 'declinetemplate',
1241     'section'     => 'billing',
1242     'description' => 'Template file for credit card decline emails.',
1243     'type'        => 'textarea',
1244   },
1245
1246   {
1247     'key'         => 'emaildecline',
1248     'section'     => 'billing',
1249     'description' => 'Enable emailing of credit card decline notices.',
1250     'type'        => 'checkbox',
1251   },
1252
1253   {
1254     'key'         => 'emaildecline-exclude',
1255     'section'     => 'billing',
1256     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
1257     'type'        => 'textarea',
1258   },
1259
1260   {
1261     'key'         => 'cancelmessage',
1262     'section'     => 'billing',
1263     'description' => 'Template file for cancellation emails.',
1264     'type'        => 'textarea',
1265   },
1266
1267   {
1268     'key'         => 'cancelsubject',
1269     'section'     => 'billing',
1270     'description' => 'Subject line for cancellation emails.',
1271     'type'        => 'text',
1272   },
1273
1274   {
1275     'key'         => 'emailcancel',
1276     'section'     => 'billing',
1277     'description' => 'Enable emailing of cancellation notices.',
1278     'type'        => 'checkbox',
1279   },
1280
1281   {
1282     'key'         => 'require_cardname',
1283     'section'     => 'billing',
1284     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
1285     'type'        => 'checkbox',
1286   },
1287
1288   {
1289     'key'         => 'enable_taxclasses',
1290     'section'     => 'billing',
1291     'description' => 'Enable per-package tax classes',
1292     'type'        => 'checkbox',
1293   },
1294
1295   {
1296     'key'         => 'require_taxclasses',
1297     'section'     => 'billing',
1298     'description' => 'Require a taxclass to be entered for every package',
1299     'type'        => 'checkbox',
1300   },
1301
1302   {
1303     'key'         => 'welcome_email',
1304     'section'     => '',
1305     'description' => 'Template file for welcome email.  Welcome emails are sent to the customer email invoice destination(s) each time a svc_acct record is created.  See the <a href="http://search.cpan.org/~mjd/Text-Template/lib/Text/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available<ul><li><code>$username</code> <li><code>$password</code> <li><code>$first</code> <li><code>$last</code> <li><code>$pkg</code></ul>',
1306     'type'        => 'textarea',
1307   },
1308
1309   {
1310     'key'         => 'welcome_email-from',
1311     'section'     => '',
1312     'description' => 'From: address header for welcome email',
1313     'type'        => 'text',
1314   },
1315
1316   {
1317     'key'         => 'welcome_email-subject',
1318     'section'     => '',
1319     'description' => 'Subject: header for welcome email',
1320     'type'        => 'text',
1321   },
1322   
1323   {
1324     'key'         => 'welcome_email-mimetype',
1325     'section'     => '',
1326     'description' => 'MIME type for welcome email',
1327     'type'        => 'select',
1328     'select_enum' => [ 'text/plain', 'text/html' ],
1329   },
1330
1331   {
1332     'key'         => 'payby',
1333     'section'     => 'billing',
1334     'description' => 'Available payment types.',
1335     'type'        => 'selectmultiple',
1336     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP) ],
1337   },
1338
1339   {
1340     'key'         => 'payby-default',
1341     'section'     => 'UI',
1342     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
1343     'type'        => 'select',
1344     'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL CASH WEST MCRD COMP HIDE) ],
1345   },
1346
1347   {
1348     'key'         => 'svc_acct-notes',
1349     'section'     => 'UI',
1350     'description' => 'Extra HTML to be displayed on the Account View screen.',
1351     'type'        => 'textarea',
1352   },
1353
1354   {
1355     'key'         => 'radius-password',
1356     'section'     => '',
1357     'description' => 'RADIUS attribute for plain-text passwords.',
1358     'type'        => 'select',
1359     'select_enum' => [ 'Password', 'User-Password' ],
1360   },
1361
1362   {
1363     'key'         => 'radius-ip',
1364     'section'     => '',
1365     'description' => 'RADIUS attribute for IP addresses.',
1366     'type'        => 'select',
1367     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
1368   },
1369
1370   {
1371     'key'         => 'svc_acct-alldomains',
1372     'section'     => '',
1373     'description' => 'Allow accounts to select any domain in the database.  Normally accounts can only select from the domain set in the service definition and those purchased by the customer.',
1374     'type'        => 'checkbox',
1375   },
1376
1377   {
1378     'key'         => 'dump-scpdest',
1379     'section'     => '',
1380     'description' => 'destination for scp database dumps: user@host:/path',
1381     'type'        => 'text',
1382   },
1383
1384   {
1385     'key'         => 'dump-pgpid',
1386     'section'     => '',
1387     'description' => "Optional PGP public key user or key id for database dumps.  The public key should exist on the freeside user's public keyring, and the gpg binary and GnuPG perl module should be installed.",
1388     'type'        => 'text',
1389   },
1390
1391   {
1392     'key'         => 'users-allow_comp',
1393     'section'     => 'deprecated',
1394     'description' => '<b>DEPRECATED</b>, enable the <i>Complimentary customer</i> access right instead.  Was: Usernames (Freeside users, created with <a href="../docs/man/bin/freeside-adduser.html">freeside-adduser</a>) which can create complimentary customers, one per line.  If no usernames are entered, all users can create complimentary accounts.',
1395     'type'        => 'textarea',
1396   },
1397
1398   {
1399     'key'         => 'cvv-save',
1400     'section'     => 'billing',
1401     'description' => 'Save CVV2 information after the initial transaction for the selected credit card types.  Enabling this option may be in violation of your merchant agreement(s), so please check them carefully before enabling this option for any credit card types.',
1402     'type'        => 'selectmultiple',
1403     'select_enum' => [ "VISA card",
1404                        "MasterCard",
1405                        "Discover card",
1406                        "American Express card",
1407                        "Diner's Club/Carte Blanche",
1408                        "enRoute",
1409                        "JCB",
1410                        "BankCard",
1411                      ],
1412   },
1413
1414   {
1415     'key'         => 'allow_negative_charges',
1416     'section'     => 'billing',
1417     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
1418     'type'        => 'checkbox',
1419   },
1420   {
1421       'key'         => 'auto_unset_catchall',
1422       'section'     => '',
1423       'description' => 'When canceling a svc_acct that is the email catchall for one or more svc_domains, automatically set their catchall fields to null.  If this option is not set, the attempt will simply fail.',
1424       'type'        => 'checkbox',
1425   },
1426
1427   {
1428     'key'         => 'system_usernames',
1429     'section'     => 'username',
1430     'description' => 'A list of system usernames that cannot be edited or removed, one per line.  Use a bare username to prohibit modification/deletion of the username in any domain, or username@domain to prohibit modification/deletetion of a specific username and domain.',
1431     'type'        => 'textarea',
1432   },
1433
1434   {
1435     'key'         => 'cust_pkg-change_svcpart',
1436     'section'     => '',
1437     'description' => "When changing packages, move services even if svcparts don't match between old and new pacakge definitions.",
1438     'type'        => 'checkbox',
1439   },
1440
1441   {
1442     'key'         => 'disable_autoreverse',
1443     'section'     => 'BIND',
1444     'description' => 'Disable automatic synchronization of reverse-ARPA entries.',
1445     'type'        => 'checkbox',
1446   },
1447
1448   {
1449     'key'         => 'svc_www-enable_subdomains',
1450     'section'     => '',
1451     'description' => 'Enable selection of specific subdomains for virtual host creation.',
1452     'type'        => 'checkbox',
1453   },
1454
1455   {
1456     'key'         => 'svc_www-usersvc_svcpart',
1457     'section'     => '',
1458     'description' => 'Allowable service definition svcparts for virtual hosts, one per line.',
1459     'type'        => 'textarea',
1460   },
1461
1462   {
1463     'key'         => 'selfservice_server-primary_only',
1464     'section'     => '',
1465     'description' => 'Only allow primary accounts to access self-service functionality.',
1466     'type'        => 'checkbox',
1467   },
1468
1469   {
1470     'key'         => 'card_refund-days',
1471     'section'     => 'billing',
1472     'description' => 'After a payment, the number of days a refund link will be available for that payment.  Defaults to 120.',
1473     'type'        => 'text',
1474   },
1475
1476   {
1477     'key'         => 'agent-showpasswords',
1478     'section'     => '',
1479     'description' => 'Display unencrypted user passwords in the agent (reseller) interface',
1480     'type'        => 'checkbox',
1481   },
1482
1483   {
1484     'key'         => 'global_unique-username',
1485     'section'     => 'username',
1486     'description' => 'Global username uniqueness control: none (usual setting - check uniqueness per exports), username (all usernames are globally unique, regardless of domain or exports), or username@domain (all username@domain pairs are globally unique, regardless of exports).  disabled turns off duplicate checking completely and is STRONGLY NOT RECOMMENDED unless you REALLY need to turn this off.',
1487     'type'        => 'select',
1488     'select_enum' => [ 'none', 'username', 'username@domain', 'disabled' ],
1489   },
1490
1491   {
1492     'key'         => 'svc_external-skip_manual',
1493     'section'     => 'UI',
1494     'description' => 'When provisioning svc_external services, skip manual entry of id and title fields in the UI.  Usually used in conjunction with an export that populates these fields (i.e. artera_turbo).',
1495     'type'        => 'checkbox',
1496   },
1497
1498   {
1499     'key'         => 'svc_external-display_type',
1500     'section'     => 'UI',
1501     'description' => 'Select a specific svc_external type to enable some UI changes specific to that type (i.e. artera_turbo).',
1502     'type'        => 'select',
1503     'select_enum' => [ 'generic', 'artera_turbo', ],
1504   },
1505
1506   {
1507     'key'         => 'ticket_system',
1508     'section'     => '',
1509     'description' => 'Ticketing system integration.  <b>RT_Internal</b> uses the built-in RT ticketing system (see the <a href="../docs/install-rt">integrated ticketing installation instructions</a>).   <b>RT_External</b> accesses an external RT installation in a separate database (local or remote).',
1510     'type'        => 'select',
1511     #'select_enum' => [ '', qw(RT_Internal RT_Libs RT_External) ],
1512     'select_enum' => [ '', qw(RT_Internal RT_External) ],
1513   },
1514
1515   {
1516     'key'         => 'ticket_system-default_queueid',
1517     'section'     => '',
1518     'description' => 'Default queue used when creating new customer tickets.',
1519     'type'        => 'select-sub',
1520     'options_sub' => sub {
1521                            my $conf = new FS::Conf;
1522                            if ( $conf->config('ticket_system') ) {
1523                              eval "use FS::TicketSystem;";
1524                              die $@ if $@;
1525                              FS::TicketSystem->queues();
1526                            } else {
1527                              ();
1528                            }
1529                          },
1530     'option_sub'  => sub { 
1531                            my $conf = new FS::Conf;
1532                            if ( $conf->config('ticket_system') ) {
1533                              eval "use FS::TicketSystem;";
1534                              die $@ if $@;
1535                              FS::TicketSystem->queue(shift);
1536                            } else {
1537                              '';
1538                            }
1539                          },
1540   },
1541
1542   {
1543     'key'         => 'ticket_system-custom_priority_field',
1544     'section'     => '',
1545     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
1546     'type'        => 'text',
1547   },
1548
1549   {
1550     'key'         => 'ticket_system-custom_priority_field-values',
1551     'section'     => '',
1552     'description' => 'Values for the custom field from the ticketing system to break down and sort customer ticket lists.',
1553     'type'        => 'textarea',
1554   },
1555
1556   {
1557     'key'         => 'ticket_system-custom_priority_field_queue',
1558     'section'     => '',
1559     'description' => 'Ticketing system queue in which the custom field specified in ticket_system-custom_priority_field is located.',
1560     'type'        => 'text',
1561   },
1562
1563   {
1564     'key'         => 'ticket_system-rt_external_datasrc',
1565     'section'     => '',
1566     'description' => 'With external RT integration, the DBI data source for the external RT installation, for example, <code>DBI:Pg:user=rt_user;password=rt_word;host=rt.example.com;dbname=rt</code>',
1567     'type'        => 'text',
1568
1569   },
1570
1571   {
1572     'key'         => 'ticket_system-rt_external_url',
1573     'section'     => '',
1574     'description' => 'With external RT integration, the URL for the external RT installation, for example, <code>https://rt.example.com/rt</code>',
1575     'type'        => 'text',
1576   },
1577
1578   {
1579     'key'         => 'company_name',
1580     'section'     => 'required',
1581     'description' => 'Your company name',
1582     'type'        => 'text',
1583   },
1584
1585   {
1586     'key'         => 'echeck-void',
1587     'section'     => 'deprecated',
1588     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable local-only voiding of echeck payments in addition to refunds against the payment gateway',
1589     'type'        => 'checkbox',
1590   },
1591
1592   {
1593     'key'         => 'cc-void',
1594     'section'     => 'deprecated',
1595     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable local-only voiding of credit card payments in addition to refunds against the payment gateway',
1596     'type'        => 'checkbox',
1597   },
1598
1599   {
1600     'key'         => 'unvoid',
1601     'section'     => 'deprecated',
1602     'description' => '<B>DEPRECATED</B>, now controlled by ACLs.  Used to enable unvoiding of voided payments',
1603     'type'        => 'checkbox',
1604   },
1605
1606   {
1607     'key'         => 'address2-search',
1608     'section'     => 'UI',
1609     'description' => 'Enable a "Unit" search box which searches the second address field',
1610     'type'        => 'checkbox',
1611   },
1612
1613   { 'key'         => 'referral_credit',
1614     'section'     => 'billing',
1615     'description' => "Enables one-time referral credits in the amount of one month <i>referred</i> customer's recurring fee (irregardless of frequency).",
1616     'type'        => 'checkbox',
1617   },
1618
1619   { 'key'         => 'selfservice_server-cache_module',
1620     'section'     => '',
1621     'description' => 'Module used to store self-service session information.  All modules handle any number of self-service servers.  Cache::SharedMemoryCache is appropriate for a single database / single Freeside server.  Cache::FileCache is useful for multiple databases on a single server, or when IPC::ShareLite is not available (i.e. FreeBSD).', #  _Database stores session information in the database and is appropriate for multiple Freeside servers, but may be slower.',
1622     'type'        => 'select',
1623     'select_enum' => [ 'Cache::SharedMemoryCache', 'Cache::FileCache', ], # '_Database' ],
1624   },
1625
1626   {
1627     'key'         => 'hylafax',
1628     'section'     => '',
1629     'description' => 'Options for a HylaFAX server to enable the FAX invoice destination.  They should be in the form of a space separated list of arguments to the Fax::Hylafax::Client::sendfax subroutine.  You probably shouldn\'t override things like \'docfile\'.  *Note* Only supported when using typeset invoices (see the invoice_latex configuration option).',
1630     'type'        => [qw( checkbox textarea )],
1631   },
1632
1633   {
1634     'key'         => 'svc_acct-usage_suspend',
1635     'section'     => 'billing',
1636     'description' => 'Suspends the package an account belongs to when svc_acct.seconds is decremented to 0 or below (accounts with an empty seconds value are ignored).  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
1637     'type'        => 'checkbox',
1638   },
1639
1640   {
1641     'key'         => 'svc_acct-usage_unsuspend',
1642     'section'     => 'billing',
1643     'description' => 'Unuspends the package an account belongs to when svc_acct.seconds is incremented from 0 or below to a positive value (accounts with an empty seconds value are ignored).  Typically used in conjunction with prepaid packages and freeside-sqlradius-radacctd.',
1644     'type'        => 'checkbox',
1645   },
1646
1647   {
1648     'key'         => 'cust-fields',
1649     'section'     => 'UI',
1650     'description' => 'Which customer fields to display on reports by default',
1651     'type'        => 'select',
1652     'select_hash' => [ FS::ConfDefaults->cust_fields_avail() ],
1653   },
1654
1655   {
1656     'key'         => 'cust_pkg-display_times',
1657     'section'     => 'UI',
1658     'description' => 'Display full timestamps (not just dates) for customer packages.  Useful if you are doing real-time things like hourly prepaid.',
1659     'type'        => 'checkbox',
1660   },
1661
1662   {
1663     'key'         => 'svc_acct-edit_uid',
1664     'section'     => 'shell',
1665     'description' => 'Allow UID editing.',
1666     'type'        => 'checkbox',
1667   },
1668
1669   {
1670     'key'         => 'svc_acct-edit_gid',
1671     'section'     => 'shell',
1672     'description' => 'Allow GID editing.',
1673     'type'        => 'checkbox',
1674   },
1675
1676   {
1677     'key'         => 'zone-underscore',
1678     'section'     => 'BIND',
1679     'description' => 'Allow underscores in zone names.  As underscores are illegal characters in zone names, this option is not recommended.',
1680     'type'        => 'checkbox',
1681   },
1682
1683   #these should become per-user...
1684   {
1685     'key'         => 'vonage-username',
1686     'section'     => '',
1687     'description' => 'Vonage Click2Call username (see <a href="https://secure.click2callu.com/">https://secure.click2callu.com/</a>)',
1688     'type'        => 'text',
1689   },
1690   {
1691     'key'         => 'vonage-password',
1692     'section'     => '',
1693     'description' => 'Vonage Click2Call username (see <a href="https://secure.click2callu.com/">https://secure.click2callu.com/</a>)',
1694     'type'        => 'text',
1695   },
1696   {
1697     'key'         => 'vonage-fromnumber',
1698     'section'     => '',
1699     'description' => 'Vonage Click2Call number (see <a href="https://secure.click2callu.com/">https://secure.click2callu.com/</a>)',
1700     'type'        => 'text',
1701   },
1702
1703   {
1704     'key'         => 'echeck-nonus',
1705     'section'     => 'billing',
1706     'description' => 'Disable ABA-format account checking for Electronic Check payment info',
1707     'type'        => 'checkbox',
1708   },
1709
1710   {
1711     'key'         => 'voip-cust_cdr_spools',
1712     'section'     => '',
1713     'description' => 'Enable the per-customer option for individual CDR spools.',
1714     'type'        => 'checkbox',
1715   },
1716
1717   {
1718     'key'         => 'svc_forward-arbitrary_dst',
1719     'section'     => '',
1720     'description' => "Allow forwards to point to arbitrary strings that don't necessarily look like email addresses.  Only used when using forwards for weird, non-email things.",
1721     'type'        => 'checkbox',
1722   },
1723
1724   {
1725     'key'         => 'tax-ship_address',
1726     'section'     => 'billing',
1727     'description' => 'By default, tax calculations are done based on the billing address.  Enable this switch to calculate tax based on the shipping address instead.  Note: Tax reports can take a long time when enabled.',
1728     'type'        => 'checkbox',
1729   },
1730
1731   {
1732     'key'         => 'batch-enable',
1733     'section'     => 'billing',
1734     'description' => 'Enable credit card batching - leave disabled for real-time installations.',
1735     'type'        => 'checkbox',
1736   },
1737
1738   {
1739     'key'         => 'batch-default_format',
1740     'section'     => 'billing',
1741     'description' => 'Default format for batches.',
1742     'type'        => 'select',
1743     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ]
1744   },
1745
1746   {
1747     'key'         => 'batch-fixed_format-CARD',
1748     'section'     => 'billing',
1749     'description' => 'Fixed (unchangeable) format for credit card batches.',
1750     'type'        => 'select',
1751     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ]
1752   },
1753
1754   {
1755     'key'         => 'batch-fixed_format-CHEK',
1756     'section'     => 'billing',
1757     'description' => 'Fixed (unchangeable) format for electronic check batches.',
1758     'type'        => 'select',
1759     'select_enum' => [ 'csv-td_canada_trust-merchant_pc_batch', 'BoM', 'PAP' ]
1760   },
1761
1762   {
1763     'key'         => 'batchconfig-BoM',
1764     'section'     => 'billing',
1765     'description' => 'Configuration for Bank of Montreal batching, seven lines: 1. Origin ID, 2. Datacenter, 3. Typecode, 4. Short name, 5. Long name, 6. Bank, 7. Bank account',
1766     'type'        => 'textarea',
1767   },
1768
1769   {
1770     'key'         => 'payment_history-years',
1771     'section'     => 'UI',
1772     'description' => 'Number of years of payment history to show by default.  Currently defaults to 2.',
1773     'type'        => 'text',
1774   },
1775
1776   {
1777     'key'         => 'cust_main-use_comments',
1778     'section'     => 'UI',
1779     'description' => 'Display free form comments on the customer edit screen.  Useful as a scratch pad.',
1780     'type'        => 'checkbox',
1781   },
1782
1783   {
1784     'key'         => 'cust_main-disable_notes',
1785     'section'     => 'UI',
1786     'description' => 'Disable new style customer notes - timestamped and user identified customr notes.  Useful in tracking who did what.',
1787     'type'        => 'checkbox',
1788   },
1789
1790   {
1791     'key'         => 'cust_main_note-display_times',
1792     'section'     => 'UI',
1793     'description' => 'Display full timestamps (not just dates) for customer notes.',
1794     'type'        => 'checkbox',
1795   },
1796
1797   {
1798     'key'         => 'cust_main-ticket_statuses',
1799     'section'     => 'UI',
1800     'description' => 'Show tickets with these statuses on the customer view page.',
1801     'type'        => 'selectmultiple',
1802     'select_enum' => [qw( new open stalled resolved rejected deleted )],
1803   },
1804
1805   {
1806     'key'         => 'cust_main-max_tickets',
1807     'section'     => 'UI',
1808     'description' => 'Maximum number of tickets to show on the customer view page.',
1809     'type'        => 'text',
1810   },
1811
1812   {
1813     'key'         => 'cust_main-skeleton_tables',
1814     'section'     => '',
1815     'description' => 'Tables which will have skeleton records inserted into them for each customer.  Syntax for specifying tables is unfortunately a tricky perl data structure for now.',
1816     'type'        => 'textarea',
1817   },
1818
1819   {
1820     'key'         => 'cust_main-skeleton_custnum',
1821     'section'     => '',
1822     'description' => 'Customer number specifying the source data to copy into skeleton tables for new customers.',
1823     'type'        => 'text',
1824   },
1825
1826
1827 );
1828
1829 1;
1830