diff --git a/module/story/control.php b/module/story/control.php index eb9b306212..1e9545dee3 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -2753,11 +2753,10 @@ class story extends control { $siblingID = !empty($_POST['siblingID']) ? $_POST['siblingID'] : 0; $story = $this->story->getByID($siblingID); + $siblings = explode(',', trim($story->siblings, ',')); if(empty($story->siblings)) return $this->send(array('result' => 'fail')); - $siblings = str_replace(",$siblingID", '', $story->siblings); - /* batchUnset siblingID from siblings.*/ $replaceSql = "UPDATE " . TABLE_STORY . " SET siblings = REPLACE(siblings,',$siblingID,', ',') WHERE `product` = $story->product"; $this->dbh->exec($replaceSql); @@ -2766,6 +2765,6 @@ class story extends control $this->dao->update(TABLE_STORY)->set('siblings')->eq('')->where('id')->eq($siblingID)->orWhere('siblings')->eq(',')->exec(); if(!dao::isError()) $this->loadModel('action')->create('story', $siblingID, 'relieved'); - return $this->send(array('result' => 'success', 'data' => $siblings)); + return $this->send(array('result' => 'success', 'silbingsCount' => count($siblings)-1)); } } diff --git a/module/story/js/common.js b/module/story/js/common.js index f0481757a9..51c47c3603 100644 --- a/module/story/js/common.js +++ b/module/story/js/common.js @@ -109,13 +109,13 @@ $('[data-toggle="popover"]').each(function(item) { function relieve(index) { - $.post(relieveURL, {storyID:storyID, siblingID:index}, function(data){ + $.post(relieveURL, {siblingID:index}, function(data){ $('[data-id="' + index + '"]').popover('hide'); if(data.result == 'success') { - if(data.data.length !== 0) $('[data-id="' + index + '"]').parent('li').remove(); - if(data.data.length == 0 || index == storyID) + if(data.silbingsCount != 0) $('[data-id="' + index + '"]').parent('li').remove(); + if(data.silbingsCount == 0 || index == storyID) { $('[href="#legendSiblings"]').parent('li').next('li').addClass('active');; $('[href="#legendSiblings"]').parent('li').remove();