Exemplo n.º 1
0
function isAlsoDefault2($cat)
{
    if ($cat == getCategoryById(getDefaultCategory())) {
        return 'selected="selected"';
    }
    return '';
}
Exemplo n.º 2
0
_e('show');
?>
</a>
        <select style="display: none;" id="cats" multiple="multiple" size="<?php 
echo getCategoryCount();
?>
" name="category[]">
            <?php 
$conn = MySQL::open_conn();
$query = "SELECT ID, name FROM c_categories";
$res = $conn->query($query);
while ($row = $res->fetch_assoc()) {
    if (@in_array($row['ID'], $categories)) {
        $h = 'selected';
    } elseif (!isset($_GET['id']) && !isset($u)) {
        if ($row['ID'] === getDefaultCategory()) {
            $h = 'selected';
            $u = 1;
        }
    } else {
        $h = '';
    }
    echo '<option value="' . $row['ID'] . '"' . $h . '>' . $row['name'] . '</option>';
}
?>
        </select>&nbsp;
    </div>
    <script>
        $(document).ready(function(){
            $("#show_cats").click(function(){
                {
Exemplo n.º 3
0
if (isset($_POST['submit_update_category'])) {
    $name = $_POST['update_category_name'];
    $link_name = urlencode($_POST['update_category_link_name']);
    $name = $conn->real_escape_string($name);
    $id = $_POST['update_category_id'];
    $query = "UPDATE c_categories SET name = '{$name}', link_name = '{$link_name}' WHERE ID = {$id}";
    $res = $conn->query($query);
    if (!$res) {
        goToError('?switch=categories', _e('cant_make_new_category', '', '', true));
    }
    ob_end_clean();
    redirectTo('index.php?switch=categories#manage_cats');
}
if (isset($_POST['submit_delete_category'])) {
    $id = $_POST['update_category_id'];
    $uncategorized_id = getDefaultCategory();
    if ($id == $uncategorized_id) {
        $helper = 1;
        goto end;
        // user should not be able to delete uncategorized category as it's the default category
    }
    $query = "DELETE FROM c_categories WHERE ID = {$id}";
    $res = $conn->query($query);
    $query = "SELECT * FROM c_posts_cats WHERE cat_id IS NULL";
    $res = $conn->query($query);
    while ($row = $res->fetch_assoc()) {
        $post_id = $row['post_id'];
        $id2 = $row['ID'];
        $query2 = "SELECT * FROM c_posts_cats WHERE cat_id IS NULL AND post_id = {$post_id}";
        $q_res = $conn->query($query2)->num_rows;
        if ($q_res == 1) {