/** * 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); }
/** * Called during validation operations, before validation. Please note that custom * validation rules can be defined in $validate. * * @param array $options Options passed from Model::save(). * @return bool True if validate operation should continue, false to abort * @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ public function beforeValidate($options = array()) { $this->validate = Hash::merge($this->validate, array('bbs_article_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'required' => true)), 'user_id' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'required' => true)))); return parent::beforeValidate($options); }
/** * 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); }