From: Steve Sutton Date: Fri, 1 Jun 2018 21:05:23 +0000 (-0400) Subject: delete notes,contacts and referred by when deleting lead X-Git-Tag: v1.0.0^2~19 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=4b836251188ba5d19b32b777be1e5709c419598d;p=WP-Plugins%2Fglm-member-db-travel.git delete notes,contacts and referred by when deleting lead Need to delete extra data per lead. --- diff --git a/models/admin/travel/index.php b/models/admin/travel/index.php index 19cea0e..140cb73 100644 --- a/models/admin/travel/index.php +++ b/models/admin/travel/index.php @@ -198,10 +198,24 @@ class GlmMembersAdmin_travel_index extends GlmDataTravelLeads switch ( $option ) { case 'delete': - // echo '
$this->entryId: ' . print_r( $this->entryId, true ) . '
'; if ( $this->entryId ) { $return = $this->deleteEntry( $this->entryId, true, 'id' ); - // echo '
$return: ' . print_r( $return, true ) . '
'; + // Need to delete the notes, contacts and referredby also + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_notes', + array( 'lead' => $this->entryId ), + array( '%d' ) + ); + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'lead_contacts', + array( 'lead' => $this->entryId ), + array( '%d' ) + ); + $this->wpdb->delete( + GLM_MEMBERS_TRAVEL_PLUGIN_DB_PREFIX . 'leads_referredby', + array( 'lead' => $this->entryId ), + array( '%d' ) + ); } $entry = $this->getList(); $view = 'index.html'; diff --git a/setup/adminTabs.php b/setup/adminTabs.php index 015bc89..46aa351 100644 --- a/setup/adminTabs.php +++ b/setup/adminTabs.php @@ -51,3 +51,20 @@ if (current_user_can('glm_members_members')) { ); } + +if ( current_user_can( 'glm_members_management' ) ) { + add_filter( + 'glm-member-db-add-tab-for-import', + function( $addOnTabs ){ + $newTabs = array( + array( + 'text' => 'Travel Leads', + 'menu' => 'import', + 'action' => 'travel', + ) + ); + $addOnTabs = array_merge( $addOnTabs, $newTabs ); + return $addOnTabs; + } + ); +} diff --git a/setup/validActions.php b/setup/validActions.php index cb55e47..abd089f 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -74,6 +74,9 @@ $glmMembersTravelAddOnValidActions = array( 'index' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, 'members' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, ), + 'import' =>array( + 'travel' => GLM_MEMBERS_TRAVEL_PLUGIN_SLUG, + ), ), 'frontActions' => array( )