function update($nom, $comment, $id_pclass = 0) { global $dbh; global $msg; global $include_path; global $thesaurus_classement_mode_pmb, $thesaurus_classement_defaut; global $thesaurus_concepts_active; if (!$nom) { return false; } // nettoyage de la chaîne en entrée $nom = clean_string($nom); if ($thesaurus_classement_mode_pmb == 0 || $id_pclass == 0) { $id_pclass = $thesaurus_classement_defaut; } $requete = "SET indexint_name='{$nom}', "; $requete .= "indexint_comment='{$comment}', "; $requete .= "num_pclass='{$id_pclass}', "; $requete .= "index_indexint=' " . strip_empty_words($nom . " " . $comment) . " '"; if ($this->indexint_id) { // update $requete = 'UPDATE indexint ' . $requete; $requete .= ' WHERE indexint_id=' . $this->indexint_id . ' LIMIT 1;'; if (pmb_mysql_query($requete, $dbh)) { $aut_link = new aut_link(AUT_TABLE_INDEXINT, $this->indexint_id); $aut_link->save_form(); $aut_pperso = new aut_pperso("indexint", $this->indexint_id); $aut_pperso->save_form(); indexint::update_index($this->indexint_id); audit::insert_modif(AUDIT_INDEXINT, $this->indexint_id); } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[indexint_update], $msg[indexint_unable]); return FALSE; } } else { // création : s'assurer que le nom n'existe pas déjà $dummy = "SELECT * FROM indexint WHERE indexint_name = '" . $nom . "' and num_pclass='" . $id_pclass . "' LIMIT 1 "; $check = pmb_mysql_query($dummy, $dbh); if (pmb_mysql_num_rows($check)) { require_once "{$include_path}/user_error.inc.php"; warning($msg[indexint_create], $msg[indexint_exists]); return FALSE; } $requete = 'INSERT INTO indexint ' . $requete . ';'; if (pmb_mysql_query($requete, $dbh)) { $this->indexint_id = pmb_mysql_insert_id(); $aut_link = new aut_link(AUT_TABLE_INDEXINT, $this->indexint_id); $aut_link->save_form(); $aut_pperso = new aut_pperso("indexint", $this->indexint_id); $aut_pperso->save_form(); audit::insert_creation(AUDIT_INDEXINT, $this->indexint_id); } else { require_once "{$include_path}/user_error.inc.php"; warning($msg[indexint_create], $msg[indexint_unable_create]); return FALSE; } } // Indexation concepts if ($thesaurus_concepts_active == 1) { $index_concept = new index_concept($this->indexint_id, TYPE_INDEXINT); $index_concept->save(); } // Mise à jour des vedettes composées contenant cette autorité vedette_composee::update_vedettes_built_with_element($this->indexint_id, "indexint"); return TRUE; }
static function import($name, $comment = "", $id_pclassement = "", $statut = 1) { global $dbh; global $pmb_limitation_dewey; global $thesaurus_classement_defaut; // check sur la variable passée en paramètre if (!$name) { return 0; } if ($pmb_limitation_dewey < 0) { return 0; } if ($pmb_limitation_dewey) { $name = substr($name, 0, $pmb_limitation_dewey); } // tentative de récupérer l'id associée dans la base (implique que l'autorité existe) // préparation de la requête $key = addslashes($name); $comment = addslashes($comment); if (!$id_pclassement) { $num_pclass = $thesaurus_classement_defaut; } else { $num_pclass = $id_pclassement; } //On regarde si le plan de classement existe $query = "SELECT name_pclass FROM pclassement WHERE id_pclass='" . addslashes($num_pclass) . "' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT pclassement " . $query); } if (!pmb_mysql_num_rows($result)) { //Le plan de classement demandé n'existe pas return 0; // -> pas d'import } $query = "SELECT indexint_id FROM indexint WHERE indexint_name='" . rtrim(substr($key, 0, 255)) . "' and num_pclass='{$num_pclass}' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT indexint " . $query); } // résultat // récupération du résultat de la recherche $tindexint = pmb_mysql_fetch_object($result); // du résultat et récupération éventuelle de l'id if ($tindexint->indexint_id) { return $tindexint->indexint_id; } // id non-récupérée >> création if (!$id_pclassement) { $num_pclass = $thesaurus_classement_defaut; } else { $num_pclass = $id_pclassement; } $query = "INSERT INTO indexint SET indexint_name='{$key}', indexint_comment='{$comment}', index_indexint=' " . strip_empty_words($key . " " . $comment) . " ', num_pclass={$num_pclass} "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into indexint " . $query); } $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_INDEXINT, $id); //update authority informations $authority = new authority(0, $id, AUT_TABLE_INDEXINT); $authority->set_num_statut($statut); $authority->update(); indexint::update_index($id); return $id; }