Changeset 301:e653484b5650
- Timestamp:
- 05/20/11 08:57:29 (14 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.settings.php
r270 r301 308 308 } 309 309 310 /** 311 Returns a list of settings matching given criteria, for any blog. 312 <b>$params</b> is an array taking the following 313 optionnal parameters: 314 315 - ns : retrieve setting from given namespace 316 - id : retrieve only settings corresponding to the given id 317 318 @param params <b>array</b> Parameters 319 @return <b>record</b> A record 320 */ 321 public function getGlobalSettings($params=array()) 322 { 323 $strReq = "SELECT * from ".$this->table." "; 324 $where = array(); 325 if (!empty($params['ns'])) { 326 $where[] = "setting_ns = '".$this->con->escape($params['ns'])."'"; 327 } 328 if (!empty($params['id'])) { 329 $where[] = "setting_id = '".$this->con->escape($params['id'])."'"; 330 } 331 if (isset($params['blog_id'])) { 332 if (!empty($params['blog_id'])) { 333 $where[] = "blog_id = '".$this->con->escape($params['blog_id'])."'"; 334 } else { 335 $where[] = "blog_id IS NULL"; 336 } 337 } 338 if (count($where) != 0) { 339 $strReq .= " WHERE ".join(" AND ", $where); 340 } 341 $strReq .= " ORDER by blog_id"; 342 return $this->con->select($strReq); 343 } 344 345 /** 346 Updates a setting from a given record 347 348 @param rs <b>record</b> the setting to update 349 */ 350 public function updateSetting($rs) 351 { 352 $cur = $this->con->openCursor($this->table); 353 $cur->setting_id = $rs->setting_id; 354 $cur->setting_value = $rs->setting_value; 355 $cur->setting_type = $rs->setting_type; 356 $cur->setting_label = $rs->setting_label; 357 $cur->blog_id = $rs->blog_id; 358 $cur->setting_ns = $rs->setting_ns; 359 if ($cur->blog_id == null) { 360 $where = 'WHERE blog_id IS NULL '; 361 } else { 362 $where = "WHERE blog_id = '".$this->con->escape($cur->blog_id)."' "; 363 } 364 $cur->update($where."AND setting_id = '".$this->con->escape($cur->setting_id)."' AND setting_ns = '".$this->con->escape($cur->setting_ns)."' "); 365 } 366 367 /** 368 Drops a setting from a given record 369 370 @param rs <b>record</b> the setting to drop 371 @return int number of deleted records (0 if setting does not exist) 372 */ 373 public function dropSetting($rs) { 374 $strReq = "DELETE FROM ".$this->table.' '; 375 if ($rs->blog_id == null) { 376 $strReq .= 'WHERE blog_id IS NULL '; 377 } else { 378 $strReq .= "WHERE blog_id = '".$this->con->escape($rs->blog_id)."' "; 379 } 380 $strReq .= "AND setting_id = '".$this->con->escape($rs->setting_id)."' AND setting_ns = '".$this->con->escape($rs->setting_ns)."' "; 381 return $this->con->execute($strReq); 382 } 310 383 } 311 384 ?>
Note: See TracChangeset
for help on using the changeset viewer.