From e1cc82f2dbf965132b3dfce183668b02ea208b6f Mon Sep 17 00:00:00 2001 From: dj3c1t Date: Fri, 9 May 2014 17:41:33 +0200 Subject: [PATCH] algo data groupes_sources --- app/data/modules/xml/sml_data_source_groupes.php | 31 +++++++++++------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/app/data/modules/xml/sml_data_source_groupes.php b/app/data/modules/xml/sml_data_source_groupes.php index cc21ed9..fead1be 100644 --- a/app/data/modules/xml/sml_data_source_groupes.php +++ b/app/data/modules/xml/sml_data_source_groupes.php @@ -32,7 +32,7 @@ { $groupes[$v_rst["id"]] = $v_rst; $groupes[$v_rst["id"]]["id_groupe_status"] = $groupes_status[$v_rst["id"]]; $groupes[$v_rst["id"]]["image_uri"] = - ( $v_rst["image"] ? + ( isset($v_rst["image"]) && $v_rst["image"] ? $env->path("content")."uploads/".$v_rst["image"] : "" ); @@ -75,9 +75,9 @@ $author_ids = array(); foreach($groupes as $i => $groupe) $author_ids[$groupe["id"]] = true; $sgbd = $this->sgbd(); - $_sources = array(); + $authors = array(); if($rst = $sgbd->open_data("sml_sources_authors")){ - while(($_sources !== false) && $v_rst = $sgbd->fetch_data($rst)){ + while(($authors !== false) && $v_rst = $sgbd->fetch_data($rst)){ if(isset($v_rst)){ if( isset($v_rst["id"]) @@ -89,29 +89,26 @@ isset($source_access_ids[$v_rst["id_sources_access"]]) && isset($author_ids[$v_rst["id_author"]]) ){ - $_sources[$v_rst["id_source"]] = array( - "id_source" => $v_rst["id_source"], - "id_author" => $v_rst["id_author"], - ); + if(!isset($authors[$v_rst["id_source"]])){ + $authors[$v_rst["id_source"]] = array(); + } + $authors[$v_rst["id_source"]][] = $v_rst["id_author"]; } } } - else $_sources = false; + else $authors = false; } $sgbd->close_data($rst); } - else $_sources = false; - if($_sources === false) return false; + else $authors = false; + if($authors === false) return false; if($rst = $sgbd->open_data("sml_sources")){ while(($sources !== false) && $v_rst = $sgbd->fetch_data($rst)){ if(isset($v_rst) && isset($v_rst["id"])){ - if(isset($_sources[$v_rst["id"]])){ + if(isset($authors[$v_rst["id"]])){ if(!isset($params["id_class"]) || (isset($v_rst["id_class"]) && ($v_rst["id_class"] == $params["id_class"]))){ - if(!isset($sources[$v_rst["id"]])){ - $sources[$v_rst["id"]] = $v_rst; - $sources[$v_rst["id"]]["authors"] = array(); - } - $sources[$v_rst["id"]]["authors"][] = $_sources[$v_rst["id"]]["id_author"]; + $sources[$v_rst["id"]] = $v_rst; + $sources[$v_rst["id"]]["authors"] = $authors[$v_rst["id"]]; } } } @@ -120,7 +117,7 @@ $sgbd->close_data($rst); } else $sources = false; - if($_sources === false) return false; + if($sources === false) return false; foreach($sources as $id_source => $source){ if($satisfy_all_groupes_access){ if(count($source["authors"]) < count($groupes)){ -- 2.1.4