@@ -14,14 +14,14 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->textual ('name', true, 255, false, ''); |
|
18 | - $this->params->textual ('title', true, 255, false, ''); |
|
19 | - $this->params->textual ('value', true, 255, false, ''); |
|
17 | + $this->params->textual('name', true, 255, false, ''); |
|
18 | + $this->params->textual('title', true, 255, false, ''); |
|
19 | + $this->params->textual('value', true, 255, false, ''); |
|
20 | 20 | |
21 | 21 | # Add indexes |
22 | 22 | |
23 | - $this->indexes->add ('name', 'UNIQUE'); |
|
24 | - $this->indexes->add ('title'); |
|
23 | + $this->indexes->add('name', 'UNIQUE'); |
|
24 | + $this->indexes->add('title'); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | } |
@@ -14,27 +14,27 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->integer ('rank', true, 1, true, RANK_GUEST); |
|
18 | - $this->params->textual ('name', true, 16, false, ''); |
|
19 | - $this->params->textual ('email', true, 128, false, ''); |
|
20 | - $this->params->textual ('auth_key', true, 40, true, ''); |
|
21 | - $this->params->textual ('password', true, 40, true, ''); |
|
22 | - $this->params->textual ('first_name', true, 255, false, ''); |
|
23 | - $this->params->textual ('last_name', true, 255, false, ''); |
|
24 | - $this->params->integer ('sex', true, 1, true, SEX_NOT_SELECTED); |
|
25 | - $this->params->textual ('city', true, 255, false, ''); |
|
26 | - $this->params->textual ('country', true, 2, false, ''); |
|
27 | - $this->params->textual ('timezone', true, 40, false, ''); |
|
28 | - $this->params->integer ('time_registered', false, 10, true, 0); |
|
29 | - $this->params->integer ('time_logged', false, 10, true, 0); |
|
17 | + $this->params->integer('rank', true, 1, true, RANK_GUEST); |
|
18 | + $this->params->textual('name', true, 16, false, ''); |
|
19 | + $this->params->textual('email', true, 128, false, ''); |
|
20 | + $this->params->textual('auth_key', true, 40, true, ''); |
|
21 | + $this->params->textual('password', true, 40, true, ''); |
|
22 | + $this->params->textual('first_name', true, 255, false, ''); |
|
23 | + $this->params->textual('last_name', true, 255, false, ''); |
|
24 | + $this->params->integer('sex', true, 1, true, SEX_NOT_SELECTED); |
|
25 | + $this->params->textual('city', true, 255, false, ''); |
|
26 | + $this->params->textual('country', true, 2, false, ''); |
|
27 | + $this->params->textual('timezone', true, 40, false, ''); |
|
28 | + $this->params->integer('time_registered', false, 10, true, 0); |
|
29 | + $this->params->integer('time_logged', false, 10, true, 0); |
|
30 | 30 | |
31 | 31 | # Add indexes |
32 | 32 | |
33 | - $this->indexes->add ('rank'); |
|
34 | - $this->indexes->add ('name', 'UNIQUE'); |
|
35 | - $this->indexes->add ('email', 'UNIQUE'); |
|
36 | - $this->indexes->add ('time_registered'); |
|
37 | - $this->indexes->add ('time_logged'); |
|
33 | + $this->indexes->add('rank'); |
|
34 | + $this->indexes->add('name', 'UNIQUE'); |
|
35 | + $this->indexes->add('email', 'UNIQUE'); |
|
36 | + $this->indexes->add('time_registered'); |
|
37 | + $this->indexes->add('time_logged'); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | } |
@@ -44,11 +44,15 @@ |
||
44 | 44 | $data['contents'] = $contents; |
45 | 45 | $data['time_modified'] = REQUEST_TIME; |
46 | 46 | |
47 | - if (0 === $this->page->id) $data['time_created'] = REQUEST_TIME; |
|
47 | + if (0 === $this->page->id) { |
|
48 | + $data['time_created'] = REQUEST_TIME; |
|
49 | + } |
|
48 | 50 | |
49 | 51 | $modifier = ((0 === $this->page->id) ? 'create' : 'edit'); |
50 | 52 | |
51 | - if (!$this->page->$modifier($data)) return 'PAGE_ERROR_MODIFY'; |
|
53 | + if (!$this->page->$modifier($data)) { |
|
54 | + return 'PAGE_ERROR_MODIFY'; |
|
55 | + } |
|
52 | 56 | |
53 | 57 | # ------------------------ |
54 | 58 |
@@ -31,30 +31,46 @@ discard block |
||
31 | 31 | |
32 | 32 | # Validate name & email |
33 | 33 | |
34 | - if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID']; |
|
34 | + if (false === ($name = Validate::userName($name))) { |
|
35 | + return ['name', 'USER_ERROR_NAME_INVALID']; |
|
36 | + } |
|
35 | 37 | |
36 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
38 | + if (false === ($email = Validate::userEmail($email))) { |
|
39 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
40 | + } |
|
37 | 41 | |
38 | 42 | # Validate password |
39 | 43 | |
40 | 44 | if ((0 === $this->user->id) || ('' !== $password)) { |
41 | 45 | |
42 | - if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
46 | + if (false === ($password = Validate::userPassword($password))) { |
|
47 | + return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
|
48 | + } |
|
43 | 49 | |
44 | - if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
50 | + if (0 !== strcmp($password, $password_retype)) { |
|
51 | + return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
|
52 | + } |
|
45 | 53 | } |
46 | 54 | |
47 | 55 | # Check name exists |
48 | 56 | |
49 | - if (false === ($check_name = $this->user->check($name, 'name'))) return 'USER_ERROR_MODIFY'; |
|
57 | + if (false === ($check_name = $this->user->check($name, 'name'))) { |
|
58 | + return 'USER_ERROR_MODIFY'; |
|
59 | + } |
|
50 | 60 | |
51 | - if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
61 | + if ($check_name === 1) { |
|
62 | + return ['name', 'USER_ERROR_NAME_DUPLICATE']; |
|
63 | + } |
|
52 | 64 | |
53 | 65 | # Check email exists |
54 | 66 | |
55 | - if (false === ($check_email = $this->user->check($email, 'email'))) return 'USER_ERROR_MODIFY'; |
|
67 | + if (false === ($check_email = $this->user->check($email, 'email'))) { |
|
68 | + return 'USER_ERROR_MODIFY'; |
|
69 | + } |
|
56 | 70 | |
57 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
71 | + if ($check_email === 1) { |
|
72 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
73 | + } |
|
58 | 74 | |
59 | 75 | # Modify user |
60 | 76 | |
@@ -84,7 +100,9 @@ discard block |
||
84 | 100 | |
85 | 101 | $modifier = ((0 === $this->user->id) ? 'create' : 'edit'); |
86 | 102 | |
87 | - if (!$this->user->$modifier($data)) return 'USER_ERROR_MODIFY'; |
|
103 | + if (!$this->user->$modifier($data)) { |
|
104 | + return 'USER_ERROR_MODIFY'; |
|
105 | + } |
|
88 | 106 | |
89 | 107 | # ------------------------ |
90 | 108 |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | |
65 | 65 | $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
66 | 66 | |
67 | - ("FROM " . static::$table . " ent ") . |
|
67 | + ("FROM " . static::$table . " ent ") . |
|
68 | 68 | |
69 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
69 | + ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
70 | 70 | |
71 | - ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::user()->rank . " AND ") . |
|
71 | + ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::user()->rank . " AND ") . |
|
72 | 72 | |
73 | - ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
73 | + ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
74 | 74 | |
75 | 75 | # Select entity from DB |
76 | 76 | |
@@ -91,17 +91,17 @@ discard block |
||
91 | 91 | |
92 | 92 | $query = ("UPDATE " . static::$table . " ent JOIN (") . |
93 | 93 | |
94 | - ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
94 | + ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
95 | 95 | |
96 | - ("FROM " . static::$table_relations . " rel ") . |
|
96 | + ("FROM " . static::$table_relations . " rel ") . |
|
97 | 97 | |
98 | - ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
98 | + ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
99 | 99 | |
100 | - ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
100 | + ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
101 | 101 | |
102 | - ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
102 | + ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
103 | 103 | |
104 | - (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
|
104 | + (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
|
105 | 105 | |
106 | 106 | if (!(DB::send($query) && DB::last()->status)) return false; |
107 | 107 | |
@@ -109,15 +109,15 @@ discard block |
||
109 | 109 | |
110 | 110 | $query = ("UPDATE " . static::$table . " ent JOIN (") . |
111 | 111 | |
112 | - ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
112 | + ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
113 | 113 | |
114 | - ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
114 | + ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
115 | 115 | |
116 | - ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
116 | + ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
117 | 117 | |
118 | - ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
118 | + ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
119 | 119 | |
120 | - (") chk ON chk.id = ent.id SET ent.locked = 0"); |
|
120 | + (") chk ON chk.id = ent.id SET ent.locked = 0"); |
|
121 | 121 | |
122 | 122 | if (!(DB::send($query) && DB::last()->status)) return false; |
123 | 123 |
@@ -22,19 +22,19 @@ discard block |
||
22 | 22 | |
23 | 23 | $selection = array_keys($this->definition->params()); |
24 | 24 | |
25 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
25 | + foreach ($selection as $key => $field) $selection[$key] = ('ent.'.$field); |
|
26 | 26 | |
27 | 27 | # Process query |
28 | 28 | |
29 | - $query = ("SELECT " . implode(', ', $selection) .", rel.ancestor as parent_id ") . |
|
29 | + $query = ("SELECT ".implode(', ', $selection).", rel.ancestor as parent_id "). |
|
30 | 30 | |
31 | - ("FROM " . static::$table . " ent ") . |
|
31 | + ("FROM ".static::$table." ent "). |
|
32 | 32 | |
33 | - ("LEFT JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id AND rel.depth = 1 ") . |
|
33 | + ("LEFT JOIN ".static::$table_relations." rel ON rel.descendant = ent.id AND rel.depth = 1 "). |
|
34 | 34 | |
35 | - ("WHERE ent.visibility = " . VISIBILITY_PUBLISHED . " AND ent.access <= " . Auth::user()->rank . " AND ") . |
|
35 | + ("WHERE ent.visibility = ".VISIBILITY_PUBLISHED." AND ent.access <= ".Auth::user()->rank." AND "). |
|
36 | 36 | |
37 | - ("ent.locked = 0 AND ent.slug = '" . addslashes($slug) . "' LIMIT 1"); |
|
37 | + ("ent.locked = 0 AND ent.slug = '".addslashes($slug)."' LIMIT 1"); |
|
38 | 38 | |
39 | 39 | # Select entity from DB |
40 | 40 | |
@@ -53,17 +53,17 @@ discard block |
||
53 | 53 | |
54 | 54 | # Send lock/update request |
55 | 55 | |
56 | - $query = ("UPDATE " . static::$table . " ent JOIN (") . |
|
56 | + $query = ("UPDATE ".static::$table." ent JOIN ("). |
|
57 | 57 | |
58 | - ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug ") . |
|
58 | + ("SELECT rel.descendant as id, GROUP_CONCAT(ens.name ORDER BY rls.depth DESC SEPARATOR '/') slug "). |
|
59 | 59 | |
60 | - ("FROM " . static::$table_relations . " rel ") . |
|
60 | + ("FROM ".static::$table_relations." rel "). |
|
61 | 61 | |
62 | - ("JOIN " . static::$table_relations . " rls ON rls.descendant = rel.descendant ") . |
|
62 | + ("JOIN ".static::$table_relations." rls ON rls.descendant = rel.descendant "). |
|
63 | 63 | |
64 | - ("JOIN " . static::$table . " ens ON ens.id = rls.ancestor ") . |
|
64 | + ("JOIN ".static::$table." ens ON ens.id = rls.ancestor "). |
|
65 | 65 | |
66 | - ("WHERE rel.ancestor = " . $this->id . " GROUP BY rel.descendant") . |
|
66 | + ("WHERE rel.ancestor = ".$this->id." GROUP BY rel.descendant"). |
|
67 | 67 | |
68 | 68 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
69 | 69 | |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | |
72 | 72 | # Send unlock request |
73 | 73 | |
74 | - $query = ("UPDATE " . static::$table . " ent JOIN (") . |
|
74 | + $query = ("UPDATE ".static::$table." ent JOIN ("). |
|
75 | 75 | |
76 | - ("SELECT rel.descendant as id FROM " . static::$table_relations . " rel ") . |
|
76 | + ("SELECT rel.descendant as id FROM ".static::$table_relations." rel "). |
|
77 | 77 | |
78 | - ("JOIN " . static::$table . " enc ON enc.id = rel.descendant AND enc.locked = 1 ") . |
|
78 | + ("JOIN ".static::$table." enc ON enc.id = rel.descendant AND enc.locked = 1 "). |
|
79 | 79 | |
80 | - ("LEFT JOIN " . static::$table . " end ON end.id != enc.id AND end.slug = enc.slug ") . |
|
80 | + ("LEFT JOIN ".static::$table." end ON end.id != enc.id AND end.slug = enc.slug "). |
|
81 | 81 | |
82 | - ("WHERE end.id IS NULL GROUP BY rel.descendant") . |
|
82 | + ("WHERE end.id IS NULL GROUP BY rel.descendant"). |
|
83 | 83 | |
84 | 84 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
85 | 85 |
@@ -12,7 +12,9 @@ discard block |
||
12 | 12 | |
13 | 13 | public function initBySlug(string $slug) { |
14 | 14 | |
15 | - if (0 !== $this->id) return false; |
|
15 | + if (0 !== $this->id) { |
|
16 | + return false; |
|
17 | + } |
|
16 | 18 | |
17 | 19 | # Process value |
18 | 20 | |
@@ -22,7 +24,9 @@ discard block |
||
22 | 24 | |
23 | 25 | $selection = array_keys($this->definition->params()); |
24 | 26 | |
25 | - foreach ($selection as $key => $field) $selection[$key] = ('ent.' . $field); |
|
27 | + foreach ($selection as $key => $field) { |
|
28 | + $selection[$key] = ('ent.' . $field); |
|
29 | + } |
|
26 | 30 | |
27 | 31 | # Process query |
28 | 32 | |
@@ -38,7 +42,9 @@ discard block |
||
38 | 42 | |
39 | 43 | # Select entity from DB |
40 | 44 | |
41 | - if (!(DB::send($query) && (DB::getLast()->rows === 1))) return false; |
|
45 | + if (!(DB::send($query) && (DB::getLast()->rows === 1))) { |
|
46 | + return false; |
|
47 | + } |
|
42 | 48 | |
43 | 49 | # ------------------------ |
44 | 50 | |
@@ -49,7 +55,9 @@ discard block |
||
49 | 55 | |
50 | 56 | public function updateSlugs() { |
51 | 57 | |
52 | - if (0 === $this->id) return false; |
|
58 | + if (0 === $this->id) { |
|
59 | + return false; |
|
60 | + } |
|
53 | 61 | |
54 | 62 | # Send lock/update request |
55 | 63 | |
@@ -67,7 +75,9 @@ discard block |
||
67 | 75 | |
68 | 76 | (") slg ON slg.id = ent.id SET ent.locked = 1, ent.slug = slg.slug"); |
69 | 77 | |
70 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
78 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
79 | + return false; |
|
80 | + } |
|
71 | 81 | |
72 | 82 | # Send unlock request |
73 | 83 | |
@@ -83,7 +93,9 @@ discard block |
||
83 | 93 | |
84 | 94 | (") chk ON chk.id = ent.id SET ent.locked = 0"); |
85 | 95 | |
86 | - if (!(DB::send($query) && DB::getLast()->status)) return false; |
|
96 | + if (!(DB::send($query) && DB::getLast()->status)) { |
|
97 | + return false; |
|
98 | + } |
|
87 | 99 | |
88 | 100 | # ------------------------ |
89 | 101 | |
@@ -94,7 +106,9 @@ discard block |
||
94 | 106 | |
95 | 107 | public function create(array $data) { |
96 | 108 | |
97 | - if (!parent::create($data)) return false; |
|
109 | + if (!parent::create($data)) { |
|
110 | + return false; |
|
111 | + } |
|
98 | 112 | |
99 | 113 | $this->updateSlugs(); |
100 | 114 | |
@@ -107,7 +121,9 @@ discard block |
||
107 | 121 | |
108 | 122 | public function edit(array $data) { |
109 | 123 | |
110 | - if (!parent::edit($data)) return false; |
|
124 | + if (!parent::edit($data)) { |
|
125 | + return false; |
|
126 | + } |
|
111 | 127 | |
112 | 128 | $this->updateSlugs(); |
113 | 129 | |
@@ -120,7 +136,9 @@ discard block |
||
120 | 136 | |
121 | 137 | public function move(int $parent_id) { |
122 | 138 | |
123 | - if (!parent::move($parent_id)) return false; |
|
139 | + if (!parent::move($parent_id)) { |
|
140 | + return false; |
|
141 | + } |
|
124 | 142 | |
125 | 143 | $this->updateSlugs(); |
126 | 144 |
@@ -20,23 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | # Validate values |
22 | 22 | |
23 | - if (false === ($password = Validate::userPassword($password))) |
|
24 | - |
|
23 | + if (false === ($password = Validate::userPassword($password))) { |
|
24 | + |
|
25 | 25 | return ['password', 'USER_ERROR_PASSWORD_INVALID']; |
26 | + } |
|
26 | 27 | |
27 | - if (false === ($password_new = Validate::userPassword($password_new))) |
|
28 | - |
|
28 | + if (false === ($password_new = Validate::userPassword($password_new))) { |
|
29 | + |
|
29 | 30 | return ['password_new', 'USER_ERROR_PASSWORD_NEW_INVALID']; |
31 | + } |
|
30 | 32 | |
31 | - if (0 !== strcmp($password_new, $password_retype)) |
|
32 | - |
|
33 | + if (0 !== strcmp($password_new, $password_retype)) { |
|
34 | + |
|
33 | 35 | return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH']; |
36 | + } |
|
34 | 37 | |
35 | 38 | # Check password |
36 | 39 | |
37 | 40 | $password = Str::encode(Auth::user()->auth_key, $password); |
38 | 41 | |
39 | - if (0 !== strcmp(Auth::user()->password, $password)) return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
42 | + if (0 !== strcmp(Auth::user()->password, $password)) { |
|
43 | + return ['password', 'USER_ERROR_PASSWORD_INCORRECT']; |
|
44 | + } |
|
40 | 45 | |
41 | 46 | # Encode password |
42 | 47 | |
@@ -49,7 +54,9 @@ discard block |
||
49 | 54 | $data['auth_key'] = $auth_key; |
50 | 55 | $data['password'] = $password; |
51 | 56 | |
52 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PASSWORD'; |
|
57 | + if (!Auth::user()->edit($data)) { |
|
58 | + return 'USER_ERROR_EDIT_PASSWORD'; |
|
59 | + } |
|
53 | 60 | |
54 | 61 | # ------------------------ |
55 | 62 |
@@ -20,13 +20,19 @@ discard block |
||
20 | 20 | |
21 | 21 | # Validate values |
22 | 22 | |
23 | - if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
23 | + if (false === ($email = Validate::userEmail($email))) { |
|
24 | + return ['email', 'USER_ERROR_EMAIL_INVALID']; |
|
25 | + } |
|
24 | 26 | |
25 | 27 | # Check email exists |
26 | 28 | |
27 | - if (false === ($check_email = Auth::user()->check($email, 'email'))) return 'USER_ERROR_EDIT_PERSONAL'; |
|
29 | + if (false === ($check_email = Auth::user()->check($email, 'email'))) { |
|
30 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
31 | + } |
|
28 | 32 | |
29 | - if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
33 | + if ($check_email === 1) { |
|
34 | + return ['email', 'USER_ERROR_EMAIL_DUPLICATE']; |
|
35 | + } |
|
30 | 36 | |
31 | 37 | # Update user |
32 | 38 | |
@@ -40,7 +46,9 @@ discard block |
||
40 | 46 | $data['country'] = $country; |
41 | 47 | $data['timezone'] = $timezone; |
42 | 48 | |
43 | - if (!Auth::user()->edit($data)) return 'USER_ERROR_EDIT_PERSONAL'; |
|
49 | + if (!Auth::user()->edit($data)) { |
|
50 | + return 'USER_ERROR_EDIT_PERSONAL'; |
|
51 | + } |
|
44 | 52 | |
45 | 53 | # ------------------------ |
46 | 54 |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | for ($id = 2; $id <= 4; $id++) $pages[] = ['id' => $id, 'visibility' => VISIBILITY_PUBLISHED, |
48 | 48 | |
49 | - 'locked' => false, 'slug' => ('page-' . ($id - 1)), 'name' => ('page-' . ($id - 1)), |
|
49 | + 'locked' => false, 'slug' => ('page-'.($id - 1)), 'name' => ('page-'.($id - 1)), |
|
50 | 50 | |
51 | - 'title' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . ($id - 1)), |
|
51 | + 'title' => (Language::get('INSTALL_PAGE_DEMO_TITLE').' '.($id - 1)), |
|
52 | 52 | |
53 | 53 | 'contents' => Template::block(Language::get('INSTALL_PAGE_DEMO_CONTENTS'))->contents(), |
54 | 54 | |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | for ($id = 1; $id <= 3; $id++) $menu[] = [ |
83 | 83 | |
84 | - 'id' => $id, 'active' => true, 'position' => ($id - 1), 'slug' => ('page-' . $id), |
|
84 | + 'id' => $id, 'active' => true, 'position' => ($id - 1), 'slug' => ('page-'.$id), |
|
85 | 85 | |
86 | - 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . $id)]; |
|
86 | + 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE').' '.$id)]; |
|
87 | 87 | |
88 | 88 | # Process insertion |
89 | 89 |
@@ -55,7 +55,11 @@ discard block |
||
55 | 55 | |
56 | 56 | $count = Informer::countEntries(TABLE_PAGES, true); |
57 | 57 | |
58 | - if (false === $count) return false; else if ($count > 0) return true; |
|
58 | + if (false === $count) { |
|
59 | + return false; |
|
60 | + } else if ($count > 0) { |
|
61 | + return true; |
|
62 | + } |
|
59 | 63 | |
60 | 64 | # Process dataset |
61 | 65 | |
@@ -69,7 +73,8 @@ discard block |
||
69 | 73 | |
70 | 74 | 'time_created' => REQUEST_TIME, 'time_modified' => REQUEST_TIME]]; |
71 | 75 | |
72 | - for ($id = 2; $id <= 4; $id++) $pages[] = ['id' => $id, 'visibility' => VISIBILITY_PUBLISHED, |
|
76 | + for ($id = 2; $id <= 4; $id++) { |
|
77 | + $pages[] = ['id' => $id, 'visibility' => VISIBILITY_PUBLISHED, |
|
73 | 78 | |
74 | 79 | 'locked' => false, 'slug' => ('page-' . ($id - 1)), 'name' => ('page-' . ($id - 1)), |
75 | 80 | |
@@ -78,10 +83,13 @@ discard block |
||
78 | 83 | 'contents' => Template::createBlock(Language::get('INSTALL_PAGE_DEMO_CONTENTS'))->getContents(), |
79 | 84 | |
80 | 85 | 'time_created' => REQUEST_TIME, 'time_modified' => REQUEST_TIME]; |
86 | + } |
|
81 | 87 | |
82 | 88 | # Process insertion |
83 | 89 | |
84 | - if (!(DB::insert(TABLE_PAGES, $pages, true) && DB::getLast()->status)) return false; |
|
90 | + if (!(DB::insert(TABLE_PAGES, $pages, true) && DB::getLast()->status)) { |
|
91 | + return false; |
|
92 | + } |
|
85 | 93 | |
86 | 94 | self::fillRelationsTable(TABLE_PAGES_RELATIONS, 4); |
87 | 95 | |
@@ -98,21 +106,29 @@ discard block |
||
98 | 106 | |
99 | 107 | $count = Informer::countEntries(TABLE_MENU, true); |
100 | 108 | |
101 | - if (false === $count) return false; else if ($count > 0) return true; |
|
109 | + if (false === $count) { |
|
110 | + return false; |
|
111 | + } else if ($count > 0) { |
|
112 | + return true; |
|
113 | + } |
|
102 | 114 | |
103 | 115 | # Process dataset |
104 | 116 | |
105 | 117 | $menu = []; |
106 | 118 | |
107 | - for ($id = 1; $id <= 3; $id++) $menu[] = [ |
|
119 | + for ($id = 1; $id <= 3; $id++) { |
|
120 | + $menu[] = [ |
|
108 | 121 | |
109 | 122 | 'id' => $id, 'active' => true, 'position' => ($id - 1), 'slug' => ('page-' . $id), |
110 | 123 | |
111 | 124 | 'text' => (Language::get('INSTALL_PAGE_DEMO_TITLE') . ' ' . $id)]; |
125 | + } |
|
112 | 126 | |
113 | 127 | # Process insertion |
114 | 128 | |
115 | - if (!(DB::insert(TABLE_MENU, $menu, true) && DB::getLast()->status)) return false; |
|
129 | + if (!(DB::insert(TABLE_MENU, $menu, true) && DB::getLast()->status)) { |
|
130 | + return false; |
|
131 | + } |
|
116 | 132 | |
117 | 133 | self::fillRelationsTable(TABLE_MENU_RELATIONS, 3); |
118 | 134 | |
@@ -127,7 +143,9 @@ discard block |
||
127 | 143 | |
128 | 144 | $definitions = self::getDefinitions(false); |
129 | 145 | |
130 | - foreach ($definitions as $definition) if (!$definition->createTables()) return false; |
|
146 | + foreach ($definitions as $definition) { |
|
147 | + if (!$definition->createTables()) return false; |
|
148 | + } |
|
131 | 149 | |
132 | 150 | # ------------------------ |
133 | 151 | |
@@ -140,7 +158,9 @@ discard block |
||
140 | 158 | |
141 | 159 | $definitions = self::getDefinitions(true); |
142 | 160 | |
143 | - foreach ($definitions as $definition) if (!$definition->removeTables()) return false; |
|
161 | + foreach ($definitions as $definition) { |
|
162 | + if (!$definition->removeTables()) return false; |
|
163 | + } |
|
144 | 164 | |
145 | 165 | # ------------------------ |
146 | 166 |
@@ -14,19 +14,19 @@ |
||
14 | 14 | |
15 | 15 | # Add params |
16 | 16 | |
17 | - $this->params->textual ('code', true, 40, true, ''); |
|
18 | - $this->params->textual ('ip', true, 255, false, ''); |
|
19 | - $this->params->integer ('time', false, 10, true, 0); |
|
17 | + $this->params->textual('code', true, 40, true, ''); |
|
18 | + $this->params->textual('ip', true, 255, false, ''); |
|
19 | + $this->params->integer('time', false, 10, true, 0); |
|
20 | 20 | |
21 | 21 | # Add indexes |
22 | 22 | |
23 | - $this->indexes->add ('code', 'UNIQUE'); |
|
24 | - $this->indexes->add ('ip'); |
|
25 | - $this->indexes->add ('time'); |
|
23 | + $this->indexes->add('code', 'UNIQUE'); |
|
24 | + $this->indexes->add('ip'); |
|
25 | + $this->indexes->add('time'); |
|
26 | 26 | |
27 | 27 | # Add foreign keys |
28 | 28 | |
29 | - $this->foreigns->add ('id', TABLE_USERS, 'id', 'CASCADE', 'RESTRICT'); |
|
29 | + $this->foreigns->add('id', TABLE_USERS, 'id', 'CASCADE', 'RESTRICT'); |
|
30 | 30 | } |
31 | 31 | } |
32 | 32 | } |