Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.Domain.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  * Mail Domain
9  *
10  * @author Anakeen 2000
11  * @version $Id: Class.Domain.php,v 1.6 2005/10/05 16:28:42 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.QueryDb.php');
21 include_once ('Class.Pop.php');
22 
23 class Domain extends DbObj
24 {
25 
26  var $Class = '$Id: Class.Domain.php,v 1.6 2005/10/05 16:28:42 eric Exp $';
27 
28  var $fields = array(
29  "iddomain",
30  "name",
31  "status",
32  "root",
33  "gentime",
34  "quotast",
35  "quota",
36  "quotaalert",
37  "quotatext",
38  "nobodymsg",
39  "nobodyalert",
40  "autoreplaymsg"
41  );
42 
43  var $id_fields = array(
44  "iddomain"
45  );
46 
47  var $dbtable = "domain";
48 
49  var $sqlcreate = "
50 create table domain(
51  iddomain int not null,
52  primary key (iddomain),
53  name varchar(100),
54  status int,
55  root varchar(255),
56  gentime int,
57  quotast int,
58  quota int,
59  quotaalert varchar(255),
60  quotatext varchar(255),
61  nobodymsg varchar(255),
62  nobodyalert varchar(255),
63  autoreplaymsg varchar(255)
64  );
65 create index domain_idx on domain(iddomain);
66 create sequence seq_iddomain start 10;
67 ";
68 
69  function PreInsert()
70  {
71  if ($this->exists($this->name)) return "Domain already exists";
72  if ($this->iddomain == "") {
73  $res = $this->exec_query("select nextval ('seq_iddomain')");
74  $arr = $this->fetch_array(0);
75  $this->iddomain = $arr["nextval"];
76  }
77  $this->name = strtolower($this->name);
78  $this->status = '1';
79  $this->log->info("Adding domain {$this->name} / {$this->iddomain}");
80  }
81 
82  function PreUpdate()
83  {
84  if ($this->status != 2) $this->log->info("Modifying domain {$this->name} / {$this->iddomain}");
85  $this->name = strtolower($this->name);
86  }
87 
88  function ListAll($local = 1)
89  {
90  $this->qcount = 0;
91  $this->qlist = NULL;
92  $query = new QueryDb($this->dbaccess, "Domain");
93  $query->basic_elem->sup_where = array(
94  "iddomain>{$local}",
95  "status != 2"
96  );
97  $this->qlist = $query->Query();
98  $this->qcount = $query->nb;
99  return;
100  }
101 
102  function MasterPopId()
103  {
104  $p = new Pop($this->dbaccess);
105  $pm = $p->GetMaster($this->iddomain);
106  return $pm->idpop;
107  }
108 
109  function Remove()
110  {
111  $this->status = '2';
112  $this->log->info("Deleting domain {$this->name} / {$this->iddomain}");
113  $this->Modify();
114  }
115 
116  function Set($name = NULL)
117  {
118  if ($name == NULL) return FALSE;
119  $query = new QueryDb($this->dbaccess, "Domain");
120  $query->basic_elem->sup_where[] = "name = '$name'";
121  $list = $query->Query(0, 0, "TABLE");
122  if ($query->nb > 0) {
123  $this->Affect($list[0]);
124  return TRUE;
125  } else {
126  $this->log->warning("No such domain {$query->string}");
127  return FALSE;
128  }
129  }
130 
131  function PostInit()
132  {
133  $this->iddomain = "0";
134  $this->name = "externe";
135  $this->Add();
136 
137  $this->iddomain = 1;
138  $this->name = "local";
139  $this->Add();
140  }
141 
142  function Created()
143  {
144  $this->status = '0';
145  $this->Modify();
146  }
147 
148  function SetGenTime($time)
149  {
150  $this->gentime = $time;
151  $this->update();
152  }
153 
154  function Exists($name)
155  {
156  $query = new QueryDb($this->dbaccess, "Domain");
157  $query->basic_elem->sup_where = array(
158  "name='$name'"
159  );
160  $list = $query->Query();
161  return ($query->nb > 0);
162  }
163 }
164 ?>
← centre documentaire © anakeen - published under CC License - Dynacase