diff --git a/modules/cmsps/classes/CmsPsPost.php b/modules/cmsps/classes/CmsPsPost.php index cda60a14..baae7e61 100644 --- a/modules/cmsps/classes/CmsPsPost.php +++ b/modules/cmsps/classes/CmsPsPost.php @@ -168,7 +168,7 @@ class CmsPsPost extends ObjectModel { } elseif ($type_relation == 'postcms_product') { return (bool) Db::getInstance()->delete('cmsps_posts_relation_product', 'id_post = '. $this->id); } elseif ($type_relation == 'postcms_pack') { - return (bool) Db::getInstance()->delete('cmsps_posts_relation_pack', 'id_post = '. $this->id); + return (bool) Db::getInstance()->delete('cmsps_posts_relation_pack', 'id_post = '. $this->id); } } diff --git a/modules/cmsps/controllers/admin/AdminCmsPsPosts.php b/modules/cmsps/controllers/admin/AdminCmsPsPosts.php index 0bf735a7..33f3082a 100644 --- a/modules/cmsps/controllers/admin/AdminCmsPsPosts.php +++ b/modules/cmsps/controllers/admin/AdminCmsPsPosts.php @@ -356,54 +356,39 @@ class AdminCmsPsPostsController extends ModuleAdminController { switch ($type) { case 'cms_extrafields_1': $relations = Tools::getValue('input-posts-cms_extrafields_1', array()); - if ($relations) { - if ($this->object->deleteRelations($type, 1)) { - foreach ($relations as $key => $relation) { - $this->object->addRelation($relation, $type, 1); - } - } + $this->object->deleteRelations($type, 1); + foreach ($relations as $key => $relation) { + $this->object->addRelation($relation, $type, 1); } break; case 'cms_extrafields_2': $relations = Tools::getValue('input-posts-cms_extrafields_2', array()); - if ($relations) { - if ($this->object->deleteRelations($type, 2)) { - foreach ($relations as $key => $relation) { - $this->object->addRelation($relation, $type, 2); - } - } + $this->object->deleteRelations($type, 2); + foreach ($relations as $key => $relation) { + $this->object->addRelation($relation, $type, 2); } break; case 'postcms': $relations = Tools::getValue('input-posts-cms', array()); - if ($relations) { - if ($this->object->deleteRelations($type)) { - foreach ($relations as $key => $relation) { - $this->object->addRelation($relation, $type); - } - } + $this->object->deleteRelations($type); + foreach ($relations as $key => $relation) { + $this->object->addRelation($relation, $type); } break; case 'postcms_product': $relations = Tools::getValue('input-posts-cms-product', array()); - if ($relations) { - if ($this->object->deleteRelations($type)) { - foreach ($relations as $key => $relation) { - $this->object->addRelation($relation, $type); - } - } + $this->object->deleteRelations($type); + foreach ($relations as $key => $relation) { + $this->object->addRelation($relation, $type); } break; case 'postcms_pack': $relations = Tools::getValue('input-posts-cms-pack', array()); - if ($relations) { - if ($this->object->deleteRelations($type)) { - foreach ($relations as $key => $relation) { - $this->object->addRelation($relation, $type); - } - } + $this->object->deleteRelations($type); + foreach ($relations as $key => $relation) { + $this->object->addRelation($relation, $type); } - break; + break; default: return FALSE; break; @@ -435,7 +420,7 @@ class AdminCmsPsPostsController extends ModuleAdminController { && !empty($this->object->id) ) { $dir_dst = _CMS_POST_IMG_DIR_.$this->object->id; - $this->_createDirectoryImage($dir_dst); + $this->createDirectoryImage($dir_dst); foreach ($_FILES as $key => $file) { foreach ($this->object->img_size as $key => $img) { $dest = $dir_dst.'/'.$img['name'].'.jpg'; @@ -445,11 +430,10 @@ class AdminCmsPsPostsController extends ModuleAdminController { } } - private function _createDirectoryImage($dir_dst) { + private function createDirectoryImage($dir_dst) { if (!is_dir($dir_dst)) { mkdir($dir_dst); } } - } diff --git a/modules/cmsps/voting.js b/modules/cmsps/voting.js index 0ba0b32c..108ce950 100644 --- a/modules/cmsps/voting.js +++ b/modules/cmsps/voting.js @@ -3,7 +3,6 @@ $( document ).ready(function() { var boxes = $(this).parent('.vote_box'); var id_post = $(this).data('id'); var uri = baseUri+'modules/cmsps/ajax_voting.php'; - var nb_vote = $(boxes).children('.nb_vote'); $.ajax({ url : uri, @@ -21,7 +20,10 @@ $( document ).ready(function() { if($(boxes).children('.already_vote').length == 0) { $(boxes).append('Merci'); } - $(nb_vote).html(json.nb_vote); + $('.nb_vote_'+id_post).each(function(index) { + $(this).html(json.nb_vote); + }); + } } }, @@ -30,4 +32,4 @@ $( document ).ready(function() { }, }); }); -}); \ No newline at end of file +}); diff --git a/themes/toutpratique/post_img.tpl b/themes/toutpratique/post_img.tpl index 01a98c9e..3b47cca1 100644 --- a/themes/toutpratique/post_img.tpl +++ b/themes/toutpratique/post_img.tpl @@ -17,7 +17,7 @@