PluginProbe
Groups – Memberships and Access Control / 1.1.4
Groups – Memberships and Access Control v1.1.4
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-capabilities-remove.php

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

99 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * groups-admin-capabilities-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.0.0
20 */
21
22 /**
23 * Shows form to confirm capability deletion.
24 * @param int $capability_id capability id
25 */
26 function groups_admin_capabilities_remove( $capability_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 $capability = Groups_Capability::read( intval( $capability_id ) );
35
36 if ( empty( $capability ) ) {
37 wp_die( __( 'No such capability.', GROUPS_PLUGIN_DOMAIN ) );
38 }
39
40 $capability_table = _groups_get_tablename( 'capability' );
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( 'capability_id', $current_url );
45
46 $output =
47 '<div class="manage-capabilities">' .
48 '<div>' .
49 '<h2>' .
50 __( 'Remove a capability', GROUPS_PLUGIN_DOMAIN ) .
51 '</h2>' .
52 '</div>' .
53 '<form id="remove-capability" action="' . $current_url . '" method="post">' .
54 '<div class="capability remove">' .
55 '<input id="capability-id-field" name="capability-id-field" type="hidden" value="' . esc_attr( intval( $capability->capability_id ) ) . '"/>' .
56 '<ul>' .
57 '<li>' . sprintf( __( 'Capability : %s', GROUPS_PLUGIN_DOMAIN ), wp_filter_nohtml_kses( $capability->capability ) ) . '</li>' .
58 '</ul> ' .
59 wp_nonce_field( 'capabilities-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>' . // .capability.remove
65 '</form>' .
66 '</div>'; // .manage-capabilities
67
68 echo $output;
69
70 Groups_Help::footer();
71 } // function groups_admin_capabilities_remove
72
73 /**
74 * Handle remove form submission.
75 */
76 function groups_admin_capabilities_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], 'capabilities-remove' ) ) {
87 wp_die( __( 'Access denied.', GROUPS_PLUGIN_DOMAIN ) );
88 }
89
90 $capability_id = isset( $_POST['capability-id-field'] ) ? $_POST['capability-id-field'] : null;
91 $capability = Groups_Capability::read( $capability_id );
92 if ( $capability ) {
93 if ( $capability->capability !== Groups_Post_Access::READ_POST_CAPABILITY ) {
94 $result = Groups_Capability::delete( $capability_id );
95 }
96 }
97 return $result;
98 } // function groups_admin_capabilities_remove_submit
99 ?>