OSDN Git Service

Attachment空登録回避
authorCake <cake_67@users.sourceforge.jp>
Mon, 19 Apr 2010 14:27:50 +0000 (23:27 +0900)
committerCake <cake_67@users.sourceforge.jp>
Mon, 19 Apr 2010 14:27:50 +0000 (23:27 +0900)
app/controllers/systems_controller.php
app/plugins/media/models/attachment_ex.php

index 1ff6802..77aaf48 100644 (file)
@@ -79,6 +79,10 @@ class SystemsController extends AppController {
 
        function admin_add() {
                if (!empty($this->data)) {
+                       if (empty($this->data['Attachment'][0]['file']['tmp_name'])) {
+                               unset($this->data['Attachment']);
+                       }
+
                        $this->System->create();
                        if ($this->System->saveAll($this->data, array('fieldList' => array_merge($this->System->fields['add'], $this->System->fields['image'])))) {
                                $this->Session->setFlash(sprintf(__('%s has been saved', true), $this->data['System']['name']));
index 9b1e6bf..d57dffe 100644 (file)
@@ -66,8 +66,9 @@ class AttachmentEx extends Attachment {
        }
 
        function beforeSave() {
-               if (!isset($this->data[$this->alias]['delete']) 
-               || ($this->data[$this->alias]['file'])) {
+               if (isset($this->data[$this->alias])
+                && (!isset($this->data[$this->alias]['delete']) 
+                || ($this->data[$this->alias]['file']))) {
                        // 登録者ID
                        if (isset($_SESSION['Auth']['User']['id'])) {
                                $this->data[$this->alias]['user_id'] = $_SESSION['Auth']['User']['id'];