OSDN Git Service

バージョン記載追加
[trpgtools-onweb/cake-frame.git] / app / models / character_sheet.php
1 <?php
2 /**
3  * PHP version 5
4  *
5  * @category Model
6  * @package  Chara-Shee!
7  * @version  beta
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/
11  */
12 class CharacterSheet extends AppModel {
13
14         var $name = 'CharacterSheet';
15
16         var $fields = array(
17                 'add' => array('system_id', 'key_name', 'name', 'public_flag', 'sort_order'),
18                 'edit' => array('name', 'public_flag', 'sort_order'),
19                 'escape' => array(
20                 ),
21         );
22
23         var $validate = array(
24                 'key_name' => array(
25                         'isUnique' => array(
26                                 'rule' => array('isUnique'),
27                         ),
28                         'keyName' => array(
29                                 'rule' => 'keyName',
30                         ),
31                         'maxLengthJP' => array(
32                                 'rule' => array('maxLengthJP', 40),
33                         ),
34                         'notEmpty' => array(
35                                 'rule' => 'notEmpty',
36                         ),
37                 ),
38                 'name' => array(
39                         'maxLengthJP' => array(
40                                 'rule' => array('maxLengthJP', 64),
41                         ),
42                         'notEmpty' => array(
43                                 'rule' => 'notEmpty',
44                         ),
45                 ),
46                 'system_id' => array(
47                         'validSystemId' => array(
48                                 'rule' => array('validSystemId', true),
49                         ),
50                 ),
51                 'public_flag' => array(
52                         'publicFlag' => array(
53                                 'rule' => 'publicFlag',
54                         ),
55                 ),
56                 'sort_order' => array(
57                         'numeric' => array(
58                                 'rule' => 'numeric',
59                                 'allowEmpty' => true,
60                         ),
61                 ),
62         );
63
64         //The Associations below have been created with all possible keys, those that are not needed can be removed
65         var $belongsTo = array(
66                 'System' => array(
67                         'className' => 'System',
68                         'foreignKey' => 'system_id',
69                         'conditions' => '',
70                         'fields' => array(
71                                 'System.id', 
72                                 'System.name', 
73                                 'System.public_flag'
74                         ),
75                         'order' => ''
76                 )
77         );
78
79         /* コールバックメソッド */
80         function beforeSave($options = array())
81         {
82                 if (empty($this->data['CharacterSheet']['sort_order'])) {
83                         $this->data['CharacterSheet']['sort_order'] = 0;
84                 }
85
86                 return parent::beforeSave($options);
87         }
88         function afterSave($created) {
89                 $this->deleteCache4CharcterSheet();
90
91                 return parent::afterSave($created);
92         }
93         function afterDelete() {
94                 $this->deleteCache4CharcterSheet();
95
96                 return parent::afterDelete($model);
97         }
98
99         /* キャッシュ削除 */
100         function deleteCache4CharcterSheet()
101         {
102                 // View
103 //              $this->deleteAllFiles(CACHE.'views');
104                 if (!isset($this->Character)) {
105                         $this->Character = CorePlus::set_model('Character');
106                 }
107                 $this->Character->cacheDelete();
108
109                 if (!isset($this->System)) {
110                         $this->System = CorePlus::set_model('System');
111                 }
112                 $this->System->cacheDelete();
113         }
114
115 }
116