ocs  2.3.6
About: OCS (Open Conference System) is a Web publishing tool that will create a complete Web presence for your scholarly conference.
  Fossies Dox: ocs-2.3.6.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

SchedConfSettingsDAO.inc.php
Go to the documentation of this file.
1 <?php
2 
16 // $Id$
17 
18 
19 import('db.SettingsDAO');
21  function &_getCache($schedConfId) {
22  static $settingCache;
23 
24  if (!isset($settingCache)) {
25  $settingCache = array();
26  }
27  if (!isset($settingCache[$schedConfId])) {
28  $cacheManager =& CacheManager::getManager();
29  $settingCache[$schedConfId] = $cacheManager->getCache(
30  'schedConfSettings', $schedConfId,
31  array($this, '_cacheMiss')
32  );
33  }
34  return $settingCache[$schedConfId];
35  }
36 
44  function &getSetting($schedConfId, $name, $locale = null) {
45  $cache =& $this->_getCache($schedConfId);
46  $returner = $cache->get($name);
47  if ($locale !== null) {
48  if (!isset($returner[$locale]) || !is_array($returner)) {
49  unset($returner);
50  $returner = null;
51  return $returner;
52  }
53  return $returner[$locale];
54  }
55  return $returner;
56  }
57 
58  function _cacheMiss(&$cache, $id) {
59  $settings =& $this->getSchedConfSettings($cache->getCacheId());
60  if (!isset($settings[$id])) {
61  // Make sure that even null values are cached
62  $cache->setCache($id, null);
63  return null;
64  }
65  return $settings[$id];
66  }
67 
73  function &getSchedConfSettings($schedConfId) {
74  $schedConfSettings = array();
75 
76  $result =& $this->retrieve(
77  'SELECT setting_name, setting_value, setting_type, locale FROM sched_conf_settings WHERE sched_conf_id = ?', $schedConfId
78  );
79 
80  if ($result->RecordCount() == 0) {
81  $returner = null;
82  $result->Close();
83  return $returner;
84 
85  } else {
86  while (!$result->EOF) {
87  $row =& $result->getRowAssoc(false);
88  $value = $this->convertFromDB($row['setting_value'], $row['setting_type']);
89  if ($row['locale'] == '') $schedConfSettings[$row['setting_name']] = $value;
90  else $schedConfSettings[$row['setting_name']][$row['locale']] = $value;
91  $result->MoveNext();
92  }
93  $result->close();
94  unset($result);
95 
96  $cache =& $this->_getCache($schedConfId);
97  $cache->setEntireCache($schedConfSettings);
98 
99  return $schedConfSettings;
100  }
101  }
102 
111  function updateSetting($schedConfId, $name, $value, $type = null, $isLocalized = false) {
112  $cache =& $this->_getCache($schedConfId);
113  $cache->setCache($name, $value);
114 
115  $keyFields = array('setting_name', 'locale', 'sched_conf_id');
116 
117  if (!$isLocalized) {
118  $value = $this->convertToDB($value, $type);
119  $this->replace('sched_conf_settings',
120  array(
121  'sched_conf_id' => $schedConfId,
122  'setting_name' => $name,
123  'setting_value' => $value,
124  'setting_type' => $type,
125  'locale' => ''
126  ),
127  $keyFields
128  );
129  } else {
130  $this->update('DELETE FROM sched_conf_settings WHERE sched_conf_id = ? AND setting_name = ?', array($schedConfId, $name));
131  if (is_array($value)) foreach ($value as $locale => $localeValue) {
132  if (empty($localeValue)) continue;
133  $type = null;
134  $this->update('INSERT INTO sched_conf_settings
135  (sched_conf_id, setting_name, setting_value, setting_type, locale)
136  VALUES (?, ?, ?, ?, ?)',
137  array(
138  $schedConfId, $name, $this->convertToDB($localeValue, $type), $type, $locale
139  )
140  );
141  }
142  }
143  }
144 
151  function deleteSetting($schedConfId, $name, $locale = null) {
152  $cache =& $this->_getCache($schedConfId);
153  $cache->setCache($name, null);
154 
155  $params = array($schedConfId, $name);
156  $sql = 'DELETE FROM sched_conf_settings WHERE sched_conf_id = ? AND setting_name = ?';
157  if ($locale !== null) {
158  $params[] = $locale;
159  $sql .= ' AND locale = ?';
160  }
161  return $this->update($sql, $params);
162  }
163 
168  function deleteSettingsBySchedConf($schedConfId) {
169  $cache =& $this->_getCache($schedConfId);
170  $cache->flush();
171 
172  return $this->update(
173  'DELETE FROM sched_conf_settings WHERE sched_conf_id = ?', $schedConfId
174  );
175  }
176 }
177 
178 ?>
config TEMPLATE inc php
Definition: config.inc.php:4
& getSetting($schedConfId, $name, $locale=null)
& getSchedConfSettings($schedConfId)
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:62
updateSetting($schedConfId, $name, $value, $type=null, $isLocalized=false)
deleteSetting($schedConfId, $name, $locale=null)
convertFromDB($value, $type)
Definition: DAO.inc.php:296
Operations for retrieving and modifying scheduled conference settings.
convertToDB($value, &$type)
Definition: DAO.inc.php:352
Operations for retrieving and modifying settings.
replace($table, $arrFields, $keyCols)
Definition: DAO.inc.php:214
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:186