| @@ -16,31 +16,8 @@ | ||
| 16 | 16 | static::$_emailTemplateModel = new EmailTemplateModel(); |
| 17 | 17 | $this->_user_details = $user_details; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - /** | |
| 21 | - * Decode a stored template `config` column into the object shape the admin editor expects. | |
| 22 | - * | |
| 23 | - * Older versions could persist an empty config as `[]`; decoded, that reaches the React editor | |
| 24 | - * as a JS array and setting a key on it throws inside the immutable-draft library. Anything that | |
| 25 | - * is not a non-empty object collapses to `{}`. | |
| 26 | - * | |
| 27 | - * @param mixed $config raw column value (JSON string, already-decoded value, or null) | |
| 28 | - * | |
| 29 | - * @return object | |
| 30 | - */ | |
| 31 | - public static function normalizeConfig($config) | |
| 32 | - { | |
| 33 | - if (is_string($config)) { | |
| 34 | - $config = json_decode($config); | |
| 35 | - } | |
| 36 | - if (is_array($config)) { | |
| 37 | - $config = (object) $config; | |
| 38 | - } | |
| 39 | - | |
| 40 | - return is_object($config) ? $config : (object) []; | |
| 41 | - } | |
| 42 | - | |
| 43 | 20 | public function getAllTemplate($templateID = null, $userID = null) |
| 44 | 21 | { |
| 45 | 22 | $condition = [ |
| 46 | 23 | 'form_id' => static::$_formID, |
| @@ -55,11 +32,9 @@ | ||
| 55 | 32 | [ |
| 56 | 33 | 'id', |
| 57 | 34 | 'title', |
| 58 | 35 | 'sub', |
| 59 | - 'body', | |
| 60 | - 'status', | |
| 61 | - 'config' | |
| 36 | + 'body' | |
| 62 | 37 | ], |
| 63 | 38 | $condition |
| 64 | 39 | ); |
| 65 | 40 | } |
| @@ -75,10 +50,8 @@ | ||
| 75 | 50 | [ |
| 76 | 51 | 'title' => $templateDetail->title, |
| 77 | 52 | 'sub' => $templateDetail->sub, |
| 78 | 53 | 'body' => $templateDetail->body, |
| 79 | - 'status' => isset($templateDetail->status) ? (int) $templateDetail->status : 1, | |
| 80 | - 'config' => isset($templateDetail->config) ? wp_json_encode($templateDetail->config) : null, | |
| 81 | 54 | 'form_id' => static::$_formID, |
| 82 | 55 | 'user_id' => $this->_user_details['id'], |
| 83 | 56 | 'user_ip' => $this->_user_details['ip'], |
| 84 | 57 | 'created_at'=> $this->_user_details['time'], |
| @@ -93,10 +66,8 @@ | ||
| 93 | 66 | [ |
| 94 | 67 | 'title' => $templateDetail->title, |
| 95 | 68 | 'sub' => $templateDetail->sub, |
| 96 | 69 | 'body' => $templateDetail->body, |
| 97 | - 'status' => isset($templateDetail->status) ? (int) $templateDetail->status : 1, | |
| 98 | - 'config' => isset($templateDetail->config) ? wp_json_encode($templateDetail->config) : null, | |
| 99 | 70 | 'form_id' => static::$_formID, |
| 100 | 71 | 'user_id' => $this->_user_details['id'], |
| 101 | 72 | 'user_ip' => $this->_user_details['ip'], |
| 102 | 73 | 'updated_at'=> $this->_user_details['time'] |