瀏覽代碼

try to use database

andre 4 年之前
父節點
當前提交
0455407d76
共有 1 個文件被更改,包括 53 次插入36 次删除
  1. 53 36
      zimbraSingle.php

+ 53 - 36
zimbraSingle.php

@@ -792,41 +792,58 @@ function zimbraSingle_ServiceSingleSignOn($params) {
 }
 
 function zimbraSingle_AdminServicesTabFieldsSave($params) {
-    $addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0 ;
-    $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
-    $addonQuota = $addonQuota + $newAddQuota;
-    $newAddQuota = 0;
-    $addonQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
-        ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
-        ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
-        ->where('tblproductconfigoptions.optionname', 'like', 'addonQuota%')
-        ->select('tblhostingconfigoptions.id')
-        ->get();
-    if (isset($addonQuotaFieldIDObj[0]->id)) {
-        $addonQuotaFieldID = $addonQuotaFieldIDObj[0]->id;
-        logModuleCall(
-            'zimbrasingle',
-            __FUNCTION__,
-            'addonQuota gefunden',
-            'Debug',
-            $addonQuotaFieldID
-        );
-    };
-    $newAddQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
-        ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
-        ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
-        ->where('tblproductconfigoptions.optionname', 'like', 'newAddQuota%')
-        ->select('tblhostingconfigoptions.id')
-        ->get();
-    if (isset($newAddQuotaFieldIDObj[0]->id)) {
-        $newAddQuotaFieldID = $newAddQuotaFieldIDObj[0]->id;
-        logModuleCall(
-            'zimbrasingle',
-            __FUNCTION__,
-            'newAddQuota gefunden',
-            'Debug',
-            $newAddQuotaFieldID
-        );
-    };
+    if(isset($params['configoptions']['addonQuota'])) {
+        $addonQuota = $params['configoptions']['addonQuota'] ? $params['configoptions']['addonQuota'] : 0 ;
+        $newAddQuota = $params['configoptions']['newAddQuota'] ? $params['configoptions']['newAddQuota'] : 0;
+        $addonQuota = $addonQuota + $newAddQuota;
+        $addonQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
+            ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
+            ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
+            ->where('tblproductconfigoptions.optionname', 'like', 'addonQuota%')
+            ->select('tblhostingconfigoptions.id')
+            ->get();
+        try {
+            $updateAddonQuota = Capsule::table('tblhostingconfigoptions')
+                ->where('id', $addonQuotaFieldIDObj[0]->id)
+                ->update(
+                    [
+                        'qty' => $addonQuota,
+                    ]
+                );
+        } catch (\Exception $e) {
+            logModuleCall(
+                'zimbrasingle',
+                __FUNCTION__,
+                $updateAddonQuota,
+                'Error: konnte addonOuota nicht speichern.',
+                $e->getMessage()
+            );
+            return 'Error: konnte addonOuota nicht speichern.';
+        }
+        $newAddQuotaFieldIDObj = Capsule::table('tblproductconfigoptions')
+            ->join('tblhostingconfigoptions', 'tblproductconfigoptions.id', '=', 'tblhostingconfigoptions.configid')
+            ->where('tblhostingconfigoptions.relid', '=', $params['serviceid'])
+            ->where('tblproductconfigoptions.optionname', 'like', 'newAddQuota%')
+            ->select('tblhostingconfigoptions.id')
+            ->get();
+        try {
+            $updateNewAddQuota = Capsule::table('tblhostingconfigoptions')
+                ->where('id', $newAddQuotaFieldIDObj[0]->id)
+                ->update(
+                    [
+                        'qty' => '0',
+                    ]
+                );
+        } catch (\Exception $e) {
+            logModuleCall(
+                'zimbrasingle',
+                __FUNCTION__,
+                $updateNewAddQuota,
+                'Error: konnte newAddQuota nicht zurücksetzen.',
+                $e->getMessage()
+            );
+            return 'Error: konnte newAddQuota nicht zurücksetzen.';
+        }
+    }
     return 'success';
 }