Skip to content

Commit

Permalink
Less extract(), addtl code cleanup, update deps (#7137)
Browse files Browse the repository at this point in the history
### Description

This PR updates various dependencies and refactors code for improved
clarity and type safety.

### Key Changes

* Dependency Updates: Updated npm and composer packages
* Code Refactoring: Adjusted method signatures for better type safety.
* Replaced raw SQL queries with ORM methods for database interactions.
* Updated formatBirthDate method calls and other related methods.
  • Loading branch information
DAcodedBEAT authored Sep 8, 2024
2 parents 98cc314 + d9389a1 commit 1aa2e8e
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 490 deletions.
661 changes: 307 additions & 354 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,22 @@
"bootstrap-show-password": "^1.3.0",
"bootstrap-toggle": "^2.2.2",
"bootstrap-validator": "^0.11.9",
"chart.js": "^4.4.3",
"chart.js": "^4.4.4",
"ckeditor4": "^4.25.0",
"daterangepicker": "^3.1.0",
"flag-icons": "^7.2.2",
"flag-icons": "^7.2.3",
"fullcalendar": "^6.1.15",
"i18n": "^0.15.1",
"i18next": "^23.13.0",
"i18next": "^23.14.0",
"icheck-bootstrap": "^3.0.1",
"inputmask": "^5.0.8",
"inputmask": "^5.0.9",
"jquery": "^3.7.1",
"jquery-photo-uploader": "^1.0.13",
"jquery-steps": "^1.1.0",
"jquery-validation": "^1.21.0",
"pace-js": "^1.2.4",
"react-bootstrap": "^2.10.2",
"react-datepicker": "^6.9.0",
"react-bootstrap": "^2.10.4",
"react-datepicker": "^7.3.0",
"react-select": "^5.7.7",
"select2": "^4.0.13"
},
Expand All @@ -103,20 +103,20 @@
"grunt-lineending": "^1.0.0",
"grunt-sass": "^3.1.0",
"i18next-conv": "^15.0.0",
"i18next-parser": "^8.13.0",
"i18next-parser": "^9.0.2",
"node-sha1": "^1.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"sass": "^1.77.0",
"tar": "^7.1.0",
"prettier": "^3.3.3",
"sass": "^1.78.0",
"tar": "^7.4.3",
"ts-loader": "^9.5.1",
"typescript": "^5.4.5",
"typescript": "^5.5.4",
"webpack": "^5.94.0",
"webpack-cli": "^5.0.0"
},
"optionalDependencies": {
"cy-verify-downloads": "^0.2.4",
"cypress": "^13.9.0",
"cy-verify-downloads": "^0.2.5",
"cypress": "^13.14.2",
"grunt-poeditor-gd": "^0.2.1"
}
}
}
4 changes: 4 additions & 0 deletions react/components/Events/EventPropertiesEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const EventPropertiesEditor: React.FunctionComponent<{
timeIntervals={15}
dateFormat="MMMM d, yyyy h:mm aa"
timeCaption="time"
selectsRange
icon="fa fa-calendar"
/>
</td>
</tr>
Expand All @@ -95,6 +97,8 @@ const EventPropertiesEditor: React.FunctionComponent<{
timeIntervals={15}
dateFormat="MMMM d, yyyy h:mm aa"
timeCaption="time"
selectsRange
icon="fa fa-calendar"
/>
</td>
</tr>
Expand Down
5 changes: 3 additions & 2 deletions src/ChurchCRM/Reports/PDF_Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ChurchCRM\dto\SystemConfig;
use ChurchCRM\model\ChurchCRM\FamilyQuery;
use ChurchCRM\model\ChurchCRM\PersonCustomQuery;
use ChurchCRM\model\ChurchCRM\PersonQuery;
use ChurchCRM\Utils\MiscUtils;

Expand Down Expand Up @@ -286,10 +287,10 @@ public function sGetCustomString($rsCustomFields, $aRow): string
}
}

public function getBirthdayString($bDirBirthday, $per_BirthMonth, $per_BirthDay, $per_BirthYear, $per_Flags): string
public function getBirthdayString(bool $bDirBirthday, $per_BirthMonth, $per_BirthDay, $per_BirthYear, $per_Flags): string
{
if ($bDirBirthday && $per_BirthDay > 0 && $per_BirthMonth > 0) {
return MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, '/', $per_Flags);
return MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $per_Flags);
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/utils/MiscUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static function formatAge(int $Month, int $Day, ?int $Year = null): strin

// Format a BirthDate
// Optionally, the separator may be specified. Default is YEAR-MN-DY
public static function formatBirthDate($per_BirthYear, ?string $per_BirthMonth, ?string $per_BirthDay, $sSeparator, $bFlags): string
public static function formatBirthDate($per_BirthYear, ?string $per_BirthMonth, ?string $per_BirthDay, ?bool $bFlags = false): string
{
try {
$birthDate = MiscUtils::birthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay);
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/utils/RedirectUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RedirectUtils
*
* @throws \Exception
*/
public static function redirect($sRelativeURL): void
public static function redirect(string $sRelativeURL): void
{
if (substr($sRelativeURL, 0, 1) != '/') {
$sRelativeURL = '/' . $sRelativeURL;
Expand Down
24 changes: 9 additions & 15 deletions src/FundRaiserEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
$linkBack = InputUtils::legacyFilterInputArr($_GET, 'linkBack');
$iFundRaiserID = InputUtils::legacyFilterInputArr($_GET, 'FundRaiserID');

$fundraiser = null;
if ($iFundRaiserID > 0) {
// Get the current fund raiser record
$sSQL = 'SELECT * from fundraiser_fr WHERE fr_ID = ' . $iFundRaiserID;
$rsFRR = RunQuery($sSQL);
extract(mysqli_fetch_array($rsFRR));
// Get the current fundraiser record
$fundraiser = FundRaiserQuery::create()->findOneById($iFundRaiserID);
// Set current fundraiser
$_SESSION['iCurrentFundraiser'] = $iFundRaiserID;
}

if ($iFundRaiserID > 0) {
$sPageTitle = gettext('Fundraiser') . ' #' . $iFundRaiserID . ' ' . $fr_title;
if ($fundraiser) {
$sPageTitle = gettext('Fundraiser') . ' #' . $iFundRaiserID . ' ' . $fundraiser->getTitle();
} else {
$sPageTitle = gettext('Create New Fund Raiser');
}
Expand Down Expand Up @@ -89,17 +88,12 @@
} else {
//FirstPass
//Are we editing or adding?
if ($iFundRaiserID > 0) {
if ($fundraiser) {
//Editing....
//Get all the data on this record

$sSQL = 'SELECT * FROM fundraiser_fr WHERE fr_ID = ' . $iFundRaiserID;
$rsFundRaiser = RunQuery($sSQL);
extract(mysqli_fetch_array($rsFundRaiser));

$dDate = $fr_date;
$sTitle = $fr_title;
$sDescription = $fr_description;
$dDate = $fundraiser->getDate();
$sTitle = $fundraiser->getTitle();
$sDescription = $fundraiser->getDescription();
} else {
$dDate = '';
$sTitle = '';
Expand Down
9 changes: 4 additions & 5 deletions src/GroupPropsFormRowOps.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'Include/Functions.php';

use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\model\ChurchCRM\GroupQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand All @@ -14,15 +15,13 @@
$iGroupID = InputUtils::legacyFilterInput($_GET['GroupID'], 'int');
$iPropID = InputUtils::legacyFilterInput($_GET['PropID'], 'int');
$sField = InputUtils::legacyFilterInput($_GET['Field']);
$sAction = $_GET['Action'];
$sAction = InputUtils::legacyFilterInput($_GET['Action']);

// Get the group information
$sSQL = 'SELECT * FROM group_grp WHERE grp_ID = ' . $iGroupID;
$rsGroupInfo = RunQuery($sSQL);
extract(mysqli_fetch_array($rsGroupInfo));
$group = GroupQuery::create()->findOneById($iGroupID);

// Abort if user tries to load with group having no special properties.
if ($grp_hasSpecialProps == false) {
if (!$group->hasSpecialProps()) {
RedirectUtils::redirect('GroupView.php?GroupID=' . $iGroupID);
}

Expand Down
15 changes: 6 additions & 9 deletions src/NoteDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,18 @@
$iNoteID = InputUtils::legacyFilterInput($_GET['NoteID'], 'int');

// Get the data on this note
$sSQL = 'SELECT * FROM note_nte WHERE nte_ID = ' . $iNoteID;
$rsNote = RunQuery($sSQL);
extract(mysqli_fetch_array($rsNote));
$note = NoteQuery::create()->findOneById($iNoteID);

// If deleting a note for a person, set the PersonView page as the redirect
if ($nte_per_ID > 0) {
$sReroute = 'PersonView.php?PersonID=' . $nte_per_ID;
} elseif ($nte_fam_ID > 0) {
if ($note->getPerId() > 0) {
$sReroute = 'PersonView.php?PersonID=' . $note->getPerId();
} elseif ($note->getFamId() > 0) {
// If deleting a note for a family, set the FamilyView page as the redirect
$sReroute = 'v2/family/' . $nte_fam_ID;
$sReroute = 'v2/family/' . $note->getFamId();
}

// Do we have confirmation?
if (isset($_GET['Confirmed'])) {
$note = NoteQuery::create()->findPk($iNoteID);
$note->delete();

// Send back to the page they came from
Expand All @@ -47,7 +44,7 @@
<?= gettext('Please confirm deletion of this note') ?>:
</div>
<div class="card-body">
<?= $nte_Text ?>
<?= $note->getText() ?>
</div>
<div class="card-footer">
<a class="btn btn-default" href="<?php echo $sReroute ?>"><?= gettext('Cancel') ?></a>
Expand Down
2 changes: 1 addition & 1 deletion src/PrintView.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}

// Format the BirthDate
$dBirthDate = MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, '-', $per_Flags);
$dBirthDate = MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $per_Flags);

// Assign the values locally, after selecting whether to display the family or person information
SelectWhichAddress($sAddress1, $sAddress2, $per_Address1, $per_Address2, $fam_Address1, $fam_Address2, false);
Expand Down
18 changes: 8 additions & 10 deletions src/PropertyDelete.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
require 'Include/Functions.php';

use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\model\ChurchCRM\PropertyQuery;
use ChurchCRM\model\ChurchCRM\RecordPropertyQuery;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;

Expand All @@ -12,25 +14,21 @@
$sPageTitle = gettext('Property Delete Confirmation');

// Get the Type and Property
$sType = $_GET['Type'];
$sType = InputUtils::legacyFilterInput($_GET['Type']);
$iPropertyID = InputUtils::legacyFilterInput($_GET['PropertyID'], 'int');

// Do we have deletion confirmation?
if (isset($_GET['Confirmed'])) {
$sSQL = 'DELETE FROM property_pro WHERE pro_ID = ' . $iPropertyID;
RunQuery($sSQL);
PropertyQuery::create()->findOneByProId($iPropertyID)->delete();

$sSQL = 'DELETE FROM record2property_r2p WHERE r2p_pro_ID = ' . $iPropertyID;
RunQuery($sSQL);
$records = RecordPropertyQuery::create()->findByPropertyId($iPropertyID);
$records->delete();

RedirectUtils::redirect('PropertyList.php?Type=' . $sType);
}

// Get the family record in question
$sSQL = 'SELECT * FROM property_pro WHERE pro_ID = ' . $iPropertyID;
$rsProperty = RunQuery($sSQL);
extract(mysqli_fetch_array($rsProperty));

$property = PropertyQuery::create()->findOneByProId($iPropertyID);
require 'Include/Header.php';

?>
Expand All @@ -40,7 +38,7 @@
</p>

<p class="ShadedBox">
<?= $pro_Name ?>
<?= $property->getProName() ?>
</p>

<p>
Expand Down
4 changes: 2 additions & 2 deletions src/Reports/ConfirmReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public function finishPage($curY): void
$pdf->writeAtCell($XRole, $curY, $XEmail - $XRole, $sFamRole);
$pdf->writeAtCell($XEmail, $curY, $XBirthday - $XEmail, $per_Email);

$birthdayStr = MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $null, $null);
//If the "HideAge" check box is true, then create a Yes/No representation of the check box.
$birthdayStr = MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, false);
// If the "HideAge" check box is true, then create a Yes/No representation of the checkbox.
if ($per_Flags) {
$hideAgeStr = gettext('Yes');
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Reports/DirectoryReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
}

if ($bDirBirthday && $per_BirthMonth && $per_BirthDay) {
$pdf->sRecordName .= ' ' . MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, '/', $per_Flags);
$pdf->sRecordName .= ' ' . MiscUtils::formatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $per_Flags);
}

SelectWhichAddress($sAddress1, $sAddress2, $per_Address1, $per_Address2, $fam_Address1, $fam_Address2, false);
Expand Down
4 changes: 3 additions & 1 deletion src/Reports/PDFLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,10 @@ function GroupBySalutation(string $famID, $aAdultRole, $aChildRole)
return $aName;
}

function MakeADCArray($sADClist)
function MakeADCArray(string $sADClist): array
{
$aReturnArray = [];

// The end of each row is marked with the pipe | symbol
// keep fetching rows until gone
while (mb_substr_count($sADClist, '|')) {
Expand Down
Loading

0 comments on commit 1aa2e8e

Please sign in to comment.