}
+ public function updateStatus( $id, $newStatus )
+ {
+ $this->wpdb->update(
+ $this->table,
+ array( 'status' => $newStatus ),
+ array( 'id' => $id ),
+ array( '%d' ),
+ array( '%d' )
+ );
+ }
+
/**
* Delete an event and all data associated with it.
*
}
-
-?>
* If not found use the member info record email.
* If nothing in either one then return.
*/
- public function sendMemberNotice( $memberId, $event )
+ public function sendMemberNotice( $memberId, $event, $status )
{
$member = $this->getEntry( $memberId );
// find notify_to
require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
$viewFile = 'admin/events/memberEmail.html';
+ $subject = 'Event Approved';
$eventList = GLM_MEMBERS_EVENTS_PLUGIN_ADMIN_URL ."?page=glm-members-admin-menu-events-list&glm_action=list";
+ switch ( $status ) {
+ case $this->config['event_status_numb']['Active']:
+ $smarty->templateAssign( 'status', 'Approval' );
+ $smarty->templateAssign( 'status_message', $this->config['settings']['approved_message'] );
+ $subject = 'Event Approved';
+ break;
+ case $this->config['event_status_numb']['Declined']:
+ $smarty->templateAssign( 'status', 'Declined' );
+ $smarty->templateAssign( 'status_message', $this->config['settings']['declined_message'] );
+ $subject = 'Event Declined';
+ break;
+ }
$smarty->templateAssign( 'location', 'Member Events' );
$smarty->templateAssign( 'name', $event['fieldData']['name'] );
$smarty->templateAssign( 'pendingEvents', $eventList );
// 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';
$message = $htmlMessage;
$header[] = 'From:' . $notify_from;
$header[] = 'Reply-To:' . $notify_from;
$success = true;
$memberID = false;
- // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
if ( isset( $_REQUEST['bulkAction'] ) && isset( $_REQUEST['bulkEdit'] ) && !empty( $_REQUEST['bulkEdit'] ) ) {
+ // Load Notifications from the helper classes
+ include_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH . '/helper/notification.php';
+ $notification = new GlmMembersAdmin_event_notification( $this->wpdb, $this->config );
$members = array();
// Process the bulk edit events.
$bulkAction = filter_var( $_REQUEST['bulkAction'], FILTER_SANITIZE_STRING );
$bulkEdit = filter_var( $_REQUEST['bulkEdit'], FILTER_VALIDATE_INT, [ 'flags' => FILTER_FORCE_ARRAY ] );
- // echo '<pre>$bulkEdit: ' . print_r( $bulkEdit, true ) . '</pre>';
foreach ( $bulkEdit as $eventId ) {
- $mId = $this->wpdb->get_var(
- $this->wpdb->prepare(
- "SELECT ref_dest
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events
- WHERE id = %d",
- $eventId
- )
- );
- $members[] = $mId;
- }
- switch ( $bulkAction ) {
- case 'Approve':
- // Foreach members send Approval notification
- break;
- case 'Decline':
- // Foreach members send Decline notification
- break;
- default:
- break;
+ $event = $this->editEntry( $eventId );
+ $member_id = $event['fieldData']['ref_dest_id'];
+ switch ( $bulkAction ) {
+ case 'Approve':
+ $this->updateTimestamp( 'approved', $eventId );
+ $this->updateStatus( $eventId, $this->config['event_status_numb']['Active'] );
+ if ( $member_id ) {
+ $notification->sendMemberNotice( $member_id, $event, $this->config['event_status_numb']['Active'] );
+ }
+ break;
+ case 'Decline':
+ $this->updateStatus( $eventId, $this->config['event_status_numb']['Declined'] );
+ if ( $member_id ) {
+ $notification->sendMemberNotice( $member_id, $event, $this->config['event_status_numb']['Declined'] );
+ }
+ break;
+ default:
+ break;
+ }
}
}
// Update approved timestamp.
$this->updateTimestamp('approved', $this->eventID);
if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
- $notification->sendMemberNotice( $member_id, $event );
+ $notification->sendMemberNotice( $member_id, $event, $new_status );
+ }
+ } else if ( $old_event_status == 20 && $new_status == 40 ) {
+ if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
+ $notification->sendMemberNotice( $member_id, $event, $new_status );
}
} else if ( $isModerated && $old_event_status == 10 && $new_status == 20 ) {
if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) {
if( $old_event_status === '20' && $current_status === '10' ) {
$subject = 'Event Approved';
$message .= $email_notifications['approved_message'];
- wp_mail( $to_email, $subject, $message, $header );
+ // This is done using helper class notifications
+ // wp_mail( $to_email, $subject, $message, $header );
} else if( $old_event_status === '20' && $current_status === '40' ){
$declined = $email_notifications['declined_message'];
$subject = 'Event Declined';
$message .= "Your event has been declined for the following reason(s):<br> $declined";
- wp_mail( $to_email, $subject, $message, $header );
+ // This is done using helper class notifications
+ // wp_mail( $to_email, $subject, $message, $header );
}
}
remove_filter( 'wp_mail_content_type', 'set_content_type' );
<a class="button glm-button glm-right" href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list&option=add">Add Event</a>
</h2>
<div class="glm-widget-content">
- <div>
- <select name="bulkAction">
- <option value="">Bulk Actions</option>
- <option value="Approve">Approve</option>
- <option value="Decline">Decline</option>
- </select>
- <input type="submit" value="Apply" class="button">
- </div>
{if $events}
+ {if !$memberID}
+ <div>
+ <select name="bulkAction">
+ <option value="">Bulk Actions</option>
+ <option value="Approve">Approve</option>
+ <option value="Decline">Decline</option>
+ </select>
+ <input type="submit" value="Apply" class="button">
+ </div>
+ {/if}
<table style="width: 100%">
<thead>
<tr>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
</head>
<body>
- <h1 id="title"> Event Approval Notification</h1>
+ <h1 id="title"> Event {$status} Notification</h1>
<div style="width: 500px">
- <p> Your event has been approved! </p>
+ <p> {$status_message} </p>
</div>
<table cellspacing="0" cellpadding="0" width="500" style="background: lightgrey;border:1px solid #ccc;border-collapse:collapse;">
</table>
<div id="emailFooter">
- <p style="margin-bottom: 0px;">A Event has been approved.</p>
+ <p style="margin-bottom: 0px;">Event Status has been updated.</p>
<p style="margin-top: 0px;">To view it, please go to the <a style="color: rgb(5, 104, 179);" href="{$pendingEvents}"> events </a> page in your admin.</p>
</div>
</body>