function bp_forums_delete_group_forum($group_id) { $forum_id = groups_get_groupmeta($group_id, 'forum_id'); if (!empty($forum_id) && is_int($forum_id)) { do_action('bbpress_init'); bb_delete_forum($forum_id); } }
bb_die(__('No forums to update!')); } if ((int) $_POST['forum_id'] && isset($_POST['forum_name']) && '' !== $_POST['forum_name']) { bb_update_forum($_POST); } foreach (array('action', 'id') as $arg) { $sent_from = remove_query_arg($arg, $sent_from); } bb_safe_redirect(add_query_arg('message', 'updated', $sent_from)); exit; break; case 'delete': bb_check_admin_referer('delete-forums'); $forum_id = (int) $_POST['forum_id']; $move_topics_forum = (int) $_POST['move_topics_forum']; if (!bb_current_user_can('delete_forum', $forum_id)) { bb_die(__("You don't have the authority to kill off the forums.")); } if (isset($_POST['move_topics']) && $_POST['move_topics'] != 'delete') { bb_move_forum_topics($forum_id, $move_topics_forum); } if (!bb_delete_forum($forum_id)) { bb_die(__('Error occured while trying to delete forum')); } foreach (array('action', 'id') as $arg) { $sent_from = remove_query_arg($arg, $sent_from); } bb_safe_redirect(add_query_arg('message', 'deleted', $sent_from)); exit; break; }
/** * Deletes a forum * * @since 1.0 * @return integer|object 1 when successfully deleted or an IXR_Error object on failure * @param array $args Arguments passed by the XML-RPC call * @param string $args[0] The username for authentication * @param string $args[1] The password for authentication * @param integer|string $args[2] The unique id of the forum to be deleted * * XML-RPC request to delete a forum with the slug "naughty-forum" * <methodCall> * <methodName>bb.deleteForum</methodName> * <params> * <param><value><string>joeblow</string></value></param> * <param><value><string>123password</string></value></param> * <param><value><string>naughty-forum</string></value></param> * </params> * </methodCall> */ function bb_deleteForum($args) { do_action('bb_xmlrpc_call', 'bb.deleteForum'); // Escape args $this->escape($args); // Get the login credentials $username = $args[0]; $password = (string) $args[1]; // Check the user is valid $user = $this->authenticate($username, $password, 'delete_forums', __('You do not have permission to delete forums.')); do_action('bb_xmlrpc_call_authenticated', 'bb.deleteForum'); // If an error was raised by authentication or by an action then return it if ($this->error) { return $this->error; } // Can be numeric id or slug $forum_id = isset($args[2]) ? $args[2] : false; // Check for bad data if (!$forum_id || !is_string($forum_id) && !is_integer($forum_id)) { $this->error = new IXR_Error(400, __('The forum id is invalid.')); return $this->error; } // Check the requested forum exists if (!($forum = bb_get_forum($forum_id))) { $this->error = new IXR_Error(400, __('No forum found.')); return $this->error; } // Cast the forum object as an array $forum = (array) $forum; // The forum id may have been a slug, so make sure it's an integer here $forum_id = (int) $forum['forum_id']; // Make sure they are allowed to delete this forum specifically if (!bb_current_user_can('delete_forum', $forum_id)) { $this->error = new IXR_Error(403, __('You do not have permission to delete this forum.')); return $this->error; } // Leave the require until the very end require_once BB_PATH . 'bb-admin/includes/functions.bb-admin.php'; // Delete the forum if (!bb_delete_forum($forum_id)) { $this->error = new IXR_Error(500, __('The forum could not be deleted.')); return $this->error; } $result = 1; do_action('bb_xmlrpc_call_return', 'bb.deleteForum'); return $result; }
/** * Delete a group forum by the group id. * * @param int $group_id ID of the group whose forum is to be deleted. */ function bp_forums_delete_group_forum($group_id) { $forum_id = groups_get_groupmeta($group_id, 'forum_id'); if (!empty($forum_id) && is_int($forum_id)) { /** This action is documented in bp-forums/bp-forums-screens */ do_action('bbpress_init'); bb_delete_forum($forum_id); } }
/** * Delete a group and all of its associated meta * * @global object $bp BuddyPress global settings * @param int $group_id * @since 1.0 */ function groups_delete_group($group_id) { global $bp; // Check the user is the group admin. if (!$bp->is_item_admin) { return false; } // Get the group object $group = new BP_Groups_Group($group_id); if (!$group->delete()) { return false; } do_action('groups_before_delete_group', $group_id); // Delete all group activity from activity streams if (bp_is_active('activity')) { bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id)); } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id); // Remove forum if component is active and current group has one if (bp_is_active('forums') && ($forum_id = groups_get_groupmeta($group_id, 'forum_id'))) { do_action('bbpress_init'); bb_delete_forum($forum_id); } do_action('groups_delete_group', $group_id); return true; }