diff --git a/.gitattributes b/.gitattributes index 8369a82af18f08122eabf5e5bb118790ada8604d..67959683a613c3b88436e497ab881412955236e3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5610,6 +5610,7 @@ scripts/emacs/popup-0.5/popup-autoloads.el -text scripts/emacs/popup-0.5/popup-pkg.el -text scripts/emacs/popup-0.5/popup.el -text scripts/find_tests.php -text +scripts/import_avis_csv.php -text scripts/import_sitotheque.php -text scripts/insert_licence.sh -text scripts/iosrd.sh -text diff --git a/scripts/import_avis_csv.php b/scripts/import_avis_csv.php new file mode 100644 index 0000000000000000000000000000000000000000..bc22b3fdfe2c297e0daf9b0042f5a1b737418e9f --- /dev/null +++ b/scripts/import_avis_csv.php @@ -0,0 +1,58 @@ +<?php +/** + * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved. + * + * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * AFI-OPAC 2.0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with AFI-OPAC 2.0; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +define("BASE_URL", "/"); + +set_include_path('.' . PATH_SEPARATOR . './library' + . PATH_SEPARATOR . '../ZendFramework-1.6.2/library' + . PATH_SEPARATOR . get_include_path()); + +include_once "local.php"; +include_once "fonctions/fonctions.php"; +require_once "Zend/Loader.php"; +require_once "startup.php"; + +setupOpac(); + +$handle = fopen('avis.csv', 'r'); +while (($line = fgetcsv($handle, 0)) !== FALSE) { + $id_origine = $line[0]; + $entete = $line[1]; + $date = $line[2]; + $avis=$line[3]; + if (!$exemplaire = Class_Exemplaire::findFirstBy(['id_origine' => $id_origine])) + continue; + $id_notice = $exemplaire->getIdNotice(); + + $datas=['id_user' => 2, + 'clef_oeuvre' => $exemplaire->getNotice()->getClefOeuvre(), + 'id_notice' => $id_notice, + 'date_avis' => implode('-', array_reverse(explode('/', $date))), + 'note' => 5, + 'entete' => $entete, + 'avis' => str_replace('"', '\"', $avis), + 'statut' => 1, + 'abon_ou_bib' => 1]; + + + echo "insert into notices_avis(id_user, clef_oeuvre, id_notice, date_avis, note, entete, avis, statut, abon_ou_bib) values(\"".implode("\",\"", array_values($datas))."\");\n"; +} + +?> \ No newline at end of file