diff --git a/.gitattributes b/.gitattributes index f15eab75bff463844d6660cc5c3c0733c577f205..082cc158d4866a427ad1f9d781893055eb7ebd8f 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 0000000000000000000000000000000000000000..6152d3cba7c3b59ad08fff594888488aab6cd93d --- /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); + + + +?>