Code Duplication    Length = 14-14 lines in 3 locations

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

@@ 976-989 (lines=14) @@
973
        }
974
975
        // This is the common name for the new photos.
976
        if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
977
            $old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
978
            $filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
979
            $filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
980
        } else {
981
            $filename = api_replace_dangerous_char($filename);
982
            if (PREFIX_IMAGE_FILENAME_WITH_UID) {
983
                $filename = uniqid('').'_'.$filename;
984
            }
985
            // We always prefix user photos with user ids, so on setting
986
            // api_get_setting('split_users_upload_directory') === 'true'
987
            // the correspondent directories to be found successfully.
988
            $filename = $group_id.'_'.$filename;
989
        }
990
991
        // Storing the new photos in 4 versions with various sizes.
992

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

@@ 1103-1116 (lines=14) @@
1100
        }
1101
1102
        // This is the common name for the new photos.
1103
        if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
1104
            $old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
1105
            $filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
1106
            $filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
1107
        } else {
1108
            $filename = api_replace_dangerous_char($filename);
1109
            if (PREFIX_IMAGE_FILENAME_WITH_UID) {
1110
                $filename = uniqid('').'_'.$filename;
1111
            }
1112
            // We always prefix user photos with user ids, so on setting
1113
            // api_get_setting('split_users_upload_directory') === 'true'
1114
            // the correspondent directories to be found successfully.
1115
            $filename = $group_id.'_'.$filename;
1116
        }
1117
1118
        // Storing the new photos in 4 versions with various sizes.
1119

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

@@ 1623-1636 (lines=14) @@
1620
        }
1621
1622
        // This is the common name for the new photos.
1623
        if (KEEP_THE_NAME_WHEN_CHANGE_IMAGE && !empty($old_file)) {
1624
            $old_extension = strtolower(substr(strrchr($old_file, '.'), 1));
1625
            $filename = in_array($old_extension, $allowed_types) ? substr($old_file, 0, -strlen($old_extension)) : $old_file;
1626
            $filename = (substr($filename, -1) == '.') ? $filename.$extension : $filename.'.'.$extension;
1627
        } else {
1628
            $filename = api_replace_dangerous_char($filename);
1629
            if (PREFIX_IMAGE_FILENAME_WITH_UID) {
1630
                $filename = uniqid('').'_'.$filename;
1631
            }
1632
            // We always prefix user photos with user ids, so on setting
1633
            // api_get_setting('split_users_upload_directory') === 'true'
1634
            // the correspondent directories to be found successfully.
1635
            $filename = $user_id.'_'.$filename;
1636
        }
1637
1638
        //Crop the image to adjust 1:1 ratio
1639
        $image = new Image($source_file);