function process() { $this->log_debug(__METHOD__ . '(): starting'); if (class_exists('GFPDF_Core')) { global $gfpdf; if (empty($gfpdf)) { $gfpdf = new GFPDF_Core(); } } $entry = $this->get_entry(); $form = $this->get_form(); foreach ($form['notifications'] as $notification) { $notification_id = $notification['id']; $setting_key = 'notification_id_' . $notification_id; if ($this->{$setting_key}) { if (!GFCommon::evaluate_conditional_logic(rgar($notification, 'conditionalLogic'), $form, $entry)) { $this->log_debug(__METHOD__ . "(): Notification conditional logic not met, not processing notification (#{$notification_id} - {$notification['name']})."); continue; } GFCommon::send_notification($notification, $form, $entry); $this->log_debug(__METHOD__ . "(): Notification sent (#{$notification_id} - {$notification['name']})."); $note = sprintf(esc_html__('Sent Notification: %s', 'gravityflow'), $notification['name']); $this->add_note($note); } } $this->send_workflow_notification(); return true; }
public static function resend_notifications() { check_admin_referer('gf_resend_notifications', 'gf_resend_notifications'); $form_id = absint(rgpost('formId')); $leads = rgpost('leadIds'); // may be a single ID or an array of IDs if (0 == $leads) { // get all the lead ids for the current filter / search $filter = rgpost('filter'); $search = rgpost('search'); $star = $filter == 'star' ? 1 : null; $read = $filter == 'unread' ? 0 : null; $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active'; $search_criteria['status'] = $status; if ($star) { $search_criteria['field_filters'][] = array('key' => 'is_starred', 'value' => (bool) $star); } if (!is_null($read)) { $search_criteria['field_filters'][] = array('key' => 'is_read', 'value' => (bool) $read); } $search_field_id = rgpost('fieldId'); if (isset($_POST['fieldId']) && $_POST['fieldId'] !== '') { $key = $search_field_id; $val = $search; $strpos_row_key = strpos($search_field_id, '|'); if ($strpos_row_key !== false) { //multi-row $key_array = explode('|', $search_field_id); $key = $key_array[0]; $val = $key_array[1] . ':' . $val; } $search_criteria['field_filters'][] = array('key' => $key, 'operator' => rgempty('operator', $_POST) ? 'is' : rgpost('operator'), 'value' => $val); } $leads = GFFormsModel::search_lead_ids($form_id, $search_criteria); } else { $leads = !is_array($leads) ? array($leads) : $leads; } $form = gf_apply_filters('gform_before_resend_notifications', $form_id, RGFormsModel::get_form_meta($form_id), $leads); if (empty($leads) || empty($form)) { _e('There was an error while resending the notifications.', 'gravityforms'); die; } $notifications = json_decode(rgpost('notifications')); if (!is_array($notifications)) { die(esc_html__('No notifications have been selected. Please select a notification to be sent.', 'gravityforms')); } if (!rgempty('sendTo', $_POST) && !GFCommon::is_valid_email_list(rgpost('sendTo'))) { die(sprintf(esc_html__('The %sSend To%s email address provided is not valid.', 'gravityforms'), '<strong>', '</strong>')); } foreach ($leads as $lead_id) { $lead = RGFormsModel::get_lead($lead_id); foreach ($notifications as $notification_id) { $notification = $form['notifications'][$notification_id]; if (!$notification) { continue; } //overriding To email if one was specified if (rgpost('sendTo')) { $notification['to'] = rgpost('sendTo'); $notification['toType'] = 'email'; } GFCommon::send_notification($notification, $form, $lead); } } die; }
public static function process_send_resume_link() { $form_id = rgpost('gform_send_resume_link'); $form_id = absint($form_id); $email = rgpost('gform_resume_email'); $resume_token = rgpost('gform_resume_token'); $resume_token = sanitize_key($resume_token); if (empty($form_id) || empty($email) || empty($resume_token) || !GFCommon::is_valid_email($email)) { return; } $form = GFFormsModel::get_form_meta($form_id); if (empty($form)) { return; } if (rgar($form, 'requireLogin')) { if (!is_user_logged_in()) { wp_die(); } check_admin_referer('gform_send_resume_link', '_gform_send_resume_link_nonce'); } $incomplete_submission = GFFormsModel::get_incomplete_submission_values($resume_token); $submission = json_decode($incomplete_submission['submission'], true); $partial_entry = $submission['partial_entry']; $notifications_to_send = GFCommon::get_notifications_to_send('form_save_email_requested', $form, $partial_entry); $log_notification_event = empty($notifications_to_send) ? 'No notifications to process' : 'Processing notifications'; GFCommon::log_debug("GFFormDisplay::process_send_resume_link(): {$log_notification_event} for form_save_email_requested event."); foreach ($notifications_to_send as $notification) { if (isset($notification['isActive']) && !$notification['isActive']) { GFCommon::log_debug("GFFormDisplay::process_send_resume_link(): Notification is inactive, not processing notification (#{$notification['id']} - {$notification['name']})."); continue; } if ($notification['toType'] == 'hidden') { $notification['to'] = $email; } $notification['message'] = self::replace_save_variables($notification['message'], $form, $resume_token, $email); GFCommon::send_notification($notification, $form, $partial_entry); } GFFormsModel::add_email_to_incomplete_sumbmission($resume_token, $email); }
public static function resend_notifications() { check_admin_referer('gf_resend_notifications', 'gf_resend_notifications'); $form_id = rgpost('formId'); $leads = rgpost('leadIds'); // may be a single ID or an array of IDs if (0 == $leads) { // get all the lead ids for the current filter / search $filter = rgpost("filter"); $search = rgpost("search"); $star = $filter == "star" ? 1 : null; $read = $filter == "unread" ? 0 : null; $status = in_array($filter, array("trash", "spam")) ? $filter : "active"; $search_criteria["status"] = $status; if ($star) { $search_criteria["field_filters"][] = array("key" => "is_starred", "value" => (bool) $star); } if (!is_null($read)) { $search_criteria["field_filters"][] = array("key" => "is_read", "value" => (bool) $read); } $search_field_id = rgpost("fieldId"); if (isset($_POST["fieldId"]) && $_POST["fieldId"] !== '') { $key = $search_field_id; $val = $search; $strpos_row_key = strpos($search_field_id, "|"); if ($strpos_row_key !== false) { //multi-row $key_array = explode("|", $search_field_id); $key = $key_array[0]; $val = $key_array[1] . ":" . $val; } $search_criteria["field_filters"][] = array("key" => $key, "operator" => rgempty("operator", $_POST) ? "is" : rgpost("operator"), "value" => $val); } $leads = GFFormsModel::search_lead_ids($form_id, $search_criteria); } else { $leads = !is_array($leads) ? array($leads) : $leads; } $form = apply_filters("gform_before_resend_notifications_{$form_id}", apply_filters('gform_before_resend_notifications', RGFormsModel::get_form_meta($form_id), $leads), $leads); if (empty($leads) || empty($form)) { _e("There was an error while resending the notifications.", "gravityforms"); die; } $notifications = json_decode(rgpost('notifications')); if (!is_array($notifications)) { die(__("No notifications have been selected. Please select a notification to be sent.", "gravityforms")); } if (rgpost('sendTo') && GFCommon::is_invalid_or_empty_email(rgpost('sendTo'))) { die(__("The <strong>Send To</strong> email address provided is not valid.", "gravityforms")); } foreach ($leads as $lead_id) { $lead = RGFormsModel::get_lead($lead_id); foreach ($notifications as $notification_id) { $notification = $form["notifications"][$notification_id]; if (!$notification) { continue; } //overriding To email if one was specified if (rgpost('sendTo')) { $notification["to"] = rgpost('sendTo'); $notification["toType"] = "email"; } GFCommon::send_notification($notification, $form, $lead); } } die; }
function set_entry_status($lead, $form) { //$location_change=$_POST['entry_info_location_change']; //$flags_change=$_POST['entry_info_flags_change']; $location_comment_change = $_POST['entry_location_comment']; $acceptance_status_change = $_POST['entry_info_status_change']; $entry_info_entry_id = $_POST['entry_info_entry_id']; $acceptance_current_status = $lead['303']; $is_acceptance_status_changed = strcmp($acceptance_current_status, $acceptance_status_change) != 0; if (!empty($entry_info_entry_id)) { if (!empty($acceptance_status_change)) { //Update Field for Acceptance Status $entry_info_entry['303'] = $acceptance_status_change; mf_update_entry_field($entry_info_entry_id, '303', $acceptance_status_change); //Reload entry to get any changes in status $lead['303'] = $acceptance_status_change; //Handle acceptance status changes if ($is_acceptance_status_changed) { //Create a note of the status change. $results = mf_add_note($entry_info_entry_id, 'EntryID:' . $entry_info_entry_id . ' status changed to ' . $acceptance_status_change); //Handle notifications for acceptance $notifications_to_send = GFCommon::get_notifications_to_send('mf_acceptance_status_changed', $form, $lead); foreach ($notifications_to_send as $notification) { if ($notification['isActive']) { GFCommon::send_notification($notification, $form, $lead); } } GFJDBHELPER::gravityforms_sync_status_jdb($entry_info_entry_id, $acceptance_status_change); } } } }
public static function resend_notifications() { check_admin_referer('gf_resend_notifications', 'gf_resend_notifications'); $form_id = rgpost('formId'); $leads = rgpost('leadIds'); // may be a single ID or an array of IDs if (0 == $leads) { // get all the lead ids for the current filter / search $filter = rgpost("filter"); $search = rgpost("search"); $star = $filter == "star" ? 1 : null; $read = $filter == "unread" ? 0 : null; $status = in_array($filter, array("trash", "spam")) ? $filter : "active"; $leads = GFFormsModel::get_lead_ids($form_id, $search, $star, $read, null, null, $status); } else { $leads = !is_array($leads) ? array($leads) : $leads; } $form = apply_filters("gform_before_resend_notifications_{$form_id}", apply_filters('gform_before_resend_notifications', RGFormsModel::get_form_meta($form_id), $leads), $leads); if (empty($leads) || empty($form)) { _e("There was an error while resending the notifications.", "gravityforms"); die; } $notifications = json_decode(rgpost('notifications')); if (!is_array($notifications)) { die(__("No notifications have been selected. Please select a notification to be sent.", "gravityforms")); } if (rgpost('sendTo') && GFCommon::is_invalid_or_empty_email(rgpost('sendTo'))) { die(__("The <strong>Send To</strong> email address provided is not valid.", "gravityforms")); } foreach ($leads as $lead_id) { $lead = RGFormsModel::get_lead($lead_id); foreach ($notifications as $notification_id) { $notification = $form["notifications"][$notification_id]; if (!$notification) { continue; } //overriding To email if one was specified if (rgpost('sendTo')) { $notification["to"] = rgpost('sendTo'); $notification["toType"] = "email"; } GFCommon::send_notification($notification, $form, $lead); } } die; }
public static function resend_notifications() { check_admin_referer('gf_resend_notifications', 'gf_resend_notifications'); $leads = rgpost('leadIds'); // may be a single ID or an array of IDs $leads = !is_array($leads) ? array($leads) : $leads; $form_id = rgpost('formId'); $form = apply_filters("gform_before_resend_notifications_{$form_id}", apply_filters('gform_before_resend_notifications', RGFormsModel::get_form_meta($form_id), $leads), $leads); if (empty($leads) || empty($form)) { _e("There was an error while resending the notifications.", "gravityforms"); die; } $notifications = json_decode(rgpost('notifications')); if (!is_array($notifications)) { die(__("No notifications have been selected. Please select a notification to be sent.", "gravityforms")); } if (rgpost('sendTo') && GFCommon::is_invalid_or_empty_email(rgpost('sendTo'))) { die(__("The <strong>Send To</strong> email address provided is not valid.", "gravityforms")); } foreach ($leads as $lead_id) { $lead = RGFormsModel::get_lead($lead_id); foreach ($notifications as $notification_id) { $notification = $form["notifications"][$notification_id]; if (!$notification) { continue; } //overriding To email if one was specified if (rgpost('sendTo')) { $notification["to"] = rgpost('sendTo'); $notification["toType"] = "email"; } GFCommon::send_notification($notification, $form, $lead); } } die; }
/** * Sends an email. * * @param $notification */ public function send_notification($notification) { $entry = $this->get_entry(); $form = $this->get_form(); $notification = apply_filters('gravityflow_notification', $notification, $form, $entry, $this); $this->log_debug(__METHOD__ . '() - sending notification: ' . print_r($notification, true)); GFCommon::send_notification($notification, $form, $entry); }
function entry_detail_approval_box($form, $entry) { global $current_user; if (!isset($entry['approval_status'])) { return; } if (isset($_POST['gf_approvals_status']) && check_admin_referer('gf_approvals')) { $new_status = $_POST['gf_approvals_status']; gform_update_meta($entry['id'], 'approval_status_' . $current_user->ID, $new_status); $entry['approval_status_' . $current_user->ID] = $new_status; $entry_approved = true; $entry_rejected = false; foreach ($this->get_feeds($form['id']) as $feed) { if ($feed['is_active'] && $this->is_feed_condition_met($feed, $form, $entry)) { $approver = $feed['meta']['approver']; if (!empty($entry['approval_status_' . $approver])) { if ($entry['approval_status_' . $approver] != 'approved') { $entry_approved = false; } if ($new_status == 'rejected') { $entry_rejected = true; } } } } if ($entry_rejected) { gform_update_meta($entry['id'], 'approval_status', 'rejected'); $entry['approval_status'] = 'rejected'; do_action('gform_approvals_entry_rejected', $entry, $form); } elseif ($entry_approved) { gform_update_meta($entry['id'], 'approval_status', 'approved'); $entry['approval_status'] = 'approved'; // Integration with the User Registration Add-On if (class_exists('GFUser')) { GFUser::gf_create_user($entry, $form); } // Integration with the Zapier Add-On if (class_exists('GFZapier')) { GFZapier::send_form_data_to_zapier($entry, $form); } do_action('gform_approvals_entry_approved', $entry, $form); } $notifications_to_send = GFCommon::get_notifications_to_send('form_approval', $form, $entry); foreach ($notifications_to_send as $notification) { GFCommon::send_notification($notification, $form, $entry); } } $status = __('Pending Approval', 'gravityformsapprovals'); $approve_icon = '<i class="fa fa-check" style="color:green"></i>'; $reject_icon = '<i class="fa fa-times" style="color:red"></i>'; if ($entry['approval_status'] == 'approved') { $status = $approve_icon . ' ' . __('Approved', 'gravityformsapprovals'); } elseif ($entry['approval_status'] == 'rejected') { $status = $reject_icon . ' ' . __('Rejected', 'gravityformsapprovals'); } ?> <div class="postbox"> <h3><?php echo $status; ?> </h3> <div style="padding:10px;"> <ul> <?php $has_been_approved = false; $current_user_is_approver = false; foreach ($this->get_feeds($form['id']) as $feed) { if ($feed['is_active']) { $approver = $feed['meta']['approver']; if ($feed['is_active'] && $this->is_feed_condition_met($feed, $form, $entry)) { $user_info = get_user_by('id', $approver); $status = $entry['approval_status_' . $approver]; if ($status === false) { $status = 'pending'; } elseif ($status != 'pending') { $has_been_approved = true; } if ($status === false || $status == 'pending') { if ($current_user->ID == $approver) { $current_user_is_approver = true; } } echo '<li>' . $user_info->display_name . ': ' . $status . '</li>'; } } } if ($has_been_approved) { add_action('gform_entrydetail_update_button', array($this, 'remove_entrydetail_update_button'), 10); } ?> </ul> <div> <?php if ($current_user_is_approver) { ?> <form method="post" id="sidebar_form" enctype='multipart/form-data'> <?php wp_nonce_field('gf_approvals'); ?> <button name="gf_approvals_status" value="approved" type="submit" class="button"> <?php echo $approve_icon; ?> <?php _e('Approve', 'gravityformsapprovals'); ?> </button> <button name="gf_approvals_status" value="rejected" type="submit" class="button"> <?php echo $reject_icon; ?> <?php _e('Reject', 'gravityformsapprovals'); ?> </button> </form> <?php } ?> </div> </div> </div> <?php }
function makerDeleteEntry() { $entryID = isset($_POST['delete_entry_id']) ? $_POST['delete_entry_id'] : 0; if ($entryID != 0) { //get entry data and form data $lead = GFAPI::get_entry(esc_attr($entryID)); $form = GFAPI::get_form($lead['form_id']); $trashed = GFAPI::update_entry_property($entryID, 'status', 'trash'); new GravityView_Cache(); if (!$trashed) { echo new WP_Error('trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview')); } //Make a note of the delete mf_add_note($entryID, "The Exhibit has been deleted by the maker."); //Handle notifications for acceptance $notifications_to_send = GFCommon::get_notifications_to_send('maker_delete_exhibit', $form, $lead); foreach ($notifications_to_send as $notification) { if ($notification['isActive']) { GFCommon::send_notification($notification, $form, $lead); } } echo $lead['151'] . ', Exhibit ID ' . $entryID . ' has been deleted'; } else { echo 'Error in deleting this entry.'; } exit; }