Update so not moderated member or contact can edit status of the event.
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Apr 2017 12:39:01 +0000 (08:39 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 3 Apr 2017 12:39:01 +0000 (08:39 -0400)
Created new template variable for isModerated using the filter for
checking if the member or contact is moderated.

index.php
models/admin/events/list.php
views/admin/events/editStatus.html

index 0e87755..1712a18 100644 (file)
--- 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 <cscott@gaslightmedia.com>
  * @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.
index 5b056e1..0245d05 100644 (file)
@@ -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,
index 5bd8b57..9e4b5fe 100644 (file)
@@ -3,7 +3,9 @@
     {if $lockedToMember}
     <input type="hidden" name="featured" value="{if $event.fieldData.featured.value}1{else}0{/if}">
     <input type="hidden" name="slideshow" value="{if $event.fieldData.slideshow.value}1{else}0{/if}">
-    <input type="hidden" name="status" value="20">
+        {if $isModerated}
+            <input type="hidden" name="status" value="20">
+        {/if}
     {/if}
 
     <table id="glm-table-descr" class="glm-admin-table glm-event-table">
@@ -60,7 +62,7 @@
             <td>{$event.fieldData.approved.datetime}</td>
         </tr>
 {/if}
-        {if !$lockedToMember}
+        {if !$isModerated}
         <tr>
             <th>Status:</th>
             <td>