Changeset 5998
- Timestamp:
- 05/23/08 20:59:51 (8 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
components/Textcube.Data.Post.php (modified) (4 diffs)
-
lib/model/blog.attachment.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/Textcube.Data.Post.php
r5997 r5998 151 151 } 152 152 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; 155 156 // step 0. Get Information 156 157 if (!isset($this->id) || !Validator::number($this->id, 1)) … … 164 165 165 166 // step 1. Check Syndication 166 if ($ old['visibility'] == 3) {167 if ($entry['visibility'] == 3) { 167 168 requireComponent('Eolin.API.Syndication'); 168 169 Syndication::leave($this->getLink()); 169 170 } 171 172 CacheControl::flushEntry($this->id); 173 CacheControl::flushDBCache('entry'); 174 CacheControl::flushDBCache('comment'); 175 CacheControl::flushDBCache('trackback'); 176 $gCacheStorage->purge(); 170 177 171 178 // step 2. Delete Entry … … 182 189 183 190 // 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 } 185 200 186 201 // 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 189 212 // step 8. Delete Tags 190 213 $this->deleteTags(); … … 193 216 requireComponent('Textcube.Control.RSS'); 194 217 RSS::refresh(); 195 218 196 219 return true; 197 220 } -
trunk/lib/model/blog.attachment.php
r5285 r5998 194 194 } while (file_exists($attachment['path'])); 195 195 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, 198 199 $targetEntryId, 199 200 '{$attachment['name']}',
