Marius Burkard
2016-04-20 4569cae57f127afd093794310ccd290d2d9fdf36
commit | author | age
c1418f 1 <?php
M 2
3 /*
4 Copyright (c) 2007 - 2013, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 --UPDATED 08.2009--
31 Full SOAP support for ISPConfig 3.1.4 b
32 Updated by Arkadiusz Roch & Artur Edelman
33 Copyright (c) Tri-Plex technology
34
35 --UPDATED 08.2013--
36 Migrated into new remote classes system
37 by Marius Cramer <m.cramer@pixcept.de>
38
39 */
40
41 class remoting_mail extends remoting {
42     //* Get mail domain details
43     public function mail_domain_get($session_id, $primary_id)
b1a6a5 44     {
c1418f 45         global $app;
b1a6a5 46
c1418f 47         if(!$this->checkPerm($session_id, 'mail_domain_get')) {
M 48             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
49             return false;
50         }
51         $app->uses('remoting_lib');
52         $app->remoting_lib->loadFormDef('../mail/form/mail_domain.tform.php');
53         return $app->remoting_lib->getDataRecord($primary_id);
54     }
b1a6a5 55
c1418f 56     //* Add a mail domain
M 57     public function mail_domain_add($session_id, $client_id, $params)
b1a6a5 58     {
c1418f 59         if(!$this->checkPerm($session_id, 'mail_domain_add')) {
M 60             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
61             return false;
62         }
b1a6a5 63         $primary_id = $this->insertQuery('../mail/form/mail_domain.tform.php', $client_id, $params);
c1418f 64         return $primary_id;
M 65     }
b1a6a5 66
c1418f 67     //* Update a mail domain
M 68     public function mail_domain_update($session_id, $client_id, $primary_id, $params)
b1a6a5 69     {
c1418f 70         if(!$this->checkPerm($session_id, 'mail_domain_update')) {
M 71             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
72             return false;
73         }
74         $affected_rows = $this->updateQuery('../mail/form/mail_domain.tform.php', $client_id, $primary_id, $params);
75         return $affected_rows;
76     }
b1a6a5 77
c1418f 78     //* Delete a mail domain
M 79     public function mail_domain_delete($session_id, $primary_id)
b1a6a5 80     {
c1418f 81         if(!$this->checkPerm($session_id, 'mail_domain_delete')) {
M 82             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
83             return false;
84         }
85         $affected_rows = $this->deleteQuery('../mail/form/mail_domain.tform.php', $primary_id);
86         return $affected_rows;
87     }
b1a6a5 88
c1418f 89     //* Get alias details
M 90     public function mail_aliasdomain_get($session_id, $primary_id)
b1a6a5 91     {
c1418f 92         global $app;
b1a6a5 93
c1418f 94         if(!$this->checkPerm($session_id, 'mail_aliasdomain_get')) {
M 95             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
96             return false;
97         }
98         $app->uses('remoting_lib');
99         $app->remoting_lib->loadFormDef('../mail/form/mail_aliasdomain.tform.php');
100         return $app->remoting_lib->getDataRecord($primary_id);
101     }
b1a6a5 102
c1418f 103     //* aliasy email
M 104     public function mail_aliasdomain_add($session_id, $client_id, $params)
105     {
106         if (!$this->checkPerm($session_id, 'mail_aliasdomain_add'))
107         {
b1a6a5 108             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 109             return false;
M 110         }
111         $affected_rows = $this->insertQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $params);
112         return $affected_rows;
113     }
114
115
116     public function mail_aliasdomain_update($session_id, $client_id, $primary_id, $params)
117     {
b1a6a5 118         if (!$this->checkPerm($session_id, 'mail_aliasdomain_update'))
MC 119         {
120             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
121             return false;
122         }
123         $affected_rows = $this->updateQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $primary_id, $params);
124         return $affected_rows;
c1418f 125     }
M 126
127     public function mail_aliasdomain_delete($session_id, $primary_id)
128     {
b1a6a5 129         if (!$this->checkPerm($session_id, 'mail_aliasdomain_delete'))
MC 130         {
131             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
132             return false;
133         }
134         $affected_rows = $this->deleteQuery('../mail/form/mail_aliasdomain.tform.php', $primary_id);
135         return $affected_rows;
c1418f 136     }
b1a6a5 137
c1418f 138     //* Get mail mailinglist details
M 139     public function mail_mailinglist_get($session_id, $primary_id)
b1a6a5 140     {
c1418f 141         global $app;
b1a6a5 142
c1418f 143         if(!$this->checkPerm($session_id, 'mail_mailinglist_get')) {
M 144             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
145             return false;
146         }
147         $app->uses('remoting_lib');
148         $app->remoting_lib->loadFormDef('../mail/form/mail_mailinglist.tform.php');
149         return $app->remoting_lib->getDataRecord($primary_id);
150     }
b1a6a5 151
c1418f 152     //* Add a mail mailinglist
M 153     public function mail_mailinglist_add($session_id, $client_id, $params)
b1a6a5 154     {
c1418f 155         if(!$this->checkPerm($session_id, 'mail_mailinglist_add')) {
M 156             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
157             return false;
158         }
b1a6a5 159         $primary_id = $this->insertQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $params);
c1418f 160         return $primary_id;
M 161     }
b1a6a5 162
c1418f 163     //* Update a mail mailinglist
M 164     public function mail_mailinglist_update($session_id, $client_id, $primary_id, $params)
b1a6a5 165     {
c1418f 166         if(!$this->checkPerm($session_id, 'mail_mailinglist_update')) {
M 167             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
168             return false;
169         }
170         $affected_rows = $this->updateQuery('../mail/form/mail_mailinglist.tform.php', $client_id, $primary_id, $params);
171         return $affected_rows;
172     }
b1a6a5 173
c1418f 174     //* Delete a mail mailinglist
M 175     public function mail_mailinglist_delete($session_id, $primary_id)
b1a6a5 176     {
c1418f 177         if(!$this->checkPerm($session_id, 'mail_mailinglist_delete')) {
M 178             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
179             return false;
180         }
181         $affected_rows = $this->deleteQuery('../mail/form/mail_mailinglist.tform.php', $primary_id);
182         return $affected_rows;
183     }
b1a6a5 184
c1418f 185     //* Get mail user details
M 186     public function mail_user_get($session_id, $primary_id)
b1a6a5 187     {
c1418f 188         global $app;
b1a6a5 189
c1418f 190         if(!$this->checkPerm($session_id, 'mail_user_get')) {
M 191             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
192             return false;
193         }
194         $app->uses('remoting_lib');
195         $app->remoting_lib->loadFormDef('../mail/form/mail_user.tform.php');
196         return $app->remoting_lib->getDataRecord($primary_id);
197     }
b1a6a5 198
MC 199
c1418f 200     //* Add mail domain
M 201     public function mail_user_add($session_id, $client_id, $params){
202         global $app;
b1a6a5 203
c1418f 204         if (!$this->checkPerm($session_id, 'mail_user_add')){
b1a6a5 205             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 206             return false;
M 207         }
b1a6a5 208
c1418f 209         //* Check if mail domain exists
b1a6a5 210         $email_parts = explode('@', $params['email']);
cc7a82 211         $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = ?", $email_parts[1]);
c1418f 212         if($tmp['domain'] != $email_parts[1]) {
b1a6a5 213             throw new SoapFault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.');
c1418f 214             return false;
M 215         }
b1a6a5 216
f5d73a 217         //* Set a few params to non empty values that will be overwritten by mail_plugin
9ea57c 218         if (!isset($params['uid'])) $params['uid'] = -1;
DM 219         if (!isset($params['gid'])) $params['gid'] = -1;
f5d73a 220
c1418f 221         $affected_rows = $this->insertQuery('../mail/form/mail_user.tform.php', $client_id, $params);
M 222         return $affected_rows;
223     }
224
b1a6a5 225     //* Update mail user
c1418f 226     public function mail_user_update($session_id, $client_id, $primary_id, $params)
M 227     {
228         global $app;
b1a6a5 229
c1418f 230         if (!$this->checkPerm($session_id, 'mail_user_update'))
M 231         {
b1a6a5 232             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 233             return false;
M 234         }
b1a6a5 235
c1418f 236         //* Check if mail domain exists
b1a6a5 237         $email_parts = explode('@', $params['email']);
cc7a82 238         $tmp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain = ?", $email_parts[1]);
c1418f 239         if($tmp['domain'] != $email_parts[1]) {
b1a6a5 240             throw new SoapFault('mail_domain_does_not_exist', 'Mail domain - '.$email_parts[1].' - does not exist.');
c1418f 241             return false;
M 242         }
b1a6a5 243
c1418f 244         $affected_rows = $this->updateQuery('../mail/form/mail_user.tform.php', $client_id, $primary_id, $params);
M 245         return $affected_rows;
246     }
247
b1a6a5 248
c1418f 249     //* Delete mail user
M 250     public function mail_user_delete($session_id, $primary_id)
251     {
252         if (!$this->checkPerm($session_id, 'mail_user_delete'))
253         {
b1a6a5 254             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 255             return false;
M 256         }
257         $affected_rows = $this->deleteQuery('../mail/form/mail_user.tform.php', $primary_id);
258         return $affected_rows;
259     }
b1a6a5 260
c1418f 261     //* Get mail user filter details
M 262     public function mail_user_filter_get($session_id, $primary_id)
b1a6a5 263     {
c1418f 264         global $app;
b1a6a5 265
c1418f 266         if(!$this->checkPerm($session_id, 'mail_user_filter_get')) {
M 267             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
268             return false;
269         }
270         $app->uses('remoting_lib');
271         $app->remoting_lib->loadFormDef('../mail/form/mail_user_filter.tform.php');
272         return $app->remoting_lib->getDataRecord($primary_id);
273     }
b1a6a5 274
c1418f 275     public function mail_user_filter_add($session_id, $client_id, $params)
M 276     {
277         global $app;
278         if (!$this->checkPerm($session_id, 'mail_user_filter_add')){
b1a6a5 279             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 280             return false;
M 281         }
b1a6a5 282         $affected_rows = $this->insertQuery('../mail/form/mail_user_filter.tform.php', $client_id, $params, 'mail:mail_user_filter:on_after_insert');
c1418f 283         // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_insert',$this);
M 284         return $affected_rows;
285     }
286
287     public function mail_user_filter_update($session_id, $client_id, $primary_id, $params)
288     {
289         global $app;
290         if (!$this->checkPerm($session_id, 'mail_user_filter_update'))
291         {
b1a6a5 292             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 293             return false;
M 294         }
b1a6a5 295         $affected_rows = $this->updateQuery('../mail/form/mail_user_filter.tform.php', $client_id, $primary_id, $params, 'mail:mail_user_filter:on_after_update');
c1418f 296         // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_update',$this);
M 297         return $affected_rows;
298     }
299
300     public function mail_user_filter_delete($session_id, $primary_id)
301     {
302         global $app;
303         if (!$this->checkPerm($session_id, 'mail_user_filter_delete'))
304         {
b1a6a5 305             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 306             return false;
M 307         }
b1a6a5 308         $affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id, 'mail:mail_user_filter:on_after_delete');
c1418f 309         // $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
M 310         return $affected_rows;
311     }
370c6a 312     
D 313     // Mail backup list function by Dominik MĂŒller, info@profi-webdesign.net
314     public function mail_user_backup_list($session_id, $primary_id = null)
315     {
316         global $app;
317     
318         if(!$this->checkPerm($session_id, 'mail_user_backup')) {
319             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
320             return false;
321         }
322     
cc7a82 323         $params = array();
370c6a 324         if ($site_id != null) {
cc7a82 325             $params[] = $site_id;
MC 326             $sql  = "SELECT * FROM mail_backup WHERE parent_domain_id = ?";
370c6a 327         }
D 328         else {
329             $sql  = "SELECT * FROM mail_backup";
330         }
331     
cc7a82 332         $result = $app->db->queryAllRecords($sql, true, $params);
370c6a 333         return $result;
D 334     }
335     
336     // Mail backup restore/download functions by Dominik MĂŒller, info@profi-webdesign.net
337     public function mail_user_backup($session_id, $primary_id, $action_type)
338     {
339         global $app;
340     
341         if(!$this->checkPerm($session_id, 'mail_user_backup')) {
342             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
343             return false;
344         }
345     
346         //*Set variables
cc7a82 347         $backup_record  =       $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id);
370c6a 348         $server_id      =       $backup_record['server_id'];
D 349     
350         //*Set default action state
351         $action_state   =       "pending";
352         $tstamp         =       time();
353     
354         //* Basic validation of variables
355         if ($server_id <= 0) {
356             $this->server->fault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
357             return false;
358         }
359     
634132 360         if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail' and $action_type != 'backup_delete_mail') {
370c6a 361             $this->server->fault('invalid_action', "Invalid action_type $action_type");
D 362             return false;
363         }
364     
365         //* Validate instance
cc7a82 366         $instance_record        =       $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type);
370c6a 367         if ($instance_record['action_id'] >= 1) {
D 368             $this->server->fault('duplicate_action', "There is already a pending $action_type action");
369             return false;
370         }
371     
372         //* Save the record
a6e3ae 373         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)) {
370c6a 374             return true;
D 375         } else {
376             return false;
377         }
378     }
c1418f 379
M 380     //* Get alias details
381     public function mail_alias_get($session_id, $primary_id)
b1a6a5 382     {
c1418f 383         global $app;
b1a6a5 384
c1418f 385         if(!$this->checkPerm($session_id, 'mail_alias_get')) {
M 386             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
387             return false;
388         }
389         $app->uses('remoting_lib');
390         $app->remoting_lib->loadFormDef('../mail/form/mail_alias.tform.php');
391         return $app->remoting_lib->getDataRecord($primary_id);
392     }
b1a6a5 393
c1418f 394     //* aliasy email
M 395     public function mail_alias_add($session_id, $client_id, $params)
396     {
397         global $app;
b1a6a5 398
c1418f 399         if (!$this->checkPerm($session_id, 'mail_alias_add'))
M 400         {
b1a6a5 401             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 402             return false;
M 403         }
b1a6a5 404
c1418f 405         //* Check if there is no active mailbox with this address
cc7a82 406         $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = ?", $params["source"]);
c1418f 407         if($tmp['number'] > 0) {
b1a6a5 408             throw new SoapFault('duplicate', 'There is already a mailbox with this email address.');
c1418f 409         }
M 410         unset($tmp);
b1a6a5 411
c1418f 412         $affected_rows = $this->insertQuery('../mail/form/mail_alias.tform.php', $client_id, $params);
M 413         return $affected_rows;
414     }
415
416
417     public function mail_alias_update($session_id, $client_id, $primary_id, $params)
418     {
419         global $app;
b1a6a5 420
c1418f 421         if (!$this->checkPerm($session_id, 'mail_alias_update'))
M 422         {
b1a6a5 423             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
c1418f 424             return false;
M 425         }
b1a6a5 426
MC 427         //* Check if there is no active mailbox with this address
cc7a82 428         $tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = ?", $params["source"]);
c1418f 429         if($tmp['number'] > 0) {
b1a6a5 430             throw new SoapFault('duplicate', 'There is already a mailbox with this email address.');
c1418f 431         }
M 432         unset($tmp);
b1a6a5 433
c1418f 434         $affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
M 435         return $affected_rows;
436     }
437
438     public function mail_alias_delete($session_id, $primary_id)
439     {
b1a6a5 440         if (!$this->checkPerm($session_id, 'mail_alias_delete'))
MC 441         {
442             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
443             return false;
444         }
445         $affected_rows = $this->deleteQuery('../mail/form/mail_alias.tform.php', $primary_id);
446         return $affected_rows;
c1418f 447     }
b1a6a5 448
c1418f 449     //* Get mail forwarding details
M 450     public function mail_forward_get($session_id, $primary_id)
b1a6a5 451     {
c1418f 452         global $app;
b1a6a5 453
c1418f 454         if(!$this->checkPerm($session_id, 'mail_forward_get')) {
M 455             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
456             return false;
457         }
458         $app->uses('remoting_lib');
459         $app->remoting_lib->loadFormDef('../mail/form/mail_forward.tform.php');
460         return $app->remoting_lib->getDataRecord($primary_id);
461     }
b1a6a5 462
MC 463     //* przekierowania email
c1418f 464     public function mail_forward_add($session_id, $client_id, $params)
M 465     {
b1a6a5 466         if (!$this->checkPerm($session_id, 'mail_forward_add'))
MC 467         {
468             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
469             return false;
470         }
471         $affected_rows = $this->insertQuery('../mail/form/mail_forward.tform.php', $client_id, $params);
472         return $affected_rows;
c1418f 473     }
M 474
475
476     public function mail_forward_update($session_id, $client_id, $primary_id, $params)
477     {
b1a6a5 478         if (!$this->checkPerm($session_id, 'mail_forward_update'))
MC 479         {
480             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
481             return false;
482         }
483         $affected_rows = $this->updateQuery('../mail/form/mail_forward.tform.php', $client_id, $primary_id, $params);
484         return $affected_rows;
c1418f 485     }
M 486
487
488     public function mail_forward_delete($session_id, $primary_id)
489     {
b1a6a5 490         if (!$this->checkPerm($session_id, 'mail_forward_delete'))
MC 491         {
492             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
493             return false;
494         }
495         $affected_rows = $this->deleteQuery('../mail/form/mail_forward.tform.php', $primary_id);
496         return $affected_rows;
c1418f 497     }
b1a6a5 498
c1418f 499     //* Get catchall details
M 500     public function mail_catchall_get($session_id, $primary_id)
b1a6a5 501     {
c1418f 502         global $app;
b1a6a5 503
c1418f 504         if(!$this->checkPerm($session_id, 'mail_catchall_get')) {
M 505             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
506             return false;
507         }
508         $app->uses('remoting_lib');
509         $app->remoting_lib->loadFormDef('../mail/form/mail_domain_catchall.tform.php');
510         return $app->remoting_lib->getDataRecord($primary_id);
511     }
512
513     //* catchall e-mail
b1a6a5 514     public function mail_catchall_add($session_id, $client_id, $params)
c1418f 515     {
b1a6a5 516         if (!$this->checkPerm($session_id, 'mail_catchall_add'))
MC 517         {
518             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
519             return false;
520         }
521         $affected_rows = $this->insertQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $params);
522         return $affected_rows;
c1418f 523     }
M 524
525     public function mail_catchall_update($session_id, $client_id, $primary_id, $params)
526     {
b1a6a5 527         if (!$this->checkPerm($session_id, 'mail_catchall_update'))
MC 528         {
529             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
530             return false;
531         }
532         $affected_rows = $this->updateQuery('../mail/form/mail_domain_catchall.tform.php', $client_id, $primary_id, $params);
533         return $affected_rows;
c1418f 534     }
M 535
536     public function mail_catchall_delete($session_id, $primary_id)
537     {
b1a6a5 538         if (!$this->checkPerm($session_id, 'mail_catchall_delete'))
MC 539         {
540             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
541             return false;
542         }
543         $affected_rows = $this->deleteQuery('../mail/form/mail_domain_catchall.tform.php', $primary_id);
544         return $affected_rows;
c1418f 545     }
b1a6a5 546
c1418f 547     //* Get transport details
M 548     public function mail_transport_get($session_id, $primary_id)
b1a6a5 549     {
c1418f 550         global $app;
b1a6a5 551
c1418f 552         if(!$this->checkPerm($session_id, 'mail_transport_get')) {
M 553             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
554             return false;
555         }
556         $app->uses('remoting_lib');
557         $app->remoting_lib->loadFormDef('../mail/form/mail_transport.tform.php');
558         return $app->remoting_lib->getDataRecord($primary_id);
559     }
b1a6a5 560
c1418f 561     //* przeniesienia e-mail
M 562     public function mail_transport_add($session_id, $client_id, $params)
563     {
b1a6a5 564         if (!$this->checkPerm($session_id, 'mail_transport_add'))
MC 565         {
566             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
567             return false;
568         }
569         $affected_rows = $this->insertQuery('../mail/form/mail_transport.tform.php', $client_id, $params);
570         return $affected_rows;
c1418f 571     }
M 572
573
574     public function mail_transport_update($session_id, $client_id, $primary_id, $params)
575     {
b1a6a5 576         if (!$this->checkPerm($session_id, 'mail_transport_update'))
MC 577         {
578             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
579             return false;
580         }
581         $affected_rows = $this->updateQuery('../mail/form/mail_transport.tform.php', $client_id, $primary_id, $params);
582         return $affected_rows;
c1418f 583     }
M 584
585
586     public function mail_transport_delete($session_id, $primary_id)
587     {
b1a6a5 588         if (!$this->checkPerm($session_id, 'mail_transport_delete'))
MC 589         {
590             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
591             return false;
592         }
593         $affected_rows = $this->deleteQuery('../mail/form/mail_transport.tform.php', $primary_id);
594         return $affected_rows;
c1418f 595     }
b1a6a5 596
f18ff1 597     //* Get mail relay_recipient details
MC 598     public function mail_relay_recipient_get($session_id, $primary_id)
599     {
600         global $app;
601
602         if(!$this->checkPerm($session_id, 'mail_relay_get')) {
603                 $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
604                 return false;
605         }
606         $app->uses('remoting_lib');
607         $app->remoting_lib->loadFormDef('../mail/form/mail_relay_recipient.tform.php');
608         return $app->remoting_lib->getDataRecord($primary_id);
609     }
610
611
612     //* relay recipient email
613     public function mail_relay_recipient_add($session_id, $client_id, $params)
614     {
615         if (!$this->checkPerm($session_id, 'mail_relay_add'))
616         {
617             $this->server->fault('permission_denied','You do not have the permissions to access this function.');
618             return false;
619         }
620         $affected_rows = $this->insertQuery('../mail/form/mail_relay_recipient.tform.php', $client_id, $params);
621         return $affected_rows;
622     }
623
624
625     public function mail_relay_recipient_update($session_id, $client_id, $primary_id, $params)
626     {
627         if (!$this->checkPerm($session_id, 'mail_relay_update'))
628         {
629             $this->server->fault('permission_denied','You do not have the permissions to access this function.');
630             return false;
631         }
632         $affected_rows = $this->updateQuery('../mail/form/mail_relay_recipient.tform.php', $client_id, $primary_id, $params);
633         return $affected_rows;
634     }
635
636
637     public function mail_relay_recipient_delete($session_id, $primary_id)
638     {
639         if (!$this->checkPerm($session_id, 'mail_relay_delete'))
640         {
641             $this->server->fault('permission_denied','You do not have the permissions to access this function.');
642             return false;
643         }
644         $affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
645         return $affected_rows;
646     }
647     
c1418f 648     //* Get spamfilter whitelist details
M 649     public function mail_spamfilter_whitelist_get($session_id, $primary_id)
b1a6a5 650     {
c1418f 651         global $app;
b1a6a5 652
c1418f 653         if(!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_get')) {
M 654             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
655             return false;
656         }
657         $app->uses('remoting_lib');
658         $app->remoting_lib->loadFormDef('../mail/form/spamfilter_whitelist.tform.php');
659         return $app->remoting_lib->getDataRecord($primary_id);
660     }
661
b1a6a5 662     //* biaƂa lista e-mail
c1418f 663     public function mail_spamfilter_whitelist_add($session_id, $client_id, $params)
M 664     {
b1a6a5 665         if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_add'))
MC 666         {
667             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
668             return false;
669         }
670         $affected_rows = $this->insertQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $params);
671         return $affected_rows;
c1418f 672     }
M 673
674
675     public function mail_spamfilter_whitelist_update($session_id, $client_id, $primary_id, $params)
676     {
b1a6a5 677         if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_update'))
MC 678         {
679             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
680             return false;
681         }
682         $affected_rows = $this->updateQuery('../mail/form/spamfilter_whitelist.tform.php', $client_id, $primary_id, $params);
683         return $affected_rows;
c1418f 684     }
M 685
686
687     public function mail_spamfilter_whitelist_delete($session_id, $primary_id)
688     {
b1a6a5 689         if (!$this->checkPerm($session_id, 'mail_spamfilter_whitelist_delete'))
MC 690         {
691             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
692             return false;
693         }
694         $affected_rows = $this->deleteQuery('../mail/form/spamfilter_whitelist.tform.php', $primary_id);
695         return $affected_rows;
c1418f 696     }
b1a6a5 697
c1418f 698     //* Get spamfilter blacklist details
M 699     public function mail_spamfilter_blacklist_get($session_id, $primary_id)
b1a6a5 700     {
c1418f 701         global $app;
b1a6a5 702
c1418f 703         if(!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_get')) {
M 704             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
705             return false;
706         }
707         $app->uses('remoting_lib');
708         $app->remoting_lib->loadFormDef('../mail/form/spamfilter_blacklist.tform.php');
709         return $app->remoting_lib->getDataRecord($primary_id);
710     }
b1a6a5 711
MC 712     //* czarna lista e-mail
c1418f 713     public function mail_spamfilter_blacklist_add($session_id, $client_id, $params)
M 714     {
b1a6a5 715         if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_add'))
MC 716         {
717             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
718             return false;
719         }
720         $affected_rows = $this->insertQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $params);
721         return $affected_rows;
c1418f 722     }
M 723
724
725     public function mail_spamfilter_blacklist_update($session_id, $client_id, $primary_id, $params)
726     {
b1a6a5 727         if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_update'))
MC 728         {
729             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
730             return false;
731         }
732         $affected_rows = $this->updateQuery('../mail/form/spamfilter_blacklist.tform.php', $client_id, $primary_id, $params);
733         return $affected_rows;
c1418f 734     }
M 735
736
737     public function mail_spamfilter_blacklist_delete($session_id, $primary_id)
738     {
b1a6a5 739         if (!$this->checkPerm($session_id, 'mail_spamfilter_blacklist_delete'))
MC 740         {
741             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
742             return false;
743         }
744         $affected_rows = $this->deleteQuery('../mail/form/spamfilter_blacklist.tform.php', $primary_id);
745         return $affected_rows;
c1418f 746     }
b1a6a5 747
c1418f 748     //* Get spamfilter user details
M 749     public function mail_spamfilter_user_get($session_id, $primary_id)
b1a6a5 750     {
c1418f 751         global $app;
b1a6a5 752
c1418f 753         if(!$this->checkPerm($session_id, 'mail_spamfilter_user_get')) {
M 754             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
755             return false;
756         }
757         $app->uses('remoting_lib');
758         $app->remoting_lib->loadFormDef('../mail/form/spamfilter_users.tform.php');
759         return $app->remoting_lib->getDataRecord($primary_id);
760     }
761
762     //* filtr spamu uĆŒytkownikĂłw e-mail
763     public function mail_spamfilter_user_add($session_id, $client_id, $params)
764     {
b1a6a5 765         if (!$this->checkPerm($session_id, 'mail_spamfilter_user_add'))
MC 766         {
767             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
768             return false;
769         }
770         $affected_rows = $this->insertQuery('../mail/form/spamfilter_users.tform.php', $client_id, $params);
771         return $affected_rows;
c1418f 772     }
M 773
774
775     public function mail_spamfilter_user_update($session_id, $client_id, $primary_id, $params)
776     {
b1a6a5 777         if (!$this->checkPerm($session_id, 'mail_spamfilter_user_update'))
MC 778         {
779             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
780             return false;
781         }
782         $affected_rows = $this->updateQuery('../mail/form/spamfilter_users.tform.php', $client_id, $primary_id, $params);
783         return $affected_rows;
c1418f 784     }
M 785
786
787     public function mail_spamfilter_user_delete($session_id, $primary_id)
788     {
b1a6a5 789         if (!$this->checkPerm($session_id, 'mail_spamfilter_user_delete'))
MC 790         {
791             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
792             return false;
793         }
794         $affected_rows = $this->deleteQuery('../mail/form/spamfilter_users.tform.php', $primary_id);
795         return $affected_rows;
c1418f 796     }
b1a6a5 797
c1418f 798     //* Get policy details
M 799     public function mail_policy_get($session_id, $primary_id)
b1a6a5 800     {
c1418f 801         global $app;
b1a6a5 802
c1418f 803         if(!$this->checkPerm($session_id, 'mail_policy_get')) {
M 804             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
805             return false;
806         }
807         $app->uses('remoting_lib');
808         $app->remoting_lib->loadFormDef('../mail/form/spamfilter_policy.tform.php');
809         return $app->remoting_lib->getDataRecord($primary_id);
810     }
b1a6a5 811
MC 812     //* polityki filtrĂłw spamu e-mail
c1418f 813     public function mail_policy_add($session_id, $client_id, $params)
M 814     {
b1a6a5 815         if (!$this->checkPerm($session_id, 'mail_policy_add'))
MC 816         {
817             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
818             return false;
819         }
820         $affected_rows = $this->insertQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $params);
821         return $affected_rows;
c1418f 822     }
M 823
824
825     public function mail_policy_update($session_id, $client_id, $primary_id, $params)
826     {
b1a6a5 827         if (!$this->checkPerm($session_id, 'mail_policy_update'))
MC 828         {
829             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
830             return false;
831         }
832         $affected_rows = $this->updateQuery('../mail/form/spamfilter_policy.tform.php', $client_id, $primary_id, $params);
833         return $affected_rows;
c1418f 834     }
M 835
836
837     public function mail_policy_delete($session_id, $primary_id)
838     {
b1a6a5 839         if (!$this->checkPerm($session_id, 'mail_policy_delete'))
MC 840         {
841             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
842             return false;
843         }
844         $affected_rows = $this->deleteQuery('../mail/form/spamfilter_policy.tform.php', $primary_id);
845         return $affected_rows;
c1418f 846     }
b1a6a5 847
c1418f 848     //* Get fetchmail details
M 849     public function mail_fetchmail_get($session_id, $primary_id)
b1a6a5 850     {
c1418f 851         global $app;
b1a6a5 852
c1418f 853         if(!$this->checkPerm($session_id, 'mail_fetchmail_get')) {
M 854             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
855             return false;
856         }
857         $app->uses('remoting_lib');
858         $app->remoting_lib->loadFormDef('../mail/form/mail_get.tform.php');
859         return $app->remoting_lib->getDataRecord($primary_id);
860     }
861
b1a6a5 862     //* fetchmail
c1418f 863     public function mail_fetchmail_add($session_id, $client_id, $params)
M 864     {
b1a6a5 865         if (!$this->checkPerm($session_id, 'mail_fetchmail_add'))
MC 866         {
867             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
868             return false;
869         }
870         $affected_rows = $this->insertQuery('../mail/form/mail_get.tform.php', $client_id, $params);
871         return $affected_rows;
c1418f 872     }
M 873
874
875     public function mail_fetchmail_update($session_id, $client_id, $primary_id, $params)
876     {
b1a6a5 877         if (!$this->checkPerm($session_id, 'mail_fetchmail_update'))
MC 878         {
879             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
880             return false;
881         }
882         $affected_rows = $this->updateQuery('../mail/form/mail_get.tform.php', $client_id, $primary_id, $params);
883         return $affected_rows;
c1418f 884     }
M 885
886
887     public function mail_fetchmail_delete($session_id, $primary_id)
888     {
b1a6a5 889         if (!$this->checkPerm($session_id, 'mail_fetchmail_delete'))
MC 890         {
891             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
892             return false;
893         }
894         $affected_rows = $this->deleteQuery('../mail/form/mail_get.tform.php', $primary_id);
895         return $affected_rows;
c1418f 896     }
b1a6a5 897
c1418f 898     //* Get whitelist details
M 899     public function mail_whitelist_get($session_id, $primary_id)
b1a6a5 900     {
c1418f 901         global $app;
b1a6a5 902
c1418f 903         if(!$this->checkPerm($session_id, 'mail_whitelist_get')) {
M 904             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
905             return false;
906         }
907         $app->uses('remoting_lib');
908         $app->remoting_lib->loadFormDef('../mail/form/mail_whitelist.tform.php');
909         return $app->remoting_lib->getDataRecord($primary_id);
910     }
b1a6a5 911
c1418f 912     //* wpisy biaƂej listy
M 913     public function mail_whitelist_add($session_id, $client_id, $params)
914     {
b1a6a5 915         if (!$this->checkPerm($session_id, 'mail_whitelist_add'))
MC 916         {
917             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
918             return false;
919         }
920         $affected_rows = $this->insertQuery('../mail/form/mail_whitelist.tform.php', $client_id, $params);
921         return $affected_rows;
c1418f 922     }
M 923
924
925     public function mail_whitelist_update($session_id, $client_id, $primary_id, $params)
926     {
b1a6a5 927         if (!$this->checkPerm($session_id, 'mail_whitelist_update'))
MC 928         {
929             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
930             return false;
931         }
932         $affected_rows = $this->updateQuery('../mail/form/mail_whitelist.tform.php', $client_id, $primary_id, $params);
933         return $affected_rows;
c1418f 934     }
M 935
936
937     public function mail_whitelist_delete($session_id, $primary_id)
938     {
b1a6a5 939         if (!$this->checkPerm($session_id, 'mail_whitelist_delete'))
MC 940         {
941             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
942             return false;
943         }
944         $affected_rows = $this->deleteQuery('../mail/form/mail_whitelist.tform.php', $primary_id);
945         return $affected_rows;
c1418f 946     }
b1a6a5 947
c1418f 948     //* Get Blacklist details
M 949     public function mail_blacklist_get($session_id, $primary_id)
b1a6a5 950     {
c1418f 951         global $app;
b1a6a5 952
c1418f 953         if(!$this->checkPerm($session_id, 'mail_blacklist_get')) {
M 954             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
955             return false;
956         }
957         $app->uses('remoting_lib');
958         $app->remoting_lib->loadFormDef('../mail/form/mail_blacklist.tform.php');
959         return $app->remoting_lib->getDataRecord($primary_id);
960     }
b1a6a5 961
c1418f 962     //* wpisy biaƂej listy
M 963     public function mail_blacklist_add($session_id, $client_id, $params)
964     {
b1a6a5 965         if (!$this->checkPerm($session_id, 'mail_blacklist_add'))
MC 966         {
967             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
968             return false;
969         }
970         $affected_rows = $this->insertQuery('../mail/form/mail_blacklist.tform.php', $client_id, $params);
971         return $affected_rows;
c1418f 972     }
M 973
974
975     public function mail_blacklist_update($session_id, $client_id, $primary_id, $params)
976     {
b1a6a5 977         if (!$this->checkPerm($session_id, 'mail_blacklist_update'))
MC 978         {
979             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
980             return false;
981         }
982         $affected_rows = $this->updateQuery('../mail/form/mail_blacklist.tform.php', $client_id, $primary_id, $params);
983         return $affected_rows;
c1418f 984     }
M 985
986
987     public function mail_blacklist_delete($session_id, $primary_id)
988     {
b1a6a5 989         if (!$this->checkPerm($session_id, 'mail_blacklist_delete'))
MC 990         {
991             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
992             return false;
993         }
994         $affected_rows = $this->deleteQuery('../mail/form/mail_blacklist.tform.php', $primary_id);
995         return $affected_rows;
c1418f 996     }
b1a6a5 997
c1418f 998     //* Get filter details
M 999     public function mail_filter_get($session_id, $primary_id)
b1a6a5 1000     {
c1418f 1001         global $app;
b1a6a5 1002
c1418f 1003         if(!$this->checkPerm($session_id, 'mail_filter_get')) {
M 1004             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1005             return false;
1006         }
1007         $app->uses('remoting_lib');
1008         $app->remoting_lib->loadFormDef('../mail/form/mail_content_filter.tform.php');
1009         return $app->remoting_lib->getDataRecord($primary_id);
1010     }
1011
1012     //* wpisy filtrow e-mail
1013     public function mail_filter_add($session_id, $client_id, $params)
1014     {
b1a6a5 1015         if (!$this->checkPerm($session_id, 'mail_filter_add'))
MC 1016         {
1017             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1018             return false;
1019         }
1020         $affected_rows = $this->insertQuery('../mail/form/mail_content_filter.tform.php', $client_id, $params);
1021         return $affected_rows;
c1418f 1022     }
M 1023
1024
1025     public function mail_filter_update($session_id, $client_id, $primary_id, $params)
1026     {
b1a6a5 1027         if (!$this->checkPerm($session_id, 'mail_filter_update'))
MC 1028         {
1029             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1030             return false;
1031         }
1032         $affected_rows = $this->updateQuery('../mail/form/mail_content_filter.tform.php', $client_id, $primary_id, $params);
1033         return $affected_rows;
c1418f 1034     }
M 1035
1036
1037     public function mail_filter_delete($session_id, $primary_id)
1038     {
b1a6a5 1039         if (!$this->checkPerm($session_id, 'mail_filter_delete'))
MC 1040         {
1041             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1042             return false;
1043         }
1044         $affected_rows = $this->deleteQuery('../mail/form/mail_content_filter.tform.php', $primary_id);
1045         return $affected_rows;
c1418f 1046     }
M 1047
b1a6a5 1048     /**
MC 1049      * Fetch the mail_domain record for the provided domain.
1050      * @param int session_id
1051      * @param string the fully qualified domain (or subdomain)
1052      * @return array array of arrays corresponding to the mail_domain table's records
1053      * @author till, benlake
1054      */
c1418f 1055
b1a6a5 1056
MC 1057     public function mail_domain_get_by_domain($session_id, $domain) {
1058         global $app;
1059         if(!$this->checkPerm($session_id, 'mail_domain_get_by_domain')) {
1060             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1061             return false;
1062         }
1063         if (!empty($domain)) {
cc7a82 1064             $sql            = "SELECT * FROM mail_domain WHERE domain = ?";
MC 1065             $result         = $app->db->queryAllRecords($sql, $domain);
b1a6a5 1066             return          $result;
MC 1067         }
1068         return false;
1069     }
1070
1071     public function mail_domain_set_status($session_id, $primary_id, $status) {
1072         global $app;
1073         if(!$this->checkPerm($session_id, 'mail_domain_set_status')) {
1074             throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1075             return false;
1076         }
1077         if(in_array($status, array('active', 'inactive'))) {
1078             if ($status == 'active') {
1079                 $status = 'y';
1080             } else {
1081                 $status = 'n';
1082             }
cc7a82 1083             $sql = "UPDATE mail_domain SET active = ? WHERE domain_id = ?";
MC 1084             $app->db->query($sql, $status, $primary_id);
b1a6a5 1085             $result = $app->db->affectedRows();
MC 1086             return $result;
1087         } else {
c1418f 1088             throw new SoapFault('status_undefined', 'The status is not available');
M 1089             return false;
b1a6a5 1090         }
MC 1091     }
1092
c7e231 1093     //** quota functions -----------------------------------------------------------------------------------
f1c4cd 1094     public function mailquota_get_by_user($session_id, $client_id)
c7e231 1095     {
DM 1096         global $app;
1097         $app->uses('quota_lib');
1098         
1099         if(!$this->checkPerm($session_id, 'mailquota_get_by_user')) {
1100             $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
1101             return false;
1102         }
1103         
f1c4cd 1104         return $app->quota_lib->get_mailquota_data($client_id, false);
c7e231 1105     }
c1418f 1106
M 1107 }
1108
b1a6a5 1109 ?>