예제 #1
0
 function delete()
 {
     global $dbh;
     global $msg;
     if (!$this->id) {
         // impossible d'accéder à cette notice de collection
         return $msg[406];
     }
     // récupération du nombre de notices affectées
     $requete = "SELECT COUNT(1) FROM notices WHERE ";
     $requete .= "coll_id={$this->id}";
     $res = pmb_mysql_query($requete, $dbh);
     $nbr_lignes = pmb_mysql_result($res, 0, 0);
     if (!$nbr_lignes) {
         // on regarde si la collection a des collections enfants
         $requete = "SELECT COUNT(1) FROM sub_collections WHERE ";
         $requete .= "sub_coll_parent=" . $this->id;
         $res = pmb_mysql_query($requete, $dbh);
         $nbr_lignes = pmb_mysql_result($res, 0, 0);
         if (!$nbr_lignes) {
             // On regarde si l'autorité est utilisée dans des vedettes composées
             $attached_vedettes = vedette_composee::get_vedettes_built_with_element($this->id, "collection");
             if (count($attached_vedettes)) {
                 // Cette autorité est utilisée dans des vedettes composées, impossible de la supprimer
                 return '<strong>' . $this->display . "</strong><br />" . $msg["vedette_dont_del_autority"];
             }
             // effacement dans la table des collections
             $requete = "DELETE FROM collections WHERE collection_id=" . $this->id;
             $result = pmb_mysql_query($requete, $dbh);
             //Import d'autorité
             collection::delete_autority_sources($this->id);
             // liens entre autorités
             $aut_link = new aut_link(AUT_TABLE_COLLECTIONS, $this->id);
             $aut_link->delete();
             $aut_pperso = new aut_pperso("collection", $this->id);
             $aut_pperso->delete();
             // nettoyage indexation concepts
             $index_concept = new index_concept($this->id, TYPE_COLLECTION);
             $index_concept->delete();
             // nettoyage indexation
             indexation_authority::delete_all_index($this->id, "authorities", "id_authority", AUT_TABLE_COLLECTIONS);
             // effacement de l'identifiant unique d'autorité
             $authority = new authority(0, $this->id, AUT_TABLE_COLLECTIONS);
             $authority->delete();
             audit::delete_audit(AUDIT_COLLECTION, $this->id);
             return false;
         } else {
             // Cet collection a des sous-collections, impossible de la supprimer
             return '<strong>' . $this->display . "</strong><br />{$msg[408]}";
         }
     } else {
         // Cette collection est utilisé dans des notices, impossible de la supprimer
         return '<strong>' . $this->display . "</strong><br />{$msg[407]}";
     }
 }
예제 #2
0
}
require_once "{$class_path}/collection.class.php";
// la taille d'un paquet de notices
$lot = COLLECTION_PAQUET_SIZE;
// defini dans ./params.inc.php
// taille de la jauge pour affichage
$jauge_size = GAUGE_SIZE;
// initialisation de la borne de départ
if (!isset($start)) {
    $start = 0;
}
$v_state = urldecode($v_state);
print "<br /><br /><h2 align='center'>" . htmlentities($msg["nettoyage_suppr_collections"], ENT_QUOTES, $charset) . "</h2>";
$query = mysql_query("SELECT collection_id from collections left join notices on collection_id=coll_id left join sub_collections on sub_coll_parent=collection_id where coll_id is null and sub_coll_parent is null ");
$affected = 0;
if ($affected = mysql_num_rows($query)) {
    while ($ligne = mysql_fetch_object($query)) {
        $coll = new collection($ligne->collection_id);
        $coll->delete();
    }
}
//Nettoyage des informations d'autorités pour les collections
collection::delete_autority_sources();
$query = mysql_query("update notices left join collections ON collection_id=coll_id SET coll_id=0, subcoll_id=0 WHERE collection_id is null");
$spec = $spec - CLEAN_COLLECTIONS;
$v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg["nettoyage_suppr_collections"], ENT_QUOTES, $charset) . " :";
$v_state .= $affected . " " . htmlentities($msg["nettoyage_res_suppr_collections"], ENT_QUOTES, $charset);
$opt = mysql_query('OPTIMIZE TABLE collections');
// mise à jour de l'affichage de la jauge
print "<table border='0' align='center' width='{$table_size}' cellpadding='0'><tr><td class='jauge'>\n   \t\t<img src='../../images/jauge.png' width='{$jauge_size}' height='16'></td></tr></table>\n  \t\t<div align='center'>100%</div>";
print "\n\t<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t</form>\n\t<script type=\"text/javascript\"><!--\n\t\tdocument.forms['process_state'].submit();\n\t\t-->\n\t</script>";