From 62c949146f08a71b7a366d0097c24e0af45c7339 Mon Sep 17 00:00:00 2001 From: efalcy <efalcy@git-test.afi-sa.fr> Date: Wed, 29 May 2013 13:31:25 +0000 Subject: [PATCH] Paniers : Ajout d'un script pour mettre a jour les cles notices par rapport aux id origines --- .gitattributes | 1 + scripts/majNoticesPanier.php | 67 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 scripts/majNoticesPanier.php diff --git a/.gitattributes b/.gitattributes index f15eab75bff..082cc158d48 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5600,6 +5600,7 @@ scripts/find_tests.php -text scripts/import_sitotheque.php -text scripts/insert_licence.sh -text scripts/iosrd.sh -text +scripts/majNoticesPanier.php -text scripts/majPaniers.php -text scripts/md5base64.pl -text scripts/monitor_recherche.php -text diff --git a/scripts/majNoticesPanier.php b/scripts/majNoticesPanier.php new file mode 100644 index 00000000000..6152d3cba7c --- /dev/null +++ b/scripts/majNoticesPanier.php @@ -0,0 +1,67 @@ +<?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(); +$mysql_file = tempnam("/tmp", "paniersupdate"); +$handle=fopen($mysql_file,'w'); +$paniers = Class_PanierNotice::findAllBy(['where' => 'id_panier<234']); +foreach($paniers as $panier) { + $cles = []; + $ids_origine=$panier->getIdsOrigine(); + if ($ids_origine=='') + continue; + $ids=explode(';',$ids_origine); + foreach ($ids as $id) { + + $exemplaire=Class_Exemplaire::findFirstBy(['id_origine'=>$id]); + if (!$exemplaire) { + echo "id not found=".$id; + continue; + } + $notice = $exemplaire->getNotice(); + if (!$notice) + echo "notice non trouvee "; + $cles[]=$notice->getClefAlpha(); + + } + fwrite($handle,'update notices_paniers set notices="'.$panier->getNotices().'" where id_panier='.$panier->getIdPanier().";"."\n"); + + if ($cles && sizeof($cles)>0) { + $panier->setNotices(implode(';',$cles)); + $panier->save(); + } + +} +fclose($handle); + + + +?> -- GitLab