本文整理汇总了PHP中GFAPI::current_user_can_any方法的典型用法代码示例。如果您正苦于以下问题:PHP GFAPI::current_user_can_any方法的具体用法?PHP GFAPI::current_user_can_any怎么用?PHP GFAPI::current_user_can_any使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GFAPI
的用法示例。
在下文中一共展示了GFAPI::current_user_can_any方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init_admin
public function init_admin()
{
parent::init_admin();
add_action('gform_entry_detail_sidebar_before', array($this, 'entry_detail_approval_box'), 10, 2);
add_filter('gform_notification_events', array($this, 'add_notification_event'));
add_filter('gform_entries_field_value', array($this, 'filter_gform_entries_field_value'), 10, 4);
if (GFAPI::current_user_can_any('gravityforms_edit_entries')) {
add_action('wp_dashboard_setup', array($this, 'dashboard_setup'));
}
}
示例2: display
public static function display($args)
{
$defaults = array('check_permissions' => true, 'detail_base_url' => admin_url('admin.php?page=gravityflow-inbox&view=entry'));
$args = array_merge($defaults, $args);
if ($args['check_permissions'] && !GFAPI::current_user_can_any('gravityflow_activity')) {
esc_html_e("You don't have permission to view this page", 'gravityflow');
return;
}
$events = Gravity_Flow_Activity::get_events();
if (sizeof($events) > 0) {
?>
<table id="gravityflow-activity" class="widefat" cellspacing="0" style="border:0px;">
<thead>
<tr>
<th data-label="<?php
esc_html_e('Event ID', 'gravityflow');
?>
"><?php
esc_html_e('Event ID', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Date', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Form', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Entry ID', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Type', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Event', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Step', 'gravityflow');
?>
</th>
<th><?php
esc_html_e('Duration', 'gravityflow');
?>
</th>
</tr>
</thead>
<tbody class="list:user user-list">
<?php
foreach ($events as $event) {
$form = GFAPI::get_form($event->form_id);
$base_url = $args['detail_base_url'];
$url_entry = $base_url . sprintf('&id=%d&lid=%d', $event->form_id, $event->lead_id);
$url_entry = esc_url_raw($url_entry);
$link = "<a href='%s'>%s</a>";
?>
<tr>
<td data-label="<?php
esc_html_e('ID', 'gravityflow');
?>
">
<?php
echo esc_html($event->id);
?>
</td>
<td data-label="<?php
esc_html_e('Date', 'gravityflow');
?>
">
<?php
echo esc_html(GFCommon::format_date($event->date_created));
?>
</td>
<td data-label="<?php
esc_html_e('Form', 'gravityflow');
?>
">
<?php
printf($link, $url_entry, $form['title']);
?>
</td>
<td data-label="<?php
esc_html_e('Entry ID', 'gravityflow');
?>
">
<?php
printf($link, $url_entry, $event->lead_id);
?>
</td>
<td data-label="<?php
esc_html_e('Type', 'gravityflow');
?>
">
<?php
//.........这里部分代码省略.........
示例3: __construct
function __construct($args = array())
{
$default_bulk_actions = array('print' => esc_html__('Print', 'gravityflow'));
if (GFAPI::current_user_can_any('gravityflow_admin_actions')) {
$default_bulk_actions['restart_workflow'] = esc_html__('Restart Workflow', 'gravityflow');
}
$default_args = array('singular' => __('entry', 'gravityflow'), 'plural' => __('entries', 'gravityflow'), 'ajax' => false, 'base_url' => admin_url('admin.php?page=gravityflow-status'), 'detail_base_url' => admin_url('admin.php?page=gravityflow-inbox&view=entry'), 'constraint_filters' => array(), 'field_ids' => array(), 'screen' => 'gravityflow-status', 'display_all' => GFAPI::current_user_can_any('gravityflow_status_view_all'), 'bulk_actions' => $default_bulk_actions, 'per_page' => 20, 'id_column' => true, 'submitter_column' => true, 'step_column' => true, 'status_column' => true, 'last_updated' => false);
$args = wp_parse_args($args, $default_args);
require_once ABSPATH . 'wp-admin/includes/template.php';
if (!class_exists('WP_Screen')) {
require_once ABSPATH . 'wp-admin/includes/class-wp-screen.php';
}
parent::__construct($args);
$this->base_url = $args['base_url'];
$this->detail_base_url = $args['detail_base_url'];
$this->constraint_filters = $args['constraint_filters'];
if (!is_array($args['field_ids'])) {
$args['field_ids'] = explode(',', $args['field_ids']);
}
$this->field_ids = $args['field_ids'];
$this->display_all = $args['display_all'];
$this->bulk_actions = $args['bulk_actions'];
$this->set_counts();
$this->per_page = $args['per_page'];
$this->id_column = $args['id_column'];
$this->step_column = $args['step_column'];
$this->submitter_column = $args['submitter_column'];
$this->status_column = $args['status_column'];
$this->last_updated = $args['last_updated'];
}
示例4: display
public static function display($args)
{
$assignee_key = sanitize_text_field(rgget('assignee'));
list($assignee_type, $assignee_id) = rgexplode('|', $assignee_key, 2);
$range = sanitize_key(rgget('range'));
switch ($range) {
case 'last-6-months':
$start_date = date('Y-m-d', strtotime('-6 months'));
break;
case 'last-3-months':
$start_date = date('Y-m-d', strtotime('-3 months'));
break;
default:
$start_date = date('Y-m-d', strtotime('-1 year'));
}
$defaults = array('view' => rgget('view'), 'form_id' => absint(rgget('form-id')), 'step_id' => absint(rgget('step-id')), 'category' => sanitize_key(rgget('category')), 'range' => $range, 'start_date' => $start_date, 'assignee' => $assignee_key, 'assignee_type' => $assignee_type, 'assignee_id' => $assignee_id, 'check_permissions' => true, 'base_url' => admin_url('admin.php?page=gravityflow-reports'));
$args = array_merge($defaults, $args);
if ($args['check_permissions'] && !GFAPI::current_user_can_any('gravityflow_reports')) {
esc_html_e("You don't have permission to view this page", 'gravityflow');
return;
}
$filter_vars['config'] = self::get_filter_config_vars();
$filter_vars['selected'] = array('formId' => $args['form_id'], 'category' => $args['category'], 'stepId' => empty($args['step_id']) ? '' : $args['step_id'], 'assignee' => $args['assignee']);
?>
<script>var gravityflowFilterVars = <?php
echo json_encode($filter_vars);
?>
;</script>
<div id="gravityflow-reports-filter" style="margin-bottom:10px;">
<form method="GET" action="<?php
echo esc_url($args['base_url']);
?>
">
<input type="hidden" value="gravityflow-reports" name="page" />
<?php
self::range_drop_down($args['range']);
?>
<?php
self::form_drop_down($args['form_id']);
?>
<?php
self::category_drop_down($args['category']);
?>
<select id="gravityflow-reports-steps" style="display:none;" name="step-id"></select>
<select id="gravityflow-reports-assignees" style="display:none;" name="assignee"></select>
<input type="submit" value="<?php
esc_html_e('Filter', 'gravityflow');
?>
" class="button-secondary" />
</form>
</div>
<?php
if (empty($args['form_id'])) {
self::report_all_forms($args);
return;
}
$form_id = $args['form_id'];
if ($args['category'] == 'assignee') {
if (empty($args['assignee_key'])) {
self::report_form_by_assignee($form_id, $args);
}
} elseif ($args['category'] == 'step') {
if (empty($args['step_id'])) {
self::report_form_by_step($form_id, $args);
} else {
$step_id = $args['step_id'];
if (empty($args['assignee_id'])) {
self::report_step_by_assignee($step_id, $args);
} else {
$assignee_type = $args['assignee_type'];
$assignee_id = $args['assignee_id'];
self::report_assignee_by_month($assignee_type, $assignee_id, $args);
}
}
} else {
self::report_form_by_month($form_id, $args);
}
}
示例5: ajax_download_export
public function ajax_download_export()
{
if (!wp_verify_nonce(rgget('nonce'), 'gravityflow_download_export') || !GFAPI::current_user_can_any('gravityflow_status')) {
$response['status'] = 'error';
$response['message'] = __('Not authorized', 'gravityflow');
$response_json = json_encode($response);
echo $response_json;
die;
}
$file_name = $_REQUEST['file_name'];
$upload_dir = wp_upload_dir();
$file_path = trailingslashit($upload_dir['basedir']) . $file_name . '.csv';
$file = '';
if (@file_exists($file_path)) {
$file = @file_get_contents($file_path);
@unlink($file_path);
}
nocache_headers();
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $file_name . '-' . date('m-d-Y') . '.csv');
header('Expires: 0');
echo $file;
die;
}
示例6: entry_detail
//.........这里部分代码省略.........
?>
: <?php
esc_html_e($form['title']);
?>
</span></span>
</h2>
<div id="gf_form_toolbar">
<ul id="gf_form_toolbar_links">
<?php
$menu_items = gravity_flow()->get_toolbar_menu_items();
echo GFForms::format_toolbar_menu_items($menu_items);
?>
</ul>
</div>
<?php
}
if ($check_view_entry_permissions) {
// Check view permissions
global $current_user;
if ($entry['created_by'] != $current_user->ID) {
$user_status = false;
if ($current_step) {
$user_status = $current_step->get_user_status();
if (!$user_status) {
$user_roles = gravity_flow()->get_user_roles();
foreach ($user_roles as $user_role) {
$user_status = $current_step->get_role_status($user_role);
}
}
}
$full_access = GFAPI::current_user_can_any(array('gform_full_access', 'gravityflow_status_view_all'));
if (!($user_status || $full_access)) {
$permission_denied_message = esc_attr__("You don't have permission to view this entry.", 'gravityflow');
$permission_denied_message = apply_filters('gravityflow_permission_denied_message_entry_detail', $permission_denied_message, $current_step);
echo $permission_denied_message;
return;
}
}
}
$url = remove_query_arg(array('gworkflow_token', 'new_status'));
?>
<div class="gform_wrapper">
<form method="post" id="entry_form" enctype='multipart/form-data' action="<?php
echo esc_url($url);
?>
">
<?php
wp_nonce_field('gforms_save_entry', 'gforms_save_entry');
?>
<div id="poststuff" class="metabox-holder has-right-sidebar">
<div id="side-info-column" class="inner-sidebar">
<?php
gravity_flow()->workflow_entry_detail_status_box($form, $entry, $current_step);
if (is_user_logged_in() || $check_view_entry_permissions) {
?>
<!-- begin print button -->
<div class="detail-view-print">
<a href="javascript:;"
onclick="var notes_qs = jQuery('#gform_print_notes').is(':checked') ? '¬es=1' : ''; var url='<?php
echo admin_url('admin-ajax.php');
?>
示例7: render
//.........这里部分代码省略.........
sort($entry_ids);
if (empty($entry_ids)) {
die(esc_html__('Form Id and Lead Id are required parameters.', 'gravityflow'));
}
$min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG || isset($_GET['gform_debug']) ? '' : '.min';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta name="Robots" content="noindex, nofollow" />
<meta http-equiv="Imagetoolbar" content="No" />
<title>
<?php
$entry_count = count($entry_ids);
$title = $entry_count > 1 ? esc_html__('Bulk Print', 'gravityflow') : esc_html__('Entry # ', 'gravityflow') . $entry_ids[0];
$title = apply_filters('gravityflow_page_title_print_entry', $title, $entry_count);
echo esc_html($title);
?>
</title>
<link rel='stylesheet' href='<?php
echo GFCommon::get_base_url();
?>
/css/print<?php
echo $min;
?>
.css' type='text/css' />
<link rel='stylesheet' href='<?php
echo gravity_flow()->get_base_url();
?>
/css/entry-detail<?php
echo $min;
?>
.css' type='text/css' />
<?php
$styles = apply_filters('gravityflow_print_styles', false);
if (!empty($styles)) {
wp_print_styles($styles);
}
?>
</head>
<body>
<div id="view-container">
<?php
require_once GFCommon::get_base_path() . '/entry_detail.php';
foreach ($entry_ids as $entry_id) {
$entry = RGFormsModel::get_lead($entry_id);
$form = GFAPI::get_form($entry['form_id']);
do_action('gravityflow_print_entry_header', $form, $entry);
// Separate each entry inside a form element so radio buttons don't get treated as a single group across multiple entries.
echo '<form>';
$gravity_flow = gravity_flow();
$current_step = $gravity_flow->get_current_step($form, $entry);
// Check view permissions
global $current_user;
if ($entry['created_by'] != $current_user->ID) {
$user_status = false;
if ($current_step) {
$user_status = $current_step->get_user_status();
gravity_flow()->log_debug(__METHOD__ . '() - user status = ' . $user_status);
if (!$user_status) {
$user_roles = gravity_flow()->get_user_roles();
foreach ($user_roles as $user_role) {
$user_status = $current_step->get_role_status($user_role);
if ($user_status) {
break;
}
}
}
}
$full_access = GFAPI::current_user_can_any(array('gform_full_access', 'gravityflow_status_view_all'));
if (!($user_status || $full_access)) {
esc_attr_e("You don't have permission to view this entry.", 'gravityflow');
continue;
}
}
require_once $gravity_flow->get_base_path() . '/includes/pages/class-entry-detail.php';
Gravity_Flow_Entry_Detail::entry_detail_grid($form, $entry, false, array(), $current_step);
echo '</form>';
if (rgget('notes')) {
Gravity_Flow_Entry_Detail::timeline($entry, $form);
}
// output entry divider/page break
if (array_search($entry_id, $entry_ids) < count($entry_ids) - 1) {
echo '<div class="print-hr ' . $page_break . '"></div>';
}
do_action('gravityflow_print_entry_footer', $form, $entry);
}
?>
</div>
</body>
</html>
<?php
}