Completed
Push — 1 ( 13c7dd...13037b )
by Morven
01:38
created

code/extensions/Ext_Users_Group.php (2 issues)

duplicate/similar code.

Duplication Informational

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
/**
4
 * Overwrite group object so we can setup some more default groups
5
 */
6
class Ext_Users_Group extends DataExtension
7
{
8
    public function requireDefaultRecords()
9
    {
10
        parent::requireDefaultRecords();
11
12
        // Add default author group if no other group exists
13
        $frontend_group = Group::get()->filter("Code", "users-frontend");
14
15 View Code Duplication
        if (!$frontend_group->exists()) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
16
            $frontend_group = new Group();
17
            $frontend_group->Code = 'users-frontend';
18
            $frontend_group->Title = "Frontend Users";
19
            $frontend_group->Sort = 1;
20
            $frontend_group->write();
21
            Permission::grant($frontend_group->ID, 'USERS_MANAGE_ACCOUNT');
22
23
            DB::alteration_message('Front end users group created', 'created');
24
        }
25
26
        // Add a verified users group (only used if we turn on
27
        // verification)
28
        $verify_group = Group::get()->filter("Code", "users-verified");
29
30 View Code Duplication
        if (!$verify_group->exists()) {
0 ignored issues
show
This code seems to be duplicated across your project.

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.

Loading history...
31
            $verify_group = new Group();
32
            $verify_group->Code = 'users-verified';
33
            $verify_group->Title = "Verified Users";
34
            $verify_group->Sort = 1;
35
            $verify_group->write();
36
            Permission::grant($verify_group->ID, 'USERS_VERIFIED');
37
38
            DB::alteration_message('Verified users group created', 'created');
39
        }
40
    }
41
}
42