Merge "Revert "Show a "(blocked)" hint on Special:ListUsers/ActiveUsers""
[lhc/web/wiklou.git] / includes / conf / DatabaseConf.php
1 <?php
2 /**
3 * Database configuration class
4 *
5 * Copyright © 2011 Chad Horohoe <chadh@wikimedia.org>
6 * http://www.mediawiki.org/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
22 *
23 * @file
24 * @ingroup Config
25 */
26 class DatabaseConf extends Conf {
27 /**
28 * @see Conf::initChangedSettings()
29 */
30 protected function initChangedSettings() {
31 $res = wfGetDB( DB_MASTER )->select( 'config', '*', array(), __METHOD__ );
32 foreach( $res as $row ) {
33 $this->values[$row->cf_name] = unserialize( $row->cf_value );
34 }
35 }
36
37 /**
38 * @see Conf::writeSetting()
39 *
40 * @param $name
41 * @param $value
42 *
43 * @return bool
44 */
45 protected function writeSetting( $name, $value ) {
46 $dbw = wfGetDB( DB_MASTER );
47 $value = serialize( $value );
48 if( $dbw->selectRow( 'config', 'cf_name', array( 'cf_name' => $name ), __METHOD__ ) ) {
49 $dbw->update( 'config', array( 'cf_value' => $value ),
50 array( 'cf_name' => $name ), __METHOD__ );
51 } else {
52 $dbw->insert( 'config',
53 array( 'cf_name' => $name, 'cf_value' => $value ), __METHOD__ );
54 }
55 return (bool)$dbw->affectedRows();
56 }
57 }