From 50f1399951527559ce9c0c4bf278cfa16534c1af Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 26 Jul 2016 14:14:15 -0400 Subject: [PATCH] Update code with documentation. Documenting the GlmMembersAdmin_management_leads class methods. --- models/admin/management/leads.php | 69 +++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 12 deletions(-) diff --git a/models/admin/management/leads.php b/models/admin/management/leads.php index df7d52a..2ef4086 100644 --- a/models/admin/management/leads.php +++ b/models/admin/management/leads.php @@ -110,6 +110,7 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement * modelAction * * @param bool $actionData + * * @access public * @return void */ @@ -263,10 +264,23 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement 'view' => 'admin/management/leads.html', 'data' => $templateData ); - - } + /** + * addInterestGroup + * + * Helper function to add the interests groups, and interests. + * Runs through the $form array and checks for the setting given for the + * group name. It adds the groups then the interests for the group from the + * form. + * + * @param mixed $form + * @param mixed $field_id + * @param mixed $group_name + * + * @access public + * @return void + */ public function addInterestGroup( $form, $field_id, $group_name ) { $interests = array(); // go through the $form array and get all the inputs for the group_name field @@ -308,7 +322,7 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement * If the group is found it simply returns the group id. * If the group is not found it will add the group and return the new id. * - * @param mixed $name + * @param mixed $name Name of the Group * * @access public * @return int The id of the group @@ -427,8 +441,8 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement /** * addEntry * - * @param mixed $entry - * @param mixed $import_fields + * @param mixed $entry Entry array from Gravity Form + * @param mixed $import_fields Array of the import_fields * * @access public * @return boolean True if added false if not @@ -501,6 +515,17 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement return $this->wpdb->insert_id; } } + /** + * getSourceId + * + * From the form id get this forms source id. If it's not found then + * create and entry and return the source id. + * + * @param mixed $form_id The id for the form. + * + * @access public + * @return int + */ public function getSourceId( $form_id ) { $source_id = $this->wpdb->get_var( $this->wpdb->prepare( @@ -528,12 +553,17 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement /** * addMemberLeadEntry * + * Adds the entry to the leads entry table. + * Checks first to see if it has a match comparing the gf_entry_id field. + * If found it will update the entry and return the id. + * If not found it will insert the entry and return the id. + * * @param mixed $lead_id Id from the leads table * @param mixed $lead Lead array * @param mixed $entry Entry array * * @access public - * @return void + * @return int Entry id */ public function addMemberLeadEntry( $lead_id, $lead, $entry ) { if ( !isset( $lead_id ) || !filter_var( $lead_id, FILTER_VALIDATE_INT ) ) { @@ -542,12 +572,6 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement if ( !isset( $lead ) || !is_array( $lead ) ) { return false; } - /* - echo '
$lead_id: ' . print_r( $lead_id, true ) . '
'; - echo '
$lead: ' . print_r( $lead, true ) . '
'; - echo '
$entry: ' . print_r( $entry, true ) . '
'; - exit; - */ // see if the gf_entry_id is already in $entry_id = $this->wpdb->get_var( $this->wpdb->prepare( @@ -612,6 +636,16 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement return $this->wpdb->insert_id; } } + /** + * getMembersInterests + * + * Returns the interests records with the gravity form field id's. + * + * @param mixed $form_id The id of the gravity form. + * + * @access public + * @return mixed + */ public function getMembersInterests( $form_id ) { static $interest = array(); if ( empty( $interest ) ) { @@ -634,6 +668,17 @@ class GlmMembersAdmin_management_leads // extends GlmDataLeadsManagement } return $interest; } + /** + * addMemberLeadInterests + * + * Add the Lead interests for the entry. + * + * @param mixed $entry_id Id for the enty + * @param mixed $entry Entry array from gravity forms. + * + * @access public + * @return mixed + */ public function addMemberLeadInterests( $entry_id, $entry ) { if ( !filter_var( $entry_id, FILTER_VALIDATE_INT ) ) { return false; -- 2.17.1