Esempio n. 1
0
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;
}
Esempio n. 2
0
    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.
        $children = getChildCategoryId(getBlogId(), $categoryId);
        if (!empty($children)) {
            $categoryIds = array_merge($categoryIds, $children);
        }
    }
    requireModel("blog.feed");
    $result = getCategoryFeedByCategoryId(getBlogId(), $categoryIds, 'atom', $categoryTitle);
    if ($result !== false) {
        $cache->reset('categoryATOM-' . $categoryId);
        $cache->contents = $result;
        $cache->update();
    }
}
Esempio n. 3
0
    $selected = $_POST['id'];
} else {
    if (empty($_GET['id'])) {
        $selected = 0;
    } else {
        $selected = $_GET['id'];
    }
}
if (!empty($_POST['visibility'])) {
    $setVisibility = $_POST['visibility'];
    $visibility = setCategoryVisibility($blogid, $selected, $setVisibility);
} else {
    $visibility = getCategoryVisibility($blogid, $selected);
}
if (!empty($_POST['deleteCategory'])) {
    $parent = getParentCategoryId($blogid, $_POST['deleteCategory']);
    $selected = is_null($parent) ? 0 : $parent;
    $_POST['modifyCategoryName'] = '';
    $_POST['modifyCategoryBodyId'] = '';
    deleteCategory($blogid, $_POST['deleteCategory']);
}
if (!empty($_POST['direction'])) {
    moveCategory($blogid, $selected, $_POST['direction']);
}
if ($selected == 0) {
    $depth = 0;
} else {
    if (!empty($_GET['name1']) && !empty($_GET['name2'])) {
        $depth = 2;
    } else {
        if (!empty($_GET['name1']) && empty($_GET['name2'])) {
Esempio n. 4
0
    }
    if (!$error) {
        $sql = "UPDATE sptbl_categories SET nDeptId = '" . $var_departmentid . "', vCatDesc='" . $var_catname . "', nParentId = '" . $var_parentcatid . "' ";
        $sql .= "WHERE nCatId= '" . mysql_real_escape_string($var_catid) . "'";
        executeQuery($sql, $conn);
        updateRoute($var_catid, $var_parentcatid);
        //Insert the actionlog
        if (logActivity()) {
            $sql = "Insert into sptbl_actionlog(nALId,nStaffId,vAction,vArea,nRespId,dDate) Values('','{$var_staffid}','" . TEXT_UPDATION . "','Categories','" . mysql_real_escape_string($var_id) . "',now())";
            executeQuery($sql, $conn);
        }
        $message = true;
        $infomessage = MESSAGE_RECORD_UPDATED;
        $flag_msg = 'class="msg_success"';
    } else {
        $var_parentcatid = getParentCategoryId($var_catid);
    }
} elseif ($_POST["postback"] == "CC") {
    //change company
    $var_companyid = trim($_POST["cmbCompany"]);
    $sql = "SELECT d.nDeptId FROM sptbl_depts d ";
    $sql .= " WHERE d.nCompId = '" . mysql_real_escape_string($var_companyid) . "' ";
    $var_result = executeSelect($sql, $conn);
    if (mysql_num_rows($var_result) > 0) {
        $var_row = mysql_fetch_array($var_result);
        $var_departmentid = $var_row["nDeptId"];
    }
    $var_catname = trim($_POST["txtCategoryName"]);
} elseif ($_POST["postback"] == "CD") {
    $var_companyid = trim($_POST["cmbCompany"]);
    $var_departmentid = trim($_POST["cmbDepartment"]);
Esempio n. 5
0
function updateEntriesOfCategory($blogid, $categoryId = -1)
{
    $ctx = Model_Context::getInstance();
    clearCategoryCache();
    if ($categoryId == -1) {
        $result = POD::queryAll("SELECT * FROM " . $ctx->getProperty('database.prefix') . "Categories WHERE blogid = {$blogid} AND parent IS NULL");
    } else {
        $parent = getParentCategoryId($blogid, $categoryId);
        if (empty($parent)) {
            // It is parent.
            $lookup = $categoryId;
        } else {
            $lookup = $parent;
        }
        $result = POD::queryAll("SELECT * FROM " . $ctx->getProperty('database.prefix') . "Categories WHERE blogid = {$blogid} AND id = {$lookup}");
    }
    foreach ($result as $row) {
        $parent = $row['id'];
        $parentName = Utils_Unicode::lessenAsEncoding($row['name'], 127);
        $row['name'] = POD::escapeString($parentName);
        $countParent = POD::queryCell("SELECT COUNT(id) FROM " . $ctx->getProperty('database.prefix') . "Entries WHERE blogid = {$blogid} AND draft = 0 AND visibility > 0 AND category = {$parent}");
        $countInLoginParent = POD::queryCell("SELECT COUNT(id) FROM " . $ctx->getProperty('database.prefix') . "Entries WHERE blogid = {$blogid} AND draft = 0 AND category = {$parent}");
        $result2 = POD::queryAll("SELECT * FROM " . $ctx->getProperty('database.prefix') . "Categories WHERE blogid = {$blogid} AND parent = {$parent}");
        foreach ($result2 as $rowChild) {
            $label = POD::escapeString(Utils_Unicode::lessenAsEncoding($parentName . '/' . $rowChild['name'], 255));
            $rowChild['name'] = POD::escapeString(Utils_Unicode::lessenAsEncoding($rowChild['name'], 127));
            $countChild = POD::queryCell("SELECT COUNT(id) FROM " . $ctx->getProperty('database.prefix') . "Entries WHERE blogid = {$blogid} AND draft = 0 AND visibility > 0 AND category = {$rowChild['id']}");
            $countInLogInChild = POD::queryCell("SELECT COUNT(id) FROM " . $ctx->getProperty('database.prefix') . "Entries WHERE blogid = {$blogid} AND draft = 0 AND category = {$rowChild['id']}");
            POD::query("UPDATE " . $ctx->getProperty('database.prefix') . "Categories SET entries = {$countChild}, entriesinlogin = {$countInLogInChild}, label = '{$label}' WHERE blogid = {$blogid} AND id = {$rowChild['id']}");
            $countParent += $countChild;
            $countInLoginParent += $countInLogInChild;
        }
        POD::query("UPDATE " . $ctx->getProperty('database.prefix') . "Categories SET entries = {$countParent}, entriesinlogin = {$countInLoginParent}, label = '{$row['name']}' WHERE blogid = {$blogid} AND id = {$parent}");
    }
    if ($categoryId >= 0) {
        CacheControl::flushCategory($categoryId);
    }
    return true;
}
Esempio n. 6
0
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;
}
Esempio n. 7
0
function updateEntriesOfCategory($blogid, $categoryId = -1)
{
    $context = Model_Context::getInstance();
    clearCategoryCache();
    $pool = DBModel::getInstance();
    if ($categoryId == -1) {
        $pool->reset("Categories");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("parent", "eq", null);
        $result = $pool->getAll();
    } else {
        $parent = getParentCategoryId($blogid, $categoryId);
        if (empty($parent)) {
            // It is parent.
            $lookup = $categoryId;
        } else {
            $lookup = $parent;
        }
        $pool->reset("Categories");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("id", "eq", $lookup);
        $result = $pool->getAll();
    }
    foreach ($result as $row) {
        $parent = $row['id'];
        $parentName = Utils_Unicode::lessenAsEncoding($row['name'], 127);
        $row['name'] = $parentName;
        $pool->reset("Entries");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("draft", "eq", 0);
        $pool->setQualifier("visibility", ">", 0);
        $pool->setQualifier("category", "eq", $parent);
        $countParent = $pool->getCount('id');
        $pool->reset("Entries");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("draft", "eq", 0);
        $pool->setQualifier("category", "eq", $parent);
        $countInLoginParent = $pool->getCount('id');
        $pool->reset("Categories");
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("parent", "eq", $parent);
        $result2 = $pool->getAll();
        foreach ($result2 as $rowChild) {
            $label = Utils_Unicode::lessenAsEncoding($parentName . '/' . $rowChild['name'], 255);
            $rowChild['name'] = Utils_Unicode::lessenAsEncoding($rowChild['name'], 127);
            $pool->reset("Entries");
            $pool->setQualifier("blogid", "eq", $blogid);
            $pool->setQualifier("draft", "eq", 0);
            $pool->setQualifier("visibility", ">", 0);
            $pool->setQualifier("category", "eq", $rowChild['id']);
            $countChild = $pool->getCount('id');
            $pool->reset("Entries");
            $pool->setQualifier("blogid", "eq", $blogid);
            $pool->setQualifier("draft", "eq", 0);
            $pool->setQualifier("category", "eq", $rowChild['id']);
            $countInLogInChild = $pool->getCount('id');
            $pool->reset("Categories");
            $pool->setAttribute("entries", $countChild);
            $pool->setAttribute("entriesinlogin", $countInLogInChild);
            $pool->setAttribute("label", $label, true);
            $pool->setQualifier("blogid", "eq", $blogid);
            $pool->setQualifier("id", "eq", $rowChild['id']);
            $pool->update();
            $countParent += $countChild;
            $countInLoginParent += $countInLogInChild;
        }
        $pool->reset("Categories");
        $pool->setAttribute("entries", $countParent);
        $pool->setAttribute("entriesinlogin", $countInLoginParent);
        $pool->setAttribute("label", $row['name'], true);
        $pool->setQualifier("blogid", "eq", $blogid);
        $pool->setQualifier("id", "eq", $parent);
        $pool->update();
    }
    if ($categoryId >= 0) {
        CacheControl::flushCategory($categoryId);
    }
    return true;
}