Code Duplication    Length = 17-18 lines in 2 locations

application/models/Privileges/Table.php 1 location

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

application/models/Roles/Table.php 1 location

@@ 102-118 (lines=17) @@
99
     * @param integer $userId
100
     * @return array of identity
101
     */
102
    public function getUserRolesIdentity($userId)
103
    {
104
        $cacheKey = 'roles:user:'.$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);
114
            Cache::addTag($cacheKey, 'roles');
115
            Cache::addTag($cacheKey, 'user:'.$userId);
116
        }
117
        return $data;
118
    }
119
}
120