From: Steve Sutton Date: Thu, 13 Sep 2018 20:32:41 +0000 (-0400) Subject: Sending notices for approved and declined profiles. X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=2658e612ed7ba14a9c67e306d8486ed2947e2ea9;p=WP-Plugins%2Fglm-member-db.git Sending notices for approved and declined profiles. New status declined. Status is changed when approved or declined. --- diff --git a/classes/helper/notification.php b/classes/helper/notification.php index 4ec1e65c..4136c157 100644 --- a/classes/helper/notification.php +++ b/classes/helper/notification.php @@ -83,7 +83,7 @@ class GlmMembersAdmin_member_notification extends GlmDataMembers * If not found use the member info record email. * If nothing in either one then return. */ - public function sendMemberNotice( $memberId, $profile ) + public function sendMemberNotice( $memberId, $profile, $approved = true ) { $member = $this->getEntry( $memberId ); // find notify_to @@ -102,7 +102,11 @@ class GlmMembersAdmin_member_notification extends GlmDataMembers // get settings $settings = $this->config['email_notifications']; $notify_from = $settings['from_email']; - $message = $settings['approved_message']; + if ( $approved ) { + $message = $settings['approved_message']; + } else { + $message = $settings['declined_message']; + } // Setup the Smarty Engine $smarty = new smartyTemplateSupport(); @@ -133,7 +137,11 @@ class GlmMembersAdmin_member_notification extends GlmDataMembers // Send confirmation email, set the content type to allow html by using this filter add_filter( 'wp_mail_content_type', array( $this, 'set_content_type' ) ); - $subject = 'Event Approved'; + if ( $approved ) { + $subject = 'Profile Approved'; + } else { + $subject = 'Profile Declined'; + } $message = $htmlMessage; $header[] = 'From:' . $notify_from; $header[] = 'Reply-To:' . $notify_from; diff --git a/config/plugin.ini b/config/plugin.ini index 95c9d84d..4da58aa8 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -54,12 +54,14 @@ sort_order_numb['Pseudo-Random'] = 20 status[10] = 'Active' status[20] = 'Pending Review' status[30] = 'Draft' +status[40] = 'Declined' status[90] = 'Archived' status_numb['Active'] = 10 status_numb['Pending'] = 20 status_numb['Draft'] = 30 status_numb['Inactive'] = 30 +status_numb['Declined'] = 40 status_numb['Archived'] = 90 ; diff --git a/css/admin.css b/css/admin.css index 3cac1b9f..2105ce90 100644 --- a/css/admin.css +++ b/css/admin.css @@ -320,12 +320,15 @@ clear: both; float: right; } -#glm-admin-content-container .button-primary#deleteMemberInfoButton { +#glm-admin-content-container .button-primary#deleteMemberInfoButton, +#glm-admin-content-container .button-primary.glm-alert { background: #e14d43; border: 1px solid #890000; box-shadow: 0 1px 0 #890000; + margin-left: 5px; } -#glm-admin-content-container .button-primary#deleteMemberInfoButton:hover { +#glm-admin-content-container .button-primary#deleteMemberInfoButton:hover, +#glm-admin-content-container .button-primary.glm-alert:hover { background: #f66258; box-shadow: 0 -1px 0 #890000; } diff --git a/models/admin/member/memberInfo.php b/models/admin/member/memberInfo.php index 81fd9872..81210214 100755 --- a/models/admin/member/memberInfo.php +++ b/models/admin/member/memberInfo.php @@ -398,9 +398,10 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo if ($this->memberInfo['status']) { // Status shortnames - $draft = $this->config['status_numb']['Draft']; - $pending = $this->config['status_numb']['Pending']; - $active = $this->config['status_numb']['Active']; + $draft = $this->config['status_numb']['Draft']; + $pending = $this->config['status_numb']['Pending']; + $active = $this->config['status_numb']['Active']; + $declined = $this->config['status_numb']['Declined']; // Send out a notice to the member if going from // Pending to Active status @@ -410,7 +411,33 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo $profile = array( 'reference_name' => filter_var( $_REQUEST['reference_name'], FILTER_SANITIZE_STRING ), ); - $Notifications->sendMemberNotice( $this->memberID, $profile ); + $Notifications->sendMemberNotice( $this->memberID, $profile, true ); + + // Need to Archive the original record since this new pending one is taking it's place. + // delete the selected record + $this->wpdb->query( + $this->wpdb->prepare( + "UPDATE " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info + SET status = %d + WHERE status = %d + AND reference_name = %s + AND member = %d + AND id != %d", + $this->config['status_numb']['Archived'], + $this->config['status_numb']['Active'], + $profile['reference_name'], + $this->memberID, + $this->memberInfoID + ) + ); + + } else if ( $new_status == $declined && $old_status == $pending ) { + $Notifications = new GlmMembersAdmin_member_notification( $this->wpdb, $this->config ); + // Get the profile reference name + $profile = array( + 'reference_name' => filter_var( $_REQUEST['reference_name'], FILTER_SANITIZE_STRING ), + ); + $Notifications->sendMemberNotice( $this->memberID, $profile, false ); } // If a moderated user is going from Draft to Pending then send the admin notification diff --git a/views/admin/member/memberInfo.html b/views/admin/member/memberInfo.html index c3e1dd85..df22c990 100755 --- a/views/admin/member/memberInfo.html +++ b/views/admin/member/memberInfo.html @@ -10,7 +10,7 @@ {if $settings.selected_map_interface == 2} - {/if} + {/if}