From dc02f552136bcbdf7f4bf5258ba09b24c5e0e001 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 3 Apr 2017 08:39:01 -0400 Subject: [PATCH] Update so not moderated member or contact can edit status of the event. Created new template variable for isModerated using the filter for checking if the member or contact is moderated. --- index.php | 6 +- models/admin/events/list.php | 184 +++++++++++++++-------------- views/admin/events/editStatus.html | 6 +- 3 files changed, 101 insertions(+), 95 deletions(-) diff --git a/index.php b/index.php index 0e87755..1712a18 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database Events * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 1.6.29 + * Version: 1.6.30 * Author: Chuck Scott * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -20,7 +20,7 @@ * @package glmMembersDatabaseEventsAddOn * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @version 1.6.29 + * @version 1.6.30 */ /* @@ -38,7 +38,7 @@ * so that we're sure the other add-ons see an up to date * version from this plugin. */ -define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.29'); +define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.6.30'); define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.1.1'); // This is the minimum version of the GLM Members DB plugin require for this plugin. diff --git a/models/admin/events/list.php b/models/admin/events/list.php index 5b056e1..0245d05 100644 --- a/models/admin/events/list.php +++ b/models/admin/events/list.php @@ -97,6 +97,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents { $lockedToMember = false; + $isModerated = false; $numbEvents = 0; $option = 'list'; $events = false; @@ -146,13 +147,14 @@ class GlmMembersAdmin_events_list extends GlmDataEvents // Check if there's a logged in user who is locked to their own entity $lockedToMember = apply_filters('glm_members_locked_to_member_id', false); + $isModerated = apply_filters('glm_user_is_moderated', $lockedToMember); if ($lockedToMember) { $memberID = $lockedToMember; $this->fields['admin_name']['required'] = true; $this->fields['admin_email']['required'] = true; $this->fields['admin_phone']['required'] = true; - // Check for Member Menu Use + // Check for Member Menu Use } elseif (defined('GLM_EVENTS_MEMBER_MENU')) { // Try to get member ID @@ -240,150 +242,151 @@ class GlmMembersAdmin_events_list extends GlmDataEvents // Do selected option switch ($option) { - case 'add': + case 'add': - $event = $this->newEntry(); + $event = $this->newEntry(); - $view = 'edit'; - - break; + $view = 'edit'; - case 'insert': + break; - $event = $this->insertEntry(); + case 'insert': - $this->eventID = $event['fieldData']['id']; + $event = $this->insertEntry(); - $this->updateCategories(); - $categories = $Categories->getListSortedParentChild(false); + $this->eventID = $event['fieldData']['id']; - if ( $this->config['settings']['use_event_amenities'] ) { - $this->updateAmenities(); - $amenities = $Amenities->getList(false); - } + $this->updateCategories(); + $categories = $Categories->getListSortedParentChild(false); - if ($event['status']) { - $haveEvent = true; - $eventAdded = true; + if ( $this->config['settings']['use_event_amenities'] ) { + $this->updateAmenities(); + $amenities = $Amenities->getList(false); + } - // Update created timestamp and name slug for URLs - $this->updateTimestamp('created', $this->eventID); - $this->updateSlug($this->eventID); + if ($event['status']) { + $haveEvent = true; + $eventAdded = true; - // Look for location data - if (isset($_REQUEST['locID'])) { + // Update created timestamp and name slug for URLs + $this->updateTimestamp('created', $this->eventID); + $this->updateSlug($this->eventID); - // For each location - foreach ($_REQUEST['locID'] as $locID) { + // Look for location data + if (isset($_REQUEST['locID'])) { - // Set the nLoc{id}_event value to the new event - $_REQUEST[$locID.'_event'] = $this->eventID; + // For each location + foreach ($_REQUEST['locID'] as $locID) { - // Check for new cities in this location and if so use the new city real ID - if (isset($_REQEUST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') { - $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']]; - } + // Set the nLoc{id}_event value to the new event + $_REQUEST[$locID.'_event'] = $this->eventID; - // Check if it's a new Location - Here it will be - if ($locID[0] == 'n') { + // Check for new cities in this location and if so use the new city real ID + if (isset($_REQEUST[$locID.'_city']) && $_REQUEST[$locID.'_city'][0] == 'n') { + $_REQUEST[$locID.'_city'] = $newCityID[$_REQUEST[$locID.'_city']]; + } - // Add the new location - $x = $Locations->insertEntry(true, $locID.'_'); + // Check if it's a new Location - Here it will be + if ($locID[0] == 'n') { - } + // Add the new location + $x = $Locations->insertEntry(true, $locID.'_'); } } - // Look for recurrence data - if (isset($_REQUEST['recurID'])) { + } - // For each recurrence - foreach ($_REQUEST['recurID'] as $recurID) { + // Look for recurrence data + if (isset($_REQUEST['recurID'])) { + + // For each recurrence + foreach ($_REQUEST['recurID'] as $recurID) { - // Set the nRecur{id}_event value to the new event - $_REQUEST[$recurID.'_event'] = $this->eventID; + // Set the nRecur{id}_event value to the new event + $_REQUEST[$recurID.'_event'] = $this->eventID; - // first check if the event is an all-day event - if (isset($_REQUEST[$recurID.'_all_day'])) { + // first check if the event is an all-day event + if (isset($_REQUEST[$recurID.'_all_day'])) { + if ( isset( $_REQUEST[$recurID.'_start_date'] ) ) { // Then take the start date (date only) and stick it into the start time $red = explode(' ', $_REQUEST[$recurID.'_start_date']); $_REQUEST[$recurID.'_start_time'] = $red[0]." 00:00"; $_REQUEST[$recurID.'_end_time'] = $red[0]." 00:00"; - } + } - // Check if it's a new Recurrence - Here it will be - if ($recurID[0] == 'n') { + // Check if it's a new Recurrence - Here it will be + if ($recurID[0] == 'n') { - // Add the new recurrence - $x = $Recurrences->insertEntry(true, $recurID.'_'); + // Add the new recurrence + $x = $Recurrences->insertEntry(true, $recurID.'_'); - // And create time entries - $Recurrences->createRecurrenceTimesEntries($x['fieldData']['id'], true, true); + // And create time entries + $Recurrences->createRecurrenceTimesEntries($x['fieldData']['id'], true, true); - } + } - } + } - // Update our recurrences - $recurrences = $Recurrences->getList("T.event = ".$this->eventID); + // Update our recurrences + $recurrences = $Recurrences->getList("T.event = ".$this->eventID); - // Check for any updated recurrences - if (isset($_REQUEST['recurUpdated']) && count($_REQUEST['recurUpdated']) > 0) { - foreach ($_REQUEST['recurUpdated'] as $r) { + // Check for any updated recurrences + if (isset($_REQUEST['recurUpdated']) && count($_REQUEST['recurUpdated']) > 0) { + foreach ($_REQUEST['recurUpdated'] as $r) { - // If we have a recurID as a value, then update this recurrence times - if ($r) { - $Recurrences->createRecurrenceTimesEntries($r, true, true); - } + // If we have a recurID as a value, then update this recurrence times + if ($r) { + $Recurrences->createRecurrenceTimesEntries($r, true, true); } } - } - // Get this again so we have the created date - $event = $this->editEntry($this->eventID); - if ( $lockedToMember ) { - if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) { - $notification->sendAdminNotice( $member_id, $event ); - } + } + + // Get this again so we have the created date + $event = $this->editEntry($this->eventID); + if ( $isModerated ) { + if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) { + $notification->sendAdminNotice( $member_id, $event ); } + } - $option = 'edit'; - $eventAdded = true; + $option = 'edit'; + $eventAdded = true; - } else { - $option = 'add'; - $eventAddError = true; + } else { + $option = 'add'; + $eventAddError = true; - // Add any recurrence data that may have been submitted -// if (isset($_REQUEST[''])) { -// NOT COMPLETED -// } + // Add any recurrence data that may have been submitted + // if (isset($_REQUEST[''])) { + // NOT COMPLETED + // } - } + } - $view = 'edit'; + $view = 'edit'; - break; + break; - case 'edit': + case 'edit': - $event = $this->editEntry($this->eventID); + $event = $this->editEntry($this->eventID); - // If we have a good event - if ($event['status']) { - $haveEvent = true; - } + // If we have a good event + if ($event['status']) { + $haveEvent = true; + } - // If we're locked to a member as a contact user and the event member doesn't equal the contact member - if ($lockedToMember && $event['fieldData']['ref_dest_id'] != $lockedToMember) { + // If we're locked to a member as a contact user and the event member doesn't equal the contact member + if ($lockedToMember && $event['fieldData']['ref_dest_id'] != $lockedToMember) { $haveEvent = false; $event = false; } @@ -427,7 +430,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) { $notification->sendMemberNotice( $member_id, $event ); } - } else if ( $lockedToMember && $old_event_status == 10 && $new_status == 20 ) { + } else if ( $isModerated && $old_event_status == 10 && $new_status == 20 ) { if ( isset( $_REQUEST['ref_dest'] ) && $member_id = filter_var( $_REQUEST['ref_dest'] ) ) { $notification->sendAdminNotice( $member_id, $event ); } @@ -785,6 +788,7 @@ class GlmMembersAdmin_events_list extends GlmDataEvents $templateData = array( 'enable_members' => $enable_members, 'lockedToMember' => $lockedToMember, + 'isModerated' => $isModerated, 'option' => $option, 'events' => $events, 'haveEvents' => $haveEvents, diff --git a/views/admin/events/editStatus.html b/views/admin/events/editStatus.html index 5bd8b57..9e4b5fe 100644 --- a/views/admin/events/editStatus.html +++ b/views/admin/events/editStatus.html @@ -3,7 +3,9 @@ {if $lockedToMember} - + {if $isModerated} + + {/if} {/if} @@ -60,7 +62,7 @@ {/if} - {if !$lockedToMember} + {if !$isModerated}
{$event.fieldData.approved.datetime}
Status: -- 2.17.1