1 | <?php declare(strict_types=1); defined('BASEPATH') or exit('No direct script access allowed'); |
||
3 | class User_Options_Model extends CI_Model { |
||
4 | public $options = array( |
||
5 | /** GENERAL OPTIONS **/ |
||
6 | 'category_custom_1' => array( |
||
7 | 'default' => 'disabled', |
||
8 | 'type' => 'int', |
||
9 | 'valid_options' => array( |
||
10 | 0 => 'disabled', |
||
11 | 1 => 'enabled' |
||
12 | ) |
||
13 | ), |
||
14 | 'category_custom_2' => array( |
||
15 | 'default' => 'disabled', |
||
16 | 'type' => 'int', |
||
17 | 'valid_options' => array( |
||
18 | 0 => 'disabled', |
||
19 | 1 => 'enabled' |
||
20 | ) |
||
21 | ), |
||
22 | 'category_custom_3' => array( |
||
23 | 'default' => 'disabled', |
||
24 | 'type' => 'int', |
||
25 | 'valid_options' => array( |
||
26 | 0 => 'disabled', |
||
27 | 1 => 'enabled' |
||
28 | ) |
||
29 | ), |
||
30 | 'category_custom_1_text' => array( |
||
31 | 'default' => 'Custom 1', |
||
32 | 'type' => 'string' |
||
33 | ), |
||
34 | 'category_custom_2_text' => array( |
||
35 | 'default' => 'Custom 2', |
||
36 | 'type' => 'string' |
||
37 | ), |
||
38 | 'category_custom_3_text' => array( |
||
39 | 'default' => 'Custom 3', |
||
40 | 'type' => 'string' |
||
41 | ), |
||
42 | |||
43 | 'enable_live_countdown_timer' => array( |
||
44 | 'default' => 'enabled', |
||
45 | 'type' => 'int', |
||
46 | 'valid_options' => array( |
||
47 | 0 => 'disabled', |
||
48 | 1 => 'enabled' |
||
49 | ) |
||
50 | ), |
||
51 | |||
52 | 'default_series_category' => array( |
||
53 | 'default' => 'reading', |
||
54 | 'type' => 'int', |
||
55 | 'valid_options' => array( |
||
56 | 0 => 'reading', |
||
57 | 1 => 'on-hold', |
||
58 | 2 => 'plan-to-read', |
||
59 | |||
60 | //FIXME: (MAJOR) This should only be enabled if the custom categories are enabled |
||
61 | // Problem is we can't easily check for this since the userscript uses it's own UserID, and not $this->User->id |
||
62 | 3 => 'custom1', |
||
63 | 4 => 'custom2', |
||
64 | 5 => 'custom3' |
||
65 | ) |
||
66 | ), |
||
67 | |||
68 | 'list_sort_type' => array( |
||
69 | 'default' => 'unread', |
||
70 | 'type' => 'int', |
||
71 | 'valid_options' => array( |
||
72 | 0 => 'unread', |
||
73 | 1 => 'alphabetical', |
||
74 | 2 => 'my_status', |
||
75 | 3 => 'latest', |
||
76 | 4 => 'unread_latest' |
||
77 | ) |
||
78 | ), |
||
79 | |||
80 | 'list_sort_order' => array( |
||
81 | 'default' => 'asc', |
||
82 | 'type' => 'int', |
||
83 | 'valid_options' => array( |
||
84 | 0 => 'asc', |
||
85 | 1 => 'desc' |
||
86 | ) |
||
87 | ), |
||
88 | |||
89 | 'theme' => array( |
||
90 | 'default' => 'light', |
||
91 | 'type' => 'int', |
||
92 | 'valid_options' => array( |
||
93 | 0 => 'light', |
||
94 | 1 => 'dark' |
||
95 | ) |
||
96 | ), |
||
97 | |||
98 | 'enable_public_list' => array( |
||
99 | 'default' => 'disabled', |
||
100 | 'type' => 'int', |
||
101 | 'valid_options' => array( |
||
102 | 0 => 'disabled', |
||
103 | 1 => 'enabled' |
||
104 | ) |
||
105 | ), |
||
106 | |||
107 | 'mal_sync' => array( |
||
108 | 'default' => 'disabled', |
||
109 | 'type' => 'int', |
||
110 | 'valid_options' => array( |
||
111 | 0 => 'disabled', |
||
112 | 1 => 'csrf', |
||
113 | 2 => 'api' |
||
114 | ) |
||
115 | ), |
||
116 | ); |
||
117 | |||
118 | 96 | public function __construct() { |
|
123 | |||
124 | /** |
||
125 | * Get user option, or default option if it does not exist. |
||
126 | * |
||
127 | * @param string $option |
||
128 | * @param int|null $userID |
||
129 | * |
||
130 | * @return mixed Returns option value as STRING, or FALSE if option does not exist. |
||
131 | */ |
||
132 | 96 | public function get(string $option, ?int $userID = NULL) { |
|
137 | |||
138 | /** |
||
139 | * @param string $option |
||
140 | * @param string|int $value |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function set(string $option, $value) : bool { |
||
163 | |||
164 | 96 | private function get_by_userid(string $option, int $userID) { |
|
186 | |||
187 | private function get_db(string $option, int $userID) { |
||
209 | |||
210 | private function parse_value(string $option, $value) { |
||
230 | |||
231 | //Used to quickly generate an array used with form_radio. |
||
232 | public function generate_radio_array(string $option, string $selected_option) { |
||
257 | |||
258 | public function getValidOptions(string $option) : array { |
||
261 | } |
||
262 |