Open Journal Systems  2.4.4
 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, locale FROM data_object_tombstone_settings WHERE tombstone_id = ? AND setting_name = ?';
26  $params = array((int) $tombstoneId, $name);
27  if ($locale !== null) {
28  $sql .= ' AND 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  unset($result);
43 
44  return $setting;
45  }
46 
56  function updateSetting($tombstoneId, $name, $value, $type = null, $isLocalized = false) {
57  $returner = null;
58 
59  $keyFields = array('tombstone_id', 'setting_name', 'locale');
60 
61  if (!$isLocalized) {
62  $value = $this->convertToDB($value, $type);
63  $this->replace('data_object_tombstone_settings',
64  array(
65  'tombstone_id' => $tombstoneId,
66  'setting_name' => $name,
67  'setting_value' => $value,
68  'setting_type' => $type,
69  'locale' => ''
70  ),
71  $keyFields
72  );
73  $returner = true;
74  } else {
75  if (is_array($value)) foreach ($value as $locale => $localeValue) {
76  $this->update('DELETE FROM data_object_tombstone_settings WHERE tombstone_id = ? AND setting_name = ? AND locale = ?', array((int) $tombstone_id, $name, $locale));
77  if (empty($localeValue)) continue;
78  $type = null;
79  $returner = $this->update('INSERT INTO data_object_tombstone_settings
80  (tombstone_id, setting_name, setting_value, setting_type, locale)
81  VALUES (?, ?, ?, ?, ?)',
82  array(
83  (int) $tombstoneId, $name, $this->convertToDB($localeValue, $type), $type, $locale
84  )
85  );
86  }
87  }
88  return $returner;
89  }
90 
97  function deleteSetting($tombstoneId, $name, $locale = null) {
98  $params = array((int) $tombstoneId, $name);
99  $sql = 'DELETE FROM data_object_tombstone_settings WHERE tombstone_id = ? AND setting_name = ?';
100  if ($locale !== null) {
101  $params[] = $locale;
102  $sql .= ' AND locale = ?';
103  }
104  return $this->update($sql, $params);
105  }
106 
111  function deleteSettings($tombstoneId) {
112  return $this->update(
113  'DELETE FROM data_object_tombstone_settings WHERE tombstone_id = ?', (int) $tombstoneId
114  );
115  }
116 }
117 
118 ?>
deleteSetting($tombstoneId, $name, $locale=null)
Operations for retrieving and modifying objects from a database.
Definition: DAO.inc.php:29
& retrieve($sql, $params=false, $callHooks=true)
Definition: DAO.inc.php:83
convertFromDB($value, $type)
Definition: DAO.inc.php:338
updateSetting($tombstoneId, $name, $value, $type=null, $isLocalized=false)
convertToDB($value, &$type)
Definition: DAO.inc.php:394
replace($table, $arrFields, $keyCols)
Definition: DAO.inc.php:240
update($sql, $params=false, $callHooks=true, $dieOnError=true)
Definition: DAO.inc.php:211
& getSetting($tombstoneId, $name, $locale=null)
Operations for retrieving and modifying submission tombstone settings.