Skip to content

Commit f319250

Browse files
committed
refactor: removed deprecated permissions
1 parent 82a607a commit f319250

File tree

2 files changed

+34
-68
lines changed

2 files changed

+34
-68
lines changed

phpmyfaq/src/phpMyFAQ/Enums/PermissionType.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ enum PermissionType: string
2323

2424
case ATTACHMENT_DELETE = 'delattachment';
2525

26+
case ATTACHMENT_DOWNLOAD = 'dlattachment';
27+
28+
case ATTACHMENT_EDIT = 'editattachment';
29+
2630
case BACKUP = 'backup';
2731

2832
case CATEGORY_ADD = 'addcateg';
@@ -31,6 +35,8 @@ enum PermissionType: string
3135

3236
case CATEGORY_EDIT = 'editcateg';
3337

38+
case CATEGORIES_VIEW = 'view_categories';
39+
3440
case COMMENT_ADD = 'addcomment';
3541
case COMMENT_DELETE = 'delcomment';
3642

@@ -46,6 +52,10 @@ enum PermissionType: string
4652

4753
case FAQ_EDIT = 'edit_faq';
4854

55+
case FAQS_VIEW = 'view_faqs';
56+
57+
case FORMS_EDIT = 'forms_edit';
58+
4959
case GLOSSARY_ADD = 'addglossary';
5060

5161
case GLOSSARY_DELETE = 'delglossary';
@@ -54,6 +64,8 @@ enum PermissionType: string
5464

5565
case GROUP_ADD = 'addgroup';
5666

67+
case GROUPS_ADMINISTRATE = 'administrate_groups';
68+
5769
case GROUP_DELETE = 'delgroup';
5870

5971
case GROUP_EDIT = 'editgroup';
@@ -70,6 +82,8 @@ enum PermissionType: string
7082

7183
case NEWS_DELETE = 'delnews';
7284

85+
case NEWS_VIEW = 'view_news';
86+
7387
case PASSWORD_CHANGE = 'passwd';
7488

7589
case QUESTION_ADD = 'addquestion';
@@ -92,7 +106,5 @@ enum PermissionType: string
92106

93107
case USER_DELETE = 'delete_user';
94108

95-
case FORMS_EDIT = 'forms_edit';
96-
97109
case VIEW_ADMIN_LINK = 'viewadminlink';
98110
}

phpmyfaq/src/phpMyFAQ/Setup/Installer.php

Lines changed: 20 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Installer extends Setup
5757
{
5858
/**
5959
* Array with user rights.
60-
* @var array<array>
60+
* @var array<array<string, string>>
6161
*/
6262
protected array $mainRights = [
6363
[
@@ -96,22 +96,18 @@ class Installer extends Setup
9696
'name' => PermissionType::COMMENT_DELETE->value,
9797
'description' => 'Right to delete comments',
9898
],
99-
//10 => "addnews",
10099
[
101100
'name' => PermissionType::NEWS_ADD->value,
102101
'description' => 'Right to add news',
103102
],
104-
//11 => "editnews",
105103
[
106104
'name' => PermissionType::NEWS_EDIT->value,
107105
'description' => 'Right to edit news',
108106
],
109-
//12 => "delnews",
110107
[
111108
'name' => PermissionType::NEWS_DELETE->value,
112109
'description' => 'Right to delete news',
113110
],
114-
//13 => "addcateg",
115111
[
116112
'name' => PermissionType::CATEGORY_ADD->value,
117113
'description' => 'Right to add categories',
@@ -124,176 +120,136 @@ class Installer extends Setup
124120
'name' => PermissionType::CATEGORY_DELETE->value,
125121
'description' => 'Right to delete categories',
126122
],
127-
//16 => "passwd",
128123
[
129124
'name' => PermissionType::PASSWORD_CHANGE->value,
130125
'description' => 'Right to change passwords',
131126
],
132-
//17 => "editconfig",
133127
[
134128
'name' => PermissionType::CONFIGURATION_EDIT->value,
135129
'description' => 'Right to edit configuration',
136130
],
137-
//18 => "viewadminlink",
138131
[
139132
'name' => PermissionType::VIEW_ADMIN_LINK->value,
140133
'description' => 'Right to see the link to the admin section'
141134
],
142-
//20 => "backup",
143135
[
144136
'name' => PermissionType::BACKUP->value,
145137
'description' => 'Right to save backups',
146138
],
147-
//21 => "restore",
148139
[
149140
'name' => PermissionType::RESTORE->value,
150141
'description' => 'Right to load backups',
151142
],
152-
//22 => "delquestion",
153143
[
154144
'name' => PermissionType::QUESTION_DELETE->value,
155145
'description' => 'Right to delete questions',
156146
],
157-
//23 => 'addglossary',
158147
[
159148
'name' => PermissionType::GLOSSARY_ADD->value,
160149
'description' => 'Right to add glossary entries',
161150
],
162-
//24 => 'editglossary',
163151
[
164152
'name' => PermissionType::GLOSSARY_EDIT->value,
165153
'description' => 'Right to edit glossary entries',
166154
],
167-
//25 => 'delglossary'
168155
[
169156
'name' => PermissionType::GLOSSARY_DELETE->value,
170157
'description' => 'Right to delete glossary entries',
171158
],
172-
//26 => 'changebtrevs'
173159
[
174160
'name' => PermissionType::REVISION_UPDATE->value,
175161
'description' => 'Right to edit revisions',
176162
],
177-
//27 => "addgroup",
178163
[
179164
'name' => PermissionType::GROUP_ADD->value,
180165
'description' => 'Right to add group accounts',
181166
],
182-
//28 => "editgroup",
183167
[
184168
'name' => PermissionType::GROUP_EDIT->value,
185169
'description' => 'Right to edit group accounts',
186170
],
187-
//29 => "delgroup",
188171
[
189172
'name' => PermissionType::GROUP_DELETE->value,
190173
'description' => 'Right to delete group accounts',
191174
],
192-
//30 => "addtranslation", @deprecated will be removed in 4.1
193175
[
194-
'name' => 'addtranslation',
195-
'description' => 'Right to add translation',
176+
'name' => PermissionType::FAQ_APPROVE->value,
177+
'description' => 'Right to approve FAQs',
196178
],
197-
//31 => "edittranslation", @deprecated will be removed in 4.1
198-
[
199-
'name' => 'edittranslation',
200-
'description' => 'Right to edit translations',
201-
],
202-
//32 => "deltranslation", @deprecated will be removed in 4.1
203-
[
204-
'name' => 'deltranslation',
205-
'description' => 'Right to delete translations',
206-
],
207-
// 33 => 'approverec'
208-
[
209-
'name' => 'approverec',
210-
'description' => 'Right to approve records',
211-
],
212-
// 34 => 'addattachment'
213179
[
214180
'name' => PermissionType::ATTACHMENT_ADD->value,
215181
'description' => 'Right to add attachments',
216182
],
217-
// 35 => 'editattachment'
218183
[
219-
'name' => 'editattachment',
184+
'name' => PermissionType::ATTACHMENT_EDIT->value,
220185
'description' => 'Right to edit attachments',
221186
],
222-
// 36 => 'delattachment'
223187
[
224-
'name' => 'delattachment',
188+
'name' => PermissionType::ATTACHMENT_DELETE->value,
225189
'description' => 'Right to delete attachments',
226190
],
227-
// 37 => 'dlattachment'
228191
[
229-
'name' => 'dlattachment',
192+
'name' => PermissionType::ATTACHMENT_DOWNLOAD->value,
230193
'description' => 'Right to download attachments',
231194
],
232-
// 38 => 'reports'
233195
[
234-
'name' => 'reports',
196+
'name' => PermissionType::REPORTS->value,
235197
'description' => 'Right to generate reports',
236198
],
237-
// 39 => 'addfaq'
238199
[
239-
'name' => 'addfaq',
200+
'name' => PermissionType::FAQ_ADD->value,
240201
'description' => 'Right to add FAQs in frontend',
241202
],
242-
// 40 => 'addquestion'
243203
[
244-
'name' => 'addquestion',
204+
'name' => PermissionType::QUESTION_ADD->value,
245205
'description' => 'Right to add questions in frontend',
246206
],
247-
// 41 => 'addcomment'
248207
[
249208
'name' => PermissionType::COMMENT_ADD->value,
250209
'description' => 'Right to add comments in frontend',
251210
],
252-
// 42 => 'editinstances'
253211
[
254-
'name' => 'editinstances',
212+
'name' => PermissionType::INSTANCE_EDIT->value,
255213
'description' => 'Right to edit multi-site instances',
256214
],
257-
// 43 => 'addinstances'
258215
[
259-
'name' => 'addinstances',
216+
'name' => PermissionType::INSTANCE_ADD->value,
260217
'description' => 'Right to add multi-site instances',
261218
],
262-
// 44 => 'delinstances'
263219
[
264-
'name' => 'delinstances',
220+
'name' => PermissionType::INSTANCE_DELETE->value,
265221
'description' => 'Right to delete multi-site instances',
266222
],
267223
[
268-
'name' => 'export',
224+
'name' => PermissionType::EXPORT->value,
269225
'description' => 'Right to export the complete FAQ',
270226
],
271227
[
272-
'name' => 'view_faqs',
228+
'name' => PermissionType::FAQS_VIEW->value,
273229
'description' => 'Right to view FAQs'
274230
],
275231
[
276-
'name' => 'view_categories',
232+
'name' => PermissionType::CATEGORIES_VIEW->value,
277233
'description' => 'Right to view categories'
278234
],
279235
[
280-
'name' => 'view_news',
236+
'name' => PermissionType::NEWS_VIEW->value,
281237
'description' => 'Right to view news'
282238
],
283239
[
284-
'name' => 'administrate_groups',
240+
'name' => PermissionType::GROUPS_ADMINISTRATE->value,
285241
'description' => 'Right to administrate groups'
286242
],
287243
[
288-
'name' => 'forms_edit',
244+
'name' => PermissionType::FORMS_EDIT->value,
289245
'description' => 'Right to edit forms'
290246
]
291247
];
292248

293249
/**
294250
* Configuration array.
295251
*
296-
* @var array<string, string>
252+
* @var array<string, string|null>
297253
*/
298254
protected array $mainConfig = [
299255
'main.currentVersion' => null,
@@ -438,7 +394,7 @@ class Installer extends Setup
438394

439395
/**
440396
* Array with form inputs
441-
* @var array<array>
397+
* @var array<array<string, int|string>>
442398
*/
443399
public array $formInputs = [
444400
// Ask Question inputs
@@ -606,12 +562,10 @@ public function __construct(private readonly System $system)
606562
*/
607563
public static function cleanFailedInstallationFiles(): void
608564
{
609-
// Remove './config/database.php' file: no need of prompt anything to the user
610565
if (file_exists(PMF_ROOT_DIR . '/content/core/config/database.php')) {
611566
unlink(PMF_ROOT_DIR . '/content/core/config/database.php');
612567
}
613568

614-
// Remove './config/ldap.php' file: no need of prompt anything to the user
615569
if (file_exists(PMF_ROOT_DIR . '/content/core/config/ldap.php')) {
616570
unlink(PMF_ROOT_DIR . '/content/core/config/ldap.php');
617571
}

0 commit comments

Comments
 (0)