function set_parent_id($new_parent_id)
 {
     global $userdata;
     // get objekt for the parent cat
     $new_parent = new categorie();
     if ($new_parent->generate_from_id($new_parent_id) == OP_SUCCESSFUL) {
         // check if user has cat_add rights in the parent group
         if (check_cat_action_allowed($new_parent->catgroup_id, $userdata['user_id'], 'cat_add')) {
             $parent = new categorie();
             if ($parent->generate_from_id($this->parent_id) == OP_SUCCESSFUL) {
                 // if this categoris is already in the db you also need move rights
                 if (isset($this->id) and !check_cat_action_allowed($parent->catgroup_id, $userdata['user_id'], 'cat_remove')) {
                     return OP_NP_MISSING_CAT_MOVE;
                 }
             }
             $this->parent_id = $new_parent_id;
             return OP_SUCCESSFUL;
         } else {
             return OP_NP_MISSING_CAT_ADD;
         }
     } else {
         return OP_PARENT_ID_INVALID;
     }
 }
示例#2
0
            $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');
        $child_cat_infos[$i]['edit'] = $child_cats[$i]->check_perm('edit');
        $child_cat_infos[$i]['catgroup_id'] = $child_cats[$i]->get_catgroup_id();
        $child_cat_infos[$i]['comments_amount'] = $child_cats[$i]->get_child_comments_amount();
    }
示例#3
0
                $content = get_content_object_from_id($HTTP_POST_VARS['id'][$key]);
                $content->set_comments_amount($content->calc_comments_amount());
                $content->commit();
            }
        }
    }
}
// check content amount for each cat
// get all categories
$sql = "SELECT id FROM " . $config_vars['table_prefix'] . "cats";
if (!($result = $db->sql_query($sql))) {
    message_die(GENERAL_ERROR, "Coudnt get cats", '', __LINE__, __FILE__, $sql);
}
while ($row = $db->sql_fetchrow($result)) {
    $cat = new categorie();
    $cat->generate_from_id($row['id']);
    $catarray[] = $cat;
}
foreach ($catarray as $cat) {
    // check how many content is in this cat
    $should_be = $cat->calc_content_amount();
    if ($should_be != $cat->get_content_amount()) {
        $missmatch['type'] = CONTENT_IN_CAT_AMOUNT;
        $missmatch['id'] = $cat->id;
        $missmatch['name'] = $cat->get_name();
        $missmatch['value'] = $cat->get_content_amount();
        $missmatch['should_be'] = $should_be;
        $missmatch_array[] = $missmatch;
    }
    // check child_content_amount
    $calc_child_content_amount = $cat->calc_child_content_amount();
 function generate_filename()
 {
     global $config_vars;
     //check if content is already in a cat
     if (!isset($this->cat_ids)) {
         $this->generate_content_in_cat_data();
     }
     if (sizeof($this->cat_ids) > 0) {
         $cat_obj = new categorie();
         $cat_obj->generate_from_id($this->cat_ids[0]);
         $path = $cat_obj->get_name();
         while ($cat_obj->get_parent_id() != $config_vars['root_categorie']) {
             $old_cat_id = $cat_obj->get_parent_id();
             $cat_obj = new categorie();
             $cat_obj->generate_from_id($old_cat_id);
             $path = $cat_obj->get_name() . '/' . $path;
         }
         // make $path is it doesnt exists
         if (!is_dir($config_vars['content_path_prefix'] . '/' . $path)) {
             makedir($config_vars['content_path_prefix'] . '/' . $path);
         }
         $path = $path . '/' . basename($this->name) . '.' . getext($this->file);
         $filename = $config_vars['content_path_prefix'] . '/' . $path;
         // if filename has changed check if such a file does not already exists is so add a number behind till its a new file
         if ($this->file != $filename) {
             $newfilename = $filename;
             $i = 0;
             while (is_file($newfilename)) {
                 $newfilename = getfile($filename) . "-{$i}." . getext($filename);
                 $i++;
             }
             $filename = $newfilename;
         }
         return $filename;
     } else {
         return OP_CONTENT_NOT_IN_CAT;
     }
 }
function build_nav_string($cat_id)
{
    global $config_vars, $lang;
    //get the navigation string
    $cat = new categorie();
    $result = $cat->generate_from_id($cat_id);
    if ($result) {
    }
    $parent_cats = $cat->get_parent_cat_array();
    //build the navigation string
    for ($i = 0; $i < sizeof($parent_cats); $i++) {
        $nav_string[$i]['id'] = $parent_cats[$i]['id'];
        $nav_string[$i]['name'] = $parent_cats[$i]['name'];
    }
    return $nav_string;
}
 function delete()
 {
     global $db, $config_vars, $userdata;
     // remove from content table
     // check is user is allowed
     $cat = new categorie();
     $cat->generate_from_id($this->owner_id);
     if ($userdata['user_id'] == $this->user_id or check_cat_action_allowed($cat->get_catgroup_id(), $userdata['user_id'], 'content_edit')) {
         $sql = "DELETE FROM " . $config_vars['table_prefix'] . "cat_comments WHERE id = " . $this->id;
         if (!($result = $db->sql_query($sql))) {
             error_report(SQL_ERROR, 'delete', __LINE__, __FILE__, $sql);
         }
         $cat->dec_child_comments_amount();
         $cat->commit();
         unset($this->id);
     }
 }
        $smarty->assign('add_to_cats', $add_to_cats);
    }
    // Check if the user has remove_from_group right for this content
    if ($content->check_perm('remove_from_group')) {
        // get the groups where the user has add_to_group rights
        $add_to_contentgroups = get_contentgroups_data_where_perm('id,name', 'add_to_group');
        if (is_array($add_to_contentgroups)) {
            $smarty->assign('add_to_contentgroups', $add_to_contentgroups);
            $smarty->assign('contentgroup', $content->get_contentgroup_id());
        }
    }
}
$smarty->assign('edit_info', $edit_info);
// Check if user has content_remove rights on this categorie
$cat_obj = new categorie();
$cat_obj->generate_from_id($HTTP_GET_VARS['cat_id']);
if (check_cat_action_allowed($cat_obj->get_catgroup_id(), $userdata['user_id'], 'content_remove')) {
    $smarty->assign('allow_content_remove', 1);
}
if ($redirect_to_cat) {
    $header_location = @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ? "Refresh: 0; URL=" : "Location: ";
    header($header_location . append_sid("view_cat.php?cat_id={$HTTP_GET_VARS['cat_id']}", true));
}
//Show comments
$root_comments = get_comments_of_content($HTTP_GET_VARS['content_id']);
for ($i = 0; $i < sizeof($root_comments); $i++) {
    make_comments($root_comments[$i], 0, $content->check_perm('comment_edit'));
}
$smarty->assign('comments', $comments);
if (check_content_action_allowed($content->get_contentgroup_id(), $userdata['user_id'], 'comment_edit')) {
    $smarty->assign('allow_comment_edit', true);
$smarty->template_dir = ROOT_PATH . 'templates/';
$smarty->compile_dir = ROOT_PATH . 'templates_c/';
$smarty->config_dir = ROOT_PATH . 'templates/';
$smarty->cache_dir = ROOT_PATH . 'smarty_cache/';
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$smarty->force_compile = '0';
$smarty->debugging = false;
//$smarty->debug_tpl = SMARTY_DIR.'debug.tpl';
//this vars are needed on every page
$smarty->assign('title_site', $board_config['sitename']);
//this vars are needed in view_cat AND view_content
$smarty->assign('lang', $lang);
$smarty->assign('phpbb_path', ROOT_PATH . PHPBB_PATH);
$smarty->assign('server_name', SERVER_NAME);
$smarty->assign('template_name', $userdata['photo_user_template']);
$smarty->assign('sid', '&sid=' . $userdata['session_id']);
$smarty->assign('username', $userdata['username']);
$smarty->assign('user_id', $userdata['user_id']);
//set if the actual user is admin or not
if ($userdata['user_level'] == 1) {
    $smarty->assign('user_level', 'admin');
} else {
    $smarty->assign('user_level', 'user');
}
// get statistics data
$root_cat = new categorie();
$root_cat->generate_from_id($config_vars['root_categorie']);
$smarty->assign('total_content', $root_cat->get_child_content_amount());
$smarty->assign('total_comments', $root_cat->get_child_comments_amount());
$smarty->assign('root_path', ROOT_PATH);