本文整理汇总了PHP中_groups_get_tablename函数的典型用法代码示例。如果您正苦于以下问题:PHP _groups_get_tablename函数的具体用法?PHP _groups_get_tablename怎么用?PHP _groups_get_tablename使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_groups_get_tablename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wc_dynamic_pricing_groups_get_all_groups
function wc_dynamic_pricing_groups_get_all_groups()
{
global $wpdb;
$group_table = _groups_get_tablename('group');
$results = $wpdb->get_results("SELECT * FROM {$group_table} ORDER BY name", ARRAY_A);
return $results;
}
示例2: groups_admin_groups_add
/**
* Show add group form.
*/
function groups_admin_groups_add()
{
global $wpdb;
if (!current_user_can(GROUPS_ADMINISTER_GROUPS)) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('paged', $current_url);
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('group_id', $current_url);
$parent_id = isset($_POST['parent-id-field']) ? $_POST['parent-id-field'] : '';
$name = isset($_POST['name-field']) ? $_POST['name-field'] : '';
$description = isset($_POST['description-field']) ? $_POST['description-field'] : '';
$group_table = _groups_get_tablename('group');
$parent_select = '<select name="parent-id-field">';
$parent_select .= '<option value="">--</option>';
$groups = $wpdb->get_results("SELECT * FROM {$group_table}");
foreach ($groups as $group) {
$parent_select .= '<option value="' . esc_attr($group->group_id) . '">' . wp_filter_nohtml_kses($group->name) . '</option>';
}
$parent_select .= '</select>';
$output = '<div class="manage-groups">' . '<div>' . '<h2>' . __('Add a new group', GROUPS_PLUGIN_DOMAIN) . '</h2>' . '</div>' . '<form id="add-group" action="' . $current_url . '" method="post">' . '<div class="group new">' . '<div class="field">' . '<label for="name-field" class="field-label first required">' . __('Name', GROUPS_PLUGIN_DOMAIN) . '</label>' . '<input id="name-field" name="name-field" class="namefield" type="text" value="' . esc_attr($name) . '"/>' . '</div>' . '<div class="field">' . '<label for="parent-id-field" class="field-label">' . __('Parent', GROUPS_PLUGIN_DOMAIN) . '</label>' . $parent_select . '</div>' . '<div class="field">' . '<label for="description-field" class="field-label description-field">' . __('Description', GROUPS_PLUGIN_DOMAIN) . '</label>' . '<textarea id="description-field" name="description-field" rows="5" cols="45">' . wp_filter_nohtml_kses($description) . '</textarea>' . '</div>' . '<div class="field">' . wp_nonce_field('groups-add', GROUPS_ADMIN_GROUPS_NONCE, true, false) . '<input class="button" type="submit" value="' . __('Add', GROUPS_PLUGIN_DOMAIN) . '"/>' . '<input type="hidden" value="add" name="action"/>' . '<a class="cancel" href="' . $current_url . '">' . __('Cancel', GROUPS_PLUGIN_DOMAIN) . '</a>' . '</div>' . '</div>' . '</form>' . '</div>';
// .manage-groups
echo $output;
Groups_Help::footer();
}
示例3: get_group_tree
public static function get_group_tree(&$tree = null)
{
global $wpdb;
$group_table = _groups_get_tablename('group');
if ($tree === null) {
$tree = array();
$root_groups = $wpdb->get_results("SELECT group_id FROM {$group_table} WHERE parent_id IS NULL");
if ($root_groups) {
foreach ($root_groups as $root_group) {
$group_id = Groups_Utility::id($root_group->group_id);
$tree[$group_id] = array();
}
}
self::get_group_tree($tree);
} else {
foreach ($tree as $group_id => $nodes) {
$children = $wpdb->get_results($wpdb->prepare("SELECT group_id FROM {$group_table} WHERE parent_id = %d", Groups_Utility::id($group_id)));
foreach ($children as $child) {
$tree[$group_id][$child->group_id] = array();
}
self::get_group_tree($tree[$group_id]);
}
}
return $tree;
}
示例4: groups_admin_groups_edit
/**
* Show edit group form.
* @param int $group_id group id
*/
function groups_admin_groups_edit($group_id)
{
global $wpdb;
if (!current_user_can(GROUPS_ADMINISTER_GROUPS)) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
$group = Groups_Group::read(intval($group_id));
if (empty($group)) {
wp_die(__('No such group.', GROUPS_PLUGIN_DOMAIN));
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('group_id', $current_url);
$name = isset($_POST['name-field']) ? $_POST['name-field'] : $group->name;
$description = isset($_POST['description-field']) ? $_POST['description-field'] : $group->description;
$parent_id = isset($_POST['parent-id-field']) ? $_POST['parent-id-field'] : $group->parent_id;
$group_table = _groups_get_tablename('group');
$parent_select = '<select name="parent-id-field">';
$parent_select .= '<option value="">--</option>';
$groups = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$group_table} WHERE group_id != %d", $group->group_id));
foreach ($groups as $g) {
$selected = $g->group_id == $group->parent_id ? ' selected="selected" ' : '';
$parent_select .= '<option ' . $selected . 'value="' . esc_attr($g->group_id) . '">' . wp_filter_nohtml_kses($g->name) . '</option>';
}
$parent_select .= '</select>';
$name_readonly = $name !== Groups_Registered::REGISTERED_GROUP_NAME ? "" : ' readonly="readonly" ';
$output = '<div class="manage-groups">' . '<div>' . '<h2>' . __('Edit a group', GROUPS_PLUGIN_DOMAIN) . '</h2>' . '</div>' . '<form id="edit-group" action="' . $current_url . '" method="post">' . '<div class="group edit">' . '<input id="group-id-field" name="group-id-field" type="hidden" value="' . esc_attr(intval($group_id)) . '"/>' . '<div class="field">' . '<label for="name-field" class="field-label first required">' . __('Name', GROUPS_PLUGIN_DOMAIN) . '</label>' . '<input ' . $name_readonly . ' id="name-field" name="name-field" class="namefield" type="text" value="' . esc_attr($name) . '"/>' . '</div>' . '<div class="field">' . '<label for="parent-id-field" class="field-label">' . __('Parent', GROUPS_PLUGIN_DOMAIN) . '</label>' . $parent_select . '</div>' . '<div class="field">' . '<label for="description-field" class="field-label description-field">' . __('Description', GROUPS_PLUGIN_DOMAIN) . '</label>' . '<textarea id="description-field" name="description-field" rows="5" cols="45">' . wp_filter_nohtml_kses($description) . '</textarea>' . '</div>' . '<div class="field">' . wp_nonce_field('groups-edit', GROUPS_ADMIN_GROUPS_NONCE, true, false) . '<input class="button" type="submit" value="' . __('Save', GROUPS_PLUGIN_DOMAIN) . '"/>' . '<input type="hidden" value="edit" name="action"/>' . '<a class="cancel" href="' . $current_url . '">' . __('Cancel', GROUPS_PLUGIN_DOMAIN) . '</a>' . '</div>' . '</div>' . '</form>' . '</div>';
// .manage-groups
echo $output;
Groups_Help::footer();
}
示例5: groups_admin_capabilities_add
/**
* Show add capability form.
*/
function groups_admin_capabilities_add()
{
global $wpdb;
if (!current_user_can(GROUPS_ADMINISTER_GROUPS)) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('paged', $current_url);
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('capability_id', $current_url);
$capability = isset($_POST['capability-field']) ? $_POST['capability-field'] : '';
$description = isset($_POST['description-field']) ? $_POST['description-field'] : '';
$capability_table = _groups_get_tablename('capability');
$output = '<div class="manage-capabilities wrap">' . '<h1>' . __('Add a new capability', GROUPS_PLUGIN_DOMAIN) . '</h1>' . Groups_Admin::render_messages() . '<form id="add-capability" action="' . esc_url($current_url) . '" method="post">' . '<div class="capability new">' . '<div class="field">' . '<label for="capability-field" class="field-label first required">' . __('Capability', GROUPS_PLUGIN_DOMAIN) . '</label>' . '<input id="name-field" name="capability-field" class="capability-field" type="text" value="' . esc_attr(stripslashes($capability)) . '"/>' . '</div>' . '<div class="field">' . '<label for="description-field" class="field-label description-field">' . __('Description', GROUPS_PLUGIN_DOMAIN) . '</label>' . '<textarea id="description-field" name="description-field" rows="5" cols="45">' . stripslashes(wp_filter_nohtml_kses($description)) . '</textarea>' . '</div>' . '<div class="field">' . wp_nonce_field('capabilities-add', GROUPS_ADMIN_GROUPS_NONCE, true, false) . '<input class="button button-primary" type="submit" value="' . __('Add', GROUPS_PLUGIN_DOMAIN) . '"/>' . '<input type="hidden" value="add" name="action"/>' . '<a class="cancel button" href="' . esc_url($current_url) . '">' . __('Cancel', GROUPS_PLUGIN_DOMAIN) . '</a>' . '</div>' . '</div>' . '</form>' . '</div>';
// .manage-capabilities
echo $output;
}
示例6: groups_admin_capabilities_remove
/**
* Shows form to confirm capability deletion.
* @param int $capability_id capability id
*/
function groups_admin_capabilities_remove($capability_id)
{
global $wpdb;
if (!current_user_can(GROUPS_ADMINISTER_GROUPS)) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
$capability = Groups_Capability::read(intval($capability_id));
if (empty($capability)) {
wp_die(__('No such capability.', GROUPS_PLUGIN_DOMAIN));
}
$capability_table = _groups_get_tablename('capability');
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('capability_id', $current_url);
$output = '<div class="manage-capabilities wrap">' . '<h1>' . __('Remove a capability', GROUPS_PLUGIN_DOMAIN) . '</h1>' . '<form id="remove-capability" action="' . esc_url($current_url) . '" method="post">' . '<div class="capability remove">' . '<input id="capability-id-field" name="capability-id-field" type="hidden" value="' . esc_attr(intval($capability->capability_id)) . '"/>' . '<ul>' . '<li>' . sprintf(__('Capability : %s', GROUPS_PLUGIN_DOMAIN), stripslashes(wp_filter_nohtml_kses($capability->capability))) . '</li>' . '</ul> ' . wp_nonce_field('capabilities-remove', GROUPS_ADMIN_GROUPS_NONCE, true, false) . '<input class="button button-primary" type="submit" value="' . __('Remove', GROUPS_PLUGIN_DOMAIN) . '"/>' . '<input type="hidden" value="remove" name="action"/>' . '<a class="cancel button" href="' . esc_url($current_url) . '">' . __('Cancel', GROUPS_PLUGIN_DOMAIN) . '</a>' . '</div>' . '</div>' . '</form>' . '</div>';
// .manage-capabilities
echo $output;
}
示例7: groups_admin_groups_remove
/**
* Shows form to confirm removal of a group.
* @param int $group_id group id
*/
function groups_admin_groups_remove($group_id)
{
global $wpdb;
if (!current_user_can(GROUPS_ADMINISTER_GROUPS)) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
$group = Groups_Group::read(intval($group_id));
if (empty($group)) {
wp_die(__('No such group.', GROUPS_PLUGIN_DOMAIN));
}
$group_table = _groups_get_tablename('group');
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('group_id', $current_url);
$output = '<div class="manage-groups">' . '<div>' . '<h2>' . __('Remove a group', GROUPS_PLUGIN_DOMAIN) . '</h2>' . '</div>' . '<form id="remove-group" action="' . $current_url . '" method="post">' . '<div class="group remove">' . '<input id="group-id-field" name="group-id-field" type="hidden" value="' . esc_attr(intval($group->group_id)) . '"/>' . '<ul>' . '<li>' . sprintf(__('Group Name : %s', GROUPS_PLUGIN_DOMAIN), wp_filter_nohtml_kses($group->name)) . '</li>' . '</ul> ' . wp_nonce_field('groups-remove', GROUPS_ADMIN_GROUPS_NONCE, true, false) . '<input class="button" type="submit" value="' . __('Remove', GROUPS_PLUGIN_DOMAIN) . '"/>' . '<input type="hidden" value="remove" name="action"/>' . '<a class="cancel" href="' . $current_url . '">' . __('Cancel', GROUPS_PLUGIN_DOMAIN) . '</a>' . '</div>' . '</div>' . '</form>' . '</div>';
// .manage-groups
echo $output;
Groups_Help::footer();
}
示例8: can
/**
* (non-PHPdoc)
* @see I_Capable::can()
*/
public function can($capability)
{
global $wpdb;
$result = false;
if ($this->user !== null) {
// if administrators can override access, let them
if (get_option(GROUPS_ADMINISTRATOR_ACCESS_OVERRIDE, GROUPS_ADMINISTRATOR_ACCESS_OVERRIDE_DEFAULT)) {
if (user_can($this->user->ID, 'administrator')) {
// just using $this->user would raise a warning on 3.2.1
return true;
}
}
$group_table = _groups_get_tablename("group");
$capability_table = _groups_get_tablename("capability");
$group_capability_table = _groups_get_tablename("group_capability");
$user_group_table = _groups_get_tablename("user_group");
// determine capability id
$capability_id = null;
if (is_numeric($capability)) {
$capability_id = Groups_Utility::id($capability);
} else {
if (is_string($capability)) {
$capability_id = $wpdb->get_var($wpdb->prepare("SELECT capability_id FROM {$capability_table} WHERE capability = %s", $capability));
}
}
if ($capability_id !== null) {
// either the user can ...
$result = Groups_User_Capability::read($this->user->ID, $capability_id) !== false;
// ... or the user can because a group the user belongs to can
if (!$result) {
// Important: before making any changes check
// INDEX usage on modified query!
$rows = $wpdb->get_results($wpdb->prepare("SELECT capability_id FROM {$group_capability_table} WHERE capability_id = %d AND group_id IN (SELECT group_id FROM {$user_group_table} WHERE user_id = %d)", Groups_Utility::id($capability_id), Groups_Utility::id($this->user->ID)));
if (count($rows) > 0) {
$result = true;
}
}
// ... or because any of the parent groups can
if (!$result) {
// search in parent groups
$limit = $wpdb->get_var("SELECT COUNT(*) FROM {$group_table}");
if ($limit !== null) {
// note that limits by blog_id for multisite are
// enforced when a user is added to a blog
$user_groups = $wpdb->get_results($wpdb->prepare("SELECT group_id FROM {$user_group_table} WHERE user_id = %d", Groups_Utility::id($this->user->ID)));
if ($user_groups) {
$group_ids = array();
foreach ($user_groups as $user_group) {
$group_ids[] = Groups_Utility::id($user_group->group_id);
}
if (count($group_ids) > 0) {
$iterations = 0;
$old_group_ids_count = 0;
while ($iterations < $limit && count($group_ids) !== $old_group_ids_count) {
$iterations++;
$old_group_ids_count = count($group_ids);
$id_list = implode(",", $group_ids);
$parent_group_ids = $wpdb->get_results("SELECT parent_id FROM {$group_table} WHERE parent_id IS NOT NULL AND group_id IN ({$id_list})");
if ($parent_group_ids) {
foreach ($parent_group_ids as $parent_group_id) {
$parent_group_id = Groups_Utility::id($parent_group_id->parent_id);
if (!in_array($parent_group_id, $group_ids)) {
$group_ids[] = $parent_group_id;
}
}
}
}
$id_list = implode(",", $group_ids);
$rows = $wpdb->get_results($wpdb->prepare("SELECT capability_id FROM {$group_capability_table} WHERE capability_id = %d AND group_id IN ({$id_list})", Groups_Utility::id($capability_id)));
if (count($rows) > 0) {
$result = true;
}
}
}
}
}
}
}
$result = apply_filters_ref_array("groups_user_can", array($result, &$this, $capability));
return $result;
}
示例9: cleanup
/**
* Plugin deactivation cleanup.
* @param $drop overrides the groups_delete_data option, default is false
*/
private static function cleanup($drop = false)
{
global $wpdb, $wp_roles;
$delete_data = Groups_Options::get_option('groups_delete_data', false);
if ($delete_data || $drop) {
foreach ($wp_roles->role_objects as $role) {
$role->remove_cap(GROUPS_ACCESS_GROUPS);
$role->remove_cap(GROUPS_ADMINISTER_GROUPS);
$role->remove_cap(GROUPS_ADMINISTER_OPTIONS);
}
$wpdb->query('DROP TABLE IF EXISTS ' . _groups_get_tablename('group'));
$wpdb->query('DROP TABLE IF EXISTS ' . _groups_get_tablename('capability'));
$wpdb->query('DROP TABLE IF EXISTS ' . _groups_get_tablename('user_group'));
$wpdb->query('DROP TABLE IF EXISTS ' . _groups_get_tablename('user_capability'));
$wpdb->query('DROP TABLE IF EXISTS ' . _groups_get_tablename('group_capability'));
Groups_Options::flush_options();
delete_option(GROUPS_ADMINISTRATOR_ACCESS_OVERRIDE);
delete_option('groups_plugin_version');
delete_option('groups_delete_data');
}
}
示例10: process_product_meta
/**
* Register groups for a product.
* @param int $post_id product ID
* @param object $post product
*/
public static function process_product_meta($post_id, $post)
{
global $wpdb;
// refresh groups, clear all, then assign checked
delete_post_meta($post_id, '_groups_groups');
delete_post_meta($post_id, '_groups_groups_remove');
// iterate over groups, could also try to find these in $_POST
// but would normally be more costly
$group_table = _groups_get_tablename("group");
$groups = $wpdb->get_results("SELECT group_id FROM {$group_table}");
if (count($groups) > 0) {
foreach ($groups as $group) {
if (!empty($_POST['_groups_groups-' . $group->group_id])) {
add_post_meta($post_id, '_groups_groups', $group->group_id);
} else {
if (!empty($_POST['_groups_groups_remove-' . $group->group_id])) {
add_post_meta($post_id, '_groups_groups_remove', $group->group_id);
}
}
}
}
// duration
delete_post_meta($post_id, '_groups_duration');
delete_post_meta($post_id, '_groups_duration_uom');
$duration = !empty($_POST['_groups_duration']) ? intval($_POST['_groups_duration']) : null;
if ($duration <= 0) {
$duration = null;
}
if ($duration !== null) {
$duration_uom = !empty($_POST['_groups_duration_uom']) ? $_POST['_groups_duration_uom'] : null;
switch ($duration_uom) {
case 'second':
case 'minute':
case 'hour':
case 'day':
case 'week':
case 'year':
break;
default:
$duration_uom = 'month';
}
add_post_meta($post_id, '_groups_duration', $duration);
add_post_meta($post_id, '_groups_duration_uom', $duration_uom);
}
}
示例11: groups_admin_groups
//.........这里部分代码省略.........
if (isset($_POST['submitted'])) {
// filter by name
if (!empty($_POST['group_name'])) {
$group_name = $_POST['group_name'];
Groups_Options::update_user_option('groups_group_name', $group_name);
}
// filter by group id
if (!empty($_POST['group_id'])) {
$group_id = intval($_POST['group_id']);
Groups_Options::update_user_option('groups_group_id', $group_id);
} else {
if (isset($_POST['group_id'])) {
// empty && isset => '' => all
$group_id = null;
Groups_Options::delete_user_option('groups_group_id');
}
}
}
}
if (isset($_POST['row_count'])) {
if (!wp_verify_nonce($_POST[GROUPS_ADMIN_GROUPS_NONCE_1], 'admin')) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
}
if (isset($_POST['paged'])) {
if (!wp_verify_nonce($_POST[GROUPS_ADMIN_GROUPS_NONCE_2], 'admin')) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('paged', $current_url);
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('group_id', $current_url);
$group_table = _groups_get_tablename('group');
$output .= '<div class="manage-groups">' . '<div>' . '<h2>' . _x('Groups', 'page-title', GROUPS_PLUGIN_DOMAIN) . '</h2>' . '</div>';
$output .= Groups_Admin::render_messages();
$output .= '<div class="manage">' . "<a title='" . __('Click to add a new group', GROUPS_PLUGIN_DOMAIN) . "' class='add button' href='" . esc_url($current_url) . "&action=add'><img class='icon' alt='" . __('Add', GROUPS_PLUGIN_DOMAIN) . "' src='" . GROUPS_PLUGIN_URL . "images/add.png'/><span class='label'>" . __('New Group', GROUPS_PLUGIN_DOMAIN) . "</span></a>" . '</div>';
$row_count = isset($_POST['row_count']) ? intval($_POST['row_count']) : 0;
if ($row_count <= 0) {
$row_count = Groups_Options::get_user_option('groups_per_page', GROUPS_GROUPS_PER_PAGE);
} else {
Groups_Options::update_user_option('groups_per_page', $row_count);
}
$offset = isset($_GET['offset']) ? intval($_GET['offset']) : 0;
if ($offset < 0) {
$offset = 0;
}
$paged = isset($_REQUEST['paged']) ? intval($_REQUEST['paged']) : 0;
if ($paged < 0) {
$paged = 0;
}
$orderby = isset($_GET['orderby']) ? $_GET['orderby'] : null;
switch ($orderby) {
case 'group_id':
case 'name':
break;
default:
$orderby = 'name';
}
$order = isset($_GET['order']) ? $_GET['order'] : null;
switch ($order) {
case 'asc':
case 'ASC':
$switch_order = 'DESC';
break;
case 'desc':
示例12: groups_admin_options
//.........这里部分代码省略.........
}
}
}
}
$admin_override = get_option(GROUPS_ADMINISTRATOR_ACCESS_OVERRIDE, GROUPS_ADMINISTRATOR_ACCESS_OVERRIDE_DEFAULT);
$show_tree_view = Groups_Options::get_option(GROUPS_SHOW_TREE_VIEW, GROUPS_SHOW_TREE_VIEW_DEFAULT);
$show_in_user_profile = Groups_Options::get_option(GROUPS_SHOW_IN_USER_PROFILE, GROUPS_SHOW_IN_USER_PROFILE_DEFAULT);
$rolenames = $wp_roles->get_names();
$caps_table = '<table class="groups-permissions">';
$caps_table .= '<thead>';
$caps_table .= '<tr>';
$caps_table .= '<td class="role">';
$caps_table .= __('Role', GROUPS_PLUGIN_DOMAIN);
$caps_table .= '</td>';
foreach ($caps as $cap) {
$caps_table .= '<td class="cap">';
$caps_table .= $cap;
$caps_table .= '</td>';
}
$caps_table .= '</tr>';
$caps_table .= '</thead>';
$caps_table .= '<tbody>';
foreach ($rolenames as $rolekey => $rolename) {
$role = $wp_roles->get_role($rolekey);
$caps_table .= '<tr>';
$caps_table .= '<td>';
$caps_table .= translate_user_role($rolename);
$caps_table .= '</td>';
foreach ($caps as $capkey => $capname) {
if ($role->has_cap($capkey)) {
$checked = ' checked="checked" ';
} else {
$checked = '';
}
$caps_table .= '<td class="checkbox">';
$role_cap_id = $rolekey . '-' . $capkey;
$caps_table .= '<input type="checkbox" name="' . $role_cap_id . '" id="' . $role_cap_id . '" ' . $checked . '/>';
$caps_table .= '</td>';
}
$caps_table .= '</tr>';
}
$caps_table .= '</tbody>';
$caps_table .= '</table>';
$delete_data = Groups_Options::get_option('groups_delete_data', false);
//
// print the options form
//
echo '<form action="" name="options" method="post">' . '<p>' . '<input class="button" type="submit" name="submit" value="' . __('Save', GROUPS_PLUGIN_DOMAIN) . '"/>' . '</p>' . '<div>' . '<h3>' . __('Administrator Access Override', GROUPS_PLUGIN_DOMAIN) . '</h3>' . '<p>' . '<label>' . '<input name="' . GROUPS_ADMINISTRATOR_ACCESS_OVERRIDE . '" type="checkbox" ' . ($admin_override ? 'checked="checked"' : '') . '/>' . __('Administrators override all access permissions derived from Groups capabilities.', GROUPS_PLUGIN_DOMAIN) . '</label>' . '</p>';
echo '<h3>' . __('Access restricions', GROUPS_PLUGIN_DOMAIN) . '</h3>';
echo '<h4>' . __('Post types', GROUPS_PLUGIN_DOMAIN) . '</h4>';
echo '<p class="description">' . __('Show access restrictions for these post types.', GROUPS_PLUGIN_DOMAIN) . '</p>';
$post_types_option = Groups_Options::get_option(Groups_Post_Access::POST_TYPES, array());
$post_types = get_post_types(array('public' => true));
echo '<ul>';
foreach ($post_types as $post_type) {
$post_type_object = get_post_type_object($post_type);
echo '<li>';
echo '<label>';
$label = $post_type;
$labels = isset($post_type_object->labels) ? $post_type_object->labels : null;
if ($labels !== null && isset($labels->singular_name)) {
$label = __($labels->singular_name);
}
$checked = !isset($post_types_option[$post_type]['add_meta_box']) || $post_types_option[$post_type]['add_meta_box'] ? ' checked="checked" ' : '';
echo '<input name="add_meta_boxes[]" type="checkbox" value="' . esc_attr($post_type) . '" ' . $checked . '/>';
echo $label;
echo '</label>';
echo '</li>';
}
echo '<ul>';
echo '<p class="description">' . __('This determines for which post types access restriction settings are offered.', GROUPS_PLUGIN_DOMAIN) . '<br/>' . __('Disabling this setting for a post type does not remove existing access restrictions on individual posts of that type.', GROUPS_PLUGIN_DOMAIN) . '<br/>' . '</p>';
echo '<h4>' . __('Capabilities', GROUPS_PLUGIN_DOMAIN) . '</h4>';
echo '<p class="description">' . __('Include these capabilities to enforce read access on posts. The selected capabilities will be offered to restrict access to posts.', GROUPS_PLUGIN_DOMAIN) . '</p>';
$capability_table = _groups_get_tablename("capability");
$capabilities = $wpdb->get_results("SELECT * FROM {$capability_table} ORDER BY capability");
$applicable_read_caps = Groups_Options::get_option(Groups_Post_Access::READ_POST_CAPABILITIES, array(Groups_Post_Access::READ_POST_CAPABILITY));
foreach ($capabilities as $capability) {
$checked = in_array($capability->capability, $applicable_read_caps) ? ' checked="checked" ' : '';
if ($capability->capability == Groups_Post_Access::READ_POST_CAPABILITY) {
$checked .= ' readonly="readonly" disabled="disabled" ';
}
echo '<label>';
echo '<input name="' . GROUPS_READ_POST_CAPABILITIES . '[]" ' . $checked . ' type="checkbox" value="' . esc_attr($capability->capability_id) . '" />';
echo wp_filter_nohtml_kses($capability->capability);
echo '</label>';
echo ' ';
echo '<span class="description">' . wp_filter_nohtml_kses($capability->description) . '</span>';
echo '<br/>';
}
echo '<h3>' . __('User profiles', GROUPS_PLUGIN_DOMAIN) . '</h3>' . '<p>' . '<label>' . '<input name="' . GROUPS_SHOW_IN_USER_PROFILE . '" type="checkbox" ' . ($show_in_user_profile ? 'checked="checked"' : '') . '/>' . __('Show groups in user profiles.', GROUPS_PLUGIN_DOMAIN) . '</label>' . '</p>';
echo '<h3>' . __('Tree view', GROUPS_PLUGIN_DOMAIN) . '</h3>' . '<p>' . '<label>' . '<input name="' . GROUPS_SHOW_TREE_VIEW . '" type="checkbox" ' . ($show_tree_view ? 'checked="checked"' : '') . '/>' . __('Show the Groups tree view.', GROUPS_PLUGIN_DOMAIN) . '</label>' . '</p>';
echo '<h3>' . __('Permissions', GROUPS_PLUGIN_DOMAIN) . '</h3>' . '<p>' . __('These permissions apply to Groups management. They do not apply to access permissions derived from Groups capabilities.', GROUPS_PLUGIN_DOMAIN) . '</p>' . $caps_table . '<p class="description">' . __('A minimum set of permissions will be preserved.', GROUPS_PLUGIN_DOMAIN) . '<br/>' . __('If you lock yourself out, please ask an administrator to help.', GROUPS_PLUGIN_DOMAIN) . '</p>';
if (!$is_sitewide_plugin) {
echo '<h3>' . __('Deactivation and data persistence', GROUPS_PLUGIN_DOMAIN) . '</h3>' . '<p>' . '<label>' . '<input name="delete-data" type="checkbox" ' . ($delete_data ? 'checked="checked"' : '') . '/>' . __('Delete all Groups plugin data on deactivation', GROUPS_PLUGIN_DOMAIN) . '</label>' . '</p>' . '<p class="description warning">' . __('CAUTION: If this option is active while the plugin is deactivated, ALL plugin settings and data will be DELETED. If you are going to use this option, now would be a good time to make a backup. By enabling this option you agree to be solely responsible for any loss of data or any other consequences thereof.', GROUPS_PLUGIN_DOMAIN) . '</p>';
}
echo '<p>' . wp_nonce_field('admin', GROUPS_ADMIN_OPTIONS_NONCE, true, false) . '<input class="button" type="submit" name="submit" value="' . __('Save', GROUPS_PLUGIN_DOMAIN) . '"/>' . '</p>' . '</div>' . '</form>';
echo '</div>';
// .groups-options
Groups_Help::footer();
}
示例13: delete
/**
* Remove capability and its relations.
*
* @param int $capability_id
* @return capability_id if successful, false otherwise
*/
public static function delete($capability_id)
{
global $wpdb;
$result = false;
// avoid nonsense requests
if ($capability = Groups_Capability::read($capability_id)) {
$capability_table = _groups_get_tablename('capability');
// get rid of it
if ($rows = $wpdb->query($wpdb->prepare("DELETE FROM {$capability_table} WHERE capability_id = %d", Groups_Utility::id($capability_id)))) {
$result = $capability_id;
do_action("groups_deleted_capability", $result);
}
}
return $result;
}
示例14: groups_admin_groups_add
/**
* Show add group form.
*/
function groups_admin_groups_add()
{
global $wpdb;
$output = '';
if (!current_user_can(GROUPS_ADMINISTER_GROUPS)) {
wp_die(__('Access denied.', GROUPS_PLUGIN_DOMAIN));
}
$current_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$current_url = remove_query_arg('paged', $current_url);
$current_url = remove_query_arg('action', $current_url);
$current_url = remove_query_arg('group_id', $current_url);
$parent_id = isset($_POST['parent-id-field']) ? $_POST['parent-id-field'] : '';
$name = isset($_POST['name-field']) ? $_POST['name-field'] : '';
$description = isset($_POST['description-field']) ? $_POST['description-field'] : '';
$group_table = _groups_get_tablename('group');
$parent_select = '<select name="parent-id-field">';
$parent_select .= '<option value="">--</option>';
$groups = $wpdb->get_results("SELECT * FROM {$group_table}");
foreach ($groups as $group) {
$parent_select .= '<option value="' . esc_attr($group->group_id) . '">' . wp_filter_nohtml_kses($group->name) . '</option>';
}
$parent_select .= '</select>';
$output .= '<div class="manage-groups wrap">';
$output .= '<h1>';
$output .= __('Add a new group', GROUPS_PLUGIN_DOMAIN);
$output .= '</h1>';
$output .= Groups_Admin::render_messages();
$output .= '<form id="add-group" action="' . esc_url($current_url) . '" method="post">';
$output .= '<div class="group new">';
$output .= '<div class="field">';
$output .= '<label for="name-field" class="field-label first required">';
$output .= __('Name', GROUPS_PLUGIN_DOMAIN);
$output .= '</label>';
$output .= '<input id="name-field" name="name-field" class="namefield" type="text" value="' . esc_attr(stripslashes($name)) . '"/>';
$output .= '</div>';
$output .= '<div class="field">';
$output .= '<label for="parent-id-field" class="field-label">';
$output .= __('Parent', GROUPS_PLUGIN_DOMAIN);
$output .= '</label>';
$output .= $parent_select;
$output .= '</div>';
$output .= '<div class="field">';
$output .= '<label for="description-field" class="field-label description-field">';
$output .= __('Description', GROUPS_PLUGIN_DOMAIN);
$output .= '</label>';
$output .= '<textarea id="description-field" name="description-field" rows="5" cols="45">';
$output .= stripslashes(wp_filter_nohtml_kses($description));
$output .= '</textarea>';
$output .= '</div>';
$output .= '<div class="field">';
$capability_table = _groups_get_tablename("capability");
$capabilities = $wpdb->get_results("SELECT * FROM {$capability_table} ORDER BY capability");
$output .= '<div class="select-capability-container" style="width:62%;">';
$output .= '<label>';
$output .= __('Capabilities', GROUPS_PLUGIN_DOMAIN);
$output .= sprintf('<select class="select capability" name="capability_ids[]" multiple="multiple" placeholder="%s">', __('Choose capabilities …', GROUPS_PLUGIN_DOMAIN));
foreach ($capabilities as $capability) {
$output .= sprintf('<option value="%s">%s</option>', esc_attr($capability->capability_id), wp_filter_nohtml_kses($capability->capability));
}
$output .= '</select>';
$output .= '</label>';
$output .= '</div>';
$output .= '<p class="description">';
$output .= __('These capabilities will be assigned to the group.', GROUPS_PLUGIN_DOMAIN);
$output .= '</p>';
$output .= Groups_UIE::render_select('.select.capability');
$output .= '</div>';
$output .= apply_filters('groups_admin_groups_add_form_after_fields', '');
$output .= '<div class="field">';
$output .= wp_nonce_field('groups-add', GROUPS_ADMIN_GROUPS_NONCE, true, false);
$output .= '<input class="button button-primary" type="submit" value="' . __('Add', GROUPS_PLUGIN_DOMAIN) . '"/>';
$output .= '<input type="hidden" value="add" name="action"/>';
$output .= '<a class="cancel button" href="' . esc_url($current_url) . '">' . __('Cancel', GROUPS_PLUGIN_DOMAIN) . '</a>';
$output .= '</div>';
$output .= '</div>';
// .group.new
$output .= '</form>';
$output .= '</div>';
// .manage-groups
echo $output;
}
示例15: get_all_capability_list
/**
* Get all capability list for select field
*
* @access public
* @return array
*/
public function get_all_capability_list()
{
$capabilities = array();
// Groups plugin active?
if (class_exists('Groups_User') && class_exists('Groups_Wordpress') && function_exists('_groups_get_tablename')) {
global $wpdb;
$capability_table = _groups_get_tablename('capability');
$all_capabilities = $wpdb->get_results('SELECT capability FROM ' . $capability_table);
if ($all_capabilities) {
foreach ($all_capabilities as $capability) {
$capabilities[$capability->capability] = $capability->capability;
}
}
} else {
global $wp_roles;
if (!isset($wp_roles)) {
get_role('administrator');
}
$roles = $wp_roles->roles;
if (is_array($roles)) {
foreach ($roles as $rolename => $atts) {
if (isset($atts['capabilities']) && is_array($atts['capabilities'])) {
foreach ($atts['capabilities'] as $capability => $value) {
if (!in_array($capability, $capabilities)) {
$capabilities[$capability] = $capability;
}
}
}
}
}
}
return apply_filters('rp_wcdpd_capability_list', array_merge(array('' => ''), $capabilities));
}