diff --git a/Application/Controllers/Recette.php b/Application/Controllers/Recette.php index 91f1da7..0f8a820 100644 --- a/Application/Controllers/Recette.php +++ b/Application/Controllers/Recette.php @@ -46,6 +46,10 @@ public function insertRecette($params) { //ajouter une recette unset($params['method']); + + $params['top']="0"; + var_dump("Webservice insert",$params); + $modelRecette = new \Application\Models\Recette(); if($modelRecette->insert($params) ) { diff --git a/Application/Controllers/User.php b/Application/Controllers/User.php index 30213ea..90e023b 100644 --- a/Application/Controllers/User.php +++ b/Application/Controllers/User.php @@ -334,5 +334,13 @@ public function deleteUser($params) { } return $this->setApiResult($deleted); } - + + + + + + + + + } \ No newline at end of file diff --git a/Application/Controllers/ViewRecette.php b/Application/Controllers/ViewRecette.php index 748348c..8288fff 100644 --- a/Application/Controllers/ViewRecette.php +++ b/Application/Controllers/ViewRecette.php @@ -38,33 +38,57 @@ public function __construct() { * @return [json] [json de recettes] */ public function getAllViewRecettes($param) { // obtenir toutes les recettes + + + + + //$where = " 1 ORDER BY `titre` "; - //si on cherche a recevoir qu'un les recettes d'une categorie... - $where = " 1 ORDER BY `titre` "; + if(empty($param['droit']) ){ + //premium s'il n'y a pas de parametre droit + //en attendant que les clients integre ce param + $param['droit']="premium"; + + //return $this->setApiResult(false, true, "la valeur 'droit' n'est pas défini"); + } + + //on effectue le tri par rapport au type de client + if ( $param['droit']==='membre' ) { + $where = " `droit`='1' "; + } else if( $param['droit']==='premium' ) { + $where = " (`droit`='1' OR `droit`='2') "; + }else{ //l'admin a acces à tout + $where=""; + } + + + + //si on cherche a recevoir que les recettes d'une categorie... if(isset($param['id_cat']) && !empty($param['id_cat']) ){ - $where = " `id_cat`={$param['id_cat']} ORDER BY `titre` "; - echo "tri selon la categorie"; + $where .= " AND `id_cat`={$param['id_cat']} ORDER BY `titre` "; + echo "tri selon la categorie"; } else if(isset($param['top']) && !empty($param['top']) ){ - $where=" `top`='1' OR `top`='2' OR `top`='3' ORDER BY `top` "; + $where .=" AND (`top`='1' OR `top`='2' OR `top`='3') ORDER BY `top` "; echo "tri selon le top"; } else if(isset($param['type']) && !empty($param['type']) ){ - $where = " `type`='{$param['type']}' ORDER BY `titre` "; + $where .= " AND `type`='{$param['type']}' ORDER BY `titre` "; echo "tri selon le type"; + }else{ + $where .= " ORDER BY `titre` "; } - unset($param['method'], $param['id_cat'], $param['top']); + unset($param['method'], $param['id_cat'], $param['top'], $param['droit']); - echo "coucou : ".$where; + - var_dump("getAllViewRecettes"); $modelViewAllRecette = new \Application\Models\ViewRecette(); $viewAllRecettes = $modelViewAllRecette->convEnTab($modelViewAllRecette->fetchAll($where) ); if( empty($viewAllRecettes[0]) ){ - $this->message->addError("Aucune Recette"); + return $this->setApiResult(false, true, "Aucune recette"); }else{ //var_dump($viewAllRecettes);