aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/config
diff options
context:
space:
mode:
authorErik Frèrejean <erikfrerejean@phpbb.com>2011-01-24 15:13:15 +0100
committerErik Frèrejean <erikfrerejean@phpbb.com>2011-04-18 12:28:47 +0200
commit2f67ade05a426d41c95c146a86251d388c718b61 (patch)
treefc7d66ab15fe13018211169ded8e0c4c41afa13e /phpBB/includes/config
parent6dd0e40d02272fca63b2bc5b3fa727e7a70c5c86 (diff)
downloadforums-2f67ade05a426d41c95c146a86251d388c718b61.tar
forums-2f67ade05a426d41c95c146a86251d388c718b61.tar.gz
forums-2f67ade05a426d41c95c146a86251d388c718b61.tar.bz2
forums-2f67ade05a426d41c95c146a86251d388c718b61.tar.xz
forums-2f67ade05a426d41c95c146a86251d388c718b61.zip
[ticket/10006] Add phpbb_config::delete
Add the missing `phpbb_config::delete` method to the config class PHPBB3-10006
Diffstat (limited to 'phpBB/includes/config')
-rw-r--r--phpBB/includes/config/config.php20
-rw-r--r--phpBB/includes/config/db.php32
2 files changed, 52 insertions, 0 deletions
diff --git a/phpBB/includes/config/config.php b/phpBB/includes/config/config.php
index 64fef28cfa..9596b1e15b 100644
--- a/phpBB/includes/config/config.php
+++ b/phpBB/includes/config/config.php
@@ -104,6 +104,26 @@ class phpbb_config implements ArrayAccess, IteratorAggregate, Countable
}
/**
+ * Removes a configuration option
+ *
+ * @param String $key The configuration option's name
+ * @param bool $cache Whether this variable should be cached or if it
+ * changes too frequently to be efficiently cached
+ * @return bool True if the configuration entry was deleted successfully,
+ * otherwise false
+ */
+ public function delete($key, $cache = true)
+ {
+ if (!isset($this->config[$key]))
+ {
+ return false;
+ }
+
+ unset($this->config[$key]);
+ return true;
+ }
+
+ /**
* Sets a configuration option's value
*
* @param string $key The configuration option's name
diff --git a/phpBB/includes/config/db.php b/phpBB/includes/config/db.php
index 74fb0504ce..f0c9a5d591 100644
--- a/phpBB/includes/config/db.php
+++ b/phpBB/includes/config/db.php
@@ -91,6 +91,38 @@ class phpbb_config_db extends phpbb_config
}
/**
+ * Removes a configuration option
+ *
+ * @param String $key The configuration option's name
+ * @param bool $cache Whether this variable should be cached or if it
+ * changes too frequently to be efficiently cached
+ * @return bool True if the configuration entry was deleted successfully,
+ * otherwise false
+ */
+ public function delete($key, $cache = true)
+ {
+ if (!isset($this->config[$key]))
+ {
+ return false;
+ }
+
+ $sql = 'DELETE FROM ' . $this->table . "
+ WHERE config_name = '" . $this->db->sql_escape($key) . "'";
+ $this->db->sql_query($sql);
+ if (!$this->db->sql_affectedrows())
+ {
+ return false;
+ }
+
+ unset($this->config[$key]);
+
+ if ($cache)
+ {
+ $this->cache->destroy('config');
+ }
+ }
+
+ /**
* Sets a configuration option's value
*
* @param string $key The configuration option's name