Changeset 5998

Show
Ignore:
Timestamp:
05/23/08 20:59:51 (8 months ago)
Author:
inureyes
Message:

#174

  • remove 함수 구현
Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/components/Textcube.Data.Post.php

    r5997 r5998  
    151151    } 
    152152     
    153     function remove($id) { // attachment & category is own your risk! 
    154         global $database; 
     153    function remove($id = null) { // attachment & category is own your risk! 
     154        global $database; 
     155        if(!empty($id)) $this->id = $id; 
    155156        // step 0. Get Information 
    156157        if (!isset($this->id) || !Validator::number($this->id, 1)) 
     
    164165             
    165166        // step 1. Check Syndication 
    166         if ($old['visibility'] == 3) { 
     167        if ($entry['visibility'] == 3) { 
    167168            requireComponent('Eolin.API.Syndication'); 
    168169            Syndication::leave($this->getLink()); 
    169170        } 
     171         
     172        CacheControl::flushEntry($this->id); 
     173        CacheControl::flushDBCache('entry'); 
     174        CacheControl::flushDBCache('comment'); 
     175        CacheControl::flushDBCache('trackback'); 
     176        $gCacheStorage->purge(); 
    170177         
    171178        // step 2. Delete Entry 
     
    182189         
    183190        // step 6. update Category 
    184             // TODO : Update Category 
     191            requireComponent('Textcube.Data.Category'); 
     192            if (isset($entry['category'])) { 
     193                $target = ($parentCategory = Category::getParent($entry['category'])) ? '(id = ' . $entry['category'] . ' OR id = ' . $parentCategory . ')' : 'id = ' . $entry['category']; 
     194 
     195                if (isset($entry['visibility']) && ($entry['visibility'] != 1)) 
     196                    POD::query("UPDATE {$database['prefix']}Categories SET entries = entries - 1, entriesInLogin = entriesInLogin - 1 WHERE blogid = ".getBlogId()." AND " . $target); 
     197                else 
     198                    POD::query("UPDATE {$database['prefix']}Categories SET entriesInLogin = entriesInLogin - 1 WHERE blogid = ".getBlogId()." AND " . $target); 
     199            } 
    185200         
    186201        // step 7. Delete Attachment 
    187             // TODO : Delete Attachment 
    188          
     202            $attachNames = POD::queryColumn("SELECT name FROM {$database['prefix']}Attachments 
     203                WHERE blogid = ".getBlogId()." AND parent = ".$this->id); 
     204            if (POD::execute("DELETE FROM {$database['prefix']}Attachments WHERE blogid = ".getBlogId()." AND parent = "$this->id)) { 
     205                foreach($attachNames as $attachName) { 
     206                    if( file_exists( ROOT . "/attach/".getBlogId()."/$attachName") ) { 
     207                        @unlink(ROOT . "/attach/".getBlogId()."/$attachName"); 
     208                    } 
     209                } 
     210            } 
     211     
    189212        // step 8. Delete Tags 
    190213            $this->deleteTags(); 
     
    193216            requireComponent('Textcube.Control.RSS'); 
    194217            RSS::refresh(); 
    195          
     218 
    196219            return true; 
    197220        } 
  • trunk/lib/model/blog.attachment.php

    r5285 r5998  
    194194        } while (file_exists($attachment['path'])); 
    195195        if(!copy($originalPath, $attachment['path'])) return 4; // copy failed. 
    196         if(!POD::execute("insert into {$database['prefix']}Attachments  
    197             values ($blogid,  
     196        if(!POD::execute("INSERT INTO {$database['prefix']}Attachments  
     197            (blogid, parent, name, label, mime, size, width, height, attached, downloads, enclosure) 
     198            VALUES ($blogid,  
    198199                $targetEntryId, 
    199200                '{$attachment['name']}',