Commit d6971dbf authored by dj3c1t's avatar dj3c1t

import.previous.version: sources licences

parent 2d62aefa
......@@ -256,10 +256,8 @@ class ImportPreviousVersion {
$author->setHasContactForm($mw_groupe["contact_form"] == 1);
$author->setUseCaptcha($mw_groupe["captcha"] == 1);
$em->persist($author);
$this->log("persisting author to database");
$em->flush();
if($mw_groupe["image"]) {
$this->log("add author logo");
$upload_manager->init("sourceml_author_logo", $author->getId());
$media = $upload_manager->importMediaFromLocalFile(
$this->webDir."/".$this->mw_env->path("content")
......@@ -295,6 +293,7 @@ class ImportPreviousVersion {
$em = $this->container->get('doctrine')->getManager();
$sm = $this->container->get('sourceml.source_manager');
$authorRepo = $em->getRepository('Dj3c1tSourceMLBundle:Author');
$licenceRepo = $em->getRepository('Dj3c1tSourceMLBundle:Licence');
$authorRoleRepo = $em->getRepository('Dj3c1tSourceMLBundle:AuthorRole');
$sourceTypeRepo = $em->getRepository("Dj3c1tSourceMLBundle:SourceType");
if(($sources = $this->mw_data->sources(array())) === false) {
......@@ -322,10 +321,18 @@ class ImportPreviousVersion {
$this->ignoreIdGenerator($source);
$source->setId($mw_source["id"]);
$source->setTitle($mw_source["titre"]);
if(isset($mw_source["reference"]["xml"]["url"])) {
if(isset($mw_source["licence"]["id"]) && $mw_source["licence"]["id"]) {
if(!($licence = $licenceRepo->find($mw_source["licence"]["id"]))) {
$this->log("can't find licence ".$mw_source["licence"]["id"]);
$this->log("WARNING skiping source: ".$mw_source["titre"]);
continue;
}
$source->setLicence($licence);
}
if(isset($mw_source["reference"]["xml"]["url"]) && $mw_source["reference"]["xml"]["url"]) {
$source->setReferenceUrl($mw_source["reference"]["xml"]["url"]);
}
if($mw_source["description"]) {
if(isset($mw_source["description"]) && $mw_source["description"]) {
$source->setInfo('description', $mw_source["description"]);
}
if(isset($mw_source["ordre"])) {
......@@ -342,9 +349,7 @@ class ImportPreviousVersion {
}
$source->setSourceType($sourceType);
$em->persist($source);
$this->log("persisting source to database");
$em->flush();
$this->log("add source authors");
foreach($mw_source["groupes"] as $mw_groupe) {
$this->log("add source author: ".$mw_groupe["nom"]);
if(!($author = $authorRepo->find($mw_groupe["id"]))) {
......@@ -364,10 +369,8 @@ class ImportPreviousVersion {
$sourceAuthor->setIsValid(true);
$em->persist($sourceAuthor);
}
$this->log("persisting source authors to database");
$em->flush();
if($mw_source["image"]) {
$this->log("add source logo");
$upload_manager->init("sourceml_source_image", $source->getId());
$media = $upload_manager->importMediaFromLocalFile(
$this->webDir."/".$this->mw_env->path("content")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment