/** * Create the breadcrumbs * * @param string $crumb_lang The last language option in the breadcrumbs * @param string $crumb_url The last url option in the breadcrumbs (this will be set to the current URL if this is blank) */ function generate_blog_breadcrumbs($crumb_lang = '', $crumb_url = '') { global $template, $user; global $page, $username, $blog_id, $reply_id; global $blog_urls, $category_id; $template->assign_block_vars('navlinks', array('FORUM_NAME' => $user->lang['BLOGS'], 'U_VIEW_FORUM' => $blog_urls['main'])); if ($category_id || $username) { if ($category_id) { $category_nav = get_category_branch($category_id, 'parents', 'descending'); foreach ($category_nav as $row) { $template->assign_block_vars('navlinks', array('FORUM_NAME' => $row['category_name'], 'U_VIEW_FORUM' => blog_url(false, false, false, array('page' => $row['category_name'], 'c' => $row['category_id'])))); } } else { if ($username != '') { $template->assign_block_vars('navlinks', array('FORUM_NAME' => $user->data['username'] == $username ? $user->lang['MY_BLOG'] : sprintf($user->lang['USERNAMES_BLOGS'], $username), 'U_VIEW_FORUM' => $blog_urls['view_user'])); } } if ($blog_id != 0) { $template->assign_block_vars('navlinks', array('FORUM_NAME' => censor_text(blog_data::$blog[$blog_id]['blog_subject']), 'U_VIEW_FORUM' => $blog_urls['view_blog'])); if ($reply_id != 0 && $page == 'reply') { $c_text = censor_text(blog_data::$reply[$reply_id]['reply_subject']); if ($c_text) { $template->assign_block_vars('navlinks', array('FORUM_NAME' => $c_text, 'U_VIEW_FORUM' => $blog_urls['view_reply'])); } } } } if ($crumb_lang != '') { $template->assign_block_vars('navlinks', array('FORUM_NAME' => $crumb_lang, 'U_VIEW_FORUM' => $crumb_url ? $crumb_url : $blog_urls['self'])); } }
/** * Remove complete category */ function delete_category($category_id, $action_blogs = 'delete', $action_subcategories = 'delete', $blogs_to_id = 0, $subcategories_to_id = 0) { global $db, $user; $category_data = $this->get_category_info($category_id); $errors = array(); $log_action_posts = $log_action_categories = $posts_to_name = $subcategories_to_name = ''; $category_ids = array($category_id); if (sizeof($errors)) { return $errors; } if ($action_blogs == 'delete') { $errors = array_merge($errors, $this->delete_category_content($category_id)); } else { if ($action_blogs == 'move') { if (!$blogs_to_id) { $errors[] = $user->lang['NO_DESTINATION_CATEGORY']; } else { $sql = 'SELECT category_name FROM ' . BLOGS_CATEGORIES_TABLE . ' WHERE category_id = ' . $blogs_to_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $errors[] = $user->lang['NO_CATEGORY']; } else { $blogs_to_name = $row['category_name']; $errors = array_merge($errors, $this->move_category_content($category_id, $blogs_to_id)); } } } } if (sizeof($errors)) { return $errors; } if ($action_subcategories == 'delete') { $rows = get_category_branch($category_id, 'children', 'descending', false); foreach ($rows as $row) { $category_ids[] = $row['category_id']; $errors = array_merge($errors, $this->delete_category_content($row['category_id'])); } if (sizeof($errors)) { return $errors; } $diff = sizeof($category_ids) * 2; $sql = 'DELETE FROM ' . BLOGS_CATEGORIES_TABLE . ' WHERE ' . $db->sql_in_set('category_id', $category_ids); $db->sql_query($sql); } else { if ($action_subcategories == 'move') { if (!$subcategories_to_id) { $errors[] = $user->lang['NO_DESTINATION_FORUM']; } else { $log_action_categories = 'MOVE_CATEGORIES'; $sql = 'SELECT category_name FROM ' . BLOGS_CATEGORIES_TABLE . ' WHERE category_id = ' . $subcategories_to_id; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); if (!$row) { $errors[] = $user->lang['NO_CATEGORY']; } else { $subcategories_to_name = $row['category_name']; $sql = 'SELECT category_id FROM ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\t\t\t\tWHERE parent_id = {$category_id}"; $result = $db->sql_query($sql); while ($row = $db->sql_fetchrow($result)) { $this->move_category($row['category_id'], $subcategories_to_id); } $db->sql_freeresult($result); // Grab new category data for correct tree updating later $category_data = $this->get_category_info($category_id); $sql = 'UPDATE ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\t\t\t\tSET parent_id = {$subcategories_to_id}\n\t\t\t\t\t\tWHERE parent_id = {$category_id}"; $db->sql_query($sql); $diff = 2; $sql = 'DELETE FROM ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\t\t\t\tWHERE category_id = {$category_id}"; $db->sql_query($sql); } } if (sizeof($errors)) { return $errors; } } else { $diff = 2; $sql = 'DELETE FROM ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\t\tWHERE category_id = {$category_id}"; $db->sql_query($sql); } } // Resync tree $sql = 'UPDATE ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\tSET right_id = right_id - {$diff}\n\t\t\tWHERE left_id < {$category_data['right_id']} AND right_id > {$category_data['right_id']}"; $db->sql_query($sql); $sql = 'UPDATE ' . BLOGS_CATEGORIES_TABLE . "\n\t\t\tSET left_id = left_id - {$diff}, right_id = right_id - {$diff}\n\t\t\tWHERE left_id > {$category_data['right_id']}"; $db->sql_query($sql); add_log('admin', 'LOG_CATEGORY_DELETE', $category_data['category_name']); return $errors; }