|
30 | 30 |
|
31 | 31 | class installer extends installer_dist { |
32 | 32 |
|
| 33 | + public function configure_mailman($status = 'insert') { |
| 34 | + global $conf; |
| 35 | + |
| 36 | + $config_dir = $conf['mailman']['config_dir'].'/'; |
| 37 | + $full_file_name = $config_dir.'mm_cfg.py'; |
| 38 | + //* Backup exiting file |
| 39 | + if(is_file($full_file_name)) { |
| 40 | + copy($full_file_name, $config_dir.'mm_cfg.py~'); |
| 41 | + } |
| 42 | + |
| 43 | + // load files |
| 44 | + $content = rf('tpl/mm_cfg.py.master'); |
| 45 | + $old_file = rf($full_file_name); |
| 46 | + |
| 47 | + $old_options = array(); |
| 48 | + $lines = explode("\n", $old_file); |
| 49 | + foreach ($lines as $line) |
| 50 | + { |
| 51 | + if (trim($line) != '' && substr($line, 0, 1) != '#') |
| 52 | + { |
| 53 | + @list($key, $value) = @explode("=", $line); |
| 54 | + if (!empty($value)) |
| 55 | + { |
| 56 | + $key = rtrim($key); |
| 57 | + $old_options[$key] = trim($value); |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + $config_dir = $conf['mailman']['config_dir'].'/'; |
| 63 | + $full_file_name = $config_dir.'virtual_to_transport.sh'; |
| 64 | + |
| 65 | + //* Backup exiting virtual_to_transport.sh script |
| 66 | + if(is_file($full_file_name)) { |
| 67 | + copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); |
| 68 | + } |
| 69 | + |
| 70 | + copy('tpl/mailman-virtual_to_transport.sh',$full_file_name); |
| 71 | + chgrp($full_file_name,'mailman'); |
| 72 | + chmod($full_file_name,0750); |
| 73 | + |
| 74 | + if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); |
| 75 | + exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); |
| 76 | + |
| 77 | + exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); |
| 78 | + |
| 79 | + $virtual_domains = ''; |
| 80 | + if($status == 'update') |
| 81 | + { |
| 82 | + // create virtual_domains list |
| 83 | + $domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); |
| 84 | + |
| 85 | + if(is_array($domainAll)) { |
| 86 | + foreach($domainAll as $domain) |
| 87 | + { |
| 88 | + if ($domainAll[0]['domain'] == $domain['domain']) |
| 89 | + $virtual_domains .= "'".$domain['domain']."'"; |
| 90 | + else |
| 91 | + $virtual_domains .= ", '".$domain['domain']."'"; |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + else |
| 96 | + $virtual_domains = "' '"; |
| 97 | + |
| 98 | + $content = str_replace('{hostname}', $conf['hostname'], $content); |
| 99 | + if(!isset($old_options['DEFAULT_SERVER_LANGUAGE'])) $old_options['DEFAULT_SERVER_LANGUAGE'] = ''; |
| 100 | + $content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); |
| 101 | + $content = str_replace('{virtual_domains}', $virtual_domains, $content); |
| 102 | + |
| 103 | + wf($full_file_name, $content); |
| 104 | + } |
| 105 | + |
33 | 106 | public function configure_amavis() { |
34 | 107 | global $conf; |
35 | 108 |
|
|
0 commit comments