get_sad_id( $sad_page_id ); $document_model = new WP_E_Document(); $document = $document_model->getDocument( $document_id ); return $document->document_title; } /** * Returns the URL for the step icon. * * @return string */ public function get_icon_url() { return $this->get_base_url() . '/images/esig-icon.png'; } /** * Returns an array of settings for this step type. * * @return array */ public function get_settings() { $settings = parent::get_settings(); if ( ! $this->is_supported() ) { return $settings; } $settings_api = $this->get_common_settings_api(); $fields = array( $settings_api->get_setting_assignee_type(), $settings_api->get_setting_assignees(), $settings_api->get_setting_assignee_routing(), $settings_api->get_setting_notification_tabs( array( array( 'label' => __( 'Assignee Email', 'gravityflow' ), 'id' => 'tab_assignee_notification', 'fields' => $settings_api->get_setting_notification( array( 'type' => 'assignee', 'label' => __( 'Send Email to the assignee(s).', 'gravityflow' ), 'tooltip' => __( 'Enable this setting to send email to each of the assignees as soon as the entry has been assigned. If a role is configured to receive emails then all the users with that role will receive the email.', 'gravityflow' ), 'default_message' => __( 'A new document has been generated and requires a signature. Please check your Workflow Inbox.', 'gravityflow' ), 'resend_enabled' => true, ) ), ) ) ), $settings_api->get_setting_instructions( esc_html__( 'Instructions: check the signature invite status in the WP E-Signature section of the Workflow sidebar and resend if necessary.', 'gravityflow' ) ), $settings_api->get_setting_display_fields(), ); $settings['fields'] = array_merge( $settings['fields'], $fields ); return $settings; } /** * Prevent the feeds assigned to the current step from being processed by the associated add-on. */ public function intercept_submission() { parent::intercept_submission(); remove_filter( 'gform_confirmation', array( ESIG_GRAVITY_Admin::get_instance(), 'reroute_confirmation' ) ); } /** * Processes this step. * * @return bool Is the step complete? */ public function process() { $complete = parent::process(); $this->assign(); return $complete; } /** * Processes the given feed for the add-on. * * @param array $feed The add-on feed properties. * * @return bool Is feed processing complete? */ public function process_feed( $feed ) { $this->_feed_id = $feed['id']; add_action( 'esig_sad_document_invite_send', array( $this, 'sad_document_invite_send' ) ); $feed['meta']['esign_gf_logic'] = 'email'; parent::process_feed( $feed ); return false; } /** * Determines if this step type is supported. * * @return bool */ public function is_supported() { return parent::is_supported() && class_exists( 'esig_sad_document' ) && class_exists( 'WP_E_Document' ); } /** * Target of esig_sad_document_invite_send hook. Store the feed id which created this document in the WP E-Signature meta. * * @param array $args The properties related to the document which was saved. */ public function sad_document_invite_send( $args ) { if ( ! empty( $this->_feed_id ) && class_exists( 'WP_E_Meta' ) ) { $sig_meta_api = new WP_E_Meta(); $sig_meta_api->add( $args['document']->document_id, 'esig_gravity_feed_id', $this->_feed_id ); $this->save_document_id( $args['document']->document_id ); } } /** * Store the current document ID in the entry meta for this step. * * @param int $document_id The documents unique ID assigned by WP E-Signature. */ public function save_document_id( $document_id ) { $document_ids = $this->get_document_ids(); if ( ! in_array( $document_id, $document_ids ) ) { $document_ids[] = $document_id; } gform_update_meta( $this->get_entry_id(), 'workflow_step_' . $this->get_id() . '_document_ids', $document_ids ); } /** * Retrieve this entries document IDs for the current step. * * @return array */ public function get_document_ids() { $document_ids = gform_get_meta( $this->get_entry_id(), 'workflow_step_' . $this->get_id() . '_document_ids' ); if ( empty( $document_ids ) ) { $document_ids = array(); } return $document_ids; } /** * Displays content inside the Workflow metabox on the workflow detail page. * * @param array $form The Form array which may contain validation details. * @param array $args Additional args which may affect the display. */ public function workflow_detail_box( $form, $args ) { $document_ids = $this->get_document_ids(); if ( ! empty( $document_ids ) && class_exists( 'WP_E_Document' ) ) { echo sprintf( '