Ticket #794: patch_settings_delete.diff
File patch_settings_delete.diff, 3.8 KB (added by zeiram, 16 years ago) |
---|
-
class.dc.namespace.php
diff -u core.orig/class.dc.namespace.php core/class.dc.namespace.php
old new 254 254 } 255 255 256 256 /** 257 Removes an existing setting. Namespace257 Removes an existing setting. 258 258 259 259 @param id <b>string</b> Setting ID 260 260 */ … … 279 279 } 280 280 281 281 /** 282 Deletes a setting (from both local and global settings). 283 284 @param id <b>string</b> Setting ID 285 @return <b>true</b> in case of success, <b>false</b> otherwise 286 */ 287 public function delete($id) 288 { 289 if (!$this->ns) { 290 throw new Exception(__('No namespace specified')); 291 } 292 293 if (!array_key_exists($id, $this->local_settings) && !array_key_exists($id, $this->global_settings)) { 294 return false; 295 } 296 297 // Remove the setting from all settings array 298 unset($this->settings[$id]); 299 unset($this->global_settings[$id]); 300 unset($this->local_settings[$id]); 301 302 // Delete setting from the the database 303 $strReq = 'DELETE FROM '.$this->table. 304 " WHERE setting_ns = '".$this->con->escape($this->ns)."' ". 305 " AND setting_id = '".$this->con->escape($id)."' "; 306 $this->con->execute($strReq); 307 return true; 308 } 309 310 /** 311 Renames a setting in the namespace. 312 313 @param oldId <b>string</b> Current setting name 314 @param newId <b>string</b> New settomg name 315 @return <b>true</b> in case of success, <b>false</b> otherwise 316 */ 317 public function rename($oldId, $newId) 318 { 319 if (!array_key_exists($oldId, $this->settings) or array_key_exists($newId, $this->settings)) { 320 return false; 321 } 322 323 // Rename the setting in the settings array 324 $this->settings[$newId] = $this->settings[$oldId]; 325 unset($this->settings[$oldId]); 326 327 // Rename the namespace in the database 328 $strReq = 'UPDATE '.$this->table. 329 " SET setting_id = '".$this->con->escape($newId)."' ". 330 " WHERE setting_ns = '".$this->con->escape($this->ns)."' ". 331 " AND setting_id = '".$this->con->escape($oldId)."' "; 332 $this->con->execute($strReq); 333 return true; 334 } 335 336 /** 282 337 Returns $settings property content. 283 338 284 339 @return <b>array</b> -
class.dc.settings.php
diff -u core.orig/class.dc.settings.php core/class.dc.settings.php
old new 128 128 } 129 129 130 130 /** 131 Deletes a whole namespace with all settings pertaining to it. 132 133 @param ns <b>string</b> Namespace name 134 @return <b>true</b> in case of success, <b>false</b> otherwise 135 */ 136 public function delete($ns) 137 { 138 if (!array_key_exists($ns, $this->namespaces)) { 139 return false; 140 } 141 142 // Remove the namespace from the namespaces array 143 unset($this->namespaces[$ns]); 144 145 // Delete all settings from the namespace in the database 146 $strReq = 'DELETE FROM '.$this->table. 147 " WHERE setting_ns = '".$this->con->escape($ns)."' "; 148 $this->con->execute($strReq); 149 return true; 150 } 151 152 /** 153 Renames a namespace. 154 155 @param oldNs <b>string</b> Current namespace name 156 @param newNs <b>string</b> New namespace name 157 @return <b>true</b> in case of success, <b>false</b> otherwise 158 */ 159 public function rename($oldNs, $newNs) 160 { 161 if (!array_key_exists($oldNs, $this->namespaces) or array_key_exists($newNs, $this->namespaces)) { 162 return false; 163 } 164 165 // Rename the namespace in the namespaces array 166 $this->namespaces[$newNs] = $this->namespace[$oldNs]; 167 unset($this->namespaces[$oldNs]); 168 169 // Rename the namespace in the database 170 $strReq = 'UPDATE '.$this->table. 171 " SET setting_ns = '".$this->con->escape($newNs)."' ". 172 " WHERE setting_ns = '".$this->con->escape($oldNs)."' "; 173 $this->con->execute($strReq); 174 return true; 175 } 176 177 /** 131 178 Raises a E_USER_NOTICE errror for deprecated functions. 132 179 This allows the developer to know he's been using deprecated functions. 133 180