Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.MailAccount.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: Class.MailAccount.php,v 1.6 2006/01/27 07:49:38 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage CORE
15  */
16 /**
17  */
18 
19 include_once ('Class.DbObj.php');
20 include_once ('Class.Domain.php');
21 include_once ('Class.MailAlias.php');
22 
23 class MailAccount extends DbObj
24 {
25  var $Class = '$Id: Class.MailAccount.php,v 1.6 2006/01/27 07:49:38 eric Exp $';
26 
27  var $fields = array(
28  "iddomain",
29  "iduser",
30  "login",
31  "pop",
32  "vacst",
33  "vacmsg",
34  "fwdst",
35  "fwdadd",
36  "type",
37  "keepfwd",
38  "uptime",
39  "remove",
40  "quota",
41  "filterspam"
42  );
43 
44  var $id_fields = array(
45  "iduser"
46  );
47 
48  var $dbtable = "mailaccount";
49 
50  var $sqlcreate = "
51 create table mailaccount(
52  iddomain int not null,
53  iduser int not null,
54  primary key (iduser),
55  login varchar(100),
56  pop varchar(100),
57  vacst int,
58  vacmsg text,
59  fwdst int,
60  fwdadd varchar(300),
61  type int,
62  keepfwd int,
63  uptime int,
64  remove int,
65  quota int,
66  filterspam int );
67 create index mailaccount_idx on mailaccount(iduser);
68 ";
69 
70  function setdef(&$v, $d)
71  {
72  if (!isset($v) || $v == "") $v = $d;
73  }
74 
75  function PreInsert()
76  {
77  if (!isset($this->pop) || $this->pop == "" || $this->pop == 0) {
78  $this->log->Debug("PreInsert for dom={$this->iddomain} iduser={$this->iduser}");
79  $dom = new Domain($this->dbaccess, $this->iddomain);
80  $this->pop = $dom->MasterPopId($this->dbaccess);
81  }
82  $this->setdef($this->quota, '0');
83  $this->setdef($this->vacst, '0');
84  $this->setdef($this->vacmsg, "");
85  $this->setdef($this->fwdst, '0');
86  $this->setdef($this->fwdadd, "");
87  $this->setdef($this->keepfwd, '1');
88  $this->setdef($this->filterspam, '0');
89  $this->uptime = time();
90  $this->type = '0';
91  $this->remove = '0';
92  }
93 
94  function PreUpdate()
95  {
96  $this->uptime = time();
97  }
98 
99  function Remove()
100  {
101  $q = new QueryDb($this->dbaccess, "MailAlias");
102  $q->basic_elem->sup_where = array(
103  "iddomain={$this->iddomain}",
104  "iduser={$this->iduser}"
105  );
106  $l = $q->Query();
107  if ($q->nb > 0) {
108  while (list($k, $v) = each($l)) {
109  $a = new MailAlias();
110  $a->Set($v->iddomain, $v->iduser);
111  $a->Delete();
112  }
113  }
114  $this->uptime = time();
115  $this->remove = '1';
116  $this->Modify();
117  }
118 
119  function PostInsert()
120  {
121  //$adm = new MailAdmin($this->db, $this->iddomain);
122  //$adm->Gen();
123 
124  }
125 
126  function PostUpdate()
127  {
128  $this->PostInsert();
129  }
130 
131  function ListAccount($dom = 0, $admacc = 'N')
132  {
133  $this->qcount = 0;
134  $this->qlist = 0;
135  if ($dom != 0) {
136  $q = new QueryDb($this->dbaccess, "MailAccount");
137  if ($admacc != 'Y') $q->basic_elem->sup_where = array(
138  "iddomain={$dom}",
139  "type='{$admacc}'",
140  "remove=0"
141  );
142  else $q->basic_elem->sup_where = array(
143  "iddomain={$dom}",
144  "remove=0"
145  );
146  $this->qlist = $q->Query();
147  $this->qcount = $q->nb;
148  }
149  return;
150  }
151 
152  function ListAlias()
153  {
154  $q = new QueryDb($this->dbaccess, "MailAlias");
155  $q->basic_elem->sup_where = array(
156  "iddomain={$this->iddomain}",
157  "iduser={$this->iduser}",
158  "type=0",
159  "remove=0"
160  );
161  $a = $q->Query();
162  return $a;
163  }
164 
165  function CheckUptime($domain, $time)
166  {
167  $q = new QueryDb($this->dbaccess, "MailAccount");
168  $q->basic_elem->sup_where = array(
169  "iddomain={$domain->iddomain}",
170  "uptime>$time"
171  );
172  $l = $q->Query();
173  return ($q->nb > 0);
174  }
175 } // End Class
176 
177 ?>
← centre documentaire © anakeen - published under CC License - Dynacase