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


PHP GFCommon::log_error方法代码示例

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


在下文中一共展示了GFCommon::log_error方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload_files

 private static function upload_files($form, $files)
 {
     //Creating temp folder if it does not exist
     $target_path = RGFormsModel::get_upload_path($form["id"]) . "/tmp/";
     wp_mkdir_p($target_path);
     foreach ($form["fields"] as $field) {
         $input_name = "input_{$field["id"]}";
         //skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
         $input_type = RGFormsModel::get_input_type($field);
         if (!in_array($input_type, array("fileupload", "post_image")) || $field["failed_validation"] || empty($_FILES[$input_name]["name"])) {
             GFCommon::log_debug("upload_files() - skipping field: {$field["label"]}({$field["id"]} - {$field["type"]})");
             continue;
         }
         $file_info = RGFormsModel::get_temp_filename($form["id"], $input_name);
         GFCommon::log_debug("upload_files() - temp file info: " . print_r($file_info, true));
         if ($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info["temp_filename"])) {
             $files[$input_name] = $file_info["uploaded_filename"];
             GFCommon::log_debug("upload_files() - file uploaded successfully:  {$file_info["uploaded_filename"]}");
         } else {
             GFCommon::log_error("upload_files() - file could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info["temp_filename"]);
         }
     }
     return $files;
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:24,代码来源:form_display.php

示例2: lead_detail_page


//.........这里部分代码省略.........
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                do_action('gform_after_update_entry', $form, $lead['id']);
                do_action("gform_after_update_entry_{$form['id']}", $form, $lead['id']);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                if ($_POST['bulk_action'] == 'delete') {
                    if (!GFCommon::current_user_can_any('gravityforms_edit_entry_notes')) {
                        die(esc_html__("You don't have adequate permission to delete notes.", 'gravityforms'));
                    }
                    RGFormsModel::delete_notes($_POST['note']);
                }
                break;
            case 'trash':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'trash');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
            case 'restore':
            case 'unspam':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                RGFormsModel::update_lead_property($lead['id'], 'status', 'active');
                $lead = RGFormsModel::get_lead($lead['id']);
                break;
开发者ID:christopherhodges,项目名称:wp-api,代码行数:67,代码来源:entry_detail.php

示例3: upload_files

 private static function upload_files($form, $files)
 {
     $form_upload_path = GFFormsModel::get_upload_path($form['id']);
     GFCommon::log_debug("GFFormDisplay::upload_files(): Upload path {$form_upload_path}");
     //Creating temp folder if it does not exist
     $target_path = $form_upload_path . '/tmp/';
     wp_mkdir_p($target_path);
     GFCommon::recursive_add_index_file($form_upload_path);
     foreach ($form['fields'] as $field) {
         $input_name = "input_{$field->id}";
         //skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
         $input_type = RGFormsModel::get_input_type($field);
         if (!in_array($input_type, array('fileupload', 'post_image')) || $field->multipleFiles) {
             continue;
         }
         /*if ( $field->failed_validation || empty( $_FILES[ $input_name ]['name'] ) ) {
         			GFCommon::log_debug( "GFFormDisplay::upload_files(): Skipping field: {$field->label}({$field->id} - {$field->type})." );
         			continue;
         		}*/
         if ($field->failed_validation) {
             GFCommon::log_debug("GFFormDisplay::upload_files(): Skipping field because it failed validation: {$field->label}({$field->id} - {$field->type}).");
             continue;
         }
         if (empty($_FILES[$input_name]['name'])) {
             GFCommon::log_debug("GFFormDisplay::upload_files(): Skipping field because " . $_FILES[$input_name]['name'] . " could not be found: {$field->label}({$field->id} - {$field->type}).");
             continue;
         }
         $file_name = $_FILES[$input_name]['name'];
         if (GFCommon::file_name_has_disallowed_extension($file_name)) {
             GFCommon::log_debug(__METHOD__ . "(): Illegal file extension: {$file_name}");
             continue;
         }
         $allowed_extensions = !empty($field->allowedExtensions) ? GFCommon::clean_extensions(explode(',', strtolower($field->allowedExtensions))) : array();
         if (!empty($allowed_extensions)) {
             if (!GFCommon::match_file_extension($file_name, $allowed_extensions)) {
                 GFCommon::log_debug(__METHOD__ . "(): The uploaded file type is not allowed: {$file_name}");
                 continue;
             }
         }
         /**
          * Allows the disabling of file upload whitelisting
          *
          * @param bool false Set to 'true' to disable whitelisting.  Defaults to 'false'.
          */
         $whitelisting_disabled = apply_filters('gform_file_upload_whitelisting_disabled', false);
         if (empty($allowed_extensions) && !$whitelisting_disabled) {
             // Whitelist the file type
             $valid_file_name = GFCommon::check_type_and_ext($_FILES[$input_name], $file_name);
             if (is_wp_error($valid_file_name)) {
                 GFCommon::log_debug(__METHOD__ . "(): The uploaded file type is not allowed: {$file_name}");
                 continue;
             }
         }
         $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
         GFCommon::log_debug('GFFormDisplay::upload_files(): Temp file info: ' . print_r($file_info, true));
         if ($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info['temp_filename'])) {
             GFFormsModel::set_permissions($target_path . $file_info['temp_filename']);
             $files[$input_name] = $file_info['uploaded_filename'];
             GFCommon::log_debug("GFFormDisplay::upload_files(): File uploaded successfully: {$file_info['uploaded_filename']}");
         } else {
             GFCommon::log_error("GFFormDisplay::upload_files(): File could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info['temp_filename']);
         }
     }
     return $files;
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:65,代码来源:form_display.php

示例4: upload_files

 private static function upload_files($form, $files)
 {
     $form_upload_path = GFFormsModel::get_upload_path($form['id']);
     //Creating temp folder if it does not exist
     $target_path = $form_upload_path . '/tmp/';
     wp_mkdir_p($target_path);
     GFCommon::recursive_add_index_file($form_upload_path);
     foreach ($form['fields'] as $field) {
         $input_name = "input_{$field->id}";
         //skip fields that are not file upload fields or that don't have a file to be uploaded or that have failed validation
         $input_type = RGFormsModel::get_input_type($field);
         if (!in_array($input_type, array('fileupload', 'post_image')) || $field->multipleFiles) {
             continue;
         }
         if ($field->failed_validation || empty($_FILES[$input_name]['name'])) {
             GFCommon::log_debug("GFFormDisplay::upload_files(): Skipping field: {$field->label}({$field->id} - {$field->type}).");
             continue;
         }
         $file_info = RGFormsModel::get_temp_filename($form['id'], $input_name);
         GFCommon::log_debug('GFFormDisplay::upload_files(): Temp file info: ' . print_r($file_info, true));
         if ($file_info && move_uploaded_file($_FILES[$input_name]['tmp_name'], $target_path . $file_info['temp_filename'])) {
             GFFormsModel::set_permissions($target_path . $file_info['temp_filename']);
             $files[$input_name] = $file_info['uploaded_filename'];
             GFCommon::log_debug("GFFormDisplay::upload_files(): File uploaded successfully: {$file_info['uploaded_filename']}");
         } else {
             GFCommon::log_error("GFFormDisplay::upload_files(): File could not be uploaded: tmp_name: {$_FILES[$input_name]['tmp_name']} - target location: " . $target_path . $file_info['temp_filename']);
         }
     }
     return $files;
 }
开发者ID:timk85,项目名称:DIT,代码行数:30,代码来源:form_display.php

示例5: send_email

 private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '', $entry = false, $notification = false)
 {
     global $phpmailer;
     $to = str_replace(' ', '', $to);
     $bcc = str_replace(' ', '', $bcc);
     $error = false;
     if (!GFCommon::is_valid_email($from)) {
         $from = get_bloginfo('admin_email');
     }
     if (!GFCommon::is_valid_email_list($to)) {
         $error = new WP_Error('invalid_to', 'Cannot send email because the TO address is invalid.');
     } else {
         if (empty($subject) && empty($message)) {
             $error = new WP_Error('missing_subject_and_message', 'Cannot send email because there is no SUBJECT and no MESSAGE.');
         } else {
             if (!GFCommon::is_valid_email($from)) {
                 $error = new WP_Error('invalid_from', 'Cannot send email because the FROM address is invalid.');
             }
         }
     }
     if (is_wp_error($error)) {
         GFCommon::log_error('GFCommon::send_email(): ' . $error->get_error_message());
         GFCommon::log_error(print_r(compact('to', 'subject', 'message'), true));
         /**
          * Fires when an email from Gravity Forms has failed to send
          *
          * @since 1.8.10
          *
          * @param string $error   The Error message returned after the email fails to send
          * @param array  $details The details of the message that failed
          * @param array  $entry   The Entry object
          *
          */
         do_action('gform_send_email_failed', $error, compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'attachments'), $entry);
         return;
     }
     $content_type = $message_format == 'html' ? 'text/html' : 'text/plain';
     $name = empty($from_name) ? $from : $from_name;
     $headers = array();
     $headers['From'] = "From: \"" . wp_strip_all_tags($name, true) . "\" <{$from}>";
     if (GFCommon::is_valid_email_list($reply_to)) {
         $headers['Reply-To'] = "Reply-To: {$reply_to}";
     }
     if (GFCommon::is_valid_email_list($bcc)) {
         $headers['Bcc'] = "Bcc: {$bcc}";
     }
     $headers['Content-type'] = "Content-type: {$content_type}; charset=" . get_option('blog_charset');
     $abort_email = false;
     extract(apply_filters('gform_pre_send_email', compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), $message_format, $notification));
     $is_success = false;
     if (!$abort_email) {
         GFCommon::log_debug('GFCommon::send_email(): Sending email via wp_mail().');
         GFCommon::log_debug(print_r(compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), true));
         $is_success = wp_mail($to, $subject, $message, $headers, $attachments);
         $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
         GFCommon::log_debug("GFCommon::send_email(): Result from wp_mail(): {$result}");
         if (!is_wp_error($is_success) && $is_success) {
             GFCommon::log_debug('GFCommon::send_email(): Mail was passed from WordPress to the mail server.');
         } else {
             GFCommon::log_error('GFCommon::send_email(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
         }
         if (has_filter('phpmailer_init')) {
             GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
         }
         if (!empty($phpmailer->ErrorInfo)) {
             GFCommon::log_debug(__METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo);
         }
     } else {
         GFCommon::log_debug('GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.');
     }
     self::add_emails_sent();
     /**
      * Fires after an email is sent
      *
      * @param bool   $is_success     True is successfully sent.  False if failed
      * @param string $to             Recipient address
      * @param string $subject        Subject line
      * @param string $message        Message body
      * @param string $headers        Email headers
      * @param string $attachments    Email attachments
      * @param string $message_format Format of the email.  Ex: text, html
      * @param string $from           Address of the sender
      * @param string $from_name      Displayed name of the sender
      * @param string $bcc            BCC recipients
      * @param string $reply_to       Reply-to address
      * @param array  $entry          Entry object associated with the sent email
      *
      */
     do_action('gform_after_email', $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to, $entry);
 }
开发者ID:Friends-School-Atlanta,项目名称:Deployable-WordPress,代码行数:90,代码来源:common.php

示例6: send_email

 private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '')
 {
     global $phpmailer;
     $to = str_replace(' ', '', $to);
     $bcc = str_replace(' ', '', $bcc);
     $error = false;
     if (!GFCommon::is_valid_email($from)) {
         $from = get_bloginfo('admin_email');
     }
     if (!GFCommon::is_valid_email_list($to)) {
         $error = new WP_Error('invalid_to', 'Cannot send email because the TO address is invalid.');
     } else {
         if (empty($subject) && empty($message)) {
             $error = new WP_Error('missing_subject_and_message', 'Cannot send email because there is no SUBJECT and no MESSAGE.');
         } else {
             if (!GFCommon::is_valid_email($from)) {
                 $error = new WP_Error('invalid_from', 'Cannot send email because the FROM address is invalid.');
             }
         }
     }
     if (is_wp_error($error)) {
         GFCommon::log_error('GFCommon::send_email(): ' . $error->get_error_message());
         GFCommon::log_error(print_r(compact('to', 'subject', 'message'), true));
         /**
          * Fires when an email from Gravity Forms has failed to send
          *
          * @param string $error The Error message returned after the email fails to send
          */
         do_action('gform_send_email_failed', $error, compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'attachments'));
         return;
     }
     $content_type = $message_format == 'html' ? 'text/html' : 'text/plain';
     $name = empty($from_name) ? $from : $from_name;
     $headers = array();
     $headers['From'] = "From: \"" . wp_strip_all_tags($name, true) . "\" <{$from}>";
     if (GFCommon::is_valid_email_list($reply_to)) {
         $headers['Reply-To'] = "Reply-To: {$reply_to}";
     }
     if (GFCommon::is_valid_email_list($bcc)) {
         $headers['Bcc'] = "Bcc: {$bcc}";
     }
     $headers['Content-type'] = "Content-type: {$content_type}; charset=" . get_option('blog_charset');
     $abort_email = false;
     extract(apply_filters('gform_pre_send_email', compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), $message_format));
     $is_success = false;
     if (!$abort_email) {
         GFCommon::log_debug('GFCommon::send_email(): Sending email via wp_mail().');
         GFCommon::log_debug(print_r(compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), true));
         $is_success = wp_mail($to, $subject, $message, $headers, $attachments);
         $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
         GFCommon::log_debug("GFCommon::send_email(): Result from wp_mail(): {$result}");
         if (!is_wp_error($is_success) && $is_success) {
             GFCommon::log_debug('GFCommon::send_email(): Mail was passed from WordPress to the mail server.');
         } else {
             GFCommon::log_error('GFCommon::send_email(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
         }
         if (has_filter('phpmailer_init')) {
             GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
         }
         if (!empty($phpmailer->ErrorInfo)) {
             GFCommon::log_debug(__METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo);
         }
     } else {
         GFCommon::log_debug('GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.');
     }
     self::add_emails_sent();
     /**
      * Fires after Gravity Forms has sent an email
      *
      * @param bool $is_success Check if the email was successfully sent
      * @param string $to The user Email to send to
      * @param string $subject The Subject of the email sent out
      * @param string $message The Message sent with a notification, alert, etc.
      * @param string $headers The email headers (the content-type and charset)
      * @param string $attachments The email attachments sent along
      * @param string $message_fomrat The Message format (HTML/Plain Text)
      * @param string $from Who the email is coming from
      * @param string $form_name The Name of the user who is associated with the from email
      * @param string $bcc The blind carbon copy which is an extra email that won't appear in the email header
      * @param string $reply_to A header that allows you to reply to another email
      */
     do_action('gform_after_email', $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to);
 }
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:83,代码来源:common.php

示例7: save_lead

 public static function save_lead($form, &$lead)
 {
     global $wpdb;
     GFCommon::log_debug(__METHOD__ . '(): Saving entry.');
     $is_form_editor = GFCommon::is_form_editor();
     $is_entry_detail = GFCommon::is_entry_detail();
     $is_admin = $is_form_editor || $is_entry_detail;
     if ($is_admin && !GFCommon::current_user_can_any('gravityforms_edit_entries')) {
         die(esc_html__("You don't have adequate permission to edit entries.", 'gravityforms'));
     }
     $lead_detail_table = self::get_lead_details_table_name();
     $is_new_lead = $lead == null;
     //Inserting lead if null
     if ($is_new_lead) {
         global $current_user;
         $user_id = $current_user && $current_user->ID ? $current_user->ID : 'NULL';
         $lead_table = RGFormsModel::get_lead_table_name();
         $user_agent = self::truncate(rgar($_SERVER, 'HTTP_USER_AGENT'), 250);
         $user_agent = sanitize_text_field($user_agent);
         $source_url = self::truncate(self::get_current_page_url(), 200);
         /**
          * Allow the currency code to be overridden.
          *
          * @param string $currency The three character ISO currency code to be stored in the entry. Default is value returned by GFCommon::get_currency()
          * @param array $form The form currently being processed.
          *
          */
         $currency = gf_apply_filters(array('gform_currency_pre_save_entry', $form['id']), GFCommon::get_currency(), $form);
         $wpdb->query($wpdb->prepare("INSERT INTO {$lead_table}(form_id, ip, source_url, date_created, user_agent, currency, created_by) VALUES(%d, %s, %s, utc_timestamp(), %s, %s, {$user_id})", $form['id'], self::get_ip(), $source_url, $user_agent, $currency));
         //reading newly created lead id
         $lead_id = $wpdb->insert_id;
         if ($lead_id == 0) {
             GFCommon::log_error(__METHOD__ . '(): Unable to save entry. ' . $wpdb->last_error);
             die(esc_html__('An error prevented the entry for this form submission being saved. Please contact support.', 'gravityforms'));
         }
         $lead = array('id' => $lead_id);
         GFCommon::log_debug(__METHOD__ . "(): Entry record created in the database. ID: {$lead_id}.");
     }
     $current_fields = $wpdb->get_results($wpdb->prepare("SELECT id, field_number FROM {$lead_detail_table} WHERE lead_id=%d", $lead['id']));
     $total_fields = array();
     /* @var $calculation_fields GF_Field[] */
     $calculation_fields = array();
     $recalculate_total = false;
     GFCommon::log_debug(__METHOD__ . '(): Saving entry fields.');
     foreach ($form['fields'] as $field) {
         /* @var $field GF_Field */
         // ignore the honeypot field
         if ($field->type == 'honeypot') {
             continue;
         }
         //Ignore fields that are marked as display only
         if ($field->displayOnly && $field->type != 'password') {
             continue;
         }
         // Ignore pricing fields in the entry detail
         if ($is_entry_detail && GFCommon::is_pricing_field($field->type)) {
             continue;
         }
         // Process total field after all fields have been saved
         if ($field->type == 'total') {
             $total_fields[] = $field;
             continue;
         }
         $read_value_from_post = $is_new_lead || !isset($lead['date_created']);
         // Only save fields that are not hidden (except when updating an entry)
         if ($is_entry_detail || !GFFormsModel::is_field_hidden($form, $field, array(), $read_value_from_post ? null : $lead)) {
             // process calculation fields after all fields have been saved (moved after the is hidden check)
             if ($field->has_calculation()) {
                 $calculation_fields[] = $field;
                 continue;
             }
             if ($field->type == 'post_category') {
                 $field = GFCommon::add_categories_as_choices($field, '');
             }
             $inputs = $field->get_entry_inputs();
             if (is_array($inputs)) {
                 foreach ($inputs as $input) {
                     self::save_input($form, $field, $lead, $current_fields, $input['id']);
                 }
             } else {
                 self::save_input($form, $field, $lead, $current_fields, $field->id);
             }
         }
     }
     if (!empty($calculation_fields)) {
         foreach ($calculation_fields as $calculation_field) {
             $inputs = $calculation_field->get_entry_inputs();
             if (is_array($inputs)) {
                 foreach ($inputs as $input) {
                     self::save_input($form, $calculation_field, $lead, $current_fields, $input['id']);
                     self::refresh_lead_field_value($lead['id'], $input['id']);
                 }
             } else {
                 self::save_input($form, $calculation_field, $lead, $current_fields, $calculation_field->id);
                 self::refresh_lead_field_value($lead['id'], $calculation_field->id);
             }
         }
         self::refresh_product_cache($form, $lead = RGFormsModel::get_lead($lead['id']));
     }
     //saving total field as the last field of the form.
//.........这里部分代码省略.........
开发者ID:fjbeteiligung,项目名称:development,代码行数:101,代码来源:forms_model.php

示例8: send_email

 private static function send_email($from, $to, $bcc, $reply_to, $subject, $message, $from_name = '', $message_format = 'html', $attachments = '')
 {
     global $phpmailer;
     $to = str_replace(' ', '', $to);
     $bcc = str_replace(' ', '', $bcc);
     $error = false;
     if (!GFCommon::is_valid_email($from)) {
         $from = get_bloginfo('admin_email');
     }
     if (!GFCommon::is_valid_email_list($to)) {
         $error = new WP_Error('invalid_to', 'Cannot send email because the TO address is invalid.');
     } else {
         if (empty($subject) && empty($message)) {
             $error = new WP_Error('missing_subject_and_message', 'Cannot send email because there is no SUBJECT and no MESSAGE.');
         } else {
             if (!GFCommon::is_valid_email($from)) {
                 $error = new WP_Error('invalid_from', 'Cannot send email because the FROM address is invalid.');
             }
         }
     }
     if (is_wp_error($error)) {
         GFCommon::log_error('GFCommon::send_email(): ' . $error->get_error_message());
         GFCommon::log_error(print_r(compact('to', 'subject', 'message'), true));
         do_action('gform_send_email_failed', $error, compact('from', 'to', 'bcc', 'reply_to', 'subject', 'message', 'from_name', 'message_format', 'attachments'));
         return;
     }
     $content_type = $message_format == 'html' ? 'text/html' : 'text/plain';
     $name = empty($from_name) ? $from : $from_name;
     $headers = array();
     $headers['From'] = "From: \"" . wp_strip_all_tags($name, true) . "\" <{$from}>";
     if (GFCommon::is_valid_email_list($reply_to)) {
         $headers['Reply-To'] = "Reply-To: {$reply_to}";
     }
     if (GFCommon::is_valid_email_list($bcc)) {
         $headers['Bcc'] = "Bcc: {$bcc}";
     }
     $headers['Content-type'] = "Content-type: {$content_type}; charset=" . get_option('blog_charset');
     $abort_email = false;
     extract(apply_filters('gform_pre_send_email', compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), $message_format));
     $is_success = false;
     if (!$abort_email) {
         GFCommon::log_debug('GFCommon::send_email(): Sending email via wp_mail().');
         GFCommon::log_debug(print_r(compact('to', 'subject', 'message', 'headers', 'attachments', 'abort_email'), true));
         $is_success = wp_mail($to, $subject, $message, $headers, $attachments);
         $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
         GFCommon::log_debug("GFCommon::send_email(): Result from wp_mail(): {$result}");
         if (!is_wp_error($is_success) && $is_success) {
             GFCommon::log_debug('GFCommon::send_email(): Mail was passed from WordPress to the mail server.');
         } else {
             GFCommon::log_error('GFCommon::send_email(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
         }
         if (has_filter('phpmailer_init')) {
             GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
         }
         if (!empty($phpmailer->ErrorInfo)) {
             GFCommon::log_debug(__METHOD__ . '(): PHPMailer class returned an error message: ' . $phpmailer->ErrorInfo);
         }
     } else {
         GFCommon::log_debug('GFCommon::send_email(): Aborting. The gform_pre_send_email hook was used to set the abort_email parameter to true.');
     }
     self::add_emails_sent();
     do_action('gform_after_email', $is_success, $to, $subject, $message, $headers, $attachments, $message_format, $from, $from_name, $bcc, $reply_to);
 }
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:63,代码来源:common.php

示例9: lead_detail_page

    public static function lead_detail_page()
    {
        global $current_user;
        if (!GFCommon::ensure_wp_version()) {
            return;
        }
        echo GFCommon::get_remote_message();
        $requested_form_id = absint($_GET['id']);
        if (empty($requested_form_id)) {
            return;
        }
        $lead = self::get_current_entry();
        if (is_wp_error($lead) || !$lead) {
            esc_html_e("Oops! We couldn't find your entry. Please try again", 'gravityforms');
            return;
        }
        $lead_id = $lead['id'];
        $form = self::get_current_form();
        $form_id = absint($form['id']);
        $total_count = self::get_total_count();
        $position = rgget('pos') ? rgget('pos') : 0;
        $prev_pos = !rgblank($position) && $position > 0 ? $position - 1 : false;
        $next_pos = !rgblank($position) && $position < self::$_total_count - 1 ? $position + 1 : false;
        $filter = rgget('filter');
        // unread filter requires special handling for pagination since entries are filter out of the query as they are read
        if ($filter == 'unread') {
            $next_pos = $position;
            if ($next_pos + 1 == $total_count) {
                $next_pos = false;
            }
        }
        RGFormsModel::update_lead_property($lead['id'], 'is_read', 1);
        switch (RGForms::post('action')) {
            case 'update':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                //Loading files that have been uploaded to temp folder
                $files = GFCommon::json_decode(stripslashes(RGForms::post('gform_uploaded_files')));
                if (!is_array($files)) {
                    $files = array();
                }
                $original_entry = $lead;
                GFFormsModel::$uploaded_files[$form_id] = $files;
                GFFormsModel::save_lead($form, $lead);
                /**
                 * Fires after the Entry is updated from the entry detail page.
                 *
                 * @param array   $form           The form object for the entry.
                 * @param integer $lead['id']     The entry ID.
                 * @param array   $original_entry The entry object before being updated.
                 */
                gf_do_action(array('gform_after_update_entry', $form['id']), $form, $lead['id'], $original_entry);
                $lead = RGFormsModel::get_lead($lead['id']);
                $lead = GFFormsModel::set_entry_meta($lead, $form);
                self::set_current_entry($lead);
                break;
            case 'add_note':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['new_note']));
                //emailing notes if configured
                if (rgpost('gentry_email_notes_to')) {
                    GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Preparing to email entry notes.');
                    $email_to = $_POST['gentry_email_notes_to'];
                    $email_from = $current_user->user_email;
                    $email_subject = stripslashes($_POST['gentry_email_subject']);
                    $body = stripslashes($_POST['new_note']);
                    $headers = "From: \"{$email_from}\" <{$email_from}> \r\n";
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Emailing notes - TO: {$email_to} SUBJECT: {$email_subject} BODY: {$body} HEADERS: {$headers}");
                    $is_success = wp_mail($email_to, $email_subject, $body, $headers);
                    $result = is_wp_error($is_success) ? $is_success->get_error_message() : $is_success;
                    GFCommon::log_debug("GFEntryDetail::lead_detail_page(): Result from wp_mail(): {$result}");
                    if (!is_wp_error($is_success) && $is_success) {
                        GFCommon::log_debug('GFEntryDetail::lead_detail_page(): Mail was passed from WordPress to the mail server.');
                    } else {
                        GFCommon::log_error('GFEntryDetail::lead_detail_page(): The mail message was passed off to WordPress for processing, but WordPress was unable to send the message.');
                    }
                    if (has_filter('phpmailer_init')) {
                        GFCommon::log_debug(__METHOD__ . '(): The WordPress phpmailer_init hook has been detected, usually used by SMTP plugins, it can impact mail delivery.');
                    }
                    /**
                     * Fires after a note is attached to an entry and sent as an email
                     *
                     * @param string $result        The Error message or success message when the entry note is sent
                     * @param string $email_to      The email address to send the entry note to
                     * @param string $email_from    The email address from which the email is sent from
                     * @param string $email_subject The subject of the email that is sent
                     * @param mixed  $body          The Full body of the email containing the message after the note is sent
                     * @param array  $form          The current form object
                     * @param array  $lead          The Current lead object
                     */
                    do_action('gform_post_send_entry_note', $result, $email_to, $email_from, $email_subject, $body, $form, $lead);
                }
                break;
            case 'add_quick_note':
                check_admin_referer('gforms_save_entry', 'gforms_save_entry');
                $user_data = get_userdata($current_user->ID);
                RGFormsModel::add_note($lead['id'], $current_user->ID, $user_data->display_name, stripslashes($_POST['quick_note']));
                break;
            case 'bulk':
                check_admin_referer('gforms_update_note', 'gforms_update_note');
//.........这里部分代码省略.........
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:101,代码来源:entry_detail.php

示例10: write_file

 /**
  * Appends lines to to the csv file for the given Export ID.
  *
  * @param string $lines
  * @param string $export_id A unique ID for the export.
  */
 public static function write_file($lines, $export_id)
 {
     $uploads_folder = RGFormsModel::get_upload_root();
     if (!is_dir($uploads_folder)) {
         wp_mkdir_p($uploads_folder);
     }
     $export_folder = $uploads_folder . 'export';
     if (!is_dir($export_folder)) {
         wp_mkdir_p($export_folder);
     }
     $export_folder = trailingslashit($export_folder);
     self::maybe_create_htaccess_file($export_folder);
     self::maybe_create_index_file($export_folder);
     $file = $export_folder . sanitize_file_name('export-' . $export_id . '.csv');
     GFCommon::log_debug(__METHOD__ . '(): Writing to file.');
     $result = file_put_contents($file, $lines, FILE_APPEND);
     if ($result === false) {
         GFCommon::log_error(__METHOD__ . '(): An issue occurred whilst writing to the file.');
     } else {
         GFCommon::log_debug(__METHOD__ . '(): Number of bytes written to the file: ' . print_r($result, 1));
     }
 }
开发者ID:nickwoodland,项目名称:easysitges,代码行数:28,代码来源:export.php

示例11: ajax_download_export

 /**
  * Handles the download request from the export entries page.
  *
  * @since 2.0.0
  */
 public static function ajax_download_export()
 {
     check_admin_referer('gform_download_export');
     if (!GFCommon::current_user_can_any('gravityforms_export_entries')) {
         die;
     }
     $form_id = absint(rgget('form-id'));
     if (empty($form_id)) {
         die;
     }
     $form = GFAPI::get_form($form_id);
     if (empty($form)) {
         die;
     }
     $filename = sanitize_title_with_dashes($form['title']) . '-' . gmdate('Y-m-d', GFCommon::get_local_timestamp(time())) . '.csv';
     GFCommon::log_debug(__METHOD__ . '(): Starting download of file: ' . $filename);
     $charset = get_option('blog_charset');
     header('Content-Description: File Transfer');
     header("Content-Disposition: attachment; filename={$filename}");
     header('Content-Type: text/csv; charset=' . $charset, true);
     $buffer_length = ob_get_length();
     //length or false if no buffer
     if ($buffer_length > 1) {
         ob_clean();
     }
     $export_folder = RGFormsModel::get_upload_root() . 'export/';
     $export_id = rgget('export-id');
     $file = $export_folder . sanitize_file_name('export-' . $export_id . '.csv');
     $result = readfile($file);
     if ($result === false) {
         GFCommon::log_error(__METHOD__ . '(): An issue occurred whilst reading the file.');
     } else {
         @unlink($file);
         GFCommon::log_debug(__METHOD__ . '(): Number of bytes read from the file: ' . print_r($result, 1));
     }
     exit;
 }
开发者ID:fjbeteiligung,项目名称:development,代码行数:42,代码来源:export.php


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