Qrz_OneDayAdmin_Model_Cron   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 7
c 3
b 0
f 1
lcom 1
cbo 1
dl 0
loc 58
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
B deactivateOneDayAdmins() 0 23 4
A getAdminRolesModel() 0 4 1
A getAdminUserModel() 0 4 1
A getSystemConfig() 0 4 1
1
<?php
2
3
class Qrz_OneDayAdmin_Model_Cron
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
6
    /**
7
     * @return void
8
     * @author Cristian Quiroz <[email protected]>
9
     */
10
    public function deactivateOneDayAdmins()
11
    {
12
        $oneDayAdminRoles = $this->getSystemConfig()->getOneDayAdminRoles();
13
14
        foreach ($oneDayAdminRoles as $oneDayAdminRole) {
15
            $adminRole = $this->getAdminRolesModel()
16
                ->load($oneDayAdminRole, 'role_name');
17
18
            if (!$adminRole->getId()) {
19
                continue;
20
            }
21
22
            $adminUserIdArray = $adminRole->getRoleUsers();
23
24
            $adminUserCollection = $this->getAdminUserModel()->getCollection()
25
                ->addFieldToFilter('user_id', array('in' => $adminUserIdArray))
26
                ->addFieldToFilter('is_active', 1);
27
28
            foreach ($adminUserCollection as $adminUser) {
29
                $adminUser->setData('is_active', 0)->save();
30
            }
31
        }
32
    }
33
34
    /**
35
     * @return Mage_Admin_Model_Roles
36
     * @author Cristian Quiroz <[email protected]>
37
     */
38
    protected function getAdminRolesModel()
39
    {
40
        return Mage::getModel('admin/roles');
41
    }
42
43
    /**
44
     * @return Mage_Admin_Model_User
45
     * @author Cristian Quiroz <[email protected]>
46
     */
47
    protected function getAdminUserModel()
48
    {
49
        return Mage::getModel('admin/user');
50
    }
51
52
    /**
53
     * @return Qrz_OneDayAdmin_Model_SystemConfig
54
     * @author Cristian Quiroz <[email protected]>
55
     */
56
    protected function getSystemConfig()
57
    {
58
        return Mage::getSingleton('qrz_onedayadmin/systemConfig');
59
    }
60
}
61