Code Duplication    Length = 19-21 lines in 2 locations

main/inc/lib/group_portal_manager.lib.php 1 location

@@ 1210-1228 (lines=19) @@
1207
     * @param int $user_id
1208
     * @return bool
1209
     */
1210
    public static function is_group_member($group_id, $user_id = 0)
1211
    {
1212
        if (empty($user_id)) {
1213
            $user_id = api_get_user_id();
1214
        }
1215
        $user_role = GroupPortalManager::get_user_group_role($user_id, $group_id);
1216
        $permissions = array(
1217
            GROUP_USER_PERMISSION_ADMIN,
1218
            GROUP_USER_PERMISSION_MODERATOR,
1219
            GROUP_USER_PERMISSION_READER,
1220
            GROUP_USER_PERMISSION_HRM
1221
        );
1222
1223
        if (in_array($user_role, $permissions)) {
1224
            return true;
1225
        } else {
1226
            return false;
1227
        }
1228
    }
1229
1230
    /**
1231
     * Shows the left column of the group page

main/inc/lib/usergroup.lib.php 1 location

@@ 1548-1568 (lines=21) @@
1545
     * @param int $user_id
1546
     * @return bool
1547
     */
1548
    public function is_group_member($group_id, $user_id = 0)
1549
    {
1550
        if (api_is_platform_admin()) {
1551
            return true;
1552
        }
1553
        if (empty($user_id)) {
1554
            $user_id = api_get_user_id();
1555
        }
1556
        $roles = array(
1557
            GROUP_USER_PERMISSION_ADMIN,
1558
            GROUP_USER_PERMISSION_MODERATOR,
1559
            GROUP_USER_PERMISSION_READER,
1560
            GROUP_USER_PERMISSION_HRM,
1561
        );
1562
        $user_role	= self::get_user_group_role($user_id, $group_id);
1563
        if (in_array($user_role, $roles)) {
1564
            return true;
1565
        } else {
1566
            return false;
1567
        }
1568
    }
1569
1570
    /**
1571
     * Gets the relationship between a group and a User