Completed
Push — master ( b0bf1d...042f37 )
by Andreas
14:04
created

midgard_admin_user_plugin   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 24
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _on_initialize() 0 6 1
A generate_password() 0 9 2
1
<?php
2
/**
3
 * @package midgard.admin.user
4
 * @author The Midgard Project, http://www.midgard-project.org
5
 * @copyright The Midgard Project, http://www.midgard-project.org
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 */
8
9
/**
10
 * user editor interface
11
 *
12
 * @package midgard.admin.user
13
 */
14
class midgard_admin_user_plugin extends midcom_baseclasses_components_plugin
15
{
16 16
    public function _on_initialize()
17
    {
18 16
        midcom::get()->auth->require_user_do('midgard.admin.user:access', null, 'midgard_admin_user_plugin');
19 16
        midgard_admin_asgard_plugin::prepare_plugin($this->_l10n->get('midgard.admin.user'), $this->_request_data);
20
21 16
        $this->add_stylesheet(MIDCOM_STATIC_URL . '/midgard.admin.user/usermgmt.css');
22 16
    }
23
24
    /**
25
     * Generate one password
26
     *
27
     * @param int $length
28
     */
29 1
    public static function generate_password($length = 8, $no_similars = true)
30
    {
31 1
        if ($no_similars) {
32 1
            $options = 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789';
33
        } else {
34
            $options = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
35
        }
36
37 1
        return midcom_helper_misc::random_string($length, $options);
38
    }
39
}
40