sync
authorjohn <john@roojs.com>
Thu, 11 Oct 2018 06:22:53 +0000 (14:22 +0800)
committerjohn <john@roojs.com>
Thu, 11 Oct 2018 06:22:53 +0000 (14:22 +0800)
DataObjects/Core_setting.php

index 34936e5..a0eae02 100644 (file)
@@ -85,16 +85,17 @@ class Pman_Core_DataObjects_Core_setting extends DB_DataObject
             return;
         }
         
+        $this->initKeys();
+        
         $c = $this->lookup($a['module'], $a['name']);
-        if($c) {
-            return;
-        }
         
-        $this->initKeys();
+        $o = clone($c);
         
-        $s = DB_DataObject::factory('core_setting');
+        if(empty($c)) {
+            $c = DB_DataObject::factory('core_setting');
+        }
         
-        $s->setFrom(array(
+        $c->setFrom(array(
             'module'        =>     $a['module'],
             'name'          =>       $a['name'],
             'description'   => $a['description'],
@@ -104,7 +105,7 @@ class Pman_Core_DataObjects_Core_setting extends DB_DataObject
             'is_valid' => 1
         ));
         
-        $s->insert();
+        empty($o) ? $c->insert() : $c->update($o);
     }
     
     //one key for encrypting all the settings