1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29: class Horde_Kolab_Filter_Configuration
30: {
31: 32: 33: 34: 35:
36: private $_sender;
37:
38: 39: 40: 41: 42:
43: private $_recipients = array();
44:
45: 46: 47: 48: 49:
50: private $_client_address;
51:
52: 53: 54: 55: 56:
57: private $_fqhostname;
58:
59: 60: 61: 62: 63:
64: private $_sasl_username;
65:
66: 67: 68: 69: 70:
71: private $_conf;
72:
73: 74: 75: 76: 77:
78: private $_cli;
79:
80: 81: 82: 83: 84:
85: public function __construct(
86: Horde_Kolab_Filter_Cli $cli
87: ) {
88: $this->_cli = $cli;
89: }
90:
91: 92: 93: 94: 95:
96: public function init()
97: {
98: $values = $this->_cli->getOptions();
99:
100: $this->_sender = strtolower($values['sender']);
101: $this->_recipients = array_map('strtolower', $values['recipient']);
102: $this->_client_address = $values['client'];
103: $this->_fqhostname = strtolower($values['host']);
104: $this->_sasl_username = strtolower($values['user']);
105:
106: global $conf;
107:
108: if (!empty($values['config']) && file_exists($values['config'])) {
109: require_once $values['config'];
110: }
111:
112: if (!empty($conf['kolab']['filter']['locale_path'])
113: && !empty($conf['kolab']['filter']['locale'])) {
114: Horde_Nls::setTextdomain('Kolab_Filter', $conf['kolab']['filter']['locale_path']);
115: setlocale(LC_ALL, $conf['kolab']['filter']['locale']);
116: }
117:
118:
119:
120: if (isset($conf['kolab']['imap']['server'])) {
121: if (!array_key_exists('SERVER_NAME', $_SERVER)) {
122: $_SERVER['SERVER_NAME'] = $conf['kolab']['imap']['server'];
123: }
124:
125: if (!array_key_exists('REMOTE_ADDR', $_SERVER)) {
126: $_SERVER['REMOTE_ADDR'] = $conf['kolab']['imap']['server'];
127: }
128:
129: if (!array_key_exists('REMOTE_HOST', $_SERVER)) {
130: $_SERVER['REMOTE_HOST'] = $conf['kolab']['imap']['server'];
131: }
132: }
133:
134:
135: ini_set('error_reporting', E_ERROR);
136: ini_set('track_errors', '1');
137:
138:
139: if (isset($conf['kolab']['filter']['error_log'])) {
140: ini_set('log_errors', '1');
141: ini_set('error_log', $conf['kolab']['filter']['error_log']);
142: }
143:
144:
145: if (isset($conf['kolab']['filter']['debug'])
146: && $conf['kolab']['filter']['debug']) {
147: ini_set('display_errors', '1');
148: }
149:
150: 151: 152:
153: if (!isset($conf['log'])) {
154: $conf['log']['enabled'] = true;
155: $conf['log']['priority'] = 'DEBUG';
156: $conf['log']['type'] = 'syslog';
157: $conf['log']['name'] = LOG_MAIL;
158: $conf['log']['ident'] = 'kolabfilter';
159: $conf['log']['params'] = array();
160: }
161:
162: $this->_conf = $conf;
163: }
164:
165: public function getSender()
166: {
167: return $this->_sender;
168: }
169:
170: public function getRecipients()
171: {
172: return $this->_recipients;
173: }
174:
175: public function getClientAddress()
176: {
177: return $this->_client_address;
178: }
179:
180: public function getFqHostname()
181: {
182: return $this->_fqhostname;
183: }
184:
185: public function getSaslUsername()
186: {
187: return $this->_sasl_username;
188: }
189:
190: public function getConf()
191: {
192: return $this->_conf;
193: }
194: }