Пример #1
0
 function delete($mode, $mode_params = 0, $content_removed = 0, $cats_removed = 0)
 {
     // deletes the categorie assigned with this object from the database
     global $db, $config_vars, $userdata;
     if (isset($this->id)) {
         $keep = false;
         // check if user has permission to do that
         $parent_cat = new categorie();
         $parent_cat->generate_from_id($this->parent_id);
         if (check_cat_action_allowed($parent_cat->get_catgroup_id(), $userdata['user_id'], 'cat_remove')) {
             if ($mode == CDM_MOVE_CONTENT) {
                 // check if user has right to edit all content in this categorie
                 // move content in this categorie to the cat with id $mode_params
                 // wie genau soll man hier mit den perms umgehen ??
             } else {
                 // check if there is content to be removed
                 $content = get_content_of_cat($this->id);
                 if (is_array($content)) {
                     // check is user is allowed to do that
                     if (check_cat_action_allowed($this->catgroup_id, $userdata['user_id'], 'content_remove')) {
                         // there is content to be removed
                         for ($i = 0; $i < sizeof($content); $i++) {
                             if ($content[$i]->remove_from_cat($this->id) == OP_SUCCESSFUL and $content[$i]->commit()) {
                                 $content_removed++;
                             } else {
                                 // not all content was removed do not delete this cat
                                 $keep = true;
                             }
                         }
                     } else {
                         $keep = true;
                     }
                 }
                 // check if user is allowed th remove cats from this cat
                 $cats = get_cats_of_cat($this->id);
                 if (is_array($cats)) {
                     // there are cats to be removed
                     if (check_cat_action_allowed($this->catgroup_id, $userdata['user_id'], 'cat_remove')) {
                         for ($i = 0; $i < sizeof($cats); $i++) {
                             if ($cats[$i]->delete($mode, $mode_params, $content_removed, $cats_removed) == OP_SUCCESSFUL) {
                                 $cats_removed++;
                             } else {
                                 // not all cats were removed do not delete this cat
                             }
                         }
                     } else {
                         $keep = true;
                     }
                 }
                 // delete content of the cat
             }
             if (!$keep) {
                 $sql = 'DELETE FROM ' . $config_vars['table_prefix'] . "cats where id like {$this->id}";
                 if (!($result = $db->sql_query($sql))) {
                     $error = new phreak_error(E_WARNING, SQL_ERROR, __LINE__, __FILE__, 'delete', $this->id, 0, 0, $sql);
                     $error->commit();
                     // 						error_report(SQL_ERROR, 'delete' , __LINE__, __FILE__,$sql);
                 }
                 unset($this->id);
                 return OP_SUCCESSFUL;
             }
             return OP_PARTLY_SUCCESSFUL;
         } else {
             return OP_NP_MISSING_DELETE;
         }
     } else {
         return OP_NOT_IN_DB;
     }
 }
 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);
     }
 }
Пример #3
0
        $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();
    }
    // in edit mode check on which cats user has rights to remove cat
    if ($HTTP_GET_VARS['mode'] == 'edit') {
        $smarty->assign('allow_cat_remove', check_cat_action_allowed($category->get_catgroup_id(), $userdata['user_id'], 'cat_remove'));
        $add_to_cats_unparsed = get_cats_data_where_perm('id,name', 'cat_add');
        $add_to_cats = get_cats_string($add_to_cats_unparsed);
        $smarty->assign('add_to_cats', $add_to_cats);
    }
    $smarty->assign('child_cat_infos', $child_cat_infos);
    $smarty->assign('number_of_child_cats', $i);
} else {
    //no child cats
    $smarty->assign('number_of_child_cats', 0);
}
// check is user is allowed to add a child cat
$smarty->assign('allow_cat_add', check_cat_action_allowed($category->get_catgroup_id(), $userdata['user_id'], 'cat_add'));
if ($HTTP_GET_VARS['mode'] == 'edit') {
    $smarty->assign('mode', 'edit');
    $add_to_catgroups = get_catgroups_data_where_perm('id,name', 'add_to_group');
Пример #4
0
    }
    // 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);
}