{
$lockedToMember = false;
+ $isModerated = false;
$numbEvents = 0;
$option = 'list';
$events = false;
// 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
// 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;
}
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 );
}
$templateData = array(
'enable_members' => $enable_members,
'lockedToMember' => $lockedToMember,
+ 'isModerated' => $isModerated,
'option' => $option,
'events' => $events,
'haveEvents' => $haveEvents,