mail.inc.php 38.1 KB
Newer Older
1
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php

/*
Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

--UPDATED 08.2009--
Full SOAP support for ISPConfig 3.1.4 b
Updated by Arkadiusz Roch & Artur Edelman
Copyright (c) Tri-Plex technology

--UPDATED 08.2013--
Migrated into new remote classes system
by Marius Cramer <m.cramer@pixcept.de>

*/

class remoting_mail extends remoting {
	//* Get mail domain details
	public function mail_domain_get($session_id, $primary_id)
44
	{
45
		global $app;
46

47
48
49
50
51
52
53
54
		if(!$this->checkPerm($session_id, 'mail_domain_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_domain.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
55

56
57
	//* Add a mail domain
	public function mail_domain_add($session_id, $client_id, $params)
58
	{
59
60
61
62
		if(!$this->checkPerm($session_id, 'mail_domain_add')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
63
		$primary_id = $this->insertQuery('../mail/form/mail_domain.tform.php', $client_id, $params);
64
65
		return $primary_id;
	}
66

67
68
	//* Update a mail domain
	public function mail_domain_update($session_id, $client_id, $primary_id, $params)
69
	{
70
71
72
73
74
75
76
		if(!$this->checkPerm($session_id, 'mail_domain_update')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_domain.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
	}
77

78
79
	//* Delete a mail domain
	public function mail_domain_delete($session_id, $primary_id)
80
	{
81
82
83
84
85
86
87
		if(!$this->checkPerm($session_id, 'mail_domain_delete')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_domain.tform.php', $primary_id);
		return $affected_rows;
	}
88

89
90
	//* Get alias details
	public function mail_aliasdomain_get($session_id, $primary_id)
91
	{
92
		global $app;
93

94
95
96
97
98
99
100
101
		if(!$this->checkPerm($session_id, 'mail_aliasdomain_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_aliasdomain.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
102

103
104
105
106
107
	//* aliasy email
	public function mail_aliasdomain_add($session_id, $client_id, $params)
	{
		if (!$this->checkPerm($session_id, 'mail_aliasdomain_add'))
		{
108
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
109
110
111
112
113
114
115
116
117
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $params);
		return $affected_rows;
	}


	public function mail_aliasdomain_update($session_id, $client_id, $primary_id, $params)
	{
118
119
120
121
122
123
124
		if (!$this->checkPerm($session_id, 'mail_aliasdomain_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
125
126
127
128
	}

	public function mail_aliasdomain_delete($session_id, $primary_id)
	{
129
130
131
132
133
134
135
		if (!$this->checkPerm($session_id, 'mail_aliasdomain_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_aliasdomain.tform.php', $primary_id);
		return $affected_rows;
136
	}
137

138
139
	//* Get mail mailinglist details
	public function mail_mailinglist_get($session_id, $primary_id)
140
	{
141
		global $app;
142

143
144
145
146
147
148
149
150
		if(!$this->checkPerm($session_id, 'mail_mailinglist_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_mailinglist.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
151

152
153
	//* Add a mail mailinglist
	public function mail_mailinglist_add($session_id, $client_id, $params)
154
	{
155
156
157
158
		if(!$this->checkPerm($session_id, 'mail_mailinglist_add')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
159
		$primary_id = $this->insertQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $params);
160
161
		return $primary_id;
	}
162

163
164
	//* Update a mail mailinglist
	public function mail_mailinglist_update($session_id, $client_id, $primary_id, $params)
165
	{
166
167
168
169
170
171
172
		if(!$this->checkPerm($session_id, 'mail_mailinglist_update')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
	}
173

174
175
	//* Delete a mail mailinglist
	public function mail_mailinglist_delete($session_id, $primary_id)
176
	{
177
178
179
180
181
182
183
		if(!$this->checkPerm($session_id, 'mail_mailinglist_delete')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_mailinglist.tform.php', $primary_id);
		return $affected_rows;
	}
184

185
186
	//* Get mail user details
	public function mail_user_get($session_id, $primary_id)
187
	{
188
		global $app;
189

190
191
192
193
194
195
196
197
		if(!$this->checkPerm($session_id, 'mail_user_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_user.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
198
199


200
201
202
	//* Add mail domain
	public function mail_user_add($session_id, $client_id, $params){
		global $app;
203

204
		if (!$this->checkPerm($session_id, 'mail_user_add')){
205
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
206
207
			return false;
		}
208

209
		//* Check if mail domain exists
210
		$email_parts = explode('@', $params['email']);
211
		$tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = ?", $email_parts[1]);
212
		if($tmp['domain'] != $email_parts[1]) {
213
			throw new SoapFault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.');
214
215
			return false;
		}
216

Dominik's avatar
Dominik committed
217
		//* Set a few params to non empty values that will be overwritten by mail_plugin
Dominik's avatar
Dominik committed
218
219
		if (!isset($params['uid'])) $params['uid'] = -1;
		if (!isset($params['gid'])) $params['gid'] = -1;
220
		if (!isset($params['maildir_format'])) $params['maildir_format'] = 'maildir';
Dominik's avatar
Dominik committed
221

222
223
224
225
		$affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params);
		return $affected_rows;
	}

226
	//* Update mail user
227
228
229
	public function mail_user_update($session_id, $client_id, $primary_id, $params)
	{
		global $app;
230

231
232
		if (!$this->checkPerm($session_id, 'mail_user_update'))
		{
233
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
234
235
			return false;
		}
236

237
		//* Check if mail domain exists
238
		$email_parts = explode('@', $params['email']);
239
		$tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = ?", $email_parts[1]);
240
		if($tmp['domain'] != $email_parts[1]) {
241
			throw new SoapFault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.');
242
243
			return false;
		}
244

245
246
247
248
		$affected_rows = $this->updateQuery('../mail/form/mail_user.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
	}

249

250
251
252
253
254
	//* Delete mail user
	public function mail_user_delete($session_id, $primary_id)
	{
		if (!$this->checkPerm($session_id, 'mail_user_delete'))
		{
255
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
256
257
258
259
260
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_user.tform.php', $primary_id);
		return $affected_rows;
	}
261

262
263
	//* Get mail user filter details
	public function mail_user_filter_get($session_id, $primary_id)
264
	{
265
		global $app;
266

267
268
269
270
271
272
273
274
		if(!$this->checkPerm($session_id, 'mail_user_filter_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_user_filter.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
275

276
277
278
279
	public function mail_user_filter_add($session_id, $client_id, $params)
	{
		global $app;
		if (!$this->checkPerm($session_id, 'mail_user_filter_add')){
280
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
281
282
			return false;
		}
283
		$affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params, 'mail:mail_user_filter:on_after_insert');
284
285
286
287
288
289
290
291
292
		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_insert',$this);
		return $affected_rows;
	}

	public function mail_user_filter_update($session_id, $client_id, $primary_id, $params)
	{
		global $app;
		if (!$this->checkPerm($session_id, 'mail_user_filter_update'))
		{
293
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
294
295
			return false;
		}
296
		$affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params, 'mail:mail_user_filter:on_after_update');
297
298
299
300
301
302
303
304
305
		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_update',$this);
		return $affected_rows;
	}

	public function mail_user_filter_delete($session_id, $primary_id)
	{
		global $app;
		if (!$this->checkPerm($session_id, 'mail_user_filter_delete'))
		{
306
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
307
308
			return false;
		}
309
		$affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id, 'mail:mail_user_filter:on_after_delete');
310
311
312
		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
		return $affected_rows;
	}
Dominik's avatar
Dominik committed
313
314
315
316
317
318
319
	
	// Mail backup list function by Dominik Müller, info@profi-webdesign.net
	public function mail_user_backup_list($session_id, $primary_id = null)
	{
		global $app;
	
		if(!$this->checkPerm($session_id, 'mail_user_backup')) {
320
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
Dominik's avatar
Dominik committed
321
322
323
			return false;
		}
	
324
		$params = array();
Dominik's avatar
Dominik committed
325
		if ($site_id != null) {
326
327
			$params[] = $site_id;
			$sql  = "SELECT * FROM mail_backup WHERE parent_domain_id = ?";
Dominik's avatar
Dominik committed
328
329
330
331
332
		}
		else {
			$sql  = "SELECT * FROM mail_backup";
		}
	
333
		$result = $app->db->queryAllRecords($sql, true, $params);
Dominik's avatar
Dominik committed
334
335
336
337
338
339
340
341
342
		return $result;
	}
	
	// Mail backup restore/download functions by Dominik Müller, info@profi-webdesign.net
	public function mail_user_backup($session_id, $primary_id, $action_type)
	{
		global $app;
	
		if(!$this->checkPerm($session_id, 'mail_user_backup')) {
343
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
Dominik's avatar
Dominik committed
344
345
346
347
			return false;
		}
	
		//*Set variables
348
		$backup_record  =       $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id);
Dominik's avatar
Dominik committed
349
350
351
352
353
354
355
356
		$server_id      =       $backup_record['server_id'];
	
		//*Set default action state
		$action_state   =       "pending";
		$tstamp         =       time();
	
		//* Basic validation of variables
		if ($server_id <= 0) {
357
			throw new SoapFault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
Dominik's avatar
Dominik committed
358
359
360
			return false;
		}
	
Dominik's avatar
Dominik committed
361
		if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail' and $action_type != 'backup_delete_mail') {
362
			throw new SoapFault('invalid_action', "Invalid action_type $action_type");
Dominik's avatar
Dominik committed
363
364
365
366
			return false;
		}
	
		//* Validate instance
367
		$instance_record        =       $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type);
Dominik's avatar
Dominik committed
368
		if ($instance_record['action_id'] >= 1) {
369
			throw new SoapFault('duplicate_action', "There is already a pending $action_type action");
Dominik's avatar
Dominik committed
370
371
372
373
			return false;
		}
	
		//* Save the record
374
		if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) {
Dominik's avatar
Dominik committed
375
376
377
378
379
			return true;
		} else {
			return false;
		}
	}
380
381
382

	//* Get alias details
	public function mail_alias_get($session_id, $primary_id)
383
	{
384
		global $app;
385

386
387
388
389
390
391
392
393
		if(!$this->checkPerm($session_id, 'mail_alias_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_alias.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
394

395
396
397
398
	//* aliasy email
	public function mail_alias_add($session_id, $client_id, $params)
	{
		global $app;
399

400
401
		if (!$this->checkPerm($session_id, 'mail_alias_add'))
		{
402
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
403
404
			return false;
		}
405

406
		//* Check if there is no active mailbox with this address
407
		$tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = ?", $params["source"]);
408
		if($tmp['number'] > 0) {
409
			throw new SoapFault('duplicate', 'There is already a mailbox with this email address.');
410
411
		}
		unset($tmp);
412

413
414
415
416
417
418
419
420
		$affected_rows = $this->insertQuery('../mail/form/mail_alias.tform.php', $client_id, $params);
		return $affected_rows;
	}


	public function mail_alias_update($session_id, $client_id, $primary_id, $params)
	{
		global $app;
421

422
423
		if (!$this->checkPerm($session_id, 'mail_alias_update'))
		{
424
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
425
426
			return false;
		}
427
428

		//* Check if there is no active mailbox with this address
429
		$tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = ?", $params["source"]);
430
		if($tmp['number'] > 0) {
431
			throw new SoapFault('duplicate', 'There is already a mailbox with this email address.');
432
433
		}
		unset($tmp);
434

435
436
437
438
439
440
		$affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
	}

	public function mail_alias_delete($session_id, $primary_id)
	{
441
442
443
444
445
446
447
		if (!$this->checkPerm($session_id, 'mail_alias_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_alias.tform.php', $primary_id);
		return $affected_rows;
448
	}
449

450
451
	//* Get mail forwarding details
	public function mail_forward_get($session_id, $primary_id)
452
	{
453
		global $app;
454

455
456
457
458
459
460
461
462
		if(!$this->checkPerm($session_id, 'mail_forward_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_forward.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
463
464

	//* przekierowania email
465
466
	public function mail_forward_add($session_id, $client_id, $params)
	{
467
468
469
470
471
472
473
		if (!$this->checkPerm($session_id, 'mail_forward_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_forward.tform.php', $client_id, $params);
		return $affected_rows;
474
475
476
477
478
	}


	public function mail_forward_update($session_id, $client_id, $primary_id, $params)
	{
479
480
481
482
483
484
485
		if (!$this->checkPerm($session_id, 'mail_forward_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_forward.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
486
487
488
489
490
	}


	public function mail_forward_delete($session_id, $primary_id)
	{
491
492
493
494
495
496
497
		if (!$this->checkPerm($session_id, 'mail_forward_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_forward.tform.php', $primary_id);
		return $affected_rows;
498
	}
499

500
501
	//* Get catchall details
	public function mail_catchall_get($session_id, $primary_id)
502
	{
503
		global $app;
504

505
506
507
508
509
510
511
512
513
514
		if(!$this->checkPerm($session_id, 'mail_catchall_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_domain_catchall.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}

	//* catchall e-mail
515
	public function mail_catchall_add($session_id, $client_id, $params)
516
	{
517
518
519
520
521
522
523
		if (!$this->checkPerm($session_id, 'mail_catchall_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $params);
		return $affected_rows;
524
525
526
527
	}

	public function mail_catchall_update($session_id, $client_id, $primary_id, $params)
	{
528
529
530
531
532
533
534
		if (!$this->checkPerm($session_id, 'mail_catchall_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
535
536
537
538
	}

	public function mail_catchall_delete($session_id, $primary_id)
	{
539
540
541
542
543
544
545
		if (!$this->checkPerm($session_id, 'mail_catchall_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_domain_catchall.tform.php', $primary_id);
		return $affected_rows;
546
	}
547

548
549
	//* Get transport details
	public function mail_transport_get($session_id, $primary_id)
550
	{
551
		global $app;
552

553
554
555
556
557
558
559
560
		if(!$this->checkPerm($session_id, 'mail_transport_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_transport.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
561

562
563
564
	//* przeniesienia e-mail
	public function mail_transport_add($session_id, $client_id, $params)
	{
565
566
567
568
569
570
571
		if (!$this->checkPerm($session_id, 'mail_transport_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_transport.tform.php', $client_id, $params);
		return $affected_rows;
572
573
574
575
576
	}


	public function mail_transport_update($session_id, $client_id, $primary_id, $params)
	{
577
578
579
580
581
582
583
		if (!$this->checkPerm($session_id, 'mail_transport_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_transport.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
584
585
586
587
588
	}


	public function mail_transport_delete($session_id, $primary_id)
	{
589
590
591
592
593
594
595
		if (!$this->checkPerm($session_id, 'mail_transport_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_transport.tform.php', $primary_id);
		return $affected_rows;
596
	}
597

598
599
600
601
602
603
	//* Get mail relay_recipient details
	public function mail_relay_recipient_get($session_id, $primary_id)
	{
		global $app;

		if(!$this->checkPerm($session_id, 'mail_relay_get')) {
604
				throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
605
606
607
608
609
610
611
612
613
614
615
616
617
				return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_relay_recipient.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}


	//* relay recipient email
	public function mail_relay_recipient_add($session_id, $client_id, $params)
	{
		if (!$this->checkPerm($session_id, 'mail_relay_add'))
		{
618
			throw new SoapFault('permission_denied','You do not have the permissions to access this function.');
619
620
621
622
623
624
625
626
627
628
629
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_relay_recipient.tform.php', $client_id, $params);
		return $affected_rows;
	}


	public function mail_relay_recipient_update($session_id, $client_id, $primary_id, $params)
	{
		if (!$this->checkPerm($session_id, 'mail_relay_update'))
		{
630
			throw new SoapFault('permission_denied','You do not have the permissions to access this function.');
631
632
633
634
635
636
637
638
639
640
641
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_relay_recipient.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
	}


	public function mail_relay_recipient_delete($session_id, $primary_id)
	{
		if (!$this->checkPerm($session_id, 'mail_relay_delete'))
		{
642
			throw new SoapFault('permission_denied','You do not have the permissions to access this function.');
643
644
645
646
647
648
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
		return $affected_rows;
	}
	
649
650
	//* Get spamfilter whitelist details
	public function mail_spamfilter_whitelist_get($session_id, $primary_id)
651
	{
652
		global $app;
653

654
655
656
657
658
659
660
661
662
		if(!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/spamfilter_whitelist.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}

663
	//* biała lista e-mail
664
665
	public function mail_spamfilter_whitelist_add($session_id, $client_id, $params)
	{
666
667
668
669
670
671
672
		if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $params);
		return $affected_rows;
673
674
675
676
677
	}


	public function mail_spamfilter_whitelist_update($session_id, $client_id, $primary_id, $params)
	{
678
679
680
681
682
683
684
		if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
685
686
687
688
689
	}


	public function mail_spamfilter_whitelist_delete($session_id, $primary_id)
	{
690
691
692
693
694
695
696
		if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/spamfilter_whitelist.tform.php', $primary_id);
		return $affected_rows;
697
	}
698

699
700
	//* Get spamfilter blacklist details
	public function mail_spamfilter_blacklist_get($session_id, $primary_id)
701
	{
702
		global $app;
703

704
705
706
707
708
709
710
711
		if(!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/spamfilter_blacklist.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
712
713

	//* czarna lista e-mail
714
715
	public function mail_spamfilter_blacklist_add($session_id, $client_id, $params)
	{
716
717
718
719
720
721
722
		if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $params);
		return $affected_rows;
723
724
725
726
727
	}


	public function mail_spamfilter_blacklist_update($session_id, $client_id, $primary_id, $params)
	{
728
729
730
731
732
733
734
		if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
735
736
737
738
739
	}


	public function mail_spamfilter_blacklist_delete($session_id, $primary_id)
	{
740
741
742
743
744
745
746
		if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/spamfilter_blacklist.tform.php', $primary_id);
		return $affected_rows;
747
	}
748

749
750
	//* Get spamfilter user details
	public function mail_spamfilter_user_get($session_id, $primary_id)
751
	{
752
		global $app;
753

754
755
756
757
758
759
760
761
762
763
764
765
		if(!$this->checkPerm($session_id, 'mail_spamfilter_user_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/spamfilter_users.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}

	//* filtr spamu użytkowników e-mail
	public function mail_spamfilter_user_add($session_id, $client_id, $params)
	{
766
767
768
769
770
771
772
		if (!$this->checkPerm($session_id, 'mail_spamfilter_user_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/spamfilter_users.tform.php', $client_id, $params);
		return $affected_rows;
773
774
775
776
777
	}


	public function mail_spamfilter_user_update($session_id, $client_id, $primary_id, $params)
	{
778
779
780
781
782
783
784
		if (!$this->checkPerm($session_id, 'mail_spamfilter_user_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/spamfilter_users.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
785
786
787
788
789
	}


	public function mail_spamfilter_user_delete($session_id, $primary_id)
	{
790
791
792
793
794
795
796
		if (!$this->checkPerm($session_id, 'mail_spamfilter_user_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/spamfilter_users.tform.php', $primary_id);
		return $affected_rows;
797
	}
798

799
800
	//* Get policy details
	public function mail_policy_get($session_id, $primary_id)
801
	{
802
		global $app;
803

804
805
806
807
808
809
810
811
		if(!$this->checkPerm($session_id, 'mail_policy_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/spamfilter_policy.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
812
813

	//* polityki filtrów spamu e-mail
814
815
	public function mail_policy_add($session_id, $client_id, $params)
	{
816
817
818
819
820
821
822
		if (!$this->checkPerm($session_id, 'mail_policy_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $params);
		return $affected_rows;
823
824
825
826
827
	}


	public function mail_policy_update($session_id, $client_id, $primary_id, $params)
	{
828
829
830
831
832
833
834
		if (!$this->checkPerm($session_id, 'mail_policy_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
835
836
837
838
839
	}


	public function mail_policy_delete($session_id, $primary_id)
	{
840
841
842
843
844
845
846
		if (!$this->checkPerm($session_id, 'mail_policy_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/spamfilter_policy.tform.php', $primary_id);
		return $affected_rows;
847
	}
848

849
850
	//* Get fetchmail details
	public function mail_fetchmail_get($session_id, $primary_id)
851
	{
852
		global $app;
853

854
855
856
857
858
859
860
861
862
		if(!$this->checkPerm($session_id, 'mail_fetchmail_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_get.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}

863
	//* fetchmail
864
865
	public function mail_fetchmail_add($session_id, $client_id, $params)
	{
866
867
868
869
870
871
872
		if (!$this->checkPerm($session_id, 'mail_fetchmail_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_get.tform.php', $client_id, $params);
		return $affected_rows;
873
874
875
876
877
	}


	public function mail_fetchmail_update($session_id, $client_id, $primary_id, $params)
	{
878
879
880
881
882
883
884
		if (!$this->checkPerm($session_id, 'mail_fetchmail_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_get.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
885
886
887
888
889
	}


	public function mail_fetchmail_delete($session_id, $primary_id)
	{
890
891
892
893
894
895
896
		if (!$this->checkPerm($session_id, 'mail_fetchmail_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_get.tform.php', $primary_id);
		return $affected_rows;
897
	}
898

899
900
	//* Get whitelist details
	public function mail_whitelist_get($session_id, $primary_id)
901
	{
902
		global $app;
903

904
905
906
907
908
909
910
911
		if(!$this->checkPerm($session_id, 'mail_whitelist_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_whitelist.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
912

913
914
915
	//* wpisy białej listy
	public function mail_whitelist_add($session_id, $client_id, $params)
	{
916
917
918
919
920
921
922
		if (!$this->checkPerm($session_id, 'mail_whitelist_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_whitelist.tform.php', $client_id, $params);
		return $affected_rows;
923
924
925
926
927
	}


	public function mail_whitelist_update($session_id, $client_id, $primary_id, $params)
	{
928
929
930
931
932
933
934
		if (!$this->checkPerm($session_id, 'mail_whitelist_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_whitelist.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
935
936
937
938
939
	}


	public function mail_whitelist_delete($session_id, $primary_id)
	{
940
941
942
943
944
945
946
		if (!$this->checkPerm($session_id, 'mail_whitelist_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_whitelist.tform.php', $primary_id);
		return $affected_rows;
947
	}
948

949
950
	//* Get Blacklist details
	public function mail_blacklist_get($session_id, $primary_id)
951
	{
952
		global $app;
953

954
955
956
957
958
959
960
961
		if(!$this->checkPerm($session_id, 'mail_blacklist_get')) {
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_blacklist.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
962

963
964
965
	//* wpisy białej listy
	public function mail_blacklist_add($session_id, $client_id, $params)
	{
966
967
968
969
970
971
972
		if (!$this->checkPerm($session_id, 'mail_blacklist_add'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->insertQuery('../mail/form/mail_blacklist.tform.php', $client_id, $params);
		return $affected_rows;
973
974
975
976
977
	}


	public function mail_blacklist_update($session_id, $client_id, $primary_id, $params)
	{
978
979
980
981
982
983
984
		if (!$this->checkPerm($session_id, 'mail_blacklist_update'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->updateQuery('../mail/form/mail_blacklist.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
985
986
987
988
989
	}


	public function mail_blacklist_delete($session_id, $primary_id)
	{
990
991
992
993
994
995
996
		if (!$this->checkPerm($session_id, 'mail_blacklist_delete'))
		{
			throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_blacklist.tform.php', $primary_id);
		return $affected_rows;
997
	}
998

999
1000
	//* Get filter details
	public function mail_filter_get($session_id, $primary_id)
For faster browsing, not all history is shown. View entire blame