/** * Retrieve the options to be used when initializing SuperSignature for this field. * * @param string $field_id The field canvas/div id attribute. * @param array $form The current form object. * * @return array */ public function get_supersignature_init_options($field_id, $form) { // Set init options based on device. $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($user_agent, 'Mac') !== FALSE) { // Settings for mac. $init_options = array('Enabled' => true, 'SignObject' => $field_id, 'BackColor' => empty($this->backgroundColor) ? '#FFFFFF' : $this->backgroundColor, 'PenSize' => rgblank($this->penSize) ? '2' : $this->penSize, 'PenColor' => empty($this->penColor) ? '#000000' : $this->penColor, 'SignWidth' => rgblank($this->boxWidth) ? '300' : $this->boxWidth, 'SignHeight' => '180', 'BorderStyle' => empty($this->borderStyle) ? 'Dashed' : $this->borderStyle, 'BorderWidth' => rgblank($this->borderWidth) ? '2px' : $this->borderWidth . 'px', 'BorderColor' => empty($this->borderColor) ? '#DDDDDD' : $this->borderColor, 'RequiredPoints' => '15', 'ClearImage' => gf_signature()->get_base_url() . '/includes/super_signature/refresh.png', 'PenCursor' => gf_signature()->get_base_url() . '/includes/super_signature/pen.cur', 'Visible' => true, 'ErrorMessage' => '', 'StartMessage' => '', 'SuccessMessage' => ''); } else { // Settings for pc and anything else. $init_options = array('SignObject' => $field_id, 'BackColor' => empty($this->backgroundColor) ? '#FFFFFF' : $this->backgroundColor, 'PenSize' => rgblank($this->penSize) ? '2' : $this->penSize, 'PenColor' => empty($this->penColor) ? '#000000' : $this->penColor, 'SignWidth' => rgblank($this->boxWidth) ? '300' : $this->boxWidth, 'SignHeight' => '180', 'BorderStyle' => empty($this->borderStyle) ? 'Dashed' : $this->borderStyle, 'BorderWidth' => rgblank($this->borderWidth) ? '2px' : $this->borderWidth . 'px', 'BorderColor' => empty($this->borderColor) ? '#DDDDDD' : $this->borderColor, 'RequiredPoints' => '15', 'ClearImage' => gf_signature()->get_base_url() . '/includes/super_signature/refresh.png', 'PenCursor' => gf_signature()->get_base_url() . '/includes/super_signature/pen.cur', 'Visible' => true, 'ErrorMessage' => '', 'StartMessage' => '', 'SuccessMessage' => '', 'forceMouseEvent' => true, 'IeModalFix' => true); } /** * Allow the SuperSignature initialization options to be customized. * * @param array $init_options The initialization options. * @param GF_Field_Signature $field The current field object. * @param array $form The current form object. * * @since 3.0.2 */ return apply_filters('gform_signature_init_options', $init_options, $this, $form); }
/** * Patch to fix signature add-on in the front-end until GF_Field is implemented. The input name is rendered with the form ID in the front-end but editing is expected to be done in admin. */ public function maybe_save_signature() { //see if this is an entry and it needs to be updated. abort if not if (!(RG_CURRENT_VIEW == 'entry' && rgpost('save') == 'Update')) { return; } $lead_id = rgget('lid'); $form = RGFormsModel::get_form_meta(rgget('id')); if (empty($lead_id)) { //lid is not always in the querystring when paging through entries, use same logic from entry detail page $filter = rgget('filter'); $status = in_array($filter, array('trash', 'spam')) ? $filter : 'active'; $search = rgget('s'); $position = rgget('pos') ? rgget('pos') : 0; $sort_direction = rgget('dir') ? rgget('dir') : 'DESC'; $sort_field = empty($_GET['sort']) ? 0 : $_GET['sort']; $sort_field_meta = RGFormsModel::get_field($form, $sort_field); $is_numeric = $sort_field_meta['type'] == 'number'; $star = $filter == 'star' ? 1 : null; $read = $filter == 'unread' ? 0 : null; $leads = RGFormsModel::get_leads(rgget('id'), $sort_field, $sort_direction, $search, $position, 1, $star, $read, $is_numeric, null, null, $status); if (!$lead_id) { $lead = !empty($leads) ? $leads[0] : false; } else { $lead = RGFormsModel::get_lead($lead_id); } if (!$lead) { _e("Oops! We couldn't find your lead. Please try again", 'gravityforms'); return; } $lead_id = $lead['id']; } //loop through form fields, get the field name of the signature field foreach ($form['fields'] as $field) { if (RGFormsModel::get_input_type($field) == 'signature') { //get field name so the value can be pulled from the post data $form_id = absint($form['id']); $input_name = 'input_' . $form_id . '_' . str_replace('.', '_', $field['id']); //when adding a new signature the data field will be populated if (!rgempty("{$input_name}_data")) { //new image added, save $filename = gf_signature()->save_signature($input_name . '_data'); } else { //existing image edited $filename = rgpost($input_name . '_signature_filename'); } $_POST["input_{$field['id']}"] = $filename; } } }