本文整理汇总了PHP中CF7DBPlugin::canUserDoRoleOption方法的典型用法代码示例。如果您正苦于以下问题:PHP CF7DBPlugin::canUserDoRoleOption方法的具体用法?PHP CF7DBPlugin::canUserDoRoleOption怎么用?PHP CF7DBPlugin::canUserDoRoleOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CF7DBPlugin
的用法示例。
在下文中一共展示了CF7DBPlugin::canUserDoRoleOption方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isAuthorized
/**
* @return bool
*/
protected function isAuthorized()
{
if (!$this->isFromShortCode) {
return $this->plugin->canUserDoRoleOption('CanSeeSubmitData');
} else {
$isAuth = $this->plugin->canUserDoRoleOption('CanSeeSubmitDataViaShortcode');
if ($isAuth && isset($this->options['role'])) {
$isAuth = $this->plugin->isUserRoleEqualOrBetterThan($this->options['role']);
}
return $isAuth;
}
}
示例2: display
function display(&$plugin)
{
if ($plugin == null) {
$plugin = new CF7DBPlugin();
}
$canEdit = $plugin->canUserDoRoleOption('CanChangeSubmitData');
$this->pageHeader($plugin);
global $wpdb;
$tableName = $plugin->getSubmitsTableName();
$useDataTables = $plugin->getOption('UseDataTablesJS', 'true', true) == 'true';
$tableHtmlId = 'cf2dbtable';
// Identify which forms have data in the database
$formsList = $plugin->getForms();
if (count($formsList) == 0) {
echo htmlspecialchars(__('No form submissions in the database', 'contact-form-7-to-database-extension'));
return;
}
$page = 1;
if (isset($_REQUEST['dbpage'])) {
$page = $this->getRequestParam('dbpage');
}
$currSelection = null;
if (isset($_REQUEST['form_name'])) {
$currSelection = $this->getRequestParam('form_name');
} else {
if (isset($_REQUEST['form'])) {
$currSelection = $this->getRequestParam('form');
}
}
if ($currSelection) {
$currSelection = stripslashes($currSelection);
$currSelection = html_entity_decode($currSelection);
}
$currSelectionEscaped = htmlentities($currSelection, null, 'UTF-8');
// If there is only one form in the DB, select that by default
if (!$currSelection && count($formsList) == 1) {
$currSelection = $formsList[0];
// Bug fix: Need to set this so the Editor plugin can reference it
$_REQUEST['form_name'] = $formsList[0];
}
if ($currSelection) {
// Check for delete operation
if (isset($_POST['cfdbdel']) && $canEdit && wp_verify_nonce($_REQUEST['_wpnonce'])) {
if (isset($_POST['submit_time'])) {
$submitTime = $_POST['submit_time'];
$wpdb->query($wpdb->prepare("delete from `{$tableName}` where `form_name` = '%s' and `submit_time` = %F", $currSelection, $submitTime));
} else {
if (isset($_POST['all'])) {
$wpdb->query($wpdb->prepare("delete from `{$tableName}` where `form_name` = '%s'", $currSelection));
} else {
foreach ($_POST as $name => $value) {
// checkboxes
if ($value == 'row') {
// Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_REQUEST["a_b"].
// http://www.php.net/manual/en/language.variables.external.php
// We are expecting a time value like '1300728460.6626' but will instead get '1300728460_6626'
// so we need to put the '.' back in before going to the DB.
$name = str_replace('_', '.', $name);
$wpdb->query($wpdb->prepare("delete from `{$tableName}` where `form_name` = '%s' and `submit_time` = %F", $currSelection, $name));
}
}
}
}
} else {
if (isset($_POST['delete_wpcf7']) && $canEdit && wp_verify_nonce($_REQUEST['_wpnonce'])) {
$plugin->delete_wpcf7_fields($currSelection);
$plugin->add_wpcf7_noSaveFields();
}
}
}
// Form selection drop-down list
$pluginDirUrl = $plugin->getPluginDirUrl();
?>
<table width="100%" cellspacing="20">
<tr>
<td align="left" valign="top">
<form method="get" action="<?php
echo $_SERVER['REQUEST_URI'];
?>
" name="displayform" id="displayform">
<input type="hidden" name="page" value="<?php
echo htmlspecialchars($this->getRequestParam('page'));
?>
"/>
<select name="form_name" id="form_name" onchange="this.form.submit();">
<option value=""><?php
echo htmlspecialchars(__('* Select a form *', 'contact-form-7-to-database-extension'));
?>
</option>
<?php
foreach ($formsList as $formName) {
$selected = $formName == $currSelection ? "selected" : "";
$formNameEscaped = htmlentities($formName, null, 'UTF-8');
?>
<option value="<?php
echo $formNameEscaped;
?>
" <?php
echo $selected;
?>
//.........这里部分代码省略.........
示例3: export
public function export($formName, $options = null)
{
$plugin = new CF7DBPlugin();
if (!$plugin->canUserDoRoleOption('CanSeeSubmitData')) {
CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
}
header('Expires: 0');
header('Cache-Control: no-store, no-cache, must-revalidate');
$pluginUrlDir = $plugin->getPluginDirUrl();
$scriptLink = $pluginUrlDir . 'CFDBGoogleSSLiveData.php';
$imageUrlDir = $pluginUrlDir . "help";
$siteUrl = get_option('home');
$userName = is_user_logged_in() ? wp_get_current_user()->user_login : 'user';
ob_start();
?>
<style type="text/css">
*.popup-trigger {
position: relative;
z-index: 0;
}
*.popup-trigger:hover {
background-color: transparent;
z-index: 50;
}
*.popup-content {
position: absolute!important;
background-color: #ffffff;
padding: 5px;
border: 2px gray;
visibility: hidden!important;
color: black;
text-decoration: none;
min-width:400px;
max-width:600px;
overflow: auto;
}
*.popup-trigger:hover *.popup-content {
visibility: visible!important;
top: 50px!important;
left: 50px!important;
}
</style>
<?php
_e('Setting up a Google Spreadsheet to pull in data from WordPress requires these manual steps:', 'contact-form-7-to-database-extension');
?>
<table cellspacing="15px" cellpadding="15px">
<tbody>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php
echo $imageUrlDir;
?>
/GoogleNewSS.png">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleNewSS.png" alt="Create a new spreadsheet" height="100px" width="61px"/>
<div class="popup-content">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleNewSS.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td><p><?php
_e('Log into Google Docs and create a new Google Spreadsheet', 'contact-form-7-to-database-extension');
?>
</p></td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php
echo $imageUrlDir;
?>
/GoogleOpenScriptEditor.png">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="69px" width="100px"/>
<div class="popup-content">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="75%" width="75%"/>
</div>
</a>
</div>
</td>
<td><p><?php
_e('Go to <strong>Tools</strong> menu -> <strong>Script Editor...', 'contact-form-7-to-database-extension');
?>
//.........这里部分代码省略.........
示例4: export
public function export($formName, $options = null)
{
$plugin = new CF7DBPlugin();
if (!$plugin->canUserDoRoleOption('CanSeeSubmitData')) {
CFDBDie::wp_die(__('You do not have sufficient permissions to access this page.', 'contact-form-7-to-database-extension'));
}
header('Expires: 0');
header('Cache-Control: no-store, no-cache, must-revalidate');
$pluginUrlDir = $plugin->getPluginDirUrl();
$scriptLink = $pluginUrlDir . 'Cf7ToDBGGoogleSS.js.php';
$imageUrlDir = $pluginUrlDir . "help";
$siteUrl = get_option('home');
$search = isset($options['search']) ? $options['search'] : '';
ob_start();
?>
<style type="text/css">
*.popup-trigger {
position: relative;
z-index: 0;
}
*.popup-trigger:hover {
background-color: transparent;
z-index: 50;
}
*.popup-content {
position: absolute!important;
background-color: #ffffff;
padding: 5px;
border: 2px gray;
visibility: hidden!important;
color: black;
text-decoration: none;
min-width:400px;
max-width:600px;
overflow: auto;
}
*.popup-trigger:hover *.popup-content {
visibility: visible!important;
top: 50px!important;
left: 50px!important;
}
</style>
Setting up a Google Spreadsheet to pull in data from WordPress requires these manual steps:
<table cellspacing="15px" cellpadding="15px">
<tbody>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php
echo $imageUrlDir;
?>
/GoogleNewSS.png">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleNewSS.png" alt="Create a new spreadsheet" height="100px" width="61px"/>
<div class="popup-content">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleNewSS.png" alt="Create a new spreadsheet"/>
</div>
</a>
</div>
</td>
<td><p>Log into Google Docs and create a new Google Spreadsheet</p></td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php
echo $imageUrlDir;
?>
/GoogleOpenScriptEditor.png">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet" height="69px" width="100px"/>
<div class="popup-content">
<img src="<?php
echo $imageUrlDir;
?>
/GoogleOpenScriptEditor.png" alt="Create a new spreadsheet"/>
</div>
</a>
</div>
</td>
<td><p>Go to <b>Tools</b> menu -> <b>Scripts</b> -> <b>Script Editor...</b></p></td>
</tr>
<tr>
<td>
<div class="popup-trigger">
<a href="<?php
echo $imageUrlDir;
?>
//.........这里部分代码省略.........
示例5: isAuthorized
protected function isAuthorized()
{
return $this->isFromShortCode ? $this->plugin->canUserDoRoleOption('CanSeeSubmitDataViaShortcode') : $this->plugin->canUserDoRoleOption('CanSeeSubmitData');
}
示例6: display
function display(&$plugin)
{
if ($plugin == null) {
$plugin = new CF7DBPlugin();
}
$canEdit = $plugin->canUserDoRoleOption('CanChangeSubmitData');
$this->pageHeader($plugin);
global $wpdb;
$tableName = $plugin->getSubmitsTableName();
$useDataTables = $plugin->getOption('UseDataTablesJS', 'true') == 'true';
$tableHtmlId = 'cf2dbtable';
// Identify which forms have data in the database
$rows = $wpdb->get_results("select distinct `form_name` from `{$tableName}` order by `form_name`");
if ($rows == null || count($rows) == 0) {
_e('No form submissions in the database', 'contact-form-7-to-database-extension');
return;
}
$page = 1;
if (isset($_REQUEST['dbpage'])) {
$page = $_REQUEST['dbpage'];
} else {
if (isset($_GET['dbpage'])) {
$page = $_GET['dbpage'];
}
}
$currSelection = null;
//$rows[0]->form_name;
if (isset($_REQUEST['form_name'])) {
$currSelection = $_REQUEST['form_name'];
} else {
if (isset($_GET['form_name'])) {
$currSelection = $_GET['form_name'];
}
}
if ($currSelection) {
// Check for delete operation
if (isset($_POST['delete']) && $canEdit) {
if (isset($_POST['submit_time'])) {
$submitTime = $_POST['submit_time'];
$wpdb->query($wpdb->prepare("delete from `{$tableName}` where `form_name` = '%s' and `submit_time` = %F", $currSelection, $submitTime));
} else {
if (isset($_POST['all'])) {
$wpdb->query($wpdb->prepare("delete from `{$tableName}` where `form_name` = '%s'", $currSelection));
} else {
foreach ($_POST as $name => $value) {
// checkboxes
if ($value == 'row') {
// Dots and spaces in variable names are converted to underscores. For example <input name="a.b" /> becomes $_REQUEST["a_b"].
// http://www.php.net/manual/en/language.variables.external.php
// We are expecting a time value like '1300728460.6626' but will instead get '1300728460_6626'
// so we need to put the '.' back in before going to the DB.
$name = str_replace('_', '.', $name);
$wpdb->query($wpdb->prepare("delete from `{$tableName}` where `form_name` = '%s' and `submit_time` = %F", $currSelection, $name));
}
}
}
}
}
}
// Form selection drop-down list
$pluginDirUrl = $plugin->getPluginDirUrl();
?>
<table width="100%" cellspacing="20">
<tr>
<td align="left" valign="top">
<form method="get" action="" name="displayform" id="displayform">
<input type="hidden" name="page" value="<?php
echo $_REQUEST['page'];
?>
"/>
<select name="form_name" id="form_name" onchange="this.form.submit();">
<option value=""><?php
_e('* Select a form *', 'contact-form-7-to-database-extension');
?>
</option>
<?php
foreach ($rows as $aRow) {
$formName = $aRow->form_name;
$selected = $formName == $currSelection ? "selected" : "";
?>
<option value="<?php
echo $formName;
?>
" <?php
echo $selected;
?>
><?php
echo $formName;
?>
</option>
<?php
}
?>
</select>
</form>
</td>
<td align="center" valign="top">
<?php
if ($currSelection) {
?>
//.........这里部分代码省略.........
示例7: ajaxRenameForm
public function ajaxRenameForm()
{
header("Pragma: no-cache");
header("Expires: Thu, 01 Jan 1970 00:00:00 GMT");
$cfdb = new CF7DBPlugin();
if (!$cfdb->canUserDoRoleOption('CanChangeSubmitData')) {
die(1);
}
if (!isset($_REQUEST['form']) || !$_REQUEST['form']) {
echo 'No form name set';
die(1);
}
if (!isset($_REQUEST['newformname']) || !$_REQUEST['newformname']) {
echo 'No new form name set';
die(1);
}
global $wpdb;
$tableName = $cfdb->getSubmitsTableName();
$parametrizedQuery = "UPDATE `{$tableName}` SET `form_name` = %s WHERE `form_name` = %s";
$result = $wpdb->query($wpdb->prepare($parametrizedQuery, $_REQUEST['newformname'], $_REQUEST['form']));
if ($result == false) {
echo 'Failed to update';
} else {
$url = admin_url('admin.php') . '?page=CF7DBPluginSubmissions&form_name=' . $_REQUEST['newformname'];
printf('Form "%s" renamed to <a href="%s">"%s"</a>.', $_REQUEST['form'], $url, $_REQUEST['newformname']);
$backUrl = admin_url('admin.php') . '?page=CF7DBPluginImport';
printf('<br/><a href="%s">%s</a>', $backUrl, 'Back');
}
die;
}