Skip to content

Commit

Permalink
Keep counter Totals first for Event Types
Browse files Browse the repository at this point in the history
Resolves #2771
  • Loading branch information
respencer committed Jun 12, 2024
1 parent 9f91c08 commit 31059d2
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions src/EventNames.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
<?php

/*******************************************************************************
*
* filename : EventNames.php
* last change : 2005-09-10
* website : https://churchcrm.io
* copyright : Copyright 2005 Todd Pillars
*
* function : List all Church Events
*
*
* Modified by Stephen Shaffer, Oct 2006
* feature changes - added recurring defaults and customizable attendance count
* fields
*
******************************************************************************/

require 'Include/Config.php';
require 'Include/Functions.php';

Expand All @@ -24,20 +8,17 @@
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

AuthenticationManager::redirectHomeIfFalse(AuthenticationManager::getCurrentUser()->isAddEvent());
if (AuthenticationManager::getCurrentUser()->isAddEvent() === false) {
RedirectUtils::securityRedirect('AddEvent');
}

$sPageTitle = gettext('Edit Event Types');

require 'Include/Header.php';

//
// process the ACTION button inputs from the form page
//

if (isset($_POST['Action'])) {
switch (InputUtils::legacyFilterInput($_POST['Action'])) {
case 'CREATE':
// Insert into the event_name table
$eName = $_POST['newEvtName'];
$eTime = $_POST['newEvtStartTime'];
$eDOM = $_POST['newEvtRecurDOM'];
Expand All @@ -46,13 +27,15 @@
$eRecur = $_POST['newEvtTypeRecur'];
$eCntLst = $_POST['newEvtTypeCntLst'];
$eCntArray = array_filter(array_map('trim', explode(',', $eCntLst)));
$eCntArray[] = 'Total';
// Normally, the order should not matter. The problem arises if the
// subscript already exists among others. Here, keeping it at the
// head of the array would be needed in some (or most) PHP versions
// especially if it is used in loops that take a total value without
// being part of the rest of the array.
array_unshift($eCntArray, 'Total');
$eCntNum = count($eCntArray);
$theID = $_POST['theID'];

# We need to be able to handle database configurations where MySQL Strict mode is enabled. (#4273)
# See: https://dev.mysql.com/doc/refman/en/sql-mode.html#sql-mode-strict
# Special thanks to @chiebert (GitHub) for the fix!
$insert = "INSERT INTO event_types (type_name";
$values = " VALUES ('" . InputUtils::legacyFilterInput($eName) . "'";
if (!empty($eTime)) {
Expand Down

0 comments on commit 31059d2

Please sign in to comment.