|
12 | 12 |
|
13 | 13 | class ctwc_controller |
14 | 14 | { |
15 | | - protected object $db; |
16 | | - protected object $request; |
17 | | - protected object $user; |
18 | | - protected object $template; |
19 | | - protected object $language; |
20 | | - protected object $ctwc_helper; |
21 | | - protected object $ext_manager; |
22 | | - protected string $ctwc_data_table; |
23 | | - protected string $phpbb_root_path; |
24 | | - protected string $phpEx; |
25 | 15 | protected string $u_action; |
26 | 16 | protected string $modul; |
27 | 17 |
|
28 | | - /** |
29 | | - * Constructor |
30 | | - */ |
31 | 18 | public function __construct |
32 | 19 | ( |
33 | | - \phpbb\db\driver\driver_interface $db, |
34 | | - \phpbb\request\request $request, |
35 | | - \phpbb\user $user, |
36 | | - \phpbb\template\template $template, |
37 | | - \phpbb\language\language $language, |
38 | | - \imcger\currenttime\controller\ctwc_helper $ctwc_helper, |
39 | | - \phpbb\extension\manager $ext_manager, |
40 | | - $ctwc_data_table, |
41 | | - $phpbb_root_path, |
42 | | - $phpEx |
| 20 | + protected \phpbb\db\driver\driver_interface $db, |
| 21 | + protected \phpbb\request\request $request, |
| 22 | + protected \phpbb\user $user, |
| 23 | + protected \phpbb\template\template $template, |
| 24 | + protected \phpbb\language\language $language, |
| 25 | + protected \imcger\currenttime\controller\ctwc_helper $ctwc_helper, |
| 26 | + protected \phpbb\extension\manager $ext_manager, |
| 27 | + protected \phpbb\config\db_text $config_text, |
| 28 | + protected $phpbb_root_path, |
| 29 | + protected $phpEx, |
43 | 30 | ) |
44 | 31 | { |
45 | | - $this->db = $db; |
46 | | - $this->request = $request; |
47 | | - $this->user = $user; |
48 | | - $this->template = $template; |
49 | | - $this->language = $language; |
50 | | - $this->ctwc_helper = $ctwc_helper; |
51 | | - $this->ext_manager = $ext_manager; |
52 | | - $this->ctwc_data_table = $ctwc_data_table; |
53 | | - $this->phpbb_root_path = $phpbb_root_path; |
54 | | - $this->phpEx = $phpEx; |
55 | | - $this->modul = ''; |
| 32 | + $this->modul = ''; |
56 | 33 | } |
57 | 34 |
|
58 | 35 | /** |
@@ -90,28 +67,10 @@ public function display_options(string $modul): void |
90 | 67 | $user_setting[7] = $this->request->variable('ctwc_wclock_lines', 0); |
91 | 68 |
|
92 | 69 | $user_data_str = json_encode($user_setting, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
93 | | - $user_data_str = $this->db->sql_escape($user_data_str); |
94 | 70 |
|
95 | 71 | if ($this->modul == 'acp') |
96 | 72 | { |
97 | | - // save default data |
98 | | - $sql = 'SELECT data_content FROM ' . $this->ctwc_data_table . ' WHERE data_id = "default"'; |
99 | | - $result = $this->db->sql_query_limit($sql, 1); |
100 | | - |
101 | | - if ($this->db->sql_fetchrow($result)) |
102 | | - { |
103 | | - $sql = 'UPDATE ' . $this->ctwc_data_table . ' |
104 | | - SET data_content=\'' . $user_data_str . '\' |
105 | | - WHERE data_id = "default"'; |
106 | | - } |
107 | | - else |
108 | | - { |
109 | | - $sql = 'INSERT INTO ' . $this->ctwc_data_table . ' ' . |
110 | | - $this->db->sql_build_array('INSERT', ['data_id' => 'default', 'data_content' => $user_data_str]); |
111 | | - } |
112 | | - $this->db->sql_freeresult($result); |
113 | | - |
114 | | - $this->db->sql_query($sql); |
| 73 | + $this->config_text->set(\imcger\currenttime\ext::CTWC_DATA, $user_data_str); |
115 | 74 |
|
116 | 75 | // overwrite settings for all user |
117 | 76 | if ($this->request->variable('ctwc_reset_default', 0)) |
@@ -150,11 +109,8 @@ protected function set_template_vars(?array $user_setting = null): void |
150 | 109 | { |
151 | 110 | if (!isset($user_setting) && $this->modul == 'acp') |
152 | 111 | { |
153 | | - $sql = 'SELECT data_content FROM ' . $this->ctwc_data_table . ' WHERE data_id = "default"'; |
154 | | - $result = $this->db->sql_query_limit($sql, 1); |
155 | | - |
156 | | - $user_setting = json_decode((string) $this->db->sql_fetchfield('data_content'), true); |
157 | | - $this->db->sql_freeresult($result); |
| 112 | + $ctwc_data = $this->config_text->get(\imcger\currenttime\ext::CTWC_DATA); |
| 113 | + $user_setting = json_decode($ctwc_data); |
158 | 114 | } |
159 | 115 | else if (!isset($user_setting) && $this->modul == 'ucp') |
160 | 116 | { |
|
0 commit comments