Skip to content

Commit

Permalink
Merge pull request #6791 from ChurchCRM/bugs/quickfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DawoudIO authored Dec 30, 2023
2 parents b04444b + fc2c8ac commit 446dfd2
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 89 deletions.
7 changes: 2 additions & 5 deletions src/CartToEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@

// Was the form submitted?
if (isset($_POST['Submit']) && count($_SESSION['aPeopleCart']) > 0 && isset($_POST['EventID'])) {
// Get the PersonID
$iEventID = InputUtils::legacyFilterInput($_POST['EventID'], 'int');

// Loop through the session array
$iCount = 0;
foreach ($_SESSION['aPeopleCart'] as $element) {
// Enter ID into event
Expand All @@ -54,7 +52,7 @@
require 'Include/Header.php';

if (count($_SESSION['aPeopleCart']) > 0) {
$sSQL = 'SELECT * FROM events_event';
$sSQL = 'SELECT event_id, event_title FROM events_event';
$rsEvents = RunQuery($sSQL); ?>
<div class="card">
<p align="center"><?= gettext('Select the event to which you would like to add your cart') ?>:</p>
Expand All @@ -74,8 +72,7 @@
// Create the group select drop-down
echo '<select name="EventID">';
while ($aRow = mysqli_fetch_array($rsEvents)) {
extract($aRow);
echo '<option value="' . $event_id . '">' . $event_title . '</option>';
echo '<option value="' . $aRow['event_id'] . '">' . $aRow['event_title'] . '</option>';
}
echo '</select>'; ?>
</td>
Expand Down
12 changes: 7 additions & 5 deletions src/ChurchCRM/Service/TaskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
class TaskService
{
/**
* @var ObjectCollection|TaskInterface[]
* @var TaskInterface[]
*/
private $taskClasses;
private array $taskClasses;
private array $notificationClasses = [
// new LatestReleaseTask()
];
Expand Down Expand Up @@ -60,10 +60,12 @@ public function getCurrentUserTasks(): array
$tasks = [];
foreach ($this->taskClasses as $taskClass) {
if ($taskClass->isActive() && (!$taskClass->isAdmin() || ($taskClass->isAdmin() && AuthenticationManager::getCurrentUser()->isAdmin()))) {
$tasks[] = ['title' => $taskClass->getTitle(),
$tasks[] = [
'title' => $taskClass->getTitle(),
'link' => $taskClass->getLink(),
'admin' => $taskClass->isAdmin(),
'desc' => $taskClass->getDesc()];
'desc' => $taskClass->getDesc()
];
}
}

Expand All @@ -75,7 +77,7 @@ public function getTaskNotifications(): array
$tasks = [];
foreach ($this->notificationClasses as $taskClass) {
if ($taskClass->isActive()) {
$tasks[] = new UiNotification($taskClass->getTitle(), 'wrench', $taskClass->getLink(), $taskClass->getDesc(), $taskClass->isAdmin() ? 'warning' : 'info', '12000', 'bottom', 'left');
$tasks[] = new UiNotification($taskClass->getTitle(), 'wrench', $taskClass->getLink(), $taskClass->getDesc(), $taskClass->isAdmin() ? 'warning' : 'info', 12000, 'bottom', 'left');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/dto/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static function addPerson($PersonID): void
if (!is_numeric($PersonID)) {
throw new \Exception(gettext('PersonID for Cart must be numeric'), 400);
}
if ($PersonID !== null && !in_array($PersonID, $_SESSION['aPeopleCart'], false)) {
if (!in_array($PersonID, $_SESSION['aPeopleCart'], false)) {
$_SESSION['aPeopleCart'][] = (int)$PersonID;
}
}
Expand Down
29 changes: 10 additions & 19 deletions src/ChurchCRM/dto/ChurchCRMRelease.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@

class ChurchCRMRelease
{
/**
* @var string
*/
public $MAJOR;
/**
* @var string
*/
public $MINOR;
/**
* @var string
*/
public $PATCH;
public string $MAJOR;
public string $MINOR;
public string $PATCH;

private array $rawRelease;

Expand All @@ -30,10 +21,10 @@ public function __construct(array $releaseArray)

public function equals(ChurchCRMRelease $b): bool
{
return $this->MAJOR == $b->MAJOR && $this->MINOR == $b->MINOR && $this->PATCH == $b->PATCH;
return $this->MAJOR === $b->MAJOR && $this->MINOR === $b->MINOR && $this->PATCH === $b->PATCH;
}

public function compareTo(ChurchCRMRelease $b)
public function compareTo(ChurchCRMRelease $b): int
{
if ($this->MAJOR < $b->MAJOR) {
return -1;
Expand All @@ -59,21 +50,21 @@ public function compareTo(ChurchCRMRelease $b)
public function __toString(): string
{
try {
return (string) $this->MAJOR . '.' . $this->MINOR . '.' . $this->PATCH;
return $this->MAJOR . '.' . $this->MINOR . '.' . $this->PATCH;
} catch (\Exception $exception) {
return '';
}
}

public function getDownloadURL()
public function getDownloadURL(): string
{
foreach ($this->rawRelease['assets'] as $asset) {
if ($asset['name'] == 'ChurchCRM-' . $this->rawRelease['name'] . '.zip') {
$url = $asset['browser_download_url'];
return $asset['browser_download_url'];
}
}

return $url;
throw new \Exception('download url not found!');
}

public function getReleaseNotes(): string
Expand All @@ -85,6 +76,6 @@ public function isPreRelease(): bool
{
// yeah, it's a boolean in the JSON, but
// let's check it to be sure this function returns a boolean.
return $this->rawRelease['prerelease'] == true;
return (bool) $this->rawRelease['prerelease'] === true;
}
}
80 changes: 26 additions & 54 deletions src/ChurchCRM/dto/Notification/UiNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,25 @@

class UiNotification implements JsonSerializable
{
private $title;
private $message;
private $url;
private $type;
private $icon;
private $delay;
private $placement;
private $align;
private string $title;
private string $message;
private string $url;
private string $type;
private string $icon;
private int $delay;
private string $placement;
private string $align;

/**
* UiNotification constructor.
*
* @param $title
* @param $message
* @param $url
* @param $type
* @param $icon
* @param $delay
* @param $placement
* @param $align
*/
public function __construct($title, $icon, $url = '', $message = '', $type = 'info', $delay = 4000, $placement = 'top', $align = 'right')
{
public function __construct(
string $title,
string $icon,
string $url = '',
string $message = '',
string $type = 'info',
int $delay = 4000,
string $placement = 'top',
string $align = 'right'
) {
$this->title = $title;
$this->message = $message;
$this->url = $url;
Expand All @@ -39,66 +35,42 @@ public function __construct($title, $icon, $url = '', $message = '', $type = 'in
$this->align = $align;
}

/**
* @return mixed
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}

/**
* @return string
*/
public function getMessage()
public function getMessage(): string
{
return $this->message;
}

/**
* @return string
*/
public function getUrl()
public function getUrl(): string
{
return $this->url;
}

/**
* @return string
*/
public function getType()
public function getType(): string
{
return $this->type;
}

/**
* @return mixed
*/
public function getIcon()
public function getIcon(): string
{
return $this->icon;
}

/**
* @return int
*/
public function getDelay()
public function getDelay(): int
{
return $this->delay;
}

/**
* @return string
*/
public function getPlacement()
public function getPlacement(): string
{
return $this->placement;
}

/**
* @return string
*/
public function getAlign()
public function getAlign(): string
{
return $this->align;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/dto/SystemConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
class SystemConfig
{
/**
* @var Config[]
* @var Config[]|null
*/
private static ?array $configs = null;

Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/model/ChurchCRM/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public function getNumericCellPhone(): string
return '1' . preg_replace('/[^\.0-9]/', '', $this->getCellPhone());
}

public function postSave(ConnectionInterface $con = null)
public function postSave(ConnectionInterface $con = null): void
{
$this->getPhoto()->refresh();

Expand Down
2 changes: 0 additions & 2 deletions src/UserEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
use ChurchCRM\Utils\RedirectUtils;
use Propel\Runtime\ActiveQuery\Criteria;

;

// Security: User must be an Admin to access this page.
// Otherwise re-direct to the main menu.
if (!AuthenticationManager::getCurrentUser()->isAdmin()) {
Expand Down
2 changes: 1 addition & 1 deletion src/api/routes/system/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function getUiNotificationAPI(Request $request, Response $response, array $args)
}
$notifications = [];
foreach (NotificationService::getNotifications() as $notification) {
$uiNotification = new UiNotification($notification->title, 'bell', $notification->link, '', 'danger', '8000', 'bottom', 'left');
$uiNotification = new UiNotification($notification->getTitle(), 'bell', $notification->link, '', 'danger', 8000, 'bottom', 'left');
$notifications[] = $uiNotification;
}

Expand Down

0 comments on commit 446dfd2

Please sign in to comment.