public function execute(HTTPRequestCustom $request) { $module_id = $request->get_getstring('module_id', ''); if (empty($module_id)) { AppContext::get_response()->redirect(Environment::get_home_page()); } $this->init(); $module_category_id = $request->get_getint('module_category_id', 0); $feed_name = $request->get_getstring('feed_name', Feed::DEFAULT_FEED_NAME); $feed = new ATOM($module_id, $feed_name, $module_category_id); if ($feed !== null && $feed->is_in_cache()) { $this->tpl->put('SYNDICATION', $feed->read()); } else { $eps = AppContext::get_extension_provider_service(); if ($eps->provider_exists($module_id, FeedProvider::EXTENSION_POINT)) { $provider = $eps->get_provider($module_id); $feeds = $provider->feeds(); $data = $feeds->get_feed_data_struct($module_category_id, $feed_name); if ($data === null) { AppContext::get_response()->set_header('content-type', 'text/html'); DispatchManager::redirect(PHPBoostErrors::unexisting_element()); } else { $feed->load_data($data); $feed->cache(); $this->tpl->put('SYNDICATION', $feed->export()); } } else { DispatchManager::redirect(PHPBoostErrors::module_not_installed()); } } return $this->build_response($this->tpl); }
function remove($id = null) { // attachment & category is own your risk! global $database; $gCacheStorage = globalCacheStorage::getInstance(); $this->init(); if (!empty($id)) { $this->id = $id; } // step 0. Get Information if (!isset($this->id) || !Validator::number($this->id, 1)) { return $this->_error('id'); } if (!($query = $this->_buildQuery())) { return false; } if (!($entry = $query->getRow('category, visibility'))) { return $this->_error('id'); } // step 1. Check Syndication if ($entry['visibility'] == 3) { Utils_Syndication::leave($this->getLink()); } CacheControl::flushEntry($this->id); CacheControl::flushDBCache('entry'); CacheControl::flushDBCache('comment'); CacheControl::flushDBCache('trackback'); $gCacheStorage->purge(); // step 2. Delete Entry $sql = "DELETE FROM " . $database['prefix'] . "Entries WHERE blogid = " . $this->blogid . " AND id = " . $this->id; if (POD::queryCount($sql)) { // step 3. Delete Comment POD::execute("DELETE FROM {$database['prefix']}Comments WHERE blogid = " . $this->blogid . " AND entry = " . $this->id); // step 4. Delete Trackback POD::execute("DELETE FROM {$database['prefix']}RemoteResponses WHERE blogid = " . $this->blogid . " AND entry = " . $this->id); // step 5. Delete Trackback Logs POD::execute("DELETE FROM {$database['prefix']}RemoteResponseLogs WHERE blogid = " . $this->blogid . " AND entry = " . $this->id); // step 6. update Category if (isset($entry['category'])) { $target = ($parentCategory = Category::getParent($entry['category'])) ? '(id = ' . $entry['category'] . ' OR id = ' . $parentCategory . ')' : 'id = ' . $entry['category']; if (isset($entry['visibility']) && $entry['visibility'] != 1) { POD::query("UPDATE {$database['prefix']}Categories SET entries = entries - 1, entriesinlogin = entriesinlogin - 1 WHERE blogid = " . $this->blogid . " AND " . $target); } else { POD::query("UPDATE {$database['prefix']}Categories SET entriesinlogin = entriesinlogin - 1 WHERE blogid = " . $this->blogid . " AND " . $target); } } // step 7. Delete Attachment $attachNames = POD::queryColumn("SELECT name FROM {$database['prefix']}Attachments\n\t\t\t\tWHERE blogid = " . getBlogId() . " AND parent = " . $this->id); if (POD::execute("DELETE FROM {$database['prefix']}Attachments WHERE blogid = " . getBlogId() . " AND parent = " . $this->id)) { foreach ($attachNames as $attachName) { if (file_exists(__TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/{$attachName}")) { @unlink(__TEXTCUBE_ATTACH_DIR__ . "/" . getBlogId() . "/{$attachName}"); } } } // step 8. Delete Tags $this->deleteTags(); // step 9. Clear RSS RSS::refresh(); ATOM::refresh(); return true; } return false; }