/** * Handles ajax requests to remove a group from a specified page */ public static function remove_group_from_page() { global $wpdb; $response = ''; $supplemental = array(); //Added in 1.1 - ensures current user is an admin before processing, else returns an error (probably not necessary - but just in case...) if (!current_user_can('edit_others_posts')) { //ERROR! If user isn't authorized $response = array('what' => 'remove_group', 'action' => 'remove_group_from_page', 'id' => new WP_Error('error', __('User is not authorized.', 'contexture-page-security'))); $response = new WP_Ajax_Response($response); $response->send(); } if (CTXPS_Queries::delete_security($_REQUEST['post_id'], $_REQUEST['group_id']) !== false) { //Which content do we need to render? if (isset($_REQUEST['requester']) && $_REQUEST['requester'] == 'sidebar') { $supplemental = array('html' => CTXPS_Components::render_sidebar_attached_groups($_REQUEST['post_id'])); //We need to regenerate sidebar content } else { $supplemental = array('html' => new CTXPS_Table_Packages('associated_content', false, true)); //We need to regenerate list-table content } //SUCCESS! $response = array('what' => 'remove_group', 'action' => 'remove_group_from_page', 'id' => 1, 'data' => __('Group removed from content', 'contexture-page-security'), 'supplemental' => $supplemental); } else { //ERROR! $response = array('what' => 'remove_group', 'action' => 'remove_group_from_page', 'id' => new WP_Error('error', __('Query failed or content not in group.', 'contexture-page-security'))); } $response = new WP_Ajax_Response($response); $response->send(); }