Skip to content

Commit

Permalink
Add the code for deleting workflow comment
Browse files Browse the repository at this point in the history
  • Loading branch information
s-nakajima committed May 21, 2015
1 parent a5cda63 commit d376bc5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Model/Bbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,16 @@ public function deleteBbs($data) {
$dataSource = $this->getDataSource();
$dataSource->begin();

$conditions = array(
$this->alias . '.key' => $data['Bbs']['key']
);
$bbses = $this->find('list', array(
'recursive' => -1,
'conditions' => $conditions,
)
);
$bbsIds = array_keys($bbses);

try {
if (! $this->deleteAll(array($this->alias . '.key' => $data['Bbs']['key']), false, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
Expand All @@ -264,14 +274,19 @@ public function deleteBbs($data) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}

if (! $this->BbsArticle->deleteAll(array($this->BbsArticle->alias . '.bbs_id' => $data['Bbs']['id']), false, false)) {
if (! $this->BbsArticle->deleteAll(array($this->BbsArticle->alias . '.bbs_id' => $bbsIds), false, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}

if (! $this->BbsArticleTree->deleteAll(array($this->BbsArticleTree->alias . '.bbs_key' => $data['Bbs']['key']), false, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}

//コメントの削除
if (! $this->Comment->deleteAll(array($this->Comment->alias . '.block_key' => $data['Block']['key']), false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
}

//Blockデータ削除
$this->Block->deleteBlock($data['Block']['key']);

Expand Down
1 change: 1 addition & 0 deletions Model/BbsArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ public function saveBbsArticle($data) {

//コメントの登録
if (isset($data['Comment']) && $this->Comment->data) {
$this->Comment->data[$this->Comment->name]['block_key'] = $data['Block']['key'];
$this->Comment->data[$this->Comment->name]['content_key'] = $bbsArticle[$this->alias]['key'];
if (! $this->Comment->save(null, false)) {
throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
Expand Down
8 changes: 8 additions & 0 deletions View/Elements/BbsArticles/edit_form.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
'value' => $frameId,
)); ?>

<?php echo $this->Form->hidden('Block.id', array(
'value' => $blockId,
)); ?>

<?php echo $this->Form->hidden('Block.key', array(
'value' => $blockKey,
)); ?>

<?php echo $this->Form->hidden('Bbs.id', array(
'value' => $bbs['id'],
)); ?>
Expand Down

0 comments on commit d376bc5

Please sign in to comment.