]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Config.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / classes / Config.php
index 92f237d7f243d240fe12866489326d165dcab5ac..390d75381ac82fb74289a91fc6a77a011d875da0 100644 (file)
@@ -120,6 +120,35 @@ class Config extends Memcached_DataObject
         return $result;
     }
 
+    function &pkeyGet($kv)
+    {
+        return Memcached_DataObject::pkeyGet('Config', $kv);
+    }
+
+    static function save($section, $setting, $value)
+    {
+        $result = null;
+
+        $config = Config::pkeyGet(array('section' => $section,
+                                        'setting' => $setting));
+
+        if (!empty($config)) {
+            $orig = clone($config);
+            $config->value = $value;
+            $result = $config->update($orig);
+        } else {
+            $config = new Config();
+
+            $config->section = $section;
+            $config->setting = $setting;
+            $config->value   = $value;
+
+            $result = $config->insert();
+        }
+
+        return $result;
+    }
+
     function _blowSettingsCache()
     {
         $c = self::memcache();