Esempio n. 1
0
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;
}
Esempio n. 2
0
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;
}