Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.Pop.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  * Pop Server Mail
9  *
10  * @author Anakeen 2000
11  * @version $Id: Class.Pop.php,v 1.4 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 //
20 // ---------------------------------------------------------------------------
21 include_once ('Class.DbObj.php');
22 
23 class Pop extends DbObj
24 {
25 
26  var $Class = '$Id: Class.Pop.php,v 1.4 2005/10/05 16:28:42 eric Exp $';
27 
28  var $fields = array(
29  "idpop",
30  "iddomain",
31  "popname",
32  "master"
33  );
34 
35  var $id_fields = array(
36  "idpop"
37  );
38 
39  var $dbtable = 'pop';
40 
41  var $sqlcreate = "
42 create table pop(
43  idpop int not null,
44  primary key (idpop),
45  iddomain int not null,
46  popname varchar(100),
47  master varchar(1) );
48 create index pop_idx on pop(popname);
49 create sequence seq_idpop start 10;
50 grant all on seq_idpop to anakeen;
51 ";
52 
53  function PreInsert()
54  {
55  $res = $this->exec_query("select nextval ('seq_idpop')");
56  $arr = $this->fetch_array(0);
57  $this->idpop = $arr["nextval"];
58  $this->popname = strtolower($this->popname);
59  $this->log->info("Adding pop name : {$this->popname} master={$this->master} domaid id = {$this->iddomain}");
60  }
61 
62  function PreUpdate()
63  {
64  $this->popname = strtolower($this->popname);
65  }
66 
67  function GetMaster($dom)
68  {
69  $query = new QueryDb($this->dbaccess, "Pop");
70  $query->basic_elem->sup_where = array(
71  "iddomain={$dom}",
72  "master='Y'"
73  );
74  $list = $query->Query();
75  return $list[0];
76  }
77 
78  function GetSlaves($dom = - 1)
79  {
80  $query = new QueryDb($this->dbaccess, "Pop");
81  if ($dom != - 1) $query->basic_elem->sup_where = array(
82  "iddomain={$dom}",
83  "master='N'"
84  );
85  $list = $query->Query();
86  return $list;
87  }
88 
89  function GetAll($dom = - 1)
90  {
91  $query = new QueryDb($this->dbaccess, "Pop");
92  if ($dom != - 1) $query->basic_elem->sup_where = array(
93  "iddomain={$dom}"
94  );
95  $list = $query->Query();
96  return $list;
97  }
98 
99  function Set($name = NULL, $id = NULL)
100  {
101  if ($name == NULL && $id == NULL) return FALSE;
102  $query = new QueryDb($this->dbaccess, "Pop");
103  if ($name != NULL) {
104  $query->basic_elem->sup_where = array(
105  "popname = '$name'"
106  );
107  } else {
108  $query->basic_elem->sup_where = array(
109  "idpop = $id"
110  );
111  }
112  $list = $query->Query(0, 0, "TABLE");
113  if ($query->nb > 0) {
114  $this->Affect($list[0]);
115  return TRUE;
116  } else {
117  $this->log->warning("No such pop host {$query->string}");
118  return FALSE;
119  }
120  }
121 }
122 ?>
← centre documentaire © anakeen - published under CC License - Dynacase