Beispiel #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())
 {
     //FaqSetting登録
     if (isset($this->FaqSetting->data['FaqSetting'])) {
         if (!$this->FaqSetting->data['FaqSetting']['faq_key']) {
             $this->FaqSetting->data['FaqSetting']['faq_key'] = $this->data[$this->alias]['key'];
         }
         if (!$this->FaqSetting->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     parent::afterSave($created, $options);
 }
Beispiel #2
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())
 {
     //FaqQuestionOrder登録
     if (isset($this->FaqQuestionOrder->data['FaqQuestionOrder'])) {
         if (!$this->FaqQuestionOrder->data['FaqQuestionOrder']['faq_question_key']) {
             $this->FaqQuestionOrder->data['FaqQuestionOrder']['faq_question_key'] = $this->data[$this->alias]['key'];
             $this->FaqQuestionOrder->data['FaqQuestionOrder']['weight'] = $this->FaqQuestionOrder->getMaxWeight($this->data['Faq']['key']) + 1;
         }
         if (!$this->FaqQuestionOrder->save(null, false)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     parent::afterSave($created, $options);
 }
Beispiel #3
0
 /**
  * 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('faq_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'faq_question_key' => array('notBlank' => array('rule' => array('notBlank'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false, 'required' => true, 'on' => 'update')), 'weight' => array('numeric' => array('rule' => array('numeric'), 'message' => __d('net_commons', 'Invalid request.'), 'allowEmpty' => false))));
     return parent::beforeValidate($options);
 }