Code Duplication    Length = 15-17 lines in 2 locations

application/models/Privileges/Table.php 1 location

@@ 97-113 (lines=17) @@
94
     * @param integer $roleId
95
     * @return array
96
     */
97
    public function getRolePrivileges($roleId)
98
    {
99
        $cacheKey = 'roles.privileges.'.$roleId;
100
101
        if (!$data = Cache::get($cacheKey)) {
102
            $data = Db::fetchColumn(
103
                "SELECT DISTINCT CONCAT(p.module, ':', p.privilege)
104
                FROM acl_privileges AS p, acl_roles AS r
105
                WHERE p.roleId = r.id AND r.id = ?
106
                ORDER BY CONCAT(p.module, ':', p.privilege)",
107
                array((int) $roleId)
108
            );
109
110
            Cache::set($cacheKey, $data, Cache::TTL_NO_EXPIRY, ['system', 'roles', 'privileges']);
111
        }
112
        return $data;
113
    }
114
}
115

application/models/Roles/Table.php 1 location

@@ 102-116 (lines=15) @@
99
     * @param integer $userId
100
     * @return array of identity
101
     */
102
    public function getUserRolesIdentity($userId)
103
    {
104
        $cacheKey = 'users.roles.'.$userId;
105
        if (!$data = Cache::get($cacheKey)) {
106
            $data = Db::fetchColumn(
107
                "SELECT r.id
108
                FROM acl_roles AS r, acl_users_roles AS u2r
109
                WHERE r.id = u2r.roleId AND u2r.userId = ?
110
                ORDER BY r.id ASC",
111
                array($userId)
112
            );
113
            Cache::set($cacheKey, $data, Cache::TTL_NO_EXPIRY, ['system', 'users', 'roles']);
114
        }
115
        return $data;
116
    }
117
}
118