OSDN Git Service

CharacterSheet一覧表示とキャッシュ
[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', 'user_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                         'keyNameNg' => array(
29                                 'rule' => 'keyNameNg',
30                         ),
31                         'keyName' => array(
32                                 'rule' => 'keyName',
33                         ),
34                         'maxLengthJP' => array(
35                                 'rule' => array('maxLengthJP', 40),
36                         ),
37                         'notEmpty' => array(
38                                 'rule' => 'notEmpty',
39                         ),
40                 ),
41                 'name' => array(
42                         'maxLengthJP' => array(
43                                 'rule' => array('maxLengthJP', 64),
44                         ),
45                         'notEmpty' => array(
46                                 'rule' => 'notEmpty',
47                         ),
48                 ),
49                 'system_id' => array(
50                         'validSystemId' => array(
51                                 'rule' => array('validSystemId', false),
52                         ),
53                 ),
54                 'public_flag' => array(
55                         'publicFlag' => array(
56                                 'rule' => 'publicFlag',
57                                 'allowEmpty' => true,
58                         ),
59                 ),
60                 'sort_order' => array(
61                         'numeric' => array(
62                                 'rule' => 'numeric',
63                                 'allowEmpty' => true,
64                         ),
65                 ),
66         );
67
68         //The Associations below have been created with all possible keys, those that are not needed can be removed
69         var $belongsTo = array(
70                 'System' => array(
71                         'className' => 'System',
72                         'foreignKey' => 'system_id',
73                         'conditions' => array(
74                                 'System.public_flag' => 'public',
75                         ),
76                         'fields' => array(
77                                 'System.id', 
78                                 'System.name', 
79                                 'System.public_flag',
80                                 'System.copyright',
81                         ),
82                         'order' => ''
83                 ),
84                 'User' => array(
85                         'className' => 'User',
86                         'foreignKey' => 'user_id',
87                         'conditions' => '',
88                         'fields' => array(
89                                 'User.id', 
90                                 'User.group_id',
91                                 'User.name'
92                         ),
93                 )
94         );
95
96         /* コールバックメソッド */
97         function beforeSave($options = array())
98         {
99                 if (empty($this->data['CharacterSheet']['sort_order'])) {
100                         $this->data['CharacterSheet']['sort_order'] = 0;
101                 }
102
103                 return parent::beforeSave($options);
104         }
105         function afterSave($created) {
106                 $this->deleteCache4CharcterSheet();
107
108                 return parent::afterSave($created);
109         }
110         function afterDelete() {
111                 $this->deleteCache4CharcterSheet();
112
113                 return parent::afterDelete();
114         }
115
116         /* キャッシュ削除 */
117         function deleteCache4CharcterSheet()
118         {
119                 // モデルキャッシュ
120                 $this->deleteAllFiles(CACHE);
121
122                 // ビューキャッシュ
123                 $this->deleteAllFiles(CACHE.'views');
124
125 /*
126                 if (!isset($this->Character)) {
127                         $this->Character = CorePlus::set_model('Character');
128                 }
129                 $this->Character->cacheDelete();
130
131                 if (!isset($this->System)) {
132                         $this->System = CorePlus::set_model('System');
133                 }
134                 $this->System->cacheDelete();
135
136                 // 自セッション関連
137                 $this->deleteCacheMyData();
138 */
139         }
140
141 }
142