Conditions | 3 |
Paths | 4 |
Total Lines | 33 |
Lines | 20 |
Ratio | 60.61 % |
Changes | 0 |
1 | <?php |
||
11 | public function requireDefaultRecords() |
||
12 | { |
||
13 | parent::requireDefaultRecords(); |
||
14 | |||
15 | // Add default author group if no other group exists |
||
16 | $frontend_group = Group::get()->filter("Code", "users-frontend"); |
||
17 | |||
18 | View Code Duplication | if (!$frontend_group->exists()) { |
|
|
|||
19 | $frontend_group = new Group(); |
||
20 | $frontend_group->Code = 'users-frontend'; |
||
21 | $frontend_group->Title = "Frontend Users"; |
||
22 | $frontend_group->Sort = 1; |
||
23 | $frontend_group->write(); |
||
24 | Permission::grant($frontend_group->ID, 'USERS_MANAGE_ACCOUNT'); |
||
25 | |||
26 | DB::alteration_message('Front end users group created', 'created'); |
||
27 | } |
||
28 | |||
29 | // Add a verified users group (only used if we turn on |
||
30 | // verification) |
||
31 | $verify_group = Group::get()->filter("Code", "users-verified"); |
||
32 | |||
33 | View Code Duplication | if (!$verify_group->exists()) { |
|
34 | $verify_group = new Group(); |
||
35 | $verify_group->Code = 'users-verified'; |
||
36 | $verify_group->Title = "Verified Users"; |
||
37 | $verify_group->Sort = 1; |
||
38 | $verify_group->write(); |
||
39 | Permission::grant($verify_group->ID, 'USERS_VERIFIED'); |
||
40 | |||
41 | DB::alteration_message('Verified users group created', 'created'); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.