Ejemplo n.º 1
0
 /**
  * Constructor. Binds the model's database table to the object.
  *
  * @param bool|int|string|array $id Set this ID for this model on startup,
  * can also be an array of options, see above.
  * @param string $table Name of database table to use.
  * @param string $ds DataSource connection name.
  * @see Model::__construct()
  * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
  */
 public function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     $this->statuses = array(WorkflowComponent::STATUS_IN_DRAFT => array('key' => WorkflowComponent::STATUS_IN_DRAFT, 'class' => 'label-info', 'message' => __d('net_commons', 'Temporary')), WorkflowComponent::STATUS_APPROVED => array('key' => WorkflowComponent::STATUS_APPROVED, 'class' => 'label-warning', 'message' => __d('net_commons', 'Approving')), WorkflowComponent::STATUS_DISAPPROVED => array('key' => WorkflowComponent::STATUS_DISAPPROVED, 'class' => 'label-warning', 'message' => __d('net_commons', 'Disapproving')), self::STATUS_BEFORE_PUBLISH => array('key' => self::STATUS_BEFORE_PUBLISH, 'class' => 'label-default', 'message' => __d('topics', 'Before publishing')), self::STATUS_ANSWER_END => array('key' => self::STATUS_ANSWER_END, 'class' => 'label-default', 'message' => __d('topics', 'Answer end')), self::STATUS_ANSWERED => array('key' => self::STATUS_ANSWERED, 'class' => 'label-default', 'message' => __d('topics', 'Answered')), self::STATUS_UNANSWERED => array('key' => self::STATUS_UNANSWERED, 'class' => 'label-success', 'message' => __d('topics', 'Unanswered')), self::STATUS_UNCONFIRMED => array('key' => self::STATUS_UNCONFIRMED, 'class' => 'label-primary', 'message' => __d('topics', 'Unconfirmed')), self::STATUS_BLOCK_PRIVATE => array('key' => self::STATUS_BLOCK_PRIVATE, 'class' => 'label-default', 'message' => __d('blocks', 'Private')), self::STATUS_BLOCK_BEFORE_PUBLISH => array('key' => self::STATUS_BLOCK_BEFORE_PUBLISH, 'class' => 'label-default', 'message' => __d('blocks', 'Public before')), self::STATUS_BLOCK_PUBLISH => array('key' => self::STATUS_BLOCK_PUBLISH, 'class' => 'label-default', 'message' => __d('blocks', 'Limited')), self::STATUS_BLOCK_END_PUBLISH => array('key' => self::STATUS_BLOCK_END_PUBLISH, 'class' => 'label-default', 'message' => __d('blocks', 'Public end')));
 }
Ejemplo n.º 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()
  * @throws InternalErrorException
  */
 public function afterSave($created, $options = array())
 {
     //TopicFramesRoom登録
     if (isset($this->data['TopicFramesRoom'])) {
         $this->loadModels(['TopicFramesRoom' => 'Topics.TopicFramesRoom']);
         if (!$this->TopicFramesRoom->saveTopicFramesRoom($this->data)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     //TopicFramesPluginのチェック
     if (isset($this->data['TopicFramesPlugin'])) {
         $this->loadModels(['TopicFramesPlugin' => 'Topics.TopicFramesPlugin']);
         if (!$this->TopicFramesPlugin->saveTopicFramesPlugin($this->data)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     //TopicFramesBlockのチェック
     if (isset($this->data['TopicFramesBlock'])) {
         $this->loadModels(['TopicFramesBlock' => 'Topics.TopicFramesBlock']);
         if (!$this->TopicFramesBlock->saveTopicFramesBlock($this->data)) {
             throw new InternalErrorException(__d('net_commons', 'Internal Server Error'));
         }
     }
     parent::afterSave($created, $options);
 }