@@ -44,27 +44,45 @@ discard block |
||
44 | 44 | |
45 | 45 | # Validate values |
46 | 46 | |
47 | - if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
47 | + if (false === ($name = Validate::userName($name))) { |
|
48 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
49 | + } |
|
48 | 50 | |
49 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
51 | + if (false === ($password = Validate::userPassword($password))) { |
|
52 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
53 | + } |
|
50 | 54 | |
51 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
55 | + if (false === ($email = Validate::userEmail($email))) { |
|
56 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
57 | + } |
|
52 | 58 | |
53 | - if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
59 | + if (0 !== strcmp($password, $password_retype)) { |
|
60 | + return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
61 | + } |
|
54 | 62 | |
55 | - if (false === Security::checkCaptcha($captcha)) return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
63 | + if (false === Security::checkCaptcha($captcha)) { |
|
64 | + return ['captcha', 'USER_ERROR_CAPTCHA_INCORRECT']; |
|
65 | + } |
|
56 | 66 | |
57 | 67 | # Check name exists |
58 | 68 | |
59 | - if (false === ($check_name = $this->user->check($name, 'name'))) return 'USER_ERROR_AUTH_REGISTER'; |
|
69 | + if (false === ($check_name = $this->user->check($name, 'name'))) { |
|
70 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
71 | + } |
|
60 | 72 | |
61 | - if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
73 | + if ($check_name === 1) { |
|
74 | + return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
75 | + } |
|
62 | 76 | |
63 | 77 | # Check email exists |
64 | 78 | |
65 | - if (false === ($check_email = $this->user->check($email, 'email'))) return 'USER_ERROR_AUTH_REGISTER'; |
|
79 | + if (false === ($check_email = $this->user->check($email, 'email'))) { |
|
80 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
81 | + } |
|
66 | 82 | |
67 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
83 | + if ($check_email === 1) { |
|
84 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
85 | + } |
|
68 | 86 | |
69 | 87 | # Encode password |
70 | 88 | |
@@ -87,7 +105,9 @@ discard block |
||
87 | 105 | $data['time_registered'] = REQUEST_TIME; |
88 | 106 | $data['time_logged'] = REQUEST_TIME; |
89 | 107 | |
90 | - if (!$this->user->create($data)) return 'USER_ERROR_AUTH_REGISTER'; |
|
108 | + if (!$this->user->create($data)) { |
|
109 | + return 'USER_ERROR_AUTH_REGISTER'; |
|
110 | + } |
|
91 | 111 | |
92 | 112 | # Send mail |
93 | 113 |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | protected function init() { |
14 | 14 | |
15 | - $this->config->addParam('active', '', function (bool $active) { |
|
15 | + $this->config->addParam('active', '', function(bool $active) { |
|
16 | 16 | |
17 | 17 | return ($active ? "ent.active = 1" : ''); |
18 | 18 | }); |
@@ -38,7 +38,9 @@ |
||
38 | 38 | |
39 | 39 | # Set remove button |
40 | 40 | |
41 | - if ($user->id === Auth::get('id')) $view->getBlock('remove')->class = 'disabled'; |
|
41 | + if ($user->id === Auth::get('id')) { |
|
42 | + $view->getBlock('remove')->class = 'disabled'; |
|
43 | + } |
|
42 | 44 | } |
43 | 45 | } |
44 | 46 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | |
79 | 79 | # Set link |
80 | 80 | |
81 | - $link = (INSTALL_PATH . static::$link . '/'); |
|
81 | + $link = (INSTALL_PATH.static::$link.'/'); |
|
82 | 82 | |
83 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
83 | + if (static::$nesting) $contents->link = ($link.($this->create ? 'create' : 'edit').'?id='.$this->parent->id); |
|
84 | 84 | |
85 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
85 | + else $contents->link = ($link.($this->create ? 'create' : ('edit?id='.$this->entity->id))); |
|
86 | 86 | |
87 | 87 | # Process selector block |
88 | 88 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | |
144 | 144 | $this->entity = Entitizer::get(static::$table, (!$this->create ? $id : 0)); |
145 | 145 | |
146 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
146 | + if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH.static::$link); |
|
147 | 147 | |
148 | 148 | # Create parent entity |
149 | 149 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | |
164 | 164 | if ($this->create && (0 !== $this->parent->id)) $this->entity->move($this->parent->id); |
165 | 165 | |
166 | - Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted'); |
|
166 | + Request::redirect(INSTALL_PATH.static::$link.'/edit?id='.$this->entity->id.'&submitted'); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | # Display success message |
@@ -56,7 +56,9 @@ discard block |
||
56 | 56 | |
57 | 57 | private function processSelector(Template\Block $selector) { |
58 | 58 | |
59 | - if ($this->create) return $selector->disable(); |
|
59 | + if ($this->create) { |
|
60 | + return $selector->disable(); |
|
61 | + } |
|
60 | 62 | |
61 | 63 | $selector->parent_id = $this->entity->parent_id; |
62 | 64 | |
@@ -81,25 +83,33 @@ discard block |
||
81 | 83 | |
82 | 84 | # Set path / title |
83 | 85 | |
84 | - if (static::$nesting) $contents->path = $this->path; |
|
85 | - |
|
86 | - else $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming)); |
|
86 | + if (static::$nesting) { |
|
87 | + $contents->path = $this->path; |
|
88 | + } else { |
|
89 | + $contents->title = ($this->create ? Language::get(static::$naming_new) : $this->entity->get(static::$naming)); |
|
90 | + } |
|
87 | 91 | |
88 | 92 | # Process parent block |
89 | 93 | |
90 | - if (static::$nesting) $this->processParent($contents->getBlock('parent')); |
|
94 | + if (static::$nesting) { |
|
95 | + $this->processParent($contents->getBlock('parent')); |
|
96 | + } |
|
91 | 97 | |
92 | 98 | # Set link |
93 | 99 | |
94 | 100 | $link = (INSTALL_PATH . static::$link . '/'); |
95 | 101 | |
96 | - if (static::$nesting) $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
97 | - |
|
98 | - else $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
102 | + if (static::$nesting) { |
|
103 | + $contents->link = ($link . ($this->create ? 'create' : 'edit') . '?id=' . $this->parent->id); |
|
104 | + } else { |
|
105 | + $contents->link = ($link . ($this->create ? 'create' : ('edit?id=' . $this->entity->id))); |
|
106 | + } |
|
99 | 107 | |
100 | 108 | # Process selector block |
101 | 109 | |
102 | - if (static::$nesting) $this->processSelector($contents->getBlock('selector')); |
|
110 | + if (static::$nesting) { |
|
111 | + $this->processSelector($contents->getBlock('selector')); |
|
112 | + } |
|
103 | 113 | |
104 | 114 | # Implement form |
105 | 115 | |
@@ -134,11 +144,15 @@ discard block |
||
134 | 144 | |
135 | 145 | $parent_id = Number::forceInt(Request::post('parent_id')); |
136 | 146 | |
137 | - if (!$this->entity->move($parent_id)) return $ajax->setError(Language::get(static::$message_error_move)); |
|
147 | + if (!$this->entity->move($parent_id)) { |
|
148 | + return $ajax->setError(Language::get(static::$message_error_move)); |
|
149 | + } |
|
138 | 150 | |
139 | 151 | } else if (Request::post('action') === 'remove') { |
140 | 152 | |
141 | - if (!$this->entity->remove()) return $ajax->setError(Language::get(static::$message_error_remove)); |
|
153 | + if (!$this->entity->remove()) { |
|
154 | + return $ajax->setError(Language::get(static::$message_error_remove)); |
|
155 | + } |
|
142 | 156 | } |
143 | 157 | |
144 | 158 | # ------------------------ |
@@ -154,7 +168,9 @@ discard block |
||
154 | 168 | |
155 | 169 | protected function handle(bool $ajax = false) { |
156 | 170 | |
157 | - if (!$this->create && $ajax) return $this->handleAjax(); |
|
171 | + if (!$this->create && $ajax) { |
|
172 | + return $this->handleAjax(); |
|
173 | + } |
|
158 | 174 | |
159 | 175 | # Create entity |
160 | 176 | |
@@ -162,7 +178,9 @@ discard block |
||
162 | 178 | |
163 | 179 | $this->entity = Entitizer::get(static::$table, (!$this->create ? $id : 0)); |
164 | 180 | |
165 | - if (!$this->create && (0 === $this->entity->id)) return Request::redirect(INSTALL_PATH . static::$link); |
|
181 | + if (!$this->create && (0 === $this->entity->id)) { |
|
182 | + return Request::redirect(INSTALL_PATH . static::$link); |
|
183 | + } |
|
166 | 184 | |
167 | 185 | # Create parent entity |
168 | 186 | |
@@ -170,7 +188,9 @@ discard block |
||
170 | 188 | |
171 | 189 | # Get path |
172 | 190 | |
173 | - if (false !== ($path = $this->parent->getPath())) $this->path = $path; |
|
191 | + if (false !== ($path = $this->parent->getPath())) { |
|
192 | + $this->path = $path; |
|
193 | + } |
|
174 | 194 | |
175 | 195 | # Create form |
176 | 196 | |
@@ -180,7 +200,9 @@ discard block |
||
180 | 200 | |
181 | 201 | if ($this->form->handle(new static::$controller_class($this->entity), true)) { |
182 | 202 | |
183 | - if ($this->create && (0 !== $this->parent->id)) $this->entity->move($this->parent->id); |
|
203 | + if ($this->create && (0 !== $this->parent->id)) { |
|
204 | + $this->entity->move($this->parent->id); |
|
205 | + } |
|
184 | 206 | |
185 | 207 | Request::redirect(INSTALL_PATH . static::$link . '/edit?id=' . $this->entity->id . '&submitted'); |
186 | 208 | } |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | |
28 | 28 | $query = ("DELETE rla FROM " . static::$table_relations . " rla ") . |
29 | 29 | |
30 | - ("JOIN " . static::$table_relations . " rlb ON rlb.descendant = rla.descendant ") . |
|
30 | + ("JOIN " . static::$table_relations . " rlb ON rlb.descendant = rla.descendant ") . |
|
31 | 31 | |
32 | - ("LEFT JOIN " . static::$table_relations . " rlx ") . |
|
32 | + ("LEFT JOIN " . static::$table_relations . " rlx ") . |
|
33 | 33 | |
34 | - ("ON rlx.ancestor = rlb.ancestor AND rlx.descendant = rla.ancestor ") . |
|
34 | + ("ON rlx.ancestor = rlb.ancestor AND rlx.descendant = rla.ancestor ") . |
|
35 | 35 | |
36 | - ("WHERE rlb.ancestor = " . $this->id . " AND rlx.ancestor IS NULL"); |
|
36 | + ("WHERE rlb.ancestor = " . $this->id . " AND rlx.ancestor IS NULL"); |
|
37 | 37 | |
38 | 38 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
39 | 39 | |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | |
53 | 53 | $query = ("INSERT INTO " . static::$table_relations . " (ancestor, descendant, depth) ") . |
54 | 54 | |
55 | - ("SELECT sup.ancestor, sub.descendant, sup.depth + sub.depth + 1 ") . |
|
55 | + ("SELECT sup.ancestor, sub.descendant, sup.depth + sub.depth + 1 ") . |
|
56 | 56 | |
57 | - ("FROM " . static::$table_relations . " sup ") . |
|
57 | + ("FROM " . static::$table_relations . " sup ") . |
|
58 | 58 | |
59 | - ("JOIN " . static::$table_relations . " sub ") . |
|
59 | + ("JOIN " . static::$table_relations . " sub ") . |
|
60 | 60 | |
61 | - ("WHERE sub.ancestor = " . $this->id . " AND sup.descendant = " . $parent_id); |
|
61 | + ("WHERE sub.ancestor = " . $this->id . " AND sup.descendant = " . $parent_id); |
|
62 | 62 | |
63 | 63 | if (!(DB::send($query) && (DB::getLast()->rows > 0))) return false; |
64 | 64 |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | |
41 | 41 | private function disconnectSubtree() : bool { |
42 | 42 | |
43 | - $query = ("DELETE rla FROM " . static::$table_relations . " rla ") . |
|
43 | + $query = ("DELETE rla FROM ".static::$table_relations." rla "). |
|
44 | 44 | |
45 | - ("JOIN " . static::$table_relations . " rlb ON rlb.descendant = rla.descendant ") . |
|
45 | + ("JOIN ".static::$table_relations." rlb ON rlb.descendant = rla.descendant "). |
|
46 | 46 | |
47 | - ("LEFT JOIN " . static::$table_relations . " rlx ") . |
|
47 | + ("LEFT JOIN ".static::$table_relations." rlx "). |
|
48 | 48 | |
49 | - ("ON rlx.ancestor = rlb.ancestor AND rlx.descendant = rla.ancestor ") . |
|
49 | + ("ON rlx.ancestor = rlb.ancestor AND rlx.descendant = rla.ancestor "). |
|
50 | 50 | |
51 | - ("WHERE rlb.ancestor = " . $this->id . " AND rlx.ancestor IS NULL"); |
|
51 | + ("WHERE rlb.ancestor = ".$this->id." AND rlx.ancestor IS NULL"); |
|
52 | 52 | |
53 | 53 | if (!(DB::send($query) && DB::getLast()->status)) return false; |
54 | 54 | |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | |
70 | 70 | private function connectSubtree(int $parent_id) : bool { |
71 | 71 | |
72 | - $query = ("INSERT INTO " . static::$table_relations . " (ancestor, descendant, depth) ") . |
|
72 | + $query = ("INSERT INTO ".static::$table_relations." (ancestor, descendant, depth) "). |
|
73 | 73 | |
74 | - ("SELECT sup.ancestor, sub.descendant, sup.depth + sub.depth + 1 ") . |
|
74 | + ("SELECT sup.ancestor, sub.descendant, sup.depth + sub.depth + 1 "). |
|
75 | 75 | |
76 | - ("FROM " . static::$table_relations . " sup ") . |
|
76 | + ("FROM ".static::$table_relations." sup "). |
|
77 | 77 | |
78 | - ("JOIN " . static::$table_relations . " sub ") . |
|
78 | + ("JOIN ".static::$table_relations." sub "). |
|
79 | 79 | |
80 | - ("WHERE sub.ancestor = " . $this->id . " AND sup.descendant = " . $parent_id); |
|
80 | + ("WHERE sub.ancestor = ".$this->id." AND sup.descendant = ".$parent_id); |
|
81 | 81 | |
82 | 82 | if (!(DB::send($query) && (DB::getLast()->rows > 0))) return false; |
83 | 83 |
@@ -50,7 +50,9 @@ discard block |
||
50 | 50 | |
51 | 51 | ("WHERE rlb.ancestor = " . $this->id . " AND rlx.ancestor IS NULL"); |
52 | 52 | |
53 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
53 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
54 | + return false; |
|
55 | + } |
|
54 | 56 | |
55 | 57 | # Set path |
56 | 58 | |
@@ -79,7 +81,9 @@ discard block |
||
79 | 81 | |
80 | 82 | ("WHERE sub.ancestor = " . $this->id . " AND sup.descendant = " . $parent_id); |
81 | 83 | |
82 | - if (!(DB::send($query) && (DB::getLast()->rows > 0))) return false; |
|
84 | + if (!(DB::send($query) && (DB::getLast()->rows > 0))) { |
|
85 | + return false; |
|
86 | + } |
|
83 | 87 | |
84 | 88 | # Set path |
85 | 89 | |
@@ -98,27 +102,37 @@ discard block |
||
98 | 102 | |
99 | 103 | public function create(array $data) : bool { |
100 | 104 | |
101 | - if (0 !== $this->id) return false; |
|
105 | + if (0 !== $this->id) { |
|
106 | + return false; |
|
107 | + } |
|
102 | 108 | |
103 | 109 | $data = $this->dataset->cast($data); |
104 | 110 | |
105 | - if (static::$auto_increment && isset($data['id'])) $data['id'] = 0; |
|
111 | + if (static::$auto_increment && isset($data['id'])) { |
|
112 | + $data['id'] = 0; |
|
113 | + } |
|
106 | 114 | |
107 | 115 | # Insert entity |
108 | 116 | |
109 | 117 | DB::insert(static::$table, $data); |
110 | 118 | |
111 | - if (!(DB::getLast() && DB::getLast()->status)) return false; |
|
119 | + if (!(DB::getLast() && DB::getLast()->status)) { |
|
120 | + return false; |
|
121 | + } |
|
112 | 122 | |
113 | 123 | # Update data |
114 | 124 | |
115 | - if (static::$auto_increment) $data['id'] = DB::getLast()->id; |
|
125 | + if (static::$auto_increment) { |
|
126 | + $data['id'] = DB::getLast()->id; |
|
127 | + } |
|
116 | 128 | |
117 | 129 | $this->dataset->update($data); |
118 | 130 | |
119 | 131 | # Init subtreee |
120 | 132 | |
121 | - if (static::$nesting) $this->initSubtree(); |
|
133 | + if (static::$nesting) { |
|
134 | + $this->initSubtree(); |
|
135 | + } |
|
122 | 136 | |
123 | 137 | # Cache entity |
124 | 138 | |
@@ -137,17 +151,23 @@ discard block |
||
137 | 151 | |
138 | 152 | public function edit(array $data) : bool { |
139 | 153 | |
140 | - if (0 === $this->id) return false; |
|
154 | + if (0 === $this->id) { |
|
155 | + return false; |
|
156 | + } |
|
141 | 157 | |
142 | 158 | $data = $this->dataset->cast($data); |
143 | 159 | |
144 | - if (isset($data['id'])) unset($data['id']); |
|
160 | + if (isset($data['id'])) { |
|
161 | + unset($data['id']); |
|
162 | + } |
|
145 | 163 | |
146 | 164 | # Update entity |
147 | 165 | |
148 | 166 | DB::update(static::$table, $data, ['id' => $this->id]); |
149 | 167 | |
150 | - if (!(DB::getLast() && DB::getLast()->status)) return false; |
|
168 | + if (!(DB::getLast() && DB::getLast()->status)) { |
|
169 | + return false; |
|
170 | + } |
|
151 | 171 | |
152 | 172 | # Update data |
153 | 173 | |
@@ -155,7 +175,9 @@ discard block |
||
155 | 175 | |
156 | 176 | # Init subtreee |
157 | 177 | |
158 | - if (static::$nesting) $this->initSubtree(); |
|
178 | + if (static::$nesting) { |
|
179 | + $this->initSubtree(); |
|
180 | + } |
|
159 | 181 | |
160 | 182 | # ------------------------ |
161 | 183 | |
@@ -170,30 +192,44 @@ discard block |
||
170 | 192 | |
171 | 193 | public function move(int $parent_id) : bool { |
172 | 194 | |
173 | - if (0 === $this->id) return false; |
|
195 | + if (0 === $this->id) { |
|
196 | + return false; |
|
197 | + } |
|
174 | 198 | |
175 | 199 | # Re-connect entity if not in tree |
176 | 200 | |
177 | - if (!$this->initSubtree()) return false; |
|
201 | + if (!$this->initSubtree()) { |
|
202 | + return false; |
|
203 | + } |
|
178 | 204 | |
179 | 205 | # Get parent entity |
180 | 206 | |
181 | 207 | if (0 !== ($parent = Entitizer::get(static::$table, $parent_id))->id) { |
182 | 208 | |
183 | - if (false === ($path = $parent->getPath())) return false; |
|
209 | + if (false === ($path = $parent->getPath())) { |
|
210 | + return false; |
|
211 | + } |
|
184 | 212 | |
185 | - if (false === ($depth = $this->getSubtreeDepth())) return false; |
|
213 | + if (false === ($depth = $this->getSubtreeDepth())) { |
|
214 | + return false; |
|
215 | + } |
|
186 | 216 | |
187 | - if ((count($path) + $depth + 1) > CONFIG_ENTITIZER_MAX_DEPTH) return false; |
|
217 | + if ((count($path) + $depth + 1) > CONFIG_ENTITIZER_MAX_DEPTH) { |
|
218 | + return false; |
|
219 | + } |
|
188 | 220 | } |
189 | 221 | |
190 | 222 | # Disconnect subtree from current position |
191 | 223 | |
192 | - if (!$this->disconnectSubtree()) return false; |
|
224 | + if (!$this->disconnectSubtree()) { |
|
225 | + return false; |
|
226 | + } |
|
193 | 227 | |
194 | 228 | # Connect subtree under new position |
195 | 229 | |
196 | - if (0 !== $parent->id) $this->connectSubtree($parent->id); |
|
230 | + if (0 !== $parent->id) { |
|
231 | + $this->connectSubtree($parent->id); |
|
232 | + } |
|
197 | 233 | |
198 | 234 | # ------------------------ |
199 | 235 | |
@@ -208,19 +244,27 @@ discard block |
||
208 | 244 | |
209 | 245 | public function remove() : bool { |
210 | 246 | |
211 | - if (0 === $this->id) return false; |
|
247 | + if (0 === $this->id) { |
|
248 | + return false; |
|
249 | + } |
|
212 | 250 | |
213 | 251 | # Check if entity is removable |
214 | 252 | |
215 | - if (static::$super && ($this->id === 1)) return false; |
|
253 | + if (static::$super && ($this->id === 1)) { |
|
254 | + return false; |
|
255 | + } |
|
216 | 256 | |
217 | - if (static::$nesting && (0 !== $this->getSubtreeCount())) return false; |
|
257 | + if (static::$nesting && (0 !== $this->getSubtreeCount())) { |
|
258 | + return false; |
|
259 | + } |
|
218 | 260 | |
219 | 261 | # Remove entity |
220 | 262 | |
221 | 263 | DB::delete(static::$table, ['id' => $this->id]); |
222 | 264 | |
223 | - if (!(DB::getLast() && DB::getLast()->status)) return false; |
|
265 | + if (!(DB::getLast() && DB::getLast()->status)) { |
|
266 | + return false; |
|
267 | + } |
|
224 | 268 | |
225 | 269 | # Uncache entity |
226 | 270 |
@@ -41,14 +41,18 @@ |
||
41 | 41 | |
42 | 42 | foreach (['full_name', 'city'] as $name) { |
43 | 43 | |
44 | - if ('' === ($text = Auth::get($name))) $contents->getBlock($name)->disable(); |
|
45 | - |
|
46 | - else $contents->getBlock($name)->text = $text; |
|
44 | + if ('' === ($text = Auth::get($name))) { |
|
45 | + $contents->getBlock($name)->disable(); |
|
46 | + } else { |
|
47 | + $contents->getBlock($name)->text = $text; |
|
48 | + } |
|
47 | 49 | } |
48 | 50 | |
49 | 51 | # Set country |
50 | 52 | |
51 | - if ('' === ($country = Auth::get('country'))) $contents->getBlock('country')->disable(); else { |
|
53 | + if ('' === ($country = Auth::get('country'))) { |
|
54 | + $contents->getBlock('country')->disable(); |
|
55 | + } else { |
|
52 | 56 | |
53 | 57 | $contents->getBlock('country')->code = $country; |
54 | 58 |
@@ -33,13 +33,19 @@ discard block |
||
33 | 33 | |
34 | 34 | # Validate values |
35 | 35 | |
36 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
36 | + if (false === ($email = Validate::userEmail($email))) { |
|
37 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # Check email exists |
39 | 41 | |
40 | - if (false === ($check_email = Auth::getUser()->check($email, 'email'))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
42 | + if (false === ($check_email = Auth::getUser()->check($email, 'email'))) { |
|
43 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
44 | + } |
|
41 | 45 | |
42 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
46 | + if ($check_email === 1) { |
|
47 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
48 | + } |
|
43 | 49 | |
44 | 50 | # Update user |
45 | 51 | |
@@ -53,7 +59,9 @@ discard block |
||
53 | 59 | $data['country'] = $country; |
54 | 60 | $data['timezone'] = $timezone; |
55 | 61 | |
56 | - if (!Auth::getUser()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
62 | + if (!Auth::getUser()->edit($data)) { |
|
63 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
64 | + } |
|
57 | 65 | |
58 | 66 | # ------------------------ |
59 | 67 |
@@ -33,23 +33,28 @@ discard block |
||
33 | 33 | |
34 | 34 | # Validate values |
35 | 35 | |
36 | - if (false === ($password = Validate::userPassword($password))) |
|
37 | - |
|
36 | + if (false === ($password = Validate::userPassword($password))) { |
|
37 | + |
|
38 | 38 | return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
39 | + } |
|
39 | 40 | |
40 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
41 | - |
|
41 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
42 | + |
|
42 | 43 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
44 | + } |
|
43 | 45 | |
44 | - if (0 !== strcmp($password_new, $password_retype)) |
|
45 | - |
|
46 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
47 | + |
|
46 | 48 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
49 | + } |
|
47 | 50 | |
48 | 51 | # Check password |
49 | 52 | |
50 | 53 | $password = Str::encode(Auth::get('auth_key'), $password); |
51 | 54 | |
52 | - if (0 !== strcmp(Auth::get('password'), $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
55 | + if (0 !== strcmp(Auth::get('password'), $password)) { |
|
56 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
57 | + } |
|
53 | 58 | |
54 | 59 | # Encode password |
55 | 60 | |
@@ -62,7 +67,9 @@ discard block |
||
62 | 67 | $data['auth_key'] = $auth_key; |
63 | 68 | $data['password'] = $password; |
64 | 69 | |
65 | - if (!Auth::getUser()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
70 | + if (!Auth::getUser()->edit($data)) { |
|
71 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
72 | + } |
|
66 | 73 | |
67 | 74 | # ------------------------ |
68 | 75 |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH . '/admin'); |
|
36 | + if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH.'/admin'); |
|
37 | 37 | |
38 | 38 | # Handle request |
39 | 39 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | |
55 | 55 | if (!Auth::isLogged() || ((false !== Request::get('logout')) && Auth::logout())) { |
56 | 56 | |
57 | - Request::redirect(INSTALL_PATH . '/admin/login'); |
|
57 | + Request::redirect(INSTALL_PATH.'/admin/login'); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | # Handle request |
@@ -33,11 +33,15 @@ discard block |
||
33 | 33 | |
34 | 34 | # Check auth |
35 | 35 | |
36 | - if (($this instanceof Area\Auth) && Auth::isLogged()) Request::redirect(INSTALL_PATH . '/admin'); |
|
36 | + if (($this instanceof Area\Auth) && Auth::isLogged()) { |
|
37 | + Request::redirect(INSTALL_PATH . '/admin'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | # Handle request |
39 | 41 | |
40 | - if (Template::isBlock($result = $this->handle())) return (new View\Form($this->_title))->display($result); |
|
42 | + if (Template::isBlock($result = $this->handle())) { |
|
43 | + return (new View\Form($this->_title))->display($result); |
|
44 | + } |
|
41 | 45 | |
42 | 46 | # ------------------------ |
43 | 47 | |
@@ -63,9 +67,13 @@ discard block |
||
63 | 67 | |
64 | 68 | $result = $this->handle(Request::isAjax() && ($request === 'display')); |
65 | 69 | |
66 | - if (Template::isBlock($result)) return (new View\Panel($this->_title))->$request($result); |
|
70 | + if (Template::isBlock($result)) { |
|
71 | + return (new View\Panel($this->_title))->$request($result); |
|
72 | + } |
|
67 | 73 | |
68 | - if (Ajax::isResponse($result)) return Ajax::output($result); |
|
74 | + if (Ajax::isResponse($result)) { |
|
75 | + return Ajax::output($result); |
|
76 | + } |
|
69 | 77 | |
70 | 78 | # ------------------------ |
71 | 79 | |
@@ -84,14 +92,20 @@ discard block |
||
84 | 92 | |
85 | 93 | $ips = preg_split('/ +/', CONFIG_ADMIN_IP, -1, PREG_SPLIT_NO_EMPTY); |
86 | 94 | |
87 | - if (!in_array(REQUEST_CLIENT_IP, $ips, true)) return Status::displayError404(); |
|
95 | + if (!in_array(REQUEST_CLIENT_IP, $ips, true)) { |
|
96 | + return Status::displayError404(); |
|
97 | + } |
|
88 | 98 | } |
89 | 99 | |
90 | 100 | # Handle request |
91 | 101 | |
92 | - if (($this instanceof Area\Auth) || ($this instanceof Area\Install)) return $this->handleFormArea(); |
|
102 | + if (($this instanceof Area\Auth) || ($this instanceof Area\Install)) { |
|
103 | + return $this->handleFormArea(); |
|
104 | + } |
|
93 | 105 | |
94 | - if ($this instanceof Area\Panel) return $this->handlePanelArea(); |
|
106 | + if ($this instanceof Area\Panel) { |
|
107 | + return $this->handlePanelArea(); |
|
108 | + } |
|
95 | 109 | |
96 | 110 | # ------------------------ |
97 | 111 |