Open Journal Systems  3.0.0
 All Classes Namespaces Functions Variables Groups Pages
DataObjectTombstoneSettingsDAO.inc.php
1 <?php
2 
24  function &getSetting($tombstoneId, $name, $locale = null) {
25  $sql = 'SELECT setting_value, setting_type FROM data_object_tombstone_settings WHERE tombstone_id = ? AND setting_name = ?';
26  $params = array((int) $tombstoneId, $name);
27  if ($locale !== null) {
28  $sql .= ' AND l.locale = ?';
29  $params[] = $locale;
30  }
31  $result = $this->retrieve($sql, $params);
32 
33  $setting = null;
34  while (!$result->EOF) {
35  $row = $result->getRowAssoc(false);
36  $value = $this->convertFromDB($row['setting_value'], $row['setting_type']);
37  if ($row['locale'] == '') $setting[$name] = $value;
38  else $setting[$name][$row['locale']] = $value;
39  $result->MoveNext();
40  }
41  $result->Close();
42  return $setting;
43  }
44 
54  function updateSetting($tombstoneId, $name, $value, $type = null, $isLocalized = false) {
55  $returner = null;
56 
57  $keyFields = array('tombstone_id', 'setting_name', 'locale');
58 
59  if (!$isLocalized) {
60  $value = $this->convertToDB($value, $type);
61  $this->replace('data_object_tombstone_settings',
62  array(
63  'tombstone_id' => $tombstoneId,
64  'setting_name' => $name,
65  'setting_value' => $value,
66  'setting_type' => $type,
67  'locale' => ''
68  ),
69  $keyFields
70  );
71  $returner = true;
72  } else {
73  if (is_array($value)) foreach ($value as $locale => $localeValue) {
74  $this->update('DELETE FROM data_object_tombstone_settings WHERE tombstone_id = ? AND setting_name = ? AND locale = ?', array((int) $tombstoneId, $name, $locale));
75  if (empty($localeValue)) continue;
76  $type = null;
77  $returner = $this->update('INSERT INTO data_object_tombstone_settings
78  (tombstone_id, setting_name, setting_value, setting_type, locale)
79  VALUES (?, ?, ?, ?, ?)',
80  array(
81  (int) $tombstoneId, $name, $this->convertToDB($localeValue, $type), $type, $locale
82  )
83  );
84  }
85  }
86  return $returner;
87  }
88 
95  function deleteSetting($tombstoneId, $name, $locale = null) {
96  $params = array((int) $tombstoneId, $name);
97  $sql = 'DELETE FROM data_object_tombstone_settings WHERE tombstone_id = ? AND setting_name = ?';
98  if ($locale !== null) {
99  $params[] = $locale;
100  $sql .= ' AND locale = ?';
101  }
102  return $this->update($sql, $params);
103  }
104 
109  function deleteSettings($tombstoneId) {
110  return $this->update(
111  'DELETE FROM data_object_tombstone_settings WHERE tombstone_id = ?', (int) $tombstoneId
112  );
113  }
114 }
115 
116 ?>
deleteSetting($tombstoneId, $name, $locale=null)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:30
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:84
convertFromDB($value, $type)
Definition: DAO.inc.php:335
updateSetting($tombstoneId, $name, $value, $type=null, $isLocalized=false)
convertToDB($value, &$type)
Definition: DAO.inc.php:391
replace($table, $arrFields, $keyCols)
Definition: DAO.inc.php:237
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:208
& getSetting($tombstoneId, $name, $locale=null)
Operations for retrieving and modifying submission tombstone settings.