metadata 관련 버그 수정

2008-07-10 15:45:38

"읽기 권한이 없어도 목록을 보여줍니다."체크 박스를 저장할때마다, always_show_list 키가 자꾸만들어지네요.

이 부분을 수정해야 할듯 ^^, 그리고 metadata 삭제하는 remove_attribute도 필요할것 같아서 추가했습니다.

Code:

Index: app/models/metadata.php
===================================================================
--- app/models/metadata.php     (revision 1212)
+++ app/models/metadata.php     (working copy)
@@ -20,9 +20,11 @@
                $this->load();
        }
        function get($key) {
+               if (!$this->loaded) $this->load();
                return array_key_exists($key, $this->attributes) ? $this->attributes[$key] : '';
        }
        function set($key, $value) {
+               if (!$this->loaded) $this->load();
                if (!array_key_exists($key, $this->attributes)) {
                        insert('metadata', array('model' => $this->model->model, 'model_id' => $this->model->id, 'key' => $key, 'value' => $value));
                } else {
@@ -30,6 +32,11 @@
                }
                $this->attributes[$key] = $value;
        }
+       function remove($key) {
+               if (!$this->loaded) $this->load();
+               delete_all('metadata', "model='{$this->model->model}' AND model_id={$this->model->id} AND `key`=".$this->db->quote($key));
+               $this->reload();
+       }
        function reset() {
                delete_all('metadata', "model='{$this->model->model}' AND model_id={$this->model->id}");
        }
Index: lib/model.php
===================================================================
--- lib/model.php       (revision 1212)
+++ lib/model.php       (working copy)
@@ -125,5 +125,10 @@
                $this->metadata->model = &$this; // workaround for PHP4 -_-
                $this->metadata->set($key, $value);
        }
+
+       function remove_attribute($key) {
+               $this->metadata->model = &$this; // workaround for PHP4 -_-
+               $this->metadata->remove($key);
+       }
 }
 ?>

엽기민원 님이 2008-07-10 15:58:17에 고쳤습니다.

← 빈 제목, 빈 내용일때 오류 메세지 나오기 | 스킨 수정요 board-default/write.php →