本文整理汇总了PHP中RGFormsModel::get_lead_details_long_table_name方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::get_lead_details_long_table_name方法的具体用法?PHP RGFormsModel::get_lead_details_long_table_name怎么用?PHP RGFormsModel::get_lead_details_long_table_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::get_lead_details_long_table_name方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public static function setup($force_setup = false)
{
global $wpdb;
$version = GFCommon::$version;
if (get_option("rg_form_version") != $version || $force_setup) {
$error = "";
if (!self::has_database_permission($error)) {
?>
<div class='error' style="padding:15px;"><?php
echo $error;
?>
</div>
<?php
}
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
//------ FORM -----------------------------------------------
$form_table_name = RGFormsModel::get_form_table_name();
$sql = "CREATE TABLE " . $form_table_name . " (\r\n id mediumint(8) unsigned not null auto_increment,\r\n title varchar(150) not null,\r\n date_created datetime not null,\r\n is_active tinyint(1) not null default 1,\r\n PRIMARY KEY (id)\r\n ) {$charset_collate};";
dbDelta($sql);
//------ META -----------------------------------------------
$meta_table_name = RGFormsModel::get_meta_table_name();
$sql = "CREATE TABLE " . $meta_table_name . " (\r\n form_id mediumint(8) unsigned not null,\r\n display_meta longtext,\r\n entries_grid_meta longtext,\r\n PRIMARY KEY (form_id)\r\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($meta_table_name, 'form_id');
//------ FORM VIEW -----------------------------------------------
$form_view_table_name = RGFormsModel::get_form_view_table_name();
$sql = "CREATE TABLE " . $form_view_table_name . " (\r\n id bigint(20) unsigned not null auto_increment,\r\n form_id mediumint(8) unsigned not null,\r\n date_created datetime not null,\r\n ip char(15),\r\n count mediumint(8) unsigned not null default 1,\r\n PRIMARY KEY (id),\r\n KEY form_id (form_id)\r\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD -----------------------------------------------
$lead_table_name = RGFormsModel::get_lead_table_name();
$sql = "CREATE TABLE " . $lead_table_name . " (\r\n id int(10) unsigned not null auto_increment,\r\n form_id mediumint(8) unsigned not null,\r\n post_id bigint(20) unsigned,\r\n date_created datetime not null,\r\n is_starred tinyint(1) not null default 0,\r\n is_read tinyint(1) not null default 0,\r\n ip varchar(39) not null,\r\n source_url varchar(200) not null default '',\r\n user_agent varchar(250) not null default '',\r\n currency varchar(5),\r\n payment_status varchar(15),\r\n payment_date datetime,\r\n payment_amount decimal(19,2),\r\n transaction_id varchar(50),\r\n is_fulfilled tinyint(1),\r\n created_by bigint(20) unsigned,\r\n transaction_type tinyint(1),\r\n status varchar(20) not null default 'active',\r\n PRIMARY KEY (id),\r\n KEY form_id (form_id),\r\n KEY status (status)\r\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD NOTES ------------------------------------------
$lead_notes_table_name = RGFormsModel::get_lead_notes_table_name();
$sql = "CREATE TABLE " . $lead_notes_table_name . " (\r\n id int(10) unsigned not null auto_increment,\r\n lead_id int(10) unsigned not null,\r\n user_name varchar(250),\r\n user_id bigint(20),\r\n date_created datetime not null,\r\n value longtext,\r\n PRIMARY KEY (id),\r\n KEY lead_id (lead_id),\r\n KEY lead_user_key (lead_id,user_id)\r\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL -----------------------------------------
$lead_detail_table_name = RGFormsModel::get_lead_details_table_name();
$sql = "CREATE TABLE " . $lead_detail_table_name . " (\r\n id bigint(20) unsigned not null auto_increment,\r\n lead_id int(10) unsigned not null,\r\n form_id mediumint(8) unsigned not null,\r\n field_number float not null,\r\n value varchar(" . GFORMS_MAX_FIELD_LENGTH . "),\r\n PRIMARY KEY (id),\r\n KEY form_id (form_id),\r\n KEY lead_id (lead_id)\r\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL LONG -----------------------------------
$lead_detail_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$sql = "CREATE TABLE " . $lead_detail_long_table_name . " (\r\n lead_detail_id bigint(20) unsigned not null,\r\n value longtext,\r\n PRIMARY KEY (lead_detail_id)\r\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($lead_detail_long_table_name, 'lead_detail_key');
//------ LEAD META -----------------------------------
$lead_meta_table_name = RGFormsModel::get_lead_meta_table_name();
$sql = "CREATE TABLE " . $lead_meta_table_name . " (\r\n id bigint(20) unsigned not null auto_increment,\r\n lead_id bigint(20) unsigned not null,\r\n meta_key varchar(255),\r\n meta_value longtext,\r\n PRIMARY KEY (id),\r\n KEY meta_key (meta_key),\r\n KEY lead_id (lead_id)\r\n ) {$charset_collate};";
dbDelta($sql);
//fix checkbox value. needed for version 1.0 and below but won't hurt for higher versions
self::fix_checkbox_value();
//auto-setting license key based on value configured via the GF_LICENSE_KEY constant or the gf_license_key variable
global $gf_license_key;
$license_key = defined("GF_LICENSE_KEY") && empty($gf_license_key) ? GF_LICENSE_KEY : $gf_license_key;
if (!empty($license_key)) {
update_option("rg_gforms_key", md5($license_key));
}
//auto-setting recaptcha keys based on value configured via the constant or global variable
global $gf_recaptcha_public_key, $gf_recaptcha_private_key;
$private_key = defined("GF_RECAPTCHA_PRIVATE_KEY") && empty($gf_recaptcha_private_key) ? GF_RECAPTCHA_PRIVATE_KEY : $gf_recaptcha_private_key;
if (!empty($private_key)) {
update_option("rg_gforms_captcha_private_key", $private_key);
}
$public_key = defined("GF_RECAPTCHA_PUBLIC_KEY") && empty($gf_recaptcha_public_key) ? GF_RECAPTCHA_PUBLIC_KEY : $gf_recaptcha_public_key;
if (!empty($public_key)) {
update_option("rg_gforms_captcha_public_key", $public_key);
}
//Auto-importing forms based on GF_IMPORT_FILE AND GF_THEME_IMPORT_FILE
if (defined("GF_IMPORT_FILE") && !get_option("gf_imported_file")) {
GFExport::import_file(GF_IMPORT_FILE);
update_option("gf_imported_file", true);
}
//adds empty index.php files to upload folders. only for v1.5.2 and below
if (version_compare(get_option("rg_form_version"), "1.6", "<")) {
self::add_empty_index_files();
}
update_option("rg_form_version", $version);
}
//Import theme specific forms if configured. Will only import forms once per theme.
if (defined("GF_THEME_IMPORT_FILE")) {
$themes = get_option("gf_imported_theme_file");
if (!is_array($themes)) {
$themes = array();
}
//if current theme has already imported it's forms, don't import again
$theme = get_template();
if (!isset($themes[$theme])) {
//importing forms
GFExport::import_file(get_stylesheet_directory() . "/" . GF_THEME_IMPORT_FILE);
//adding current theme to the list of imported themes. So that forms are not imported again for it.
$themes[$theme] = true;
update_option("gf_imported_theme_file", $themes);
//.........这里部分代码省略.........
示例2: setup_database
public static function setup_database()
{
global $wpdb;
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
//Fixes issue with dbDelta lower-casing table names, which cause problems on case sensitive DB servers.
add_filter('dbdelta_create_queries', array('RGForms', 'dbdelta_fix_case'));
/*
* Indexes have a maximum size of 767 bytes. Historically, we haven't need to be concerned about that.
* As of 4.2, however, WP core moved to utf8mb4, which uses 4 bytes per character. This means that an index which
* used to have room for floor(767/3) = 255 characters, now only has room for floor(767/4) = 191 characters.
*/
$max_index_length = 191;
//------ FORM -----------------------------------------------
$form_table_name = RGFormsModel::get_form_table_name();
$sql = 'CREATE TABLE ' . $form_table_name . " (\n id mediumint(8) unsigned not null auto_increment,\n title varchar(150) not null,\n date_created datetime not null,\n is_active tinyint(1) not null default 1,\n is_trash tinyint(1) not null default 0,\n PRIMARY KEY (id)\n ) {$charset_collate};";
dbDelta($sql);
//droping table that was created by mistake in version 1.6.3.2
$wpdb->query('DROP TABLE IF EXISTS A' . $form_table_name);
//------ META -----------------------------------------------
$meta_table_name = RGFormsModel::get_meta_table_name();
$sql = 'CREATE TABLE ' . $meta_table_name . " (\n form_id mediumint(8) unsigned not null,\n display_meta longtext,\n entries_grid_meta longtext,\n confirmations longtext,\n notifications longtext,\n PRIMARY KEY (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($meta_table_name, 'form_id');
//------ FORM VIEW -----------------------------------------------
$form_view_table_name = RGFormsModel::get_form_view_table_name();
$sql = 'CREATE TABLE ' . $form_view_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null,\n date_created datetime not null,\n ip char(15),\n count mediumint(8) unsigned not null default 1,\n PRIMARY KEY (id),\n KEY form_id (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD -----------------------------------------------
$lead_table_name = RGFormsModel::get_lead_table_name();
$sql = 'CREATE TABLE ' . $lead_table_name . " (\n id int(10) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null,\n post_id bigint(20) unsigned,\n date_created datetime not null,\n is_starred tinyint(1) not null default 0,\n is_read tinyint(1) not null default 0,\n ip varchar(39) not null,\n source_url varchar(200) not null default '',\n user_agent varchar(250) not null default '',\n currency varchar(5),\n payment_status varchar(15),\n payment_date datetime,\n payment_amount decimal(19,2),\n payment_method varchar(30),\n transaction_id varchar(50),\n is_fulfilled tinyint(1),\n created_by bigint(20) unsigned,\n transaction_type tinyint(1),\n status varchar(20) not null default 'active',\n PRIMARY KEY (id),\n KEY form_id (form_id),\n KEY status (status)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD NOTES ------------------------------------------
$lead_notes_table_name = RGFormsModel::get_lead_notes_table_name();
$sql = 'CREATE TABLE ' . $lead_notes_table_name . " (\n id int(10) unsigned not null auto_increment,\n lead_id int(10) unsigned not null,\n user_name varchar(250),\n user_id bigint(20),\n date_created datetime not null,\n value longtext,\n note_type varchar(50),\n PRIMARY KEY (id),\n KEY lead_id (lead_id),\n KEY lead_user_key (lead_id,user_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL -----------------------------------------
$lead_detail_table_name = RGFormsModel::get_lead_details_table_name();
$sql = 'CREATE TABLE ' . $lead_detail_table_name . ' (
id bigint(20) unsigned not null auto_increment,
lead_id int(10) unsigned not null,
form_id mediumint(8) unsigned not null,
field_number float not null,
value varchar(' . GFORMS_MAX_FIELD_LENGTH . "),\n PRIMARY KEY (id),\n KEY form_id (form_id),\n KEY lead_id (lead_id),\n KEY lead_field_number (lead_id,field_number)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL LONG -----------------------------------
$lead_detail_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$sql = 'CREATE TABLE ' . $lead_detail_long_table_name . " (\n lead_detail_id bigint(20) unsigned not null,\n value longtext,\n PRIMARY KEY (lead_detail_id)\n ) {$charset_collate};";
dbDelta($sql);
// dropping outdated form_id index (if one exists)
self::drop_index($lead_detail_long_table_name, 'lead_detail_key');
//------ LEAD META ------------------------------------------
$lead_meta_table_name = RGFormsModel::get_lead_meta_table_name();
// dropping meta_key and form_id_meta_key (if they exist) to prevent duplicate keys error on upgrade
if (version_compare(get_option('rg_form_version'), '1.9.8.12', '<')) {
self::drop_index($lead_meta_table_name, 'meta_key');
self::drop_index($lead_meta_table_name, 'form_id_meta_key');
}
$sql = 'CREATE TABLE ' . $lead_meta_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null default 0,\n lead_id bigint(20) unsigned not null,\n meta_key varchar(255),\n meta_value longtext,\n PRIMARY KEY (id),\n KEY meta_key (meta_key({$max_index_length})),\n KEY lead_id (lead_id),\n KEY form_id_meta_key (form_id,meta_key({$max_index_length}))\n ) {$charset_collate};";
dbDelta($sql);
//------ INCOMPLETE SUBMISSIONS -------------------------------
$incomplete_submissions_table_name = RGFormsModel::get_incomplete_submissions_table_name();
$sql = 'CREATE TABLE ' . $incomplete_submissions_table_name . " (\n uuid char(32) not null,\n email varchar(255),\n form_id mediumint(8) unsigned not null,\n date_created datetime not null,\n ip varchar(39) not null,\n source_url longtext not null,\n submission longtext not null,\n PRIMARY KEY (uuid),\n KEY form_id (form_id)\n ) {$charset_collate};";
dbDelta($sql);
remove_filter('dbdelta_create_queries', array('RGForms', 'dbdelta_fix_case'));
//fix form_id value needed to update from version 1.6.11
self::fix_lead_meta_form_id_values();
//fix checkbox value. needed for version 1.0 and below but won't hurt for higher versions
self::fix_checkbox_value();
//fix leading and trailing spaces in Form objects and entry values
if (version_compare(get_option('rg_form_version'), '1.8.3.1', '<')) {
self::fix_leading_and_trailing_spaces();
}
}
示例3: RGFormsModel
/**
*
* @global type $wpdb
* @param type $lead_detail_id
* @param type $value
*/
function insert_lead_detail_long($lead_detail_id, $value)
{
global $wpdb;
$f = new RGFormsModel();
$lead_detail_long = $f->get_lead_details_long_table_name();
$query = $wpdb->prepare("INSERT INTO {$lead_detail_long}(lead_detail_id, value) VALUES(%d, %s)", $lead_detail_id, $value);
$wpdb->query($query);
}
示例4: setup_database
public static function setup_database()
{
global $wpdb;
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
//Fixes issue with dbDelta lower-casing table names, which cause problems on case sensitive DB servers.
add_filter('dbdelta_create_queries', array("RGForms", "dbdelta_fix_case"));
//------ FORM -----------------------------------------------
$form_table_name = RGFormsModel::get_form_table_name();
$sql = "CREATE TABLE " . $form_table_name . " (\n id mediumint(8) unsigned not null auto_increment,\n title varchar(150) not null,\n date_created datetime not null,\n is_active tinyint(1) not null default 1,\n is_trash tinyint(1) not null default 0,\n PRIMARY KEY (id)\n ) {$charset_collate};";
dbDelta($sql);
//droping table that was created by mistake in version 1.6.3.2
$wpdb->query("DROP TABLE IF EXISTS A" . $form_table_name);
//------ META -----------------------------------------------
$meta_table_name = RGFormsModel::get_meta_table_name();
$sql = "CREATE TABLE " . $meta_table_name . " (\n form_id mediumint(8) unsigned not null,\n display_meta longtext,\n entries_grid_meta longtext,\n confirmations longtext,\n notifications longtext,\n PRIMARY KEY (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($meta_table_name, 'form_id');
//------ FORM VIEW -----------------------------------------------
$form_view_table_name = RGFormsModel::get_form_view_table_name();
$sql = "CREATE TABLE " . $form_view_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null,\n date_created datetime not null,\n ip char(15),\n count mediumint(8) unsigned not null default 1,\n PRIMARY KEY (id),\n KEY form_id (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD -----------------------------------------------
$lead_table_name = RGFormsModel::get_lead_table_name();
$sql = "CREATE TABLE " . $lead_table_name . " (\n id int(10) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null,\n post_id bigint(20) unsigned,\n date_created datetime not null,\n is_starred tinyint(1) not null default 0,\n is_read tinyint(1) not null default 0,\n ip varchar(39) not null,\n source_url varchar(200) not null default '',\n user_agent varchar(250) not null default '',\n currency varchar(5),\n payment_status varchar(15),\n payment_date datetime,\n payment_amount decimal(19,2),\n payment_method varchar(30),\n transaction_id varchar(50),\n is_fulfilled tinyint(1),\n created_by bigint(20) unsigned,\n transaction_type tinyint(1),\n status varchar(20) not null default 'active',\n PRIMARY KEY (id),\n KEY form_id (form_id),\n KEY status (status)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD NOTES ------------------------------------------
$lead_notes_table_name = RGFormsModel::get_lead_notes_table_name();
$sql = "CREATE TABLE " . $lead_notes_table_name . " (\n id int(10) unsigned not null auto_increment,\n lead_id int(10) unsigned not null,\n user_name varchar(250),\n user_id bigint(20),\n date_created datetime not null,\n value longtext,\n PRIMARY KEY (id),\n KEY lead_id (lead_id),\n KEY lead_user_key (lead_id,user_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL -----------------------------------------
$lead_detail_table_name = RGFormsModel::get_lead_details_table_name();
$sql = "CREATE TABLE " . $lead_detail_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n lead_id int(10) unsigned not null,\n form_id mediumint(8) unsigned not null,\n field_number float not null,\n value varchar(" . GFORMS_MAX_FIELD_LENGTH . "),\n PRIMARY KEY (id),\n KEY form_id (form_id),\n KEY lead_id (lead_id),\n KEY lead_field_number (lead_id,field_number)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL LONG -----------------------------------
$lead_detail_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$sql = "CREATE TABLE " . $lead_detail_long_table_name . " (\n lead_detail_id bigint(20) unsigned not null,\n value longtext,\n PRIMARY KEY (lead_detail_id)\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($lead_detail_long_table_name, 'lead_detail_key');
//------ LEAD META -----------------------------------
$lead_meta_table_name = RGFormsModel::get_lead_meta_table_name();
$sql = "CREATE TABLE " . $lead_meta_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null default 0,\n lead_id bigint(20) unsigned not null,\n meta_key varchar(255),\n meta_value longtext,\n PRIMARY KEY (id),\n KEY meta_key (meta_key),\n KEY lead_id (lead_id),\n KEY form_id_meta_key (form_id,meta_key)\n ) {$charset_collate};";
dbDelta($sql);
remove_filter('dbdelta_create_queries', array("RGForms", "dbdelta_fix_case"));
//fix form_id value needed to update from version 1.6.11
self::fix_lead_meta_form_id_values();
//fix checkbox value. needed for version 1.0 and below but won't hurt for higher versions
self::fix_checkbox_value();
//fix leading and trailing spaces in Form objects and entry values from versions prior to 1.8.2
if (version_compare(get_option("rg_form_version"), "1.8.2", "<=")) {
//uncomment to test
//self::fix_leading_and_trailing_spaces();
}
}
示例5: detachFormEntry
public function detachFormEntry($lead_id)
{
$entries = $this->getFormEntryIds();
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Start to detach gravity forms: " . print_r($entries, true));
if (in_array($lead_id, $entries)) {
Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Lead id is in the list of entries: " . $lead_id);
if (class_exists('RGForms')) {
if (!class_exists('RGFormsModel')) {
RGForms::init();
}
if (class_exists('RGFormsModel')) {
global $wpdb;
$lead_table = RGFormsModel::get_lead_table_name();
$lead_notes_table = RGFormsModel::get_lead_notes_table_name();
$lead_detail_table = RGFormsModel::get_lead_details_table_name();
$lead_detail_long_table = RGFormsModel::get_lead_details_long_table_name();
//Delete from detail long
$sql = $wpdb->prepare(" DELETE FROM {$lead_detail_long_table}\n WHERE lead_detail_id IN(\n SELECT id FROM {$lead_detail_table} WHERE lead_id=%d\n )", $lead_id);
$wpdb->query($sql);
//Delete from lead details
$sql = $wpdb->prepare("DELETE FROM {$lead_detail_table} WHERE lead_id=%d", $lead_id);
$wpdb->query($sql);
//Delete from lead notes
$sql = $wpdb->prepare("DELETE FROM {$lead_notes_table} WHERE lead_id=%d", $lead_id);
$wpdb->query($sql);
//Delete from lead
$sql = $wpdb->prepare("DELETE FROM {$lead_table} WHERE id=%d", $lead_id);
$wpdb->query($sql);
// Remove entry from array
$entries = array_values(array_diff($entries, array($lead_id)));
$this->_formEntryIds = $entries;
$qty = $this->getQuantity();
$this->setQuantity($qty - 1);
}
}
}
}
示例6: get_lead_detail_long_value
/**
* get_lead_detail_long_value
*
* Helper to get the 'long value' for a specific entry field
*
* @param int $lead_id Entry ID
* @param int $field_id Field ID
* @return string $results Value from 'long value' gforms table
* @access public
* @author Ben Moody
*/
private function get_lead_detail_long_value($lead_id = NULL, $field_id = NULL)
{
//Init vars
global $wpdb;
$lead_detail_id = NULL;
$results = NULL;
if (isset($lead_id, $field_id)) {
$lead_details_table_name = RGFormsModel::get_lead_details_table_name();
$lead_details_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$lead_detail_id = $wpdb->get_results("SELECT lead_detail_id FROM {$lead_details_table_name} d\n\t \t INNER JOIN {$lead_details_long_table_name} l ON d.id = l.lead_detail_id\n\t \t WHERE lead_id = {$lead_id} AND field_number = {$field_id}");
if (isset($lead_detail_id[0]->lead_detail_id)) {
$lead_detail_id = $lead_detail_id[0]->lead_detail_id;
$results = $wpdb->get_results("SELECT {$lead_details_long_table_name}.value FROM {$lead_details_long_table_name}\n\t\t \t WHERE lead_detail_id = {$lead_detail_id}");
}
if (isset($results[0]->value)) {
$results = maybe_unserialize($results[0]->value);
}
}
return $results;
}
示例7: setup_site
public static function setup_site($blog_id = null)
{
if (empty($blog_id)) {
$blog_id = get_current_blog_id();
}
//if a blog id is specified, switch to it
if (MULTISITE && !switch_to_blog($blog_id)) {
return;
}
global $wpdb;
$error = "";
if (!self::has_database_permission($error)) {
?>
<div class='error' style="padding:15px;"><?php
echo $error;
?>
</div>
<?php
}
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
//Fixes issue with dbDelta lower-casing table names, which cause problems on case sensitive DB servers.
add_filter('dbdelta_create_queries', array("RGForms", "dbdelta_fix_case"));
//------ FORM -----------------------------------------------
$form_table_name = RGFormsModel::get_form_table_name();
$sql = "CREATE TABLE " . $form_table_name . " (\n\n id mediumint(8) unsigned not null auto_increment,\n\n title varchar(150) not null,\n\n date_created datetime not null,\n\n is_active tinyint(1) not null default 1,\n\n PRIMARY KEY (id)\n\n ) {$charset_collate};";
dbDelta($sql);
//droping table that was created by mistake in version 1.6.3.2
$wpdb->query("DROP TABLE IF EXISTS A" . $form_table_name);
//------ META -----------------------------------------------
$meta_table_name = RGFormsModel::get_meta_table_name();
$sql = "CREATE TABLE " . $meta_table_name . " (\n\n form_id mediumint(8) unsigned not null,\n\n display_meta longtext,\n\n entries_grid_meta longtext,\n\n confirmations longtext,\n\n notifications longtext,\n\n PRIMARY KEY (form_id)\n\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($meta_table_name, 'form_id');
//------ FORM VIEW -----------------------------------------------
$form_view_table_name = RGFormsModel::get_form_view_table_name();
$sql = "CREATE TABLE " . $form_view_table_name . " (\n\n id bigint(20) unsigned not null auto_increment,\n\n form_id mediumint(8) unsigned not null,\n\n date_created datetime not null,\n\n ip char(15),\n\n count mediumint(8) unsigned not null default 1,\n\n PRIMARY KEY (id),\n\n KEY form_id (form_id)\n\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD -----------------------------------------------
$lead_table_name = RGFormsModel::get_lead_table_name();
$sql = "CREATE TABLE " . $lead_table_name . " (\n\n id int(10) unsigned not null auto_increment,\n\n form_id mediumint(8) unsigned not null,\n\n post_id bigint(20) unsigned,\n\n date_created datetime not null,\n\n is_starred tinyint(1) not null default 0,\n\n is_read tinyint(1) not null default 0,\n\n ip varchar(39) not null,\n\n source_url varchar(200) not null default '',\n\n user_agent varchar(250) not null default '',\n\n currency varchar(5),\n\n payment_status varchar(15),\n\n payment_date datetime,\n\n payment_amount decimal(19,2),\n\n transaction_id varchar(50),\n\n is_fulfilled tinyint(1),\n\n created_by bigint(20) unsigned,\n\n transaction_type tinyint(1),\n\n status varchar(20) not null default 'active',\n\n PRIMARY KEY (id),\n\n KEY form_id (form_id),\n\n KEY status (status)\n\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD NOTES ------------------------------------------
$lead_notes_table_name = RGFormsModel::get_lead_notes_table_name();
$sql = "CREATE TABLE " . $lead_notes_table_name . " (\n\n id int(10) unsigned not null auto_increment,\n\n lead_id int(10) unsigned not null,\n\n user_name varchar(250),\n\n user_id bigint(20),\n\n date_created datetime not null,\n\n value longtext,\n\n PRIMARY KEY (id),\n\n KEY lead_id (lead_id),\n\n KEY lead_user_key (lead_id,user_id)\n\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL -----------------------------------------
$lead_detail_table_name = RGFormsModel::get_lead_details_table_name();
$sql = "CREATE TABLE " . $lead_detail_table_name . " (\n\n id bigint(20) unsigned not null auto_increment,\n\n lead_id int(10) unsigned not null,\n\n form_id mediumint(8) unsigned not null,\n\n field_number float not null,\n\n value varchar(" . GFORMS_MAX_FIELD_LENGTH . "),\n\n PRIMARY KEY (id),\n\n KEY form_id (form_id),\n\n KEY lead_id (lead_id),\n\n KEY lead_field_number (lead_id,field_number)\n\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL LONG -----------------------------------
$lead_detail_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$sql = "CREATE TABLE " . $lead_detail_long_table_name . " (\n\n lead_detail_id bigint(20) unsigned not null,\n\n value longtext,\n\n PRIMARY KEY (lead_detail_id)\n\n ) {$charset_collate};";
dbDelta($sql);
//droping outdated form_id index (if one exists)
self::drop_index($lead_detail_long_table_name, 'lead_detail_key');
//------ LEAD META -----------------------------------
$lead_meta_table_name = RGFormsModel::get_lead_meta_table_name();
$sql = "CREATE TABLE " . $lead_meta_table_name . " (\n\n id bigint(20) unsigned not null auto_increment,\n\n form_id mediumint(8) unsigned not null default 0,\n\n lead_id bigint(20) unsigned not null,\n\n meta_key varchar(255),\n\n meta_value longtext,\n\n PRIMARY KEY (id),\n\n KEY meta_key (meta_key),\n\n KEY lead_id (lead_id),\n\n KEY form_id_meta_key (form_id,meta_key)\n\n ) {$charset_collate};";
dbDelta($sql);
remove_filter('dbdelta_create_queries', array("RGForms", "dbdelta_fix_case"));
//fix form_id value needed to update from version 1.6.11
self::fix_lead_meta_form_id_values();
//fix checkbox value. needed for version 1.0 and below but won't hurt for higher versions
self::fix_checkbox_value();
//auto-setting license key based on value configured via the GF_LICENSE_KEY constant or the gf_license_key variable
global $gf_license_key;
$license_key = defined("GF_LICENSE_KEY") && empty($gf_license_key) ? GF_LICENSE_KEY : $gf_license_key;
if (!empty($license_key)) {
update_option("rg_gforms_key", md5($license_key));
}
//auto-setting recaptcha keys based on value configured via the constant or global variable
global $gf_recaptcha_public_key, $gf_recaptcha_private_key;
$private_key = defined("GF_RECAPTCHA_PRIVATE_KEY") && empty($gf_recaptcha_private_key) ? GF_RECAPTCHA_PRIVATE_KEY : $gf_recaptcha_private_key;
if (!empty($private_key)) {
update_option("rg_gforms_captcha_private_key", $private_key);
}
$public_key = defined("GF_RECAPTCHA_PUBLIC_KEY") && empty($gf_recaptcha_public_key) ? GF_RECAPTCHA_PUBLIC_KEY : $gf_recaptcha_public_key;
if (!empty($public_key)) {
update_option("rg_gforms_captcha_public_key", $public_key);
}
//Auto-importing forms based on GF_IMPORT_FILE AND GF_THEME_IMPORT_FILE
if (defined("GF_IMPORT_FILE") && !get_option("gf_imported_file")) {
GFExport::import_file(GF_IMPORT_FILE);
update_option("gf_imported_file", true);
}
//adds empty index.php files to upload folders. only for v1.5.2 and below
if (version_compare(get_option("rg_form_version"), "1.6", "<")) {
self::add_empty_index_files();
}
update_option("rg_form_version", GFCommon::$version);
//going back to current blog
//.........这里部分代码省略.........
示例8: gform_post_submission
public function gform_post_submission($entry, $form)
{
global $wpdb;
$this->options['entries'] = apply_filters($this->name . '_entries', $this->options['entries'], $form);
if (!$this->options['entries'] || $this->is_delete()) {
$tables = (object) array('lead_table' => RGFormsModel::get_lead_table_name(), 'lead_notes_table' => RGFormsModel::get_lead_notes_table_name(), 'lead_detail_table' => RGFormsModel::get_lead_details_table_name(), 'lead_detail_long_table' => RGFormsModel::get_lead_details_long_table_name());
$queries = array($wpdb->prepare("DELETE FROM {$tables->lead_detail_long_table} WHERE lead_detail_id IN (SELECT id FROM {$tables->lead_detail_table} WHERE lead_id = %d)", $entry['id']), $wpdb->prepare("DELETE FROM {$tables->lead_detail_table} WHERE lead_id = %d", $entry['id']), $wpdb->prepare("DELETE FROM {$tables->lead_notes_table} WHERE lead_id = %d", $entry['id']), $wpdb->prepare("DELETE FROM {$tables->lead_table} WHERE id = %d", $entry['id']));
foreach ($queries as $query) {
$wpdb->query($query);
}
}
if ($this->is_delete()) {
wp_delete_post($this->post['ID']);
}
// If a custom field is unique, get all the rows and combine them into one
foreach ($form['fields'] as $field) {
if ($field['type'] == 'post_custom_field' && isset($field['postCustomFieldUnique'])) {
$meta = get_post_meta($this->post['ID'], $field['postCustomFieldName']);
delete_post_meta($this->post['ID'], $field['postCustomFieldName']);
add_post_meta($this->post['ID'], $field['postCustomFieldName'], is_array($meta) && count($meta) == 1 ? $meta[0] : $meta, true);
}
}
}
示例9: update_gforms_entry_meta
/**
* update_gforms_entry_meta
*
* Updates form entry data to show api video uploads in entries view
*
* @access private
* @author Ben Moody
*/
private function update_gforms_entry_meta($field_values = array())
{
//Init vars
global $wpdb;
$lead_details_table_name = NULL;
$lead_details_long_table_name = NULL;
$entry_id = NULL;
$results = NULL;
if (!empty($field_values) && isset($this->data['gforms_entry']['id'])) {
//Cache entry data provided from gravity forms
$entry_id = $this->data['gforms_entry']['id'];
//Allow devs to hook before we get the gravity form table names ect
do_action('prso_gform_youtube_uploader_pre_update_meta', $field_values, $this->data);
//Get gravity forms table names
$lead_details_table_name = RGFormsModel::get_lead_details_table_name();
$lead_details_long_table_name = RGFormsModel::get_lead_details_long_table_name();
//Loop the array of field values and update the gravity forms meta for each field
foreach ($field_values as $field_id => $value) {
//Get the lead detail id required to find the our value in gforms meta table
$results = $wpdb->get_results("SELECT lead_detail_id FROM {$lead_details_table_name} d\n\t\t \t INNER JOIN {$lead_details_long_table_name} l ON d.id = l.lead_detail_id\n\t\t \t WHERE lead_id = {$entry_id} AND field_number = {$field_id}");
//Update the gforms meta values with our new data including the video api data
if (isset($results[0]->lead_detail_id)) {
//Update upload details
//Serialize array
$value = maybe_serialize($value);
//As gforms only looks at details long table if value maxs out the std table
//Update std table before long table - value will be truncated by mysql
//No probs as it will be stored ok in long table next
$wpdb->query($wpdb->prepare("UPDATE {$lead_details_table_name} SET value = %s \n\t\t\t \t\t WHERE id = %d", $value, $results[0]->lead_detail_id));
$wpdb->query($wpdb->prepare("UPDATE {$lead_details_long_table_name} SET value = %s \n\t\t\t \t\t WHERE lead_detail_id = %d", $value, $results[0]->lead_detail_id));
}
}
}
}
开发者ID:QuackenbushDev,项目名称:prso-gravity-forms-adv-uploader,代码行数:42,代码来源:class.prso-adv-s3-uploader.php
示例10: process_attachments
function process_attachments($entry, $form)
{
$upload_field_ids = array();
foreach ($form['fields'] as $form_field) {
if ($form_field->type == 'fileupload') {
array_push($upload_field_ids, $form_field->id);
}
}
//loop through upload field IDS and push contents to S3
foreach ($upload_field_ids as $upload_field_id) {
if (!empty($entry[$upload_field_id])) {
// Grab the field value
$field_value = $entry[$upload_field_id];
// If multi-uplaod is enabled for the field, the value will be a JSON string.
// Decode it so we can test if it's an array
$field_value_decoded = json_decode($field_value);
// If we have an aray, loop through it and upload each file
// Else, just uplaod the one file.
if (is_array($field_value_decoded)) {
// empty array to store new urls
$new_file_url = array();
foreach ($field_value_decoded as $attachment_url) {
//push file to S3 and return new url
$multi_file_item_url = upload_to_s3($attachment_url, $form['id']);
//push new url in the new url array
array_push($new_file_url, $multi_file_item_url);
}
//json encode the new url before updating DB
$new_file_url = json_encode($new_file_url);
} else {
$new_file_url = upload_to_s3($field_value, $form['id']);
}
//gform_update_meta( $entry['id'], 'api_response', $new_file_url );
global $wpdb;
$lead_detail_table = RGFormsModel::get_lead_details_table_name();
if (is_array($field_value_decoded)) {
$entry_detail_row = $wpdb->get_row("SELECT * FROM {$lead_detail_table} WHERE field_number = {$upload_field_id} AND lead_id = {$entry['id']} AND form_id = {$entry['form_id']}", ARRAY_A);
$entry_detail_id = $entry_detail_row["id"];
$lead_detail_long_table = RGFormsModel::get_lead_details_long_table_name();
$wpdb->update($lead_detail_long_table, array('value' => $new_file_url), array('lead_detail_id' => $entry_detail_id));
} else {
$wpdb->update($lead_detail_table, array('value' => $new_file_url), array('field_number' => $upload_field_id, 'lead_id' => $entry['id'], 'form_id' => $entry['form_id']));
}
}
}
}
示例11: setup
public static function setup()
{
global $wpdb;
$version = GFCommon::$version;
if (get_option("rg_form_version") != $version) {
require_once ABSPATH . '/wp-admin/includes/upgrade.php';
if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}";
}
if (!empty($wpdb->collate)) {
$charset_collate .= " COLLATE {$wpdb->collate}";
}
//------ FORM -----------------------------------------------
$form_table_name = RGFormsModel::get_form_table_name();
$sql = "CREATE TABLE " . $form_table_name . " (\n id mediumint(8) unsigned not null auto_increment,\n title varchar(150) not null,\n date_created datetime not null,\n is_active tinyint(1) not null default 1,\n PRIMARY KEY (id)\n ) {$charset_collate};";
dbDelta($sql);
//------ META -----------------------------------------------
$meta_table_name = RGFormsModel::get_meta_table_name();
$sql = "CREATE TABLE " . $meta_table_name . " (\n form_id mediumint(8) unsigned not null,\n display_meta longtext,\n entries_grid_meta longtext,\n KEY form_id (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ FORM VIEW -----------------------------------------------
$form_view_table_name = RGFormsModel::get_form_view_table_name();
$sql = "CREATE TABLE " . $form_view_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null,\n date_created datetime not null,\n ip char(15),\n count mediumint(8) unsigned not null default 1,\n PRIMARY KEY (id),\n KEY form_id (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD -----------------------------------------------
$lead_table_name = RGFormsModel::get_lead_table_name();
$sql = "CREATE TABLE " . $lead_table_name . " (\n id int(10) unsigned not null auto_increment,\n form_id mediumint(8) unsigned not null,\n post_id bigint(20) unsigned,\n date_created datetime not null,\n is_starred tinyint(1) not null default 0,\n is_read tinyint(1) not null default 0,\n ip char(15) not null,\n source_url varchar(200) not null default '',\n user_agent varchar(250) not null default '',\n PRIMARY KEY (id),\n KEY form_id (form_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD NOTES ------------------------------------------
$lead_notes_table_name = RGFormsModel::get_lead_notes_table_name();
$sql = "CREATE TABLE " . $lead_notes_table_name . " (\n id int(10) unsigned not null auto_increment,\n lead_id int(10) unsigned not null,\n user_name varchar(250),\n user_id bigint(20),\n date_created datetime not null,\n value longtext,\n PRIMARY KEY (id),\n KEY lead_id (lead_id),\n KEY lead_user_key (lead_id,user_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL -----------------------------------------
$lead_detail_table_name = RGFormsModel::get_lead_details_table_name();
$sql = "CREATE TABLE " . $lead_detail_table_name . " (\n id bigint(20) unsigned not null auto_increment,\n lead_id int(10) unsigned not null,\n form_id mediumint(8) unsigned not null,\n field_number float not null,\n value varchar(" . GFORMS_MAX_FIELD_LENGTH . "),\n PRIMARY KEY (id),\n KEY form_id (form_id),\n KEY lead_id (lead_id)\n ) {$charset_collate};";
dbDelta($sql);
//------ LEAD DETAIL LONG -----------------------------------
$lead_detail_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$sql = "CREATE TABLE " . $lead_detail_long_table_name . " (\n lead_detail_id bigint(20) unsigned not null,\n value longtext,\n KEY lead_detail_key (lead_detail_id)\n ) {$charset_collate};";
dbDelta($sql);
//fix checkbox value. needed for version 1.0 and below but won't hurt for higher versions
self::fix_checkbox_value();
}
update_option("rg_form_version", $version);
}
示例12: spgfle_gform_entry_id_pre_save_lead
/**
* Setup the current lead_id to update the entry
* instead of creating a new one
*/
function spgfle_gform_entry_id_pre_save_lead($entry_id, $form)
{
if (intval($entry_id) > 0) {
return $entry_id;
}
if (!$form['spgfle_enableedit']) {
return $entry_id;
}
$entry_id = (int) $_POST['gform_lead_id'];
$lead = RGFormsModel::get_lead($entry_id);
if (GFCommon::current_user_can_any('gravityforms_edit_entries') || $lead['created_by'] == wp_get_current_user()->ID) {
/**
* In case that GF only stores data for fields that are set
* we have to delete the old entry data
*/
global $wpdb;
$lead_details_table_name = RGFormsModel::get_lead_details_table_name();
$lead_details_long_table_name = RGFormsModel::get_lead_details_long_table_name();
$wpdb->query($wpdb->prepare("DELETE FROM {$lead_details_table_name} WHERE lead_id = %d", $entry_id));
//$wpdb->query( $wpdb->prepare( "DELETE FROM {$lead_details_long_table_name} WHERE lead_id = %d", $entry_id ) );
return $entry_id;
}
}
示例13: ovr_delete_gf_entry
/**
* Delete Gravity Forms entry specified
* @global object $wpdb
*@param string $lead_id, id of gravity form entry to remove
*/
function ovr_delete_gf_entry($lead_id)
{
global $wpdb;
// Prepare variables.
$lead_table = RGFormsModel::get_lead_table_name();
$lead_notes_table = RGFormsModel::get_lead_notes_table_name();
$lead_detail_table = RGFormsModel::get_lead_details_table_name();
$lead_detail_long_table = RGFormsModel::get_lead_details_long_table_name();
// Delete from lead detail long.
$sql = $wpdb->prepare("DELETE FROM {$lead_detail_long_table} WHERE lead_detail_id IN(SELECT id FROM {$lead_detail_table} WHERE lead_id = %d)", $lead_id);
$wpdb->query($sql);
// Delete from lead details.
$sql = $wpdb->prepare("DELETE FROM {$lead_detail_table} WHERE lead_id = %d", $lead_id);
$wpdb->query($sql);
// Delete from lead notes.
$sql = $wpdb->prepare("DELETE FROM {$lead_notes_table} WHERE lead_id = %d", $lead_id);
$wpdb->query($sql);
// Delete from lead.
$sql = $wpdb->prepare("DELETE FROM {$lead_table} WHERE id = %d", $lead_id);
$wpdb->query($sql);
// Finally, ensure everything is deleted (like stuff from Addons).
GFAPI::delete_entry($lead_id);
}