OSDN Git Service

Character 基本表示と関連付けまで merge
authorCake <cake_67@users.sourceforge.jp>
Mon, 18 Jan 2010 16:28:30 +0000 (01:28 +0900)
committerCake <cake_67@users.sourceforge.jp>
Mon, 18 Jan 2010 16:28:30 +0000 (01:28 +0900)
app/controllers/characters_controller.php
app/models/character.php
app/views/characters/add.ctp

index e8952de..9a9adcf 100644 (file)
@@ -2,7 +2,34 @@
 class CharactersController extends AppController {
 
        var $name = 'Characters';
-       var $helpers = array('Html', 'Form');
+       var $helpers = array(
+               'Html',
+               'Form',
+               'Token'
+       );
+
+       /* ACL */
+       // 追加アクション用 crudMap
+       var $actionMapPlus = array(
+       );
+
+       var $disableTokenActions = array();
+
+       /* メソッド */
+
+       function beforeFilter() {
+
+               parent::beforeFilter();
+
+               // 不正fieldsのPOST削除(id, createdなど)
+               $this->unsetData('auto', true);
+
+               // 認証なしアクセス可
+               $this->AuthPlus->allow('view');
+               $this->AuthPlus->allow('index');
+       }
+
+       /* アクションメソッド */
 
        function index() {
                $this->Character->recursive = 0;
@@ -18,7 +45,11 @@ class CharactersController extends AppController {
        }
 
        function add() {
+               $this->unsetData('add', false);
+
                if (!empty($this->data)) {
+                       $this->data['Character']['user_id'] = $this->user['User']['id'];
+
                        $this->Character->create();
                        if ($this->Character->save($this->data)) {
                                $this->Session->setFlash(__('The Character has been saved', true));
index 6260fd5..505c489 100644 (file)
@@ -2,6 +2,72 @@
 class Character extends AppModel {
 
        var $name = 'Character';
+
+       var $fields = array(
+               'id' => array(
+                       'auto' => true,
+               ),
+               'name' => array(
+                       'auto' => false,
+                       'add' => true,
+                       'edit' => true,
+                       'escape' => array(
+                               'html' => true,
+                               'all' => true,
+                       ),
+               ),
+               'image_filename' => array(
+                       'auto' => false,
+                       'add' => false,
+                       'edit' => false,
+               ),
+               'system_id' => array(
+                       'auto' => false,
+                       'add' => true,
+                       'edit' => false,
+               ),
+               'sort_order' => array(
+                       'auto' => false,
+                       'add' => true,
+                       'edit' => true,
+               ),
+               'status' => array(
+                       'auto' => false,
+                       'add' => true,
+                       'edit' => true,
+               ),
+               'public_flag' => array(
+                       'auto' => false,
+                       'add' => true,
+                       'edit' => true,
+               ),
+               'user_id' => array(
+                       'auto' => true,
+               ),
+               'detail' => array(
+                       'auto' => false,
+                       'add' => true,
+                       'edit' => true,
+                       'escape' => array(
+                               'html' => true,
+                               'images' => true,
+                               'sctipts' => true,
+                       ),
+               ),
+               'deleted' => array(
+                       'auto' => true,
+               ),
+               'created' => array(
+                       'auto' => true,
+               ),
+               'modified' => array(
+                       'auto' => true,
+               ),
+               'deleted_date' => array(
+                       'auto' => true,
+               ),
+       );
+
        var $validate = array(
                'name' => array('notempty'),
                'sort_order' => array('numeric')
index 6267b29..0e06354 100644 (file)
@@ -6,13 +6,13 @@
                echo $form->input('system_id');
                echo $form->input('user_id');
                echo $form->input('name');
-               echo $form->input('image_filename');
-               echo $form->input('notes');
-               echo $form->input('public_flag');
-               echo $form->input('status_2');
+               echo $form->input('system_id');
                echo $form->input('sort_order');
-               echo $form->input('deleted');
-               echo $form->input('deleted_date');
+               echo $form->input('status');
+               echo $form->input('public_flag');
+               echo $form->input('notes');
+
+               echo $token->create();
        ?>
        </fieldset>
 <?php echo $form->end('Submit');?>