本文整理汇总了PHP中RGFormsModel::update_form_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::update_form_meta方法的具体用法?PHP RGFormsModel::update_form_meta怎么用?PHP RGFormsModel::update_form_meta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RGFormsModel
的用法示例。
在下文中一共展示了RGFormsModel::update_form_meta方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_form_info
/**
* Saves form meta. Note the special requirements for the meta string.
*
* @param $id
* @param string $form_json A valid JSON string. The JSON is manipulated before decoding and is designed to work together with jQuery.toJSON() rather than json_encode. Avoid using json_encode as it will convert unicode characters into their respective entities with slashes. These slashes get stripped so unicode characters won't survive intact.
*
* @return array
*/
public static function save_form_info($id, $form_json)
{
global $wpdb;
$form_json = stripslashes($form_json);
$form_json = nl2br($form_json);
GFCommon::log_debug('GFFormDetail::save_form_info(): Form meta json: ' . $form_json);
$form_meta = json_decode($form_json, true);
$form_meta = GFFormsModel::convert_field_objects($form_meta);
GFCommon::log_debug('GFFormDetail::save_form_info(): Form meta => ' . print_r($form_meta, true));
if (!$form_meta) {
return array('status' => 'invalid_json', 'meta' => null);
}
$form_table_name = $wpdb->prefix . 'rg_form';
//Making sure title is not duplicate
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower($form_meta['title']) && rgar($form_meta, 'id') != $form->id) {
return array('status' => 'duplicate_title', 'meta' => $form_meta);
}
}
if ($id > 0) {
$form_meta = GFFormsModel::trim_form_meta_values($form_meta);
RGFormsModel::update_form_meta($id, $form_meta);
//updating form title
$wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta['title'], $form_meta['id']));
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, false);
return array('status' => $id, 'meta' => $form_meta);
} else {
//inserting form
$id = RGFormsModel::insert_form($form_meta['title']);
//updating object's id property
$form_meta['id'] = $id;
//creating default notification
if (apply_filters('gform_default_notification', true)) {
$default_notification = array('id' => uniqid(), 'to' => '{admin_email}', 'name' => __('Admin Notification', 'gravityforms'), 'event' => 'form_submission', 'toType' => 'email', 'subject' => __('New submission from', 'gravityforms') . ' {form_title}', 'message' => '{all_fields}');
$notifications = array($default_notification['id'] => $default_notification);
//updating notifications form meta
RGFormsModel::save_form_notifications($id, $notifications);
}
// add default confirmation when saving a new form
$confirmation_id = uniqid();
$confirmations = array();
$confirmations[$confirmation_id] = array('id' => $confirmation_id, 'name' => __('Default Confirmation', 'gravityforms'), 'isDefault' => true, 'type' => 'message', 'message' => __('Thanks for contacting us! We will get in touch with you shortly.', 'gravityforms'), 'url' => '', 'pageId' => '', 'queryString' => '');
GFFormsModel::save_form_confirmations($id, $confirmations);
//updating form meta
RGFormsModel::update_form_meta($id, $form_meta);
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, true);
return array('status' => $id * -1, 'meta' => $form_meta);
}
}
示例2: import_file
public static function import_file($filepath)
{
$xmlstr = file_get_contents($filepath);
require_once "xml.php";
$options = array("page" => array("unserialize_as_array" => true), "form" => array("unserialize_as_array" => true), "field" => array("unserialize_as_array" => true), "rule" => array("unserialize_as_array" => true), "choice" => array("unserialize_as_array" => true), "input" => array("unserialize_as_array" => true), "routing_item" => array("unserialize_as_array" => true), "routin" => array("unserialize_as_array" => true));
$xml = new RGXML($options);
$forms = $xml->unserialize($xmlstr);
if (!$forms) {
return 0;
} else {
if (version_compare($forms["version"], self::$min_import_version, "<")) {
return -1;
}
}
//Error. XML version is not compatible with current Gravity Forms version
//cleaning up generated object
self::cleanup($forms);
foreach ($forms as $key => $form) {
$title = $form["title"];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form["title"] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form["title"] = $title;
$form["id"] = $form_id;
RGFormsModel::update_form_meta($form_id, $form);
}
return sizeof($forms);
}
示例3: import_xml
public static function import_xml($xmlstr, &$forms = null)
{
require_once 'xml.php';
$options = array('page' => array('unserialize_as_array' => true), 'form' => array('unserialize_as_array' => true), 'field' => array('unserialize_as_array' => true), 'rule' => array('unserialize_as_array' => true), 'choice' => array('unserialize_as_array' => true), 'input' => array('unserialize_as_array' => true), 'routing_item' => array('unserialize_as_array' => true), 'creditCard' => array('unserialize_as_array' => true), 'routin' => array('unserialize_as_array' => true), 'confirmation' => array('unserialize_as_array' => true), 'notification' => array('unserialize_as_array' => true));
$options = apply_filters('gform_import_form_xml_options', $options);
$xml = new RGXML($options);
$forms = $xml->unserialize($xmlstr);
if (!$forms) {
return 0;
} else {
if (version_compare($forms['version'], self::$min_import_version, '<')) {
return -1;
}
}
//Error. XML version is not compatible with current Gravity Forms version
//cleaning up generated object
self::cleanup($forms);
foreach ($forms as $key => &$form) {
$title = $form['title'];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form['title'] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form['title'] = $title;
$form['id'] = $form_id;
$form = GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = self::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = self::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
return sizeof($forms);
}
示例4: save_form_info
/**
* Saves form meta. Note the special requirements for the meta string.
*
* @param $id
* @param string $form_json A valid JSON string. The JSON is manipulated before decoding and is designed to work together with jQuery.toJSON() rather than json_encode. Avoid using json_encode as it will convert unicode characters into their respective entities with slashes. These slashes get stripped so unicode characters won't survive intact.
*
* @return array
*/
public static function save_form_info($id, $form_json)
{
global $wpdb;
$form_json = stripslashes($form_json);
$form_json = nl2br($form_json);
GFCommon::log_debug("form meta json:" . $form_json);
$form_meta = json_decode($form_json, true);
GFCommon::log_debug("form meta:");
GFCommon::log_debug(print_r($form_json, true));
if (!$form_meta) {
return array("status" => "invalid_json", "meta" => null);
}
$form_table_name = $wpdb->prefix . "rg_form";
//Making sure title is not duplicate
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower($form_meta["title"]) && rgar($form_meta, "id") != $form->id) {
return array("status" => "duplicate_title", "meta" => $form_meta);
}
}
if ($id > 0) {
$form_meta = GFFormsModel::trim_form_meta_values($form_meta);
RGFormsModel::update_form_meta($id, $form_meta);
//updating form title
$wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta["title"], $form_meta["id"]));
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, false);
return array("status" => $id, "meta" => $form_meta);
} else {
//inserting form
$id = RGFormsModel::insert_form($form_meta["title"]);
//updating object's id property
$form_meta["id"] = $id;
//creating default notification
if (apply_filters('gform_default_notification', true)) {
$default_notification = array("id" => uniqid(), "to" => "{admin_email}", "name" => __("Admin Notification", "gravityforms"), "event" => "form_submission", "toType" => "email", "subject" => __("New submission from", "gravityforms") . " {form_title}", "message" => "{all_fields}");
$notifications = array($default_notification["id"] => $default_notification);
//updating notifications form meta
RGFormsModel::save_form_notifications($id, $notifications);
}
// add default confirmation when saving a new form
$confirmation_id = uniqid();
$confirmations = array();
$confirmations[$confirmation_id] = array('id' => $confirmation_id, 'name' => __('Default Confirmation', 'gravityforms'), 'isDefault' => true, 'type' => 'message', 'message' => __("Thanks for contacting us! We will get in touch with you shortly.", "gravityforms"), 'url' => '', 'pageId' => '', 'queryString' => '');
GFFormsModel::save_form_confirmations($id, $confirmations);
//updating form meta
RGFormsModel::update_form_meta($id, $form_meta);
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, true);
return array("status" => $id * -1, "meta" => $form_meta);
}
}
示例5: save_form_info
public static function save_form_info($id, $form_json)
{
global $wpdb;
$form_json = stripslashes($form_json);
//$form_json = preg_replace('|\r\n?|', '\n', $form_json);
$form_json = nl2br($form_json);
$form_meta = GFCommon::json_decode($form_json, true);
if (!$form_meta) {
return array("status" => "invalid_json", "meta" => null);
}
$form_table_name = $wpdb->prefix . "rg_form";
$meta_table_name = $wpdb->prefix . "rg_form_meta";
//Making sure title is not duplicate
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower($form_meta["title"]) && $form_meta["id"] != $form->id) {
return array("status" => "duplicate_title", "meta" => $form_meta);
}
}
if ($id > 0) {
RGFormsModel::update_form_meta($id, $form_meta);
//updating form title
$wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta["title"], $form_meta["id"]));
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, false);
return array("status" => $id, "meta" => $form_meta);
} else {
//inserting form
$id = RGFormsModel::insert_form($form_meta["title"]);
//updating object's id property
$form_meta["id"] = $id;
//creating default notification
if (apply_filters('gform_default_notification', true)) {
$form_meta["notification"]["to"] = get_bloginfo("admin_email");
$form_meta["notification"]["subject"] = __("New submission from", "gravityforms") . " {form_title}";
$form_meta["notification"]["message"] = "{all_fields}";
}
//updating form meta
RGFormsModel::update_form_meta($id, $form_meta);
$form_meta = RGFormsModel::get_form_meta($id);
do_action('gform_after_save_form', $form_meta, true);
return array("status" => $id * -1, "meta" => $form_meta);
}
}
示例6: metarecovery_page
public static function metarecovery_page()
{
if (RGForms::post("gf_metarecovery_submit")) {
global $wpdb;
$table_name = RGFormsModel::get_meta_table_name();
$form_id = RGForms::post("gf_metarecovery_form_id");
$meta = $wpdb->get_var($wpdb->prepare("SELECT display_meta FROM {$table_name} WHERE form_id=%d", $form_id));
//fixing meta
$meta = preg_replace('!s:(\\d+):"(.*?)";!e', "'s:'.strlen('\$2').':\"\$2\";'", $meta);
//if successfull, store new meta
$obj = unserialize($meta);
if ($obj) {
RGFormsModel::update_form_meta($form_id, $obj);
$is_success = true;
} else {
$is_failure = true;
}
}
?>
<style>
.left_header{float:left; width:200px;}
.margin_vertical_10{margin: 10px 0;}
</style>
<div class="wrap">
<form method="post">
<h2><?php
_e("Meta Recovery Utility", "gravityformsmetarecovery");
?>
</h2>
<?php
if ($is_success) {
?>
<div class="updated fade" style="padding:6px"><?php
echo sprintf(__("Meta recovered successfully. %sGo to form editor%s", "gravityformsmetarecovery"), "<a href='?page=gf_edit_forms&id={$form_id}'>", "</a>");
?>
</div>
<?php
}
if ($is_failure) {
?>
<div class="error" style="padding:6px"><?php
echo __("This form's meta could not be recovered.", "gravityformsmetarecovery");
?>
</div>
<?php
}
?>
<div class="margin_vertical_10">
<label for="gf_metarecovery_form_id" class="left_header"><?php
_e("Gravity Form", "gravityforms_feed");
?>
</label>
<select name="gf_metarecovery_form_id" id="gf_metarecovery_form_id">
<option value=""><?php
_e("Select a form", "gravityforms_feed");
?>
</option>
<?php
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
?>
<option value="<?php
echo absint($form->id);
?>
"><?php
echo esc_html($form->title);
?>
</option>
<?php
}
?>
</select>
</div>
<div class="margin_vertical_10">
<input type="submit" class="button-primary" name="gf_metarecovery_submit" value="<?php
_e("Submit", "gravityformsmetarecovery");
?>
" />
</div>
</form>
</div>
<?php
}
示例7: save_form
public static function save_form()
{
global $wpdb;
check_ajax_referer('rg_save_form', 'rg_save_form');
$id = $_POST["id"];
$form_json = $_POST["form"];
$form_json = stripslashes($form_json);
//$form_json = preg_replace('|\r\n?|', '\n', $form_json);
$form_json = nl2br($form_json);
$form_meta = GFCommon::json_decode($form_json, true);
if (!$form_meta) {
die("EndUpdateForm(0);");
}
$form_table_name = $wpdb->prefix . "rg_form";
$meta_table_name = $wpdb->prefix . "rg_form_meta";
//Making sure title is not duplicate
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower($form_meta["title"]) && $form_meta["id"] != $form->id) {
die('DuplicateTitleMessage();');
}
}
if ($id > 0) {
RGFormsModel::update_form_meta($id, $form_meta);
//updating form title
$wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta["title"], $form_meta["id"]));
die("EndUpdateForm({$id});");
} else {
//inserting form
$id = RGFormsModel::insert_form($form_meta["title"]);
//updating object's id property
$form_meta["id"] = $id;
//creating default notification
if (apply_filters('gform_default_notification', true)) {
$form_meta["notification"]["to"] = get_bloginfo("admin_email");
$form_meta["notification"]["subject"] = __("New submission from", "gravityforms") . " {form_title}";
$form_meta["notification"]["message"] = "{all_fields}";
}
//updating form meta
RGFormsModel::update_form_meta($id, $form_meta);
die("EndInsertForm({$id});");
}
}
示例8: notification_page
public static function notification_page($form_id)
{
$form = RGFormsModel::get_form_meta($form_id);
if ($_POST["save"]) {
check_admin_referer('gforms_save_notification', 'gforms_save_notification');
$form["notification"]["to"] = stripslashes($_POST["form_notification_to"]);
$form["notification"]["bcc"] = stripslashes($_POST["form_notification_bcc"]);
$form["notification"]["subject"] = stripslashes($_POST["form_notification_subject"]);
$form["notification"]["message"] = stripslashes($_POST["form_notification_message"]);
$form["notification"]["from"] = empty($_POST["form_notification_from_field"]) ? stripslashes($_POST["form_notification_from"]) : "";
$form["notification"]["fromField"] = stripslashes($_POST["form_notification_from_field"]);
$form["notification"]["fromName"] = empty($_POST["form_notification_from_name_field"]) ? stripslashes($_POST["form_notification_from_name"]) : "";
$form["notification"]["fromNameField"] = stripslashes($_POST["form_notification_from_name_field"]);
$form["notification"]["replyTo"] = empty($_POST["form_notification_reply_to_field"]) ? stripslashes($_POST["form_notification_reply_to"]) : "";
$form["notification"]["replyToField"] = stripslashes($_POST["form_notification_reply_to_field"]);
$form["notification"]["routing"] = !empty($_POST["gform_routing_meta"]) ? GFCommon::json_decode(stripslashes($_POST["gform_routing_meta"]), true) : null;
$form["notification"]["disableAutoformat"] = $_POST["form_notification_disable_autoformat"];
$form["autoResponder"]["toField"] = stripslashes($_POST["form_autoresponder_to"]);
$form["autoResponder"]["bcc"] = stripslashes($_POST["form_autoresponder_bcc"]);
$form["autoResponder"]["fromName"] = stripslashes($_POST["form_autoresponder_from_name"]);
$form["autoResponder"]["from"] = stripslashes($_POST["form_autoresponder_from"]);
$form["autoResponder"]["replyTo"] = stripslashes($_POST["form_autoresponder_reply_to"]);
$form["autoResponder"]["subject"] = stripslashes($_POST["form_autoresponder_subject"]);
$form["autoResponder"]["message"] = stripslashes($_POST["form_autoresponder_message"]);
$form["autoResponder"]["disableAutoformat"] = $_POST["form_autoresponder_disable_autoformat"];
//validating input...
$invalid_tab = self::validate_notification();
if ($invalid_tab == 0) {
//input valid, updating...
//emptying notification email if it is supposed to be disabled
if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "routing") {
$form["notification"]["to"] = "";
}
//emptying notification routing if it is supposed to be disabled
if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "email") {
$form["notification"]["routing"] = null;
}
//emptying autoResponder settings if it is supposed to be disabled
if (empty($_POST["form_notification_enable_user"])) {
$form["autoResponder"]["toField"] = "";
}
RGFormsModel::update_form_meta($form_id, $form);
}
}
$wp_email = get_bloginfo("admin_email");
$email_fields = GFCommon::get_email_fields($form);
$name_fields = GFCommon::get_fields_by_type($form, array("name"));
$has_admin_notification_fields = (!empty($form["notification"]["to"]) || !empty($form["notification"]["routing"])) && (!empty($form["notification"]["subject"]) || !empty($form["notification"]["message"]));
$has_user_notification_fields = !empty($form["autoResponder"]["toField"]) && (!empty($form["autoResponder"]["subject"]) || !empty($form["autoResponder"]["message"]));
$is_admin_notification_enabled = $has_admin_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_admin"]);
$is_user_notification_enabled = $has_user_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_user"]);
$is_routing_enabled = !empty($form["notification"]["routing"]) && $_POST["notification_to"] != "email";
?>
<link rel="stylesheet" href="<?php
echo GFCommon::get_base_url();
?>
/css/admin.css?ver=<?php
echo GFCommon::$version;
?>
" />
<script type="text/javascript" src="<?php
echo GFCommon::get_base_url();
?>
/js/forms.js?ver=<?php
echo GFCommon::$version;
?>
"></script>
<script src="<?php
echo GFCommon::get_base_url();
?>
/js/jquery.json-1.3.js?ver=<?php
echo GFCommon::$version;
?>
"></script>
<script type="text/javascript">
var gform_has_unsaved_changes = false;
jQuery(document).ready(function(){
jQuery("#entry_form input, #entry_form textarea, #entry_form select").change(function(){
gform_has_unsaved_changes = true;
});
window.onbeforeunload = function(){
if (gform_has_unsaved_changes){
return "You have unsaved changes.";
}
}
});
<?php
if (empty($form["notification"])) {
$form["notification"] = array();
}
?>
var form = <?php
echo GFCommon::json_encode($form);
?>
;
//.........这里部分代码省略.........
示例9: import_file
public static function import_file($filepath, &$forms = null)
{
$xmlstr = file_get_contents($filepath);
require_once "xml.php";
$options = array("page" => array("unserialize_as_array" => true), "form" => array("unserialize_as_array" => true), "field" => array("unserialize_as_array" => true), "rule" => array("unserialize_as_array" => true), "choice" => array("unserialize_as_array" => true), "input" => array("unserialize_as_array" => true), "routing_item" => array("unserialize_as_array" => true), "creditCard" => array("unserialize_as_array" => true), "routin" => array("unserialize_as_array" => true), "confirmation" => array("unserialize_as_array" => true), "notification" => array("unserialize_as_array" => true));
$options = apply_filters('gform_import_form_xml_options', $options);
$xml = new RGXML($options);
$forms = $xml->unserialize($xmlstr);
if (!$forms) {
return 0;
} else {
if (version_compare($forms["version"], self::$min_import_version, "<")) {
return -1;
}
}
//Error. XML version is not compatible with current Gravity Forms version
//cleaning up generated object
self::cleanup($forms);
foreach ($forms as $key => &$form) {
$title = $form["title"];
$count = 2;
while (!RGFormsModel::is_unique_title($title)) {
$title = $form["title"] . "({$count})";
$count++;
}
//inserting form
$form_id = RGFormsModel::insert_form($title);
//updating form meta
$form["title"] = $title;
$form["id"] = $form_id;
$form = GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = self::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = self::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
return sizeof($forms);
}
示例10: notification_page
public static function notification_page($form_id)
{
add_action('media_buttons', array('GFNotification', 'media_buttons'), 40);
$form = RGFormsModel::get_form_meta($form_id);
$invalid_tab = "";
if (rgpost("save")) {
check_admin_referer('gforms_save_notification', 'gforms_save_notification');
$form["notification"]["to"] = rgpost("form_notification_to");
$form["notification"]["bcc"] = rgpost("form_notification_bcc");
$form["notification"]["subject"] = rgpost("form_notification_subject");
$form["notification"]["message"] = rgpost("form_notification_message");
$form["notification"]["from"] = rgempty("form_notification_from_field") ? rgpost("form_notification_from") : "";
$form["notification"]["fromField"] = rgpost("form_notification_from_field");
$form["notification"]["fromName"] = rgempty("form_notification_from_name_field") ? rgpost("form_notification_from_name") : "";
$form["notification"]["fromNameField"] = rgpost("form_notification_from_name_field");
$form["notification"]["replyTo"] = rgempty("form_notification_reply_to_field") ? rgpost("form_notification_reply_to") : "";
$form["notification"]["replyToField"] = rgpost("form_notification_reply_to_field");
$form["notification"]["routing"] = !rgempty("gform_routing_meta") ? GFCommon::json_decode(rgpost("gform_routing_meta"), true) : null;
$form["notification"]["disableAutoformat"] = rgpost("form_notification_disable_autoformat");
$form["autoResponder"]["toField"] = rgpost("form_autoresponder_to");
$form["autoResponder"]["bcc"] = rgpost("form_autoresponder_bcc");
$form["autoResponder"]["fromName"] = rgpost("form_autoresponder_from_name");
$form["autoResponder"]["from"] = rgpost("form_autoresponder_from");
$form["autoResponder"]["replyTo"] = rgpost("form_autoresponder_reply_to");
$form["autoResponder"]["subject"] = rgpost("form_autoresponder_subject");
$form["autoResponder"]["message"] = rgpost("form_autoresponder_message");
$form["autoResponder"]["disableAutoformat"] = rgpost("form_autoresponder_disable_autoformat");
//validating input...
$invalid_tab = self::validate_notification();
if ($invalid_tab == 0) {
//input valid, updating...
//emptying notification email if it is supposed to be disabled
if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "routing") {
$form["notification"]["to"] = "";
}
//emptying notification routing if it is supposed to be disabled
if (empty($_POST["form_notification_enable_admin"]) || $_POST["notification_to"] == "email") {
$form["notification"]["routing"] = null;
}
//emptying autoResponder settings if it is supposed to be disabled
if (empty($_POST["form_notification_enable_user"])) {
$form["autoResponder"]["toField"] = "";
}
RGFormsModel::update_form_meta($form_id, $form);
}
}
$wp_email = "{admin_email}";
$email_fields = GFCommon::get_email_fields($form);
$name_fields = GFCommon::get_fields_by_type($form, array("name"));
$has_admin_notification_fields = GFCommon::has_admin_notification($form);
$has_user_notification_fields = GFCommon::has_user_notification($form);
$is_admin_notification_enabled = $has_admin_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_admin"]);
$is_user_notification_enabled = $has_user_notification_fields && empty($_POST["save"]) || !empty($_POST["form_notification_enable_user"]);
$is_routing_enabled = !empty($form["notification"]["routing"]) && rgpost("notification_to") != "email";
?>
<link rel="stylesheet" href="<?php
echo GFCommon::get_base_url();
?>
/css/admin.css?ver=<?php
echo GFCommon::$version;
?>
" />
<script type="text/javascript" src="<?php
echo GFCommon::get_base_url();
?>
/js/forms.js?ver=<?php
echo GFCommon::$version;
?>
"></script>
<script src="<?php
echo GFCommon::get_base_url();
?>
/js/jquery.json-1.3.js?ver=<?php
echo GFCommon::$version;
?>
"></script>
<script type="text/javascript">
var gform_has_unsaved_changes = false;
jQuery(document).ready(function(){
jQuery("#entry_form input, #entry_form textarea, #entry_form select").change(function(){
gform_has_unsaved_changes = true;
});
window.onbeforeunload = function(){
if (gform_has_unsaved_changes){
return "You have unsaved changes.";
}
}
if(jQuery(document).on){
jQuery(document).on('change', '.gfield_routing_value_dropdown', function(){
SetRoutingValueDropDown(jQuery(this));
});
}
else{
jQuery('.gfield_routing_value_dropdown').live('change', function(){
SetRoutingValueDropDown(jQuery(this));
//.........这里部分代码省略.........
示例11: convert_old_settings
/**
* Convert settings from v1.x of the plugin
*
* @return void
* @author James Inman
*/
public function convert_old_settings()
{
$options_to_delete = array('gravityforms_sms');
$old_options = get_option('gravityforms_sms');
foreach ($this->forms as $form) {
$meta = RGFormsModel::get_form_meta($form->id);
$meta['clockwork_active'] = $meta['mediaburst_active'];
$meta['clockwork_to'] = $meta['mediaburst_to'];
if (isset($old_options['message'])) {
$meta['clockwork_message'] = $old_options['message'];
}
unset($meta['mediaburst_active']);
unset($meta['mediaburst_to']);
RGFormsModel::update_form_meta($form->id, $meta);
}
foreach ($options_to_delete as $option) {
delete_option($option);
}
}
示例12: send_notifications
/** Sends an e-mail out, good stuff */
public function send_notifications($form_id)
{
$form = RGFormsModel::get_form_meta($form_id);
if (!$form) {
// TODO: Yet, groups will only be sent out in the next schedule
// TODO: perhaps add a $now = 'group' flag for instant turnaround?
$this->reschedule_existing();
return;
}
$digest_group = isset($form['digests']['digest_group']) ? $form['digests']['digest_group'] : false;
$digest_interval = isset($form['digests']['digest_interval']) ? $form['digests']['digest_interval'] : false;
$digest_report_always = isset($form['digests']['digest_report_always']) ? $form['digests']['digest_report_always'] : false;
$digest_export_all_fields = isset($form['digests']['digest_export_all_fields']) ? $form['digests']['digest_export_all_fields'] : true;
$digest_export_field_list = isset($form['digests']['digest_export_field_list']) ? $form['digests']['digest_export_field_list'] : array();
$forms = array($form['id'] => $form);
if ($digest_group) {
/* We may want to send out a group of forms in one e-mail if possible */
foreach (RGFormsModel::get_forms(true) as $existing_form) {
if ($existing_form->id == $form_id) {
continue;
}
// It is I!
$existing_form = RGFormsModel::get_form_meta($existing_form->id);
if (!isset($existing_form['digests']['enable_digest'])) {
continue;
}
// Meh, not interesting
if (!isset($existing_form['digests']['digest_group'])) {
continue;
}
// Meh, not interesting
if (!isset($existing_form['digests']['digest_interval'])) {
continue;
}
// Meh, not interesting
if ($existing_form['digests']['digest_group'] == $digest_group) {
if ($existing_form['digests']['digest_interval'] == $digest_interval) {
$forms[$existing_form['id']] = $existing_form;
// Add them all
}
}
}
}
$emails = array();
/* Gather all the leads and update the last_sent counters */
foreach ($forms as $i => $form) {
$last_sent = isset($form['digests']['digest_last_sent']) ? $form['digests']['digest_last_sent'] : 0;
/* Retrieve form entries newer than the last sent ID */
global $wpdb;
$leads_table = RGFormsModel::get_lead_table_name();
$leads = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$leads_table} WHERE form_id = %d AND id > %d AND status = 'active';", $form['id'], $last_sent));
if (!sizeof($leads)) {
if (!$digest_report_always) {
continue;
// Nothing to report on
}
} else {
/* Update the reported id counter */
$form['digests']['digest_last_sent'] = $leads[sizeof($leads) - 1]->id;
}
if (version_compare(GFCommon::$version, '1.7') >= 0) {
/* Seems like 1.7 really messed up the meta structure */
unset($form['notifications']);
unset($form['confirmations']);
}
RGFormsModel::update_form_meta($form['id'], $form);
$forms[$i]['leads'] = $leads;
/* Also make a lookup table of all e-mail addresses to forms */
foreach ($form['digests']['digest_emails'] as $email) {
if (!isset($emails[$email])) {
$emails[$email] = array();
}
$emails[$email][] = $form['id'];
}
}
/* Now, let's try and mail stuff */
foreach ($emails as $email => $form_ids) {
/* CSV e-mails */
$report = 'Report generated at ' . date('Y-m-d H:i:s') . "\n";
$csv_attachment = tempnam(sys_get_temp_dir(), '');
$csv = fopen($csv_attachment, 'w');
$from = null;
$to = null;
$names = array();
foreach ($form_ids as $form_id) {
$form = $forms[$form_id];
$names[] = $form['title'];
fputcsv($csv, array('Form: ' . $form['title'] . ' (#' . $form_id . ')'));
$headers = array('Date Submitted');
if ($digest_export_all_fields) {
foreach ($form['fields'] as $field) {
if ($field['label']) {
$headers[] = $field['label'];
}
}
} else {
foreach ($form['fields'] as $field) {
if ($field['label'] && in_array($field['id'], $digest_export_field_list)) {
$headers[] = $field['label'];
//.........这里部分代码省略.........
示例13: save_form
public static function save_form()
{
global $wpdb;
check_ajax_referer('rg_save_form', 'rg_save_form');
$id = $_POST["id"];
$form_json = $_POST["form"];
$form_json = stripslashes($form_json);
$form_meta = GFCommon::json_decode($form_json, true);
if (!$form_meta) {
die("EndUpdateForm(0);");
}
$form_table_name = $wpdb->prefix . "rg_form";
$meta_table_name = $wpdb->prefix . "rg_form_meta";
//Making sure title is not duplicate
$forms = RGFormsModel::get_forms();
foreach ($forms as $form) {
if (strtolower($form->title) == strtolower($form_meta["title"]) && $form_meta["id"] != $form->id) {
die('DuplicateTitleMessage();');
}
}
if ($id > 0) {
RGFormsModel::update_form_meta($id, $form_meta);
//updating form title
$wpdb->query($wpdb->prepare("UPDATE {$form_table_name} SET title=%s WHERE id=%d", $form_meta["title"], $form_meta["id"]));
die("EndUpdateForm({$id});");
} else {
//inserting form
$id = RGFormsModel::insert_form($form_meta["title"]);
//updating object's id property
$form_meta["id"] = $id;
//updating form meta
RGFormsModel::update_form_meta($id, $form_meta);
die("EndInsertForm({$id});");
}
}
示例14: generateForm
public static function generateForm()
{
if (class_exists('GFAPI')) {
$thankyouPage = get_page_by_path('events/thank-you', OBJECT, 'page');
$form = array('labelPlacement' => 'top_label', 'useCurrentUserAsAuthor' => '1', 'title' => self::$formTitle, 'descriptionPlacement' => 'below', 'button' => array('type' => 'text', 'text' => 'Submit'), 'fields' => array(array('id' => '1', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'nameFormat' => 'simple', 'label' => 'First Name'), array('id' => '2', 'isRequired' => '1', 'size' => 'medium', 'type' => 'name', 'nameFormat' => 'simple', 'label' => 'Last Name'), array('id' => '3', 'isRequired' => '1', 'size' => 'medium', 'type' => 'email', 'label' => 'Email'), array('id' => '4', 'isRequired' => '1', 'size' => 'medium', 'type' => 'phone', 'phoneFormat' => 'standard', 'label' => 'Phone'), array('id' => '5', 'isRequired' => '1', 'size' => 'medium', 'type' => 'select', 'label' => 'Number Attending', 'choices' => array(array('text' => '1', 'value' => '1'), array('text' => '2', 'value' => '2'), array('text' => '3', 'value' => '3'), array('text' => '4', 'value' => '4'), array('text' => '5', 'value' => '5'), array('text' => '6', 'value' => '6'), array('text' => '7', 'value' => '7'), array('text' => '8', 'value' => '8'))), array('id' => '6', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{embed_post:post_title}', 'label' => 'Event Name'), array('id' => '7', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{embed_post:ID}', 'label' => 'Event Post ID'), array('id' => '8', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventStartDate}', 'label' => 'Event Start Date'), array('id' => '9', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventEndDate}', 'label' => 'Event End Date'), array('id' => '10', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventRecurrence}', 'label' => 'Event Recurrence'), array('id' => '11', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '{custom_field:_EventAllDay}', 'label' => 'All Day Event'), array('id' => '90', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '', 'label' => 'Event Formatted Date'), array('id' => '91', 'size' => 'medium', 'type' => 'hidden', 'defaultValue' => '', 'label' => 'Event Formatted Time')), 'cssClass' => 'contact-form-gfec-form', 'enableHoneypot' => '1', 'confirmations' => array(array('id' => '5316355c6c8c1', 'isDefault' => '1', 'type' => 'page', 'name' => 'Default Confirmation', 'pageId' => $thankyouPage->ID, 'queryString' => 'eventID={post_id:7}')), 'notifications' => array(array('id' => '53163750d13d3', 'to' => '3', 'name' => 'RSVP', 'event' => 'form_submission', 'toType' => 'field', 'subject' => 'Thank You for Registering for (Event Name:5} - {Event Date:6}', 'message' => '{all_fields}', 'from' => '{admin_email}', 'fromName' => get_bloginfo('name'))));
if (RGFormsModel::is_unique_title($form['title'])) {
$form_id = RGFormsModel::insert_form($form['title']);
$form["id"] = $form_id;
GFFormsModel::trim_form_meta_values($form);
if (isset($form['confirmations'])) {
$form['confirmations'] = GFExport::set_property_as_key($form['confirmations'], 'id');
$form['confirmations'] = GFFormsModel::trim_conditional_logic_values($form['confirmations'], $form);
GFFormsModel::update_form_meta($form_id, $form['confirmations'], 'confirmations');
unset($form['confirmations']);
}
if (isset($form['notifications'])) {
$form['notifications'] = GFExport::set_property_as_key($form['notifications'], 'id');
$form['notifications'] = GFFormsModel::trim_conditional_logic_values($form['notifications'], $form);
GFFormsModel::update_form_meta($form_id, $form['notifications'], 'notifications');
unset($form['notifications']);
}
RGFormsModel::update_form_meta($form_id, $form);
}
}
}