Combu Server  3.1.1
PHP API Documentation
ServerSettings.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Combu;
4 
10 class ServerSettings extends DataClass {
11 
12  const TABLE_NAME = "ServerSettings";
13 
14  public $DataKey = "";
15  public $DataValue = "";
16  public $Visible = 0;
17 
21  public function __construct($src = null, $stripSlashes = false) {
22  if ($src == null)
23  return;
24  if (is_array($src)) {
25  // Load by array
26  $this->_loadByRow($src, $stripSlashes);
27  }
28  }
29 
35  public static function GetCurrentSettings(&$serverClientKeys) {
36  $serverClientKeys = array();
37  $settings = array();
38  $recs = self::Load();
39  foreach ($recs as $rec) {
40  $settings[$rec->DataKey] = $rec->DataValue;
41  if ($rec->Visible) {
42  $serverClientKeys[$rec->DataKey] = $rec->DataValue;
43  }
44  }
45  return $settings;
46  }
47 
53  public static function Load ($visible = FALSE) {
54  $where = "";
55  if ($visible) {
56  $where .= ($where ? " AND " : "") . "(Visible = 1)";
57  }
58  return self::_load(self::GetTableName(__CLASS__), __CLASS__, $where);
59  }
60 
66  public function Save() {
67  global $Database;
68  $query = sprintf("REPLACE INTO %s (DataKey, DataValue, Visible) VALUES ('%s', '%s', %d)",
69  self::GetTableName(__CLASS__),
70  $Database->Escape($this->DataKey),
71  $Database->Escape($this->DataValue),
72  $this->Visible);
73  return $Database->Query($query);
74  }
75 
81  public function Delete() {
82  global $Database;
83  if ($this->DataKey) {
84  return $this->_Delete(self::GetTableName(__CLASS__), sprintf("DataKey = '%s'", $Database->Escape($this->DataKey)));
85  }
86  return FALSE;
87  }
88 }
__construct($src=null, $stripSlashes=false)
static GetCurrentSettings(&$serverClientKeys)
Definition: Account.php:3
static Load($visible=FALSE)