本文整理汇总了PHP中GFCommon::current_user_can_any方法的典型用法代码示例。如果您正苦于以下问题:PHP GFCommon::current_user_can_any方法的具体用法?PHP GFCommon::current_user_can_any怎么用?PHP GFCommon::current_user_can_any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFCommon
的用法示例。
在下文中一共展示了GFCommon::current_user_can_any方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: leads_page
public static function leads_page($form_id)
{
global $wpdb;
//quit if version of wp is not supported
if (!GFCommon::ensure_wp_version()) {
return;
}
$form_id = absint($form_id);
echo GFCommon::get_remote_message();
$action = RGForms::post('action');
$filter = rgget('filter');
$search = stripslashes(rgget('s'));
$page_index = empty($_GET['paged']) ? 0 : intval($_GET['paged']) - 1;
$star = $filter == 'star' ? 1 : null;
$read = $filter == 'unread' ? 0 : null;
$status = in_array($filter, array('trash', 'spam')) ? $filter : 'active';
$form = RGFormsModel::get_form_meta($form_id);
$search_criteria['status'] = $status;
if ($star) {
$search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star);
}
if (!is_null($read)) {
$search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read);
}
$search_field_id = rgget('field_id');
$search_operator = rgget('operator');
if (isset($_GET['field_id']) && $_GET['field_id'] !== '') {
$key = $search_field_id;
$val = stripslashes(rgget('s'));
$strpos_row_key = strpos($search_field_id, '|');
if ($strpos_row_key !== false) {
//multi-row likert
$key_array = explode('|', $search_field_id);
$key = $key_array[0];
$val = $key_array[1] . ':' . $val;
}
if ('entry_id' == $key) {
$key = 'id';
}
$filter_operator = empty($search_operator) ? 'is' : $search_operator;
$field = GFFormsModel::get_field($form, $key);
if ($field) {
$input_type = GFFormsModel::get_input_type($field);
if ($field->type == 'product' && in_array($input_type, array('radio', 'select'))) {
$filter_operator = 'contains';
}
}
$search_criteria['field_filters'][] = array('key' => $key, 'operator' => $filter_operator, 'value' => $val);
}
$update_message = '';
switch ($action) {
case 'delete':
check_admin_referer('gforms_entry_list', 'gforms_entry_list');
$lead_id = $_POST['action_argument'];
if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
RGFormsModel::delete_lead($lead_id);
$update_message = esc_html__('Entry deleted.', 'gravityforms');
} else {
$update_message = esc_html__("You don't have adequate permission to delete entries.", 'gravityforms');
}
break;
case 'bulk':
check_admin_referer('gforms_entry_list', 'gforms_entry_list');
$bulk_action = !empty($_POST['bulk_action']) ? $_POST['bulk_action'] : $_POST['bulk_action2'];
$select_all = rgpost('all_entries');
$leads = empty($select_all) ? $_POST['lead'] : GFFormsModel::search_lead_ids($form_id, $search_criteria);
$entry_count = count($leads) > 1 ? sprintf(esc_html__('%d entries', 'gravityforms'), count($leads)) : esc_html__('1 entry', 'gravityforms');
switch ($bulk_action) {
case 'delete':
if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
RGFormsModel::delete_leads($leads);
$update_message = sprintf(esc_html__('%s deleted.', 'gravityforms'), $entry_count);
} else {
$update_message = esc_html__("You don't have adequate permission to delete entries.", 'gravityforms');
}
break;
case 'trash':
RGFormsModel::update_leads_property($leads, 'status', 'trash');
$update_message = sprintf(esc_html__('%s moved to Trash.', 'gravityforms'), $entry_count);
break;
case 'restore':
RGFormsModel::update_leads_property($leads, 'status', 'active');
$update_message = sprintf(esc_html__('%s restored from the Trash.', 'gravityforms'), $entry_count);
break;
case 'unspam':
RGFormsModel::update_leads_property($leads, 'status', 'active');
$update_message = sprintf(esc_html__('%s restored from the spam.', 'gravityforms'), $entry_count);
break;
case 'spam':
RGFormsModel::update_leads_property($leads, 'status', 'spam');
$update_message = sprintf(esc_html__('%s marked as spam.', 'gravityforms'), $entry_count);
break;
case 'mark_read':
RGFormsModel::update_leads_property($leads, 'is_read', 1);
$update_message = sprintf(esc_html__('%s marked as read.', 'gravityforms'), $entry_count);
break;
case 'mark_unread':
RGFormsModel::update_leads_property($leads, 'is_read', 0);
$update_message = sprintf(esc_html__('%s marked as unread.', 'gravityforms'), $entry_count);
break;
//.........这里部分代码省略.........
示例2: form_settings_fields
/**
* Add form settings page with schedule export options.
*
* TODO: Add default email address - admin email if empty?
*
* @since 1.0.0
*
*/
public function form_settings_fields($form)
{
if (!GFCommon::current_user_can_any('gravityforms_edit_forms')) {
wp_die('You do not have permission to access this page');
}
//collect the form id from the schedule export settings page url for the current form
$form_id = $_REQUEST['id'];
$form = apply_filters("gform_form_export_page_{$form_id}", apply_filters('gform_form_export_page', $form));
//collect filter settings TODO: these are currently not used.
$filter_settings = GFCommon::get_field_filter_settings($form);
$filter_settings_json = json_encode($filter_settings);
//collect and add the default export fields
$form = GFExport::add_default_export_fields($form);
$form_fields = $form['fields'];
$choices[] = array('label' => 'Select All', 'name' => '', 'default_value' => 1);
//loop through the fields and format all the inputs in to an array to be rendered as checkboxes
foreach ($form_fields as $field) {
$inputs = $field->get_entry_inputs();
if (is_array($inputs)) {
foreach ($inputs as $input) {
$choices[] = array('label' => GFCommon::get_label($field, $input['id']), 'name' => $input['id'], 'default_value' => 1);
}
} else {
if (!$field->displayOnly) {
$choices[] = array('label' => GFCommon::get_label($field), 'name' => $field->id, 'default_value' => 1);
}
}
}
$inputs = array(array('title' => "Scheduled Entries Export", 'description' => "The settings below will automatically export new entries and send them to the emails below based on the set time frame.", 'fields' => array(array('label' => "Activate the Schedule", 'type' => "checkbox", 'name' => "enabled", 'tooltip' => "Enabling the schedule based on the sets below. This runs off WP Cron.", 'choices' => array(array('label' => "", 'name' => "enabled"))), array('label' => "Time Frame", 'type' => "select", 'name' => "time_frame", 'tooltip' => "Set how frequently it the entries are exported and emailed", 'choices' => array(array('label' => "Hourly", 'value' => "hourly"), array('label' => "Twice Daily", 'value' => "twicedaily"), array('label' => "Daily", 'value' => "daily"), array('label' => "Weekly", 'value' => "weekly"), array('label' => "Monthly - Every 30 Days", 'value' => "monthly"))), array('type' => "text", 'name' => "email", 'label' => "Email Address", 'class' => "medium", 'tooltip' => "Enter a comma separated list of emails you would like to receive the exported entries file."), array('label' => "Form Fields", 'type' => "checkbox", 'name' => "fields", 'tooltip' => "Select the fields you would like to include in the export. Caution: Make sure you are not sending any sensitive information.", 'choices' => $choices))));
return $inputs;
}
示例3: init
public function init()
{
if (!GFCommon::current_user_can_any($this->_capabilities)) {
return;
}
//add top toolbar menu item
add_filter("gform_toolbar_menu", array($this, 'add_toolbar_menu_item'), 10, 2);
//add custom form action
add_filter("gform_form_actions", array($this, 'add_form_action'), 10, 2);
//add the results view
add_action("gform_entries_view", array($this, 'add_view'), 10, 2);
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
require_once GFCommon::get_base_path() . "/tooltips.php";
add_filter('gform_tooltips', array($this, 'add_tooltips'));
}
示例4: query
public static function query($query)
{
if (method_exists('RGFormsModel', 'get_lead_table_name') && isset($_POST['gform_lead_id']) && preg_match('/^INSERT INTO ' . RGFormsModel::get_lead_table_name() . '/i', $query)) {
$lid = (int) $_POST['gform_lead_id'];
if ($lid) {
$lead = RGFormsModel::get_lead($lid);
if (GFCommon::current_user_can_any("gravityforms_edit_entries") || $lead['created_by'] == wp_get_current_user()->ID) {
global $wpdb;
$wpdb->insert_id = $lid;
$query = 'SELECT 1';
}
}
}
return $query;
}
示例5: add_edit_view_link
/**
* Add Edit View link when in embedded View
*
* @since 1.13
* @return void
*/
function add_edit_view_link()
{
/** @var WP_Admin_Bar $wp_admin_bar */
global $wp_admin_bar;
if (GFCommon::current_user_can_any('edit_pages')) {
$view_data = GravityView_View_Data::getInstance();
$views = $view_data->get_views();
// If there is a View embed, shor Edit View link.
// todo: Support multiple View embeds with a drop-down menu
if (!$this->gravityview_view->isGravityviewPostType() && !empty($views) && !$view_data->has_multiple_views()) {
$view = reset($views);
$wp_admin_bar->add_menu(array('id' => 'edit-view', 'title' => __('Edit View', 'gravityview'), 'href' => esc_url_raw(admin_url(sprintf('post.php?post=%d&action=edit', $view['id'])))));
}
}
}
示例6: load
/**
* @since 3.6.3
* @return void
*/
function load()
{
// Does GF exist? Can the user edit entries?
if (!class_exists('GFCommon')) {
return;
}
if (!GFCommon::current_user_can_any("gravityforms_edit_entries")) {
return;
}
// If screen mode isn't set, then we're in the wrong place.
if (empty($_REQUEST['screen_mode'])) {
return;
}
// Now, no validation is required in the methods; let's hook in.
add_action('admin_init', array(&$this, 'set_screen_mode'));
add_action("gform_entry_info", array(&$this, 'add_select'), 10, 2);
add_action("gform_after_update_entry", array(&$this, 'update_entry_creator'), 10, 2);
}
示例7: init
public function init()
{
if (!GFCommon::current_user_can_any($this->_capabilities)) {
return;
}
// is any GF page
if (GFForms::is_gravity_page()) {
// add top toolbar menu item
add_filter('gform_toolbar_menu', array($this, 'add_toolbar_menu_item'), 10, 2);
// add custom form action
add_filter('gform_form_actions', array($this, 'add_form_action'), 10, 2);
}
// is results page
if (rgget('view') == "gf_results_{$this->_slug}") {
// add the results view
add_action('gform_entries_view', array($this, 'add_view'), 10, 2);
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
// tooltips
require_once GFCommon::get_base_path() . '/tooltips.php';
add_filter('gform_tooltips', array($this, 'add_tooltips'));
}
}
示例8: current_user_can_any
/**
* Checks whether the current user is assigned to a capability or role.
*
* @param string|array $caps An string or array of capabilities to check
* @return bool Returns true if the current user is assigned to any of the capabilities.
*/
protected function current_user_can_any($caps)
{
return GFCommon::current_user_can_any($caps);
}
示例9: authorize
public function authorize($caps = array())
{
if (GFCommon::current_user_can_any($caps)) {
GFCommon::add_api_call();
return true;
}
$this->die_permission_denied();
}
示例10: load_admin_bar_styles
/**
* Hooked into the 'admin_head' action.
*
* Outputs the styles for the Forms Toolbar menu.
* Outputs gf vars if required.
*
* @since 2.0.1.2
*/
public static function load_admin_bar_styles()
{
if (!get_option('gform_enable_toolbar_menu')) {
return;
}
if (!GFCommon::current_user_can_any(array('gravityforms_edit_forms', 'gravityforms_create_form', 'gravityforms_preview_forms', 'gravityforms_view_entries'))) {
// The current user can't use anything on the menu so bail.
return;
}
?>
<style>
.gforms-menu-icon{
float: left;
width: 26px!important;
height: 30px!important;
background-repeat: no-repeat;
background-position: 0 6px;
background-size: 20px;
}
@media screen and ( max-width: 782px ) {
#wpadminbar #wp-admin-bar-gform-forms .ab-item {
line-height: 53px;
height: 46px !important;
width: 52px !important;
display: block;
background-size: 36px 36px;
background-position: 7px 6px;
}
#wpadminbar li#wp-admin-bar-gform-forms {
display: block;
}
}
</style>
<?php
}
示例11: settings_page
public static function settings_page()
{
if (rgpost("uninstall")) {
check_admin_referer("uninstall", "gf_paypal_uninstall");
self::uninstall();
?>
<div class="updated fade" style="padding:20px;"><?php
_e(sprintf("Gravity Forms PayPal Add-On have been successfully uninstalled. It can be re-activated from the %splugins page%s.", "<a href='plugins.php'>", "</a>"), "gravityformspaypal");
?>
</div>
<?php
return;
}
$is_configured = get_option("gf_paypal_configured");
?>
<form action="" method="post">
<?php
wp_nonce_field("update", "gf_paypal_update");
?>
<h3><?php
_e("PayPal Settings", "gravityformspaypal");
?>
</h3>
<p style="text-align: left;">
<?php
_e("Gravity Forms requires IPN to be enabled on your PayPal account. Follow the following steps to confirm IPN is enabled.", "gravityformspaypal");
?>
</p>
<ul>
<li><?php
echo sprintf(__("Navigate to your PayPal %sIPN Settings page.%s", "gravityformspaypal"), "<a href='https://www.paypal.com/us/cgi-bin/webscr?cmd=_profile-ipn-notify' target='_blank'>", "</a>");
?>
</li>
<li><?php
_e("If IPN is already enabled, you will see your current IPN settings along with a button to turn off IPN. If that is the case, just check the confirmation box below and you are ready to go!", "gravityformspaypal");
?>
</li>
<li><?php
_e("If IPN is not enabled, click the 'Choose IPN Settings' button.", "gravityformspaypal");
?>
</li>
<li><?php
echo sprintf(__("Click the box to enable IPN and enter the following Notification URL: %s", "gravityformspaypal"), "<strong>" . add_query_arg("page", "gf_paypal_ipn", get_bloginfo("url") . "/") . "</strong>");
?>
</li>
</ul>
<br/>
<input type="checkbox" name="gf_paypal_configured" id="gf_paypal_configured" onclick="confirm_settings()" <?php
echo $is_configured ? "checked='checked'" : "";
?>
/>
<label for="gf_paypal_configured" class="inline"><?php
_e("Confirm that your have configured your PayPal account to enable IPN", "gravityformspaypal");
?>
</label>
<script type="text/javascript">
function confirm_settings(){
var confirmed = jQuery("#gf_paypal_configured").is(":checked") ? 1 : 0;
jQuery.post(ajaxurl, {action:"gf_paypal_confirm_settings", is_confirmed: confirmed});
}
</script>
</form>
<form action="" method="post">
<?php
wp_nonce_field("uninstall", "gf_paypal_uninstall");
?>
<?php
if (GFCommon::current_user_can_any("gravityforms_paypal_uninstall")) {
?>
<div class="hr-divider"></div>
<h3><?php
_e("Uninstall PayPal Add-On", "gravityformspaypal");
?>
</h3>
<div class="delete-alert"><?php
_e("Warning! This operation deletes ALL PayPal Feeds.", "gravityformspaypal");
?>
<?php
$uninstall_button = '<input type="submit" name="uninstall" value="' . __("Uninstall PayPal Add-On", "gravityformspaypal") . '" class="button" onclick="return confirm(\'' . __("Warning! ALL PayPal Feeds will be deleted. This cannot be undone. \\'OK\\' to delete, \\'Cancel\\' to stop", "gravityformspaypal") . '\');"/>';
echo apply_filters("gform_paypal_uninstall_button", $uninstall_button);
?>
</div>
<?php
}
?>
</form>
<?php
}
示例12: update_page
public static function update_page()
{
if (!GFCommon::current_user_can_any('gravityforms_view_updates')) {
wp_die(__("You don't have permissions to view this page", 'gravityforms'));
}
if (!GFCommon::ensure_wp_version()) {
return;
}
GFCommon::cache_remote_message();
echo GFCommon::get_remote_message();
wp_print_styles(array('thickbox'));
?>
<link rel="stylesheet" href="<?php
echo GFCommon::get_base_url() . '/css/admin.css';
?>
" />
<div class="wrap <?php
echo GFCommon::get_browser_class();
?>
">
<h2><?php
_e('Gravity Forms Updates', 'gravityforms');
?>
</h2>
<?php
$version_info = GFCommon::get_version_info(false);
do_action('gform_after_check_update');
if (version_compare(GFCommon::$version, $version_info['version'], '<')) {
$plugin_file = 'gravityforms/gravityforms.php';
$upgrade_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . urlencode($plugin_file), 'upgrade-plugin_' . $plugin_file);
$message = __('There is a new version of Gravity Forms available.', 'gravityforms');
if (rgar($version_info, 'is_valid_key')) {
?>
<div class="gf_update_outdated alert_yellow">
<?php
echo $message . ' ' . sprintf(__('<p>You can update to the latest version automatically or download the update and install it manually. %sUpdate Automatically%s %sDownload Update%s', 'gravityforms'), "</p><a class='button-primary' href='{$upgrade_url}'>", '</a>', " <a class='button' href='{$version_info["url"]}'>", '</a>');
?>
</div>
<?php
} else {
?>
<div class="gf_update_expired alert_red">
<?php
echo $message . ' ' . __(sprintf('%sRegister%s your copy of Gravity Forms to receive access to automatic updates and support. Need a license key? %sPurchase one now%s.', '<a href="admin.php?page=gf_settings">', '</a>', '<a href="http://www.gravityforms.com">', '</a>'), 'gravityforms');
?>
</div>
<?php
}
echo '<br/><br/>';
$changelog = RGForms::get_changelog();
echo $changelog;
} else {
?>
<div class="gf_update_current alert_green">
<?php
_e('Your version of Gravity Forms is up to date.', 'gravityforms');
?>
</div>
<?php
}
do_action('gform_updates');
?>
<div id='gform_upgrade_license' style="display:none;"></div>
<script type="text/javascript">
jQuery(document).ready(function () {
jQuery.post(ajaxurl, {
action : "gf_upgrade_license",
gf_upgrade_license: "<?php
echo wp_create_nonce('gf_upgrade_license');
?>
"},
function (data) {
if (data.trim().length > 0)
jQuery("#gform_upgrade_license").replaceWith(data);
}
);
});
</script>
</div>
<?php
}
示例13: admin_bar
public static function admin_bar()
{
global $wp_admin_bar;
if (!GFCommon::current_user_can_any('gravityforms_create_form')) {
return;
}
$wp_admin_bar->add_menu(array('id' => 'gravityforms-new-form', 'parent' => 'new-content', 'title' => esc_attr__('Form', 'gravityforms'), 'href' => admin_url('admin.php?page="gf_new_form')));
}
示例14: get_parent_menu
/**
* Returns the parent menu item
*
* @param $menu_items
* @param $addon_menus
*
* @return array|bool The parent menu araray or false if none
*/
private function get_parent_menu($menu_items, $addon_menus)
{
$parent = false;
if (GFCommon::current_user_can_any($this->_capabilities_app_menu)) {
foreach ($menu_items as $menu_item) {
if ($this->current_user_can_any($menu_item['permission'])) {
$parent = $menu_item;
break;
}
}
} elseif (is_array($addon_menus) && sizeof($addon_menus) > 0) {
foreach ($addon_menus as $addon_menu) {
if ($this->current_user_can_any($addon_menu['permission'])) {
$parent = array('name' => $addon_menu['name'], 'callback' => $addon_menu['callback']);
break;
}
}
} elseif ($this->has_app_settings() && $this->current_user_can_any($this->_capabilities_app_settings)) {
$parent = array('name' => $this->_slug . '_settings', 'callback' => array($this, 'app_settings'));
}
return $parent;
}
示例15: forms_page
//.........这里部分代码省略.........
</li>
</ul>
</div>
</div>
</div>
<div>
<div id="after_insert_dialog" style="display:none;">
<h3><?php
_e('You have successfully saved your form!', 'gravityforms');
?>
</h3>
<p><?php
_e('What would you like to do next?', 'gravityforms');
?>
</p>
<div class="new-form-option">
<a title="<?php
_e('Preview this form', 'gravityforms');
?>
" id="preview_form_link" href="<?php
echo trailingslashit(site_url());
?>
?gf_page=preview&id={formid}" target="_blank"><?php
_e('Preview this Form', 'gravityforms');
?>
</a>
</div>
<?php
if (GFCommon::current_user_can_any('gravityforms_edit_forms')) {
?>
<div class="new-form-option">
<a title="<?php
_e('Setup email notifications for this form', 'gravityforms');
?>
" id="notification_form_link" href="#"><?php
_e('Setup Email Notifications for this Form', 'gravityforms');
?>
</a>
</div>
<?php
}
?>
<div class="new-form-option">
<a title="<?php
_e('Continue editing this form', 'gravityforms');
?>
" id="edit_form_link" href="#"><?php
_e('Continue Editing this Form', 'gravityforms');
?>
</a>
</div>
<div class="new-form-option">
<a title="<?php
_e('I am done. Take me back to form list', 'gravityforms');
?>
" href="?page=gf_edit_forms"><?php
_e('Return to Form List', 'gravityforms');
?>
</a>