define('__TEXTCUBE_CUSTOM_HEADER__', true); require ROOT . '/library/preprocessor.php'; requireModel("blog.category"); requireStrictBlogURL(); $children = array(); $cache = pageCache::getInstance(); if (!empty($suri['id'])) { $categoryId = $suri['id']; if (in_array($categoryId, getCategoryVisibilityList($blogid, 'private'))) { return false; } $categotyTitle = getCategoryNameById($categoryId); } else { if (!empty($suri['value'])) { $categoryId = getCategoryIdByLabel(getBlogId(), $suri['value']); if (in_array($categoryId, getCategoryVisibilityList($blogid, 'private'))) { return false; } $categoryTitle = $suri['value']; } else { // If no category is mentioned, redirect it to total atom. header("Location: " . $context->getProperty('uri.host') . $context->getProperty('uri.blog') . "/atom"); exit; } } $cache->reset('categoryATOM-' . $categoryId); if (!$cache->load()) { $categoryIds = array($categoryId); $parent = getParentCategoryId(getBlogId(), $categoryId); if ($parent === null) { // It's parent. let's find childs.
function getTrackbackFeedByEntryId($blogid = null, $entryId, $rawMode = false, $mode = 'rss') { global $database, $serviceURL, $defaultURL, $blogURL, $blog, $service; if (empty($blogid)) { $blogid = getBlogId(); } $entry = POD::queryRow("SELECT slogan, visibility, category FROM {$database['prefix']}Entries WHERE blogid = {$blogid} AND id = {$entryId}"); if (empty($entry)) { return false; } if ($entry['visibility'] < 2) { return false; } if (in_array($entry['category'], getCategoryVisibilityList($blogid, 'private'))) { return false; } $channel = array(); $channel = initializeRSSchannel($blogid); $channel['title'] = RSSMessage($blog['title'] . ': ' . _textf('%1 에 달린 트랙백', $entry['slogan'])); if ($blog['useSloganOnPost']) { $channel['link'] = $defaultURL . "/entry/" . URL::encode($entry['slogan'], true); } else { $channel['link'] = $defaultURL . "/" . $entryId; } $result = POD::queryAll("SELECT * \n\t\tFROM {$database['prefix']}RemoteResponses\n\t\tWHERE blogid = " . $blogid . " \n\t\t\tAND entry = " . $entryId . "\n\t\t\tAND isfiltered = 0\n\t\t\tAND type = 'trackback'"); if (!$result) { $result = array(); } $channel['items'] = array(); foreach ($result as $row) { $trackbackURL = $channel['link'] . "#trackback"; $content = htmlspecialchars($row['excerpt']); $item = array('id' => $row['id'], 'title' => RSSMessage($row['subject']), 'link' => $trackbackURL . $row['id'], 'categories' => array(), 'description' => RSSMessage($content), 'author' => RSSMessage(htmlspecialchars($row['site'])), 'pubDate' => $row['written'], 'comments' => $trackbackURL, 'guid' => $trackbackURL . $row['id']); array_push($channel['items'], $item); } if ($rawMode == true) { return $channel['items']; } $rss = array('channel' => $channel); if ($mode == 'rss') { return publishRSS($blogid, $rss); } else { if ($mode == 'atom') { return publishATOM($blogid, $rss); } } return false; }
function getEntryListWithPagingByCategory($blogid, $category, $page, $count) { global $database, $suri, $folderURL, $blog; if ($category === null) { return array(); } if (!doesHaveOwnership() && getCategoryVisibility($blogid, $category) < 2 && $category != 0) { return array(); } if ($category > 0) { $categories = POD::queryColumn("SELECT id FROM {$database['prefix']}Categories WHERE blogid = {$blogid} AND parent = {$category}"); array_push($categories, $category); if (!doesHaveOwnership()) { $categories = array_diff($categories, getCategoryVisibilityList($blogid, 'private')); } $cond = 'AND e.category IN (' . implode(', ', $categories) . ')'; $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0'; } else { $cond = 'AND e.category >= 0'; $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid); } $visibility .= doesHaveOwnership() && !Acl::check('group.editors') ? ' AND (e.userid = ' . getUserId() . ' OR e.visibility > 0)' : ''; $sql = "SELECT e.blogid,e.userid,e.id,e.title,e.comments,e.slogan,e.published\n\t\t\tFROM {$database['prefix']}Entries e \n\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} {$cond} \n\t\t\tORDER BY e.published DESC"; return Paging::fetch($sql, $page, $count, "{$folderURL}/" . (!getBlogSetting('useSloganOnCategory', true) && isset($suri['id']) ? $suri['id'] : $suri['value'])); }
function getPrivateCategoryExclusionId($blogid) { $exclusionList = getCategoryVisibilityList($blogid, 'private'); if (empty($exclusionList)) { return null; } return ' AND e.category NOT IN (' . implode(',', $exclusionList) . ')'; }
function getTrackbackFeedByEntryId($blogid = null, $entryId, $rawMode = false, $mode = 'rss') { $context = Model_Context::getInstance(); if (empty($blogid)) { $blogid = getBlogId(); } $pool = DBModel::getInstance(); $pool->reset("Entries"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("id", "eq", $entryId); $entry = $pool->getRow("slogan,visibility,category"); if (empty($entry)) { return false; } if ($entry['visibility'] < 2) { return false; } if (in_array($entry['category'], getCategoryVisibilityList($blogid, 'private'))) { return false; } $channel = array(); $channel = initializeRSSchannel($blogid); $channel['title'] = RSSMessage($context->getProperty('blog.title') . ': ' . _textf('%1 에 달린 트랙백', $entry['slogan'])); if ($context->getProperty('blog.useSloganOnPost')) { $channel['link'] = $context->getProperty('uri.default') . "/entry/" . URL::encode($entry['slogan'], true); } else { $channel['link'] = $context->getProperty('uri.default') . "/" . $entryId; } $pool->reset("RemoteResponses"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("entry", "eq", $entryId); $pool->setQualifier("isfiltered", "eq", 0); $pool->setQualifier("type", "eq", "trackback", true); $result = $pool->getAll(); if (!$result) { $result = array(); } $channel['items'] = array(); foreach ($result as $row) { $trackbackURL = $channel['link'] . "#trackback"; $content = htmlspecialchars($row['excerpt']); $item = array('id' => $row['id'], 'title' => RSSMessage($row['subject']), 'link' => $trackbackURL . $row['id'], 'categories' => array(), 'description' => RSSMessage($content), 'author' => RSSMessage(htmlspecialchars($row['site'])), 'pubDate' => $row['written'], 'comments' => $trackbackURL, 'guid' => $trackbackURL . $row['id']); array_push($channel['items'], $item); } if ($rawMode == true) { return $channel['items']; } $rss = array('channel' => $channel); if ($mode == 'rss') { return publishRSS($blogid, $rss); } else { if ($mode == 'atom') { return publishATOM($blogid, $rss); } } return false; }
function getEntryListWithPagingByCategory($blogid, $category, $page, $count) { if ($category === null) { return array(); } if (!doesHaveOwnership() && getCategoryVisibility($blogid, $category) < 2 && $category != 0) { return array(); } $ctx = Model_Context::getInstance(); $pool = DBModel::getInstance(); if ($category > 0) { $pool->init("Categories"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("parent", "eq", $category); $categories = $pool->getColumn("id"); array_push($categories, $category); if (!doesHaveOwnership()) { $categories = array_diff($categories, getCategoryVisibilityList($blogid, 'private')); } $pool->init("Entries"); $pool->setAlias("Entries", "e"); $pool->setQualifier("e.category", "hasoneof", $categories); if (!doesHaveOwnership()) { $pool->setQualifier("e.visibility", ">", 0); } } else { $pool->init("Entries"); $pool->setAlias("Entries", "e"); $pool->setQualifier("e.category", ">=", 0); if (!doesHaveOwnership()) { $pool->setQualifier("e.visibility", ">", 0); $pool = getPrivateCategoryExclusionQualifier($pool, $blogid); } } if (doesHaveOwnership() && !Acl::check('group.editors')) { $pool->setQualifierSet(array("e.userid", "eq", getUserId()), "OR", array("e.visibility", ">", 0)); } $pool->setProjection("e.blogid", "e.userid", "e.id", "e.title", "e.comments", "e.slogan", "e.published"); $pool->setOrder("e.published", "desc"); return Paging::fetch($pool, $page, $count, $ctx->getProperty('uri.folder') . "/" . (!$ctx->getProperty('blog.useSloganOnCategory', true) && $ctx->getProperty('suri.id', null) != null ? $ctx->getProperty('suri.id') : $ctx->getProperty('suri.value'))); }
function getPrivateCategoryExclusionQualifier($pool, $blogid = null) { if (is_null($blogid)) { $blogid = getBlogId(); } $exclusionList = getCategoryVisibilityList($blogid, 'private'); if (empty($exclusionList)) { return $pool; } $pool->setQualifier("e.category", "hasnoneof", $exclusionList); return $pool; }
function getEntryListWithPagingByCategory($blogid, $category, $page, $count) { $ctx = Model_Context::getInstance(); if ($category === null) { return array(); } if (!doesHaveOwnership() && getCategoryVisibility($blogid, $category) < 2 && $category != 0) { return array(); } if ($category > 0) { $categories = POD::queryColumn("SELECT id FROM " . $ctx->getProperty('database.prefix') . "Categories WHERE blogid = {$blogid} AND parent = {$category}"); array_push($categories, $category); if (!doesHaveOwnership()) { $categories = array_diff($categories, getCategoryVisibilityList($blogid, 'private')); } $cond = 'AND e.category IN (' . implode(', ', $categories) . ')'; $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0'; } else { $cond = 'AND e.category >= 0'; $visibility = doesHaveOwnership() ? '' : 'AND e.visibility > 0' . getPrivateCategoryExclusionQuery($blogid); } $visibility .= doesHaveOwnership() && !Acl::check('group.editors') ? ' AND (e.userid = ' . getUserId() . ' OR e.visibility > 0)' : ''; $sql = "SELECT e.blogid,e.userid,e.id,e.title,e.comments,e.slogan,e.published\n\t\t\tFROM " . $ctx->getProperty('database.prefix') . "Entries e \n\t\t\tWHERE e.blogid = {$blogid} AND e.draft = 0 {$visibility} {$cond} \n\t\t\tORDER BY e.published DESC"; return Paging::fetch($sql, $page, $count, $ctx->getProperty('uri.folder') . "/" . (!$ctx->getProperty('blog.useSloganOnCategory', true) && $ctx->getProperty('suri.id', null) != null ? $ctx->getProperty('suri.id') : $ctx->getProperty('suri.value'))); }