<?php flush(); } } setProgress(0, _t('교정 대상을 확인하고 있습니다.')); $items = 4 + POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}Comments WHERE blogid = {$blogid}") + POD::queryCell("SELECT COUNT(*) FROM {$database['prefix']}RemoteResponses WHERE blogid = {$blogid}"); set_time_limit(0); $item = 0; $corrected = 0; $post = new Post(); setProgress($item++ / $items * 100, _t('글의 댓글 정보를 다시 계산해서 저장합니다.')); $post->updateComments(); setProgress($item++ / $items * 100, _t('글의 걸린글 정보를 다시 계산해서 저장합니다.')); $post->updateRemoteResponses(); setProgress($item++ / $items * 100, _t('분류의 글 정보를 다시 계산해서 저장합니다.')); updateEntriesOfCategory($blogid); setProgress($item++ / $items * 100, _t('태그와 태그 관계 정보를 다시 계산해서 저장합니다.')); $post->correctTagsAll(); if ($result = POD::query("SELECT id, name, parent, homepage, comment, entry, isfiltered FROM {$database['prefix']}Comments WHERE blogid = {$blogid} and isfiltered = 0")) { while ($comment = POD::fetch($result)) { setProgress($item++ / $items * 100, _t('댓글과 방명록 데이터를 교정하고 있습니다.')); $correction = ''; if (!Utils_Unicode::validate($comment['name'])) { $correction .= ' name = \'' . POD::escapeString(Utils_Unicode::correct($comment['name'], '?')) . '\''; } if (!Utils_Unicode::validate($comment['homepage'])) { $correction .= ' homepage = \'' . POD::escapeString(Utils_Unicode::correct($comment['homepage'], '?')) . '\''; } if (!Utils_Unicode::validate($comment['comment'])) { $correction .= ' comment = \'' . POD::escapeString(Utils_Unicode::correct($comment['comment'], '?')) . '\''; }
function changeCategoryOfEntries($blogid, $entries, $category) { global $database; requireModel("blog.category"); requireModel("blog.feed"); $targets = array_unique(preg_split('/,/', $entries, -1, PREG_SPLIT_NO_EMPTY)); $effectedCategories = array(); if (count($targets) < 1 || !is_numeric($category)) { return false; } if ($category == -1) { // Check Keyword duplication foreach ($targets as $entryId) { $title = POD::queryCell("SELECT title FROM {$database['prefix']}Entries WHERE blogid = {$blogid} AND id = {$entryId} AND draft = 0"); if (is_null($title)) { return false; } if (POD::queryExistence("SELECT id FROM {$database['prefix']}Entries WHERE blogid = {$blogid} AND id <> {$entryId} AND draft = 0 AND title = '{$title}' AND category = -1") == true) { return false; } } } else { $parent = getParentCategoryId($blogid, $categoryId); array_push($effectedCategories, $parent); } foreach ($targets as $entryId) { list($effectedCategoryId, $oldVisibility) = POD::queryRow("SELECT category, visibility FROM {$database['prefix']}Entries WHERE blogid = {$blogid} AND id = {$entryId} AND draft = 0"); $visibility = $oldVisibility; if ($category < 0) { if ($visibility == 1) { $visibility = 0; } if ($visibility == 3) { $visibility = 2; } } if ($oldVisibility == 3 && $visibility != 3) { syndicateEntry($entryId, 'delete'); } POD::execute("UPDATE {$database['prefix']}Entries SET category = {$category} , visibility = {$visibility} WHERE blogid = {$blogid} AND id = {$entryId}"); if (!in_array($effectedCategoryId, $effectedCategories)) { array_push($effectedCategories, $effectedCategoryId); $parent = getParentCategoryId($blogid, $effectedCategoryId); if (!is_null($parent)) { array_push($effectedCategories, $parent); } } } $effected = false; foreach ($effectedCategories as $effectedCategory) { updateEntriesOfCategory($blogid, $effectedCategory); $effected = true; } if (updateEntriesOfCategory($blogid, $category)) { if ($effected) { clearFeed(); CacheControl::flushDBCache('comment'); CacheControl::flushDBCache('trackback'); } return true; } return false; }
function setCategoryVisibility($blogid, $id, $visibility) { global $database; requireModel('blog.feed'); if ($id == 0) { return false; } $parentVisibility = getParentCategoryVisibility($blogid, $id); if ($parentVisibility !== false && $parentVisibility < 2) { return false; } // return without changing if parent category is set to hidden. $result = POD::query("UPDATE {$database['prefix']}Categories\n\t\tSET visibility = {$visibility}\n\t\tWHERE blogid = {$blogid}\n\t\t\tAND id = {$id}"); if ($result && $visibility == 1) { $result = setChildCategoryVisibility($blogid, $id, $visibility); } if ($result) { clearFeed(); } updateEntriesOfCategory($blogid); CacheControl::flushCategory($id); return $result ? $visibility : false; }
function setCategoryVisibility($blogid, $id, $visibility) { requireModel('blog.feed'); if ($id == 0) { return false; } $parentVisibility = getParentCategoryVisibility($blogid, $id); if ($parentVisibility !== false && $parentVisibility < 2) { return false; } // return without changing if parent category is set to hidden. $pool = DBModel::getInstance(); $pool->reset('Categories'); $pool->setAttribute('visibility', $visibility); $pool->setQualifier('blogid', 'eq', $blogid); $pool->setQualifier('id', 'eq', $id); $result = $pool->update(); if ($result && $visibility == 1) { $result = setChildCategoryVisibility($blogid, $id, $visibility); } if ($result) { clearFeed(); } updateEntriesOfCategory($blogid); CacheControl::flushCategory($id); return $result ? $visibility : false; }
function changeCategoryOfEntries($blogid, $entries, $category) { $ctx = Model_Context::getInstance(); $pool = DBModel::getInstance(); importlib("model.blog.category"); importlib("model.blog.feed"); $targets = array_unique(preg_split('/,/', $entries, -1, PREG_SPLIT_NO_EMPTY)); $effectedCategories = array(); if (count($targets) < 1 || !is_numeric($category)) { return false; } if ($category == -1) { // Check Keyword duplication foreach ($targets as $entryId) { $pool->init("Entries"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("id", "eq", $entryId); $pool->setQualifier("draft", "eq", 0); $title = $pool->getCell("title"); if (is_null($title)) { return false; } $pool->init("Entries"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("id", "neq", $entryId); $pool->setQualifier("draft", "eq", 0); $pool->setQualifier("title", "eq", $title, true); $pool->setQualifier("category", "eq", -1); if ($pool->doesExist("id")) { return false; } } } else { $parent = getParentCategoryId($blogid, $categoryId); array_push($effectedCategories, $parent); } foreach ($targets as $entryId) { $pool->init("Entries"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("id", "eq", $entryId); $pool->setQualifier("draft", "eq", 0); list($effectedCategoryId, $oldVisibility) = $pool->getRow("category, visibility"); $visibility = $oldVisibility; if ($category < 0) { if ($visibility == 1) { $visibility = 0; } if ($visibility == 3) { $visibility = 2; } } if ($oldVisibility == 3 && $visibility != 3) { syndicateEntry($entryId, 'delete'); } $pool->init("Entries"); $pool->setQualifier("blogid", "eq", $blogid); $pool->setQualifier("id", "eq", $entryId); $pool->setAttribute("category", $category); $pool->setAttribute("visibility", $visibility); $pool->update(); if (!in_array($effectedCategoryId, $effectedCategories)) { array_push($effectedCategories, $effectedCategoryId); $parent = getParentCategoryId($blogid, $effectedCategoryId); if (!is_null($parent)) { array_push($effectedCategories, $parent); } } } $effected = false; foreach ($effectedCategories as $effectedCategory) { updateEntriesOfCategory($blogid, $effectedCategory); $effected = true; } if (updateEntriesOfCategory($blogid, $category)) { if ($effected) { clearFeed(); CacheControl::flushDBCache('comment'); CacheControl::flushDBCache('trackback'); } return true; } return false; }