Completed
Push — 1 ( 9b7a9d...a879de )
by Morven
07:43
created

code/Users.php (2 issues)

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
 * Root class for users, this will mostly be used to store generic
5
 * config, but will probably be extended in future to provide additional
6
 * functionality.
7
 *
8
 * @author i-lateral (http://www.i-lateral.com)
9
 * @package users
10
 */
11
class Users extends Object
12
{
13
14
    /**
15
     * Stipulate if a user requires verification. NOTE this does not
16
     * actually deny the user the ability to login, it only alerts them
17
     * that they need validiation
18
     *
19
     * @var Boolean
20
     * @config
21
     */
22
    private static $require_verification = true;
23
24
    /**
25
     * Stipulate whether to send a verification email to users after
26
     * registration
27
     *
28
     * @var Boolean
29
     * @config
30
     */
31
    private static $send_verification_email = true;
32
33
    /**
34
     * Stipulate the sender address for emails sent from this module. If
35
     * not set, use the default @Email.admin_email instead.
36
     *
37
     * @var strong
38
     * @config
39
     */
40
    private static $send_email_from;
41
42
    /**
43
     * Auto login users after registration
44
     *
45
     * @var Boolean
46
     * @config
47
     */
48
    private static $login_after_register = true;
49
50
    /**
51
     * Add new users to the following groups. This is a list of group codes.
52
     * Adding a new code will add the user to this group
53
     *
54
     * @var array
55
     * @config
56
     */
57
    private static $new_user_groups = array(
0 ignored issues
show
The property $new_user_groups is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
58
        "users-frontend"
59
    );
60
61
    /**
62
     * Add a group to the list of groups a new user is added to on
63
     * registering.
64
     *
65
     * @param string Group code that will be used
66
     */
67
    public static function addNewUserGroup($code)
68
    {
69
        Deprecation::notice("1.3", "addNewUserGroup depreciated, use global config instead");
70
        self::config()->new_user_groups[] = $code;
71
    }
72
73
    /**
74
     * Remove a group from the list of groups a new user is added to on
75
     * registering.
76
     *
77
     * @param string Group code that will be used
78
     */
79
    public static function removeNewUserGroup($code)
80
    {
81
        if (isset(self::config()->new_user_groups[$code])) {
82
            unset(self::config()->new_user_groups[$code]);
83
        }
84
    }
85
86
    /**
87
     * Groups a user will be added to when verified. This should be an
88
     * array of group "codes", NOT names or ID's
89
     *
90
     * @var array
91
     * @config
92
     */
93
    private static $verification_groups = array(
0 ignored issues
show
The property $verification_groups is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
94
        "users-verified"
95
    );
96
97
    /**
98
     * Add a group to the list of groups a new user is added to on
99
     * registering.
100
     *
101
     * @param string Group code that will be used
102
     */
103
    public static function addVerificationGroup($code)
104
    {
105
        Deprecation::notice("1.3", "addVerificationGroup depreciated, use global config instead");
106
        self::config()->verification_groups[] = $code;
107
    }
108
109
    /**
110
     * Remove a group from the list of groups a new user is added to on
111
     * registering.
112
     *
113
     * @param string Group code that will be used
114
     */
115
    public static function removeVerificationGroup($code)
116
    {
117
        if (isset(self::config()->verification_groups[$code])) {
118
            unset(self::config()->verification_groups[$code]);
119
        }
120
    }
121
}
122