Пример #1
0
 function __construct($id = false, $table = NULL, $ds = NULL)
 {
     if (in_array('Search', App::objects('plugin'))) {
         $this->actsAs[] = 'Search.Searchable';
     }
     if (in_array('Comment', App::objects('plugin'))) {
         $this->actsAs[] = 'Comment.Commented';
     }
     App::import('Lib', 'Blog.BlogConfig');
     $this->multimedia['multimedia']['fields']['format'] = BlogConfig::load('cropFormats');
     parent::__construct($id, $table, $ds);
 }
Пример #2
0
 /**
  * 関連する記事データをカテゴリ無所属に変更し保存する
  * 
  * @param boolean $cascade
  * @return boolean
  * @access public
  */
 function beforeDelete($cascade = true)
 {
     parent::beforeDelete($cascade);
     $ret = true;
     if (!empty($this->data['BlogCategory']['id'])) {
         $id = $this->data['BlogCategory']['id'];
         $this->BlogPost->unBindModel(array('belongsTo' => array('BlogCategory')));
         $datas = $this->BlogPost->find('all', array('conditions' => array('BlogPost.blog_category_id' => $id)));
         if ($datas) {
             foreach ($datas as $data) {
                 $data['BlogPost']['blog_category_id'] = '';
                 $this->BlogPost->set($data);
                 if (!$this->BlogPost->save()) {
                     $ret = false;
                 }
             }
         }
     }
     return $ret;
 }
Пример #3
0
 function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     $this->validate = array('title' => array('notEmpty' => array('rule' => 'notEmpty', 'message' => __('Please enter the title of your post', true))), 'body' => array('notEmpty' => array('rule' => 'notEmpty', 'message' => __('Please enter your post', true))), 'category_id' => array('comparison' => array('rule' => array('comparison', '>', 0), 'message' => __('Please select a category', true))));
 }