allow_negative_charges config option
[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
8 $DEBUG = 0;
9
10 =head1 NAME
11
12 FS::Conf - Freeside configuration values
13
14 =head1 SYNOPSIS
15
16   use FS::Conf;
17
18   $conf = new FS::Conf "/config/directory";
19
20   $FS::Conf::default_dir = "/config/directory";
21   $conf = new FS::Conf;
22
23   $dir = $conf->dir;
24
25   $value = $conf->config('key');
26   @list  = $conf->config('key');
27   $bool  = $conf->exists('key');
28
29   $conf->touch('key');
30   $conf->set('key' => 'value');
31   $conf->delete('key');
32
33   @config_items = $conf->config_items;
34
35 =head1 DESCRIPTION
36
37 Read and write Freeside configuration values.  Keys currently map to filenames,
38 but this may change in the future.
39
40 =head1 METHODS
41
42 =over 4
43
44 =item new [ DIRECTORY ]
45
46 Create a new configuration object.  A directory arguement is required if
47 $FS::Conf::default_dir has not been set.
48
49 =cut
50
51 sub new {
52   my($proto,$dir) = @_;
53   my($class) = ref($proto) || $proto;
54   my($self) = { 'dir' => $dir || $default_dir } ;
55   bless ($self, $class);
56 }
57
58 =item dir
59
60 Returns the directory.
61
62 =cut
63
64 sub dir {
65   my($self) = @_;
66   my $dir = $self->{dir};
67   -e $dir or die "FATAL: $dir doesn't exist!";
68   -d $dir or die "FATAL: $dir isn't a directory!";
69   -r $dir or die "FATAL: Can't read $dir!";
70   -x $dir or die "FATAL: $dir not searchable (executable)!";
71   $dir =~ /^(.*)$/;
72   $1;
73 }
74
75 =item config KEY
76
77 Returns the configuration value or values (depending on context) for key.
78
79 =cut
80
81 sub config {
82   my($self,$file)=@_;
83   my($dir)=$self->dir;
84   my $fh = new IO::File "<$dir/$file" or return;
85   if ( wantarray ) {
86     map {
87       /^(.*)$/
88         or die "Illegal line (array context) in $dir/$file:\n$_\n";
89       $1;
90     } <$fh>;
91   } else {
92     <$fh> =~ /^(.*)$/
93       or die "Illegal line (scalar context) in $dir/$file:\n$_\n";
94     $1;
95   }
96 }
97
98 =item exists KEY
99
100 Returns true if the specified key exists, even if the corresponding value
101 is undefined.
102
103 =cut
104
105 sub exists {
106   my($self,$file)=@_;
107   my($dir) = $self->dir;
108   -e "$dir/$file";
109 }
110
111 =item touch KEY
112
113 Creates the specified configuration key if it does not exist.
114
115 =cut
116
117 sub touch {
118   my($self, $file) = @_;
119   my $dir = $self->dir;
120   unless ( $self->exists($file) ) {
121     warn "[FS::Conf] TOUCH $file\n" if $DEBUG;
122     system('touch', "$dir/$file");
123   }
124 }
125
126 =item set KEY VALUE
127
128 Sets the specified configuration key to the given value.
129
130 =cut
131
132 sub set {
133   my($self, $file, $value) = @_;
134   my $dir = $self->dir;
135   $value =~ /^(.*)$/s;
136   $value = $1;
137   unless ( join("\n", @{[ $self->config($file) ]}) eq $value ) {
138     warn "[FS::Conf] SET $file\n" if $DEBUG;
139 #    warn "$dir" if is_tainted($dir);
140 #    warn "$dir" if is_tainted($file);
141     chmod 0644, "$dir/$file";
142     my $fh = new IO::File ">$dir/$file" or return;
143     chmod 0644, "$dir/$file";
144     print $fh "$value\n";
145   }
146 }
147 #sub is_tainted {
148 #             return ! eval { join('',@_), kill 0; 1; };
149 #         }
150
151 =item delete KEY
152
153 Deletes the specified configuration key.
154
155 =cut
156
157 sub delete {
158   my($self, $file) = @_;
159   my $dir = $self->dir;
160   if ( $self->exists($file) ) {
161     warn "[FS::Conf] DELETE $file\n";
162     unlink "$dir/$file";
163   }
164 }
165
166 =item config_items
167
168 Returns all of the possible configuration items as FS::ConfItem objects.  See
169 L<FS::ConfItem>.
170
171 =cut
172
173 sub config_items {
174   my $self = shift; 
175   #quelle kludge
176   @config_items,
177   ( map { 
178         my $basename = basename($_);
179         $basename =~ /^(.*)$/;
180         $basename = $1;
181         new FS::ConfItem {
182                            'key'         => $basename,
183                            'section'     => 'billing',
184                            'description' => 'Alternate template file for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
185                            'type'        => 'textarea',
186                          }
187       } glob($self->dir. '/invoice_template_*')
188   ),
189   ( map { 
190         my $basename = basename($_);
191         $basename =~ /^(.*)$/;
192         $basename = $1;
193         new FS::ConfItem {
194                            'key'         => $basename,
195                            'section'     => 'billing',
196                            'description' => 'Alternate LaTeX template for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
197                            'type'        => 'textarea',
198                          }
199       } glob($self->dir. '/invoice_latex_*')
200   );
201 }
202
203 =back
204
205 =head1 BUGS
206
207 If this was more than just crud that will never be useful outside Freeside I'd
208 worry that config_items is freeside-specific and icky.
209
210 =head1 SEE ALSO
211
212 "Configuration" in the web interface (config/config.cgi).
213
214 httemplate/docs/config.html
215
216 =cut
217
218 @config_items = map { new FS::ConfItem $_ } (
219
220   {
221     'key'         => 'address',
222     'section'     => 'deprecated',
223     'description' => 'This configuration option is no longer used.  See <a href="#invoice_template">invoice_template</a> instead.',
224     'type'        => 'text',
225   },
226
227   {
228     'key'         => 'alerter_template',
229     'section'     => 'billing',
230     'description' => 'Template file for billing method expiration alerts.  See the <a href="../docs/billing.html#invoice_template">billing documentation</a> for details.',
231     'type'        => 'textarea',
232   },
233
234   {
235     'key'         => 'apacheroot',
236     'section'     => 'deprecated',
237     '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',
238     'type'        => 'text',
239   },
240
241   {
242     'key'         => 'apacheip',
243     'section'     => 'deprecated',
244     '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',
245     'type'        => 'text',
246   },
247
248   {
249     'key'         => 'apachemachine',
250     'section'     => 'deprecated',
251     '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.',
252     'type'        => 'text',
253   },
254
255   {
256     'key'         => 'apachemachines',
257     'section'     => 'deprecated',
258     '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.',
259     'type'        => 'textarea',
260   },
261
262   {
263     'key'         => 'bindprimary',
264     'section'     => 'deprecated',
265     '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',
266     'type'        => 'text',
267   },
268
269   {
270     'key'         => 'bindsecondaries',
271     'section'     => 'deprecated',
272     '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',
273     'type'        => 'textarea',
274   },
275
276   {
277     'key'         => 'business-onlinepayment',
278     'section'     => 'billing',
279     '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.',
280     'type'        => 'textarea',
281   },
282
283   {
284     'key'         => 'business-onlinepayment-ach',
285     'section'     => 'billing',
286     '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.',
287     'type'        => 'textarea',
288   },
289
290   {
291     'key'         => 'business-onlinepayment-description',
292     'section'     => 'billing',
293     '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)',
294     'type'        => 'text',
295   },
296
297   {
298     'key'         => 'bsdshellmachines',
299     'section'     => 'deprecated',
300     '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\'.',
301     'type'        => 'textarea',
302   },
303
304   {
305     'key'         => 'countrydefault',
306     'section'     => 'UI',
307     'description' => 'Default two-letter country code (if not supplied, the default is `US\')',
308     'type'        => 'text',
309   },
310
311   {
312     'key'         => 'cyrus',
313     'section'     => 'deprecated',
314     '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.',
315     'type'        => 'textarea',
316   },
317
318   {
319     'key'         => 'cp_app',
320     'section'     => 'deprecated',
321     '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).',
322     'type'        => 'textarea',
323   },
324
325   {
326     'key'         => 'deletecustomers',
327     'section'     => 'UI',
328     '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.',
329     'type'        => 'checkbox',
330   },
331
332   {
333     'key'         => 'deletepayments',
334     'section'     => 'UI',
335     'description' => 'Enable deletion of unclosed payments.  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.',
336     'type'        => [qw( checkbox text )],
337   },
338
339   {
340     'key'         => 'unapplypayments',
341     'section'     => 'UI',
342     'description' => 'Enable "unapplication" of unclosed payments.',
343     'type'        => 'checkbox',
344   },
345
346   {
347     'key'         => 'dirhash',
348     'section'     => 'shell',
349     '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>',
350     'type'        => 'text',
351   },
352
353   {
354     'key'         => 'disable_customer_referrals',
355     'section'     => 'UI',
356     'description' => 'Disable new customer-to-customer referrals in the web interface',
357     'type'        => 'checkbox',
358   },
359
360   {
361     'key'         => 'editreferrals',
362     'section'     => 'UI',
363     'description' => 'Enable advertising source modification for existing customers',
364     'type'       => 'checkbox',
365   },
366
367   {
368     'key'         => 'emailinvoiceonly',
369     'section'     => 'billing',
370     'description' => 'Disables postal mail invoices',
371     'type'       => 'checkbox',
372   },
373
374   {
375     'key'         => 'disablepostalinvoicedefault',
376     'section'     => 'billing',
377     '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>.',
378     'type'       => 'checkbox',
379   },
380
381   {
382     'key'         => 'emailinvoiceauto',
383     'section'     => 'billing',
384     'description' => 'Automatically adds new accounts to the email invoice list',
385     'type'       => 'checkbox',
386   },
387
388   {
389     'key'         => 'exclude_ip_addr',
390     'section'     => '',
391     'description' => 'Exclude these from the list of available broadband service IP addresses. (One per line)',
392     'type'        => 'textarea',
393   },
394   
395   {
396     'key'         => 'erpcdmachines',
397     'section'     => 'deprecated',
398     'description' => '<b>DEPRECATED</b>, ERPCD is no longer supported.  Used to be ERPCD authenticaion machines, one per line.  This enables export of `/usr/annex/acp_passwd\' and `/usr/annex/acp_dialup\'',
399     'type'        => 'textarea',
400   },
401
402   {
403     'key'         => 'hidecancelledpackages',
404     'section'     => 'UI',
405     'description' => 'Prevent cancelled packages from showing up in listings (though they will still be in the database)',
406     'type'        => 'checkbox',
407   },
408
409   {
410     'key'         => 'hidecancelledcustomers',
411     'section'     => 'UI',
412     'description' => 'Prevent customers with only cancelled packages from showing up in listings (though they will still be in the database)',
413     'type'        => 'checkbox',
414   },
415
416   {
417     'key'         => 'home',
418     'section'     => 'required',
419     'description' => 'For new users, prefixed to username to create a directory name.  Should have a leading but not a trailing slash.',
420     'type'        => 'text',
421   },
422
423   {
424     'key'         => 'icradiusmachines',
425     'section'     => 'deprecated',
426     '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>',
427     'type'        => [qw( checkbox textarea )],
428   },
429
430   {
431     'key'         => 'icradius_mysqldest',
432     'section'     => 'deprecated',
433     '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/".',
434     'type'        => 'text',
435   },
436
437   {
438     'key'         => 'icradius_mysqlsource',
439     'section'     => 'deprecated',
440     '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".',
441     'type'        => 'text',
442   },
443
444   {
445     'key'         => 'icradius_secrets',
446     'section'     => 'deprecated',
447     '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.',
448     'type'        => 'textarea',
449   },
450
451   {
452     'key'         => 'invoice_from',
453     'section'     => 'required',
454     'description' => 'Return address on email invoices',
455     'type'        => 'text',
456   },
457
458   {
459     'key'         => 'invoice_template',
460     'section'     => 'required',
461     'description' => 'Required template file for invoices.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
462     'type'        => 'textarea',
463   },
464
465   {
466     'key'         => 'invoice_latex',
467     'section'     => 'billing',
468     'description' => 'Optional LaTeX template for typeset PostScript invoices.',
469     'type'        => 'textarea',
470   },
471
472   {
473     'key'         => 'invoice_latexnotes',
474     'section'     => 'billing',
475     'description' => 'Notes section for LaTeX typeset PostScript invoices.',
476     'type'        => 'textarea',
477   },
478
479   {
480     'key'         => 'invoice_latexfooter',
481     'section'     => 'billing',
482     'description' => 'Footer for LaTeX typeset PostScript invoices.',
483     'type'        => 'textarea',
484   },
485
486   { 
487     'key'         => 'invoice_default_terms',
488     'section'     => 'billing',
489     'description' => 'Optional default invoice term, used to calculate a due date printed on invoices.',
490     'type'        => 'select',
491     'select_enum' => [ '', 'Payable upon receipt', 'Net 10', 'Net 15', 'Net 30', 'Net 45', 'Net 60' ],
492   },
493
494   {
495     'key'         => 'invoice_send_receipts',
496     'section'     => 'billing',
497     'description' => 'Send receipts for payments and credits.',
498     'type'        => 'checkbox',
499   },
500
501   {
502     'key'         => 'lpr',
503     'section'     => 'required',
504     'description' => 'Print command for paper invoices, for example `lpr -h\'',
505     'type'        => 'text',
506   },
507
508   {
509     'key'         => 'maildisablecatchall',
510     'section'     => 'deprecated',
511     '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.',
512     'type'        => 'checkbox',
513   },
514
515   {
516     'key'         => 'money_char',
517     'section'     => '',
518     'description' => 'Currency symbol - defaults to `$\'',
519     'type'        => 'text',
520   },
521
522   {
523     'key'         => 'mxmachines',
524     'section'     => 'deprecated',
525     'description' => 'MX entries for new domains, weight and machine, one per line, with trailing `.\'',
526     'type'        => 'textarea',
527   },
528
529   {
530     'key'         => 'nsmachines',
531     'section'     => 'deprecated',
532     'description' => 'NS nameservers for new domains, one per line, with trailing `.\'',
533     'type'        => 'textarea',
534   },
535
536   {
537     'key'         => 'defaultrecords',
538     'section'     => 'BIND',
539     'description' => 'DNS entries to add automatically when creating a domain',
540     'type'        => 'editlist',
541     'editlist_parts' => [ { type=>'text' },
542                           { type=>'immutable', value=>'IN' },
543                           { type=>'select',
544                             select_enum=>{ map { $_=>$_ } qw(A CNAME MX NS)} },
545                           { type=> 'text' }, ],
546   },
547
548   {
549     'key'         => 'arecords',
550     'section'     => 'deprecated',
551     'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
552     'type'        => 'textarea',
553   },
554
555   {
556     'key'         => 'cnamerecords',
557     'section'     => 'deprecated',
558     'description' => 'A list of tab seperated CNAME records to add automatically when creating a domain',
559     'type'        => 'textarea',
560   },
561
562   {
563     'key'         => 'nismachines',
564     'section'     => 'deprecated',
565     '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\'.',
566     'type'        => 'textarea',
567   },
568
569   {
570     'key'         => 'passwordmin',
571     'section'     => 'password',
572     'description' => 'Minimum password length (default 6)',
573     'type'        => 'text',
574   },
575
576   {
577     'key'         => 'passwordmax',
578     'section'     => 'password',
579     'description' => 'Maximum password length (default 8) (don\'t set this over 12 if you need to import or export crypt() passwords)',
580     'type'        => 'text',
581   },
582
583   {
584     'key'         => 'qmailmachines',
585     'section'     => 'deprecated',
586     '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.',
587     'type'        => [qw( checkbox textarea )],
588   },
589
590   {
591     'key'         => 'radiusmachines',
592     'section'     => 'deprecated',
593     '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\'.',
594     'type'        => 'textarea',
595   },
596
597   {
598     'key'         => 'referraldefault',
599     'section'     => 'UI',
600     'description' => 'Default referral, specified by refnum',
601     'type'        => 'text',
602   },
603
604 #  {
605 #    'key'         => 'registries',
606 #    'section'     => 'required',
607 #    'description' => 'Directory which contains domain registry information.  Each registry is a directory.',
608 #  },
609
610   {
611     'key'         => 'report_template',
612     'section'     => 'required',
613     'description' => 'Required template file for reports.  See the <a href="../docs/billing.html">billing documentation</a> for details.',
614     'type'        => 'textarea',
615   },
616
617
618   {
619     'key'         => 'maxsearchrecordsperpage',
620     'section'     => 'UI',
621     'description' => 'If set, number of search records to return per page.',
622     'type'        => 'text',
623   },
624
625   {
626     'key'         => 'sendmailconfigpath',
627     'section'     => 'deprecated',
628     '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\'.',
629     'type'        => 'text',
630   },
631
632   {
633     'key'         => 'sendmailmachines',
634     'section'     => 'deprecated',
635     '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\'.',
636     'type'        => 'textarea',
637   },
638
639   {
640     'key'         => 'sendmailrestart',
641     'section'     => 'deprecated',
642     '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.',
643     'type'        => 'text',
644   },
645
646   {
647     'key'         => 'session-start',
648     'section'     => 'session',
649     '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.',
650     'type'        => 'text',
651   },
652
653   {
654     'key'         => 'session-stop',
655     'section'     => 'session',
656     '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.',
657     'type'        => 'text',
658   },
659
660   {
661     'key'         => 'shellmachine',
662     'section'     => 'deprecated',
663     '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.',
664     'type'        => 'text',
665   },
666
667   {
668     'key'         => 'shellmachine-useradd',
669     'section'     => 'deprecated',
670     '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>.',
671     'type'        => [qw( checkbox text )],
672   },
673
674   {
675     'key'         => 'shellmachine-userdel',
676     'section'     => 'deprecated',
677     '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>.',
678     'type'        => [qw( checkbox text )],
679   },
680
681   {
682     'key'         => 'shellmachine-usermod',
683     'section'     => 'deprecated',
684     '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>.',
685     #'type'        => [qw( checkbox text )],
686     'type'        => 'text',
687   },
688
689   {
690     'key'         => 'shellmachines',
691     'section'     => 'deprecated',
692     '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.',
693      'type'        => 'textarea',
694  },
695
696   {
697     'key'         => 'shells',
698     'section'     => 'required',
699     '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.',
700     'type'        => 'textarea',
701   },
702
703   {
704     'key'         => 'showpasswords',
705     'section'     => 'UI',
706     'description' => 'Display unencrypted user passwords in the web interface',
707     'type'        => 'checkbox',
708   },
709
710   {
711     'key'         => 'signupurl',
712     'section'     => 'UI',
713     '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',
714     'type'        => 'text',
715   },
716
717   {
718     'key'         => 'smtpmachine',
719     'section'     => 'required',
720     'description' => 'SMTP relay for Freeside\'s outgoing mail',
721     'type'        => 'text',
722   },
723
724   {
725     'key'         => 'soadefaultttl',
726     'section'     => 'BIND',
727     'description' => 'SOA default TTL for new domains.',
728     'type'        => 'text',
729   },
730
731   {
732     'key'         => 'soaemail',
733     'section'     => 'BIND',
734     'description' => 'SOA email for new domains, in BIND form (`.\' instead of `@\'), with trailing `.\'',
735     'type'        => 'text',
736   },
737
738   {
739     'key'         => 'soaexpire',
740     'section'     => 'BIND',
741     'description' => 'SOA expire for new domains',
742     'type'        => 'text',
743   },
744
745   {
746     'key'         => 'soamachine',
747     'section'     => 'BIND',
748     'description' => 'SOA machine for new domains, with trailing `.\'',
749     'type'        => 'text',
750   },
751
752   {
753     'key'         => 'soarefresh',
754     'section'     => 'BIND',
755     'description' => 'SOA refresh for new domains',
756     'type'        => 'text',
757   },
758
759   {
760     'key'         => 'soaretry',
761     'section'     => 'BIND',
762     'description' => 'SOA retry for new domains',
763     'type'        => 'text',
764   },
765
766   {
767     'key'         => 'statedefault',
768     'section'     => 'UI',
769     'description' => 'Default state or province (if not supplied, the default is `CA\')',
770     'type'        => 'text',
771   },
772
773   {
774     'key'         => 'radiusprepend',
775     'section'     => 'deprecated',
776     '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).',
777     'type'        => 'textarea',
778   },
779
780   {
781     'key'         => 'textradiusprepend',
782     'section'     => 'deprecated',
783     '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.',
784     'type'        => 'text',
785   },
786
787   {
788     'key'         => 'unsuspendauto',
789     'section'     => 'billing',
790     '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',
791     'type'        => 'checkbox',
792   },
793
794   {
795     'key'         => 'usernamemin',
796     'section'     => 'username',
797     'description' => 'Minimum username length (default 2)',
798     'type'        => 'text',
799   },
800
801   {
802     'key'         => 'usernamemax',
803     'section'     => 'username',
804     'description' => 'Maximum username length',
805     'type'        => 'text',
806   },
807
808   {
809     'key'         => 'username-ampersand',
810     'section'     => 'username',
811     '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.',
812     'type'        => 'checkbox',
813   },
814
815   {
816     'key'         => 'username-letter',
817     'section'     => 'username',
818     'description' => 'Usernames must contain at least one letter',
819     'type'        => 'checkbox',
820   },
821
822   {
823     'key'         => 'username-letterfirst',
824     'section'     => 'username',
825     'description' => 'Usernames must start with a letter',
826     'type'        => 'checkbox',
827   },
828
829   {
830     'key'         => 'username-noperiod',
831     'section'     => 'username',
832     'description' => 'Disallow periods in usernames',
833     'type'        => 'checkbox',
834   },
835
836   {
837     'key'         => 'username-nounderscore',
838     'section'     => 'username',
839     'description' => 'Disallow underscores in usernames',
840     'type'        => 'checkbox',
841   },
842
843   {
844     'key'         => 'username-nodash',
845     'section'     => 'username',
846     'description' => 'Disallow dashes in usernames',
847     'type'        => 'checkbox',
848   },
849
850   {
851     'key'         => 'username-uppercase',
852     'section'     => 'username',
853     'description' => 'Allow uppercase characters in usernames',
854     'type'        => 'checkbox',
855   },
856
857   {
858     'key'         => 'username_policy',
859     'section'     => 'deprecated',
860     '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\'',
861     'type'        => 'select',
862     'select_enum' => [ 'prepend domsvc', 'append domsvc', 'append domain', 'append @domain' ],
863     #'type'        => 'text',
864   },
865
866   {
867     'key'         => 'vpopmailmachines',
868     'section'     => 'deprecated',
869     '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',
870     'type'        => 'textarea',
871   },
872
873   {
874     'key'         => 'vpopmailrestart',
875     'section'     => 'deprecated',
876     '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.',
877     'type'        => 'textarea',
878   },
879
880   {
881     'key'         => 'safe-part_pkg',
882     'section'     => 'UI',
883     'description' => 'Validates package definition setup and recur expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
884     'type'        => 'checkbox',
885   },
886
887   {
888     'key'         => 'safe-part_bill_event',
889     'section'     => 'UI',
890     'description' => 'Validates invoice event expressions against a preset list.  Useful for webdemos, annoying to powerusers.',
891     'type'        => 'checkbox',
892   },
893
894   {
895     'key'         => 'show_ss',
896     'section'     => 'UI',
897     'description' => 'Turns on display/collection of SS# in the web interface.',
898     'type'        => 'checkbox',
899   },
900
901   { 
902     'key'         => 'agent_defaultpkg',
903     'section'     => 'UI',
904     'description' => 'Setting this option will cause new packages to be available to all agent types by default.',
905     'type'        => 'checkbox',
906   },
907
908   {
909     'key'         => 'legacy_link',
910     'section'     => 'UI',
911     'description' => 'Display options in the web interface to link legacy pre-Freeside services.',
912     'type'        => 'checkbox',
913   },
914
915   {
916     'key'         => 'queue_dangerous_controls',
917     'section'     => 'UI',
918     '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.',
919     'type'        => 'checkbox',
920   },
921
922   {
923     'key'         => 'security_phrase',
924     'section'     => 'password',
925     'description' => 'Enable the tracking of a "security phrase" with each account.  Not recommended, as it is vulnerable to social engineering.',
926     'type'        => 'checkbox',
927   },
928
929   {
930     'key'         => 'locale',
931     'section'     => 'UI',
932     'description' => 'Message locale',
933     'type'        => 'select',
934     'select_enum' => [ qw(en_US) ],
935   },
936
937   {
938     'key'         => 'selfservice_server-quiet',
939     'section'     => 'deprecated',
940     '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.',
941     'type'        => 'checkbox',
942   },
943
944   {
945     'key'         => 'signup_server-quiet',
946     'section'     => 'deprecated',
947     '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.',
948     'type'        => 'checkbox',
949   },
950
951   {
952     'key'         => 'signup_server-payby',
953     'section'     => '',
954     'description' => 'Acceptable payment types for the signup server',
955     'type'        => 'selectmultiple',
956     'select_enum' => [ qw(CARD DCRD CHEK DCHK LECB PREPAY BILL COMP) ],
957   },
958
959   {
960     'key'         => 'signup_server-email',
961     'section'     => 'deprecated',
962     '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.',
963     'type'        => 'text',
964   },
965
966   {
967     'key'         => 'signup_server-default_agentnum',
968     'section'     => '',
969     'description' => 'Default agentnum for the signup server',
970     'type'        => 'text',
971   },
972
973   {
974     'key'         => 'signup_server-default_refnum',
975     'section'     => '',
976     'description' => 'Default advertising source number for the signup server',
977     'type'        => 'text',
978   },
979
980   {
981     'key'         => 'show-msgcat-codes',
982     'section'     => 'UI',
983     'description' => 'Show msgcat codes in error messages.  Turn this option on before reporting errors to the mailing list.',
984     'type'        => 'checkbox',
985   },
986
987   {
988     'key'         => 'signup_server-realtime',
989     'section'     => '',
990     'description' => 'Run billing for signup server signups immediately, and suspend accounts which subsequently have a balance.',
991     'type'        => 'checkbox',
992   },
993
994   {
995     'key'         => 'declinetemplate',
996     'section'     => 'billing',
997     'description' => 'Template file for credit card decline emails.',
998     'type'        => 'textarea',
999   },
1000
1001   {
1002     'key'         => 'emaildecline',
1003     'section'     => 'billing',
1004     'description' => 'Enable emailing of credit card decline notices.',
1005     'type'        => 'checkbox',
1006   },
1007
1008   {
1009     'key'         => 'emaildecline-exclude',
1010     'section'     => 'billing',
1011     'description' => 'List of error messages that should not trigger email decline notices, one per line.',
1012     'type'        => 'textarea',
1013   },
1014
1015   {
1016     'key'         => 'cancelmessage',
1017     'section'     => 'billing',
1018     'description' => 'Template file for cancellation emails.',
1019     'type'        => 'textarea',
1020   },
1021
1022   {
1023     'key'         => 'cancelsubject',
1024     'section'     => 'billing',
1025     'description' => 'Subject line for cancellation emails.',
1026     'type'        => 'text',
1027   },
1028
1029   {
1030     'key'         => 'emailcancel',
1031     'section'     => 'billing',
1032     'description' => 'Enable emailing of cancellation notices.',
1033     'type'        => 'checkbox',
1034   },
1035
1036   {
1037     'key'         => 'require_cardname',
1038     'section'     => 'billing',
1039     'description' => 'Require an "Exact name on card" to be entered explicitly; don\'t default to using the first and last name.',
1040     'type'        => 'checkbox',
1041   },
1042
1043   {
1044     'key'         => 'enable_taxclasses',
1045     'section'     => 'billing',
1046     'description' => 'Enable per-package tax classes',
1047     'type'        => 'checkbox',
1048   },
1049
1050   {
1051     'key'         => 'welcome_email',
1052     'section'     => '',
1053     '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/doc/MJD/Text-Template-1.42/Template.pm">Text::Template</a> documentation for details on the template substitution language.  The following variables are available: <code>$username</code>, <code>$password</code>, <code>$first</code>, <code>$last</code> and <code>$pkg</code>.',
1054     'type'        => 'textarea',
1055   },
1056
1057   {
1058     'key'         => 'welcome_email-from',
1059     'section'     => '',
1060     'description' => 'From: address header for welcome email',
1061     'type'        => 'text',
1062   },
1063
1064   {
1065     'key'         => 'welcome_email-subject',
1066     'section'     => '',
1067     'description' => 'Subject: header for welcome email',
1068     'type'        => 'text',
1069   },
1070   
1071   {
1072     'key'         => 'welcome_email-mimetype',
1073     'section'     => '',
1074     'description' => 'MIME type for welcome email',
1075     'type'        => 'select',
1076     'select_enum' => [ 'text/plain', 'text/html' ],
1077   },
1078
1079   {
1080     'key'         => 'payby-default',
1081     'section'     => 'UI',
1082     'description' => 'Default payment type.  HIDE disables display of billing information and sets customers to BILL.',
1083     'type'        => 'select',
1084     'select_enum' => [ '', qw(CARD DCRD CHEK DCHK LECB BILL COMP HIDE) ],
1085   },
1086
1087   {
1088     'key'         => 'svc_acct-notes',
1089     'section'     => 'UI',
1090     'description' => 'Extra HTML to be displayed on the Account View screen.',
1091     'type'        => 'textarea',
1092   },
1093
1094   {
1095     'key'         => 'radius-password',
1096     'section'     => '',
1097     'description' => 'RADIUS attribute for plain-text passwords.',
1098     'type'        => 'select',
1099     'select_enum' => [ 'Password', 'User-Password' ],
1100   },
1101
1102   {
1103     'key'         => 'radius-ip',
1104     'section'     => '',
1105     'description' => 'RADIUS attribute for IP addresses.',
1106     'type'        => 'select',
1107     'select_enum' => [ 'Framed-IP-Address', 'Framed-Address' ],
1108   },
1109
1110   {
1111     'key'         => 'svc_acct-alldomains',
1112     'section'     => '',
1113     '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.',
1114     'type'        => 'checkbox',
1115   },
1116
1117   {
1118     'key'         => 'dump-scpdest',
1119     'section'     => '',
1120     'description' => 'destination for scp database dumps: user@host:/path',
1121     'type'        => 'text',
1122   },
1123
1124   {
1125     'key'         => 'users-allow_comp',
1126     'section'     => '',
1127     'description' => '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.',
1128     'type'        => 'textarea',
1129   },
1130
1131   {
1132     'key'         => 'cvv-save',
1133     'section'     => 'billing',
1134     '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.',
1135     'type'        => 'selectmultiple',
1136     'select_enum' => [ "VISA card",
1137                        "MasterCard",
1138                        "Discover card",
1139                        "American Express card",
1140                        "Diner's Club/Carte Blanche",
1141                        "enRoute",
1142                        "JCB",
1143                        "BankCard",
1144                      ],
1145   },
1146
1147   {
1148     'key'         => 'allow_negative_charges',
1149     'section'     => 'billing',
1150     'description' => 'Allow negative charges.  Normally not used unless importing data from a legacy system that requires this.',
1151     'type'        => 'checkbox',
1152   },
1153
1154 );
1155
1156 1;
1157