Plugin Directory

Changeset 3208711


Ignore:
Timestamp:
12/16/2024 04:58:06 PM (14 months ago)
Author:
suaudeau
Message:

4.9.1

*Release Date - 16 December 2024*

  • BUG : Import tool was not functionnal because of a bad check of file extension
Location:
mon-laboratoire/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mon-laboratoire/trunk/Admin/Import/class-import-main.php

    r3125386 r3208711  
    1616    render_main_form( )
    1717    processing()
     18    _process_csv_submited_file( string $file_submit_name )
    1819*/
    1920
     
    116117        $imported_teams = array();
    117118        if ( $this->_check_nonce( 'import_cvs_files' ) ) {
    118             $csv = Csv::getInstance();
    119             if ( isset( $_FILES['submit_import_persons'] ) ) {     
    120                 if ( !empty( $_FILES['submit_import_persons']['tmp_name'] ) ) {     
    121                     $imported_persons = $csv->importCsvToArray( $_FILES['submit_import_persons']['tmp_name'] );
    122                 }
    123             }
    124             if ( isset( $_FILES['submit_import_teams_members'] ) ) {     
    125                 if ( !empty(( $_FILES['submit_import_teams_members']['tmp_name'] ) ) ) {     
    126                     $imported_teams_members = $csv->importCsvToArray( $_FILES['submit_import_teams_members']['tmp_name'] );
    127                 }
    128             }
    129             if ( isset( $_FILES['submit_import_teams'] ) ) {     
    130                 if ( !empty(( $_FILES['submit_import_teams']['tmp_name'] ) ) ) {     
    131                     $imported_teams = $csv->importCsvToArray( $_FILES['submit_import_teams']['tmp_name'] );
    132                 }
    133             }                       
     119            $imported_persons       = $this->_process_csv_submited_file('submit_import_persons' );
     120            $imported_teams_members = $this->_process_csv_submited_file('submit_import_teams_members' );
     121            $imported_teams         = $this->_process_csv_submited_file('submit_import_teams' );                       
    134122            $Pre_Import = New Pre_Import( $imported_persons, $imported_teams_members, $imported_teams );
    135123            $retval .= $Pre_Import->processing( );
     
    146134    }
    147135
     136    /**
     137     * Process import of CSV submited file
     138     * @param string $file_submit_name : Field name of file import
     139     * @return array<int,array<string,string>>
     140     */
     141    private function _process_csv_submited_file( string $file_submit_name ) {
     142        $csv = Csv::getInstance();
     143        $imported_array = array();
     144        if ( isset( $_FILES[ $file_submit_name ] ) && !empty( $_FILES[ $file_submit_name ]['tmp_name'] ) ) {   
     145            $extension = strtolower( pathinfo( $_FILES[ $file_submit_name ]['name'], PATHINFO_EXTENSION ) );
     146            if ( 'csv' === $extension ) {
     147                $imported_array = $csv->importCsvToArray( $_FILES[ $file_submit_name ]['tmp_name'] );
     148            }
     149        }
     150        return $imported_array;
     151    }
     152
    148153}
  • mon-laboratoire/trunk/Admin/class-csv.php

    r3119363 r3208711  
    204204    function importCsvToArray( string $filepath ) : array {
    205205        $table_imported = array();
    206         $extension = strtolower( pathinfo( $filepath, PATHINFO_EXTENSION ) );
    207         if ( 'csv' === $extension ) {
    208             $csvFile = fopen( $filepath, 'r');
    209             if ( $csvFile !== false ) {
    210                 while( ! feof( $csvFile ) ){
    211                     $data = fgetcsv( $csvFile );
    212                     $table_imported[] = $data;
    213                 }
    214                 fclose($csvFile);
    215             }
     206        $csvFile = fopen( $filepath, 'r');
     207        if ( $csvFile !== false ) {
     208            while( ! feof( $csvFile ) ){
     209                $data = fgetcsv( $csvFile );
     210                $table_imported[] = $data;
     211            }
     212            fclose($csvFile);
    216213        }
    217214        return $this->_clean_imported_array( $table_imported );
  • mon-laboratoire/trunk/mon-laboratoire.php

    r3186035 r3208711  
    1212 * Plugin URI:        http://www.monlabo.org
    1313 * Description:       Simplify the management of a research unit's website
    14  * Version:           4.9
     14 * Version:           4.9.1
    1515 * Requires at least: 5.6
    1616 * Requires PHP:      7.2
     
    4848* @return string version
    4949*/
    50 function get_MonLabo_version(): string { return '4.9'; }
     50function get_MonLabo_version(): string { return '4.9.1'; }
    5151
    5252///////////////////////////////////////////////////////////////////////////////////////////
  • mon-laboratoire/trunk/readme.txt

    r3186035 r3208711  
    55Requires at least: 5.6
    66Tested up to: 6.7
    7 Stable tag: 4.9
     7Stable tag: 4.9.1
    88Requires PHP: 7.2
    99License: GPLv3 or later
     
    4242== Changelog ==
    4343
     44= 4.9.1 =
     45*Release Date - 16 December 2024*
     46
     47* BUG : Import tool was not functionnal because of a bad check of file extension
     48
    4449= 4.9 =
    45 *Release Date - 11 November 2024 *
     50*Release Date - 11 November 2024*
    4651
    4752* Evolutions of functionalities :
Note: See TracChangeset for help on using the changeset viewer.