X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;f=app%2Fcontrollers%2Fusers%2Fpistes.php;h=c1a70dfbfffa69b74ba2f22ef41b82e37b5c22f2;hb=f58d0d306acdf88245f47573bf78dc5497aa03d7;hp=4fd25f64210c36a8728a1b5f3ca1937aae378971;hpb=07d04626b2bd3e64763c10c961e6cfa3c90dc427;p=mw_sourceml diff --git a/app/controllers/users/pistes.php b/app/controllers/users/pistes.php index 4fd25f6..c1a70df 100644 --- a/app/controllers/users/pistes.php +++ b/app/controllers/users/pistes.php @@ -147,9 +147,24 @@ return; } $web_path = $env->path("web"); + $upload_dir = $env->path("content")."uploads/".$this->user["id"]; $_SESSION["upload_dir"] = $web_path.($web_path ? "" : "/").$env->path("content")."uploads/".$this->user["id"]; $users_sources_mod = $env->get_controller("users/sources"); - if($_POST){ + if(isset($_POST["button_derive"])){ + if( + ($origin_source_id = $_POST["button_derive"]) + && ($origin_source_xml_url = $data->source_xml_url($origin_source_id)) + && ($origin_source_xml_content = $data->get_source_xml($origin_source_id)) + ){ + $piste["derivations"][$origin_source_id] = $users_sources_mod->get_source_from_xml( + $env, + $origin_source_xml_url, + $origin_source_xml_content, + true + ); + } + } + elseif($_POST){ if(!($groupe = $data->groupe($_POST["id_groupe"]))){ $env->erreur("Impossible de lire les informations du groupe"); return; @@ -220,6 +235,11 @@ } } if(!$env->messages()){ + if(($image = $data->upload("image", $upload_dir)) === false){ + $env->erreur("erreur lors de l'envoi de l'image. la piste n'a pas été ajoutée"); + return; + } + if($image) $source_infos["image"] = $this->user["id"]."/".$image; if( ( $id_source = $data->add_source( @@ -301,6 +321,7 @@ return; } $web_path = $env->path("web"); + $upload_dir = $env->path("content")."uploads/".$this->user["id"]; $_SESSION["upload_dir"] = $web_path.($web_path ? "" : "/").$env->path("content")."uploads/".$this->user["id"]; if(($compositions = $data->source_compositions(array("id_source" => $piste["id"]))) === false){ $env->erreur("Impossible de lire la liste des compositions"); @@ -315,7 +336,8 @@ $piste = $data->empty_source( array( "id" => $piste["id"], - "groupes" => $piste["groupes"] + "groupes" => $piste["groupes"], + "image" => isset($piste["image"]) ? $piste["image"] : "" ) ); $users_sources_mod = $env->get_controller("users/sources"); @@ -385,6 +407,23 @@ } } if(!$env->messages()){ + if(isset($_POST["del_image"])){ + if($piste["image"]){ + if(!@unlink($env->path("content")."uploads/".$piste["image"])){ + $env->erreur("Impossible d'effacer l'image de la piste"); + return; + } + } + $piste["image"] = ""; + } + else{ + if(($up_image = $data->upload("image", $upload_dir)) === false){ + $env->erreur("Impossible d'uploader l'image"); + return; + } + if($up_image) $piste["image"] = $this->user["id"]."/".$up_image; + } + if($piste["image"]) $source_infos["image"] = $piste["image"]; if( ( $data->set_source( @@ -510,6 +549,18 @@ ); } + function groupes(){ + $env = $this->env(); + if( + !($sources_invitations_controller = $env->get_controller("users/sources_invitations")) + || !$sources_invitations_controller->validate() + ){ + $env->erreur("impossible de valider le controleur users/sources_invitations"); + return; + } + $sources_invitations_controller->source_groupes(); + } + } ?> \ No newline at end of file