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; } }
} else { $op['text'] = $value; } $selector_options[] = $op; } $smarty->assign('selectable_content_per_page', $selector_options); } $smarty->assign('cat_id', $HTTP_GET_VARS['cat_id']); // proceed comments $comment_type = 'cat'; include 'includes/proceed_comment.inc.php'; //Show comments $root_comments = get_comments_of_cat($HTTP_GET_VARS['cat_id']); if (sizeof($root_comments) > 0) { for ($i = 0; $i < sizeof($root_comments); $i++) { make_comments($root_comments[$i], 0, check_cat_action_allowed($HTTP_GET_VARS['cat_id'], $userdata['user_id'], 'comment_edit')); } $smarty->assign('comments', $comments); } else { $smarty->assign('comments', 'false'); } //link where to go when back to thumbs $HTTP_SESSION_VARS['thumb_link'] = "view_cat.php?cat_id={$HTTP_GET_VARS['cat_id']}"; $smarty->assign('thumb_link', $HTTP_SESSION_VARS['thumb_link']); $smarty->assign('current_page', $HTTP_SESSION_VARS['thumb_link']); //thats for the index.php who needs another template file. index.php just set the $template_file to another value and includes this file if (!isset($template_file)) { $template_file = 'view_cat'; } $smarty->assign('nav_string', build_nav_string($HTTP_GET_VARS['cat_id'])); $smarty->assign('redirect', PHREAKPIC_PATH . "{$template_file}.php");
function remove_from_cat($old_cat_id) { global $userdata; // $result = new phreak_error(); // $result->set_object_id($this->id); // $result->set_should_value($old_cat_id); // $result->set_operation('remove_from_cat'); if (!is_array($this->cat_ids)) { $this->generate_content_in_cat_data(); } $this->remove_from_cat = new categorie(); $this->remove_from_cat->generate_from_id($old_cat_id); // check perms (needs content_remove) if (check_cat_action_allowed($this->remove_from_cat->catgroup_id, $userdata['user_id'], "content_remove")) { // check if content is in cat if (in_array($old_cat_id, $this->cat_ids)) { // unset the key that contains the cat to be removed array_splice($this->cat_ids, array_search($old_cat_id, $this->cat_ids), 1); $this->remove_from_cat->set_content_amount($this->remove_from_cat->get_content_amount() - 1); $this->new_filename = $this->generate_filename(); // $result->set_type(NO_ERROR); return OP_SUCCESSFUL; } else { $error = new phreak_error(E_WARNING, GENERAL_ERROR, __LINE__, __FILE__, 'remove_from_cat', $this->id, 0, $old_cat_id, $sql); $error->commit(); /* $result->set_why(OP_CONTENT_NOT_IN_CAT); $result->set_type(GENERAL_ERROR);*/ return $error; } } else { /* $result->set_why(OP_NP_MISSING_EDIT); $result->set_type(AUTH_ERROR);*/ $error = new phreak_error(E_WARNING, AUTH_ERROR, __LINE__, __FILE__, 'commit', $this->id, 0, $old_cat_id, $sql); $error->commit(); return $error; } }
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); } }
$vals['move'] = $HTTP_POST_VARS['move'][$i]; $vals['change_group'] = $HTTP_POST_VARS['change_group'][$i]; $vals['to_contentgroup'] = $HTTP_POST_VARS['to_contentgroup']; $vals['delete'] = $HTTP_POST_VARS['delete'][$i]; $contents[$i]->edit_content($vals, $cat_id); } } $smarty->assign('mode', 'view'); $smarty->assign('edited', true); $contents = get_content_of_cat($cat_id); } // check if user is allowed to unlink from this cat if ($mode == 'edit') { $smarty->assign('mode', 'edit'); if (is_object($category)) { $smarty->assign('allow_content_remove', check_cat_action_allowed($category->get_catgroup_id(), $userdata['user_id'], 'content_remove')); } // Check if user has rights to add content to a cat (zu irgendeiner) //dass auch $add_to_cats_unparsed = get_cats_data_where_perm('id,name', 'content_add'); $add_to_cats = get_cats_string($add_to_cats_unparsed); if (is_array($add_to_cats)) { $smarty->assign('allow_link', true); $smarty->assign('add_to_cats', $add_to_cats); } } //show thumbnails and get some infos about the content for ($i = 1; $i <= sizeof($contents); $i++) { $thumb_infos = $contents[$i - 1]->get_thumb(); $thumb_infos['add_params'] = $contents[$i - 1]->add_params; if ($mode == 'edit') {
} // 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); }