remoting.inc.php 145 KB
Newer Older
latham's avatar
latham committed
1
2
3
<?php

/*
4
Copyright (c) 2007 - 2011, Till Brehm, projektfarm Gmbh
latham's avatar
latham committed
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
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

*/

class remoting {
38

latham's avatar
latham committed
39
40
	//* remote session timeout in seconds
	private $session_timeout = 600;
41

42
	protected $server;
latham's avatar
latham committed
43
44
45
	public $oldDataRecord;
	public $dataRecord;
	public $id;
46

latham's avatar
latham committed
47
	/*
48
	These variables shall stay global.
latham's avatar
latham committed
49
	Please do not make them private variables.
50

latham's avatar
latham committed
51
52
53
54
	private $app;
    private $conf;
    */

55
56
57
58
	public function __construct()
	{
		global $server;
		$this->server = $server;
latham's avatar
latham committed
59
60
61
62
		/*
        $this->app = $app;
        $this->conf = $conf;
		*/
63
	}
latham's avatar
latham committed
64
65
66

	//* remote login function
	public function login($username, $password)
67
	{
latham's avatar
latham committed
68
		global $app, $conf, $server;
69

70
71
72
73
74
75
76
		// Maintenance mode
		$app->uses('ini_parser,getconf');
		$server_config_array = $app->getconf->get_global_config('misc');
		if($server_config_array['maintenance_mode'] == 'y'){
			$this->server->fault('maintenance_mode', 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.');
			return false;
		}
77

latham's avatar
latham committed
78
		if(empty($username)) {
79
			$this->server->fault('login_username_empty', 'The login username is empty.');
latham's avatar
latham committed
80
81
			return false;
		}
82

latham's avatar
latham committed
83
		if(empty($password)) {
84
			$this->server->fault('login_password_empty', 'The login password is empty.');
latham's avatar
latham committed
85
86
			return false;
		}
87

latham's avatar
latham committed
88
89
90
		//* Delete old remoting sessions
		$sql = "DELETE FROM remote_session WHERE tstamp < ".time();
		$app->db->query($sql);
91

latham's avatar
latham committed
92
93
		$username = $app->db->quote($username);
		$password = $app->db->quote($password);
94

latham's avatar
latham committed
95
96
97
98
		$sql = "SELECT * FROM remote_user WHERE remote_username = '$username' and remote_password = md5('$password')";
		$remote_user = $app->db->queryOneRecord($sql);
		if($remote_user['remote_userid'] > 0) {
			//* Create a remote user session
99
			srand((double)microtime()*1000000);
latham's avatar
latham committed
100
101
102
103
104
			$remote_session = md5(rand());
			$remote_userid = $remote_user['remote_userid'];
			$remote_functions = $remote_user['remote_functions'];
			$tstamp = time() + $this->session_timeout;
			$sql = 'INSERT INTO remote_session (remote_session,remote_userid,remote_functions,tstamp'
105
106
				.') VALUES ('
				." '$remote_session',$remote_userid,'$remote_functions',$tstamp)";
latham's avatar
latham committed
107
108
109
110
111
112
			$app->db->query($sql);
			return $remote_session;
		} else {
			$this->server->fault('login_failed', 'The login failed. Username or password wrong.');
			return false;
		}
113

latham's avatar
latham committed
114
	}
115

latham's avatar
latham committed
116
117
	//* remote logout function
	public function logout($session_id)
118
	{
latham's avatar
latham committed
119
		global $app;
120

latham's avatar
latham committed
121
122
123
124
		if(empty($session_id)) {
			$this->server->fault('session_id_empty', 'The SessionID is empty.');
			return false;
		}
125

latham's avatar
latham committed
126
		$session_id = $app->db->quote($session_id);
127

latham's avatar
latham committed
128
		$sql = "DELETE FROM remote_session WHERE remote_session = '$session_id'";
129
130
131
132
133
		if($app->db->query($sql) != false) {
			return true;
		} else {
			return false;
		}
134
135
136
137
138
139
140
141
	}


	/**
	 Gets the server configuration
	 @param int session id
	 @param int server id
	 @param string  section of the config field in the server table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
142
	 @author Julio Montoya <gugli100@gmail.com> BeezNest 2010, extended by M. Cramer <m.cramer@pixcept.de> 2014
143
144
145
	 */


146
	public function server_get($session_id, $server_id = null, $section ='') {
147
148
149
150
151
		global $app;
		if(!$this->checkPerm($session_id, 'server_get')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
		if (!empty($session_id)) {
			if(!empty($server_id)) {
				$app->uses('remoting_lib , getconf');
				$section_config =  $app->getconf->get_server_config($server_id, $section);
				return $section_config;
			} else {
				$servers = array();
				$sql = "SELECT server_id FROM server WHERE 1";
				$all = $app->db->queryAllRecords($sql);
				foreach($all as $s) {
					$servers[$s['server_id']] = $app->getconf->get_server_config($s['server_id'], $section);
				}
				unset($all);
				unset($s);
				return $servers;
			}
		} else {
			return false;
		}
	}
	
	/**
	    Gets a list of all servers
	    @param int session_id
	    @param int server_name
	    @author Marius Cramer <m.cramer@pixcept.de> 2014
    */
	public function server_get_all($session_id)
    {
        global $app;
		if(!$this->checkPerm($session_id, 'server_get')) {
        	$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
		}
		if (!empty($session_id)) {
			$sql = "SELECT server_id, server_name FROM server WHERE 1";
			$servers = $app->db->queryAllRecords($sql);
			return $servers;
190
191
192
		} else {
			return false;
		}
latham's avatar
latham committed
193
	}
194
195
	
	/**
196
197
198
199
200
201
202
203
	    Gets the server_id by server_name
	    @param int session_id
	    @param int server_name
	    @author Sascha Bay <info@space2place.de> TheCry 2013
    */
	public function server_get_serverid_by_name($session_id, $server_name)
    {
        global $app;
204
		if(!$this->checkPerm($session_id, 'server_get')) {
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
        	$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
		}
		if (!empty($session_id) && !empty($server_name)) {
			$sql = "SELECT server_id FROM server WHERE server_name  = '$server_name' LIMIT 1 ";
			$all = $app->db->queryAllRecords($sql);
			return $all;
		} else {
			return false;
		}
	}
	
	/**
	    Gets the functions of a server by server_id
	    @param int session_id
	    @param int server_id
	    @author Sascha Bay <info@space2place.de> TheCry 2013
    */
	public function server_get_functions($session_id, $server_id)
    {
        global $app;
		if(!$this->checkPerm($session_id, 'server_get')) {
        	$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
		}
		if (!empty($session_id) && !empty($server_id)) { 
			$sql = "SELECT mail_server, web_server, dns_server, file_server, db_server, vserver_server, proxy_server, firewall_server FROM server WHERE server_id  = '$server_id' LIMIT 1 ";
			$all = $app->db->queryAllRecords($sql);
			return $all;
		} else {
235
236
			return false;
		}
237
238
	}
	
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
	/**
	 * set record permissions in any table
	 * @param string session_id
	 * @param string index_field
	 * @param string index_value
	 * @param array permissions
	 * @author "ispcomm", improved by M. Cramer <m.cramer@pixcept.de>
	 */
	public function update_record_permissions($tablename, $index_field, $index_value, $permissions) {
		global $app;
		
		if(!$this->checkPerm($session_id, 'admin_record_permissions')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		
		foreach($permissions as $key => $value) {  // make sure only sys_ fields are updated
			switch($key) {
				case 'sys_userid':
					// check if userid is valid
					$check = $app->db->queryOneRecord('SELECT userid FROM sys_user WHERE userid = ' . $app->functions->intval($value));
					if(!$check || !$check['userid']) {
						$this->server->fault('invalid parameters', $value . ' is no valid sys_userid.');
						return false;
					}
Marius Cramer's avatar
Marius Cramer committed
264
					$permissions[$key] = $app->functions->intval($value);
265
266
267
268
269
270
271
272
					break;
				case 'sys_groupid':
					// check if groupid is valid
					$check = $app->db->queryOneRecord('SELECT groupid FROM sys_group WHERE groupid = ' . $app->functions->intval($value));
					if(!$check || !$check['groupid']) {
						$this->server->fault('invalid parameters', $value . ' is no valid sys_groupid.');
						return false;
					}
Marius Cramer's avatar
Marius Cramer committed
273
					$permissions[$key] = $app->functions->intval($value);
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
					break;
				case 'sys_perm_user':
				case 'sys_perm_group':
					// check if permissions are valid
					$value = strtolower($value);
					if(!preg_match('/^[riud]+$/', $value)) {
						$this->server->fault('invalid parameters', $value . ' is no valid permission string.');
						return false;
					}
					
					$newvalue = '';
					if(strpos($value, 'r') !== false) $newvalue .= 'r';
					if(strpos($value, 'i') !== false) $newvalue .= 'i';
					if(strpos($value, 'u') !== false) $newvalue .= 'u';
					if(strpos($value, 'd') !== false) $newvalue .= 'd';
Marius Cramer's avatar
Marius Cramer committed
289
					$permissions[$key] = $newvalue;
290
291
292
293
294
295
296
297
298
299
300
301
					unset($newvalue);
					
					break;
				default:
					$this->server->fault('invalid parameters', 'Only sys_userid, sys_groupid, sys_perm_user and sys_perm_group parameters can be changed with this function.');
					break;
			}
		}
		
		return $app->db->datalogUpdate( $tablename, $permissions, $index_field, $index_value ) ;
	}
	
302
303
304
305
306
307
308
309
310
311
312
313
	/**
	    Gets the ISPconfig version of the server
	    @param int session_id
	    @author Sascha Bay <info@space2place.de> TheCry 2013
    */
	public function server_get_app_version($session_id)
    {
        global $app;
		if(!$this->checkPerm($session_id, 'server_get')) {
        	$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
            return false;
		}
314
315
316
317
318
319
320
		if (!empty($session_id)) { 
			$ispc_app_version = array('ispc_app_version' => ISPC_APP_VERSION);
			return $ispc_app_version;
		} else {
			return false;
		}
	}
latham's avatar
latham committed
321

322
	public function server_get_serverid_by_ip($session_id, $ipaddress)
323
324
	{
		global $app;
325
		if(!$this->checkPerm($session_id, 'server_get_serverid_by_ip')) {
326
327
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
328
		}
329
330
331
		$sql = "SELECT server_id FROM server_ip WHERE ip_address  = '$ipaddress' LIMIT 1 ";
		$all = $app->db->queryAllRecords($sql);
		return $all;
332
	}
333

334
335
336
337
338
339
340
341
342
343
344
345
346
347
	//* Get server ips
	public function server_ip_get($session_id, $primary_id)
	{
		global $app;

		if(!$this->checkPerm($session_id, 'server_ip_get')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../admin/form/server_ip.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
	
348
349
	//* Add a IP address record
	public function server_ip_add($session_id, $client_id, $params)
350
	{
351
352
353
354
		if(!$this->checkPerm($session_id, 'server_ip_add')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
355
		return $this->insertQuery('../admin/form/server_ip.tform.php', $client_id, $params);
356
	}
357

358
359
	//* Update IP address record
	public function server_ip_update($session_id, $client_id, $ip_id, $params)
360
	{
361
362
363
364
		if(!$this->checkPerm($session_id, 'server_ip_update')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
365
		$affected_rows = $this->updateQuery('../admin/form/server_ip.tform.php', $client_id, $ip_id, $params);
366
367
		return $affected_rows;
	}
368

369
370
	//* Delete IP address record
	public function server_ip_delete($session_id, $ip_id)
371
	{
372
373
374
375
		if(!$this->checkPerm($session_id, 'server_ip_delete')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
376
		$affected_rows = $this->deleteQuery('../admin/form/server_ip.tform.php', $ip_id);
377
378
		return $affected_rows;
	}
379

latham's avatar
latham committed
380
381
	//* Get mail domain details
	public function mail_domain_get($session_id, $primary_id)
382
	{
latham's avatar
latham committed
383
		global $app;
384

latham's avatar
latham committed
385
386
387
388
389
390
391
392
		if(!$this->checkPerm($session_id, 'mail_domain_get')) {
			$this->server->fault('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);
	}
393

latham's avatar
latham committed
394
395
	//* Add a mail domain
	public function mail_domain_add($session_id, $client_id, $params)
396
	{
latham's avatar
latham committed
397
398
399
400
		if(!$this->checkPerm($session_id, 'mail_domain_add')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
401
		$primary_id = $this->insertQuery('../mail/form/mail_domain.tform.php', $client_id, $params);
latham's avatar
latham committed
402
403
		return $primary_id;
	}
404

latham's avatar
latham committed
405
406
	//* Update a mail domain
	public function mail_domain_update($session_id, $client_id, $primary_id, $params)
407
	{
latham's avatar
latham committed
408
409
410
411
412
413
414
		if(!$this->checkPerm($session_id, 'mail_domain_update')) {
			$this->server->fault('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;
	}
415

latham's avatar
latham committed
416
417
	//* Delete a mail domain
	public function mail_domain_delete($session_id, $primary_id)
418
	{
latham's avatar
latham committed
419
420
421
422
423
424
425
		if(!$this->checkPerm($session_id, 'mail_domain_delete')) {
			$this->server->fault('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;
	}
426

427
428
	//* Get alias details
	public function mail_aliasdomain_get($session_id, $primary_id)
429
	{
430
		global $app;
431

432
433
434
435
436
437
438
439
		if(!$this->checkPerm($session_id, 'mail_aliasdomain_get')) {
			$this->server->fault('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);
	}
440

441
442
443
444
445
	//* aliasy email
	public function mail_aliasdomain_add($session_id, $client_id, $params)
	{
		if (!$this->checkPerm($session_id, 'mail_aliasdomain_add'))
		{
446
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
447
448
449
450
451
452
453
454
455
			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)
	{
456
457
458
459
460
461
462
		if (!$this->checkPerm($session_id, 'mail_aliasdomain_update'))
		{
			$this->server->fault('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;
463
464
465
466
	}

	public function mail_aliasdomain_delete($session_id, $primary_id)
	{
467
468
469
470
471
472
473
		if (!$this->checkPerm($session_id, 'mail_aliasdomain_delete'))
		{
			$this->server->fault('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;
474
	}
475

476
477
	//* Get mail mailinglist details
	public function mail_mailinglist_get($session_id, $primary_id)
478
	{
479
		global $app;
480

481
482
483
484
485
486
487
488
		if(!$this->checkPerm($session_id, 'mail_mailinglist_get')) {
			$this->server->fault('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);
	}
489

490
491
	//* Add a mail mailinglist
	public function mail_mailinglist_add($session_id, $client_id, $params)
492
	{
493
494
495
496
		if(!$this->checkPerm($session_id, 'mail_mailinglist_add')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
497
		$primary_id = $this->insertQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $params);
498
499
		return $primary_id;
	}
500

501
502
	//* Update a mail mailinglist
	public function mail_mailinglist_update($session_id, $client_id, $primary_id, $params)
503
	{
504
505
506
507
508
509
510
		if(!$this->checkPerm($session_id, 'mail_mailinglist_update')) {
			$this->server->fault('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;
	}
511

512
513
	//* Delete a mail mailinglist
	public function mail_mailinglist_delete($session_id, $primary_id)
514
	{
515
516
517
518
519
520
521
		if(!$this->checkPerm($session_id, 'mail_mailinglist_delete')) {
			$this->server->fault('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;
	}
522

latham's avatar
latham committed
523
524
	//* Get mail user details
	public function mail_user_get($session_id, $primary_id)
525
	{
latham's avatar
latham committed
526
		global $app;
527

latham's avatar
latham committed
528
529
530
		if(!$this->checkPerm($session_id, 'mail_user_get')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
531
		}
latham's avatar
latham committed
532
533
534
535
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_user.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
536
537


538
	//* Add mail domain
latham's avatar
latham committed
539
	public function mail_user_add($session_id, $client_id, $params){
540
		global $app;
541

latham's avatar
latham committed
542
		if (!$this->checkPerm($session_id, 'mail_user_add')){
543
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
latham's avatar
latham committed
544
			return false;
545
		}
546

547
		//* Check if mail domain exists
548
		$email_parts = explode('@', $params['email']);
549
550
		$tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
		if($tmp['domain'] != $email_parts[1]) {
551
			$this->server->fault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.');
552
553
			return false;
		}
554

latham's avatar
latham committed
555
556
557
		$affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params);
		return $affected_rows;
	}
558

559
	//* Update mail user
latham's avatar
latham committed
560
561
	public function mail_user_update($session_id, $client_id, $primary_id, $params)
	{
562
		global $app;
563

latham's avatar
latham committed
564
565
		if (!$this->checkPerm($session_id, 'mail_user_update'))
		{
566
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
latham's avatar
latham committed
567
568
			return false;
		}
569

570
		//* Check if mail domain exists
571
		$email_parts = explode('@', $params['email']);
572
573
		$tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = '".$app->db->quote($email_parts[1])."'");
		if($tmp['domain'] != $email_parts[1]) {
574
			$this->server->fault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.');
575
576
			return false;
		}
577

latham's avatar
latham committed
578
579
		$affected_rows = $this->updateQuery('../mail/form/mail_user.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
580
	}
latham's avatar
latham committed
581

582

583
	//* Delete mail user
latham's avatar
latham committed
584
	public function mail_user_delete($session_id, $primary_id)
585
	{
latham's avatar
latham committed
586
587
		if (!$this->checkPerm($session_id, 'mail_user_delete'))
		{
588
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
latham's avatar
latham committed
589
			return false;
590
		}
latham's avatar
latham committed
591
592
593
		$affected_rows = $this->deleteQuery('../mail/form/mail_user.tform.php', $primary_id);
		return $affected_rows;
	}
594

latham's avatar
latham committed
595
596
	//* Get mail user filter details
	public function mail_user_filter_get($session_id, $primary_id)
597
	{
598
		global $app;
599

latham's avatar
latham committed
600
		if(!$this->checkPerm($session_id, 'mail_user_filter_get')) {
601
602
603
604
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
		$app->uses('remoting_lib');
latham's avatar
latham committed
605
		$app->remoting_lib->loadFormDef('../mail/form/mail_user_filter.tform.php');
606
607
		return $app->remoting_lib->getDataRecord($primary_id);
	}
608

latham's avatar
latham committed
609
610
611
612
	public function mail_user_filter_add($session_id, $client_id, $params)
	{
		global $app;
		if (!$this->checkPerm($session_id, 'mail_user_filter_add')){
613
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
latham's avatar
latham committed
614
615
			return false;
		}
616
		$affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params, 'mail:mail_user_filter:on_after_insert');
latham's avatar
latham committed
617
618
619
		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_insert',$this);
		return $affected_rows;
	}
620

latham's avatar
latham committed
621
622
623
624
625
	public function mail_user_filter_update($session_id, $client_id, $primary_id, $params)
	{
		global $app;
		if (!$this->checkPerm($session_id, 'mail_user_filter_update'))
		{
626
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
627
628
			return false;
		}
629
		$affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params, 'mail:mail_user_filter:on_after_update');
latham's avatar
latham committed
630
631
		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_update',$this);
		return $affected_rows;
632
633
	}

latham's avatar
latham committed
634
635
636
637
638
	public function mail_user_filter_delete($session_id, $primary_id)
	{
		global $app;
		if (!$this->checkPerm($session_id, 'mail_user_filter_delete'))
		{
639
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
latham's avatar
latham committed
640
641
			return false;
		}
642
		$affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id, 'mail:mail_user_filter:on_after_delete');
643
		// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
latham's avatar
latham committed
644
645
646
647
648
		return $affected_rows;
	}

	//* Get alias details
	public function mail_alias_get($session_id, $primary_id)
649
	{
latham's avatar
latham committed
650
		global $app;
651

latham's avatar
latham committed
652
		if(!$this->checkPerm($session_id, 'mail_alias_get')) {
653
654
655
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
		}
latham's avatar
latham committed
656
657
658
659
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_alias.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
	}
660

latham's avatar
latham committed
661
662
663
	//* aliasy email
	public function mail_alias_add($session_id, $client_id, $params)
	{
664
		global $app;
665

latham's avatar
latham committed
666
667
		if (!$this->checkPerm($session_id, 'mail_alias_add'))
		{
668
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
latham's avatar
latham committed
669
670
			return false;
		}
671

672
673
674
		//* Check if there is no active mailbox with this address
		$tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'");
		if($tmp['number'] > 0) {
675
			$this->server->fault('duplicate', 'There is already a mailbox with this email address.');
676
677
		}
		unset($tmp);
678

latham's avatar
latham committed
679
		$affected_rows = $this->insertQuery('../mail/form/mail_alias.tform.php', $client_id, $params);
680
681
682
683
		return $affected_rows;
	}


latham's avatar
latham committed
684
685
	public function mail_alias_update($session_id, $client_id, $primary_id, $params)
	{
686
		global $app;
687

688
689
		if (!$this->checkPerm($session_id, 'mail_alias_update'))
		{
690
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
691
692
			return false;
		}
693
694

		//* Check if there is no active mailbox with this address
695
696
		$tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'");
		if($tmp['number'] > 0) {
697
			$this->server->fault('duplicate', 'There is already a mailbox with this email address.');
698
699
		}
		unset($tmp);
700

701
702
		$affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
		return $affected_rows;
latham's avatar
latham committed
703
704
705
706
	}

	public function mail_alias_delete($session_id, $primary_id)
	{
707
708
709
710
711
712
713
		if (!$this->checkPerm($session_id, 'mail_alias_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
714
	}
715

latham's avatar
latham committed
716
717
	//* Get mail forwarding details
	public function mail_forward_get($session_id, $primary_id)
718
	{
latham's avatar
latham committed
719
		global $app;
720

latham's avatar
latham committed
721
722
723
		if(!$this->checkPerm($session_id, 'mail_forward_get')) {
			$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
			return false;
724
		}
latham's avatar
latham committed
725
726
727
		$app->uses('remoting_lib');
		$app->remoting_lib->loadFormDef('../mail/form/mail_forward.tform.php');
		return $app->remoting_lib->getDataRecord($primary_id);
728
	}
729
730

	//* przekierowania email
latham's avatar
latham committed
731
732
	public function mail_forward_add($session_id, $client_id, $params)
	{
733
734
735
736
737
738
739
		if (!$this->checkPerm($session_id, 'mail_forward_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
740
741
742
743
744
	}


	public function mail_forward_update($session_id, $client_id, $primary_id, $params)
	{
745
746
747
748
749
750
751
		if (!$this->checkPerm($session_id, 'mail_forward_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
752
753
754
755
756
	}


	public function mail_forward_delete($session_id, $primary_id)
	{
757
758
759
760
761
762
763
		if (!$this->checkPerm($session_id, 'mail_forward_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
764
	}
765

latham's avatar
latham committed
766
767
	//* Get catchall details
	public function mail_catchall_get($session_id, $primary_id)
768
	{
latham's avatar
latham committed
769
		global $app;
770

latham's avatar
latham committed
771
772
773
774
775
776
777
778
779
780
		if(!$this->checkPerm($session_id, 'mail_catchall_get')) {
			$this->server->fault('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
781
	public function mail_catchall_add($session_id, $client_id, $params)
latham's avatar
latham committed
782
	{
783
784
785
786
787
788
789
		if (!$this->checkPerm($session_id, 'mail_catchall_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
790
791
792
793
	}

	public function mail_catchall_update($session_id, $client_id, $primary_id, $params)
	{
794
795
796
797
798
799
800
		if (!$this->checkPerm($session_id, 'mail_catchall_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
801
802
803
804
	}

	public function mail_catchall_delete($session_id, $primary_id)
	{
805
806
807
808
809
810
811
		if (!$this->checkPerm($session_id, 'mail_catchall_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
812
	}
813

latham's avatar
latham committed
814
815
	//* Get transport details
	public function mail_transport_get($session_id, $primary_id)
816
	{
latham's avatar
latham committed
817
		global $app;
818

latham's avatar
latham committed
819
820
821
822
823
824
825
826
		if(!$this->checkPerm($session_id, 'mail_transport_get')) {
			$this->server->fault('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);
	}
827

latham's avatar
latham committed
828
829
830
	//* przeniesienia e-mail
	public function mail_transport_add($session_id, $client_id, $params)
	{
831
832
833
834
835
836
837
		if (!$this->checkPerm($session_id, 'mail_transport_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
838
839
840
841
842
	}


	public function mail_transport_update($session_id, $client_id, $primary_id, $params)
	{
843
844
845
846
847
848
849
		if (!$this->checkPerm($session_id, 'mail_transport_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
850
851
852
853
854
	}


	public function mail_transport_delete($session_id, $primary_id)
	{
855
856
857
858
859
860
861
		if (!$this->checkPerm($session_id, 'mail_transport_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
862
	}
863

864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916

	//* 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')) {
				$this->server->fault('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_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'))
		{
			$this->server->fault('permission_denied','You do not have the permissions to access this function.');
			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'))
		{
			$this->server->fault('permission_denied','You do not have the permissions to access this function.');
			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'))
		{
			$this->server->fault('permission_denied','You do not have the permissions to access this function.');
			return false;
		}
		$affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
		return $affected_rows;
	}


latham's avatar
latham committed
917
918
	//* Get spamfilter whitelist details
	public function mail_spamfilter_whitelist_get($session_id, $primary_id)
919
	{
latham's avatar
latham committed
920
		global $app;
921

latham's avatar
latham committed
922
923
924
925
926
927
928
929
930
		if(!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_get')) {
			$this->server->fault('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);
	}

931
	//* biała lista e-mail
latham's avatar
latham committed
932
933
	public function mail_spamfilter_whitelist_add($session_id, $client_id, $params)
	{
934
935
936
937
938
939
940
		if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
941
942
943
944
945
	}


	public function mail_spamfilter_whitelist_update($session_id, $client_id, $primary_id, $params)
	{
946
947
948
949
950
951
952
		if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
953
954
955
956
957
	}


	public function mail_spamfilter_whitelist_delete($session_id, $primary_id)
	{
958
959
960
961
962
963
964
		if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
965
	}
966

latham's avatar
latham committed
967
968
	//* Get spamfilter blacklist details
	public function mail_spamfilter_blacklist_get($session_id, $primary_id)
969
	{
latham's avatar
latham committed
970
		global $app;
971

latham's avatar
latham committed
972
973
974
975
976
977
978
979
		if(!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_get')) {
			$this->server->fault('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);
	}
980
981

	//* czarna lista e-mail
latham's avatar
latham committed
982
983
	public function mail_spamfilter_blacklist_add($session_id, $client_id, $params)
	{
984
985
986
987
988
989
990
		if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
991
992
993
994
995
	}


	public function mail_spamfilter_blacklist_update($session_id, $client_id, $primary_id, $params)
	{
996
997
998
999
1000
1001
1002
		if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1003
1004
1005
1006
1007
	}


	public function mail_spamfilter_blacklist_delete($session_id, $primary_id)
	{
1008
1009
1010
1011
1012
1013
1014
		if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1015
	}
1016

latham's avatar
latham committed
1017
1018
	//* Get spamfilter user details
	public function mail_spamfilter_user_get($session_id, $primary_id)
1019
	{
latham's avatar
latham committed
1020
		global $app;
1021

latham's avatar
latham committed
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
		if(!$this->checkPerm($session_id, 'mail_spamfilter_user_get')) {
			$this->server->fault('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)
	{
1034
1035
1036
1037
1038
1039
1040
		if (!$this->checkPerm($session_id, 'mail_spamfilter_user_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1041
1042
1043
1044
1045
	}


	public function mail_spamfilter_user_update($session_id, $client_id, $primary_id, $params)
	{
1046
1047
1048
1049
1050
1051
1052
		if (!$this->checkPerm($session_id, 'mail_spamfilter_user_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1053
1054
1055
1056
1057
	}


	public function mail_spamfilter_user_delete($session_id, $primary_id)
	{
1058
1059
1060
1061
1062
1063
1064
		if (!$this->checkPerm($session_id, 'mail_spamfilter_user_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1065
	}
1066

latham's avatar
latham committed
1067
1068
	//* Get policy details
	public function mail_policy_get($session_id, $primary_id)
1069
	{
latham's avatar
latham committed
1070
		global $app;
1071

latham's avatar
latham committed
1072
1073
1074
1075
1076
1077
1078
1079
		if(!$this->checkPerm($session_id, 'mail_policy_get')) {
			$this->server->fault('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);
	}
1080
1081

	//* polityki filtrów spamu e-mail
latham's avatar
latham committed
1082
1083
	public function mail_policy_add($session_id, $client_id, $params)
	{
1084
1085
1086
1087
1088
1089
1090
		if (!$this->checkPerm($session_id, 'mail_policy_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1091
1092
1093
1094
1095
	}


	public function mail_policy_update($session_id, $client_id, $primary_id, $params)
	{
1096
1097
1098
1099
1100
1101
1102
		if (!$this->checkPerm($session_id, 'mail_policy_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1103
1104
1105
1106
1107
	}


	public function mail_policy_delete($session_id, $primary_id)
	{
1108
1109
1110
1111
1112
1113
1114
		if (!$this->checkPerm($session_id, 'mail_policy_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1115
	}
1116

latham's avatar
latham committed
1117
1118
	//* Get fetchmail details
	public function mail_fetchmail_get($session_id, $primary_id)
1119
	{
latham's avatar
latham committed
1120
		global $app;
1121

latham's avatar
latham committed
1122
1123
1124
1125
1126
1127
1128
1129
1130
		if(!$this->checkPerm($session_id, 'mail_fetchmail_get')) {
			$this->server->fault('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);
	}

1131
	//* fetchmail
latham's avatar
latham committed
1132
1133
	public function mail_fetchmail_add($session_id, $client_id, $params)
	{
1134
1135
1136
1137
1138
1139
1140
		if (!$this->checkPerm($session_id, 'mail_fetchmail_add'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1141
1142
1143
1144
1145
	}


	public function mail_fetchmail_update($session_id, $client_id, $primary_id, $params)
	{
1146
1147
1148
1149
1150
1151
1152
		if (!$this->checkPerm($session_id, 'mail_fetchmail_update'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1153
1154
1155
1156
1157
	}


	public function mail_fetchmail_delete($session_id, $primary_id)
	{
1158
1159
1160
1161
1162
1163
1164
		if (!$this->checkPerm($session_id, 'mail_fetchmail_delete'))
		{
			$this->server->fault('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;
latham's avatar
latham committed
1165
	}
1166