8 * @author Cake <cake_67@users.sourceforge.jp>
9 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
10 * @link http://trpgtools-onweb.sourceforge.jp/
12 class CharacterSheet extends AppModel {
14 var $name = 'CharacterSheet';
17 'add' => array('system_id', 'user_id', 'key_name', 'name', 'public_flag', 'sort_order'),
18 'edit' => array('name', 'public_flag', 'sort_order'),
23 var $validate = array(
26 'rule' => array('isUnique'),
29 'rule' => 'keyNameNg',
34 'maxLengthJP' => array(
35 'rule' => array('maxLengthJP', 40),
42 'maxLengthJP' => array(
43 'rule' => array('maxLengthJP', 64),
50 'validSystemId' => array(
51 'rule' => array('validSystemId', false),
54 'public_flag' => array(
55 'publicFlag' => array(
56 'rule' => 'publicFlag',
60 'sort_order' => array(
68 //The Associations below have been created with all possible keys, those that are not needed can be removed
69 var $belongsTo = array(
71 'className' => 'System',
72 'foreignKey' => 'system_id',
73 'conditions' => array(
74 'System.public_flag' => 'public',
85 'className' => 'User',
86 'foreignKey' => 'user_id',
97 function beforeSave($options = array())
99 if (empty($this->data['CharacterSheet']['sort_order'])) {
100 $this->data['CharacterSheet']['sort_order'] = 0;
103 return parent::beforeSave($options);
105 function afterSave($created) {
106 $this->deleteCache4CharcterSheet();
108 return parent::afterSave($created);
110 function afterDelete() {
111 $this->deleteCache4CharcterSheet();
113 return parent::afterDelete();
117 function deleteCache4CharcterSheet()
120 $this->deleteAllFiles(CACHE);
123 $this->deleteAllFiles(CACHE.'views');
126 if (!isset($this->Character)) {
127 $this->Character = CorePlus::set_model('Character');
129 $this->Character->cacheDelete();
131 if (!isset($this->System)) {
132 $this->System = CorePlus::set_model('System');
134 $this->System->cacheDelete();
137 $this->deleteCacheMyData();