示例#1
0
 /**
  * Called after each successful save operation.
  *
  * @param bool $created True if this save created a new record
  * @param array $options Options passed from Model::save().
  * @return void
  * @throws InternalErrorException
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
  * @see Model::save()
  */
 public function afterSave($created, $options = array())
 {
     //BbsArticleTree登録
     if (isset($this->BbsArticleTree->data['BbsArticleTree'])) {
         if (!$this->BbsArticleTree->data['BbsArticleTree']['bbs_article_key']) {
             $this->BbsArticleTree->data['BbsArticleTree']['bbs_article_key'] = $this->data[$this->alias]['key'];
         }
         if (!$this->BbsArticleTree->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     //Bbsのbbs_article_count、bbs_article_modified
     if (isset($this->data['Bbs']['id']) && isset($this->data['Bbs']['key'])) {
         $this->updateBbsByBbsArticle($this->data['Bbs']['id'], $this->data['Bbs']['key'], $this->data[$this->alias]['language_id']);
     }
     //コメント数の更新
     if (isset($this->data['BbsArticleTree']['root_id']) && $this->data['BbsArticleTree']['root_id']) {
         $this->updateBbsArticleChildCount($this->data['BbsArticleTree']['root_id'], $this->data[$this->alias]['language_id']);
     }
     parent::afterSave($created, $options);
 }
示例#2
0
文件: Bbs.php 项目: Onasusweb/Bbses
 /**
  * Called after each successful save operation.
  *
  * @param bool $created True if this save created a new record
  * @param array $options Options passed from Model::save().
  * @return void
  * @throws InternalErrorException
  * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave
  * @see Model::save()
  */
 public function afterSave($created, $options = array())
 {
     //BbsSetting登録
     if (isset($this->BbsSetting->data['BbsSetting'])) {
         if (!$this->BbsSetting->data['BbsSetting']['bbs_key']) {
             $this->BbsSetting->data['BbsSetting']['bbs_key'] = $this->data[$this->alias]['key'];
         }
         if (!$this->BbsSetting->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     //BbsFrameSetting登録
     if (isset($this->BbsFrameSetting->data['BbsFrameSetting']) && !$this->BbsFrameSetting->data['BbsFrameSetting']['id']) {
         if (!$this->BbsFrameSetting->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     parent::afterSave($created, $options);
 }