OSDN Git Service

System削除確認画面と関連データ処理追加
authorCake <cake_67@users.sourceforge.jp>
Thu, 1 Apr 2010 08:41:37 +0000 (17:41 +0900)
committerCake <cake_67@users.sourceforge.jp>
Thu, 1 Apr 2010 08:41:37 +0000 (17:41 +0900)
app/controllers/systems_controller.php
app/models/system.php
app/plugins/media/models/attachment_ex.php
app/views/systems/admin_delete.ctp [new file with mode: 0644]
app/views/systems/admin_view.ctp

index 12b10f7..5b2d3b3 100644 (file)
@@ -141,10 +141,14 @@ class SystemsController extends AppController {
                        $this->Session->setFlash(__('Invalid id for System', true));
                        $this->redirect(array('action'=>'index'));
                }
-               if ($this->System->del($id)) {
-                       $this->Session->setFlash(__('System deleted', true));
-                       $this->redirect(array('action'=>'index'));
+               if (isset($this->data['System']['confirm']) && $this->data['System']['confirm'] == 'yes') {
+                       if ($this->System->del($id)) {
+                               $this->Session->setFlash(__('System deleted', true));
+                               $this->redirect(array('action'=>'index'));
+                       }
                }
+
+               $this->admin_view($id);
        }
 
        /* 共通メソッド */
index bb4a793..7da3a0e 100644 (file)
@@ -66,7 +66,7 @@ class System extends AppModel {
                'Character' => array(
                        'className' => 'Character',
                        'foreignKey' => 'system_id',
-                       'dependent' => true,
+                       'dependent' => false,
                        'conditions' => array(
                                'Character.public_flag' => 'public',
                                'Character.deleted' => '0',
@@ -131,5 +131,10 @@ class System extends AppModel {
                return parent::beforeSave($options);
        }
 
+       function beforeDelete($cascade = true) {
+               $this->data['System']['isAdmin'] = true;
+
+               return parent::beforeDelete($cascade);
+       }
 }
 
index 842f858..9b1e6bf 100644 (file)
@@ -78,6 +78,10 @@ class AttachmentEx extends Attachment {
        }
 
        function beforeDelete($cascade = true) {
+               if (!isset($this->data[$this->alias]['isAdmin']) || $this->data[$this->alias]['isAdmin'] == true) {
+                       return parent::beforeDelete($cascade);
+               }
+
                if (!isset($this->data[$this->alias]['id']) || empty($this->data[$this->alias]['id'])) {
                        return false;
                }
diff --git a/app/views/systems/admin_delete.ctp b/app/views/systems/admin_delete.ctp
new file mode 100644 (file)
index 0000000..3d3aacb
--- /dev/null
@@ -0,0 +1,116 @@
+<div class="systems form delete">
+<?php echo $form->create('System', array(
+       'url' => array(
+               'controller' => 'systems',
+               'action' => 'admin_delete',
+               $system['System']['id']
+       ),
+));
+?>
+<fieldset>
+<legend><?php echo sprintf(__('Are you sure you want to delete %s?', true), $system['System']['name']); ?></legend>
+
+<?php 
+       echo $html->div(
+       'notice',
+       sprintf(__('ALL PROFILE data belonging %s will be deleted. OK?', true), $system['System']['name'])
+       );
+
+       echo $form->input('confirm', array(
+               'type' => 'hidden',
+               'value' => 'yes'
+       ));
+ ?>
+
+<div class="system_data">
+<?php
+       $system_name = $system['System']['name'];
+
+       $url = null;
+       if ($system['System']['url']) {
+               $url = $system['System']['url'];
+       }
+       $file = $upfile->file(
+               'filter/xs', 
+               CorePlus::get_value($system, 'Attachment.0'),
+               array(
+                       'model_name' => 'System', 
+                       'mime_type' => 'original',
+                       'nodata' => 'image',
+               )
+       );
+       $system_img = $upfile->embed(
+               $file,
+               array(
+                       'alt' => CorePlus::get_value($system, 'Attachment.0.alternative'),
+                       'restrict' => array('image'),
+                       'htmlAttributes' => array(
+                               'target' => '_blank',
+                       ),
+               )
+       );
+
+       $public = $html->tag('span', 
+               $select->get_i18n_public_flag($system['System']['public_flag'], $public_flags),
+               array(
+                       'class' => 'text publicFlag',
+               )
+       );
+       if ($system['System']['set_npc']) {
+               $npc_status = __('NPC Setting: Use', true);
+       } else {
+               $npc_status = __('NPC Setting: No Use', true);
+       }
+       $npc_use = $html->tag('span', 
+               $npc_status,
+               array(
+                       'class' => 'text',
+               )
+       );
+
+       $footer = null;
+
+       echo $this->renderElement('box', array(
+               'header' => $system_img. $system_name. $public. $npc_use,
+               'body' => $system['System']['detail']."&nbsp;",
+               'footer' => $footer,
+       ));
+?>
+</div>
+
+<div class="characters">
+<?php
+       $total =  $html->tag('span', sprintf(__('Total Characters %d', true), $system['System']['character_num']), array('class' => 'total_chara_num'));
+
+       echo $this->renderElement('character_picture_table', array(
+               'header' => __('Characters', true). $total,
+               'characters' => $system['Character'],
+               'previewVersion' => 'xs',
+               'colNum' => 15,
+               'id' => null,
+               'isUser' => false,
+               'isCharacter' => false,
+               'isSystem' => false,
+               'isModified' => false,
+       ));
+?>
+</div>
+
+<?php
+       echo $token->create();
+?>
+</fieldset>
+<?php echo $form->end('Submit');?>
+</div>
+
+<div class="backButton">
+<?php
+       echo $form->create('', array('url' => array(
+               'controller' => 'systems', 'action' => 'admin_view', $system['System']['id']),
+               'type' => 'GET',
+               'id' => 'CancelButton'
+       ));
+       echo $form->end('Cancel');
+?>
+</div>
+
index 8a739fe..e8242d9 100644 (file)
@@ -58,7 +58,7 @@
 
        $footer = '<ul>'.
                '<li>'.$html->link(__('Edit System', true), array('action' => 'edit', $system['System']['id'])).'</li>'.
-               '<li>'.$html->link(__('Delete System', true), array('action' => 'delete', $system['System']['id']), null, sprintf(__('Are you sure you want to delete %s?', true), $system['System']['name'])).'</li>'.
+               '<li>'.$html->link(__('Delete System', true), array('action' => 'delete', $system['System']['id'])).'</li>'.
                '</ul>';
 
        echo $this->renderElement('box', array(