PluginProbe
Groups – Memberships and Access Control / 1.1.5
Groups – Memberships and Access Control v1.1.5
4.7.1 4.7.0 4.6.0 4.5.0 4.4.0 4.3.0 trunk 1.0.0-beta-1 1.0.0-beta-2 1.0.0-beta-3 1.0.0-beta-3b 1.0.0-beta-3c 1.0.0-beta-3d 1.1.4 1.1.5 1.10.0 1.10.1 1.10.2 1.10.3 1.11.0 1.11.1 1.11.2 1.11.3 1.12.0 1.13.0 All 131 releases
groups / lib / admin / groups-admin-groups-remove.php

groups-admin-groups-remove.php in Groups – Memberships and Access Control 1.1.5, at lib/admin/groups-admin-groups-remove.php

99 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * groups-admin-groups-remove.php
4 *
5 * Copyright (c) "kento" Karim Rahimpur www.itthinx.com
6 *
7 * This code is released under the GNU General Public License.
8 * See COPYRIGHT.txt and LICENSE.txt.
9 *
10 * This code is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * This header and all notices must be kept intact.
16 *
17 * @author Karim Rahimpur
18 * @package groups
19 * @since groups 1.1.0
20 */
21
22 /**
23 * Shows form to confirm removal of a group.
24 * @param int $group_id group id
25 */
26 function groups_admin_groups_remove( $group_id ) {
27
28 global $wpdb;
29
30 if ( !current_user_can( GROUPS_ADMINISTER_GROUPS ) ) {
31 wp_die( __( 'Access denied.', GROUPS_PLUGIN_DOMAIN ) );
32 }
33
34 $group = Groups_Group::read( intval( $group_id ) );
35
36 if ( empty( $group ) ) {
37 wp_die( __( 'No such group.', GROUPS_PLUGIN_DOMAIN ) );
38 }
39
40 $group_table = _groups_get_tablename( 'group' );
41
42 $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
43 $current_url = remove_query_arg( 'action', $current_url );
44 $current_url = remove_query_arg( 'group_id', $current_url );
45
46 $output =
47 '<div class="manage-groups">' .
48 '<div>' .
49 '<h2>' .
50 __( 'Remove a group', GROUPS_PLUGIN_DOMAIN ) .
51 '</h2>' .
52 '</div>' .
53 '<form id="remove-group" action="' . $current_url . '" method="post">' .
54 '<div class="group remove">' .
55 '<input id="group-id-field" name="group-id-field" type="hidden" value="' . esc_attr( intval( $group->group_id ) ) . '"/>' .
56 '<ul>' .
57 '<li>' . sprintf( __( 'Group Name : %s', GROUPS_PLUGIN_DOMAIN ), wp_filter_nohtml_kses( $group->name ) ) . '</li>' .
58 '</ul> ' .
59 wp_nonce_field( 'groups-remove', GROUPS_ADMIN_GROUPS_NONCE, true, false ) .
60 '<input type="submit" value="' . __( 'Remove', GROUPS_PLUGIN_DOMAIN ) . '"/>' .
61 '<input type="hidden" value="remove" name="action"/>' .
62 '<a class="cancel" href="' . $current_url . '">' . __( 'Cancel', GROUPS_PLUGIN_DOMAIN ) . '</a>' .
63 '</div>' .
64 '</div>' . // .group.remove
65 '</form>' .
66 '</div>'; // .manage-groups
67
68 echo $output;
69
70 Groups_Help::footer();
71 } // function groups_admin_groups_remove
72
73 /**
74 * Handle remove form submission.
75 */
76 function groups_admin_groups_remove_submit() {
77
78 global $wpdb;
79
80 $result = false;
81
82 if ( !current_user_can( GROUPS_ADMINISTER_GROUPS ) ) {
83 wp_die( __( 'Access denied.', GROUPS_PLUGIN_DOMAIN ) );
84 }
85
86 if ( !wp_verify_nonce( $_POST[GROUPS_ADMIN_GROUPS_NONCE], 'groups-remove' ) ) {
87 wp_die( __( 'Access denied.', GROUPS_PLUGIN_DOMAIN ) );
88 }
89
90 $group_id = isset( $_POST['group-id-field'] ) ? $_POST['group-id-field'] : null;
91 $group = Groups_Group::read( $group_id );
92 if ( $group ) {
93 if ( $group->name !== Groups_Registered::REGISTERED_GROUP_NAME ) {
94 $result = Groups_Group::delete( $group_id );
95 }
96 }
97 return $result;
98 } // function groups_admin_groups_remove_submit
99 ?>