function calc_child_comments_amount()
    {
        global $db, $config_vars;
        //get the comments from  cat
        $sql = 'SELECT count(cat_comments.id) FROM ' . $config_vars['table_prefix'] . 'cat_comments AS cat_comments WHERE cat_comments.owner_id = ' . $this->id;
        if (!($result = $db->sql_query($sql))) {
            $error = new phreak_error(E_WARNING, SQL_ERROR, __LINE__, __FILE__, 'calc_child_comments_amoount', $this->id, 0, 0, $sql);
            $error->commit();
            error_report(SQL_ERROR, 'commit', __LINE__, __FILE__, $sql);
        }
        $row = $db->sql_fetchrow($result);
        $amount = $row[0];
        //get the comments from content
        $sql = 'SELECT count(content_comments.id) 
				FROM ' . $config_vars['table_prefix'] . 'content_comments AS content_comments, ' . $config_vars['table_prefix'] . 'content_in_cat AS content_in_cat 
				WHERE (content_in_cat.cat_id = ' . $this->id . ') AND (content_in_cat.content_id = content_comments.owner_id)';
        if (!($result = $db->sql_query($sql))) {
            error_report(SQL_ERROR, 'commit', __LINE__, __FILE__, $sql);
        }
        $row = $db->sql_fetchrow($result);
        $amount += $row[0];
        $child_cats = get_cats_of_cat($this->id);
        for ($i = 0; $i < sizeof($child_cats); $i++) {
            if ($child_cats[$i]->id != $config_vars['root_categorie']) {
                $amount += $child_cats[$i]->calc_child_comments_amount();
            }
        }
        return $amount;
    }
Esempio n. 2
0
        $child_cats[$i]->set_description($HTTP_POST_VARS['cat_description'][$i]);
        $child_cats[$i]->set_catgroup_id($HTTP_POST_VARS['cat_catgroup'][$i], $HTTP_POST_VARS['cat_apply_recursive'][$i]);
        $child_cats[$i]->set_parent_id($HTTP_POST_VARS['cat_parent_cat'][$i]);
        if ($HTTP_POST_VARS['cat_delete'][$i] == 'on') {
            $error = $child_cats[$i]->delete('CDM_REMOVE_CONTENT');
            if ($error != OP_SUCCESSFUL) {
                error_report(GENERAL_ERROR, 'del_cat', __LINE__, __FILE__, $error);
            }
        } else {
            $error = $child_cats[$i]->commit();
            if ($error != OP_SUCCESSFUL) {
                error_report(GENERAL_ERROR, 'cat_commit', __LINE__, __FILE__, $error);
            }
        }
    }
    $child_cats = get_cats_of_cat($HTTP_GET_VARS['cat_id']);
}
//Get the contents of the actual cat and their thumbnails plus information like
$category = new categorie();
$category->generate_from_id($HTTP_GET_VARS['cat_id']);
if (isset($child_cats)) {
    for ($i = 0; $i < sizeof($child_cats); $i++) {
        $child_cat_infos[$i]['id'] = $child_cats[$i]->get_id();
        $child_cat_infos[$i]['parent_id'] = $child_cats[$i]->get_parent_id();
        $child_cat_infos[$i]['name'] = htmlspecialchars($child_cats[$i]->get_name());
        $child_cat_infos[$i]['description'] = htmlspecialchars($child_cats[$i]->get_description());
        $child_cat_infos[$i]['content_amount'] = $child_cats[$i]->get_content_amount();
        $child_cat_infos[$i]['content_child_amount'] = $child_cats[$i]->get_child_content_amount() - $child_cat_infos[$i]['content_amount'];
        $child_cat_infos[$i]['current_rating'] = $child_cats[$i]->get_current_rating();
        $child_cat_infos[$i]['remove_from_group'] = $child_cats[$i]->check_perm('remove_from_group');
        $child_cat_infos[$i]['delete'] = $child_cats[$i]->check_perm('delete');