Exemplo n.º 1
0
function em_set_capabilities()
{
    //Get default roles
    global $wp_roles;
    if (get_option('dbem_version') == '') {
        //Assign caps in groups, as we go down, permissions are "looser"
        $caps = array('publish_events', 'delete_others_events', 'edit_others_events', 'manage_others_bookings', 'publish_recurring_events', 'delete_others_recurring_events', 'edit_others_recurring_events', 'publish_locations', 'delete_others_locations', 'delete_locations', 'edit_others_locations', 'delete_event_categories', 'edit_event_categories');
        em_set_mass_caps(array('administrator', 'editor'), $caps);
        //Add all the open caps
        $loose_caps = array('manage_bookings', 'upload_event_images', 'delete_events', 'edit_events', 'read_private_events', 'delete_recurring_events', 'edit_recurring_events', 'edit_locations', 'read_private_locations', 'read_others_locations');
        em_set_mass_caps(array('administrator', 'editor', 'contributor', 'author', 'subscriber'), $loose_caps);
    }
    if (get_option('dbem_version') && get_option('dbem_version') < 5) {
        //Add new caps that are similar to old ones
        $conditional_caps = array('publish_events' => 'publish_locations,publish_recurring_events', 'edit_others_events' => 'edit_others_recurring_events', 'delete_others_events' => 'delete_others_recurring_events', 'edit_categories' => 'edit_event_categories,delete_event_categories', 'edit_recurrences' => 'edit_recurring_events,delete_recurring_events', 'edit_events' => 'upload_event_images');
        $default_caps = array('read_private_events', 'read_private_locations');
        foreach ($conditional_caps as $cond_cap => $new_caps) {
            foreach ($wp_roles->role_objects as $role_name => $role) {
                if ($role->has_cap($cond_cap)) {
                    foreach (explode(',', $new_caps) as $new_cap) {
                        $role->add_cap($new_cap);
                    }
                }
            }
        }
        em_set_mass_caps(array('administrator', 'editor', 'contributor', 'author', 'subscriber'), $default_caps);
    }
}
Exemplo n.º 2
0
function em_set_capabilities()
{
    //Get default roles
    global $wp_roles;
    if (get_option('dbem_version') == '' || get_option('dbem_version') < 4) {
        //Assign caps in groups, as we go down, permissions are "looser"
        $caps = array('publish_events', 'edit_others_events', 'delete_others_events', 'edit_others_locations', 'delete_others_locations', 'manage_others_bookings', 'edit_categories');
        em_set_mass_caps(array('administrator', 'editor'), $caps);
        //Add all the open caps
        $users = array('administrator', 'editor');
        $caps = array('edit_events', 'edit_locations', 'delete_events', 'manage_bookings', 'delete_locations', 'edit_recurrences', 'read_others_locations');
        em_set_mass_caps(array('administrator', 'editor'), $caps);
        if (get_option('dbem_version') == '') {
            //so pre v4 doesn't get security loopholes
            em_set_mass_caps(array('contributor', 'author', 'subscriber'), $caps);
        }
    }
}