$arrayIdImpactes = array(); $synchro_rdf = new synchro_rdf(); $noeud = new noeuds($id_to_delete); $thes = new thesaurus($noeud->num_thesaurus); //parent if ($noeud->num_parent != $thes->num_noeud_racine) { $arrayIdImpactes[] = $noeud->num_parent; } //renvoi_voir if ($noeud->num_renvoi_voir) { $arrayIdImpactes[] = $noeud->num_renvoi_voir; } //on supprime le rdf if (count($arrayIdImpactes)) { foreach ($arrayIdImpactes as $idNoeud) { $synchro_rdf->delConcept($idNoeud); } } $synchro_rdf->delConcept($id_to_delete); } // nettoyage indexation concepts $index_concept = new index_concept($id_to_delete, TYPE_CATEGORY); $index_concept->delete(); noeuds::delete($id_to_delete); //On remet à jour les noeuds impactes if ($pmb_synchro_rdf) { if (count($arrayIdImpactes)) { foreach ($arrayIdImpactes as $idNoeud) { $synchro_rdf->storeConcept($idNoeud); } }
//enfants $res = noeuds::listChilds($id, 1); if (pmb_mysql_num_rows($res)) { while ($row = pmb_mysql_fetch_array($res)) { if (!count($arrayIdImpactes) || !in_array($row[0], $arrayIdImpactes)) { $arrayIdImpactes[] = $row[0]; } } } //renvoi_voir if ($noeud->num_renvoi_voir) { if (!count($arrayIdImpactes) || !in_array($noeud->num_renvoi_voir, $arrayIdImpactes)) { $arrayIdImpactes[] = $noeud->num_renvoi_voir; } } //on met le tout à jour $synchro_rdf = new synchro_rdf(); if (count($arrayIdImpactes)) { foreach ($arrayIdImpactes as $idNoeud) { $synchro_rdf->delConcept($idNoeud); $synchro_rdf->storeConcept($idNoeud); } } //On met à jour le thésaurus pour les topConcepts $synchro_rdf->updateAuthority($id_thes, 'thesaurus'); } if ($user_input != "") { include './autorites/subjects/search.inc.php'; } else { include './autorites/subjects/default.inc.php'; }
function replace($by = 0, $link_save = 0) { global $msg, $dbh; global $pmb_synchro_rdf; if ($this->id_noeud == $by || !$this->id_noeud || !$by) { return $msg["categ_imposible_remplace_elle_meme"]; } $aut_link = new aut_link(AUT_TABLE_CATEG, $this->id_noeud); // "Conserver les liens entre autorités" est demandé if ($link_save) { // liens entre autorités $aut_link->add_link_to(AUT_TABLE_CATEG, $by); } $aut_link->delete(); //synchro_rdf : on empile les noeuds impactés pour les traiter plus loin if ($pmb_synchro_rdf) { $arrayIdImpactes = array(); $arrayThesImpactes = array(); $thes = thesaurus::getByEltId($this->id_noeud); $arrayThesImpactes[] = $thes->id_thesaurus; //parent if ($this->num_parent != $thes->num_noeud_racine) { $arrayIdImpactes[] = $this->num_parent; } //enfants $res = noeuds::listChilds($this->id_noeud, 1); if (pmb_mysql_num_rows($res)) { while ($row = pmb_mysql_fetch_array($res)) { $arrayIdImpactes[] = $row[0]; } } //renvoi_voir if ($this->num_renvoi_voir) { $arrayIdImpactes[] = $this->num_renvoi_voir; } } $noeuds_a_garder = new noeuds($by); //Si les noeuds sont du même thésaurus if ($noeuds_a_garder->num_thesaurus == $this->num_thesaurus) { //On déplace les catégories qui renvoi vers l'ancien noeuds pour qu'elle renvoie vers le nouveau if (noeuds::isTarget($this->id_noeud)) { $requete = "UPDATE noeuds SET num_renvoi_voir='" . $by . "' WHERE num_renvoi_voir='" . $this->id_noeud . "' and id_noeud!='" . $by . "' "; @pmb_mysql_query($requete, $dbh); } //On garde les liens voir_aussi $requete = "UPDATE ignore voir_aussi SET num_noeud_orig='" . $by . "' WHERE num_noeud_orig='" . $this->id_noeud . "' and num_noeud_dest!='" . $by . "' "; @pmb_mysql_query($requete, $dbh); $requete = "UPDATE ignore voir_aussi SET num_noeud_dest='" . $by . "' WHERE num_noeud_dest='" . $this->id_noeud . "' and num_noeud_orig!='" . $by . "'"; @pmb_mysql_query($requete, $dbh); } if (noeuds::isTarget($this->id_noeud)) { //Si le noeuds à supprimé est utilisé pour des renvois et qu'il reste des liens on les supprime //On supprime les renvoies $requete = "UPDATE noeuds SET num_renvoi_voir='0' WHERE num_renvoi_voir='" . $this->id_noeud . "'"; @pmb_mysql_query($requete, $dbh); } //On déplace les notices liées $requete = "UPDATE ignore notices_categories SET num_noeud='" . $by . "' where num_noeud = '" . $this->id_noeud . "' "; @pmb_mysql_query($requete, $dbh); //nettoyage d'autorities_sources $query = "select * from authorities_sources where num_authority = " . $this->id_noeud . " and authority_type = 'category'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { while ($row = pmb_mysql_fetch_object($result)) { if ($row->authority_favorite == 1) { //on suprime les références si l'autorité a été importée... $query = "delete from notices_authorities_sources where num_authority_source = " . $row->id_authority_source; pmb_mysql_result($query); $query = "delete from authorities_sources where id_authority_source = " . $row->id_authority_source; pmb_mysql_result($query); } else { //on fait suivre le reste $query = "update authorities_sources set num_authority = " . $by . " where num_authority_source = " . $row->id_authority_source; pmb_mysql_query($query); } } } //On supprime le noeuds $this->delete(); // effacement de l'identifiant unique d'autorité $authority = new authority(0, $this->id_noeud, AUT_TABLE_CATEG); $authority->delete(); //synchro_rdf if ($pmb_synchro_rdf) { //on ajoute les noeuds impactés par le $by $thesBy = thesaurus::getByEltId($by); if (!in_array($thesBy->id_thesaurus, $arrayThesImpactes)) { $arrayThesImpactes[] = $thesBy->id_thesaurus; } $arrayIdImpactes[] = $by; //parent if ($noeuds_a_garder->num_parent != $thesBy->num_noeud_racine) { $arrayIdImpactes[] = $noeuds_a_garder->num_parent; } //enfants $res = noeuds::listChilds($noeuds_a_garder->id_noeud, 1); if (pmb_mysql_num_rows($res)) { while ($row = pmb_mysql_fetch_array($res)) { $arrayIdImpactes[] = $row[0]; } } //renvoi_voir if ($noeuds_a_garder->num_renvoi_voir) { $arrayIdImpactes[] = $noeuds_a_garder->num_renvoi_voir; } //On met le tout à jour $synchro_rdf = new synchro_rdf(); $synchro_rdf->delConcept($this->id_noeud); if (count($arrayIdImpactes)) { foreach ($arrayIdImpactes as $idNoeud) { $synchro_rdf->delConcept($idNoeud); $synchro_rdf->storeConcept($idNoeud); } } if (count($arrayThesImpactes)) { foreach ($arrayThesImpactes as $idThes) { $synchro_rdf->updateAuthority($idThes, 'thesaurus'); } } } return ""; }
function delete($id_thes = 0) { global $dbh; global $msg; global $pmb_synchro_rdf; if (!$id_thes) { $id_thes = $this->id_thesaurus; } if ($pmb_synchro_rdf) { $synchro_rdf = new synchro_rdf(); } $q = "select id_noeud from noeuds where num_thesaurus = '" . $id_thes . "' "; $r = mysql_query($q, $dbh); while ($row = mysql_fetch_row($r)) { noeuds::delete($row[0]); /*$q1 = "delete from categories where num_noeud = '".$row[0]."' "; $r1 = mysql_query($q1, $dbh); $q2 = "delete from noeuds where id_noeud = '".$row[0]."' "; $r2 = mysql_query($q2, $dbh); */ if ($pmb_synchro_rdf) { $synchro_rdf->delConcept($row[0]); } } $q = "delete from thesaurus where id_thesaurus = '" . $id_thes . "' "; $r = mysql_query($q, $dbh); if ($pmb_synchro_rdf) { $synchro_rdf->delThesaurusDefinition($id_thes); } }