diff --git a/src/EventEditor.php b/src/EventEditor.php index ee976bbda5..3ff029a290 100644 --- a/src/EventEditor.php +++ b/src/EventEditor.php @@ -1,27 +1,5 @@ isAddEvent()); $sPageTitle = gettext('Church Event Editor'); -AuthenticationManager::redirectHomeIfFalse(AuthenticationManager::getCurrentUser()->isAddEvent()); +require 'Include/Header.php'; $sAction = 'Create Event'; -require 'Include/Header.php'; if (isset($_GET['calendarAction'])) { $sAction = 'Edit'; @@ -49,35 +27,28 @@ if (array_key_exists('EID', $_POST)) { $sOpp = $_POST['EID']; - } // from EDIT button on event listing + } if (array_key_exists('EN_tyid', $_POST)) { $tyid = $_POST['EN_tyid']; - } else { // from event type list page + } else { $tyid = 0; } } +$EventExists = 0; $iEventID = 0; $iErrors = 0; -if (!$sAction) { - $sAction = 'Create Event'; -} - -// -// process the action inputs -// if ($sAction === 'Create Event' && !empty($tyid)) { - // - // user is coming from the event types screen and thus there + + // User is coming from the event types screen and thus there // is no existing event in the event_event table // // will use the event type information to smart-prefill the // event fields...but still allow the user to edit everything // except event type since event type is tied to the attendance count fields - // - $EventExists = 0; + $sSQL = "SELECT * FROM event_types WHERE type_id=$tyid"; $rsOpps = RunQuery($sSQL); $numRows = mysqli_num_rows($rsOpps); @@ -112,10 +83,9 @@ } $nCnts = $iNumCounts; $sCountNotes = ''; - // - // this switch manages the smart-prefill of the form based on the event type + + // This switch manages the smart-prefill of the form based on the event type // definitions, recurrence type, etc. - // switch ($sDefRecurType) { case 'none': $sEventStartDate = date('Y-m-d'); @@ -128,13 +98,13 @@ break; case 'weekly': - // check for the last occurrence of this type_id in the events table and + // Check for the last occurrence of this type_id in the events table and // create a new event based on this date reference $sSQL = "SELECT * FROM events_event WHERE event_type = '$iTypeID' ORDER BY event_start DESC LIMIT 1"; $ecOpps = RunQuery($sSQL); $numRows = mysqli_num_rows($ecOpps); if ($numRows > 0) { - // use the most recent event if it exists + // Use the most recent event if it exists $ecRow = mysqli_fetch_array($ecOpps, MYSQLI_BOTH); extract($ecRow); $aStartTokens = explode(' ', $event_start); @@ -149,7 +119,7 @@ $iEventEndHour = $iEventStartHour + 1; $iEventEndMins = $iEventStartMins; } else { - // use the event type definition + // Use the event type definition $sEventStartDate = date('Y-m-d', strtotime("last $iDefRecurDOW")); $aStartTimeTokens = explode(':', $sDefStartTime); $iEventStartHour = $aStartTimeTokens[0]; @@ -161,13 +131,13 @@ break; case 'monthly': - // check for the last occurrence of this type_id in the events table and + // Check for the last occurrence of this type_id in the events table and // create a new event based on this date reference $sSQL = "SELECT * FROM events_event WHERE event_type = '$iTypeID' ORDER BY event_start DESC LIMIT 1"; $ecOpps = RunQuery($sSQL); $numRows = mysqli_num_rows($ecOpps); if ($numRows > 0) { - // use the most recent event if it exists + // Use the most recent event if it exists $ecRow = mysqli_fetch_array($ecOpps, MYSQLI_BOTH); extract($ecRow); $aStartTokens = explode(' ', $event_start); @@ -182,7 +152,7 @@ $iEventEndHour = intval($aEventStartTimeTokens[0]) + 1; $iEventEndMins = $aEventStartTimeTokens[1]; } else { - // use the event type definition + // Use the event type definition $currentDOM = date('d'); if ($currentDOM < $iDefRecurDOM) { $sEventStartDate = date('Y-m-d', mktime(0, 0, 0, date('m') - 1, $iDefRecurDOM, date('Y'))); @@ -204,7 +174,7 @@ $ecOpps = RunQuery($sSQL); $numRows = mysqli_num_rows($ecOpps); if ($numRows > 0) { - // use the most recent event if it exists + // Use the most recent event, if it exists $ecRow = mysqli_fetch_array($ecOpps, MYSQLI_BOTH); extract($ecRow); $aStartTokens = explode(' ', $event_start); @@ -219,15 +189,18 @@ $iEventEndHour = intval($aEventStartTimeTokens[0]) + 1; $iEventEndMins = $aEventStartTimeTokens[1]; } else { - // use the event type definition + // Use the event type definition $currentDOY = time(); $defaultDOY = strtotime($sDefRecurDOY); - if ($currentDOY < $defaultDOY) { // event is future + if ($currentDOY < $defaultDOY) { + // Event is in the future $sEventStartDate = $sDefRecurDOY; - } elseif ($currentDOY > $defaultDOY + (365 * 24 * 60 * 60)) { // event is over 1 year past + } elseif ($currentDOY > $defaultDOY + (365 * 24 * 60 * 60)) { + // Event is over 1 year in the past $aDMY = explode('-', $sDefRecurDOY); $sEventStartDate = date('Y-m-d', mktime(0, 0, 0, $aDMY[1], $aDMY[2], date('Y') - 1)); - } else { // event is past + } else { + // Event is past $aDMY = explode('-', $sDefRecurDOY); $sEventStartDate = date('Y-m-d', mktime(0, 0, 0, $aDMY[1], $aDMY[2], date('Y'))); } @@ -247,7 +220,6 @@ $iEventStatus = 0; $iTypeID = $type_id; } elseif ($sAction = 'Edit' && !empty($sOpp)) { - // Get data for the form as it now exists.. $EventExists = 1; $sSQL = "SELECT * FROM events_event as t1, event_types as t2 WHERE t1.event_type = t2.type_id AND t1.event_id ='" . $sOpp . "' LIMIT 1"; $rsOpps = RunQuery($sSQL); @@ -274,11 +246,11 @@ $iEventStatus = $inactive; $sSQL = "SELECT * FROM eventcounts_evtcnt WHERE evtcnt_eventid='$iEventID' ORDER BY evtcnt_countid ASC"; - // echo $cvSQL; + $cvOpps = RunQuery($sSQL); $iNumCounts = mysqli_num_rows($cvOpps); $nCnts = $iNumCounts; - // echo "numcounts = {$aNumCounts}\n\l"; + if ($iNumCounts) { for ($c = 0; $c < $iNumCounts; $c++) { $aRow = mysqli_fetch_array($cvOpps, MYSQLI_BOTH); @@ -290,7 +262,6 @@ } } } elseif (isset($_POST['SaveChanges'])) { - // Does the user want to save changes to text fields? $iEventID = $_POST['EventID']; $iTypeID = $_POST['EventTypeID']; $EventExists = $_POST['EventExists']; @@ -342,15 +313,14 @@ $sCountNotes = $_POST['EventCountNotes']; - // If no errors, then update. if ($iErrors === 0) { - if ($EventExists == 0) { + if ($EventExists === 0) { $event = new Event(); $event ->setType(InputUtils::legacyFilterInput($iTypeID)) ->setTitle(InputUtils::legacyFilterInput($sEventTitle)) ->setDesc(InputUtils::legacyFilterInput($sEventDesc)) - ->setText(InputUtils::filterHTML($sEventText)) + ->setText(InputUtils::legacyFilterInput($sEventText)) ->setStart(InputUtils::legacyFilterInput($sEventStart)) ->setEnd(InputUtils::legacyFilterInput($sEventEnd)) ->setInActive(InputUtils::legacyFilterInput($iEventStatus)); @@ -376,7 +346,7 @@ ->setType(InputUtils::legacyFilterInput($iTypeID)) ->setTitle(InputUtils::legacyFilterInput($sEventTitle)) ->setDesc(InputUtils::legacyFilterInput($sEventDesc)) - ->setText(InputUtils::filterHTML($sEventText)) + ->setText(InputUtils::legacyFilterInput($sEventText)) ->setStart(InputUtils::legacyFilterInput($sEventStart)) ->setEnd(InputUtils::legacyFilterInput($sEventEnd)) ->setInActive(InputUtils::legacyFilterInput($iEventStatus)); @@ -398,19 +368,17 @@ header('Location: ListEvents.php'); } } - -// Construct the form ?>
-

+

" . gettext('There were ') . $iErrors . gettext(' errors. Please see below') . '
'; - } else { + if ($iErrors === 0) { echo '
' . gettext('Items with a ') . '*' . gettext(' are required') . '
'; + } else { + echo "
" . gettext('There were ') . $iErrors . gettext(' errors. Please see below') . '
'; } ?>
@@ -450,7 +418,7 @@ + } else { ?> *: @@ -459,7 +427,6 @@ - *: @@ -480,15 +447,13 @@ - - @@ -504,8 +469,7 @@ + } ?>   @@ -513,8 +477,7 @@ + } ?> @@ -541,7 +504,7 @@ + } ?> diff --git a/src/EventNames.php b/src/EventNames.php index 6874483c1a..1f549e7740 100644 --- a/src/EventNames.php +++ b/src/EventNames.php @@ -1,21 +1,5 @@ " > $(document).ready(function () { -//Added by @saulowulhynek to translation of datatable nav terms $('#eventNames').DataTable(window.CRM.plugin.dataTable); });