当前位置: 首页>>代码示例>>PHP>>正文


PHP RGFormsModel::save_form_notifications方法代码示例

本文整理汇总了PHP中RGFormsModel::save_form_notifications方法的典型用法代码示例。如果您正苦于以下问题:PHP RGFormsModel::save_form_notifications方法的具体用法?PHP RGFormsModel::save_form_notifications怎么用?PHP RGFormsModel::save_form_notifications使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RGFormsModel的用法示例。


在下文中一共展示了RGFormsModel::save_form_notifications方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
     }
 }
开发者ID:sbayer55,项目名称:The-Road-Gallery,代码行数:60,代码来源:form_detail.php

示例2: duplicate_notification

 public static function duplicate_notification($notification_id, $form_id)
 {
     if (!$form_id) {
         return false;
     }
     $form = !is_array($form_id) ? RGFormsModel::get_form_meta($form_id) : $form_id;
     $new_notification = $form['notifications'][$notification_id];
     $name = rgar($new_notification, "name");
     $new_id = uniqid();
     $count = 2;
     $new_name = $name . " - Copy 1";
     while (!self::is_unique_name($new_name, $form['notifications'])) {
         $new_name = $name . " - Copy {$count}";
         $count++;
     }
     $new_notification["name"] = $new_name;
     $new_notification["id"] = $new_id;
     $form['notifications'][$new_id] = $new_notification;
     // clear Form cache so next retrieval of form meta will return duplicated notification
     RGFormsModel::flush_current_forms();
     return RGFormsModel::save_form_notifications($form['id'], $form['notifications']);
 }
开发者ID:rushabhrakholiya,项目名称:TEST,代码行数:22,代码来源:notification.php

示例3: 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);
     }
 }
开发者ID:nickyshannon,项目名称:miriam,代码行数:60,代码来源:form_detail.php

示例4: duplicate_notification

 public static function duplicate_notification($notification_id, $form_id)
 {
     if (!$form_id) {
         return false;
     }
     $form = !is_array($form_id) ? RGFormsModel::get_form_meta($form_id) : $form_id;
     $new_notification = $form['notifications'][$notification_id];
     $name = rgar($new_notification, 'name');
     $new_id = uniqid();
     $count = 2;
     $new_name = $name . ' - Copy 1';
     while (!self::is_unique_name($new_name, $form['notifications'])) {
         $new_name = $name . " - Copy {$count}";
         $count++;
     }
     $new_notification['name'] = $new_name;
     $new_notification['id'] = $new_id;
     unset($new_notification['isDefault']);
     if ($new_notification['toType'] == 'hidden') {
         $new_notification['toType'] = 'email';
     }
     $form['notifications'][$new_id] = $new_notification;
     // clear Form cache so next retrieval of form meta will return duplicated notification
     RGFormsModel::flush_current_forms();
     return RGFormsModel::save_form_notifications($form['id'], $form['notifications']);
 }
开发者ID:jamesaveryw,项目名称:mississippi-staging,代码行数:26,代码来源:notification.php

示例5: delete_notification

 /**
  * Delete a form notification by ID.
  *
  * @param mixed $notification_id
  * @param mixed $form_id Can pass a form ID or a form object
  */
 public static function delete_notification($notification_id, $form_id)
 {
     if (!$form_id) {
         return false;
     }
     $form = !is_array($form_id) ? RGFormsModel::get_form_meta($form_id) : $form_id;
     unset($form['notifications'][$notification_id]);
     // clear form cache so next retrieval of form meta will reflect deleted notification
     RGFormsModel::flush_current_forms();
     return RGFormsModel::save_form_notifications($form['id'], $form['notifications']);
 }
开发者ID:ascarius,项目名称:wordpress-bootstrap,代码行数:17,代码来源:notification.php


注:本文中的RGFormsModel::save_form_notifications方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。