';
- public static function FilterString($sInput)
- {
- // or use htmlspecialchars( stripslashes( ))
- return strip_tags(trim($sInput));
- }
+ public static function LegacyFilterInputArr($arr, $key, $type = 'string', $size = 1)
+ {
+ if (array_key_exists($key, $arr)) {
+ return InputUtils::LegacyFilterInput($arr[$key], $type, $size);
+ } else {
+ return InputUtils::LegacyFilterInput('', $type, $size);
+ }
+ }
+
+ public static function translate_special_charset($string)
+ {
+ if (empty($string)) {
+ return '';
+ }
- public static function FilterHTML($sInput)
- {
- return strip_tags(trim($sInput), self::$AllowedHTMLTags);
- }
+ return (SystemConfig::getValue('sCSVExportCharset') == 'UTF-8') ? gettext($string) : iconv('UTF-8', SystemConfig::getValue('sCSVExportCharset'), gettext($string));
+ }
- public static function FilterChar($sInput,$size=1)
- {
- return mb_substr(trim($sInput), 0, $size);
- }
+ public static function FilterString($sInput)
+ {
+ // or use htmlspecialchars( stripslashes( ))
+ return strip_tags(trim($sInput));
+ }
- public static function FilterInt($sInput)
- {
- return (int) intval(trim($sInput));
- }
+ public static function FilterHTML($sInput)
+ {
+ return strip_tags(trim($sInput), self::$AllowedHTMLTags);
+ }
- public static function FilterFloat($sInput)
- {
- return (float) floatval(trim($sInput));
- }
+ public static function FilterChar($sInput, $size = 1)
+ {
+ return mb_substr(trim($sInput), 0, $size);
+ }
- public static function FilterDate($sInput)
- {
- // Attempts to take a date in any format and convert it to YYYY-MM-DD format
- // Logel Philippe
- if (empty($sInput))
- return "";
- else
- return date('Y-m-d', strtotime(str_replace("/","-",$sInput)));
- }
+ public static function FilterInt($sInput)
+ {
+ return (int) intval(trim($sInput));
+ }
+
+ public static function FilterFloat($sInput)
+ {
+ return (float) floatval(trim($sInput));
+ }
+
+ public static function FilterDate($sInput)
+ {
+ // Attempts to take a date in any format and convert it to YYYY-MM-DD format
+ // Logel Philippe
+ if (empty($sInput)) {
+ return '';
+ } else {
+ return date('Y-m-d', strtotime(str_replace('/', '-', $sInput)));
+ }
+ }
- // Sanitizes user input as a security measure
- // Optionally, a filtering type and size may be specified. By default, strip any tags from a string.
- // Note that a database connection must already be established for the mysqli_real_escape_string function to work.
- public static function LegacyFilterInput($sInput, $type = 'string', $size = 1)
- {
- global $cnInfoCentral;
- if (strlen($sInput) > 0) {
- switch ($type) {
- case 'string':
- return mysqli_real_escape_string($cnInfoCentral, self::FilterString($sInput));
- case 'htmltext':
- return mysqli_real_escape_string($cnInfoCentral, self::FilterHTML($sInput));
- case 'char':
- return mysqli_real_escape_string($cnInfoCentral, self::FilterChar($sInput,$size));
- case 'int':
- return self::FilterInt($sInput);
- case 'float':
- return self::FilterFloat($sInput);
- case 'date':
- return self::FilterDate($sInput);
- }
- }
- else {
- return '';
+ // Sanitizes user input as a security measure
+ // Optionally, a filtering type and size may be specified. By default, strip any tags from a string.
+ // Note that a database connection must already be established for the mysqli_real_escape_string function to work.
+ public static function LegacyFilterInput($sInput, $type = 'string', $size = 1)
+ {
+ global $cnInfoCentral;
+ if (strlen($sInput) > 0) {
+ switch ($type) {
+ case 'string':
+ return mysqli_real_escape_string($cnInfoCentral, self::FilterString($sInput));
+ case 'htmltext':
+ return mysqli_real_escape_string($cnInfoCentral, self::FilterHTML($sInput));
+ case 'char':
+ return mysqli_real_escape_string($cnInfoCentral, self::FilterChar($sInput, $size));
+ case 'int':
+ return self::FilterInt($sInput);
+ case 'float':
+ return self::FilterFloat($sInput);
+ case 'date':
+ return self::FilterDate($sInput);
+ }
+ } else {
+ return '';
+ }
}
- }
}
-?>
diff --git a/src/ChurchCRM/utils/LoggerUtils.php b/src/ChurchCRM/utils/LoggerUtils.php
index 5871acb37b..daa7d3124f 100644
--- a/src/ChurchCRM/utils/LoggerUtils.php
+++ b/src/ChurchCRM/utils/LoggerUtils.php
@@ -2,12 +2,10 @@
namespace ChurchCRM\Utils;
-use Monolog\Handler\StreamHandler;
-use Monolog\Logger;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\dto\SystemURLs;
-use ChurchCRM\Utils\RemoteAddress;
-use ChurchCRM\Authentication\AuthenticationManager;
+use Monolog\Handler\StreamHandler;
+use Monolog\Logger;
class LoggerUtils
{
@@ -18,103 +16,111 @@ class LoggerUtils
private static $authLogHandler;
private static $correlationId;
- public static function GetCorrelationId() {
- if ( empty( self::$correlationId )) {
- self::$correlationId = uniqid();
- }
- return self::$correlationId;
+ public static function GetCorrelationId()
+ {
+ if (empty(self::$correlationId)) {
+ self::$correlationId = uniqid();
+ }
+
+ return self::$correlationId;
}
public static function getLogLevel()
{
- return intval(SystemConfig::getValue("sLogLevel"));
+ return intval(SystemConfig::getValue('sLogLevel'));
}
public static function buildLogFilePath($type)
{
- return $logFilePrefix = SystemURLs::getDocumentRoot() . '/logs/' . date("Y-m-d") . '-' . $type . '.log';
+ return $logFilePrefix = SystemURLs::getDocumentRoot().'/logs/'.date('Y-m-d').'-'.$type.'.log';
}
/**
* @return Logger
*/
- public static function getAppLogger($level=null)
+ public static function getAppLogger($level = null)
{
- if (is_null(self::$appLogger)){
- // if $level is null
- // (meaning this function was invoked without explicitly setting the level),
- // then get the level from the database
- if (is_null($level)) {
- $level = self::getLogLevel();
+ if (is_null(self::$appLogger)) {
+ // if $level is null
+ // (meaning this function was invoked without explicitly setting the level),
+ // then get the level from the database
+ if (is_null($level)) {
+ $level = self::getLogLevel();
+ }
+ self::$appLogger = new Logger('defaultLogger');
+ //hold a reference to the handler object so that ResetAppLoggerLevel can be called later on
+ self::$appLogHandler = new StreamHandler(self::buildLogFilePath('app'), $level);
+ self::$appLogger->pushHandler(self::$appLogHandler);
+ self::$appLogger->pushProcessor(function ($entry) {
+ $entry['extra']['url'] = $_SERVER['REQUEST_URI'];
+ $entry['extra']['remote_ip'] = $_SERVER['REMOTE_ADDR'];
+ $entry['extra']['correlation_id'] = self::GetCorrelationId();
+
+ return $entry;
+ });
}
- self::$appLogger = new Logger('defaultLogger');
- //hold a reference to the handler object so that ResetAppLoggerLevel can be called later on
- self::$appLogHandler = new StreamHandler(self::buildLogFilePath("app"), $level);
- self::$appLogger->pushHandler(self::$appLogHandler);
- self::$appLogger->pushProcessor(function ($entry) {
- $entry['extra']['url'] = $_SERVER['REQUEST_URI'];
- $entry['extra']['remote_ip'] = $_SERVER['REMOTE_ADDR'];
- $entry['extra']['correlation_id'] = self::GetCorrelationId();
- return $entry;
- });
- }
- return self::$appLogger;
+
+ return self::$appLogger;
}
- private static function getCaller() {
- $callers = debug_backtrace();
- $call = [];
- if ($callers[5]) {
- $call = $callers[5];
- }
- return [
- "ContextClass"=> array_key_exists("class",$call) ? $call['class'] : "",
- "ContextMethod"=> $call['function']
- ];
+ private static function getCaller()
+ {
+ $callers = debug_backtrace();
+ $call = [];
+ if ($callers[5]) {
+ $call = $callers[5];
+ }
+
+ return [
+ 'ContextClass' => array_key_exists('class', $call) ? $call['class'] : '',
+ 'ContextMethod'=> $call['function'],
+ ];
}
/**
* @return Logger
*/
- public static function getAuthLogger($level=null)
+ public static function getAuthLogger($level = null)
{
- if (is_null(self::$authLogger)){
- // if $level is null
- // (meaning this function was invoked without explicitly setting the level),
- // then get the level from the database
- if (is_null($level)) {
- $level = self::getLogLevel();
+ if (is_null(self::$authLogger)) {
+ // if $level is null
+ // (meaning this function was invoked without explicitly setting the level),
+ // then get the level from the database
+ if (is_null($level)) {
+ $level = self::getLogLevel();
+ }
+ self::$authLogger = new Logger('authLogger');
+ //hold a reference to the handler object so that ResetAppLoggerLevel can be called later on
+ self::$authLogHandler = new StreamHandler(self::buildLogFilePath('auth'), $level);
+ self::$authLogger->pushHandler(self::$authLogHandler);
+ self::$authLogger->pushProcessor(function ($entry) {
+ $entry['extra']['url'] = $_SERVER['REQUEST_URI'];
+ $entry['extra']['remote_ip'] = $_SERVER['REMOTE_ADDR'];
+ $entry['extra']['correlation_id'] = self::GetCorrelationId();
+ $entry['extra']['context'] = self::getCaller();
+
+ return $entry;
+ });
}
- self::$authLogger = new Logger('authLogger');
- //hold a reference to the handler object so that ResetAppLoggerLevel can be called later on
- self::$authLogHandler = new StreamHandler(self::buildLogFilePath("auth"), $level);
- self::$authLogger->pushHandler(self::$authLogHandler);
- self::$authLogger->pushProcessor(function ($entry) {
- $entry['extra']['url'] = $_SERVER['REQUEST_URI'];
- $entry['extra']['remote_ip'] = $_SERVER['REMOTE_ADDR'];
- $entry['extra']['correlation_id'] = self::GetCorrelationId();
- $entry['extra']['context'] = self::getCaller();
-
- return $entry;
- });
- }
- return self::$authLogger;
+
+ return self::$authLogger;
}
- public static function ResetAppLoggerLevel() {
- // if the app log handler was initialized (in the boostrapper) to a specific level
- // before the database initialization occurred
- // we provide a function to reset the app logger to what's defined in the database.
- self::$appLogHandler->setLevel(self::getLogLevel());
+ public static function ResetAppLoggerLevel()
+ {
+ // if the app log handler was initialized (in the boostrapper) to a specific level
+ // before the database initialization occurred
+ // we provide a function to reset the app logger to what's defined in the database.
+ self::$appLogHandler->setLevel(self::getLogLevel());
}
public static function getCSPLogger()
{
- if (is_null(self::$cspLogger)){
- self::$cspLogger = new Logger('cspLogger');
- self::$cspLogger->pushHandler(new StreamHandler(self::buildLogFilePath("csp"), self::getLogLevel()));
- }
- return self::$cspLogger;
- }
+ if (is_null(self::$cspLogger)) {
+ self::$cspLogger = new Logger('cspLogger');
+ self::$cspLogger->pushHandler(new StreamHandler(self::buildLogFilePath('csp'), self::getLogLevel()));
+ }
-}
\ No newline at end of file
+ return self::$cspLogger;
+ }
+}
diff --git a/src/ChurchCRM/utils/MiscUtils.php b/src/ChurchCRM/utils/MiscUtils.php
index dd43baaeeb..dace6e0a15 100644
--- a/src/ChurchCRM/utils/MiscUtils.php
+++ b/src/ChurchCRM/utils/MiscUtils.php
@@ -1,126 +1,134 @@
y < 1)
- return sprintf(ngettext('%d month old', '%d months old', $age->m), $age->m);
-
- return sprintf(ngettext('%d year old', '%d years old', $age->y), $age->y);
+
+ public static function getPhotoCacheExpirationTimestamp()
+ {
+ $cacheLength = SystemConfig::getValue('iPhotoClientCacheDuration');
+ $cacheLength = MiscUtils::getRandomCache($cacheLength, 0.5 * $cacheLength);
+
+ //echo time() + $cacheLength;
+ //die();
+ return time() + $cacheLength;
}
- // Format a BirthDate
- // Optionally, the separator may be specified. Default is YEAR-MN-DY
- public static function FormatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $sSeparator, $bFlags)
- {
- $birthDate = MiscUtils::BirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay);
- if (!$birthDate) {
+ public static function FormatAge($Month, $Day, $Year, $Flags)
+ {
+ if ($Flags || is_null($Year) || $Year == '') {
+ return;
+ }
+
+ $birthDate = MiscUtils::BirthDate($Year, $Month, $Day);
+ $ageSuffix = gettext('Unknown');
+ $ageValue = 0;
+
+ $now = date_create('today');
+ $age = date_diff($now, $birthDate);
+
+ if ($age->y < 1) {
+ return sprintf(ngettext('%d month old', '%d months old', $age->m), $age->m);
+ }
+
+ return sprintf(ngettext('%d year old', '%d years old', $age->y), $age->y);
+ }
+
+ // Format a BirthDate
+ // Optionally, the separator may be specified. Default is YEAR-MN-DY
+ public static function FormatBirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay, $sSeparator, $bFlags)
+ {
+ $birthDate = MiscUtils::BirthDate($per_BirthYear, $per_BirthMonth, $per_BirthDay);
+ if (!$birthDate) {
+ return false;
+ }
+ if ($bFlags || is_null($per_BirthYear) || $per_BirthYear == '') {
+ return $birthDate->format(SystemConfig::getValue('sDateFormatNoYear'));
+ } else {
+ return $birthDate->format(SystemConfig::getValue('sDateFormatLong'));
+ }
+ }
+
+ public static function BirthDate($year, $month, $day)
+ {
+ if (!is_null($day) && $day != '' && !is_null($month) && $month != '') {
+ if (is_null($year) || $year == '') {
+ $year = 1900;
+ }
+
+ return date_create($year.'-'.$month.'-'.$day);
+ }
+
return false;
- }
- if ($bFlags || is_null($per_BirthYear) || $per_BirthYear == '')
- {
- return $birthDate->format(SystemConfig::getValue("sDateFormatNoYear"));
- }
- else
- {
- return $birthDate->format(SystemConfig::getValue("sDateFormatLong"));
- }
- }
-
- public static function BirthDate($year, $month, $day)
- {
- if (!is_null($day) && $day != '' && !is_null($month) && $month != '') {
- if (is_null($year) || $year == '')
- {
- $year = 1900;
+ }
+
+ public static function GetGitHubWikiAnchorLink($text)
+ {
+ // roughly adapted from https://gist.github.com/asabaylus/3071099#gistcomment-1593627
+ $anchor = strtolower($text);
+ $anchor = preg_replace('/[^\w\d\- ]+/', '', $anchor);
+ $anchor = preg_replace('/\s/', '-', $anchor);
+ $anchor = preg_replace('/\-+$/', '', $anchor);
+ $anchor = str_replace(' ', '-', $anchor);
+
+ return $anchor;
+ }
+
+ public static function dashesToCamelCase($string, $capitalizeFirstCharacter = false)
+ {
+ $str = str_replace(' ', '', ucwords(str_replace('-', ' ', $string)));
+
+ if (!$capitalizeFirstCharacter) {
+ $str[0] = strtolower($str[0]);
}
- return date_create($year . '-' . $month . '-' . $day);
- }
- return false;
- }
-
- public static function GetGitHubWikiAnchorLink($text) {
- // roughly adapted from https://gist.github.com/asabaylus/3071099#gistcomment-1593627
- $anchor = strtolower($text);
- $anchor = preg_replace('/[^\w\d\- ]+/','',$anchor);
- $anchor = preg_replace('/\s/','-',$anchor);
- $anchor = preg_replace('/\-+$/','',$anchor);
- $anchor = str_replace(" ", "-", $anchor);
- return $anchor;
- }
-
- public static function dashesToCamelCase($string, $capitalizeFirstCharacter = false)
- {
- $str = str_replace(' ', '', ucwords(str_replace('-', ' ', $string)));
-
- if (!$capitalizeFirstCharacter) {
- $str[0] = strtolower($str[0]);
- }
-
- return $str;
- }
-}
-?>
+ return $str;
+ }
+}
diff --git a/src/ChurchCRM/utils/ORMUtils.php b/src/ChurchCRM/utils/ORMUtils.php
index 046f41a9a3..d23c0b2ce6 100644
--- a/src/ChurchCRM/utils/ORMUtils.php
+++ b/src/ChurchCRM/utils/ORMUtils.php
@@ -2,15 +2,15 @@
namespace ChurchCRM\Utils;
-
class ORMUtils
{
public static function getValidationErrors($failures)
{
$validationErrors = [];
foreach ($failures as $failure) {
- array_push($validationErrors, "Property " . $failure->getPropertyPath() . ": " . $failure->getMessage());
+ array_push($validationErrors, 'Property '.$failure->getPropertyPath().': '.$failure->getMessage());
}
+
return $validationErrors;
}
}
diff --git a/src/ChurchCRM/utils/PHPToMomentJSConverter.php b/src/ChurchCRM/utils/PHPToMomentJSConverter.php
index 5fa58e1cf0..b1412e7287 100644
--- a/src/ChurchCRM/utils/PHPToMomentJSConverter.php
+++ b/src/ChurchCRM/utils/PHPToMomentJSConverter.php
@@ -2,14 +2,15 @@
namespace ChurchCRM\Utils;
-/*
+/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-class PHPToMomentJSConverter {
- private static $replacements = [
+class PHPToMomentJSConverter
+{
+ private static $replacements = [
'd' => 'DD',
'D' => 'ddd',
'j' => 'D',
@@ -48,9 +49,12 @@ class PHPToMomentJSConverter {
'r' => '', // no equivalent
'U' => 'X',
];
- public static function ConvertFormatString($string){
- //borrowed from https://stackoverflow.com/questions/30186611/php-dateformat-to-moment-js-format
- $momentFormat = strtr($string, self::$replacements );
- return $momentFormat;
- }
-}
\ No newline at end of file
+
+ public static function ConvertFormatString($string)
+ {
+ //borrowed from https://stackoverflow.com/questions/30186611/php-dateformat-to-moment-js-format
+ $momentFormat = strtr($string, self::$replacements);
+
+ return $momentFormat;
+ }
+}
diff --git a/src/ChurchCRM/utils/RedirectUtils.php b/src/ChurchCRM/utils/RedirectUtils.php
index e05ad0037c..72e605dff0 100644
--- a/src/ChurchCRM/utils/RedirectUtils.php
+++ b/src/ChurchCRM/utils/RedirectUtils.php
@@ -6,35 +6,36 @@
class RedirectUtils
{
-
/**
* Convert a relative URL into an absolute URL and redirect the browser there.
+ *
* @param string $sRelativeURL
+ *
* @throws \Exception
*/
public static function Redirect($sRelativeURL)
{
- if (substr($sRelativeURL, 0,1) != "/") {
- $sRelativeURL = "/" . $sRelativeURL;
+ if (substr($sRelativeURL, 0, 1) != '/') {
+ $sRelativeURL = '/'.$sRelativeURL;
}
if (substr($sRelativeURL, 0, strlen(SystemURLs::getRootPath())) != SystemURLs::getRootPath()) {
- $finalLocation = SystemURLs::getRootPath() . $sRelativeURL;
+ $finalLocation = SystemURLs::getRootPath().$sRelativeURL;
} else {
$finalLocation = $sRelativeURL;
}
- header('Location: ' . $finalLocation);
+ header('Location: '.$finalLocation);
exit;
}
- public static function AbsoluteRedirect($sTargetURL) {
- header('Location: ' . $sTargetURL);
+ public static function AbsoluteRedirect($sTargetURL)
+ {
+ header('Location: '.$sTargetURL);
exit;
}
-
-
- public static function SecurityRedirect($missingRole) {
- LoggerUtils::getAppLogger()->info("Security Redirect Request due to Role: " . $missingRole);
- self::Redirect("Menu.php");
+
+ public static function SecurityRedirect($missingRole)
+ {
+ LoggerUtils::getAppLogger()->info('Security Redirect Request due to Role: '.$missingRole);
+ self::Redirect('Menu.php');
}
-
}
diff --git a/src/ConvertIndividualToFamily.php b/src/ConvertIndividualToFamily.php
index 5191d7f791..dee5089340 100644
--- a/src/ConvertIndividualToFamily.php
+++ b/src/ConvertIndividualToFamily.php
@@ -23,8 +23,8 @@
require 'Include/Config.php';
require 'Include/Functions.php';
-use ChurchCRM\Utils\RedirectUtils;
use ChurchCRM\Authentication\AuthenticationManager;
+use ChurchCRM\Utils\RedirectUtils;
// Security
if (!AuthenticationManager::GetCurrentUser()->isAdmin()) {
diff --git a/src/DonatedItemReplicate.php b/src/DonatedItemReplicate.php
index fb5a2337cd..4db0283c71 100644
--- a/src/DonatedItemReplicate.php
+++ b/src/DonatedItemReplicate.php
@@ -12,9 +12,9 @@
require 'Include/Config.php';
require 'Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
$iFundRaiserID = $_SESSION['iCurrentFundraiser'];
$iDonatedItemID = InputUtils::LegacyFilterInputArr($_GET, 'DonatedItemID', 'int');
diff --git a/src/FamilyCustomFieldsRowOps.php b/src/FamilyCustomFieldsRowOps.php
index 2526e5afa9..c955acbfbe 100644
--- a/src/FamilyCustomFieldsRowOps.php
+++ b/src/FamilyCustomFieldsRowOps.php
@@ -13,9 +13,9 @@
require 'Include/Config.php';
require 'Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security: user must be administrator to use this page.
if (!AuthenticationManager::GetCurrentUser()->isAdmin()) {
diff --git a/src/FamilyVerify.php b/src/FamilyVerify.php
index 2b3e109623..8958bcf8da 100644
--- a/src/FamilyVerify.php
+++ b/src/FamilyVerify.php
@@ -9,7 +9,7 @@
//Get the FamilyID out of the querystring
$iFamilyID = InputUtils::LegacyFilterInput($_GET['FamilyID'], 'int');
-$family = FamilyQuery::create()
+$family = FamilyQuery::create()
->findOneById($iFamilyID);
$family->verify();
diff --git a/src/GroupPropsFormRowOps.php b/src/GroupPropsFormRowOps.php
index 1d8cba398e..03c85db686 100644
--- a/src/GroupPropsFormRowOps.php
+++ b/src/GroupPropsFormRowOps.php
@@ -12,9 +12,9 @@
require 'Include/Config.php';
require 'Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security: user must be allowed to edit records to use this page.
if (!AuthenticationManager::GetCurrentUser()->isManageGroupsEnabled()) {
diff --git a/src/Include/CanvassUtilities.php b/src/Include/CanvassUtilities.php
index d925a92aad..5e5de8c82c 100644
--- a/src/Include/CanvassUtilities.php
+++ b/src/Include/CanvassUtilities.php
@@ -100,7 +100,7 @@ function CanvassAssignNonPledging($groupName, $iFYID)
$pledgeCount = mysqli_num_rows($rsPledges);
if ($pledgeCount == 0) {
- ++$numFamilies;
+ $numFamilies++;
if (!($aCanvasser = mysqli_fetch_array($rsCanvassers))) {
mysqli_data_seek($rsCanvassers, 0);
$aCanvasser = mysqli_fetch_array($rsCanvassers);
diff --git a/src/Include/Header-Security.php b/src/Include/Header-Security.php
index 1403023e95..2ab26d6826 100644
--- a/src/Include/Header-Security.php
+++ b/src/Include/Header-Security.php
@@ -6,10 +6,10 @@
* and open the template in the editor.
*/
-use ChurchCRM\dto\SystemURLs;
use ChurchCRM\dto\SystemConfig;
+use ChurchCRM\dto\SystemURLs;
-$csp = array(
+$csp = [
"default-src 'self'",
"script-src 'unsafe-eval' 'self' 'nonce-".SystemURLs::getCSPNonce()."' browser-update.org",
"object-src 'none'",
@@ -19,10 +19,10 @@
"frame-src 'self'",
"font-src 'self' fonts.gstatic.com",
"connect-src 'self'",
- "report-uri ".SystemURLs::getRootPath()."/api/system/background/csp-report"
-);
-if (SystemConfig::getBooleanValue("bHSTSEnable")) {
+ 'report-uri '.SystemURLs::getRootPath().'/api/system/background/csp-report',
+];
+if (SystemConfig::getBooleanValue('bHSTSEnable')) {
header('Strict-Transport-Security: max-age=31536000; includeSubDomains');
}
header('X-Frame-Options: SAMEORIGIN');
-header("Content-Security-Policy-Report-Only:".join(";", $csp));
+header('Content-Security-Policy-Report-Only:'.join(';', $csp));
diff --git a/src/Include/slim/error-handler.php b/src/Include/slim/error-handler.php
index 4088e599bf..f150b54505 100644
--- a/src/Include/slim/error-handler.php
+++ b/src/Include/slim/error-handler.php
@@ -3,11 +3,11 @@
$container['errorHandler'] = function ($container) {
return function ($request, $response, $exception) use ($container) {
$data = [
- 'code' => $exception->getCode(),
+ 'code' => $exception->getCode(),
'message' => $exception->getMessage(),
- 'file' => $exception->getFile(),
- 'line' => $exception->getLine(),
- 'trace' => explode("\n", $exception->getTraceAsString())
+ 'file' => $exception->getFile(),
+ 'line' => $exception->getLine(),
+ 'trace' => explode("\n", $exception->getTraceAsString()),
];
return $container->get('response')->withStatus(500)
@@ -21,7 +21,7 @@
return $container['response']
->withStatus(404)
->withHeader('Content-Type', 'text/html')
- ->write("Can't find route for " . $request->getMethod() . ' on ' . $request->getUri());
+ ->write("Can't find route for ".$request->getMethod().' on '.$request->getUri());
};
};
@@ -31,6 +31,6 @@
->withStatus(405)
->withHeader('Allow', implode(', ', $methods))
->withHeader('Content-type', 'text/html')
- ->write('Method must be one of: ' . implode(', ', $methods));
+ ->write('Method must be one of: '.implode(', ', $methods));
};
};
diff --git a/src/Include/winlocalelist.php b/src/Include/winlocalelist.php
index b99a44aae9..cad35989e2 100644
--- a/src/Include/winlocalelist.php
+++ b/src/Include/winlocalelist.php
@@ -2,68 +2,68 @@
$lang_map_windows =
[
- 'cs' => 'csy',
- 'cs_cs' => 'csy',
- 'cs_cz' => 'csy',
- 'cz' => 'csy',
- 'cz_cz' => 'csy',
- 'da' => 'dan',
- 'da_da' => 'dan',
- 'de' => 'deu',
- 'de_at' => 'dea',
- 'de_ch' => 'des',
- 'de_de' => 'deu',
- 'el' => 'ell',
- 'el_el' => 'ell',
- 'el_gr' => 'ell',
- 'en' => 'eng',
- 'en_au' => 'ena',
- 'en_ca' => 'enc',
- 'en_en' => 'eng',
- 'en_ie' => 'eng',
- 'en_nz' => 'enz',
- 'en_gb' => 'eng',
- 'en_us' => 'usa',
- 'es' => 'esp',
- 'es_es' => 'esp',
- 'es_mx' => 'esm',
- 'fi' => 'fin',
- 'fi_fi' => 'fin',
- 'fr' => 'fra',
- 'fr_be' => 'frb',
- 'fr_ca' => 'frc',
- 'fr_ch' => 'frs',
- 'fr_fr' => 'fra',
- 'it' => 'ita',
- 'it_ch' => 'its',
- 'it_it' => 'its',
- 'ja' => 'jpn',
- 'ja_ja' => 'jpn',
- 'ja_jp' => 'jpn',
- 'ko' => 'kor',
- 'ko_ko' => 'kor',
- 'ko_kr' => 'kor',
- 'nl' => 'nld',
- 'nl_be' => 'nlb',
- 'nl_nl' => 'nld',
- 'no' => 'norwegian',
- 'no_no' => 'norwegian',
- 'nb' => 'nor',
- 'nb_nb' => 'nor',
- 'nn' => 'non',
- 'nn_nn' => 'non',
- 'pl' => 'plk',
- 'pl_pl' => 'plk',
- 'pt' => 'ptg',
- 'pt_br' => 'ptb',
- 'pt_pt' => 'ptg',
- 'sv' => 'sve',
- 'sv_se' => 'sve',
- 'sv_sv' => 'sve',
- 'zh' => 'chinese',
- 'zh_tw' => 'cht',
- 'zh_cn' => 'chs',
- 'zh_hk' => 'cht',
- 'zh_sg' => 'cht',
- 'zh_zh' => 'chinese',
+ 'cs' => 'csy',
+ 'cs_cs' => 'csy',
+ 'cs_cz' => 'csy',
+ 'cz' => 'csy',
+ 'cz_cz' => 'csy',
+ 'da' => 'dan',
+ 'da_da' => 'dan',
+ 'de' => 'deu',
+ 'de_at' => 'dea',
+ 'de_ch' => 'des',
+ 'de_de' => 'deu',
+ 'el' => 'ell',
+ 'el_el' => 'ell',
+ 'el_gr' => 'ell',
+ 'en' => 'eng',
+ 'en_au' => 'ena',
+ 'en_ca' => 'enc',
+ 'en_en' => 'eng',
+ 'en_ie' => 'eng',
+ 'en_nz' => 'enz',
+ 'en_gb' => 'eng',
+ 'en_us' => 'usa',
+ 'es' => 'esp',
+ 'es_es' => 'esp',
+ 'es_mx' => 'esm',
+ 'fi' => 'fin',
+ 'fi_fi' => 'fin',
+ 'fr' => 'fra',
+ 'fr_be' => 'frb',
+ 'fr_ca' => 'frc',
+ 'fr_ch' => 'frs',
+ 'fr_fr' => 'fra',
+ 'it' => 'ita',
+ 'it_ch' => 'its',
+ 'it_it' => 'its',
+ 'ja' => 'jpn',
+ 'ja_ja' => 'jpn',
+ 'ja_jp' => 'jpn',
+ 'ko' => 'kor',
+ 'ko_ko' => 'kor',
+ 'ko_kr' => 'kor',
+ 'nl' => 'nld',
+ 'nl_be' => 'nlb',
+ 'nl_nl' => 'nld',
+ 'no' => 'norwegian',
+ 'no_no' => 'norwegian',
+ 'nb' => 'nor',
+ 'nb_nb' => 'nor',
+ 'nn' => 'non',
+ 'nn_nn' => 'non',
+ 'pl' => 'plk',
+ 'pl_pl' => 'plk',
+ 'pt' => 'ptg',
+ 'pt_br' => 'ptb',
+ 'pt_pt' => 'ptg',
+ 'sv' => 'sve',
+ 'sv_se' => 'sve',
+ 'sv_sv' => 'sve',
+ 'zh' => 'chinese',
+ 'zh_tw' => 'cht',
+ 'zh_cn' => 'chs',
+ 'zh_hk' => 'cht',
+ 'zh_sg' => 'cht',
+ 'zh_zh' => 'chinese',
];
diff --git a/src/Menu.php b/src/Menu.php
index 81785096e4..1b0e850b30 100644
--- a/src/Menu.php
+++ b/src/Menu.php
@@ -1,4 +1,5 @@
isAdmin()) {
diff --git a/src/Reports/AdvancedDeposit.php b/src/Reports/AdvancedDeposit.php
index cdf6d3122b..c3fa86c47f 100644
--- a/src/Reports/AdvancedDeposit.php
+++ b/src/Reports/AdvancedDeposit.php
@@ -10,11 +10,11 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
@@ -329,7 +329,7 @@ public function Headings($curY)
public function FinishPage($page)
{
- $footer = "Page $page Generated on ".date(SystemConfig::getValue("sDateTimeFormat"));
+ $footer = "Page $page Generated on ".date(SystemConfig::getValue('sDateTimeFormat'));
$this->SetFont('Times', 'I', 9);
$this->WriteAt(80, 258, $footer);
}
@@ -877,10 +877,10 @@ public function FinishPage($page)
}
$pdf->FinishPage($page);
- $pdf->Output('DepositReport-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('DepositReport-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
- // Output a text file
- // ##################
+// Output a text file
+// ##################
} elseif ($output == 'csv') {
// Settings
$delimiter = ',';
@@ -908,6 +908,6 @@ public function FinishPage($page)
// Export file
header('Content-type: text/x-csv');
- header("Content-Disposition: attachment; filename='ChurchCRM".date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+ header("Content-Disposition: attachment; filename='ChurchCRM".date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
echo $buffer;
}
diff --git a/src/Reports/CanvassReports.php b/src/Reports/CanvassReports.php
index d08ba95375..7e45b69885 100644
--- a/src/Reports/CanvassReports.php
+++ b/src/Reports/CanvassReports.php
@@ -14,7 +14,7 @@
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\PDF_CanvassBriefingReport;
use ChurchCRM\Utils\InputUtils;
-use \ChurchCRM\Utils\MiscUtils;
+use ChurchCRM\Utils\MiscUtils;
//Get the Fiscal Year ID out of the querystring
$iFYID = InputUtils::LegacyFilterInput($_GET['FYID'], 'int');
@@ -43,7 +43,7 @@ function CanvassProgressReport($iFYID)
$curY = 10;
$pdf->SetFont('Times', '', 24);
- $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Canvass Progress Report').' '.date(SystemConfig::getValue("sDateFormatLong")));
+ $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Canvass Progress Report').' '.date(SystemConfig::getValue('sDateFormatLong')));
$pdf->SetFont('Times', '', 14);
$curY += 10;
@@ -99,7 +99,7 @@ function CanvassProgressReport($iFYID)
$rsCanvassData = RunQuery($sSQL);
if (mysqli_num_rows($rsCanvassData) == 1) {
- ++$thisCanvasserDone;
+ $thisCanvasserDone++;
}
}
@@ -129,7 +129,7 @@ function CanvassProgressReport($iFYID)
$percentStr = sprintf('%.0f%%', ($totalDone / $totalToDo) * 100);
$pdf->WriteAt($percentX, $curY, $percentStr);
- $pdf->Output('CanvassProgress'.date(SystemConfig::getValue("sDateFormatLong")).'.pdf', 'D');
+ $pdf->Output('CanvassProgress'.date(SystemConfig::getValue('sDateFormatLong')).'.pdf', 'D');
}
function CanvassBriefingSheets($iFYID)
@@ -304,7 +304,7 @@ function CanvassBriefingSheets($iFYID)
$pdf->AddPage();
}
- $pdf->Output('CanvassBriefing'.date(SystemConfig::getValue("sDateFormatLong")).'.pdf', 'D');
+ $pdf->Output('CanvassBriefing'.date(SystemConfig::getValue('sDateFormatLong')).'.pdf', 'D');
}
function CanvassSummaryReport($iFYID)
@@ -318,7 +318,7 @@ function CanvassSummaryReport($iFYID)
$pdf->SetFont('Times', '', 24);
- $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Canvass Summary Report').' '.date(SystemConfig::getValue("sDateFormatLong")));
+ $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Canvass Summary Report').' '.date(SystemConfig::getValue('sDateFormatLong')));
$pdf->SetFont('Times', '', 14);
@@ -359,7 +359,7 @@ function CanvassSummaryReport($iFYID)
mysqli_data_seek($rsCanvassData, 0);
}
- $pdf->Output('CanvassSummary'.date(SystemConfig::getValue("sDateFormatLong")).'.pdf', 'D');
+ $pdf->Output('CanvassSummary'.date(SystemConfig::getValue('sDateFormatLong')).'.pdf', 'D');
}
function CanvassNotInterestedReport($iFYID)
@@ -372,7 +372,7 @@ function CanvassNotInterestedReport($iFYID)
$curY = 10;
$pdf->SetFont('Times', '', 24);
- $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Canvass Not Interested Report').' '.date(SystemConfig::getValue("sDateFormatLong")));
+ $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Canvass Not Interested Report').' '.date(SystemConfig::getValue('sDateFormatLong')));
$pdf->SetFont('Times', '', 14);
$curY += 10;
@@ -402,7 +402,7 @@ function CanvassNotInterestedReport($iFYID)
}
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
- $pdf->Output('CanvassNotInterested'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('CanvassNotInterested'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
}
if ($sWhichReport == 'Briefing') {
diff --git a/src/Reports/ClassAttendance.php b/src/Reports/ClassAttendance.php
index fd4397b777..068e50e9b5 100644
--- a/src/Reports/ClassAttendance.php
+++ b/src/Reports/ClassAttendance.php
@@ -11,16 +11,12 @@
require '../Include/Config.php';
require '../Include/Functions.php';
-use ChurchCRM\Reports\PDF_Attendance;
use ChurchCRM\dto\SystemConfig;
-use ChurchCRM\Utils\InputUtils;
use ChurchCRM\dto\SystemURLs;
-use ChurchCRM\PersonQuery;
-use ChurchCRM\FamilyQuery;
use ChurchCRM\GroupQuery;
-use ChurchCRM\Person2group2roleP2g2r;
use ChurchCRM\Map\PersonTableMap;
-use Propel\Runtime\ActiveQuery\Criteria;
+use ChurchCRM\Reports\PDF_Attendance;
+use ChurchCRM\Utils\InputUtils;
$iGroupID = InputUtils::LegacyFilterInput($_GET['GroupID']);
$aGrp = explode(',', $iGroupID);
@@ -89,18 +85,18 @@
}
//Get the data on this group
$group = GroupQuery::Create()->findOneById($iGroupID);
-
+
$FYString = MakeFYString($iFYID);
-
+
$reportHeader = str_pad($group->getName(), 95).$FYString;
-
+
// Build the teacher string- first teachers, then the liaison
$teacherString = gettext('Teachers').': ';
$bFirstTeacher = true;
$iTeacherCnt = 0;
$iMaxTeachersFit = 4;
$iStudentCnt = 0;
-
+
$groupRoleMemberships = ChurchCRM\Person2group2roleP2g2rQuery::create()
->joinWithPerson()
->orderBy(PersonTableMap::COL_PER_LASTNAME)
@@ -109,29 +105,28 @@
if ($tAllRoles != 1) {
$liaisonString = '';
-
+
foreach ($groupRoleMemberships as $groupRoleMembership) {
$person = $groupRoleMembership->getPerson();
$family = $person->getFamily();
-
- $homePhone = "";
+
+ $homePhone = '';
if (!empty(family)) {
$homePhone = $family->getHomePhone();
-
-
+
if (empty($homePhone)) {
$homePhone = $family->getCellPhone();
}
-
+
if (empty($homePhone)) {
$homePhone = $family->getWorkPhone();
}
}
-
+
$groupRole = ChurchCRM\ListOptionQuery::create()->filterById($group->getRoleListId())->filterByOptionId($groupRoleMembership->getRoleId())->findOne();
-
+
$lst_OptionName = $groupRole->getOptionName();
-
+
if ($lst_OptionName == 'Teacher') {
$aTeachers[$iTeacherCnt] = $person; // Make an array of teachers while we're here
if (!$bFirstTeacher) {
@@ -139,9 +134,9 @@
}
$teacherString .= $person->getFullName();
$bFirstTeacher = false;
-
+
$person->getPhoto()->createThumbnail();
- $aTeachersIMG[$iTeacherCnt++] = str_replace(SystemURLs::getDocumentRoot(), "", $person->getPhoto()->getThumbnailURI());
+ $aTeachersIMG[$iTeacherCnt++] = str_replace(SystemURLs::getDocumentRoot(), '', $person->getPhoto()->getThumbnailURI());
} elseif ($lst_OptionName == 'Student') {
$aStudents[$iStudentCnt] = $person;
@@ -151,12 +146,11 @@
$liaisonString .= gettext('Liaison').':'.$person->getFullName().' '.$pdf->StripPhone($homePhone).' ';
}
}
-
+
if ($iTeacherCnt < $iMaxTeachersFit) {
$teacherString .= ' '.$liaisonString;
}
-
$pdf->SetFont('Times', 'B', 12);
$y = $yTeachers;
@@ -188,13 +182,12 @@
$aStudentsIMG,
$withPictures
);
-
-
+
// we start a new page
- if ($y > $yTeachers+10) {
+ if ($y > $yTeachers + 10) {
$pdf->AddPage();
}
-
+
$y = $yTeachers;
$pdf->DrawAttendanceCalendar(
$nameX,
@@ -221,12 +214,12 @@
// print all roles on the attendance sheet
//
$iStudentCnt = 0;
-
+
unset($aStudents);
-
+
foreach ($groupRoleMemberships as $groupRoleMembership) {
$person = $groupRoleMembership->getPerson();
-
+
$aStudents[$iStudentCnt] = $groupRoleMembership->getPerson();
$aStudentsIMG[$iStudentCnt++] = $person->getPhoto()->getThumbnailURI();
}
@@ -240,7 +233,7 @@
$y + 6,
$aStudents,
gettext('All Members'),
- $iExtraStudents+$iExtraTeachers,
+ $iExtraStudents + $iExtraTeachers,
$tFirstSunday,
$tLastSunday,
$tNoSchool1,
@@ -260,7 +253,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if ($iPDFOutputType == 1) {
- $pdf->Output('ClassAttendance'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('ClassAttendance'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/ClassList.php b/src/Reports/ClassList.php
index 344d51a70f..526e5bc4fb 100644
--- a/src/Reports/ClassList.php
+++ b/src/Reports/ClassList.php
@@ -10,17 +10,12 @@
require '../Include/Config.php';
require '../Include/Functions.php';
-use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\dto\SystemConfig;
-use ChurchCRM\Utils\InputUtils;
-use ChurchCRM\dto\SystemURLs;
-use ChurchCRM\PersonQuery;
-use ChurchCRM\Person;
-use ChurchCRM\FamilyQuery;
use ChurchCRM\GroupQuery;
-use ChurchCRM\Person2group2roleP2g2r;
use ChurchCRM\Map\PersonTableMap;
-use Propel\Runtime\ActiveQuery\Criteria;
+use ChurchCRM\PersonQuery;
+use ChurchCRM\Reports\ChurchInfoReport;
+use ChurchCRM\Utils\InputUtils;
$iGroupID = InputUtils::LegacyFilterInput($_GET['GroupID']);
$aGrp = explode(',', $iGroupID);
@@ -51,11 +46,11 @@ public function __construct()
for ($i = 0; $i < $nGrps; $i++) {
$iGroupID = $aGrp[$i];
-
+
if ($i > 0) {
$pdf->AddPage();
}
-
+
$group = GroupQuery::Create()->findOneById($iGroupID);
$nameX = 20;
@@ -70,7 +65,7 @@ public function __construct()
$pdf->SetFont('Times', 'B', 16);
- $pdf->WriteAt($nameX, $yTitle, ($group->getName().' - '));
+ $pdf->WriteAt($nameX, $yTitle, $group->getName().' - ');
$FYString = MakeFYString($iFYID);
$pdf->WriteAt($phoneX, $yTitle, $FYString);
@@ -97,15 +92,15 @@ public function __construct()
foreach ($groupRoleMemberships as $groupRoleMembership) {
$person = $groupRoleMembership->getPerson();
$family = $person->getFamily();
-
- $homePhone = "";
+
+ $homePhone = '';
if (!empty($family)) {
$homePhone = $family->getHomePhone();
-
+
if (empty($homePhone)) {
$homePhone = $family->getCellPhone();
}
-
+
if (empty($homePhone)) {
$homePhone = $family->getWorkPhone();
}
@@ -113,7 +108,7 @@ public function __construct()
$groupRole = ChurchCRM\ListOptionQuery::create()->filterById($group->getRoleListId())->filterByOptionId($groupRoleMembership->getRoleId())->findOne();
$lst_OptionName = $groupRole->getOptionName();
-
+
if ($lst_OptionName == 'Teacher') {
$phone = $pdf->StripPhone($homePhone);
if ($teacherCount >= $teachersThatFit) {
@@ -129,17 +124,16 @@ public function __construct()
$teacherString1 .= $person->getFullName().' '.$phone;
$bFirstTeacher1 = false;
}
- ++$teacherCount;
+ $teacherCount++;
} elseif ($lst_OptionName == gettext('Liaison')) {
$liaisonString .= gettext('Liaison').':'.$person->getFullName().' '.$phone.' ';
} elseif ($lst_OptionName == 'Student') {
$elt = ['perID' => $groupRoleMembership->getPersonId()];
-
+
array_push($students, $elt);
}
}
-
$pdf->SetFont('Times', 'B', 10);
$y = $yTeachers;
@@ -162,93 +156,93 @@ public function __construct()
for ($row = 0; $row < $numMembers; $row++) {
$student = $students[$row];
-
+
$person = PersonQuery::create()->findPk($student['perID']);
-
+
$assignedProperties = $person->getProperties();
-
+
$family = $person->getFamily();
- $studentName = ($person->getFullName());
-
+ $studentName = $person->getFullName();
+
if ($studentName != $prevStudentName) {
$pdf->WriteAt($nameX, $y, $studentName);
-
+
$imgName = $person->getPhoto()->getThumbnailURI();
-
+
$birthdayStr = change_date_for_place_holder($person->getBirthYear().'-'.$person->getBirthMonth().'-'.$person->getBirthDay());
$pdf->WriteAt($birthdayX, $y, $birthdayStr);
if ($withPictures) {
- $imageHeight=9;
-
- $nameX-=2;
- $y-=2;
-
+ $imageHeight = 9;
+
+ $nameX -= 2;
+ $y -= 2;
+
$pdf->SetLineWidth(0.25);
- $pdf->Line($nameX-$imageHeight, $y, $nameX, $y);
- $pdf->Line($nameX-$imageHeight, $y+$imageHeight, $nameX, $y+$imageHeight);
- $pdf->Line($nameX-$imageHeight, $y, $nameX, $y);
- $pdf->Line($nameX-$imageHeight, $y, $nameX-$imageHeight, $y+$imageHeight);
- $pdf->Line($nameX, $y, $nameX, $y+$imageHeight);
-
+ $pdf->Line($nameX - $imageHeight, $y, $nameX, $y);
+ $pdf->Line($nameX - $imageHeight, $y + $imageHeight, $nameX, $y + $imageHeight);
+ $pdf->Line($nameX - $imageHeight, $y, $nameX, $y);
+ $pdf->Line($nameX - $imageHeight, $y, $nameX - $imageHeight, $y + $imageHeight);
+ $pdf->Line($nameX, $y, $nameX, $y + $imageHeight);
+
// we build the cross in the case of there's no photo
//$this->SetLineWidth(0.25);
- $pdf->Line($nameX-$imageHeight, $y+$imageHeight, $nameX, $y);
- $pdf->Line($nameX-$imageHeight, $y, $nameX, $y+$imageHeight);
-
+ $pdf->Line($nameX - $imageHeight, $y + $imageHeight, $nameX, $y);
+ $pdf->Line($nameX - $imageHeight, $y, $nameX, $y + $imageHeight);
+
if ($imgName != ' ' && strlen($imgName) > 5 && file_exists($imgName)) {
list($width, $height) = getimagesize($imgName);
- $factor = 8/$height;
+ $factor = 8 / $height;
$nw = $imageHeight;
$nh = $imageHeight;
-
- $pdf->Image($imgName, $nameX-$nw, $y, $nw, $nh, 'JPG');
+
+ $pdf->Image($imgName, $nameX - $nw, $y, $nw, $nh, 'JPG');
}
-
- $nameX+=2;
- $y+=2;
+
+ $nameX += 2;
+ $y += 2;
}
-
- $props = "";
+
+ $props = '';
if (!empty($assignedProperties)) {
foreach ($assignedProperties as $property) {
- $props.= $property->getProName().", ";
+ $props .= $property->getProName().', ';
}
-
- $props = chop($props, ", ");
-
- if (strlen($props)>0) {
- $props = " !!! ".$props;
-
+
+ $props = chop($props, ', ');
+
+ if (strlen($props) > 0) {
+ $props = ' !!! '.$props;
+
$pdf->SetFont('Times', 'B', 10);
- $pdf->WriteAt($nameX, $y+3.5, $props);
+ $pdf->WriteAt($nameX, $y + 3.5, $props);
$pdf->SetFont('Times', '', 12);
}
}
}
-
- $parentsStr = $phone = "";
+
+ $parentsStr = $phone = '';
if (!empty($family)) {
$parentsStr = $pdf->MakeSalutation($family->getId());
-
+
$phone = $family->getHomePhone();
-
+
if (empty($phone)) {
$phone = $family->getCellPhone();
}
-
+
if (empty($phone)) {
$phone = $family->getWorkPhone();
}
}
$pdf->WriteAt($parentsX, $y, $parentsStr);
-
+
$pdf->WriteAt($phoneX, $y, $pdf->StripPhone($phone));
$y += $yIncrement;
- $addrStr = "";
+ $addrStr = '';
if (!empty($family)) {
$addrStr = $family->getAddress1();
if ($fam_Address2 != '') {
@@ -268,12 +262,12 @@ public function __construct()
}
$pdf->SetFont('Times', 'B', 12);
- $pdf->WriteAt($phoneX-7, $y+5, FormatDate(date('Y-m-d')));
+ $pdf->WriteAt($phoneX - 7, $y + 5, FormatDate(date('Y-m-d')));
}
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if ($iPDFOutputType == 1) {
- $pdf->Output('ClassList'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('ClassList'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/ConfirmLabels.php b/src/Reports/ConfirmLabels.php
index 96394b542c..862e0630d8 100644
--- a/src/Reports/ConfirmLabels.php
+++ b/src/Reports/ConfirmLabels.php
@@ -11,9 +11,9 @@
require '../Include/Functions.php';
use ChurchCRM\dto\SystemConfig;
+use ChurchCRM\FamilyQuery;
use ChurchCRM\Reports\PDF_Label;
use ChurchCRM\Utils\InputUtils;
-use ChurchCRM\FamilyQuery;
$sLabelFormat = InputUtils::LegacyFilterInput($_GET['labeltype']);
$bRecipientNamingMethod = $_GET['recipientnamingmethod'];
@@ -36,7 +36,7 @@
->find();
foreach ($families as $family) {
- if ($bRecipientNamingMethod == "familyname") {
+ if ($bRecipientNamingMethod == 'familyname') {
$labelText = $family->getName();
} else {
$labelText = $pdf->MakeSalutation($family->getID());
@@ -58,7 +58,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if ($iPDFOutputType == 1) {
- $pdf->Output('ConfirmDataLabels'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('ConfirmDataLabels'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/ConfirmReport.php b/src/Reports/ConfirmReport.php
index 600c7afb4c..3ef6b42730 100644
--- a/src/Reports/ConfirmReport.php
+++ b/src/Reports/ConfirmReport.php
@@ -70,7 +70,7 @@ public function FinishPage($curY)
// Instantiate the directory class and build the report.
$pdf = new PDF_ConfirmReport();
-$filename = 'ConfirmReport'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf';
+$filename = 'ConfirmReport'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf';
// Get the list of custom person fields
$sSQL = 'SELECT person_custom_master.* FROM person_custom_master ORDER BY custom_Order';
@@ -137,7 +137,7 @@ public function FinishPage($curY)
$pdf->SetFont('Times', 'B', 10);
$pdf->WriteAtCell(SystemConfig::getValue('leftX'), $curY, $dataCol - SystemConfig::getValue('leftX'), gettext('City, State, Zip'));
$pdf->SetFont('Times', '', 10);
- $pdf->WriteAtCell($dataCol, $curY, $dataWid, ($fam_City.', '.$fam_State.' '.$fam_Zip));
+ $pdf->WriteAtCell($dataCol, $curY, $dataWid, $fam_City.', '.$fam_State.' '.$fam_Zip);
$curY += SystemConfig::getValue('incrementY');
$pdf->SetFont('Times', 'B', 10);
$pdf->WriteAtCell(SystemConfig::getValue('leftX'), $curY, $dataCol - SystemConfig::getValue('leftX'), gettext('Home Phone'));
@@ -157,8 +157,8 @@ public function FinishPage($curY)
$pdf->SetFont('Times', 'B', 10);
$pdf->WriteAtCell(SystemConfig::getValue('leftX'), $curY, $dataCol - SystemConfig::getValue('leftX'), gettext('Anniversary Date'));
$pdf->SetFont('Times', '', 10);
- if ($fam_WeddingDate != "") {
- $pdf->WriteAtCell($dataCol, $curY, $dataWid, date_format(date_create($fam_WeddingDate), SystemConfig::getValue("sDateFormatLong")));
+ if ($fam_WeddingDate != '') {
+ $pdf->WriteAtCell($dataCol, $curY, $dataWid, date_format(date_create($fam_WeddingDate), SystemConfig::getValue('sDateFormatLong')));
}
$curY += SystemConfig::getValue('incrementY');
diff --git a/src/Reports/ConfirmReportEmail.php b/src/Reports/ConfirmReportEmail.php
index 445e739310..13ae54276b 100644
--- a/src/Reports/ConfirmReportEmail.php
+++ b/src/Reports/ConfirmReportEmail.php
@@ -13,12 +13,12 @@
require '../Include/Functions.php';
use ChurchCRM\dto\SystemConfig;
-use ChurchCRM\Reports\ChurchInfoReport;
+use ChurchCRM\dto\SystemURLs;
use ChurchCRM\Emails\FamilyVerificationEmail;
+use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
-use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\dto\SystemURLs;
use ChurchCRM\Utils\LoggerUtils;
+use ChurchCRM\Utils\RedirectUtils;
class EmailPDF_ConfirmReport extends ChurchInfoReport
{
@@ -66,7 +66,7 @@ public function FinishPage($curY)
$curY += 4 * SystemConfig::getValue('incrementY');
- $this->WriteAt(SystemConfig::getValue('leftX'), $curY, SystemConfig::getValue('sConfirmSincerely'). ",");
+ $this->WriteAt(SystemConfig::getValue('leftX'), $curY, SystemConfig::getValue('sConfirmSincerely').',');
$curY += 4 * SystemConfig::getValue('incrementY');
$this->WriteAt(SystemConfig::getValue('leftX'), $curY, SystemConfig::getValue('sConfirmSigner'));
}
@@ -130,7 +130,7 @@ public function FinishPage($curY)
$pdf->SetFont('Times', 'B', 10);
$pdf->WriteAtCell(SystemConfig::getValue('leftX'), $curY, $dataCol - SystemConfig::getValue('leftX'), gettext('City, State, Zip'));
$pdf->SetFont('Times', '', 10);
- $pdf->WriteAtCell($dataCol, $curY, $dataWid, ($fam_City.', '.$fam_State.' '.$fam_Zip));
+ $pdf->WriteAtCell($dataCol, $curY, $dataWid, $fam_City.', '.$fam_State.' '.$fam_Zip);
$curY += SystemConfig::getValue('incrementY');
$pdf->SetFont('Times', 'B', 10);
$pdf->WriteAtCell(SystemConfig::getValue('leftX'), $curY, $dataCol - SystemConfig::getValue('leftX'), gettext('Home Phone'));
@@ -323,7 +323,7 @@ public function FinishPage($curY)
if (!empty($emaillist)) {
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
- $doc = $pdf->Output('ConfirmReportEmail-'.$fam_ID.'-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'S');
+ $doc = $pdf->Output('ConfirmReportEmail-'.$fam_ID.'-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'S');
$subject = $fam_Name.' Family Information Review';
@@ -332,7 +332,7 @@ public function FinishPage($curY)
}
$mail = new FamilyVerificationEmail($emaillist, $fam_Name);
- $filename = 'ConfirmReportEmail-'.$fam_Name.'-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf';
+ $filename = 'ConfirmReportEmail-'.$fam_Name.'-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf';
$mail->addStringAttachment($doc, $filename);
if ($mail->send()) {
@@ -347,5 +347,5 @@ public function FinishPage($curY)
if ($_GET['familyId']) {
RedirectUtils::Redirect('v2/family/'.$_GET['familyId'].'&PDFEmailed='.$familyEmailSent);
} else {
- RedirectUtils::Redirect(SystemURLs::getRootPath().'/v2/people/verify?AllPDFsEmailed='. $familiesEmailed);
+ RedirectUtils::Redirect(SystemURLs::getRootPath().'/v2/people/verify?AllPDFsEmailed='.$familiesEmailed);
}
diff --git a/src/Reports/DirectoryReport.php b/src/Reports/DirectoryReport.php
index 39154fa468..b9db850ba2 100644
--- a/src/Reports/DirectoryReport.php
+++ b/src/Reports/DirectoryReport.php
@@ -13,12 +13,12 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\PDF_Directory;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\MiscUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Check for Create Directory user permission.
if (!AuthenticationManager::GetCurrentUser()->isCreateDirectoryEnabled()) {
@@ -169,16 +169,16 @@
} elseif ($mysqlversion == 3 && $mysqlsubversion >= 22) {
// If UNION not supported use this query with temporary table. Prior to version 3.22 no IF EXISTS statement.
$sSQL = 'DROP TABLE IF EXISTS tmp;';
- $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or die(mysqli_error($cnInfoCentral));
+ $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or exit(mysqli_error($cnInfoCentral));
$sSQL = "CREATE TABLE tmp TYPE = InnoDB SELECT *, 0 AS memberCount, per_LastName AS SortMe FROM $sGroupTable LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID = 0 $sWhereExt $sClassQualifier ;";
- $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or die(mysqli_error($cnInfoCentral));
+ $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or exit(mysqli_error($cnInfoCentral));
$sSQL = "INSERT INTO tmp SELECT *, COUNT(*) AS memberCount, fam_Name AS SortMe FROM $sGroupTable LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID > 0 $sWhereExt $sClassQualifier GROUP BY per_fam_ID HAVING memberCount = 1;";
- $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or die(mysqli_error($cnInfoCentral));
+ $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or exit(mysqli_error($cnInfoCentral));
$sSQL = "INSERT INTO tmp SELECT *, COUNT(*) AS memberCount, fam_Name AS SortMe FROM $sGroupTable LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID > 0 $sWhereExt $sClassQualifier GROUP BY per_fam_ID HAVING memberCount > 1;";
- $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or die(mysqli_error($cnInfoCentral));
+ $rsRecords = mysqli_query($cnInfoCentral, $sSQL) or exit(mysqli_error($cnInfoCentral));
$sSQL = 'SELECT DISTINCT * FROM tmp ORDER BY SortMe';
} else {
- die(gettext('This option requires at least version 3.22 of MySQL! Hit browser back button to return to ChurchCRM.'));
+ exit(gettext('This option requires at least version 3.22 of MySQL! Hit browser back button to return to ChurchCRM.'));
}
$rsRecords = RunQuery($sSQL);
@@ -255,7 +255,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);
@@ -340,7 +340,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('Directory-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('Directory-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/EnvelopeReport.php b/src/Reports/EnvelopeReport.php
index 513b557c7b..eb624297b1 100644
--- a/src/Reports/EnvelopeReport.php
+++ b/src/Reports/EnvelopeReport.php
@@ -8,10 +8,10 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// If CSVAdminOnly option is enabled and user is not admin, redirect to the menu.
if (!AuthenticationManager::GetCurrentUser()->isAdmin() && SystemConfig::getValue('bCSVAdminOnly')) {
@@ -133,7 +133,7 @@ public function Add_Record($text, $numlines)
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('EnvelopeAssignments-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('EnvelopeAssignments-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/FRBidSheets.php b/src/Reports/FRBidSheets.php
index 1753321643..99f84d682c 100644
--- a/src/Reports/FRBidSheets.php
+++ b/src/Reports/FRBidSheets.php
@@ -102,7 +102,7 @@ public function AddPage($orientation = '', $format = '')
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('FRBidSheets'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('FRBidSheets'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/FRCatalog.php b/src/Reports/FRCatalog.php
index fadfb9964a..9760dfa59d 100644
--- a/src/Reports/FRCatalog.php
+++ b/src/Reports/FRCatalog.php
@@ -104,7 +104,7 @@ public function AddPage($orientation = '', $format = '')
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('FRCatalog'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('FRCatalog'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/FRCertificates.php b/src/Reports/FRCertificates.php
index 202192106a..115b25b012 100644
--- a/src/Reports/FRCertificates.php
+++ b/src/Reports/FRCertificates.php
@@ -50,7 +50,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('FRCertificates'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('FRCertificates'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/FamilyPledgeSummary.php b/src/Reports/FamilyPledgeSummary.php
index 404a03dba4..3860146071 100644
--- a/src/Reports/FamilyPledgeSummary.php
+++ b/src/Reports/FamilyPledgeSummary.php
@@ -11,11 +11,11 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
@@ -349,7 +349,7 @@ public function __construct()
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('FamilyPledgeSummary'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('FamilyPledgeSummary'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/FundRaiserStatement.php b/src/Reports/FundRaiserStatement.php
index 95cb9edd25..25297a69e4 100644
--- a/src/Reports/FundRaiserStatement.php
+++ b/src/Reports/FundRaiserStatement.php
@@ -174,7 +174,7 @@ public function CellWithWrap($curY, $curNewY, $ItemWid, $tableCellY, $txt, $bdr,
$nextY = $pdf->CellWithWrap($curY, $nextY, $ItemWid, $tableCellY, $di_item, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $QtyWid, $tableCellY, '1', 0, 'L'); // quantity 1 for all individual items
$nextY = $pdf->CellWithWrap($curY, $nextY, $TitleWid, $tableCellY, $di_title, 0, 'L');
- $nextY = $pdf->CellWithWrap($curY, $nextY, $DonorWid, $tableCellY, ($donorFirstName.' '.$donorLastName), 0, 'L');
+ $nextY = $pdf->CellWithWrap($curY, $nextY, $DonorWid, $tableCellY, $donorFirstName.' '.$donorLastName, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $PhoneWid, $tableCellY, $donorPhone, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $EmailWid, $tableCellY, $donorEmail, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $PriceWid, $tableCellY, '$'.$di_sellprice, 0, 'R');
@@ -202,23 +202,23 @@ public function CellWithWrap($curY, $curNewY, $ItemWid, $tableCellY, $txt, $bdr,
$nextY = $pdf->CellWithWrap($curY, $nextY, $ItemWid, $tableCellY, $di_item, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $QtyWid, $tableCellY, $mb_count, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $TitleWid, $tableCellY, stripslashes($di_title), 0, 'L');
- $nextY = $pdf->CellWithWrap($curY, $nextY, $DonorWid, $tableCellY, ($donorFirstName.' '.$donorLastName), 0, 'L');
+ $nextY = $pdf->CellWithWrap($curY, $nextY, $DonorWid, $tableCellY, $donorFirstName.' '.$donorLastName, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $PhoneWid, $tableCellY, $donorPhone, 0, 'L');
$nextY = $pdf->CellWithWrap($curY, $nextY, $EmailWid, $tableCellY, $donorEmail, 0, 'L');
- $nextY = $pdf->CellWithWrap($curY, $nextY, $PriceWid, $tableCellY, ('$'.($mb_count * $di_sellprice)), 0, 'R');
+ $nextY = $pdf->CellWithWrap($curY, $nextY, $PriceWid, $tableCellY, '$'.($mb_count * $di_sellprice), 0, 'R');
$curY = $nextY;
$totalAmount += $mb_count * $di_sellprice;
}
// Report total purchased items
- $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, (gettext('Total of all purchases: $').$totalAmount));
+ $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Total of all purchases: $').$totalAmount);
$curY += 2 * SystemConfig::getValue('incrementY');
// Make the tear-off record for the bottom of the page
$curY = 240;
$pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('-----------------------------------------------------------------------------------------------------------------------------------------------'));
$curY += 2 * SystemConfig::getValue('incrementY');
- $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, (gettext('Buyer # ').$pn_Num.' : '.$paddleFirstName.' '.$paddleLastName.' : '.gettext('Total purchases: $').$totalAmount.' : '.gettext('Amount paid: ________________')));
+ $pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Buyer # ').$pn_Num.' : '.$paddleFirstName.' '.$paddleLastName.' : '.gettext('Total purchases: $').$totalAmount.' : '.gettext('Amount paid: ________________'));
$curY += 2 * SystemConfig::getValue('incrementY');
$pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Paid by ( ) Cash ( ) Check ( ) Credit card __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ Exp __ / __'));
$curY += 2 * SystemConfig::getValue('incrementY');
@@ -229,4 +229,4 @@ public function CellWithWrap($curY, $curNewY, $ItemWid, $tableCellY, $txt, $bdr,
}
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
-$pdf->Output('FundRaiserStatement'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+$pdf->Output('FundRaiserStatement'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
diff --git a/src/Reports/GroupReport.php b/src/Reports/GroupReport.php
index 18ab610c04..3b6c5b5f8b 100644
--- a/src/Reports/GroupReport.php
+++ b/src/Reports/GroupReport.php
@@ -168,7 +168,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('GroupDirectory-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('GroupDirectory-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/NameTags.php b/src/Reports/NameTags.php
index 61e9094bd2..9e48fb4b3a 100644
--- a/src/Reports/NameTags.php
+++ b/src/Reports/NameTags.php
@@ -83,7 +83,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('NameTags'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('NameTags'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/NewsLetterLabels.php b/src/Reports/NewsLetterLabels.php
index d94cb7a9c6..c4ffc84dc2 100644
--- a/src/Reports/NewsLetterLabels.php
+++ b/src/Reports/NewsLetterLabels.php
@@ -11,9 +11,9 @@
require '../Include/Functions.php';
use ChurchCRM\dto\SystemConfig;
+use ChurchCRM\FamilyQuery;
use ChurchCRM\Reports\PDF_NewsletterLabels;
use ChurchCRM\Utils\InputUtils;
-use ChurchCRM\FamilyQuery;
$sLabelFormat = InputUtils::LegacyFilterInput($_GET['labeltype']);
$bRecipientNamingMethod = $_GET['recipientnamingmethod'];
@@ -33,12 +33,12 @@
// Get all the families which receive the newsletter by mail
$families = FamilyQuery::create()
- ->filterBySendNewsletter("TRUE")
+ ->filterBySendNewsletter('TRUE')
->orderByZip()
->find();
foreach ($families as $family) {
- if ($bRecipientNamingMethod == "familyname") {
+ if ($bRecipientNamingMethod == 'familyname') {
$labelText = $family->getName();
} else {
$labelText = $pdf->MakeSalutation($family->getID());
@@ -60,7 +60,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('NewsLetterLabels'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('NewsLetterLabels'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/PDFLabel.php b/src/Reports/PDFLabel.php
index 41cddc979a..9bff31de27 100644
--- a/src/Reports/PDFLabel.php
+++ b/src/Reports/PDFLabel.php
@@ -209,7 +209,7 @@ function MakeADCArray($sADClist)
$endOfRow = strpos($sADClist, '|');
if ($endOfRow) {
$currentRow = mb_substr($sADClist, 0, $endOfRow);
- $sADClist = mb_substr($sADClist, ($endOfRow + 1));
+ $sADClist = mb_substr($sADClist, $endOfRow + 1);
// find the current adc (hint, last item listed)
$currentRow = trim($currentRow);
@@ -727,7 +727,7 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp
$sAddress .= "\n".$sAddress2;
}
- if (!$bOnlyComplete || ((strlen($sAddress)) && strlen($sCity) && strlen($sState) && strlen($sZip))) {
+ if (!$bOnlyComplete || (strlen($sAddress) && strlen($sCity) && strlen($sState) && strlen($sZip))) {
$sLabelList[] = ['Name'=>$sName, 'Address'=>$sAddress, 'City'=>$sCity, 'State'=>$sState, 'Zip'=>$sZip]; //,'fam_ID'=>$aRow['fam_ID']);
}
} // end of foreach loop
@@ -861,27 +861,26 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('Labels-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('Labels-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
} else { // File Type must be CSV
- $delimiter = SystemConfig::getValue("sCSVExportDelimiter");
+ $delimiter = SystemConfig::getValue('sCSVExportDelimiter');
$sCSVOutput = '';
if ($iBulkCode) {
$sCSVOutput .= '"ZipBundle"'.$delimiter;
}
-
- $sCSVOutput .= '"'.InputUtils::translate_special_charset("Greeting").'"'.$delimiter.'"'.InputUtils::translate_special_charset("Name").'"'.$delimiter.'"'.InputUtils::translate_special_charset("Address").'"'.$delimiter.'"'.InputUtils::translate_special_charset("City").'"'.$delimiter.'"'.InputUtils::translate_special_charset("State").'"'.$delimiter.'"'.InputUtils::translate_special_charset("Zip").'"'."\n";
+ $sCSVOutput .= '"'.InputUtils::translate_special_charset('Greeting').'"'.$delimiter.'"'.InputUtils::translate_special_charset('Name').'"'.$delimiter.'"'.InputUtils::translate_special_charset('Address').'"'.$delimiter.'"'.InputUtils::translate_special_charset('City').'"'.$delimiter.'"'.InputUtils::translate_special_charset('State').'"'.$delimiter.'"'.InputUtils::translate_special_charset('Zip').'"'."\n";
while (list($i, $sLT) = each($aLabelList)) {
if ($iBulkCode) {
$sCSVOutput .= '"'.$sLT['Note'].'"'.$delimiter;
}
- $iNewline = (strpos($sLT['Name'], "\n"));
+ $iNewline = strpos($sLT['Name'], "\n");
if ($iNewline === false) { // There is no newline character
$sCSVOutput .= '""'.$delimiter.'"'.InputUtils::translate_special_charset($sLT['Name']).'"'.$delimiter;
} else {
@@ -889,7 +888,7 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp
'"'.InputUtils::translate_special_charset(mb_substr($sLT['Name'], $iNewline + 1)).'"'.$delimiter;
}
- $iNewline = (strpos($sLT['Address'], "\n"));
+ $iNewline = strpos($sLT['Address'], "\n");
if ($iNewline === false) { // There is no newline character
$sCSVOutput .= '"'.InputUtils::translate_special_charset($sLT['Address']).'"'.$delimiter;
} else {
@@ -902,20 +901,19 @@ function GenerateLabels(&$pdf, $mode, $iBulkMailPresort, $bToParents, $bOnlyComp
'"'.$sLT['Zip'].'"'."\n";
}
- header('Content-type: application/csv;charset='.SystemConfig::getValue("sCSVExportCharset"));
- header('Content-Disposition: attachment; filename=Labels-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+ header('Content-type: application/csv;charset='.SystemConfig::getValue('sCSVExportCharset'));
+ header('Content-Disposition: attachment; filename=Labels-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
-
+
//add BOM to fix UTF-8 in Excel 2016 but not under, so the problem is solved with the sCSVExportCharset variable
- if (SystemConfig::getValue("sCSVExportCharset") == "UTF-8") {
+ if (SystemConfig::getValue('sCSVExportCharset') == 'UTF-8') {
echo "\xEF\xBB\xBF";
}
-
+
echo $sCSVOutput;
}
-
-exit();
+exit;
diff --git a/src/Reports/PhotoBook.php b/src/Reports/PhotoBook.php
index 64955865f6..4aef445cb1 100644
--- a/src/Reports/PhotoBook.php
+++ b/src/Reports/PhotoBook.php
@@ -10,13 +10,13 @@
require '../Include/Config.php';
require '../Include/Functions.php';
-use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\dto\SystemConfig;
-use ChurchCRM\Utils\InputUtils;
use ChurchCRM\GroupQuery;
-use ChurchCRM\Map\PersonTableMap;
use ChurchCRM\ListOptionQuery;
+use ChurchCRM\Map\PersonTableMap;
use ChurchCRM\Person2group2roleP2g2rQuery;
+use ChurchCRM\Reports\ChurchInfoReport;
+use ChurchCRM\Utils\InputUtils;
$iGroupID = InputUtils::LegacyFilterInput($_GET['GroupID']);
$aGrp = explode(',', $iGroupID);
@@ -37,7 +37,7 @@ class PDF_PhotoBook extends ChurchInfoReport
private $personMarginR;
private $personImageHeight;
private $personImageWidth;
-
+
// Constructor
public function __construct($iFYID)
{
@@ -52,7 +52,7 @@ public function __construct($iFYID)
$this->personImageWidth = 30;
$this->FYIDString = MakeFYString($iFYID);
}
-
+
public function drawGroup($iGroupID)
{
$this->group = GroupQuery::Create()->findOneById($iGroupID);
@@ -60,11 +60,11 @@ public function drawGroup($iGroupID)
$this->SetFont('Times', '', 14);
$this->SetAutoPageBreak(false);
$this->AddPage();
- $this->drawGroupMebersByRole("Teacher", gettext("Teachers"));
+ $this->drawGroupMebersByRole('Teacher', gettext('Teachers'));
$this->AddPage();
- $this->drawGroupMebersByRole("Student", gettext("Students"));
+ $this->drawGroupMebersByRole('Student', gettext('Students'));
}
-
+
private function drawPageHeader($title)
{
$this->currentX = $this->pageMarginL;
@@ -77,42 +77,41 @@ private function drawPageHeader($title)
$this->SetLineWidth(0.5);
$this->Line($this->pageMarginL, 25.25, $this->GetPageWidth() - $this->pageMarginR, 25.25);
}
-
+
private function drawPersonBlock($name, $thumbnailURI)
{
- # Draw a bounding box around the image placeholder centered around the name text.
+ // Draw a bounding box around the image placeholder centered around the name text.
$this->currentX += $this->personMarginL;
$this->SetFont('Times', '', 10);
$NameWidth = $this->GetStringWidth($name);
- $offset = ($NameWidth/2) - ($this->personImageWidth /2)+2;
-
+ $offset = ($NameWidth / 2) - ($this->personImageWidth / 2) + 2;
+
$this->SetLineWidth(0.25);
$this->Rect($this->currentX, $this->currentY, $this->personImageWidth, $this->personImageHeight);
-
-
- # Draw the image or an x
+
+ // Draw the image or an x
if (file_exists($thumbnailURI)) {
- $this->Image($thumbnailURI, $this->currentX+.25, $this->currentY+.25, $this->personImageWidth-.5, $this->personImageHeight-.5, 'PNG');
+ $this->Image($thumbnailURI, $this->currentX + .25, $this->currentY + .25, $this->personImageWidth - .5, $this->personImageHeight - .5, 'PNG');
} else {
$this->Line($this->currentX, $this->currentY, $this->currentX + $this->personImageWidth, $this->currentY + $this->personImageHeight);
- $this->Line($this->currentX+$this->personImageWidth, $this->currentY, $this->currentX, $this->currentY + $this->personImageHeight);
+ $this->Line($this->currentX + $this->personImageWidth, $this->currentY, $this->currentX, $this->currentY + $this->personImageHeight);
}
-
- # move the cursor, and draw the teacher name
+
+ // move the cursor, and draw the teacher name
$this->currentX -= $offset;
$this->currentY += $this->personImageHeight + 2;
$this->WriteAt($this->currentX, $this->currentY, $name);
-
+
$this->currentX += $offset;
$this->currentY -= $this->personImageHeight + 2;
-
+
$this->currentX += $this->personImageWidth;
$this->currentX += $this->personMarginR;
}
-
+
private function drawGroupMebersByRole($roleName, $roleDisplayName)
{
- $RoleListID =$this->group->getRoleListId();
+ $RoleListID = $this->group->getRoleListId();
$groupRole = ListOptionQuery::create()->filterById($RoleListID)->filterByOptionName($roleName)->findOne();
$groupRoleMemberships = Person2group2roleP2g2rQuery::create()
->filterByGroup($this->group)
@@ -121,19 +120,19 @@ private function drawGroupMebersByRole($roleName, $roleDisplayName)
->orderBy(PersonTableMap::COL_PER_LASTNAME)
->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME)
->find();
- $this->drawPageHeader((gettext("PhotoBook").' - '.$this->group->getName().' - '.$roleDisplayName." (".$groupRoleMemberships->count().")"));
+ $this->drawPageHeader(gettext('PhotoBook').' - '.$this->group->getName().' - '.$roleDisplayName.' ('.$groupRoleMemberships->count().')');
$this->currentX = $this->pageMarginL;
$this->currentY += 10;
foreach ($groupRoleMemberships as $roleMembership) {
$person = $roleMembership->getPerson();
$this->drawPersonBlock($person->getFullName(), $person->getPhoto()->getPhotoURI());
- if ($this->currentX + $this->personMarginL + $this->personImageWidth + $this->personMarginR >= $this->GetPageWidth() - $this->pageMarginR) { //can we fit another on the page?
+ if ($this->currentX + $this->personMarginL + $this->personImageWidth + $this->personMarginR >= $this->GetPageWidth() - $this->pageMarginR) { //can we fit another on the page?
$this->currentY += 50;
$this->currentX = $this->pageMarginL;
}
- if ($this->currentY + $this->personImageHeight+10 >= $this->GetPageHeight() - $this->pageMarginB) {
+ if ($this->currentY + $this->personImageHeight + 10 >= $this->GetPageHeight() - $this->pageMarginB) {
$this->AddPage();
- $this->drawPageHeader((gettext("PhotoBook").' - '.$this->group->getName().' - '.$roleDisplayName." (".$groupRoleMemberships->count().")"));
+ $this->drawPageHeader(gettext('PhotoBook').' - '.$this->group->getName().' - '.$roleDisplayName.' ('.$groupRoleMemberships->count().')');
$this->currentX = $this->pageMarginL;
$this->currentY += 10;
}
@@ -148,7 +147,7 @@ private function drawGroupMebersByRole($roleName, $roleDisplayName)
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if ($iPDFOutputType == 1) {
- $pdf->Output('ClassList'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('ClassList'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/PledgeSummary.php b/src/Reports/PledgeSummary.php
index ced60d0ab8..694fb47666 100644
--- a/src/Reports/PledgeSummary.php
+++ b/src/Reports/PledgeSummary.php
@@ -10,11 +10,11 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
@@ -266,13 +266,13 @@ public function __construct()
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('PledgeSummaryReport'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('PledgeSummaryReport'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
- // Output a text file
- // ##################
+// Output a text file
+// ##################
} elseif ($output == 'csv') {
// Settings
$delimiter = ',';
@@ -300,6 +300,6 @@ public function __construct()
// Export file
header('Content-type: text/x-csv');
- header('Content-Disposition: attachment; filename=ChurchInfo-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+ header('Content-Disposition: attachment; filename=ChurchInfo-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
echo $buffer;
}
diff --git a/src/Reports/PrintDeposit.php b/src/Reports/PrintDeposit.php
index 2a6a39909b..5000947e59 100644
--- a/src/Reports/PrintDeposit.php
+++ b/src/Reports/PrintDeposit.php
@@ -14,37 +14,36 @@
global $iChecksPerDepositForm;
-require "../Include/Config.php";
-require "../Include/Functions.php";
+require '../Include/Config.php';
+require '../Include/Functions.php';
-use ChurchCRM\Utils\InputUtils;
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemURLs;
+use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
//Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
- RedirectUtils::Redirect("Menu.php");
+ RedirectUtils::Redirect('Menu.php');
exit;
}
$iBankSlip = 0;
-if (array_key_exists("BankSlip", $_GET)) {
- $iBankSlip = InputUtils::LegacyFilterInput($_GET["BankSlip"], 'int');
+if (array_key_exists('BankSlip', $_GET)) {
+ $iBankSlip = InputUtils::LegacyFilterInput($_GET['BankSlip'], 'int');
}
-if (!$iBankSlip && array_key_exists("report_type", $_POST)) {
- $iBankSlip = InputUtils::LegacyFilterInput($_POST["report_type"], 'int');
+if (!$iBankSlip && array_key_exists('report_type', $_POST)) {
+ $iBankSlip = InputUtils::LegacyFilterInput($_POST['report_type'], 'int');
}
-$output = "pdf";
-if (array_key_exists("output", $_POST)) {
- $output = InputUtils::LegacyFilterInput($_POST["output"]);
+$output = 'pdf';
+if (array_key_exists('output', $_POST)) {
+ $output = InputUtils::LegacyFilterInput($_POST['output']);
}
-
$iDepositSlipID = 0;
-if (array_key_exists("deposit", $_POST)) {
- $iDepositSlipID = InputUtils::LegacyFilterInput($_POST["deposit"], "int");
+if (array_key_exists('deposit', $_POST)) {
+ $iDepositSlipID = InputUtils::LegacyFilterInput($_POST['deposit'], 'int');
}
if (!$iDepositSlipID && array_key_exists('iCurrentDeposit', $_SESSION)) {
@@ -53,13 +52,13 @@
// If CSVAdminOnly option is enabled and user is not admin, redirect to the menu.
// If no DepositSlipId, redirect to the menu
-if ((!AuthenticationManager::GetCurrentUser()->isAdmin() && $bCSVAdminOnly && $output != "pdf") || !$iDepositSlipID) {
- RedirectUtils::Redirect("Menu.php");
+if ((!AuthenticationManager::GetCurrentUser()->isAdmin() && $bCSVAdminOnly && $output != 'pdf') || !$iDepositSlipID) {
+ RedirectUtils::Redirect('Menu.php');
exit;
}
-if ($output == "pdf") {
- header('Location: '.SystemURLs::getRootPath()."/api/deposits/".$iDepositSlipID."/pdf");
-} elseif ($output == "csv") {
- header('Location: '.SystemURLs::getRootPath()."/api/deposits/".$iDepositSlipID."/csv");
+if ($output == 'pdf') {
+ header('Location: '.SystemURLs::getRootPath().'/api/deposits/'.$iDepositSlipID.'/pdf');
+} elseif ($output == 'csv') {
+ header('Location: '.SystemURLs::getRootPath().'/api/deposits/'.$iDepositSlipID.'/csv');
}
diff --git a/src/Reports/ReminderReport.php b/src/Reports/ReminderReport.php
index 577035ea24..612ea867ff 100644
--- a/src/Reports/ReminderReport.php
+++ b/src/Reports/ReminderReport.php
@@ -10,11 +10,11 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
@@ -473,7 +473,7 @@ public function FinishPage($curY)
}
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('ReminderReport'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('ReminderReport'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/TaxReport.php b/src/Reports/TaxReport.php
index 16e86d343e..fa1341c34c 100644
--- a/src/Reports/TaxReport.php
+++ b/src/Reports/TaxReport.php
@@ -10,11 +10,11 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
@@ -455,13 +455,13 @@ public function FinishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('TaxReport'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('TaxReport'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
- // Output a text file
- // ##################
+// Output a text file
+// ##################
} elseif ($output == 'csv') {
// Settings
$delimiter = ',';
@@ -489,6 +489,6 @@ public function FinishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres
// Export file
header('Content-type: text/x-csv');
- header('Content-Disposition: attachment; filename=ChurchCRM-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+ header('Content-Disposition: attachment; filename=ChurchCRM-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
echo $buffer;
}
diff --git a/src/Reports/USISTAddressReport.php b/src/Reports/USISTAddressReport.php
index fb722dff15..d71626e368 100644
--- a/src/Reports/USISTAddressReport.php
+++ b/src/Reports/USISTAddressReport.php
@@ -11,10 +11,10 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\PDF_AddressReport;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// If user does not have permission redirect to the menu.
if (!AuthenticationManager::GetCurrentUser()->isbUSAddressVerificationEnabled()) {
@@ -131,7 +131,7 @@
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('Addresses-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('Addresses-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/VotingMembers.php b/src/Reports/VotingMembers.php
index 493a102953..cfa1cf9b65 100644
--- a/src/Reports/VotingMembers.php
+++ b/src/Reports/VotingMembers.php
@@ -40,7 +40,7 @@ public function __construct()
$topY = 10;
$curY = $topY;
-$pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, (gettext('Voting members ').MakeFYString($iFYID)));
+$pdf->WriteAt(SystemConfig::getValue('leftX'), $curY, gettext('Voting members ').MakeFYString($iFYID));
$curY += 10;
$votingMemberCount = 0;
@@ -89,7 +89,7 @@ public function __construct()
while ($aMember = mysqli_fetch_array($rsFamilyMembers)) {
extract($aMember);
- $pdf->WriteAt(SystemConfig::getValue('leftX') + 30, $curY, ($per_FirstName.' '.$per_LastName));
+ $pdf->WriteAt(SystemConfig::getValue('leftX') + 30, $curY, $per_FirstName.' '.$per_LastName);
$curY += 5;
if ($curY > 245) {
$pdf->AddPage();
@@ -109,7 +109,7 @@ public function __construct()
header('Pragma: public'); // Needed for IE when using a shared SSL certificate
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('VotingMembers'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('VotingMembers'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
diff --git a/src/Reports/ZeroGivers.php b/src/Reports/ZeroGivers.php
index ab3bd56503..7a4a714002 100644
--- a/src/Reports/ZeroGivers.php
+++ b/src/Reports/ZeroGivers.php
@@ -11,11 +11,11 @@
require '../Include/Config.php';
require '../Include/Functions.php';
+use ChurchCRM\Authentication\AuthenticationManager;
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\Utils\InputUtils;
use ChurchCRM\Utils\RedirectUtils;
-use ChurchCRM\Authentication\AuthenticationManager;
// Security
if (!AuthenticationManager::GetCurrentUser()->isFinanceEnabled()) {
@@ -138,13 +138,13 @@ public function FinishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres
}
if (SystemConfig::getValue('iPDFOutputType') == 1) {
- $pdf->Output('ZeroGivers'.date(SystemConfig::getValue("sDateFilenameFormat")).'.pdf', 'D');
+ $pdf->Output('ZeroGivers'.date(SystemConfig::getValue('sDateFilenameFormat')).'.pdf', 'D');
} else {
$pdf->Output();
}
- // Output a text file
- // ##################
+// Output a text file
+// ##################
} elseif ($output == 'csv') {
// Settings
$delimiter = ',';
@@ -172,6 +172,6 @@ public function FinishPage($curY, $fam_ID, $fam_Name, $fam_Address1, $fam_Addres
// Export file
header('Content-type: text/x-csv');
- header('Content-Disposition: attachment; filename=ChurchCRM-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+ header('Content-Disposition: attachment; filename=ChurchCRM-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
echo $buffer;
}
diff --git a/src/api/dependencies.php b/src/api/dependencies.php
index 6b5f10862a..24274a23e4 100644
--- a/src/api/dependencies.php
+++ b/src/api/dependencies.php
@@ -1,6 +1,5 @@
add(new VersionMiddleware());
$app->add(new AuthMiddleware());
// Set up
-require __DIR__ . '/dependencies.php';
-require __DIR__ . '/../Include/slim/error-handler.php';
+require __DIR__.'/dependencies.php';
+require __DIR__.'/../Include/slim/error-handler.php';
// calendar
-require __DIR__ . '/routes/calendar/events.php';
-require __DIR__ . '/routes/calendar/calendar.php';
+require __DIR__.'/routes/calendar/events.php';
+require __DIR__.'/routes/calendar/calendar.php';
// finance routes
-require __DIR__ . '/routes/finance/finance-deposits.php';
-require __DIR__ . '/routes/finance/finance-payments.php';
+require __DIR__.'/routes/finance/finance-deposits.php';
+require __DIR__.'/routes/finance/finance-payments.php';
// People (families / persons)
-require __DIR__ . '/routes/people/people-family.php';
-require __DIR__ . '/routes/people/people-families.php';
-require __DIR__ . '/routes/people/people-groups.php';
-require __DIR__ . '/routes/people/people-person.php';
-require __DIR__ . '/routes/people/people-persons.php';
-require __DIR__ . '/routes/people/people-properties.php';
+require __DIR__.'/routes/people/people-family.php';
+require __DIR__.'/routes/people/people-families.php';
+require __DIR__.'/routes/people/people-groups.php';
+require __DIR__.'/routes/people/people-person.php';
+require __DIR__.'/routes/people/people-persons.php';
+require __DIR__.'/routes/people/people-properties.php';
// Public
-require __DIR__ . '/routes/public/public.php';
-require __DIR__ . '/routes/public/public-data.php';
-require __DIR__ . '/routes/public/public-calendar.php';
-require __DIR__ . '/routes/public/public-user.php';
-require __DIR__ . '/routes/public/public-register.php';
+require __DIR__.'/routes/public/public.php';
+require __DIR__.'/routes/public/public-data.php';
+require __DIR__.'/routes/public/public-calendar.php';
+require __DIR__.'/routes/public/public-user.php';
+require __DIR__.'/routes/public/public-register.php';
// system routes
-require __DIR__ . '/routes/system/system.php';
-require __DIR__ . '/routes/system/system-config.php';
-require __DIR__ . '/routes/system/system-custom-fields.php';
-require __DIR__ . '/routes/system/system-database.php';
-require __DIR__ . '/routes/system/system-debug.php';
-require __DIR__ . '/routes/system/system-issues.php';
-require __DIR__ . '/routes/system/system-register.php';
-require __DIR__ . '/routes/system/system-upgrade.php';
-require __DIR__ . '/routes/system/system-custom-menu.php';
-require __DIR__ . '/routes/system/system-locale.php';
+require __DIR__.'/routes/system/system.php';
+require __DIR__.'/routes/system/system-config.php';
+require __DIR__.'/routes/system/system-custom-fields.php';
+require __DIR__.'/routes/system/system-database.php';
+require __DIR__.'/routes/system/system-debug.php';
+require __DIR__.'/routes/system/system-issues.php';
+require __DIR__.'/routes/system/system-register.php';
+require __DIR__.'/routes/system/system-upgrade.php';
+require __DIR__.'/routes/system/system-custom-menu.php';
+require __DIR__.'/routes/system/system-locale.php';
// other
-require __DIR__ . '/routes/cart.php';
-require __DIR__ . '/routes/background.php';
-require __DIR__ . '/routes/geocoder.php';
-require __DIR__ . '/routes/kiosks.php';
-require __DIR__ . '/routes/email/mailchimp.php';
-require __DIR__ . '/routes/search.php';
+require __DIR__.'/routes/cart.php';
+require __DIR__.'/routes/background.php';
+require __DIR__.'/routes/geocoder.php';
+require __DIR__.'/routes/kiosks.php';
+require __DIR__.'/routes/email/mailchimp.php';
+require __DIR__.'/routes/search.php';
//user
-require __DIR__ . '/routes/users/user.php';
-require __DIR__ . '/routes/users/user-admin.php';
-require __DIR__ . '/routes/users/user-current.php';
-require __DIR__ . '/routes/users/user-settings.php';
+require __DIR__.'/routes/users/user.php';
+require __DIR__.'/routes/users/user-admin.php';
+require __DIR__.'/routes/users/user-current.php';
+require __DIR__.'/routes/users/user-settings.php';
// Run app
$app->run();
diff --git a/src/api/routes/background.php b/src/api/routes/background.php
index f29376696c..bb00180e25 100644
--- a/src/api/routes/background.php
+++ b/src/api/routes/background.php
@@ -12,8 +12,9 @@
function getPageCommonData(Request $request, Response $response, array $p_args)
{
- $pageName = $request->getQueryParam("name", "");
+ $pageName = $request->getQueryParam('name', '');
$DashboardValues = NewDashboardService::getValues($pageName);
+
return $response->withJson($DashboardValues);
}
diff --git a/src/api/routes/calendar/calendar.php b/src/api/routes/calendar/calendar.php
index 8255c53808..820567ca0f 100644
--- a/src/api/routes/calendar/calendar.php
+++ b/src/api/routes/calendar/calendar.php
@@ -21,10 +21,8 @@
$this->get('/{id}/fullcalendar', 'getUserCalendarFullCalendarEvents');
$this->post('/{id}/NewAccessToken', 'NewAccessToken')->add(new AddEventsRoleAuthMiddleware());
$this->delete('/{id}/AccessToken', 'DeleteAccessToken')->add(new AddEventsRoleAuthMiddleware());
-
});
-
$app->group('/systemcalendars', function () {
$this->get('', 'getSystemCalendars');
$this->get('/', 'getSystemCalendars');
@@ -33,7 +31,6 @@
$this->get('/{id}/fullcalendar', 'getSystemCalendarFullCalendarEvents');
});
-
function getSystemCalendars(Request $request, Response $response, array $args)
{
return $response->write(SystemCalendars::getCalendarList()->toJSON());
@@ -42,10 +39,11 @@ function getSystemCalendars(Request $request, Response $response, array $args)
function getSystemCalendarEvents(Request $request, Response $response, array $args)
{
$Calendar = SystemCalendars::getCalendarById($args['id']);
- $start = $request->getQueryParam("start", "");
- $end = $request->getQueryParam("end", "");
+ $start = $request->getQueryParam('start', '');
+ $end = $request->getQueryParam('end', '');
if ($Calendar) {
- $events = $Calendar->getEvents($start,$end);
+ $events = $Calendar->getEvents($start, $end);
+
return $response->withJson($events->toJSON());
}
}
@@ -56,27 +54,27 @@ function getSystemCalendarEventById(Request $request, Response $response, array
if ($Calendar) {
$event = $Calendar->getEventById($args['eventid']);
+
return $response->withJson($event->toJSON());
}
}
-
function getSystemCalendarFullCalendarEvents($request, Response $response, $args)
{
$Calendar = SystemCalendars::getCalendarById($args['id']);
- $start = $request->getQueryParam("start", "");
- $end = $request->getQueryParam("end", "");
+ $start = $request->getQueryParam('start', '');
+ $end = $request->getQueryParam('end', '');
if (!$Calendar) {
return $response->withStatus(404);
}
- $Events = $Calendar->getEvents($start,$end);
+ $Events = $Calendar->getEvents($start, $end);
if (!$Events) {
return $response->withStatus(404);
}
+
return $response->write(json_encode(EventsObjectCollectionToFullCalendar($Events, SystemCalendars::toPropelCalendar($Calendar))));
}
-
function getUserCalendars(Request $request, Response $response, array $args)
{
$CalendarQuery = CalendarQuery::create();
@@ -100,7 +98,6 @@ function getUserCalendarEvents(Request $request, Response $response, array $p_ar
return $response->withJson($Events->toJSON());
}
}
-
}
function getUserCalendarFullCalendarEvents($request, Response $response, $args)
@@ -111,16 +108,17 @@ function getUserCalendarFullCalendarEvents($request, Response $response, $args)
if (!$calendar) {
return $response->withStatus(404);
}
- $start = $request->getQueryParam("start", "");
- $end = $request->getQueryParam("end", "");
+ $start = $request->getQueryParam('start', '');
+ $end = $request->getQueryParam('end', '');
$Events = EventQuery::create()
- ->filterByStart(array("min" => $start))
- ->filterByEnd(array("max" => $end))
+ ->filterByStart(['min' => $start])
+ ->filterByEnd(['max' => $end])
->filterByCalendar($calendar)
->find();
if (!$Events) {
return $response->withStatus(404);
}
+
return $response->write(json_encode(EventsObjectCollectionToFullCalendar($Events, $calendar)));
}
@@ -132,62 +130,65 @@ function EventsObjectCollectionToFullCalendar(ObjectCollection $Events, Calendar
$fce->createFromEvent($event, $Calendar);
array_push($formattedEvents, $fce);
}
+
return $formattedEvents;
}
function NewAccessToken($request, Response $response, $args)
{
-
if (!isset($args['id'])) {
- return $response->withStatus(400, gettext("Invalid request: Missing calendar id"));
+ return $response->withStatus(400, gettext('Invalid request: Missing calendar id'));
}
$Calendar = CalendarQuery::create()
->findOneById($args['id']);
if (!$Calendar) {
- return $response->withStatus(404, gettext("Not Found: Unknown calendar id") . ": " . $args['id']);
+ return $response->withStatus(404, gettext('Not Found: Unknown calendar id').': '.$args['id']);
}
$Calendar->setAccessToken(ChurchCRM\Utils\MiscUtils::randomToken());
$Calendar->save();
+
return $Calendar->toJSON();
}
function DeleteAccessToken($request, Response $response, $args)
{
- if (!isset($args['id'])) {
- return $response->withStatus(400, gettext("Invalid request: Missing calendar id"));
- }
- $Calendar = CalendarQuery::create()
- ->findOneById($args['id']);
- if (!$Calendar) {
- return $response->withStatus(404, gettext("Not Found: Unknown calendar id") . ": " . $args['id']);
- }
- $Calendar->setAccessToken(null);
- $Calendar->save();
- return $Calendar->toJSON();
+ if (!isset($args['id'])) {
+ return $response->withStatus(400, gettext('Invalid request: Missing calendar id'));
+ }
+ $Calendar = CalendarQuery::create()
+ ->findOneById($args['id']);
+ if (!$Calendar) {
+ return $response->withStatus(404, gettext('Not Found: Unknown calendar id').': '.$args['id']);
+ }
+ $Calendar->setAccessToken(null);
+ $Calendar->save();
+
+ return $Calendar->toJSON();
}
function NewCalendar(Request $request, Response $response, $args)
{
- $input = (object)$request->getParsedBody();
- $Calendar = new Calendar();
- $Calendar->setName($input->Name);
- $Calendar->setForegroundColor($input->ForegroundColor);
- $Calendar->setBackgroundColor($input->BackgroundColor);
- $Calendar->save();
- return $response->withJson($Calendar->toArray());
+ $input = (object) $request->getParsedBody();
+ $Calendar = new Calendar();
+ $Calendar->setName($input->Name);
+ $Calendar->setForegroundColor($input->ForegroundColor);
+ $Calendar->setBackgroundColor($input->BackgroundColor);
+ $Calendar->save();
+ return $response->withJson($Calendar->toArray());
}
function deleteUserCalendar(Request $request, Response $response, $args)
{
- if (!isset($args['id'])) {
- return $response->withStatus(400, gettext("Invalid request: Missing calendar id"));
+ if (!isset($args['id'])) {
+ return $response->withStatus(400, gettext('Invalid request: Missing calendar id'));
}
$Calendar = CalendarQuery::create()
->findOneById($args['id']);
if (!$Calendar) {
- return $response->withStatus(404, gettext("Not Found: Unknown calendar id") . ": " . $args['id']);
+ return $response->withStatus(404, gettext('Not Found: Unknown calendar id').': '.$args['id']);
}
$Calendar->delete();
- return $response->withJson(array("status"=>"success"));
+
+ return $response->withJson(['status'=>'success']);
}
diff --git a/src/api/routes/calendar/events.php b/src/api/routes/calendar/events.php
index c6a52e1a0a..bb09a924ab 100644
--- a/src/api/routes/calendar/events.php
+++ b/src/api/routes/calendar/events.php
@@ -13,12 +13,11 @@
use Slim\Http\Response;
$app->group('/events', function () {
-
$this->get('/', 'getAllEvents');
$this->get('', 'getAllEvents');
- $this->get("/types", "getEventTypes");
- $this->get('/{id}', 'getEvent')->add(new EventsMiddleware);
- $this->get('/{id}/', 'getEvent')->add(new EventsMiddleware);
+ $this->get('/types', 'getEventTypes');
+ $this->get('/{id}', 'getEvent')->add(new EventsMiddleware());
+ $this->get('/{id}/', 'getEvent')->add(new EventsMiddleware());
$this->get('/{id}/primarycontact', 'getEventPrimaryContact');
$this->get('/{id}/secondarycontact', 'getEventSecondaryContact');
$this->get('/{id}/location', 'getEventLocation');
@@ -26,11 +25,10 @@
$this->post('/', 'newEvent')->add(new AddEventsRoleAuthMiddleware());
$this->post('', 'newEvent')->add(new AddEventsRoleAuthMiddleware());
- $this->post('/{id}', 'updateEvent')->add(new AddEventsRoleAuthMiddleware())->add(new EventsMiddleware);
+ $this->post('/{id}', 'updateEvent')->add(new AddEventsRoleAuthMiddleware())->add(new EventsMiddleware());
$this->post('/{id}/time', 'setEventTime')->add(new AddEventsRoleAuthMiddleware());
- $this->delete("/{id}", 'deleteEvent')->add(new AddEventsRoleAuthMiddleware());
-
+ $this->delete('/{id}', 'deleteEvent')->add(new AddEventsRoleAuthMiddleware());
});
function getAllEvents($request, Response $response, $args)
@@ -40,6 +38,7 @@ function getAllEvents($request, Response $response, $args)
if ($Events) {
return $response->write($Events->toJSON());
}
+
return $response->withStatus(404);
}
@@ -51,12 +50,14 @@ function getEventTypes($request, Response $response, $args)
if ($EventTypes) {
return $response->write($EventTypes->toJSON());
}
+
return $response->withStatus(404);
}
function getEvent(Request $request, Response $response, $args)
{
- $Event = $request->getAttribute("event");
+ $Event = $request->getAttribute('event');
+
return $response->write($Event->toJSON());
}
@@ -70,6 +71,7 @@ function getEventPrimaryContact($request, $response, $args)
return $response->write($Contact->toJSON());
}
}
+
return $response->withStatus(404);
}
@@ -81,6 +83,7 @@ function getEventSecondaryContact($request, $response, $args)
if ($Contact) {
return $response->write($Contact->toJSON());
}
+
return $response->withStatus(404);
}
@@ -92,6 +95,7 @@ function getEventLocation($request, $response, $args)
if ($Location) {
return $response->write($Location->toJSON());
}
+
return $response->withStatus(404);
}
@@ -103,49 +107,48 @@ function getEventAudience($request, Response $response, $args)
if ($Audience) {
return $response->write($Audience->toJSON());
}
+
return $response->withStatus(404);
}
function newEvent($request, $response, $args)
{
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
//fetch all related event objects before committing this event.
$type = EventTypeQuery::Create()
->findOneById($input->Type);
if (!$type) {
- return $response->withStatus(400, gettext("invalid event type id"));
+ return $response->withStatus(400, gettext('invalid event type id'));
}
$calendars = CalendarQuery::create()
->filterById($input->PinnedCalendars)
->find();
if (count($calendars) != count($input->PinnedCalendars)) {
- return $response->withStatus(400, gettext("invalid calendar pinning"));
+ return $response->withStatus(400, gettext('invalid calendar pinning'));
}
// we have event type and pined calendars. now create the event.
- $event = new Event;
+ $event = new Event();
$event->setTitle($input->Title);
$event->setEventType($type);
$event->setDesc($input->Desc);
- $event->setStart(str_replace("T", " ", $input->Start));
- $event->setEnd(str_replace("T", " ", $input->End));
+ $event->setStart(str_replace('T', ' ', $input->Start));
+ $event->setEnd(str_replace('T', ' ', $input->End));
$event->setText(InputUtils::FilterHTML($input->Text));
$event->setCalendars($calendars);
$event->save();
- return $response->withJson(array("status" => "success"));
+ return $response->withJson(['status' => 'success']);
}
function updateEvent($request, $response, $args)
{
-
-
- $e=new Event();
+ $e = new Event();
//$e->getId();
$input = $request->getParsedBody();
- $Event = $request->getAttribute("event");
+ $Event = $request->getAttribute('event');
$id = $Event->getId();
$Event->fromArray($input);
$Event->setId($id);
@@ -159,7 +162,7 @@ function updateEvent($request, $response, $args)
function setEventTime($request, Response $response, $args)
{
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$event = EventQuery::Create()
->findOneById($args['id']);
@@ -169,15 +172,14 @@ function setEventTime($request, Response $response, $args)
$event->setStart($input->startTime);
$event->setEnd($input->endTime);
$event->save();
- return $response->withJson(array("status" => "success"));
+ return $response->withJson(['status' => 'success']);
}
-
function unusedSetEventAttendance()
{
if ($input->Total > 0 || $input->Visitors || $input->Members) {
- $eventCount = new EventCounts;
+ $eventCount = new EventCounts();
$eventCount->setEvtcntEventid($event->getID());
$eventCount->setEvtcntCountid(1);
$eventCount->setEvtcntCountname('Total');
@@ -185,7 +187,7 @@ function unusedSetEventAttendance()
$eventCount->setEvtcntNotes($input->EventCountNotes);
$eventCount->save();
- $eventCount = new EventCounts;
+ $eventCount = new EventCounts();
$eventCount->setEvtcntEventid($event->getID());
$eventCount->setEvtcntCountid(2);
$eventCount->setEvtcntCountname('Members');
@@ -193,7 +195,7 @@ function unusedSetEventAttendance()
$eventCount->setEvtcntNotes($input->EventCountNotes);
$eventCount->save();
- $eventCount = new EventCounts;
+ $eventCount = new EventCounts();
$eventCount->setEvtcntEventid($event->getID());
$eventCount->setEvtcntCountid(3);
$eventCount->setEvtcntCountname('Visitors');
@@ -205,7 +207,7 @@ function unusedSetEventAttendance()
function deleteEvent($request, $response, $args)
{
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$event = EventQuery::Create()
->findOneById($args['id']);
@@ -213,5 +215,6 @@ function deleteEvent($request, $response, $args)
return $response->withStatus(404);
}
$event->delete();
- return $response->withJson(array("status" => "success"));
+
+ return $response->withJson(['status' => 'success']);
}
diff --git a/src/api/routes/cart.php b/src/api/routes/cart.php
index ff6c644d86..c4b54b6ea5 100644
--- a/src/api/routes/cart.php
+++ b/src/api/routes/cart.php
@@ -3,51 +3,51 @@
use ChurchCRM\dto\Cart;
$app->group('/cart', function () {
-
$this->get('/', function ($request, $response, $args) {
return $response->withJson(['PeopleCart' => $_SESSION['aPeopleCart']]);
});
$this->post('/', function ($request, $response, $args) {
- $cartPayload = (object)$request->getParsedBody();
- if (isset ($cartPayload->Persons) && count($cartPayload->Persons) > 0) {
+ $cartPayload = (object) $request->getParsedBody();
+ if (isset($cartPayload->Persons) && count($cartPayload->Persons) > 0) {
Cart::AddPersonArray($cartPayload->Persons);
- } elseif (isset ($cartPayload->Family)) {
+ } elseif (isset($cartPayload->Family)) {
Cart::AddFamily($cartPayload->Family);
- } elseif (isset ($cartPayload->Group)) {
+ } elseif (isset($cartPayload->Group)) {
Cart::AddGroup($cartPayload->Group);
} else {
- throw new \Exception(gettext("POST to cart requires a Persons array, FamilyID, or GroupID"), 500);
+ throw new \Exception(gettext('POST to cart requires a Persons array, FamilyID, or GroupID'), 500);
}
- return $response->withJson(['status' => "success"]);
+
+ return $response->withJson(['status' => 'success']);
});
$this->post('/emptyToGroup', function ($request, $response, $args) {
- $cartPayload = (object)$request->getParsedBody();
+ $cartPayload = (object) $request->getParsedBody();
Cart::EmptyToGroup($cartPayload->groupID, $cartPayload->groupRoleID);
+
return $response->withJson([
- 'status' => "success",
- 'message' => gettext('records(s) successfully added to selected Group.')
+ 'status' => 'success',
+ 'message' => gettext('records(s) successfully added to selected Group.'),
]);
});
$this->post('/removeGroup', function ($request, $response, $args) {
- $cartPayload = (object)$request->getParsedBody();
+ $cartPayload = (object) $request->getParsedBody();
Cart::RemoveGroup($cartPayload->Group);
+
return $response->withJson([
- 'status' => "success",
- 'message' => gettext('records(s) successfully deleted from the selected Group.')
+ 'status' => 'success',
+ 'message' => gettext('records(s) successfully deleted from the selected Group.'),
]);
});
-
/**
- * delete. This will empty the cart
+ * delete. This will empty the cart.
*/
$this->delete('/', function ($request, $response, $args) {
-
- $cartPayload = (object)$request->getParsedBody();
- if (isset ($cartPayload->Persons) && count($cartPayload->Persons) > 0) {
+ $cartPayload = (object) $request->getParsedBody();
+ if (isset($cartPayload->Persons) && count($cartPayload->Persons) > 0) {
Cart::RemovePersonArray($cartPayload->Persons);
} else {
$sMessage = gettext('Your cart is empty');
@@ -56,11 +56,10 @@
$sMessage = gettext('Your cart has been successfully emptied');
}
}
+
return $response->withJson([
- 'status' => "success",
- 'message' => $sMessage
+ 'status' => 'success',
+ 'message' => $sMessage,
]);
-
});
-
});
diff --git a/src/api/routes/email/mailchimp.php b/src/api/routes/email/mailchimp.php
index ba48a8c0fc..c43f13985d 100644
--- a/src/api/routes/email/mailchimp.php
+++ b/src/api/routes/email/mailchimp.php
@@ -17,27 +17,24 @@
$this->get('family/{familyId}', 'getFamilyStatus')->add(new FamilyAPIMiddleware());
})->add(new MailChimpMiddleware());
-
function getMailchimpList(Request $request, Response $response, array $args)
{
-
$listId = $args['id'];
- $mailchimpService = $request->getAttribute("mailchimpService");
+ $mailchimpService = $request->getAttribute('mailchimpService');
$list = $mailchimpService->getList($listId);
- return $response->withJson(["list" => $list]);
+ return $response->withJson(['list' => $list]);
}
function getMailchimpEmailNotInCRM(Request $request, Response $response, array $args)
{
-
$listId = $args['id'];
- $mailchimpService = $request->getAttribute("mailchimpService");
+ $mailchimpService = $request->getAttribute('mailchimpService');
$list = $mailchimpService->getList($listId);
if ($list) {
- $mailchimpListMembers = $list["members"];
+ $mailchimpListMembers = $list['members'];
foreach (getPeopleWithEmails() as $person) {
$inList = checkEmailInList($person->getEmail(), $mailchimpListMembers);
@@ -50,11 +47,11 @@ function getMailchimpEmailNotInCRM(Request $request, Response $response, array $
}
}
}
- LoggerUtils::getAppLogger()->debug("MailChimp list " . $listId . " now has " . count($mailchimpListMembers) . " members");
+ LoggerUtils::getAppLogger()->debug('MailChimp list '.$listId.' now has '.count($mailchimpListMembers).' members');
- return $response->withJson(["id" => $list["id"], "name" => $list["name"], "members" => $mailchimpListMembers]);
+ return $response->withJson(['id' => $list['id'], 'name' => $list['name'], 'members' => $mailchimpListMembers]);
} else {
- return $response->withStatus(404, gettext("List not found"));
+ return $response->withStatus(404, gettext('List not found'));
}
}
@@ -62,10 +59,10 @@ function getMailChimpMissingSubscribed(Request $request, Response $response, arr
{
$listId = $args['id'];
- $mailchimpService = $request->getAttribute("mailchimpService");
+ $mailchimpService = $request->getAttribute('mailchimpService');
$list = $mailchimpService->getList($listId);
if ($list) {
- $mailchimpListMembers = $list["members"];
+ $mailchimpListMembers = $list['members'];
$personsNotInMailchimp = [];
foreach (getPeopleWithEmails() as $person) {
if (!empty($person->getEmail()) || !empty($person->getWorkEmail())) {
@@ -86,50 +83,53 @@ function getMailChimpMissingSubscribed(Request $request, Response $response, arr
if (!empty($person->getWorkEmail())) {
array_push($emails, $person->getWorkEmail());
}
- array_push($personsNotInMailchimp, ["id" => $person->getId(),
- "name" => $person->getFullName(),
- "emails" => $emails
+ array_push($personsNotInMailchimp, ['id' => $person->getId(),
+ 'name' => $person->getFullName(),
+ 'emails' => $emails,
]);
}
}
}
- LoggerUtils::getAppLogger()->debug("MailChimp list " . $listId . " now has " . count($mailchimpListMembers) . " members");
+ LoggerUtils::getAppLogger()->debug('MailChimp list '.$listId.' now has '.count($mailchimpListMembers).' members');
- return $response->withJson(["id" => $list["id"], "name" => $list["name"] ,"members" =>$personsNotInMailchimp]);
+ return $response->withJson(['id' => $list['id'], 'name' => $list['name'], 'members' =>$personsNotInMailchimp]);
} else {
- return $response->withStatus(404, gettext("List not inList"));
+ return $response->withStatus(404, gettext('List not inList'));
}
}
function getFamilyStatus(Request $request, Response $response, array $args)
{
- $family = $request->getAttribute("family");
- $mailchimpService = $request->getAttribute("mailchimpService");
+ $family = $request->getAttribute('family');
+ $mailchimpService = $request->getAttribute('mailchimpService');
$emailToLists = [];
if (!empty($family->getEmail())) {
- array_push($emailToLists, ["email" => $family->getEmail(), "emailMD5" => md5($family->getEmail()),
- "list" => $mailchimpService->isEmailInMailChimp($family->getEmail())]);
+ array_push($emailToLists, ['email' => $family->getEmail(), 'emailMD5' => md5($family->getEmail()),
+ 'list' => $mailchimpService->isEmailInMailChimp($family->getEmail())]);
}
+
return $response->withJson($emailToLists);
}
function getPersonStatus(Request $request, Response $response, array $args)
{
- $person = $request->getAttribute("person");
- $mailchimpService = $request->getAttribute("mailchimpService");
+ $person = $request->getAttribute('person');
+ $mailchimpService = $request->getAttribute('mailchimpService');
$emailToLists = [];
if (!empty($person->getEmail())) {
- array_push($emailToLists, ["email" => $person->getEmail(), "emailMD5" => md5($person->getEmail()),
- "list" => $mailchimpService->isEmailInMailChimp($person->getEmail())]);
+ array_push($emailToLists, ['email' => $person->getEmail(), 'emailMD5' => md5($person->getEmail()),
+ 'list' => $mailchimpService->isEmailInMailChimp($person->getEmail())]);
}
if (!empty($person->getWorkEmail())) {
- array_push($emailToLists, ["email" => $person->getWorkEmail(), "emailMD5" => md5($person->getWorkEmail()),
- "list" => $mailchimpService->isEmailInMailChimp($person->getWorkEmail())]);
+ array_push($emailToLists, ['email' => $person->getWorkEmail(), 'emailMD5' => md5($person->getWorkEmail()),
+ 'list' => $mailchimpService->isEmailInMailChimp($person->getWorkEmail())]);
}
+
return $response->withJson($emailToLists);
}
-function getPeopleWithEmails() {
+function getPeopleWithEmails()
+{
$list = PersonQuery::create()
->filterByEmail(null, Criteria::NOT_EQUAL)
->_or()
@@ -140,11 +140,13 @@ function getPeopleWithEmails() {
return $list;
}
-function checkEmailInList($email, $memberList) {
+function checkEmailInList($email, $memberList)
+{
$email = trim(strtolower($email));
- $key = array_search($email, array_column($memberList, "email"));
+ $key = array_search($email, array_column($memberList, 'email'));
if ($key > 0) {
return true;
}
+
return false;
}
diff --git a/src/api/routes/finance/finance-deposits.php b/src/api/routes/finance/finance-deposits.php
index 2a8d6cdaa6..8d02651866 100644
--- a/src/api/routes/finance/finance-deposits.php
+++ b/src/api/routes/finance/finance-deposits.php
@@ -8,7 +8,7 @@
$app->group('/deposits', function () {
$this->post('', function ($request, $response, $args) {
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$deposit = new Deposit();
$deposit->setType($input->depositType);
$deposit->setComment($input->depositComment);
@@ -21,6 +21,7 @@
$list = DepositQuery::create()
->filterByDate(['min' =>date('Y-m-d', strtotime('-90 days'))])
->find();
+
return $response->withJson($list->toArray());
});
@@ -35,7 +36,7 @@
$this->post('/{id:[0-9]+}', function ($request, $response, $args) {
$id = $args['id'];
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$thisDeposit = DepositQuery::create()->findOneById($id);
$thisDeposit->setType($input->depositType);
$thisDeposit->setComment($input->depositComment);
@@ -60,7 +61,7 @@
$this->get('/{id:[0-9]+}/csv', function ($request, $response, $args) {
$id = $args['id'];
//echo DepositQuery::create()->findOneById($id)->toCSV();
- header('Content-Disposition: attachment; filename=ChurchCRM-Deposit-' . $id . '-' . date(SystemConfig::getValue("sDateFilenameFormat")) . '.csv');
+ header('Content-Disposition: attachment; filename=ChurchCRM-Deposit-'.$id.'-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
echo PledgeQuery::create()->filterByDepId($id)
->joinDonationFund()->useDonationFundQuery()
->withColumn('DonationFund.Name', 'DonationFundName')
@@ -88,7 +89,7 @@
->withColumn('DonationFund.Name')
->find()
->toArray();
- return $response->withJson($Pledges);
+ return $response->withJson($Pledges);
});
})->add(new FinanceRoleAuthMiddleware());
diff --git a/src/api/routes/finance/finance-payments.php b/src/api/routes/finance/finance-payments.php
index 0821608573..a22687ca64 100644
--- a/src/api/routes/finance/finance-payments.php
+++ b/src/api/routes/finance/finance-payments.php
@@ -18,39 +18,39 @@
});
$this->get('/family/{familyId:[0-9]+}/list', function (Request $request, Response $response, array $args) {
- $familyId = $request->getAttribute("route")->getArgument("familyId");
+ $familyId = $request->getAttribute('route')->getArgument('familyId');
$query = PledgeQuery::create()->filterByFamId($familyId);
if (!empty(AuthenticationManager::GetCurrentUser()->getShowSince())) {
$query->filterByDate(AuthenticationManager::GetCurrentUser()->getShowSince(), Criteria::GREATER_EQUAL);
}
if (!AuthenticationManager::GetCurrentUser()->isShowPayments()) {
- $query->filterByPledgeOrPayment("Payment", Criteria::NOT_EQUAL);
+ $query->filterByPledgeOrPayment('Payment', Criteria::NOT_EQUAL);
}
if (!AuthenticationManager::GetCurrentUser()->isShowPledges()) {
- $query->filterByPledgeOrPayment("Pledge", Criteria::NOT_EQUAL);
+ $query->filterByPledgeOrPayment('Pledge', Criteria::NOT_EQUAL);
}
- $query->innerJoinDonationFund()->withColumn("donationfund_fun.fun_Name" , "PledgeName");
+ $query->innerJoinDonationFund()->withColumn('donationfund_fun.fun_Name', 'PledgeName');
$data = $query->find();
$rows = [];
foreach ($data as $row) {
- $newRow["FormattedFY"] = $row->getFormattedFY();
- $newRow["GroupKey"] = $row->getGroupKey();
- $newRow["Amount"] = $row->getAmount();
- $newRow["Nondeductible"] = $row->getNondeductible();
- $newRow["Schedule"] = $row->getSchedule();
- $newRow["Method"] = $row->getMethod();
- $newRow["Comment"] = $row->getComment();
- $newRow["PledgeOrPayment"] = $row->getPledgeOrPayment();
- $newRow["Date"] = $row->getDate("Y-m-d");
- $newRow["DateLastEdited"] = $row->getDateLastEdited("Y-m-d");
- $newRow["EditedBy"] = $row->getPerson()->getFullName();
- $newRow["Fund"] = $row->getPledgeName();
+ $newRow['FormattedFY'] = $row->getFormattedFY();
+ $newRow['GroupKey'] = $row->getGroupKey();
+ $newRow['Amount'] = $row->getAmount();
+ $newRow['Nondeductible'] = $row->getNondeductible();
+ $newRow['Schedule'] = $row->getSchedule();
+ $newRow['Method'] = $row->getMethod();
+ $newRow['Comment'] = $row->getComment();
+ $newRow['PledgeOrPayment'] = $row->getPledgeOrPayment();
+ $newRow['Date'] = $row->getDate('Y-m-d');
+ $newRow['DateLastEdited'] = $row->getDateLastEdited('Y-m-d');
+ $newRow['EditedBy'] = $row->getPerson()->getFullName();
+ $newRow['Fund'] = $row->getPledgeName();
array_push($rows, $newRow);
}
- return $response->withJson(["data" => $rows]);
+ return $response->withJson(['data' => $rows]);
});
$this->delete('/{groupKey}', function (Request $request, Response $response, array $args) {
diff --git a/src/api/routes/geocoder.php b/src/api/routes/geocoder.php
index deb77dc1d3..886c3f2081 100644
--- a/src/api/routes/geocoder.php
+++ b/src/api/routes/geocoder.php
@@ -9,13 +9,13 @@
$this->post('/address/', 'getGeoLocals');
});
-
/**
* A method that return GeoLocation based on an address.
*
- * @param \Slim\Http\Request $p_request The request.
+ * @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
- * @param array $p_args Arguments
+ * @param array $p_args Arguments
+ *
* @return \Slim\Http\Response The augmented response.
*/
function getGeoLocals(Request $request, Response $response, array $p_args)
@@ -24,5 +24,6 @@ function getGeoLocals(Request $request, Response $response, array $p_args)
if (!empty($input)) {
return $response->withJson(GeoUtils::getLatLong($input->address));
}
+
return $response->withStatus(400); // bad request
}
diff --git a/src/api/routes/kiosks.php b/src/api/routes/kiosks.php
index 99e7f79cef..426f37a613 100644
--- a/src/api/routes/kiosks.php
+++ b/src/api/routes/kiosks.php
@@ -5,7 +5,6 @@
use Propel\Runtime\ActiveQuery\Criteria;
$app->group('/kiosks', function () {
-
$this->get('/', function ($request, $response, $args) {
$Kiosks = KioskDeviceQuery::create()
->joinWithKioskAssignment(Criteria::LEFT_JOIN)
@@ -13,14 +12,16 @@
->joinWithEvent(Criteria::LEFT_JOIN)
->endUse()
->find();
+
return $response->write($Kiosks->toJSON());
});
$this->post('/allowRegistration', function ($request, $response, $args) {
$window = new DateTime();
- $window->add(new DateInterval("PT05S"));
- SystemConfig::setValue("sKioskVisibilityTimestamp", $window->format('Y-m-d H:i:s'));
- return $response->write(json_encode(array("visibleUntil" => $window)));
+ $window->add(new DateInterval('PT05S'));
+ SystemConfig::setValue('sKioskVisibilityTimestamp', $window->format('Y-m-d H:i:s'));
+
+ return $response->write(json_encode(['visibleUntil' => $window]));
});
$this->post('/{kioskId:[0-9]+}/reloadKiosk', function ($request, $response, $args) {
@@ -28,6 +29,7 @@
$reload = KioskDeviceQuery::create()
->findOneById($kioskId)
->reloadKiosk();
+
return $response->write(json_encode($reload));
});
@@ -36,6 +38,7 @@
$identify = KioskDeviceQuery::create()
->findOneById($kioskId)
->identifyKiosk();
+
return $response->write(json_encode($identify));
});
@@ -45,16 +48,17 @@
->findOneById($kioskId)
->setAccepted(true)
->save();
+
return $response->write(json_encode($accept));
});
$this->post('/{kioskId:[0-9]+}/setAssignment', function ($request, $response, $args) {
$kioskId = $args['kioskId'];
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$accept = KioskDeviceQuery::create()
->findOneById($kioskId)
->setAssignment($input->assignmentType, $input->eventId);
+
return $response->write(json_encode($accept));
});
-
});
diff --git a/src/api/routes/people/people-families.php b/src/api/routes/people/people-families.php
index 837c134775..6b74632548 100644
--- a/src/api/routes/people/people-families.php
+++ b/src/api/routes/people/people-families.php
@@ -16,7 +16,6 @@
use Slim\Http\Response;
$app->group('/families', function () {
-
$this->get('/latest', 'getLatestFamilies');
$this->get('/updated', 'getUpdatedFamilies');
$this->get('/anniversaries', 'getFamiliesWithAnniversaries');
@@ -37,17 +36,16 @@
if (!$hasEmail) {
array_push($familiesWithoutEmails, $family->toArray());
}
- }
+ }
}
- return $response->withJson(["count" => count($familiesWithoutEmails), "families" => $familiesWithoutEmails]);
+ return $response->withJson(['count' => count($familiesWithoutEmails), 'families' => $familiesWithoutEmails]);
});
$this->get('/numbers', function ($request, $response, $args) {
return $response->withJson(MenuEventsCount::getNumberAnniversaries());
});
-
$this->get('/search/{query}', function ($request, $response, $args) {
$query = $args['query'];
$results = [];
@@ -59,7 +57,7 @@
array_push($results, $family->toSearchArray());
}
- return $response->withJson(json_encode(["Families" => $results]));
+ return $response->withJson(json_encode(['Families' => $results]));
});
$this->get('/self-register', function ($request, $response, $args) {
@@ -68,6 +66,7 @@
->orderByDateEntered(Criteria::DESC)
->limit(100)
->find();
+
return $response->withJson(['families' => $families->toArray()]);
});
@@ -78,23 +77,24 @@
->joinWithFamily()
->limit(100)
->find();
+
return $response->withJson(['families' => $verificationNotes->toArray()]);
});
$this->get('/pending-self-verify', function ($request, $response, $args) {
$pendingTokens = TokenQuery::create()
->filterByType(Token::typeFamilyVerify)
- ->filterByRemainingUses(array('min' => 1))
- ->filterByValidUntilDate(array('min' => new DateTime()))
+ ->filterByRemainingUses(['min' => 1])
+ ->filterByValidUntilDate(['min' => new DateTime()])
->addJoin(TokenTableMap::COL_REFERENCE_ID, FamilyTableMap::COL_FAM_ID)
- ->withColumn(FamilyTableMap::COL_FAM_NAME, "FamilyName")
- ->withColumn(TokenTableMap::COL_REFERENCE_ID, "FamilyId")
+ ->withColumn(FamilyTableMap::COL_FAM_NAME, 'FamilyName')
+ ->withColumn(TokenTableMap::COL_REFERENCE_ID, 'FamilyId')
->limit(100)
->find();
+
return $response->withJson(['families' => $pendingTokens->toArray()]);
});
-
$this->get('/byCheckNumber/{scanString}', function ($request, $response, $args) {
$scanString = $args['scanString'];
echo $this->FinancialService->getMemberByScanString($scanString);
@@ -102,21 +102,21 @@
/**
* Update the family status to activated or deactivated with :familyId and :status true/false.
- * Pass true to activate and false to deactivate. *
+ * Pass true to activate and false to deactivate. *.
*/
$this->post('/{familyId:[0-9]+}/activate/{status}', function ($request, $response, $args) {
- $familyId = $args["familyId"];
- $newStatus = $args["status"];
+ $familyId = $args['familyId'];
+ $newStatus = $args['status'];
$family = FamilyQuery::create()->findPk($familyId);
$currentStatus = (empty($family->getDateDeactivated()) ? 'true' : 'false');
//update only if the value is different
if ($currentStatus != $newStatus) {
- if ($newStatus == "false") {
+ if ($newStatus == 'false') {
$family->setDateDeactivated(date('YmdHis'));
- } elseif ($newStatus == "true") {
- $family->setDateDeactivated(Null);
+ } elseif ($newStatus == 'true') {
+ $family->setDateDeactivated(null);
}
$family->save();
@@ -132,25 +132,22 @@
$note->setEntered(AuthenticationManager::GetCurrentUser()->getId());
$note->save();
}
- return $response->withJson(['success' => true]);
+ return $response->withJson(['success' => true]);
});
-
});
-
function getFamiliesWithAnniversaries(Request $request, Response $response, array $p_args)
{
$families = FamilyQuery::create()
->filterByDateDeactivated(null)
->filterByWeddingdate(null, Criteria::NOT_EQUAL)
- ->addUsingAlias(FamilyTableMap::COL_FAM_WEDDINGDATE,"MONTH(". FamilyTableMap::COL_FAM_WEDDINGDATE .") =" . date('m'),Criteria::CUSTOM)
- ->addUsingAlias(FamilyTableMap::COL_FAM_WEDDINGDATE,"DAY(". FamilyTableMap::COL_FAM_WEDDINGDATE .") =" . date('d'),Criteria::CUSTOM)
+ ->addUsingAlias(FamilyTableMap::COL_FAM_WEDDINGDATE, 'MONTH('.FamilyTableMap::COL_FAM_WEDDINGDATE.') ='.date('m'), Criteria::CUSTOM)
+ ->addUsingAlias(FamilyTableMap::COL_FAM_WEDDINGDATE, 'DAY('.FamilyTableMap::COL_FAM_WEDDINGDATE.') ='.date('d'), Criteria::CUSTOM)
->orderByWeddingdate('DESC')
->find();
return $response->withJson(buildFormattedFamilies($families, false, false, true));
-
}
function getLatestFamilies(Request $request, Response $response, array $p_args)
{
@@ -182,22 +179,23 @@ function buildFormattedFamilies($families, $created, $edited, $wedding)
foreach ($families as $family) {
$formattedFamily = [];
- $formattedFamily["FamilyId"] = $family->getId();
- $formattedFamily["Name"] = $family->getName();
- $formattedFamily["Address"] = $family->getAddress();
+ $formattedFamily['FamilyId'] = $family->getId();
+ $formattedFamily['Name'] = $family->getName();
+ $formattedFamily['Address'] = $family->getAddress();
if ($created) {
- $formattedFamily["Created"] = date_format($family->getDateEntered(), SystemConfig::getValue('sDateFormatLong'));
+ $formattedFamily['Created'] = date_format($family->getDateEntered(), SystemConfig::getValue('sDateFormatLong'));
}
if ($edited) {
- $formattedFamily["LastEdited"] = date_format($family->getDateLastEdited(), SystemConfig::getValue('sDateFormatLong'));
+ $formattedFamily['LastEdited'] = date_format($family->getDateLastEdited(), SystemConfig::getValue('sDateFormatLong'));
}
if ($wedding) {
- $formattedFamily["WeddingDate"] = date_format($family->getWeddingdate(), SystemConfig::getValue('sDateFormatLong'));
+ $formattedFamily['WeddingDate'] = date_format($family->getWeddingdate(), SystemConfig::getValue('sDateFormatLong'));
}
array_push($formattedList, $formattedFamily);
}
- return ["families" => $formattedList];
+
+ return ['families' => $formattedList];
}
diff --git a/src/api/routes/people/people-family.php b/src/api/routes/people/people-family.php
index 339c1afe2a..337107748d 100644
--- a/src/api/routes/people/people-family.php
+++ b/src/api/routes/people/people-family.php
@@ -16,87 +16,96 @@
$app->group('/family/{familyId:[0-9]+}', function () {
$this->get('/photo', function ($request, $response, $args) {
$res = $this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
- $photo = new Photo("Family", $args['familyId']);
+ $photo = new Photo('Family', $args['familyId']);
+
return $res->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
});
$this->post('/photo', function ($request, $response, $args) {
- $input = (object)$request->getParsedBody();
- $family = $request->getAttribute("family");
+ $input = (object) $request->getParsedBody();
+ $family = $request->getAttribute('family');
$family->setImageFromBase64($input->imgBase64);
+
return $response->withStatus(200);
})->add(new EditRecordsRoleAuthMiddleware());
$this->delete('/photo', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
- return $response->withJson(["status" => $family->deletePhoto()]);
+ $family = $request->getAttribute('family');
+
+ return $response->withJson(['status' => $family->deletePhoto()]);
})->add(new EditRecordsRoleAuthMiddleware());
$this->get('/thumbnail', function ($request, $response, $args) {
$res = $this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
- $photo = new Photo("Family", $args['familyId']);
+ $photo = new Photo('Family', $args['familyId']);
+
return $res->write($photo->getThumbnailBytes())->withHeader('Content-type', $photo->getThumbnailContentType());
});
$this->get('', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
- return $response->withHeader('Content-Type','application/json')->write($family->exportTo('JSON'));
+ $family = $request->getAttribute('family');
+
+ return $response->withHeader('Content-Type', 'application/json')->write($family->exportTo('JSON'));
});
$this->get('/geolocation', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
+ $family = $request->getAttribute('family');
$familyAddress = $family->getAddress();
$familyLatLong = GeoUtils::getLatLong($familyAddress);
$familyDrivingInfo = GeoUtils::DrivingDistanceMatrix($familyAddress, ChurchMetaData::getChurchAddress());
$geoLocationInfo = array_merge($familyDrivingInfo, $familyLatLong);
+
return $response->withJson($geoLocationInfo);
});
$this->get('/nav', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
+ $family = $request->getAttribute('family');
$familyNav = [];
- $familyNav["PreFamilyId"] = 0;
- $familyNav["NextFamilyId"] = 0;
+ $familyNav['PreFamilyId'] = 0;
+ $familyNav['NextFamilyId'] = 0;
$tempFamily = FamilyQuery::create()->filterById($family->getId(), Criteria::LESS_THAN)->orderById(Criteria::DESC)->findOne();
if ($tempFamily) {
- $familyNav["PreFamilyId"] = $tempFamily->getId();
+ $familyNav['PreFamilyId'] = $tempFamily->getId();
}
$tempFamily = FamilyQuery::create()->filterById($family->getId(), Criteria::GREATER_THAN)->orderById()->findOne();
if ($tempFamily) {
- $familyNav["NextFamilyId"] = $tempFamily->getId();
+ $familyNav['NextFamilyId'] = $tempFamily->getId();
}
+
return $response->withJson($familyNav);
});
-
$this->post('/verify', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
- try{
+ $family = $request->getAttribute('family');
+
+ try {
$family->sendVerifyEmail();
+
return $response->withStatus(200);
- } catch (Exception $e ) {
+ } catch (Exception $e) {
LoggerUtils::getAppLogger()->error($e->getMessage());
- return $response->withStatus(500)->withJson(['message' => gettext("Error sending email(s)") . " - " . gettext("Please check logs for more information"), "trace" => $e->getMessage()]);
+
+ return $response->withStatus(500)->withJson(['message' => gettext('Error sending email(s)').' - '.gettext('Please check logs for more information'), 'trace' => $e->getMessage()]);
}
});
$this->get('/verify/url', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
- TokenQuery::create()->filterByType("verifyFamily")->filterByReferenceId($family->getId())->delete();
+ $family = $request->getAttribute('family');
+ TokenQuery::create()->filterByType('verifyFamily')->filterByReferenceId($family->getId())->delete();
$token = new Token();
- $token->build("verifyFamily", $family->getId());
+ $token->build('verifyFamily', $family->getId());
$token->save();
- $family->createTimeLineNote("verify-URL");
- return $response->withJson(["url" => SystemURLs::getURL() . "/external/verify/" . $token->getToken()]);
+ $family->createTimeLineNote('verify-URL');
+
+ return $response->withJson(['url' => SystemURLs::getURL().'/external/verify/'.$token->getToken()]);
});
$this->post('/verify/now', function ($request, $response, $args) {
- $family = $request->getAttribute("family");
+ $family = $request->getAttribute('family');
$family->verify();
- return $response->withJson(["message" => "Success"]);
- });
+ return $response->withJson(['message' => 'Success']);
+ });
})->add(new FamilyAPIMiddleware());
-
diff --git a/src/api/routes/people/people-groups.php b/src/api/routes/people/people-groups.php
index 9c7a03696e..adef5169aa 100644
--- a/src/api/routes/people/people-groups.php
+++ b/src/api/routes/people/people-groups.php
@@ -56,7 +56,6 @@
->joinWithPerson()
->findByGroupId($groupID);
-
// we loop to find the information in the family to add addresses etc ...
foreach ($members as $member) {
$p = $member->getPerson();
@@ -93,9 +92,8 @@
});
$app->group('/groups', function () {
-
$this->post('/', function ($request, $response, $args) {
- $groupSettings = (object)$request->getParsedBody();
+ $groupSettings = (object) $request->getParsedBody();
$group = new Group();
if ($groupSettings->isSundaySchool) {
$group->makeSundaySchool();
@@ -107,7 +105,7 @@
$this->post('/{groupID:[0-9]+}', function ($request, $response, $args) {
$groupID = $args['groupID'];
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$group = GroupQuery::create()->findOneById($groupID);
$group->setName($input->groupName);
$group->setType($input->groupType);
@@ -122,7 +120,6 @@
echo json_encode(['status' => 'success']);
});
-
$this->delete('/{groupID:[0-9]+}/removeperson/{userID:[0-9]+}', function ($request, $response, $args) {
$groupID = $args['groupID'];
$userID = $args['userID'];
@@ -133,8 +130,8 @@
if ($groupRoleMembership->getPersonId() == $person->getId()) {
$groupRoleMembership->delete();
$note = new Note();
- $note->setText(gettext("Deleted from group") . ": " . $group->getName());
- $note->setType("group");
+ $note->setText(gettext('Deleted from group').': '.$group->getName());
+ $note->setType('group');
$note->setEntered(AuthenticationManager::GetCurrentUser()->getId());
$note->setPerId($person->getId());
$note->save();
@@ -147,7 +144,7 @@
$groupID = $args['groupID'];
$userID = $args['userID'];
$person = PersonQuery::create()->findPk($userID);
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$group = GroupQuery::create()->findPk($groupID);
$p2g2r = Person2group2roleP2g2rQuery::create()
->filterByGroupId($groupID)
@@ -162,8 +159,8 @@
$group->addPerson2group2roleP2g2r($p2g2r);
$group->save();
$note = new Note();
- $note->setText(gettext("Added to group") . ": " . $group->getName());
- $note->setType("group");
+ $note->setText(gettext('Added to group').': '.$group->getName());
+ $note->setType('group');
$note->setEntered(AuthenticationManager::GetCurrentUser()->getId());
$note->setPerId($person->getId());
$note->save();
@@ -187,7 +184,7 @@
$this->post('/{groupID:[0-9]+}/roles/{roleID:[0-9]+}', function ($request, $response, $args) {
$groupID = $args['groupID'];
$roleID = $args['roleID'];
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$group = GroupQuery::create()->findOneById($groupID);
if (isset($input->groupRoleName)) {
$groupRole = ChurchCRM\ListOptionQuery::create()->filterById($group->getRoleListId())->filterByOptionId($roleID)->findOne();
@@ -242,7 +239,7 @@
$this->post('/{groupID:[0-9]+}/settings/active/{value}', function ($request, $response, $args) {
$groupID = $args['groupID'];
$flag = $args['value'];
- if ($flag == "true" || $flag == "false") {
+ if ($flag == 'true' || $flag == 'false') {
$group = GroupQuery::create()->findOneById($groupID);
if ($group != null) {
$group->setActive($flag);
@@ -250,7 +247,8 @@
} else {
return $response->withStatus(500, gettext('invalid group id'));
}
- return $response->withJson(['status' => "success"]);
+
+ return $response->withJson(['status' => 'success']);
} else {
return $response->withStatus(500, gettext('invalid status value'));
}
@@ -259,7 +257,7 @@
$this->post('/{groupID:[0-9]+}/settings/email/export/{value}', function ($request, $response, $args) {
$groupID = $args['groupID'];
$flag = $args['value'];
- if ($flag == "true" || $flag == "false") {
+ if ($flag == 'true' || $flag == 'false') {
$group = GroupQuery::create()->findOneById($groupID);
if ($group != null) {
$group->setIncludeInEmailExport($flag);
@@ -267,7 +265,8 @@
} else {
return $response->withStatus(500, gettext('invalid group id'));
}
- return $response->withJson(['status' => "success"]);
+
+ return $response->withJson(['status' => 'success']);
} else {
return $response->withStatus(500, gettext('invalid export value'));
}
diff --git a/src/api/routes/people/people-person.php b/src/api/routes/people/people-person.php
index f6dedfdf23..60298f807f 100644
--- a/src/api/routes/people/people-person.php
+++ b/src/api/routes/people/people-person.php
@@ -13,34 +13,36 @@
// This group does not load the person via middleware (to speed up the page loads)
$app->group('/person/{personId:[0-9]+}', function () {
-
$this->get('/thumbnail', function ($request, $response, $args) {
$res = $this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
- $photo = new Photo("Person", $args['personId']);
+ $photo = new Photo('Person', $args['personId']);
+
return $res->write($photo->getThumbnailBytes())->withHeader('Content-type', $photo->getThumbnailContentType());
});
$this->get('/photo', function ($request, $response, $args) {
$res = $this->cache->withExpires($response, MiscUtils::getPhotoCacheExpirationTimestamp());
- $photo = new Photo("Person", $args['personId']);
+ $photo = new Photo('Person', $args['personId']);
+
return $res->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
});
});
$app->group('/person/{personId:[0-9]+}', function () {
-
$this->get('', function ($request, $response, $args) {
- $person = $request->getAttribute("person");
+ $person = $request->getAttribute('person');
+
return $response->withHeader('Content-Type', 'application/json')->write($person->exportTo('JSON'));
});
$this->delete('', function ($request, $response, $args) {
- $person = $request->getAttribute("person");
+ $person = $request->getAttribute('person');
if (AuthenticationManager::GetCurrentUser()->getId() == $person->getId()) {
return $response->withStatus(403, gettext("Can't delete yourself"));
}
$person->delete();
- return $response->withJson(["status" => gettext("success")]);
+
+ return $response->withJson(['status' => gettext('success')]);
})->add(new DeleteRecordRoleAuthMiddleware());
$this->post('/role/{roleId:[0-9]+}', 'setPersonRoleAPI')->add(new EditRecordsRoleAuthMiddleware());
@@ -50,23 +52,22 @@
});
$this->post('/photo', function ($request, $response, $args) {
- $person = $request->getAttribute("person");
- $input = (object)$request->getParsedBody();
+ $person = $request->getAttribute('person');
+ $input = (object) $request->getParsedBody();
$person->setImageFromBase64($input->imgBase64);
- $response->withJson(array("status" => "success"));
+ $response->withJson(['status' => 'success']);
})->add(new EditRecordsRoleAuthMiddleware());
$this->delete('/photo', function ($request, $response, $args) {
- $person = $request->getAttribute("person");
+ $person = $request->getAttribute('person');
+
return $response->withJson(['success' => $person->deletePhoto()]);
})->add(new DeleteRecordRoleAuthMiddleware());
-
})->add(new PersonAPIMiddleware());
-
function setPersonRoleAPI(Request $request, Response $response, array $args)
{
- $person = $request->getAttribute("person");
+ $person = $request->getAttribute('person');
$roleId = $args['roleId'];
$role = ListOptionQuery::create()->filterByOptionId($roleId)->findOne();
diff --git a/src/api/routes/people/people-persons.php b/src/api/routes/people/people-persons.php
index 297029dfe4..cea698240e 100644
--- a/src/api/routes/people/people-persons.php
+++ b/src/api/routes/people/people-persons.php
@@ -12,7 +12,6 @@
use Slim\Http\Response;
$app->group('/persons', function () {
-
$this->get('/roles', 'getAllRolesAPI');
$this->get('/roles/', 'getAllRolesAPI');
$this->get('/duplicate/emails', 'getEmailDupesAPI');
@@ -25,7 +24,7 @@
$this->get('/search/{query}', function ($request, $response, $args) {
$query = $args['query'];
- $searchLikeString = '%' . $query . '%';
+ $searchLikeString = '%'.$query.'%';
$people = PersonQuery::create()->
filterByFirstName($searchLikeString, Criteria::LIKE)->
_or()->filterByLastName($searchLikeString, Criteria::LIKE)->
@@ -57,14 +56,15 @@
->orderByDateEntered(Criteria::DESC)
->limit(100)
->find();
+
return $response->withJson(['people' => $people->toArray()]);
});
-
});
function getAllRolesAPI(Request $request, Response $response, array $p_args)
{
$roles = ListOptionQuery::create()->getFamilyRoles();
+
return $response->withJson($roles->toArray());
}
@@ -85,21 +85,21 @@ function getEmailDupesAPI(Request $request, Response $response, array $args)
$dbPeople = PersonQuery::create()->filterByEmail($email)->_or()->filterByWorkEmail($email)->find();
$people = [];
foreach ($dbPeople as $person) {
- array_push($people, ["id" => $person->getId(), "name" => $person->getFullName()]);
+ array_push($people, ['id' => $person->getId(), 'name' => $person->getFullName()]);
}
$families = [];
$dbFamilies = FamilyQuery::create()->findByEmail($email);
foreach ($dbFamilies as $family) {
- array_push($families, ["id" => $family->getId(), "name" => $family->getName()]);
+ array_push($families, ['id' => $family->getId(), 'name' => $family->getName()]);
}
array_push($emails, [
- "email" => $email,
- "people" => $people,
- "families" => $families
+ 'email' => $email,
+ 'people' => $people,
+ 'families' => $families,
]);
}
- return $response->withJson(["emails" => $emails]);
+ return $response->withJson(['emails' => $emails]);
}
function getLatestPersons(Request $request, Response $response, array $p_args)
@@ -111,7 +111,7 @@ function getLatestPersons(Request $request, Response $response, array $p_args)
->limit(10)
->find();
- return $response->withJson(buildFormattedPersonList($people, true, false, false ));
+ return $response->withJson(buildFormattedPersonList($people, true, false, false));
}
function getUpdatedPersons(Request $request, Response $response, array $p_args)
@@ -126,7 +126,6 @@ function getUpdatedPersons(Request $request, Response $response, array $p_args)
return $response->withJson(buildFormattedPersonList($people, false, true, false));
}
-
function getPersonsWithBirthdays(Request $request, Response $response, array $p_args)
{
$people = PersonQuery::create()
@@ -143,25 +142,25 @@ function buildFormattedPersonList($people, $created, $edited, $birthday)
foreach ($people as $person) {
$formattedPerson = [];
- $formattedPerson["PersonId"] = $person->getId();
- $formattedPerson["FirstName"] = $person->getFirstName();
- $formattedPerson["LastName"] = $person->getLastName();
- $formattedPerson["FormattedName"] = $person->getFullName();
- $formattedPerson["Email"] = $person->getEmail();
+ $formattedPerson['PersonId'] = $person->getId();
+ $formattedPerson['FirstName'] = $person->getFirstName();
+ $formattedPerson['LastName'] = $person->getLastName();
+ $formattedPerson['FormattedName'] = $person->getFullName();
+ $formattedPerson['Email'] = $person->getEmail();
if ($created) {
- $formattedPerson["Created"] = date_format($person->getDateEntered(), SystemConfig::getValue('sDateFormatLong'));
+ $formattedPerson['Created'] = date_format($person->getDateEntered(), SystemConfig::getValue('sDateFormatLong'));
}
if ($edited) {
- $formattedPerson["LastEdited"] = date_format($person->getDateLastEdited(), SystemConfig::getValue('sDateFormatLong'));
+ $formattedPerson['LastEdited'] = date_format($person->getDateLastEdited(), SystemConfig::getValue('sDateFormatLong'));
}
if ($birthday) {
- $formattedPerson["Birthday"] = date_format($person->getBirthDate(), SystemConfig::getValue('sDateFormatLong'));
+ $formattedPerson['Birthday'] = date_format($person->getBirthDate(), SystemConfig::getValue('sDateFormatLong'));
}
-
array_push($formattedList, $formattedPerson);
}
- return ["people" => $formattedList];
+
+ return ['people' => $formattedList];
}
diff --git a/src/api/routes/people/people-properties.php b/src/api/routes/people/people-properties.php
index 58290cf467..ffac630fdc 100644
--- a/src/api/routes/people/people-properties.php
+++ b/src/api/routes/people/people-properties.php
@@ -1,6 +1,5 @@
group('/people/properties', function () {
-
- $personPropertyAPIMiddleware = new PropertyAPIMiddleware("p");
+ $personPropertyAPIMiddleware = new PropertyAPIMiddleware('p');
$personAPIMiddleware = new PersonAPIMiddleware();
- $familyPropertyAPIMiddleware = new PropertyAPIMiddleware("f");
+ $familyPropertyAPIMiddleware = new PropertyAPIMiddleware('f');
$familyAPIMiddleware = new FamilyAPIMiddleware();
-
$this->get('/person', 'getAllPersonProperties');
$this->get('/person/{personId}', 'getPersonProperties')->add($personAPIMiddleware);
$this->post('/person/{personId}/{propertyId}', 'addPropertyToPerson')->add($personAPIMiddleware)->add($personPropertyAPIMiddleware);
@@ -30,54 +26,56 @@
$this->get('/family/{familyId}', 'getFamilyProperties')->add($familyAPIMiddleware);
$this->post('/family/{familyId}/{propertyId}', 'addPropertyToFamily')->add($familyAPIMiddleware)->add($familyPropertyAPIMiddleware);
$this->delete('/family/{familyId}/{propertyId}', 'removePropertyFromFamily')->add($familyAPIMiddleware)->add($familyPropertyAPIMiddleware);
-
-
})->add(new MenuOptionsRoleAuthMiddleware());
-
function getAllPersonProperties(Request $request, Response $response, array $args)
{
$properties = PropertyQuery::create()
- ->filterByProClass("p")
+ ->filterByProClass('p')
->find();
+
return $response->withJson($properties->toArray());
}
-function addPropertyToPerson (Request $request, Response $response, array $args)
+function addPropertyToPerson(Request $request, Response $response, array $args)
{
- $person = $request->getAttribute("person");
- return addProperty($request, $response, $person->getId(), $request->getAttribute("property"));
+ $person = $request->getAttribute('person');
+
+ return addProperty($request, $response, $person->getId(), $request->getAttribute('property'));
}
-function removePropertyFromPerson ($request, $response, $args)
+function removePropertyFromPerson($request, $response, $args)
{
- $person = $request->getAttribute("person");
- return removeProperty($response, $person->getId(), $request->getAttribute("property"));
+ $person = $request->getAttribute('person');
+
+ return removeProperty($response, $person->getId(), $request->getAttribute('property'));
}
function getAllFamilyProperties(Request $request, Response $response, array $args)
{
$properties = PropertyQuery::create()
- ->filterByProClass("f")
+ ->filterByProClass('f')
->find();
+
return $response->withJson($properties->toArray());
}
function getPersonProperties(Request $request, Response $response, array $args)
{
- $person = $request->getAttribute("person");
- return getProperties($response, "p", $person->getId());
-}
+ $person = $request->getAttribute('person');
+ return getProperties($response, 'p', $person->getId());
+}
function getFamilyProperties(Request $request, Response $response, array $args)
{
- $family = $request->getAttribute("family");
- return getProperties($response, "f", $family->getId());
-}
+ $family = $request->getAttribute('family');
+ return getProperties($response, 'f', $family->getId());
+}
-function getProperties(Response $response, $type, $id) {
+function getProperties(Response $response, $type, $id)
+{
$properties = RecordPropertyQuery::create()
->filterByRecordId($id)
->find();
@@ -85,18 +83,18 @@ function getProperties(Response $response, $type, $id) {
$finalProperties = [];
foreach ($properties as $property) {
- $rawProp =$property->getProperty();
+ $rawProp = $property->getProperty();
if ($rawProp->getProClass() == $type) {
$tempProp = [];
- $tempProp["id"] = $property->getPropertyId();
- $tempProp["name"] = $rawProp->getProName();
- $tempProp["value"] = $property->getPropertyValue();
+ $tempProp['id'] = $property->getPropertyId();
+ $tempProp['name'] = $rawProp->getProName();
+ $tempProp['value'] = $property->getPropertyValue();
if (AuthenticationManager::GetCurrentUser()->isEditRecordsEnabled()) {
- $tempProp["allowEdit"] = !empty(trim($rawProp->getProPrompt()));
- $tempProp["allowDelete"] = true;
- } else {
- $tempProp["allowEdit"] = false;
- $tempProp["allowDelete"] = false;
+ $tempProp['allowEdit'] = !empty(trim($rawProp->getProPrompt()));
+ $tempProp['allowDelete'] = true;
+ } else {
+ $tempProp['allowEdit'] = false;
+ $tempProp['allowDelete'] = false;
}
array_push($finalProperties, $tempProp);
}
@@ -105,29 +103,32 @@ function getProperties(Response $response, $type, $id) {
return $response->withJson($finalProperties);
}
-function addPropertyToFamily (Request $request, Response $response, array $args) {
- $family = $request->getAttribute("family");
- return addProperty($request, $response, $family->getId(), $request->getAttribute("property"));
+function addPropertyToFamily(Request $request, Response $response, array $args)
+{
+ $family = $request->getAttribute('family');
+
+ return addProperty($request, $response, $family->getId(), $request->getAttribute('property'));
}
-function removePropertyFromFamily ($request, $response, $args)
+function removePropertyFromFamily($request, $response, $args)
{
- $family = $request->getAttribute("family");
- return removeProperty($response, $family->getId(), $request->getAttribute("property"));
-}
+ $family = $request->getAttribute('family');
-function addProperty(Request $request, Response $response, $id, $property) {
+ return removeProperty($response, $family->getId(), $request->getAttribute('property'));
+}
+function addProperty(Request $request, Response $response, $id, $property)
+{
$personProperty = RecordPropertyQuery::create()
->filterByRecordId($id)
->filterByPropertyId($property->getProId())
->findOne();
- $propertyValue = "";
+ $propertyValue = '';
if (!empty($property->getProPrompt())) {
$data = $request->getParsedBody();
$propertyValue = empty($data['value']) ? 'N/A' : $data['value'];
- LoggerUtils::getAppLogger()->debug("final value is: " . $propertyValue);
+ LoggerUtils::getAppLogger()->debug('final value is: '.$propertyValue);
}
if ($personProperty) {
@@ -147,14 +148,15 @@ function addProperty(Request $request, Response $response, $id, $property) {
$personProperty->setRecordId($id);
$personProperty->setPropertyValue($propertyValue);
$personProperty->save();
+
return $response->withJson(['success' => true, 'msg' => gettext('The property is successfully assigned.')]);
}
return $response->withStatus(500, gettext('The property could not be assigned.'));
}
-function removeProperty($response, $id, $property) {
-
+function removeProperty($response, $id, $property)
+{
$personProperty = RecordPropertyQuery::create()
->filterByRecordId($id)
->filterByPropertyId($property->getProId())
diff --git a/src/api/routes/public/public-calendar.php b/src/api/routes/public/public-calendar.php
index dd64509180..e8471cf61a 100644
--- a/src/api/routes/public/public-calendar.php
+++ b/src/api/routes/public/public-calendar.php
@@ -16,26 +16,28 @@
function getJSON(Request $request, Response $response)
{
- $events = $request->getAttribute("events");
- return $response->withJson($events->toArray());
+ $events = $request->getAttribute('events');
+
+ return $response->withJson($events->toArray());
}
function getICal($request, $response)
{
- $calendar = $request->getAttribute("calendar");
- $events = $request->getAttribute("events");
- $calendarName = $calendar->getName() . ": " . ChurchMetaData::getChurchName();
- $CalendarICS = new iCal($events, $calendarName);
- $body = $response->getBody();
- $body->write($CalendarICS->toString());
-
- return $response->withHeader('Content-type', 'text/calendar; charset=utf-8')
- ->withHeader('Content-Disposition', 'attachment; filename=calendar.ics');;
+ $calendar = $request->getAttribute('calendar');
+ $events = $request->getAttribute('events');
+ $calendarName = $calendar->getName().': '.ChurchMetaData::getChurchName();
+ $CalendarICS = new iCal($events, $calendarName);
+ $body = $response->getBody();
+ $body->write($CalendarICS->toString());
+
+ return $response->withHeader('Content-type', 'text/calendar; charset=utf-8')
+ ->withHeader('Content-Disposition', 'attachment; filename=calendar.ics');
}
function getPublicCalendarFullCalendarEvents($request, Response $response)
{
- $calendar = $request->getAttribute("calendar");
- $events = $request->getAttribute("events");
- return $response->write(json_encode(EventsObjectCollectionToFullCalendar($events, $calendar)));
+ $calendar = $request->getAttribute('calendar');
+ $events = $request->getAttribute('events');
+
+ return $response->write(json_encode(EventsObjectCollectionToFullCalendar($events, $calendar)));
}
diff --git a/src/api/routes/public/public-data.php b/src/api/routes/public/public-data.php
index 9012633dd2..9bab250674 100644
--- a/src/api/routes/public/public-data.php
+++ b/src/api/routes/public/public-data.php
@@ -12,7 +12,6 @@
$this->get('/countries/{countryCode}/states/', 'getStates');
});
-
function getCountries(Request $request, Response $response, array $args)
{
return $response->withJson(array_values(Countries::getAll()));
@@ -21,5 +20,6 @@ function getCountries(Request $request, Response $response, array $args)
function getStates(Request $request, Response $response, array $args)
{
$states = new States($args['countryCode']);
+
return $response->withJson($states->getAll());
}
diff --git a/src/api/routes/public/public-register.php b/src/api/routes/public/public-register.php
index b9e8ed218a..870be50ca0 100644
--- a/src/api/routes/public/public-register.php
+++ b/src/api/routes/public/public-register.php
@@ -19,7 +19,7 @@ function registerFamilyAPI(Request $request, Response $response, array $args)
{
$family = new Family();
- $familyMetadata = (object)$request->getParsedBody();
+ $familyMetadata = (object) $request->getParsedBody();
$family->setName($familyMetadata->Name);
$family->setAddress1($familyMetadata->Address1);
@@ -42,17 +42,17 @@ function registerFamilyAPI(Request $request, Response $response, array $args)
$person = new Person();
$person->setEnteredBy(Person::SELF_REGISTER);
$person->setDateEntered(new \DateTime());
- $person->setFirstName($personMetaData["firstName"]);
- $person->setLastName($personMetaData["lastName"]);
- $person->setGender($personMetaData["gender"]);
- $person->setFmrId($personMetaData["role"]);
- $person->setEmail($personMetaData["email"]);
- $person->setCellPhone($personMetaData["cellPhone"]);
- $person->setHomePhone($personMetaData["homePhone"]);
- $person->setWorkPhone($personMetaData["workPhone"]);
- $person->setFlags($personMetaData["hideAge"] ? "1" : 0);
-
- $birthday = $personMetaData["birthday"];
+ $person->setFirstName($personMetaData['firstName']);
+ $person->setLastName($personMetaData['lastName']);
+ $person->setGender($personMetaData['gender']);
+ $person->setFmrId($personMetaData['role']);
+ $person->setEmail($personMetaData['email']);
+ $person->setCellPhone($personMetaData['cellPhone']);
+ $person->setHomePhone($personMetaData['homePhone']);
+ $person->setWorkPhone($personMetaData['workPhone']);
+ $person->setFlags($personMetaData['hideAge'] ? '1' : 0);
+
+ $birthday = $personMetaData['birthday'];
if (!empty($birthday)) {
$birthdayDate = \DateTime::createFromFormat('m/d/Y', $birthday);
$person->setBirthDay($birthdayDate->format('d'));
@@ -61,16 +61,16 @@ function registerFamilyAPI(Request $request, Response $response, array $args)
}
if (!$person->validate()) {
- LoggerUtils::getAppLogger()->error("Public Reg Error with the following data: " . json_encode($personMetaData));
- return $response->withStatus(401)->withJson(["error" => gettext("Validation Error"),
- "failures" => ORMUtils::getValidationErrors($person->getValidationFailures())]);
+ LoggerUtils::getAppLogger()->error('Public Reg Error with the following data: '.json_encode($personMetaData));
+
+ return $response->withStatus(401)->withJson(['error' => gettext('Validation Error'),
+ 'failures' => ORMUtils::getValidationErrors($person->getValidationFailures())]);
}
array_push($familyMembers, $person);
}
-
} else {
- return $response->withStatus(400)->withJson(["error" => gettext("Validation Error"),
- "failures" => ORMUtils::getValidationErrors($family->getValidationFailures())]);
+ return $response->withStatus(400)->withJson(['error' => gettext('Validation Error'),
+ 'failures' => ORMUtils::getValidationErrors($family->getValidationFailures())]);
}
$family->save();
@@ -81,12 +81,12 @@ function registerFamilyAPI(Request $request, Response $response, array $args)
}
$family->save();
- return $response->withHeader('Content-Type','application/json')->write($family->exportTo('JSON'));
+
+ return $response->withHeader('Content-Type', 'application/json')->write($family->exportTo('JSON'));
}
function registerPersonAPI(Request $request, Response $response, array $args)
{
-
$person = new Person();
$person->fromJSON($request->getBody());
$person->setId(); //ignore any ID set in the payload
@@ -94,9 +94,10 @@ function registerPersonAPI(Request $request, Response $response, array $args)
$person->setDateEntered(new \DateTime());
if ($person->validate()) {
$person->save();
- return $response->withHeader('Content-Type','application/json')->write($person->exportTo('JSON'));
+
+ return $response->withHeader('Content-Type', 'application/json')->write($person->exportTo('JSON'));
}
- return $response->withStatus(400)->withJson(["error" => gettext("Validation Error"),
- "failures" => ORMUtils::getValidationErrors($person->getValidationFailures())]);
+ return $response->withStatus(400)->withJson(['error' => gettext('Validation Error'),
+ 'failures' => ORMUtils::getValidationErrors($person->getValidationFailures())]);
}
diff --git a/src/api/routes/public/public-user.php b/src/api/routes/public/public-user.php
index 653f8b23b7..3abc85de4c 100644
--- a/src/api/routes/public/public-user.php
+++ b/src/api/routes/public/public-user.php
@@ -7,7 +7,6 @@
$app->group('/public/user', function () {
$this->post('/login', 'userLogin');
$this->post('/login/', 'userLogin');
-
});
function userLogin(Request $request, Response $response, array $args)
@@ -18,12 +17,12 @@ function userLogin(Request $request, Response $response, array $args)
if (!empty($user)) {
$password = $body->password;
if ($user->isPasswordValid($password)) {
- return $response->withJson(["apiKey" => $user->getApiKey()]);
+ return $response->withJson(['apiKey' => $user->getApiKey()]);
} else {
return $response->withStatus(401, gettext('Invalid User/Password'));
}
}
}
+
return $response->withStatus(404);
}
-
diff --git a/src/api/routes/public/public.php b/src/api/routes/public/public.php
index 0dd4cfeda1..83884e46f1 100644
--- a/src/api/routes/public/public.php
+++ b/src/api/routes/public/public.php
@@ -7,15 +7,14 @@
$this->get('/echo', 'getEhco');
});
-
/**
- *
- * @param \Slim\Http\Request $p_request The request.
+ * @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
- * @param array $p_args Arguments
+ * @param array $p_args Arguments
+ *
* @return \Slim\Http\Response The augmented response.
*/
function getEhco(Request $request, Response $response, array $p_args)
{
- return $response->withJson(["message" => "echo"]);
+ return $response->withJson(['message' => 'echo']);
}
diff --git a/src/api/routes/search.php b/src/api/routes/search.php
index 4cfd773669..6c58fd070a 100644
--- a/src/api/routes/search.php
+++ b/src/api/routes/search.php
@@ -30,14 +30,13 @@
new GroupSearchResultProvider(),
new FinanceDepositSearchResultProvider(),
new FinancePaymentSearchResultProvider(),
- new CalendarEventSearchResultProvider()
+ new CalendarEventSearchResultProvider(),
];
- foreach($resultsProviders as $provider)
- {
+ foreach ($resultsProviders as $provider) {
/* @var $provider iSearchResultProvider */
- array_push($resultsArray,$provider->getSearchResults($query));
-
+ array_push($resultsArray, $provider->getSearchResults($query));
}
+
return $response->withJson(array_values(array_filter($resultsArray)));
});
diff --git a/src/api/routes/system/system-config.php b/src/api/routes/system/system-config.php
index 6f36f601b2..38415c8a5f 100644
--- a/src/api/routes/system/system-config.php
+++ b/src/api/routes/system/system-config.php
@@ -14,13 +14,14 @@
function getConfigValueByNameAPI(Request $request, Response $response, array $args)
{
- return $response->withJson(["value" => SystemConfig::getValue($args['configName'])]);
+ return $response->withJson(['value' => SystemConfig::getValue($args['configName'])]);
}
function setConfigValueByNameAPI(Request $request, Response $response, array $args)
{
$configName = $args['configName'];
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
SystemConfig::setValue($configName, $input->value);
- return $response->withJson(["value" => SystemConfig::getValue($configName)]);
+
+ return $response->withJson(['value' => SystemConfig::getValue($configName)]);
}
diff --git a/src/api/routes/system/system-custom-fields.php b/src/api/routes/system/system-custom-fields.php
index 98ccff7687..2fa6edb5b3 100644
--- a/src/api/routes/system/system-custom-fields.php
+++ b/src/api/routes/system/system-custom-fields.php
@@ -10,13 +10,13 @@
$this->get('/person/', 'getPersonFieldsByType');
})->add(new AdminRoleAuthMiddleware());
-
/**
* A method that does the work to handle getting an existing person custom fields by type.
*
- * @param \Slim\Http\Request $p_request The request.
+ * @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
- * @param array $p_args Arguments
+ * @param array $p_args Arguments
+ *
* @return \Slim\Http\Response The augmented response.
*/
function getPersonFieldsByType(Request $request, Response $response, array $p_args)
@@ -29,7 +29,7 @@ function getPersonFieldsByType(Request $request, Response $response, array $p_ar
$keyValue = [];
foreach ($fields as $field) {
- array_push($keyValue, ["id" => $field->getId(), "value" => $field->getName()]);
+ array_push($keyValue, ['id' => $field->getId(), 'value' => $field->getName()]);
}
return $response->withJson($keyValue);
diff --git a/src/api/routes/system/system-custom-menu.php b/src/api/routes/system/system-custom-menu.php
index d2c79a78bc..28a3b809ff 100644
--- a/src/api/routes/system/system-custom-menu.php
+++ b/src/api/routes/system/system-custom-menu.php
@@ -7,7 +7,6 @@
use Slim\Http\Request;
use Slim\Http\Response;
-
$app->group('/system/menu', function () {
$this->get('', 'getMenus');
$this->get('/', 'getMenus');
@@ -17,15 +16,13 @@
$this->delete('/{linkId:[0-9]+}', 'delMenu');
})->add(new AdminRoleAuthMiddleware());
-
function getMenus(Request $request, Response $response, array $args)
{
$links = MenuLinkQuery::create()->orderByOrder()->find();
- return $response->withJson(["menus" => $links->toArray()]);
+ return $response->withJson(['menus' => $links->toArray()]);
}
-
function addMenu(Request $request, Response $response, array $args)
{
$link = new MenuLink();
@@ -33,18 +30,21 @@ function addMenu(Request $request, Response $response, array $args)
if ($link->validate()) {
$link->save();
+
return $response->withJson($link->toArray());
}
- return $response->withStatus(400)->withJson(["error" => gettext("Validation Error"),
- "failures" => ORMUtils::getValidationErrors($link->getValidationFailures())]);
+
+ return $response->withStatus(400)->withJson(['error' => gettext('Validation Error'),
+ 'failures' => ORMUtils::getValidationErrors($link->getValidationFailures())]);
}
function delMenu(Request $request, Response $response, array $args)
{
- $link = MenuLinkQuery::create()->findPk($args["linkId"]);
+ $link = MenuLinkQuery::create()->findPk($args['linkId']);
if (empty($link)) {
- return $response->withStatus(404, gettext("Link Not found"). ": " . $args["linkId"]);
+ return $response->withStatus(404, gettext('Link Not found').': '.$args['linkId']);
}
$link->delete();
+
return $response->withStatus(200);
}
diff --git a/src/api/routes/system/system-database.php b/src/api/routes/system/system-database.php
index 015c5a8abf..87f5e4f67e 100644
--- a/src/api/routes/system/system-database.php
+++ b/src/api/routes/system/system-database.php
@@ -24,39 +24,40 @@
use Slim\Http\Response;
$app->group('/database', function () {
-
$this->delete('/reset', 'resetDatabase');
$this->delete('/people/clear', 'clearPeopleTables');
$this->get('/people/export/chmeetings', 'exportChMeetings');
$this->post('/backup', function ($request, $response, $args) {
- $input = (object)$request->getParsedBody();
- $BaseName = preg_replace('/[^a-zA-Z0-9\-_]/','', SystemConfig::getValue('sChurchName')). "-" . date(SystemConfig::getValue("sDateFilenameFormat"));
+ $input = (object) $request->getParsedBody();
+ $BaseName = preg_replace('/[^a-zA-Z0-9\-_]/', '', SystemConfig::getValue('sChurchName')).'-'.date(SystemConfig::getValue('sDateFilenameFormat'));
$BackupType = $input->BackupType;
- $Backup = new BackupJob($BaseName, $BackupType, SystemConfig::getValue('bBackupExtraneousImages'), isset($input->EncryptBackup) ? $input->EncryptBackup : "", isset($input->BackupPassword) ? $input->BackupPassword : "");
+ $Backup = new BackupJob($BaseName, $BackupType, SystemConfig::getValue('bBackupExtraneousImages'), isset($input->EncryptBackup) ? $input->EncryptBackup : '', isset($input->BackupPassword) ? $input->BackupPassword : '');
$Backup->Execute();
+
return $response->withJson($Backup);
});
$this->post('/backupRemote', function ($request, $response, $args) {
- if (SystemConfig::getValue('sExternalBackupUsername') && SystemConfig::getValue('sExternalBackupPassword') && SystemConfig::getValue('sExternalBackupEndpoint')) {
- $input = (object)$request->getParsedBody();
- $BaseName = preg_replace('/[^a-zA-Z0-9\-_]/','', SystemConfig::getValue('sChurchName')). "-" . date(SystemConfig::getValue("sDateFilenameFormat"));
- $BackupType = $input->BackupType;
- $Backup = new BackupJob($BaseName, $BackupType, SystemConfig::getValue('bBackupExtraneousImages'));
- $Backup->Execute();
- $copyStatus = $Backup->CopyToWebDAV(SystemConfig::getValue('sExternalBackupEndpoint'), SystemConfig::getValue('sExternalBackupUsername'), SystemConfig::getValue('sExternalBackupPassword'));
- return $response->withJson($copyStatus);
- }
- else {
- throw new \Exception('WebDAV backups are not correctly configured. Please ensure endpoint, username, and password are set', 500);
- }
+ if (SystemConfig::getValue('sExternalBackupUsername') && SystemConfig::getValue('sExternalBackupPassword') && SystemConfig::getValue('sExternalBackupEndpoint')) {
+ $input = (object) $request->getParsedBody();
+ $BaseName = preg_replace('/[^a-zA-Z0-9\-_]/', '', SystemConfig::getValue('sChurchName')).'-'.date(SystemConfig::getValue('sDateFilenameFormat'));
+ $BackupType = $input->BackupType;
+ $Backup = new BackupJob($BaseName, $BackupType, SystemConfig::getValue('bBackupExtraneousImages'));
+ $Backup->Execute();
+ $copyStatus = $Backup->CopyToWebDAV(SystemConfig::getValue('sExternalBackupEndpoint'), SystemConfig::getValue('sExternalBackupUsername'), SystemConfig::getValue('sExternalBackupPassword'));
+
+ return $response->withJson($copyStatus);
+ } else {
+ throw new \Exception('WebDAV backups are not correctly configured. Please ensure endpoint, username, and password are set', 500);
+ }
});
$this->post('/restore', function ($request, $response, $args) {
$RestoreJob = new RestoreJob();
$RestoreJob->Execute();
+
return $response->withJson($RestoreJob);
});
@@ -66,47 +67,47 @@
});
})->add(new AdminRoleAuthMiddleware());
-
/**
- * A method that drops all db tables
+ * A method that drops all db tables.
*
- * @param \Slim\Http\Request $p_request The request.
+ * @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
- * @param array $p_args Arguments
+ * @param array $p_args Arguments
+ *
* @return \Slim\Http\Response The augmented response.
*/
-function exportChMeetings(Request $request, Response $response, array $p_args) {
-
- $header_data=array(
- 'First Name','Last Name','Middle Name','Gender',
- 'Marital Status','Anniversary','Engagement Date',
- 'Birthdate','Mobile Phone','Home Phone','Email',
- 'Facebook','School','Grade','Employer','Job Title','Talents And Hobbies',
- 'Address Line','Address Line 2','City','State','ZIP Code','Notes','Join Date',
- 'Family Id','Family Role',
- 'Baptism Date','Baptism Location','Nickname');
+function exportChMeetings(Request $request, Response $response, array $p_args)
+{
+ $header_data = [
+ 'First Name', 'Last Name', 'Middle Name', 'Gender',
+ 'Marital Status', 'Anniversary', 'Engagement Date',
+ 'Birthdate', 'Mobile Phone', 'Home Phone', 'Email',
+ 'Facebook', 'School', 'Grade', 'Employer', 'Job Title', 'Talents And Hobbies',
+ 'Address Line', 'Address Line 2', 'City', 'State', 'ZIP Code', 'Notes', 'Join Date',
+ 'Family Id', 'Family Role',
+ 'Baptism Date', 'Baptism Location', 'Nickname'];
$people = PersonQuery::create()->find();
- $list = array();
+ $list = [];
foreach ($people as $person) {
$family = $person->getFamily();
- $annaversery = ($family ? $family->getWeddingdate(SystemConfig::getValue("sDateFormatShort")) : "");
+ $annaversery = ($family ? $family->getWeddingdate(SystemConfig::getValue('sDateFormatShort')) : '');
$familyRole = $person->getFamilyRoleName();
- if ($familyRole == "Head of Household") {
- $familyRole = "Primary";
+ if ($familyRole == 'Head of Household') {
+ $familyRole = 'Primary';
}
- $chPerson = array($person->getFirstName(), $person->getLastName(), $person->getMiddleName(), $person->getGenderName(),
- '', $annaversery, "",
+ $chPerson = [$person->getFirstName(), $person->getLastName(), $person->getMiddleName(), $person->getGenderName(),
+ '', $annaversery, '',
$person->getFormattedBirthDate(), $person->getCellPhone(), $person->getHomePhone(), $person->getEmail(),
- $person->getFacebookID(), "","", "", "", "",
- $person->getAddress1(), $person->getAddress2(), $person->getCity(), $person->getState(), $person->getZip(), "", $person->getMembershipDate(SystemConfig::getValue("sDateFormatShort")),
- ($family? $family->getId(): ""), $familyRole,
- "", "", "");
+ $person->getFacebookID(), '', '', '', '', '',
+ $person->getAddress1(), $person->getAddress2(), $person->getCity(), $person->getState(), $person->getZip(), '', $person->getMembershipDate(SystemConfig::getValue('sDateFormatShort')),
+ $family ? $family->getId() : '', $familyRole,
+ '', '', ''];
array_push($list, $chPerson);
}
$stream = fopen('php://memory', 'w+');
- fputcsv($stream,$header_data);
+ fputcsv($stream, $header_data);
foreach ($list as $fields) {
fputcsv($stream, $fields, ',');
}
@@ -114,17 +115,18 @@ function exportChMeetings(Request $request, Response $response, array $p_args) {
rewind($stream);
$response = $response->withHeader('Content-Type', 'text/csv');
- $response = $response->withHeader('Content-Disposition', 'attachment; filename="ChMeetings-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv"');
+ $response = $response->withHeader('Content-Disposition', 'attachment; filename="ChMeetings-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv"');
return $response->withBody(new \Slim\Http\Stream($stream));
}
/**
- * A method that drops all db tables
+ * A method that drops all db tables.
*
- * @param \Slim\Http\Request $p_request The request.
+ * @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
- * @param array $p_args Arguments
+ * @param array $p_args Arguments
+ *
* @return \Slim\Http\Response The augmented response.
*/
function resetDatabase(Request $request, Response $response, array $p_args)
@@ -132,21 +134,21 @@ function resetDatabase(Request $request, Response $response, array $p_args)
$connection = Propel::getConnection();
$logger = LoggerUtils::getAppLogger();
- $logger->info("DB Drop started ");
+ $logger->info('DB Drop started ');
- $statement = $connection->prepare("SHOW FULL TABLES;");
+ $statement = $connection->prepare('SHOW FULL TABLES;');
$statement->execute();
$dbTablesSQLs = $statement->fetchAll();
foreach ($dbTablesSQLs as $dbTable) {
- if ($dbTable[1] == "VIEW") {
- $alterSQL = "DROP VIEW " . $dbTable[0] . " ;";
+ if ($dbTable[1] == 'VIEW') {
+ $alterSQL = 'DROP VIEW '.$dbTable[0].' ;';
} else {
- $alterSQL = "DROP TABLE " . $dbTable[0] . " ;";
+ $alterSQL = 'DROP TABLE '.$dbTable[0].' ;';
}
$dbAlterStatement = $connection->exec($alterSQL);
- $logger->info("DB Update: " . $alterSQL . " done.");
+ $logger->info('DB Update: '.$alterSQL.' done.');
}
return $response->withJson(['success' => true, 'msg' => gettext('The database has been cleared.')]);
@@ -157,44 +159,42 @@ function clearPeopleTables(Request $request, Response $response, array $p_args)
$connection = Propel::getConnection();
$logger = LoggerUtils::getAppLogger();
$curUserId = AuthenticationManager::GetCurrentUser()->getId();
- $logger->info("People DB Clear started ");
-
+ $logger->info('People DB Clear started ');
FamilyCustomQuery::create()->deleteAll($connection);
- $logger->info("Family custom deleted ");
+ $logger->info('Family custom deleted ');
FamilyQuery::create()->deleteAll($connection);
- $logger->info("Families deleted");
+ $logger->info('Families deleted');
// Delete Family Photos
- FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot() . "/Family/", Photo::getValidExtensions());
- FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot() . "/Family/thumbnails/", Photo::getValidExtensions());
- $logger->info("family photos deleted");
+ FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot().'/Family/', Photo::getValidExtensions());
+ FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot().'/Family/thumbnails/', Photo::getValidExtensions());
+ $logger->info('family photos deleted');
Person2group2roleP2g2rQuery::create()->deleteAll($connection);
- $logger->info("Person Group Roles deleted");
+ $logger->info('Person Group Roles deleted');
PersonCustomQuery::create()->deleteAll($connection);
- $logger->info("Person Custom deleted");
+ $logger->info('Person Custom deleted');
PersonVolunteerOpportunityQuery::create()->deleteAll($connection);
- $logger->info("Person Volunteer deleted");
+ $logger->info('Person Volunteer deleted');
UserQuery::create()->filterByPersonId($curUserId, Criteria::NOT_EQUAL)->delete($connection);
- $logger->info("Users aide from person logged in deleted");
+ $logger->info('Users aide from person logged in deleted');
PersonQuery::create()->filterById($curUserId, Criteria::NOT_EQUAL)->delete($connection);
- $logger->info("Persons aide from person logged in deleted");
+ $logger->info('Persons aide from person logged in deleted');
// Delete Person Photos
- FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot() . "/Person/", Photo::getValidExtensions());
- FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot() . "/Person/thumbnails/", Photo::getValidExtensions());
+ FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot().'/Person/', Photo::getValidExtensions());
+ FileSystemUtils::deleteFiles(SystemURLs::getImagesRoot().'/Person/thumbnails/', Photo::getValidExtensions());
- $logger->info("people photos deleted");
+ $logger->info('people photos deleted');
NoteQuery::create()->filterByPerId($curUserId, Criteria::NOT_EQUAL)->delete($connection);
- $logger->info("Notes deleted");
+ $logger->info('Notes deleted');
return $response->withJson(['success' => true, 'msg' => gettext('The people and families has been cleared from the database.')]);
}
-
diff --git a/src/api/routes/system/system-debug.php b/src/api/routes/system/system-debug.php
index 132b0e7fdf..662ac329ae 100644
--- a/src/api/routes/system/system-debug.php
+++ b/src/api/routes/system/system-debug.php
@@ -12,9 +12,9 @@
function getSystemURLAPI(Request $request, Response $response, array $args)
{
return $response->withJson([
- "RootPath" => SystemURLs::getRootPath(),
- "ImagesRoot" => SystemURLs::getImagesRoot(),
- "DocumentRoot" => SystemURLs::getDocumentRoot(),
- "SupportURL" => SystemURLs::getSupportURL()
+ 'RootPath' => SystemURLs::getRootPath(),
+ 'ImagesRoot' => SystemURLs::getImagesRoot(),
+ 'DocumentRoot' => SystemURLs::getDocumentRoot(),
+ 'SupportURL' => SystemURLs::getSupportURL(),
]);
}
diff --git a/src/api/routes/system/system-locale.php b/src/api/routes/system/system-locale.php
index 25e3175729..a165e64f70 100644
--- a/src/api/routes/system/system-locale.php
+++ b/src/api/routes/system/system-locale.php
@@ -1,57 +1,51 @@
group('/locale', function () {
$this->get('/database/terms', 'getDBTerms');
})->add(new AdminRoleAuthMiddleware());
-
/**
- * A method that gets locale terms from the db for po generation
+ * A method that gets locale terms from the db for po generation.
*
- * @param \Slim\Http\Request $p_request The request.
+ * @param \Slim\Http\Request $p_request The request.
* @param \Slim\Http\Response $p_response The response.
- * @param array $p_args Arguments
+ * @param array $p_args Arguments
+ *
* @return \Slim\Http\Response The augmented response.
*/
function getDBTerms(Request $request, Response $response, array $p_args)
{
- $terms = array();
+ $terms = [];
- $dbTerms = UserConfigQuery::create()->select(array('ucfg_tooltip'))->distinct()->find();
+ $dbTerms = UserConfigQuery::create()->select(['ucfg_tooltip'])->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term);
}
- $dbTerms = QueryParameterOptionsQuery::create()->select(array('qpo_Display'))->distinct()->find();
+ $dbTerms = QueryParameterOptionsQuery::create()->select(['qpo_Display'])->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term);
}
- $dbTerms = PredefinedReportsQuery::create()->select(array('qry_Name','qry_Description'))->distinct()->find();
+ $dbTerms = PredefinedReportsQuery::create()->select(['qry_Name', 'qry_Description'])->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term['qry_Name']);
array_push($terms, $term['qry_Description']);
}
- $dbTerms = QueryParametersQuery::create()->select(array('qrp_Name','qrp_Description'))->distinct()->find();
+ $dbTerms = QueryParametersQuery::create()->select(['qrp_Name', 'qrp_Description'])->distinct()->find();
foreach ($dbTerms as $term) {
array_push($terms, $term['qrp_Name']);
array_push($terms, $term['qrp_Description']);
}
-
-
return $response->withJson(['terms' => $terms]);
-
}
-
-
-
diff --git a/src/api/routes/system/system-register.php b/src/api/routes/system/system-register.php
index c1896ce9cf..7916973181 100644
--- a/src/api/routes/system/system-register.php
+++ b/src/api/routes/system/system-register.php
@@ -6,7 +6,7 @@
$app->group('/register', function () {
$this->post('', function ($request, $response, $args) {
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$registrationData = new \stdClass();
$registrationData->sName = SystemConfig::getValue('sChurchName');
diff --git a/src/api/routes/system/system-upgrade.php b/src/api/routes/system/system-upgrade.php
index 1831da0a7d..223f619f1d 100644
--- a/src/api/routes/system/system-upgrade.php
+++ b/src/api/routes/system/system-upgrade.php
@@ -7,12 +7,14 @@
$app->group('/systemupgrade', function () {
$this->get('/downloadlatestrelease', function ($request, Response $response, $args) {
$upgradeFile = ChurchCRMReleaseManager::downloadLatestRelease();
+
return $response->withJson($upgradeFile);
});
$this->post('/doupgrade', function ($request, $response, $args) {
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$upgradeResult = ChurchCRMReleaseManager::doUpgrade($input->fullPath, $input->sha1);
+
return $response->withJson($upgradeResult);
});
})->add(new AdminRoleAuthMiddleware());
diff --git a/src/api/routes/system/system.php b/src/api/routes/system/system.php
index bf9ed23052..4425912452 100644
--- a/src/api/routes/system/system.php
+++ b/src/api/routes/system/system.php
@@ -21,18 +21,17 @@ function logCSPReportAPI(Request $request, Response $response, array $args)
function getUiNotificationAPI(Request $request, Response $response, array $args)
{
- if (NotificationService::isUpdateRequired())
- {
+ if (NotificationService::isUpdateRequired()) {
NotificationService::updateNotifications();
}
$notifications = [];
foreach (NotificationService::getNotifications() as $notification) {
- $uiNotification = new UiNotification($notification->title, "bell", $notification->link, "", "danger", "8000", "bottom", "left");
+ $uiNotification = new UiNotification($notification->title, 'bell', $notification->link, '', 'danger', '8000', 'bottom', 'left');
array_push($notifications, $uiNotification);
}
$taskSrv = new TaskService();
$notifications = array_merge($notifications, $taskSrv->getTaskNotifications());
- return $response->withJson(["notifications" => $notifications]);
+ return $response->withJson(['notifications' => $notifications]);
}
diff --git a/src/api/routes/users/user-admin.php b/src/api/routes/users/user-admin.php
index d118ce4190..b69aa7ba41 100644
--- a/src/api/routes/users/user-admin.php
+++ b/src/api/routes/users/user-admin.php
@@ -13,52 +13,54 @@
use Slim\Http\Response;
$app->group('/user/{userId:[0-9]+}', function () {
- $this->post("/password/reset", "resetPasswordAPI");
- $this->post('/disableTwoFactor', "disableTwoFactor");
- $this->post('/login/reset', "resetLogin");
- $this->delete('/', "deleteUser");
- $this->get("/permissions", "getUserPermissionsAPI");
+ $this->post('/password/reset', 'resetPasswordAPI');
+ $this->post('/disableTwoFactor', 'disableTwoFactor');
+ $this->post('/login/reset', 'resetLogin');
+ $this->delete('/', 'deleteUser');
+ $this->get('/permissions', 'getUserPermissionsAPI');
})->add(new AdminRoleAuthMiddleware())->add(new UserAPIMiddleware());
function resetPasswordAPI(Request $request, Response $response, array $args)
{
-
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$password = $user->resetPasswordToRandom();
$user->save();
- $user->createTimeLineNote("password-reset");
+ $user->createTimeLineNote('password-reset');
$email = new ResetPasswordEmail($user, $password);
if ($email->send()) {
return $response->withStatus(200);
} else {
LoggerUtils::getAppLogger()->error($email->getError());
+
throw new Exception($email->getError());
}
}
function disableTwoFactor(Request $request, Response $response, array $args)
{
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$user->disableTwoFactorAuthentication();
+
return $response->withStatus(200);
}
function resetLogin(Request $request, Response $response, array $args)
{
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$user->setFailedLogins(0);
$user->save();
- $user->createTimeLineNote("login-reset");
+ $user->createTimeLineNote('login-reset');
$email = new UnlockedEmail($user);
if (!$email->send()) {
LoggerUtils::getAppLogger()->warning($email->getError());
}
+
return $response->withStatus(200);
}
function deleteUser(Request $request, Response $response, array $args)
{
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$userName = $user->getName();
$userConfig = UserConfigQuery::create()->findPk($user->getId());
if (!is_null($userConfig)) {
@@ -66,19 +68,20 @@ function deleteUser(Request $request, Response $response, array $args)
}
$user->delete();
- if (SystemConfig::getBooleanValue("bSendUserDeletedEmail")) {
+ if (SystemConfig::getBooleanValue('bSendUserDeletedEmail')) {
$email = new AccountDeletedEmail($user);
if (!$email->send()) {
LoggerUtils::getAppLogger()->warning($email->getError());
}
}
- return $response->withJson(["user" => $userName]);
-}
+ return $response->withJson(['user' => $userName]);
+}
function getUserPermissionsAPI(Request $request, Response $response, array $args)
{
$userId = $args['userId'];
$user = UserQuery::create()->findPk($userId);
- return $response->withJson(["user" => $user->getName(), "userId" => $user->getId(), "addEvent" => $user->isAddEvent(), "csvExport" => $user->isCSVExport()]);
+
+ return $response->withJson(['user' => $user->getName(), 'userId' => $user->getId(), 'addEvent' => $user->isAddEvent(), 'csvExport' => $user->isCSVExport()]);
}
diff --git a/src/api/routes/users/user-current.php b/src/api/routes/users/user-current.php
index 9269b4160a..7041059092 100644
--- a/src/api/routes/users/user-current.php
+++ b/src/api/routes/users/user-current.php
@@ -7,51 +7,55 @@
use Slim\Http\Response;
$app->group('/user/current', function () {
- $this->post("/refresh2fasecret", "refresh2fasecret");
- $this->post("/refresh2farecoverycodes", "refresh2farecoverycodes");
- $this->post("/remove2fasecret", "remove2fasecret");
- $this->post("/test2FAEnrollmentCode", "test2FAEnrollmentCode");
- $this->get("/get2faqrcode",'get2faqrcode');
+ $this->post('/refresh2fasecret', 'refresh2fasecret');
+ $this->post('/refresh2farecoverycodes', 'refresh2farecoverycodes');
+ $this->post('/remove2fasecret', 'remove2fasecret');
+ $this->post('/test2FAEnrollmentCode', 'test2FAEnrollmentCode');
+ $this->get('/get2faqrcode', 'get2faqrcode');
});
function refresh2fasecret(Request $request, Response $response, array $args)
{
$user = AuthenticationManager::GetCurrentUser();
$secret = $user->provisionNew2FAKey();
- LoggerUtils::getAuthLogger()->info("Began 2FA enrollment for user: " . $user->getUserName());
- return $response->withJson(["TwoFAQRCodeDataUri" => LocalAuthentication::GetTwoFactorQRCode($user->getUserName(),$secret)->writeDataUri()]);
+ LoggerUtils::getAuthLogger()->info('Began 2FA enrollment for user: '.$user->getUserName());
+
+ return $response->withJson(['TwoFAQRCodeDataUri' => LocalAuthentication::GetTwoFactorQRCode($user->getUserName(), $secret)->writeDataUri()]);
}
function refresh2farecoverycodes(Request $request, Response $response, array $args)
{
$user = AuthenticationManager::GetCurrentUser();
- return $response->withJson(["TwoFARecoveryCodes" => $user->getNewTwoFARecoveryCodes()]);
+
+ return $response->withJson(['TwoFARecoveryCodes' => $user->getNewTwoFARecoveryCodes()]);
}
function remove2fasecret(Request $request, Response $response, array $args)
{
$user = AuthenticationManager::GetCurrentUser();
$user->remove2FAKey();
+
return $response->withJson([]);
}
function get2faqrcode(Request $request, Response $response, array $args)
{
$user = AuthenticationManager::GetCurrentUser();
- $response = $response->withHeader("Content-Type", "image/png");
- return $response->write(LocalAuthentication::GetTwoFactorQRCode($user->getUserName(),$user->getDecryptedTwoFactorAuthSecret())->writeString());
+ $response = $response->withHeader('Content-Type', 'image/png');
+
+ return $response->write(LocalAuthentication::GetTwoFactorQRCode($user->getUserName(), $user->getDecryptedTwoFactorAuthSecret())->writeString());
}
function test2FAEnrollmentCode(Request $request, Response $response, array $args)
{
- $requestParsedBody = (object)$request->getParsedBody();
+ $requestParsedBody = (object) $request->getParsedBody();
$user = AuthenticationManager::GetCurrentUser();
$result = $user->confirmProvisional2FACode($requestParsedBody->enrollmentCode);
if ($result) {
- LoggerUtils::getAuthLogger()->info("Completed 2FA enrollment for user: " . $user->getUserName());
- }
- else {
- LoggerUtils::getAuthLogger()->notice("Unsuccessful 2FA enrollment for user: " . $user->getUserName());
+ LoggerUtils::getAuthLogger()->info('Completed 2FA enrollment for user: '.$user->getUserName());
+ } else {
+ LoggerUtils::getAuthLogger()->notice('Unsuccessful 2FA enrollment for user: '.$user->getUserName());
}
- return $response->withJson(["IsEnrollmentCodeValid" => $result]);
+
+ return $response->withJson(['IsEnrollmentCodeValid' => $result]);
}
diff --git a/src/api/routes/users/user-settings.php b/src/api/routes/users/user-settings.php
index e5da54a50b..f191bf65a4 100644
--- a/src/api/routes/users/user-settings.php
+++ b/src/api/routes/users/user-settings.php
@@ -1,35 +1,34 @@
group('/user/{userId:[0-9]+}/setting', function () {
- $this->get("/{settingName}", "getUserSetting");
- $this->post("/{settingName}", "updateUserSetting");
+ $this->get('/{settingName}', 'getUserSetting');
+ $this->post('/{settingName}', 'updateUserSetting');
})->add(new UserAPIMiddleware());
function getUserSetting(Request $request, Response $response, array $args)
{
-
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$settingName = $args['settingName'];
$setting = $user->getSetting($settingName);
- $value = "";
+ $value = '';
if ($setting) {
$value = $setting->getValue();
}
- return $response->withJson(["value" => $value]);
+
+ return $response->withJson(['value' => $value]);
}
function updateUserSetting(Request $request, Response $response, array $args)
{
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$settingName = $args['settingName'];
- $input = (object)$request->getParsedBody();
+ $input = (object) $request->getParsedBody();
$user->setSetting($settingName, $input->value);
- return $response->withJson(["value" => $user->getSetting($settingName)->getValue()]);
+
+ return $response->withJson(['value' => $user->getSetting($settingName)->getValue()]);
}
diff --git a/src/api/routes/users/user.php b/src/api/routes/users/user.php
index fb8e50cbcc..057a92247d 100644
--- a/src/api/routes/users/user.php
+++ b/src/api/routes/users/user.php
@@ -6,23 +6,23 @@
use Slim\Http\Response;
$app->group('/user/{userId:[0-9]+}', function () {
- $this->post("/apikey/regen", "genAPIKey");
- $this->post("/config/{key}", "updateUserConfig");
+ $this->post('/apikey/regen', 'genAPIKey');
+ $this->post('/config/{key}', 'updateUserConfig');
})->add(new UserAPIMiddleware());
function genAPIKey(Request $request, Response $response, array $args)
{
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$user->setApiKey(User::randomApiKey());
$user->save();
- $user->createTimeLineNote("api-key-regen");
- return $response->withJson(["apiKey" => $user->getApiKey()]);
-}
+ $user->createTimeLineNote('api-key-regen');
+ return $response->withJson(['apiKey' => $user->getApiKey()]);
+}
function updateUserConfig(Request $request, Response $response, array $args)
{
- $user = $request->getAttribute("user");
+ $user = $request->getAttribute('user');
$userConfigName = $args['key'];
$parsedBody = (object) $request->getParsedBody();
$newValue = $parsedBody->value;
@@ -31,4 +31,4 @@ function updateUserConfig(Request $request, Response $response, array $args)
if ($user->getUserConfigString($userConfigName) == $newValue) {
return $response->withJson([$userConfigName => $newValue]);
}
-};
+}
diff --git a/src/bin/google-map/GoogleMap.php b/src/bin/google-map/GoogleMap.php
index 8a451ffeab..45c7f941fc 100644
--- a/src/bin/google-map/GoogleMap.php
+++ b/src/bin/google-map/GoogleMap.php
@@ -137,6 +137,7 @@ class GoogleMapAPI
* that calls the map's onload function using $this->printOnLoadFunction.
*
* @var bool
+ *
* @default true
*/
public $onload = true;
@@ -189,12 +190,12 @@ class GoogleMapAPI
*/
public $directions_unit_system = '';
- /**
- * sets default option for type controls(DEFAULT, HORIZONTAL_BAR, DROPDOWN_MENU).
- *
- * @var string
- */
- public $type_controls_style = 'DEFAULT';
+ /**
+ * sets default option for type controls(DEFAULT, HORIZONTAL_BAR, DROPDOWN_MENU).
+ *
+ * @var string
+ */
+ public $type_controls_style = 'DEFAULT';
/**
* default map type google.maps.MapTypeId.(ROADMAP, SATELLITE, HYBRID, TERRAIN).
@@ -346,8 +347,8 @@ class GoogleMapAPI
*/
public $directions = true;
- /* waypoints */
- protected $_waypoints_string = '';
+ /* waypoints */
+ protected $_waypoints_string = '';
/**
* determines if map markers bring up an info window.
@@ -363,24 +364,24 @@ class GoogleMapAPI
*/
public $window_trigger = 'click';
- /**
- * determines whether or not to use the MarkerClusterer plugin.
- */
- public $marker_clusterer = false;
+ /**
+ * determines whether or not to use the MarkerClusterer plugin.
+ */
+ public $marker_clusterer = false;
- /**
- * set default marker clusterer *webserver* file location.
- */
- public $marker_clusterer_location = '/MarkerClusterer-1.0/markerclusterer_compiled.js';
+ /**
+ * set default marker clusterer *webserver* file location.
+ */
+ public $marker_clusterer_location = '/MarkerClusterer-1.0/markerclusterer_compiled.js';
- /**
- * set default marker clusterer options.
- */
- public $marker_clusterer_options = [
+ /**
+ * set default marker clusterer options.
+ */
+ public $marker_clusterer_options = [
'maxZoom' => 'null',
'gridSize'=> 'null',
'styles' => 'null',
- ];
+ ];
/**
* determines if traffic overlay is displayed on map.
@@ -426,16 +427,16 @@ class GoogleMapAPI
* @deprecated
*/
public $driving_dir_text = [
- 'dir_to' => 'Start address: (include addr, city st/region)',
- 'to_button_value' => 'Get Directions',
- 'to_button_type' => 'submit',
- 'dir_from' => 'End address: (include addr, city st/region)',
- 'from_button_value' => 'Get Directions',
- 'from_button_type' => 'submit',
- 'dir_text' => 'Directions: ',
- 'dir_tohere' => 'To here',
- 'dir_fromhere' => 'From here',
- ];
+ 'dir_to' => 'Start address: (include addr, city st/region)',
+ 'to_button_value' => 'Get Directions',
+ 'to_button_type' => 'submit',
+ 'dir_from' => 'End address: (include addr, city st/region)',
+ 'from_button_value' => 'Get Directions',
+ 'from_button_type' => 'submit',
+ 'dir_text' => 'Directions: ',
+ 'dir_tohere' => 'To here',
+ 'dir_fromhere' => 'From here',
+ ];
/**
* version number.
@@ -601,13 +602,13 @@ class GoogleMapAPI
*/
public $_display_js_functions = true;
- /**
- * Class variable that will store flag to minify js - this can be overwritten after object is instantiated. Include JSMin.php if
- * you want to use JS Minification.
- *
- * @var bool
- */
- public $_minify_js = true;
+ /**
+ * Class variable that will store flag to minify js - this can be overwritten after object is instantiated. Include JSMin.php if
+ * you want to use JS Minification.
+ *
+ * @var bool
+ */
+ public $_minify_js = true;
/**
* class constructor.
@@ -1111,37 +1112,37 @@ public function disableInfoWindow()
$this->info_window = false;
}
- /**
- * enable elevation marker to be displayed.
- */
- public function enableElevationMarker()
- {
- $this->elevation_markers = true;
- }
-
- /**
- * disable elevation marker.
- */
- public function disableElevationMarker()
- {
- $this->elevation_markers = false;
- }
-
- /**
- * enable elevation to be displayed for directions.
- */
- public function enableElevationDirections()
- {
- $this->elevation_directions = true;
- }
-
- /**
- * disable elevation to be displayed for directions.
- */
- public function disableElevationDirections()
- {
- $this->elevation_directions = false;
- }
+ /**
+ * enable elevation marker to be displayed.
+ */
+ public function enableElevationMarker()
+ {
+ $this->elevation_markers = true;
+ }
+
+ /**
+ * disable elevation marker.
+ */
+ public function disableElevationMarker()
+ {
+ $this->elevation_markers = false;
+ }
+
+ /**
+ * enable elevation to be displayed for directions.
+ */
+ public function enableElevationDirections()
+ {
+ $this->elevation_directions = true;
+ }
+
+ /**
+ * disable elevation to be displayed for directions.
+ */
+ public function disableElevationDirections()
+ {
+ $this->elevation_directions = false;
+ }
/**
* enable map marker clustering.
@@ -1191,7 +1192,7 @@ public function setInfoWindowTrigger($type)
default:
$this->window_trigger = 'click';
break;
- }
+ }
}
/**
@@ -1330,6 +1331,7 @@ public function addMarkerByCoords($lon, $lat, $title = '', $html = '', $tooltip
}
$this->_markers[] = $_marker;
$this->adjustCenterCoords($_marker['lon'], $_marker['lat']);
+
// return index of marker
return count($this->_markers) - 1;
}
@@ -1495,32 +1497,33 @@ public function addPolyLineByCoords($lon1, $lat1, $lon2, $lat2, $id = false, $co
}
$this->adjustCenterCoords($lon1, $lat1);
$this->adjustCenterCoords($lon2, $lat2);
+
// return index of polyline
return $id;
}
- /**
- * function to add an elevation profile for a polyline to the page.
- */
- public function addPolylineElevation($polyline_id, $elevation_dom_id, $samples = 256, $width = '', $height = '', $focus_color = '#00ff00')
- {
- if (isset($this->_polylines[$polyline_id])) {
- $this->_elevation_polylines[$polyline_id] = [
+ /**
+ * function to add an elevation profile for a polyline to the page.
+ */
+ public function addPolylineElevation($polyline_id, $elevation_dom_id, $samples = 256, $width = '', $height = '', $focus_color = '#00ff00')
+ {
+ if (isset($this->_polylines[$polyline_id])) {
+ $this->_elevation_polylines[$polyline_id] = [
'dom_id' => $elevation_dom_id,
'samples' => $samples,
'width' => ($width != '' ? $width : str_replace('px', '', $this->width)),
'height' => ($height != '' ? $height : str_replace('px', '', $this->height) / 2),
'focus_color'=> $focus_color,
];
- }
- }
-
- /**
- * function to add an overlay to the map.
- */
- public function addOverlay($bds_lat1, $bds_lon1, $bds_lat2, $bds_lon2, $img_src, $opacity = 100)
- {
- $_overlay = [
+ }
+ }
+
+ /**
+ * function to add an overlay to the map.
+ */
+ public function addOverlay($bds_lat1, $bds_lon1, $bds_lat2, $bds_lon2, $img_src, $opacity = 100)
+ {
+ $_overlay = [
'bounds' => [
'ne'=> [
'lat' => $bds_lat1,
@@ -1533,25 +1536,25 @@ public function addOverlay($bds_lat1, $bds_lon1, $bds_lat2, $bds_lon2, $img_src,
],
'img' => $img_src,
'opacity' => $opacity / 10,
- ];
- $this->adjustCenterCoords($bds_lon1, $bds_lat1);
- $this->adjustCenterCoords($bds_lon2, $bds_lat2);
- $this->_overlays[] = $_overlay;
+ ];
+ $this->adjustCenterCoords($bds_lon1, $bds_lat1);
+ $this->adjustCenterCoords($bds_lon2, $bds_lat2);
+ $this->_overlays[] = $_overlay;
- return count($this->_overlays) - 1;
- }
+ return count($this->_overlays) - 1;
+ }
- /**
- * function to add a KML overlay to the map.
- * *Note that this expects a filename and file parsing/processing is done
- * on the client side.
- */
- public function addKMLOverlay($file)
- {
- $this->_kml_overlays[] = $file;
+ /**
+ * function to add a KML overlay to the map.
+ * *Note that this expects a filename and file parsing/processing is done
+ * on the client side.
+ */
+ public function addKMLOverlay($file)
+ {
+ $this->_kml_overlays[] = $file;
- return count($this->_kml_overlays) - 1;
- }
+ return count($this->_kml_overlays) - 1;
+ }
/**
* adjust map center coordinates by the given lat/lon point.
@@ -1605,12 +1608,12 @@ public function createMarkerIcon($iconImage, $iconShadowImage = '', $iconAnchorX
{
$_icon_image_path = strpos($iconImage, 'http') === 0 ? $iconImage : $_SERVER['DOCUMENT_ROOT'].$iconImage;
if (!($_image_info = @getimagesize($_icon_image_path))) {
- die('GoogleMapAPI:createMarkerIcon: Error reading image: '.$iconImage);
+ exit('GoogleMapAPI:createMarkerIcon: Error reading image: '.$iconImage);
}
if ($iconShadowImage) {
$_shadow_image_path = strpos($iconShadowImage, 'http') === 0 ? $iconShadowImage : $_SERVER['DOCUMENT_ROOT'].$iconShadowImage;
if (!($_shadow_info = @getimagesize($_shadow_image_path))) {
- die('GoogleMapAPI:createMarkerIcon: Error reading shadow image: '.$iconShadowImage);
+ exit('GoogleMapAPI:createMarkerIcon: Error reading shadow image: '.$iconShadowImage);
}
}
@@ -1628,18 +1631,18 @@ public function createMarkerIcon($iconImage, $iconShadowImage = '', $iconAnchorX
}
$icon_info = [
- 'image' => $iconImage,
- 'iconWidth' => $_image_info[0],
- 'iconHeight' => $_image_info[1],
- 'iconAnchorX' => $iconAnchorX,
- 'iconAnchorY' => $iconAnchorY,
- 'infoWindowAnchorX' => $infoWindowAnchorX,
- 'infoWindowAnchorY' => $infoWindowAnchorY,
- ];
+ 'image' => $iconImage,
+ 'iconWidth' => $_image_info[0],
+ 'iconHeight' => $_image_info[1],
+ 'iconAnchorX' => $iconAnchorX,
+ 'iconAnchorY' => $iconAnchorY,
+ 'infoWindowAnchorX' => $infoWindowAnchorX,
+ 'infoWindowAnchorY' => $infoWindowAnchorY,
+ ];
if ($iconShadowImage) {
$icon_info = array_merge($icon_info, ['shadow' => $iconShadowImage,
- 'shadowWidth' => $_shadow_info[0],
- 'shadowHeight' => $_shadow_info[1], ]);
+ 'shadowWidth' => $_shadow_info[0],
+ 'shadowHeight' => $_shadow_info[1], ]);
}
return $icon_info;
@@ -2034,7 +2037,6 @@ public function getMapJS()
";
if (!empty($this->_markers)) {
-
//Add markers to the street view
if ($this->street_view_dom_id != '') {
$_script .= $this->getAddMarkersJS($this->map_id, $pano = true);
@@ -2146,15 +2148,15 @@ public function getMapJS()
';
}
- //end JS if mapObj != "undefined" block
+ //end JS if mapObj != "undefined" block
$_script .= '}'."\n";
}//end if $this->display_map==true
if (!empty($this->browser_alert)) {
//TODO:Update with new browser catch SEE ABOVE
- // $_output .= '} else {' . "\n";
- // $_output .= 'alert("' . str_replace('"','\"',$this->browser_alert) . '");' . "\n";
- // $_output .= '}' . "\n";
+ // $_output .= '} else {' . "\n";
+ // $_output .= 'alert("' . str_replace('"','\"',$this->browser_alert) . '");' . "\n";
+ // $_output .= '}' . "\n";
}
if ($this->onload) {
@@ -2175,18 +2177,18 @@ public function getMapJS()
return $_output;
}
- /**
- * function to render utility functions for use on the page.
- */
- public function getMapFunctions()
- {
- $_script = '';
- if ($this->_display_js_functions === true) {
- $_script = $this->getUtilityFunctions();
- }
+ /**
+ * function to render utility functions for use on the page.
+ */
+ public function getMapFunctions()
+ {
+ $_script = '';
+ if ($this->_display_js_functions === true) {
+ $_script = $this->getUtilityFunctions();
+ }
- return $_script;
- }
+ return $_script;
+ }
public function getUtilityFunctions()
{
@@ -2200,8 +2202,8 @@ public function getUtilityFunctions()
if (!empty($this->_elevation_polylines) || (!empty($this->_directions) && $this->elevation_directions)) {
$_script .= $this->getPlotElevationJS();
}
- // Utility functions used to distinguish between tabbed and non-tabbed info windows
- $_script .= 'function isArray(a) {return isObject(a) && a.constructor == Array;}'."\n";
+ // Utility functions used to distinguish between tabbed and non-tabbed info windows
+ $_script .= 'function isArray(a) {return isObject(a) && a.constructor == Array;}'."\n";
$_script .= 'function isObject(a) {return (a && typeof a == \'object\') || isFunction(a);}'."\n";
$_script .= 'function isFunction(a) {return typeof a == \'function\';}'."\n";
$_script .= 'function isEmpty(obj) { for(var i in obj) { return false; } return true; }'."\n";
@@ -2228,7 +2230,8 @@ public function getAddMarkersJS($map_id = '', $pano = false)
foreach ($this->_markers as $_marker) {
$iw_html = str_replace('"', '\"', str_replace(["\n", "\r"], '', $_marker['html']));
$_output .= 'var point = new google.maps.LatLng('.$_marker['lat'].','.$_marker['lon'].");\n";
- $_output .= sprintf('%s.push(createMarker(%s%s, point,"%s","%s", %s, %s, "%s", %s ));',
+ $_output .= sprintf(
+ '%s.push(createMarker(%s%s, point,"%s","%s", %s, %s, "%s", %s ));',
(($pano == true) ? $_prefix : '').'markers'.$map_id,
$_prefix,
$map_id,
@@ -2236,8 +2239,8 @@ public function getAddMarkersJS($map_id = '', $pano = false)
str_replace('/', '\/', $iw_html),
(isset($_marker['icon_key'])) ? 'icon'.$map_id."['".$_marker['icon_key']."'].image" : "''",
(isset($_marker['icon_key']) && isset($_marker['shadow_icon'])) ? 'icon'.$map_id."['".$_marker['icon_key']."'].shadow" : "''",
- (($this->sidebar) ? $this->sidebar_id : ''),
- ((isset($_marker['openers']) && count($_marker['openers']) > 0) ? json_encode($_marker['openers']) : "''")
+ ($this->sidebar) ? $this->sidebar_id : '',
+ (isset($_marker['openers']) && count($_marker['openers']) > 0) ? json_encode($_marker['openers']) : "''"
)."\n";
}
@@ -2310,41 +2313,41 @@ public function getPolylineJS()
return $_output;
}
- /**
- * function to render proper calls for directions - for now can only be used on a map, not a streetview.
- */
- public function getAddDirectionsJS()
- {
- $_output = '';
-
- foreach ($this->_directions as $directions) {
- $dom_id = $directions['dom_id'];
- $travelModeParams = [];
- $directionsParams = '';
- if ($this->walking_directions == true) {
- $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.WALKING";
- } elseif ($this->biking_directions == true) {
- $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.BICYCLING";
- } else {
- $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.DRIVING";
- }
-
- if ($this->avoid_highways == true) {
- $directionsParams .= ", \n avoidHighways: true";
- }
- if ($this->avoid_tollways == true) {
- $directionsParams .= ", \n avoidTolls: true";
- }
-
- if ($this->directions_unit_system != '') {
- if ($this->directions_unit_system == 'METRIC') {
- $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.METRIC";
- } else {
- $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL";
- }
- }
-
- $_output .= '
+ /**
+ * function to render proper calls for directions - for now can only be used on a map, not a streetview.
+ */
+ public function getAddDirectionsJS()
+ {
+ $_output = '';
+
+ foreach ($this->_directions as $directions) {
+ $dom_id = $directions['dom_id'];
+ $travelModeParams = [];
+ $directionsParams = '';
+ if ($this->walking_directions == true) {
+ $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.WALKING";
+ } elseif ($this->biking_directions == true) {
+ $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.BICYCLING";
+ } else {
+ $directionsParams .= ", \n travelMode:google.maps.DirectionsTravelMode.DRIVING";
+ }
+
+ if ($this->avoid_highways == true) {
+ $directionsParams .= ", \n avoidHighways: true";
+ }
+ if ($this->avoid_tollways == true) {
+ $directionsParams .= ", \n avoidTolls: true";
+ }
+
+ if ($this->directions_unit_system != '') {
+ if ($this->directions_unit_system == 'METRIC') {
+ $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.METRIC";
+ } else {
+ $directionsParams .= ", \n unitSystem: google.maps.DirectionsUnitSystem.IMPERIAL";
+ }
+ }
+
+ $_output .= '
directions'.$this->map_id."['$dom_id'] = {
displayRenderer:new google.maps.DirectionsRenderer(),
directionService:new google.maps.DirectionsService(),
@@ -2378,27 +2381,27 @@ public function getAddDirectionsJS()
}
});
';
- }
-
- return $_output;
- }
-
- /**
- * function to get overlay creation JS.
- */
- public function getAddOverlayJS()
- {
- $_output = '';
- foreach ($this->_overlays as $_key=>$_overlay) {
- $_output .= '
+ }
+
+ return $_output;
+ }
+
+ /**
+ * function to get overlay creation JS.
+ */
+ public function getAddOverlayJS()
+ {
+ $_output = '';
+ foreach ($this->_overlays as $_key=>$_overlay) {
+ $_output .= '
var bounds = new google.maps.LatLngBounds(new google.maps.LatLng('.$_overlay['bounds']['ne']['lat'].', '.$_overlay['bounds']['ne']['long'].'), new google.maps.LatLng('.$_overlay['bounds']['sw']['lat'].', '.$_overlay['bounds']['sw']['long']."));
var image = '".$_overlay['img']."';
overlays".$this->map_id."[$_key] = new CustomOverlay(bounds, image, map".$this->map_id.', '.$_overlay['opacity'].');
';
- }
+ }
- return $_output;
- }
+ return $_output;
+ }
/**
* overridable function to generate the js for the js function for creating a marker.
@@ -2460,12 +2463,12 @@ function createMarker(map, point, title, html, icon, icon_shadow, sidebar_id, op
return $_output;
}
- /**
- * Get create overlay js.
- */
- public function getCreateOverlayJS()
- {
- $_output = "
+ /**
+ * Get create overlay js.
+ */
+ public function getCreateOverlayJS()
+ {
+ $_output = "
CustomOverlay.prototype = new google.maps.OverlayView();
function CustomOverlay(bounds, image, map, opacity){
this.bounds_ = bounds;
@@ -2507,8 +2510,8 @@ function CustomOverlay(bounds, image, map, opacity){
}
";
- return $_output;
- }
+ return $_output;
+ }
/**
* print helper function to draw elevation results as a chart.
@@ -2543,12 +2546,12 @@ function plotElevation(results, status, elevation_data, map, charts_array) {
return $_output;
}
- /**
- * create JS that is inside of JS plot elevation function.
- */
- public function getElevationMarkerJS()
- {
- $_output = "
+ /**
+ * create JS that is inside of JS plot elevation function.
+ */
+ public function getElevationMarkerJS()
+ {
+ $_output = "
google.visualization.events.addListener(elevation_data.chart, 'onmouseover', function(e) {
if(elevation_data.marker==null){
elevation_data.marker = new google.maps.Marker({
@@ -2572,8 +2575,8 @@ function clearElevationMarker(marker){
}
";
- return $_output;
- }
+ return $_output;
+ }
/**
* print map (put at location map will appear).
@@ -2670,11 +2673,11 @@ public function getCache($address)
require_once 'DB.php';
$_db = &DB::connect($this->dsn);
if (PEAR::isError($_db)) {
- die($_db->getMessage());
+ exit($_db->getMessage());
}
$_res = &$_db->query("SELECT lon,lat FROM {$this->_db_cache_table} where address = ?", $address);
if (PEAR::isError($_res)) {
- die($_res->getMessage());
+ exit($_res->getMessage());
}
if ($_row = $_res->fetchRow()) {
$_ret['lon'] = $_row[0];
@@ -2704,11 +2707,11 @@ public function putCache($address, $lon, $lat)
require_once 'DB.php';
$_db = &DB::connect($this->dsn);
if (PEAR::isError($_db)) {
- die($_db->getMessage());
+ exit($_db->getMessage());
}
$_res = &$_db->query('insert into '.$this->_db_cache_table.' values (?, ?, ?)', [$address, $lon, $lat]);
if (PEAR::isError($_res)) {
- die($_res->getMessage());
+ exit($_res->getMessage());
}
$_db->disconnect();
@@ -2806,33 +2809,32 @@ public function fetchURL($url)
*/
public function geoGetDistance($lat1, $lon1, $lat2, $lon2, $unit = 'M')
{
-
- // calculate miles
- $M = 69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2))));
+ // calculate miles
+ $M = 69.09 * rad2deg(acos(sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($lon1 - $lon2))));
switch (strtoupper($unit)) {
- case 'K':
- // kilometers
- return $M * 1.609344;
- break;
- case 'N':
- // nautical miles
- return $M * 0.868976242;
- break;
- case 'F':
- // feet
- return $M * 5280;
- break;
- case 'I':
- // inches
- return $M * 63360;
- break;
- case 'M':
- default:
- // miles
- return $M;
- break;
- }
+ case 'K':
+ // kilometers
+ return $M * 1.609344;
+ break;
+ case 'N':
+ // nautical miles
+ return $M * 0.868976242;
+ break;
+ case 'F':
+ // feet
+ return $M * 5280;
+ break;
+ case 'I':
+ // inches
+ return $M * 63360;
+ break;
+ case 'M':
+ default:
+ // miles
+ return $M;
+ break;
+ }
}
/** #)MS
@@ -2920,22 +2922,23 @@ public function addPolygonByCoords($lon1, $lat1, $lon2, $lat2, $id = false, $col
}
$this->adjustCenterCoords($lon1, $lat1);
$this->adjustCenterCoords($lon2, $lat2);
+
// return index of polyline
return $id;
}
- /**#)MS
- * adds polyline by passed array
- * if color, weight and opacity are not defined, use the google maps defaults
- * @param array $polyline_array array of lat/long coords
- * @param string $id An array id to use to append coordinates to a line
- * @param string $color the color of the line (format: #000000)
- * @param string $weight the weight of the line in pixels
- * @param string $opacity the line opacity (percentage)
- * @param string $fill_color the polygon color (format: #000000)
- * @param string $fill_opacity the polygon opacity (percentage)
- * @return bool|int Array id of newly added point or false
- */
+ /**#)MS
+ * adds polyline by passed array
+ * if color, weight and opacity are not defined, use the google maps defaults
+ * @param array $polyline_array array of lat/long coords
+ * @param string $id An array id to use to append coordinates to a line
+ * @param string $color the color of the line (format: #000000)
+ * @param string $weight the weight of the line in pixels
+ * @param string $opacity the line opacity (percentage)
+ * @param string $fill_color the polygon color (format: #000000)
+ * @param string $fill_opacity the polygon opacity (percentage)
+ * @return bool|int Array id of newly added point or false
+ */
public function addPolygonByCoordsArray($polygon_array, $id = false, $color = '', $weight = 0, $opacity = 0, $fill_color = '', $fill_opacity = 0)
{
if (!is_array($polygon_array) || count($polygon_array) < 3) {
diff --git a/src/bin/google-map/JSMin.php b/src/bin/google-map/JSMin.php
index 6afdf56585..c159df93aa 100644
--- a/src/bin/google-map/JSMin.php
+++ b/src/bin/google-map/JSMin.php
@@ -149,7 +149,8 @@ protected function action($command)
}
if (ord($this->a) <= self::ORD_LF) {
throw new JSMin_UnterminatedStringException(
- 'Unterminated String: '.var_export($str, true));
+ 'Unterminated String: '.var_export($str, true)
+ );
}
$str .= $this->a;
if ($this->a === '\\') {
@@ -176,13 +177,14 @@ protected function action($command)
$pattern .= $this->a;
} elseif (ord($this->a) <= self::ORD_LF) {
throw new JSMin_UnterminatedRegExpException(
- 'Unterminated RegExp: '.var_export($pattern, true));
+ 'Unterminated RegExp: '.var_export($pattern, true)
+ );
}
$this->output .= $this->a;
}
$this->b = $this->next();
}
- // end case ACTION_DELETE_A_B
+ // end case ACTION_DELETE_A_B
}
}
diff --git a/src/email/MemberEmailExport.php b/src/email/MemberEmailExport.php
index 1b961464c0..9953a53ccd 100644
--- a/src/email/MemberEmailExport.php
+++ b/src/email/MemberEmailExport.php
@@ -38,7 +38,7 @@
}
header('Content-type: text/csv');
-header('Content-Disposition: attachment; filename=EmailExport-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+header('Content-Disposition: attachment; filename=EmailExport-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
header('Pragma: no-cache');
header('Expires: 0');
diff --git a/src/external/index.php b/src/external/index.php
index b416d2e7c3..fee4c42ee7 100644
--- a/src/external/index.php
+++ b/src/external/index.php
@@ -6,22 +6,22 @@
//require '../Include/Functions.php';
// This file is generated by Composer
-require_once dirname(__FILE__) . '/../vendor/autoload.php';
+require_once dirname(__FILE__).'/../vendor/autoload.php';
// Instantiate the app
$app = new \Slim\App();
$container = $app->getContainer();
if (SystemConfig::debugEnabled()) {
- $container["settings"]['displayErrorDetails'] = true;
+ $container['settings']['displayErrorDetails'] = true;
}
// Set up
-require __DIR__ . '/../Include/slim/error-handler.php';
+require __DIR__.'/../Include/slim/error-handler.php';
// routes
-require __DIR__ . '/routes/register.php';
-require __DIR__ . '/routes/verify.php';
-require __DIR__ . '/routes/calendar.php';
+require __DIR__.'/routes/register.php';
+require __DIR__.'/routes/verify.php';
+require __DIR__.'/routes/calendar.php';
// Run app
$app->run();
diff --git a/src/external/routes/calendar.php b/src/external/routes/calendar.php
index 54f6118922..7b8c4b63cc 100644
--- a/src/external/routes/calendar.php
+++ b/src/external/routes/calendar.php
@@ -1,18 +1,19 @@
group('/calendars', function () {
$this->get('/{CalendarAccessToken}', 'serveCalendarPage');
$this->get('/{CalendarAccessToken}/', 'serveCalendarPage');
-
})->add(new PublicCalendarAPIMiddleware());
-function serveCalendarPage ($request, $response) {
- $renderer = new PhpRenderer('templates/calendar/');
- $eventSource = SystemURLs::getRootPath()."/api/public/calendar/".$request->getAttribute("route")->getArgument("CalendarAccessToken")."/fullcalendar";
- $calendarName = $request->getAttribute("calendar")->getName();
- return $renderer->render($response, 'calendar.php', ['eventSource' => $eventSource, 'calendarName'=> $calendarName]);
-}
\ No newline at end of file
+function serveCalendarPage($request, $response)
+{
+ $renderer = new PhpRenderer('templates/calendar/');
+ $eventSource = SystemURLs::getRootPath().'/api/public/calendar/'.$request->getAttribute('route')->getArgument('CalendarAccessToken').'/fullcalendar';
+ $calendarName = $request->getAttribute('calendar')->getName();
+
+ return $renderer->render($response, 'calendar.php', ['eventSource' => $eventSource, 'calendarName'=> $calendarName]);
+}
diff --git a/src/external/routes/register.php b/src/external/routes/register.php
index 9885151576..2b9b068c69 100644
--- a/src/external/routes/register.php
+++ b/src/external/routes/register.php
@@ -2,13 +2,10 @@
use ChurchCRM\dto\SystemConfig;
use ChurchCRM\dto\SystemURLs;
-use ChurchCRM\Family;
use ChurchCRM\ListOptionQuery;
-use ChurchCRM\Person;
use Slim\Views\PhpRenderer;
$app->group('/register', function () {
-
$enableSelfReg = SystemConfig::getBooleanValue('bEnableSelfRegistration');
if ($enableSelfReg) {
diff --git a/src/external/routes/verify.php b/src/external/routes/verify.php
index 050670c25f..40d4f56964 100644
--- a/src/external/routes/verify.php
+++ b/src/external/routes/verify.php
@@ -1,61 +1,58 @@
group('/verify', function () {
-
- $this->get('/{token}', function ($request, $response, $args) {
- $renderer = new PhpRenderer("templates/verify/");
- $token = TokenQuery::create()->findPk($args['token']);
- $haveFamily = false;
- if ($token != null && $token->isVerifyFamilyToken() && $token->isValid()) {
- $family = FamilyQuery::create()->findPk($token->getReferenceId());
- $haveFamily = ($family != null);
- if ($token->getRemainingUses() > 0) {
- $token->setRemainingUses($token->getRemainingUses() - 1);
- $token->save();
- }
- }
-
- if ($haveFamily) {
- return $renderer->render($response, "verify-family-info.php", array("family" => $family, "token" => $token));
- } else {
- return $renderer->render($response, "/../404.php", array("message" => gettext("Unable to load verification info")));
- }
- });
-
- $this->post('/{token}', function ($request, $response, $args) {
- $token = TokenQuery::create()->findPk($args['token']);
- if ($token != null && $token->isVerifyFamilyToken() && $token->isValid()) {
- $family = FamilyQuery::create()->findPk($token->getReferenceId());
- if ($family != null) {
- $body = (object) $request->getParsedBody();
- $note = new Note();
- $note->setFamily($family);
- $note->setType("verify");
- $note->setEntered(Person::SELF_VERIFY);
- $note->setText(gettext("No Changes"));
- if (!empty($body->message)) {
- $note->setText($body->message);
+ $this->get('/{token}', function ($request, $response, $args) {
+ $renderer = new PhpRenderer('templates/verify/');
+ $token = TokenQuery::create()->findPk($args['token']);
+ $haveFamily = false;
+ if ($token != null && $token->isVerifyFamilyToken() && $token->isValid()) {
+ $family = FamilyQuery::create()->findPk($token->getReferenceId());
+ $haveFamily = ($family != null);
+ if ($token->getRemainingUses() > 0) {
+ $token->setRemainingUses($token->getRemainingUses() - 1);
+ $token->save();
+ }
}
- $note->save();
- }
- }
- return $response->withStatus(200);
- });
- /*$this->post('/', function ($request, $response, $args) {
- $body = $request->getParsedBody();
- $renderer = new PhpRenderer("templates/verify/");
- $family = PersonQuery::create()->findByEmail($body["email"]);
- return $renderer->render($response, "view-info.php", array("family" => $family));
- });*/
-});
+ if ($haveFamily) {
+ return $renderer->render($response, 'verify-family-info.php', ['family' => $family, 'token' => $token]);
+ } else {
+ return $renderer->render($response, '/../404.php', ['message' => gettext('Unable to load verification info')]);
+ }
+ });
+
+ $this->post('/{token}', function ($request, $response, $args) {
+ $token = TokenQuery::create()->findPk($args['token']);
+ if ($token != null && $token->isVerifyFamilyToken() && $token->isValid()) {
+ $family = FamilyQuery::create()->findPk($token->getReferenceId());
+ if ($family != null) {
+ $body = (object) $request->getParsedBody();
+ $note = new Note();
+ $note->setFamily($family);
+ $note->setType('verify');
+ $note->setEntered(Person::SELF_VERIFY);
+ $note->setText(gettext('No Changes'));
+ if (!empty($body->message)) {
+ $note->setText($body->message);
+ }
+ $note->save();
+ }
+ }
+ return $response->withStatus(200);
+ });
+ /*$this->post('/', function ($request, $response, $args) {
+ $body = $request->getParsedBody();
+ $renderer = new PhpRenderer("templates/verify/");
+ $family = PersonQuery::create()->findByEmail($body["email"]);
+ return $renderer->render($response, "view-info.php", array("family" => $family));
+ });*/
+});
diff --git a/src/index.php b/src/index.php
index f9c6241a64..28b9d4ff64 100644
--- a/src/index.php
+++ b/src/index.php
@@ -1,7 +1,7 @@
/ListEvents.php
$shortName = str_replace(SystemURLs::getRootPath().'/', '', $_SERVER['REQUEST_URI']);
$fileName = MiscUtils::dashesToCamelCase($shortName, true).'.php';
-if (!empty($_GET["location"])) {
- $_SESSION['location'] = $_GET["location"];
+if (!empty($_GET['location'])) {
+ $_SESSION['location'] = $_GET['location'];
}
// First, ensure that the user is authenticated.
@@ -36,7 +35,7 @@
if (strtolower($shortName) == 'index.php' || strtolower($fileName) == 'index.php') {
// Index.php -> Menu.php
- header('Location: '.SystemURLs::getRootPath()."/Menu.php");
+ header('Location: '.SystemURLs::getRootPath().'/Menu.php');
exit;
} elseif (file_exists($shortName)) {
// Try actual path
diff --git a/src/kiosk/index.php b/src/kiosk/index.php
index b1737d668b..b0517a0a58 100644
--- a/src/kiosk/index.php
+++ b/src/kiosk/index.php
@@ -3,7 +3,7 @@
require '../Include/Config.php';
// This file is generated by Composer
-require_once dirname(__FILE__) . '/../vendor/autoload.php';
+require_once dirname(__FILE__).'/../vendor/autoload.php';
use ChurchCRM\dto\SystemConfig;
@@ -11,20 +11,20 @@
$app = new App();
$container = $app->getContainer();
if (SystemConfig::debugEnabled()) {
- $container["settings"]['displayErrorDetails'] = true;
+ $container['settings']['displayErrorDetails'] = true;
}
// Set up
-require __DIR__ . '/../Include/slim/error-handler.php';
+require __DIR__.'/../Include/slim/error-handler.php';
// routes
-require __DIR__ . '/routes/kiosk.php';
+require __DIR__.'/routes/kiosk.php';
-$windowOpen = new DateTime(SystemConfig::getValue("sKioskVisibilityTimestamp")) > new DateTime();
+$windowOpen = new DateTime(SystemConfig::getValue('sKioskVisibilityTimestamp')) > new DateTime();
if (isset($_COOKIE['kioskCookie'])) {
$g = hash('sha256', $_COOKIE['kioskCookie']);
- $Kiosk = \ChurchCRM\Base\KioskDeviceQuery::create()
+ $Kiosk = \ChurchCRM\Base\KioskDeviceQuery::create()
->findOneByGUIDHash($g);
if (is_null($Kiosk)) {
setcookie(kioskCookie, '', time() - 3600);
@@ -35,13 +35,13 @@
if (!isset($_COOKIE['kioskCookie'])) {
if ($windowOpen) {
$guid = uniqid();
- setcookie("kioskCookie", $guid, 2147483647);
+ setcookie('kioskCookie', $guid, 2147483647);
$Kiosk = new \ChurchCRM\KioskDevice();
$Kiosk->setGUIDHash(hash('sha256', $guid));
$Kiosk->setAccepted($false);
$Kiosk->save();
} else {
- header("HTTP/1.1 401 Unauthorized");
+ header('HTTP/1.1 401 Unauthorized');
exit;
}
}
diff --git a/src/kiosk/routes/kiosk.php b/src/kiosk/routes/kiosk.php
index d9c343a790..4c66809cd7 100644
--- a/src/kiosk/routes/kiosk.php
+++ b/src/kiosk/routes/kiosk.php
@@ -6,55 +6,52 @@
use Psr\Http\Message\ServerRequestInterface;
use Slim\Views\PhpRenderer;
+$app->get('/', function ($request, $response, $args) {
+ $renderer = new PhpRenderer('templates/kioskDevices/');
+ $pageObjects = ['sRootPath' => $_SESSION['sRootPath']];
-$app->get('/', function ($request, $response, $args) use ($app) {
- $renderer = new PhpRenderer("templates/kioskDevices/");
- $pageObjects = array("sRootPath" => $_SESSION['sRootPath']);
- return $renderer->render($response, "sunday-school-class-view.php", $pageObjects);
- });
-
- $app->get('/heartbeat', function ($request, $response, $args) use ($app) {
+ return $renderer->render($response, 'sunday-school-class-view.php', $pageObjects);
+});
+$app->get('/heartbeat', function ($request, $response, $args) use ($app) {
return json_encode($app->kiosk->heartbeat());
- });
-
- $app->post('/checkin', function ($request, $response, $args) use ($app) {
+});
+$app->post('/checkin', function ($request, $response, $args) use ($app) {
$input = (object) $request->getParsedBody();
$status = $app->kiosk->getActiveAssignment()->getEvent()->checkInPerson($input->PersonId);
+
return $response->withJson($status);
- });
+});
- $app->post('/checkout', function ($request, $response, $args) use ($app) {
+$app->post('/checkout', function ($request, $response, $args) use ($app) {
$input = (object) $request->getParsedBody();
$status = $app->kiosk->getActiveAssignment()->getEvent()->checkOutPerson($input->PersonId);
+
return $response->withJson($status);
- });
+});
- $app->post('/triggerNotification', function ($request, $response, $args) use ($app) {
+$app->post('/triggerNotification', function ($request, $response, $args) use ($app) {
$input = (object) $request->getParsedBody();
- $Person =PersonQuery::create()
+ $Person = PersonQuery::create()
->findOneById($input->PersonId);
$Notification = new Notification();
$Notification->setPerson($Person);
$Notification->setRecipients($Person->getFamily()->getAdults());
- $Notification->setProjectorText($app->kiosk->getActiveAssignment()->getEvent()->getType()."-".$Person->getId());
+ $Notification->setProjectorText($app->kiosk->getActiveAssignment()->getEvent()->getType().'-'.$Person->getId());
$Status = $Notification->send();
return $response->withJson($Status);
- });
+});
-
- $app->get('/activeClassMembers', function ($request, $response, $args) use ($app) {
+$app->get('/activeClassMembers', function ($request, $response, $args) use ($app) {
return $app->kiosk->getActiveAssignment()->getActiveGroupMembers()->toJSON();
- });
+});
+$app->get('/activeClassMember/{PersonId}/photo', function (ServerRequestInterface $request, ResponseInterface $response, $args) {
+ $photo = new Photo('Person', $args['PersonId']);
- $app->get('/activeClassMember/{PersonId}/photo', function (ServerRequestInterface $request, ResponseInterface $response, $args) use ($app) {
- $photo = new Photo("Person",$args['PersonId']);
return $response->write($photo->getPhotoBytes())->withHeader('Content-type', $photo->getPhotoContentType());
- });
-
-
+});
diff --git a/src/mysql/upgrade/2.9.0-InnoDB.php b/src/mysql/upgrade/2.9.0-InnoDB.php
index 577ab532cf..11a5daba1e 100644
--- a/src/mysql/upgrade/2.9.0-InnoDB.php
+++ b/src/mysql/upgrade/2.9.0-InnoDB.php
@@ -6,24 +6,22 @@
$connection = Propel::getConnection();
$logger = LoggerUtils::getAppLogger();
-$logger->info("Upgrade to InnoDB started ");
+$logger->info('Upgrade to InnoDB started ');
-
-$sqlEvents = "ALTER TABLE events_event DROP INDEX event_txt;";
+$sqlEvents = 'ALTER TABLE events_event DROP INDEX event_txt;';
$connection->exec($sqlEvents);
-$logger->info("Dropped events_event INDEX");
+$logger->info('Dropped events_event INDEX');
$statement = $connection->prepare("SHOW FULL TABLES WHERE Table_Type = 'BASE TABLE'");
$statement->execute();
$dbTablesSQLs = $statement->fetchAll();
foreach ($dbTablesSQLs as $dbTable) {
-
- $alterSQL = "ALTER TABLE " . $dbTable[0] . " ENGINE=InnoDB;";
- $logger->info("Upgrade: " . $alterSQL);
+ $alterSQL = 'ALTER TABLE '.$dbTable[0].' ENGINE=InnoDB;';
+ $logger->info('Upgrade: '.$alterSQL);
$dbAlterStatement = $connection->exec($alterSQL);
- $logger->info("Upgrade: " . $alterSQL . " done.");
+ $logger->info('Upgrade: '.$alterSQL.' done.');
}
-$logger->info("Upgrade to InnoDB finished ");
+$logger->info('Upgrade to InnoDB finished ');
diff --git a/src/mysql/upgrade/3.0.0.php b/src/mysql/upgrade/3.0.0.php
index e6deb8b6f8..1c272bfccd 100644
--- a/src/mysql/upgrade/3.0.0.php
+++ b/src/mysql/upgrade/3.0.0.php
@@ -3,41 +3,39 @@
use ChurchCRM\Calendar;
use ChurchCRM\EventQuery;
-
-$EventsQuery = "SELECT * FROM events_event";
+$EventsQuery = 'SELECT * FROM events_event';
$statement = $connection->prepare($EventsQuery);
$statement->execute();
$Events = $statement->fetchAll();
$PublicCalendar = new Calendar();
-$PublicCalendar->setName(gettext("Public Calendar"));
-$PublicCalendar->setBackgroundColor("00AA00");
-$PublicCalendar->setForegroundColor("FFFFFF");
+$PublicCalendar->setName(gettext('Public Calendar'));
+$PublicCalendar->setBackgroundColor('00AA00');
+$PublicCalendar->setForegroundColor('FFFFFF');
$PublicCalendar->save();
$PrivateCalendar = new Calendar();
-$PrivateCalendar->setName(gettext("Private Calendar"));
-$PrivateCalendar->setBackgroundColor("0000AA");
-$PrivateCalendar->setForegroundColor("FFFFFF");
+$PrivateCalendar->setName(gettext('Private Calendar'));
+$PrivateCalendar->setBackgroundColor('0000AA');
+$PrivateCalendar->setForegroundColor('FFFFFF');
$PrivateCalendar->save();
if (count($Events) > 0) {
- foreach ($Events as $Event) {
- $w = EventQuery::Create() ->findOneById($Event['event_id']);
- if ($Event['event_publicly_visible']){
- $w->addCalendar($PublicCalendar);
- }
- else {
- $w->addCalendar($PrivateCalendar);
+ foreach ($Events as $Event) {
+ $w = EventQuery::Create()->findOneById($Event['event_id']);
+ if ($Event['event_publicly_visible']) {
+ $w->addCalendar($PublicCalendar);
+ } else {
+ $w->addCalendar($PrivateCalendar);
+ }
+ $w->save();
}
- $w->save();
- }
}
-$publicEventsQuery = "ALTER TABLE `events_event` "
- . "DROP COLUMN `event_publicly_visible`, "
- . "DROP COLUMN `event_grpid`";
+$publicEventsQuery = 'ALTER TABLE `events_event` '
+ .'DROP COLUMN `event_publicly_visible`, '
+ .'DROP COLUMN `event_grpid`';
$statement = $connection->prepare($publicEventsQuery);
$statement->execute();
diff --git a/src/mysql/upgrade/3.5.0.php b/src/mysql/upgrade/3.5.0.php
index aed51e60af..b9ed4fa266 100644
--- a/src/mysql/upgrade/3.5.0.php
+++ b/src/mysql/upgrade/3.5.0.php
@@ -6,30 +6,27 @@
$connection = Propel::getConnection();
$logger = LoggerUtils::getAppLogger();
-$logger->info("Dropping columns for 3.5.0 upgrade");
-
+$logger->info('Dropping columns for 3.5.0 upgrade');
try {
- $q1 = "alter table family_custom_master drop column `fam_custom_Side`;";
- $connection->exec($q1);
-} catch (\Exception $e){
- $logger->warning("Could not remove `family_custom_master.fam_custom_Side`, but this is probably ok");
+ $q1 = 'alter table family_custom_master drop column `fam_custom_Side`;';
+ $connection->exec($q1);
+} catch (\Exception $e) {
+ $logger->warning('Could not remove `family_custom_master.fam_custom_Side`, but this is probably ok');
}
try {
- $q2 = "alter table custom_master drop column `custom_Side`;";
- $connection->exec($q2);
-} catch (\Exception $e){
- $logger->warning("Could not remove `custom_master.custom_Side`, but this is probably ok");
+ $q2 = 'alter table custom_master drop column `custom_Side`;';
+ $connection->exec($q2);
+} catch (\Exception $e) {
+ $logger->warning('Could not remove `custom_master.custom_Side`, but this is probably ok');
}
-
try {
- $q3 = "alter table person_custom_master drop column `custom_Side`;";
- $connection->exec($q3);
-} catch (\Exception $e){
- $logger->warning("Could not remove `person_custom_master.custom_Side`, but this is probably ok");
+ $q3 = 'alter table person_custom_master drop column `custom_Side`;';
+ $connection->exec($q3);
+} catch (\Exception $e) {
+ $logger->warning('Could not remove `person_custom_master.custom_Side`, but this is probably ok');
}
-
-$logger->info("Finished dropping columns for 3.5.0 upgrade");
+$logger->info('Finished dropping columns for 3.5.0 upgrade');
diff --git a/src/session/index.php b/src/session/index.php
index e63f3a9b3b..70a880ca63 100644
--- a/src/session/index.php
+++ b/src/session/index.php
@@ -1,25 +1,26 @@
get('/begin', 'beginSession');
-$app->post("/begin", "beginSession");
+$app->post('/begin', 'beginSession');
$app->get('/end', 'endSession');
$app->get('/two-factor', 'processTwoFactorGet');
$app->post('/two-factor', 'processTwoFactorPost');
@@ -44,16 +44,15 @@ function processTwoFactorGet(Request $request, Response $response, array $args)
$curUser = AuthenticationManager::GetCurrentUser();
$pageArgs = [
'sRootPath' => SystemURLs::getRootPath(),
- 'user' => $curUser,
+ 'user' => $curUser,
];
return $renderer->render($response, 'two-factor.php', $pageArgs);
}
-
function processTwoFactorPost(Request $request, Response $response, array $args)
{
- $loginRequestBody = (object)$request->getParsedBody();
+ $loginRequestBody = (object) $request->getParsedBody();
$request = new LocalTwoFactorTokenRequest($loginRequestBody->TwoFACode);
AuthenticationManager::Authenticate($request);
}
@@ -63,17 +62,16 @@ function endSession(Request $request, Response $response, array $args)
AuthenticationManager::EndSession();
}
-
function beginSession(Request $request, Response $response, array $args)
{
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
+ 'sRootPath' => SystemURLs::getRootPath(),
'localAuthNextStepURL' => AuthenticationManager::GetSessionBeginURL(),
- 'forgotPasswordURL' => AuthenticationManager::GetForgotPasswordURL()
+ 'forgotPasswordURL' => AuthenticationManager::GetForgotPasswordURL(),
];
- if ($request->getMethod() == "POST") {
- $loginRequestBody = (object)$request->getParsedBody();
+ if ($request->getMethod() == 'POST') {
+ $loginRequestBody = (object) $request->getParsedBody();
$request = new LocalUsernamePasswordRequest($loginRequestBody->User, $loginRequestBody->Password);
$authenticationResult = AuthenticationManager::Authenticate($request);
$pageArgs['sErrorText'] = $authenticationResult->message;
@@ -81,8 +79,8 @@ function beginSession(Request $request, Response $response, array $args)
$renderer = new PhpRenderer('templates/');
- $pageArgs['prefilledUserName'] = "";
- # Defermine if approprirate to pre-fill the username field
+ $pageArgs['prefilledUserName'] = '';
+ // Defermine if approprirate to pre-fill the username field
if (isset($_GET['username'])) {
$pageArgs['prefilledUserName'] = $_GET['username'];
} elseif (isset($_SESSION['username'])) {
diff --git a/src/session/routes/password-reset.php b/src/session/routes/password-reset.php
index ecd81d439b..5d05f4708d 100644
--- a/src/session/routes/password-reset.php
+++ b/src/session/routes/password-reset.php
@@ -1,22 +1,21 @@
group('/forgot-password', function () {
if (SystemConfig::getBooleanValue('bEnableLostPassword')) {
- $this->get('/reset-request', "forgotPassword");
+ $this->get('/reset-request', 'forgotPassword');
$this->post('/reset-request', 'userPasswordReset');
$this->get('/set/{token}', function ($request, $response, $args) {
$renderer = new PhpRenderer('templates');
@@ -30,39 +29,40 @@
$token->save();
$password = $user->resetPasswordToRandom();
$user->save();
- LoggerUtils::getAuthLogger()->info("Password reset for user ". $user->getUserName());
+ LoggerUtils::getAuthLogger()->info('Password reset for user '.$user->getUserName());
$email = new ResetPasswordEmail($user, $password);
if ($email->send()) {
return $renderer->render($response, 'password/password-check-email.php', ['sRootPath' => SystemURLs::getRootPath()]);
} else {
$this->Logger->error($email->getError());
+
throw new \Exception($email->getError());
}
}
}
- return $renderer->render($response, "error.php", array("message" => gettext("Unable to reset password")));
+ return $renderer->render($response, 'error.php', ['message' => gettext('Unable to reset password')]);
});
- }
- else {
+ } else {
$this->get('/{foo:.*}', function ($request, $response, $args) {
$renderer = new PhpRenderer('templates');
- return $renderer->render($response, '/error.php', array("message" => gettext("Password reset not available. Please contact your system administrator")));
+
+ return $renderer->render($response, '/error.php', ['message' => gettext('Password reset not available. Please contact your system administrator')]);
});
}
});
-
-function forgotPassword($request, $response, $args) {
+function forgotPassword($request, $response, $args)
+{
$renderer = new PhpRenderer('templates/password/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- "PasswordResetXHREndpoint" => AuthenticationManager::GetForgotPasswordURL()
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'PasswordResetXHREndpoint' => AuthenticationManager::GetForgotPasswordURL(),
];
+
return $renderer->render($response, 'enter-username.php', $pageArgs);
}
-
function userPasswordReset(Request $request, Response $response, array $args)
{
$logger = LoggerUtils::getAppLogger();
@@ -72,17 +72,19 @@ function userPasswordReset(Request $request, Response $response, array $args)
$user = UserQuery::create()->findOneByUserName($userName);
if (!empty($user) && !empty($user->getEmail())) {
$token = new Token();
- $token->build("password", $user->getId());
+ $token->build('password', $user->getId());
$token->save();
$email = new ResetPasswordTokenEmail($user, $token->getToken());
if (!$email->send()) {
LoggerUtils::getAppLogger()->error($email->getError());
}
- LoggerUtils::getAuthLogger()->info("Password reset token for ". $user->getUserName() . " sent to email address: " . $user->getEmail());
+ LoggerUtils::getAuthLogger()->info('Password reset token for '.$user->getUserName().' sent to email address: '.$user->getEmail());
+
return $response->withStatus(200);
} else {
- return $response->withStatus(404, gettext("User") . " [" . $userName . "] ". gettext("no found or user without an email"));
+ return $response->withStatus(404, gettext('User').' ['.$userName.'] '.gettext('no found or user without an email'));
}
}
- return $response->withStatus(400, gettext("UserName not set"));
+
+ return $response->withStatus(400, gettext('UserName not set'));
}
diff --git a/src/setup/index.php b/src/setup/index.php
index be2db57f04..059a54bb60 100644
--- a/src/setup/index.php
+++ b/src/setup/index.php
@@ -5,26 +5,26 @@
error_reporting(E_ALL);
ini_set('log_errors', 1);
-ini_set('error_log', __DIR__ . '/../logs/external.log');
+ini_set('error_log', __DIR__.'/../logs/external.log');
if (file_exists('../Include/Config.php')) {
header('Location: ../index.php');
} else {
- require_once dirname(__FILE__) . '/../vendor/autoload.php';
+ require_once dirname(__FILE__).'/../vendor/autoload.php';
$rootPath = str_replace('/setup/index.php', '', $_SERVER['SCRIPT_NAME']);
- SystemURLs::init($rootPath, '', dirname(__FILE__)."/../");
+ SystemURLs::init($rootPath, '', dirname(__FILE__).'/../');
SystemConfig::init();
$app = new \Slim\App();
$container = $app->getContainer();
if (SystemConfig::debugEnabled()) {
- $container["settings"]['displayErrorDetails'] = true;
+ $container['settings']['displayErrorDetails'] = true;
}
- require __DIR__ . '/../Include/slim/error-handler.php';
+ require __DIR__.'/../Include/slim/error-handler.php';
- require __DIR__ . '/routes/setup.php';
+ require __DIR__.'/routes/setup.php';
$app->run();
}
diff --git a/src/setup/routes/setup.php b/src/setup/routes/setup.php
index be4d0abef7..65bd71c7b6 100644
--- a/src/setup/routes/setup.php
+++ b/src/setup/routes/setup.php
@@ -8,9 +8,10 @@
$this->get('', function ($request, $response, $args) {
$renderer = new PhpRenderer('templates/');
$renderPage = 'setup-steps.php';
- if (version_compare(phpversion(), "8.0.0", ">=")) {
+ if (version_compare(phpversion(), '8.0.0', '>=')) {
$renderPage = 'setup-error.php';
}
+
return $renderer->render($response, $renderPage, ['sRootPath' => SystemURLs::getRootPath()]);
});
@@ -21,6 +22,7 @@
$this->get('SystemPrerequisiteCheck', function ($request, $response, $args) {
$required = AppIntegrityService::getApplicationPrerequisites();
+
return $response->withJson($required);
});
diff --git a/src/sundayschool/SundaySchoolClassListExport.php b/src/sundayschool/SundaySchoolClassListExport.php
index da27564341..acbd84dc1a 100644
--- a/src/sundayschool/SundaySchoolClassListExport.php
+++ b/src/sundayschool/SundaySchoolClassListExport.php
@@ -9,75 +9,68 @@
require '../Include/Config.php';
require '../Include/Functions.php';
-use ChurchCRM\Reports\ChurchInfoReport;
use ChurchCRM\dto\SystemConfig;
-use ChurchCRM\Utils\InputUtils;
-use ChurchCRM\dto\SystemURLs;
-use ChurchCRM\PersonQuery;
use ChurchCRM\FamilyQuery;
use ChurchCRM\GroupQuery;
-use ChurchCRM\Person2group2roleP2g2r;
use ChurchCRM\Map\PersonTableMap;
+use ChurchCRM\Utils\InputUtils;
use Propel\Runtime\ActiveQuery\Criteria;
header('Pragma: no-cache');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Description: File Transfer');
-header('Content-Type: text/csv;charset='.SystemConfig::getValue("sCSVExportCharset"));
-header('Content-Disposition: attachment; filename=SundaySchool-'.date(SystemConfig::getValue("sDateFilenameFormat")).'.csv');
+header('Content-Type: text/csv;charset='.SystemConfig::getValue('sCSVExportCharset'));
+header('Content-Disposition: attachment; filename=SundaySchool-'.date(SystemConfig::getValue('sDateFilenameFormat')).'.csv');
header('Content-Transfer-Encoding: binary');
-$delimiter = SystemConfig::getValue("sCSVExportDelimiter");
+$delimiter = SystemConfig::getValue('sCSVExportDelimiter');
$out = fopen('php://output', 'w');
//add BOM to fix UTF-8 in Excel 2016 but not under, so the problem is solved with the sCSVExportCharset variable
-if (SystemConfig::getValue("sCSVExportCharset") == "UTF-8") {
- fputs($out, $bom =(chr(0xEF) . chr(0xBB) . chr(0xBF)));
+if (SystemConfig::getValue('sCSVExportCharset') == 'UTF-8') {
+ fputs($out, $bom = (chr(0xEF).chr(0xBB).chr(0xBF)));
}
-
fputcsv($out, [InputUtils::translate_special_charset('Class'),
- InputUtils::translate_special_charset('Role'),
- InputUtils::translate_special_charset('First Name'),
- InputUtils::translate_special_charset('Last Name'),
- InputUtils::translate_special_charset('Birth Date'),
- InputUtils::translate_special_charset('Mobile'),
- InputUtils::translate_special_charset('Home Phone'),
- InputUtils::translate_special_charset('Home Address'),
- InputUtils::translate_special_charset('Dad Name'),
- InputUtils::translate_special_charset('Dad Mobile') ,
- InputUtils::translate_special_charset('Dad Email'),
- InputUtils::translate_special_charset('Mom Name'),
- InputUtils::translate_special_charset('Mom Mobile'),
- InputUtils::translate_special_charset('Mom Email'),
- InputUtils::translate_special_charset('Properties') ], $delimiter);
+ InputUtils::translate_special_charset('Role'),
+ InputUtils::translate_special_charset('First Name'),
+ InputUtils::translate_special_charset('Last Name'),
+ InputUtils::translate_special_charset('Birth Date'),
+ InputUtils::translate_special_charset('Mobile'),
+ InputUtils::translate_special_charset('Home Phone'),
+ InputUtils::translate_special_charset('Home Address'),
+ InputUtils::translate_special_charset('Dad Name'),
+ InputUtils::translate_special_charset('Dad Mobile'),
+ InputUtils::translate_special_charset('Dad Email'),
+ InputUtils::translate_special_charset('Mom Name'),
+ InputUtils::translate_special_charset('Mom Mobile'),
+ InputUtils::translate_special_charset('Mom Email'),
+ InputUtils::translate_special_charset('Properties')], $delimiter);
// only the unday groups
$groups = GroupQuery::create()
->orderByName(Criteria::ASC)
->filterByType(4)
->find();
-
foreach ($groups as $group) {
$iGroupID = $group->getID();
$sundayschoolClass = $group->getName();
-
-
+
$groupRoleMemberships = ChurchCRM\Person2group2roleP2g2rQuery::create()
->joinWithPerson()
->orderBy(PersonTableMap::COL_PER_LASTNAME)
->_and()->orderBy(PersonTableMap::COL_PER_FIRSTNAME) // I've try to reproduce per_LastName, per_FirstName
->findByGroupId($iGroupID);
-
+
foreach ($groupRoleMemberships as $groupRoleMembership) {
$groupRole = ChurchCRM\ListOptionQuery::create()->filterById($group->getRoleListId())->filterByOptionId($groupRoleMembership->getRoleId())->findOne();
-
+
$lst_OptionName = $groupRole->getOptionName();
$member = $groupRoleMembership->getPerson();
-
+
$firstName = $member->getFirstName();
$middlename = $member->getMiddleName();
$lastname = $member->getLastName();
@@ -87,13 +80,13 @@
$homePhone = $member->getHomePhone();
$mobilePhone = $member->getCellPhone();
$hideAge = $member->hideAge();
-
+
$family = $member->getFamily();
-
- $Address1 = $Address2 = $city = $state = $zip = " ";
- $dadFirstName = $dadLastName = $dadCellPhone = $dadEmail = " ";
- $momFirstName = $momLastName = $momCellPhone = $momEmail = " ";
-
+
+ $Address1 = $Address2 = $city = $state = $zip = ' ';
+ $dadFirstName = $dadLastName = $dadCellPhone = $dadEmail = ' ';
+ $momFirstName = $momLastName = $momCellPhone = $momEmail = ' ';
+
if (!empty($family)) {
$famID = $family->getID();
$Address1 = $family->getAddress1();
@@ -101,12 +94,11 @@
$city = $family->getCity();
$state = $family->getState();
$zip = $family->getZip();
-
-
- if ($lst_OptionName == "Student") {
+
+ if ($lst_OptionName == 'Student') {
// only for a student
$FAmembers = FamilyQuery::create()->findOneByID($famID)->getAdults();
-
+
// il faut encore chercher les membres de la famille
foreach ($FAmembers as $maf) {
if ($maf->getGender() == 1) {
@@ -125,23 +117,23 @@
}
}
}
-
+
$assignedProperties = $member->getProperties();
- $props = " ";
- if ($lst_OptionName == "Student" && !empty($assignedProperties)) {
+ $props = ' ';
+ if ($lst_OptionName == 'Student' && !empty($assignedProperties)) {
foreach ($assignedProperties as $property) {
- $props.= $property->getProName().", ";
+ $props .= $property->getProName().', ';
}
-
- $props = chop($props, ", ");
+
+ $props = chop($props, ', ');
}
-
+
$birthDate = '';
- if ($birthYear != '' && !$birthDate && (!$member->getFlags() || $lst_OptionName == "Student")) {
+ if ($birthYear != '' && !$birthDate && (!$member->getFlags() || $lst_OptionName == 'Student')) {
$publishDate = DateTime::createFromFormat('Y-m-d', $birthYear.'-'.$birthMonth.'-'.$birthDay);
- $birthDate = $publishDate->format(SystemConfig::getValue("sDateFormatLong"));
+ $birthDate = $publishDate->format(SystemConfig::getValue('sDateFormatLong'));
}
-
+
fputcsv($out, [
InputUtils::translate_special_charset($sundayschoolClass),
InputUtils::translate_special_charset($lst_OptionName),
diff --git a/src/v2/index.php b/src/v2/index.php
index c0bfb07d94..1fe541735e 100644
--- a/src/v2/index.php
+++ b/src/v2/index.php
@@ -1,4 +1,5 @@
get('/database/reset', 'dbResetPage');
})->add(new AdminRoleAuthMiddleware());
-function debugPage(Request $request, Response $response, array $args) {
+function debugPage(Request $request, Response $response, array $args)
+{
$renderer = new PhpRenderer('templates/admin/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('Debug')
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('Debug'),
];
return $renderer->render($response, 'debug.php', $pageArgs);
}
-function menuPage(Request $request, Response $response, array $args) {
+function menuPage(Request $request, Response $response, array $args)
+{
$renderer = new PhpRenderer('templates/admin/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('Custom Menus')
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('Custom Menus'),
];
return $renderer->render($response, 'menus.php', $pageArgs);
}
-
-function dbResetPage(Request $request, Response $response, array $args) {
+function dbResetPage(Request $request, Response $response, array $args)
+{
$renderer = new PhpRenderer('templates/admin/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('Database Reset Functions')
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('Database Reset Functions'),
];
return $renderer->render($response, 'database-reset.php', $pageArgs);
}
-
-
diff --git a/src/v2/routes/calendar.php b/src/v2/routes/calendar.php
index 6ec00fa1ad..393387fa14 100644
--- a/src/v2/routes/calendar.php
+++ b/src/v2/routes/calendar.php
@@ -9,28 +9,29 @@
use Slim\Http\Response;
use Slim\Views\PhpRenderer;
-
$app->group('/calendar', function () {
$this->get('/', 'getCalendar');
$this->get('', 'getCalendar');
});
-function getCalendar(Request $request, Response $response, array $args) {
+function getCalendar(Request $request, Response $response, array $args)
+{
$renderer = new PhpRenderer('templates/calendar/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('Calendar'),
- 'calendarJSArgs' => getCalendarJSArgs()
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('Calendar'),
+ 'calendarJSArgs' => getCalendarJSArgs(),
];
return $renderer->render($response, 'calendar.php', $pageArgs);
}
-function getCalendarJSArgs() {
- return array(
- 'isModifiable' => AuthenticationManager::GetCurrentUser()->isAddEvent(),
- 'countCalendarAccessTokens' => CalendarQuery::create()->filterByAccessToken(null, Criteria::NOT_EQUAL)->count(),
- 'bEnableExternalCalendarAPI' => SystemConfig::getBooleanValue("bEnableExternalCalendarAPI")
- );
+function getCalendarJSArgs()
+{
+ return [
+ 'isModifiable' => AuthenticationManager::GetCurrentUser()->isAddEvent(),
+ 'countCalendarAccessTokens' => CalendarQuery::create()->filterByAccessToken(null, Criteria::NOT_EQUAL)->count(),
+ 'bEnableExternalCalendarAPI' => SystemConfig::getBooleanValue('bEnableExternalCalendarAPI'),
+ ];
}
diff --git a/src/v2/routes/cart.php b/src/v2/routes/cart.php
index 1b6cb8de4a..5e72d88630 100644
--- a/src/v2/routes/cart.php
+++ b/src/v2/routes/cart.php
@@ -6,30 +6,31 @@
use Slim\Http\Response;
use Slim\Views\PhpRenderer;
-
$app->group('/cart', function () {
- $this->get('/', 'getCartView');
- $this->get('', 'getCartView');
+ $this->get('/', 'getCartView');
+ $this->get('', 'getCartView');
});
-function getCartView(Request $request, Response $response, array $args) {
- $renderer = new PhpRenderer('templates/cart/');
+function getCartView(Request $request, Response $response, array $args)
+{
+ $renderer = new PhpRenderer('templates/cart/');
+
+ $pageArgs = [
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('View Your Cart'),
+ 'PageJSVars' => [],
+ ];
- $pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('View Your Cart'),
- 'PageJSVars' => []
- ];
+ if (!Cart::HasPeople()) {
+ return $renderer->render($response, 'cartempty.php', $pageArgs);
+ } else {
+ $pageArgs = array_merge($pageArgs, [
+ 'sEmailLink' => Cart::getEmailLink(),
+ 'sPhoneLink' => Cart::getSMSLink(),
+ 'iNumFamilies' => Cart::CountFamilies(),
+ 'cartPeople' => Cart::getCartPeople(),
+ ]);
- if (!Cart::HasPeople()) {
- return $renderer->render($response, 'cartempty.php', $pageArgs);
- } else {
- $pageArgs = array_merge($pageArgs, array(
- 'sEmailLink' => Cart::getEmailLink(),
- 'sPhoneLink' => Cart::getSMSLink(),
- 'iNumFamilies' => Cart::CountFamilies(),
- 'cartPeople' => Cart::getCartPeople()
- ));
- return $renderer->render($response, 'cartview.php', $pageArgs);
- }
+ return $renderer->render($response, 'cartview.php', $pageArgs);
+ }
}
diff --git a/src/v2/routes/common/mvc-helper.php b/src/v2/routes/common/mvc-helper.php
index d72bbfb518..4ece4dac9f 100644
--- a/src/v2/routes/common/mvc-helper.php
+++ b/src/v2/routes/common/mvc-helper.php
@@ -4,13 +4,14 @@
use Slim\Http\Response;
use Slim\Views\PhpRenderer;
-function renderPage(Response $response, $renderPath, $renderFile, $title = "")
+function renderPage(Response $response, $renderPath, $renderFile, $title = '')
{
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext($title)
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext($title),
];
$renderer = new PhpRenderer($renderPath);
+
return $renderer->render($response, $renderFile, $pageArgs);
-}
\ No newline at end of file
+}
diff --git a/src/v2/routes/email.php b/src/v2/routes/email.php
index 59c28591bf..f4f9b810a7 100644
--- a/src/v2/routes/email.php
+++ b/src/v2/routes/email.php
@@ -27,10 +27,10 @@ function getEmailDashboardMVC(Request $request, Response $response, array $args)
$mailchimp = new MailChimpService();
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('eMail Dashboard'),
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('eMail Dashboard'),
'isMailChimpActive' => $mailchimp->isActive(),
- 'mailChimpLists' => $mailchimp->getLists()
+ 'mailChimpLists' => $mailchimp->getLists(),
];
return $renderer->render($response, 'dashboard.php', $pageArgs);
@@ -41,35 +41,35 @@ function testEmailConnectionMVC(Request $request, Response $response, array $arg
$renderer = new PhpRenderer('templates/email/');
$mailer = new PHPMailer();
- $message = "";
+ $message = '';
- if (!empty(SystemConfig::getValue("sSMTPHost")) && !empty(ChurchMetaData::getChurchEmail())) {
+ if (!empty(SystemConfig::getValue('sSMTPHost')) && !empty(ChurchMetaData::getChurchEmail())) {
$mailer->IsSMTP();
$mailer->CharSet = 'UTF-8';
- $mailer->Timeout = intval(SystemConfig::getValue("iSMTPTimeout"));
- $mailer->Host = SystemConfig::getValue("sSMTPHost");
- if (SystemConfig::getBooleanValue("bSMTPAuth")) {
+ $mailer->Timeout = intval(SystemConfig::getValue('iSMTPTimeout'));
+ $mailer->Host = SystemConfig::getValue('sSMTPHost');
+ if (SystemConfig::getBooleanValue('bSMTPAuth')) {
$mailer->SMTPAuth = true;
- echo "SMTP Auth Used ";
- $mailer->Username = SystemConfig::getValue("sSMTPUser");
- $mailer->Password = SystemConfig::getValue("sSMTPPass");
+ echo 'SMTP Auth Used ';
+ $mailer->Username = SystemConfig::getValue('sSMTPUser');
+ $mailer->Password = SystemConfig::getValue('sSMTPPass');
}
$mailer->SMTPDebug = 3;
- $mailer->Subject = "Test SMTP Email";
+ $mailer->Subject = 'Test SMTP Email';
$mailer->setFrom(ChurchMetaData::getChurchEmail());
$mailer->addAddress(ChurchMetaData::getChurchEmail());
- $mailer->Body = "test email";
- $mailer->Debugoutput = "html";
+ $mailer->Body = 'test email';
+ $mailer->Debugoutput = 'html';
} else {
- $message = gettext("SMTP Host is not setup, please visit the settings page");
+ $message = gettext('SMTP Host is not setup, please visit the settings page');
}
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext("Debug Email Connection"),
- 'mailer' => $mailer,
- 'message' => $message
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('Debug Email Connection'),
+ 'mailer' => $mailer,
+ 'message' => $message,
];
return $renderer->render($response, 'debug.php', $pageArgs);
@@ -77,12 +77,12 @@ function testEmailConnectionMVC(Request $request, Response $response, array $arg
function getDuplicateEmailsMVC(Request $request, Response $response, array $args)
{
- return renderPage($response,'templates/email/', 'duplicate.php', _("Duplicate Emails"));
+ return renderPage($response, 'templates/email/', 'duplicate.php', _('Duplicate Emails'));
}
function getFamiliesWithoutEmailsMVC(Request $request, Response $response, array $args)
{
- return renderPage($response,'templates/email/', 'without.php', _("Families Without Emails"));
+ return renderPage($response, 'templates/email/', 'without.php', _('Families Without Emails'));
}
function getMailListUnSubscribersMVC(Request $request, Response $response, array $args)
@@ -92,13 +92,15 @@ function getMailListUnSubscribersMVC(Request $request, Response $response, array
if ($list) {
$renderer = new PhpRenderer('templates/email/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => _("People not in"). " ". $list["name"],
- 'listId' => $list["id"]
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => _('People not in').' '.$list['name'],
+ 'listId' => $list['id'],
];
+
return $renderer->render($response, 'mailchimp-unsubscribers.php', $pageArgs);
}
- return $response->withStatus(404, gettext("Invalid List id") . ": " . $args['listId']);
+
+ return $response->withStatus(404, gettext('Invalid List id').': '.$args['listId']);
}
function getMailListMissingMVC(Request $request, Response $response, array $args)
@@ -108,11 +110,13 @@ function getMailListMissingMVC(Request $request, Response $response, array $args
if ($list) {
$renderer = new PhpRenderer('templates/email/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => $list["name"] . " " . _("Audience not in the ChurchCRM"),
- 'listId' => $list["id"]
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => $list['name'].' '._('Audience not in the ChurchCRM'),
+ 'listId' => $list['id'],
];
+
return $renderer->render($response, 'mailchimp-missing.php', $pageArgs);
}
- return $response->withStatus(404, gettext("Invalid List id") . ": " . $args['listId']);
+
+ return $response->withStatus(404, gettext('Invalid List id').': '.$args['listId']);
}
diff --git a/src/v2/routes/family.php b/src/v2/routes/family.php
index 34e058ff91..0e58bd7a44 100644
--- a/src/v2/routes/family.php
+++ b/src/v2/routes/family.php
@@ -15,48 +15,49 @@
use Slim\Views\PhpRenderer;
$app->group('/family', function () {
- $this->get('','listFamilies');
- $this->get('/','listFamilies');
+ $this->get('', 'listFamilies');
+ $this->get('/', 'listFamilies');
$this->get('/not-found', 'viewFamilyNotFound');
$this->get('/{id}', 'viewFamily');
});
function listFamilies(Request $request, Response $response, array $args)
{
- $renderer = new PhpRenderer('templates/people/');
- $sMode = 'Active';
- // Filter received user input as needed
- if (isset($_GET['mode'])) {
- $sMode = InputUtils::LegacyFilterInput($_GET['mode']);
- }
- if (strtolower($sMode) == 'inactive') {
- $families = FamilyQuery::create()
- ->filterByDateDeactivated(null, Criteria::ISNOTNULL)
- ->orderByName()
- ->find();
- } else {
- $sMode = 'Active';
- $families = FamilyQuery::create()
- ->filterByDateDeactivated(null)
- ->orderByName()
- ->find();
- }
- $pageArgs = [
- 'sMode' => $sMode,
- 'sRootPath' => SystemURLs::getRootPath(),
- 'families' => $families
- ];
- return $renderer->render($response, 'family-list.php', $pageArgs);
+ $renderer = new PhpRenderer('templates/people/');
+ $sMode = 'Active';
+ // Filter received user input as needed
+ if (isset($_GET['mode'])) {
+ $sMode = InputUtils::LegacyFilterInput($_GET['mode']);
+ }
+ if (strtolower($sMode) == 'inactive') {
+ $families = FamilyQuery::create()
+ ->filterByDateDeactivated(null, Criteria::ISNOTNULL)
+ ->orderByName()
+ ->find();
+ } else {
+ $sMode = 'Active';
+ $families = FamilyQuery::create()
+ ->filterByDateDeactivated(null)
+ ->orderByName()
+ ->find();
+ }
+ $pageArgs = [
+ 'sMode' => $sMode,
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'families' => $families,
+ ];
+
+ return $renderer->render($response, 'family-list.php', $pageArgs);
}
function viewFamilyNotFound(Request $request, Response $response, array $args)
{
- $renderer = new PhpRenderer('templates/common/');
+ $renderer = new PhpRenderer('templates/common/');
- $pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'memberType' => "Family",
- 'id' => $request->getParam("id")
+ $pageArgs = [
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'memberType' => 'Family',
+ 'id' => $request->getParam('id'),
];
return $renderer->render($response, 'not-found-view.php', $pageArgs);
@@ -66,29 +67,29 @@ function viewFamily(Request $request, Response $response, array $args)
{
$renderer = new PhpRenderer('templates/people/');
- $familyId = $args["id"];
+ $familyId = $args['id'];
$family = FamilyQuery::create()->findPk($familyId);
if (empty($family)) {
- return $response->withRedirect(SystemURLs::getRootPath() . "/v2/family/not-found?id=".$args["id"]);
+ return $response->withRedirect(SystemURLs::getRootPath().'/v2/family/not-found?id='.$args['id']);
}
$timelineService = new TimelineService();
- $allFamilyProperties = PropertyQuery::create()->findByProClass("f");
+ $allFamilyProperties = PropertyQuery::create()->findByProClass('f');
$allFamilyCustomFields = FamilyCustomMasterQuery::create()->find();
// get family with all the extra columns created
- $rawQry = FamilyCustomQuery::create();
- foreach ($allFamilyCustomFields as $customfield ) {
+ $rawQry = FamilyCustomQuery::create();
+ foreach ($allFamilyCustomFields as $customfield) {
$rawQry->withColumn($customfield->getField());
}
$thisFamilyCustomFields = $rawQry->findOneByFamId($familyId);
if ($thisFamilyCustomFields) {
$familyCustom = [];
- foreach ($allFamilyCustomFields as $customfield ) {
+ foreach ($allFamilyCustomFields as $customfield) {
if (AuthenticationManager::GetCurrentUser()->isEnabledSecurity($customfield->getFieldSecurity())) {
$value = $thisFamilyCustomFields->getVirtualColumn($customfield->getField());
if (!empty($value)) {
@@ -100,14 +101,12 @@ function viewFamily(Request $request, Response $response, array $args)
}
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'family' => $family,
- 'familyTimeline' => $timelineService->getForFamily($family->getId()),
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'family' => $family,
+ 'familyTimeline' => $timelineService->getForFamily($family->getId()),
'allFamilyProperties' => $allFamilyProperties,
- 'familyCustom' => $familyCustom
+ 'familyCustom' => $familyCustom,
];
return $renderer->render($response, 'family-view.php', $pageArgs);
-
}
-
diff --git a/src/v2/routes/people.php b/src/v2/routes/people.php
index 1c1c0933c9..c3ba226fbe 100644
--- a/src/v2/routes/people.php
+++ b/src/v2/routes/people.php
@@ -8,13 +8,11 @@
use Slim\Http\Response;
use Slim\Views\PhpRenderer;
-
// entity can be a person, family, or business
$app->group('/people', function () {
- $this->get('','listPeople');
+ $this->get('', 'listPeople');
$this->get('/', 'listPeople');
- $this->get('/verify','viewPeopleVerify');
-
+ $this->get('/verify', 'viewPeopleVerify');
});
function viewPeopleVerify(Request $request, Response $response, array $args)
@@ -25,15 +23,15 @@ function viewPeopleVerify(Request $request, Response $response, array $args)
'sRootPath' => SystemURLs::getRootPath(),
];
- if ($request->getQueryParam("EmailsError")) {
- $errorArgs = ['sGlobalMessage' => gettext("Error sending email(s)") . " - " . gettext("Please check logs for more information"), "sGlobalMessageClass" => "danger"];
- $pageArgs = array_merge($pageArgs, $errorArgs);
+ if ($request->getQueryParam('EmailsError')) {
+ $errorArgs = ['sGlobalMessage' => gettext('Error sending email(s)').' - '.gettext('Please check logs for more information'), 'sGlobalMessageClass' => 'danger'];
+ $pageArgs = array_merge($pageArgs, $errorArgs);
}
- if ($request->getQueryParam("AllPDFsEmailed")) {
- $headerArgs = ['sGlobalMessage' => gettext('PDFs successfully emailed ').$request->getQueryParam("AllPDFsEmailed").' '.gettext('families').".",
- "sGlobalMessageClass" => "success"];
- $pageArgs = array_merge($pageArgs, $headerArgs);
+ if ($request->getQueryParam('AllPDFsEmailed')) {
+ $headerArgs = ['sGlobalMessage' => gettext('PDFs successfully emailed ').$request->getQueryParam('AllPDFsEmailed').' '.gettext('families').'.',
+ 'sGlobalMessageClass' => 'success'];
+ $pageArgs = array_merge($pageArgs, $headerArgs);
}
return $renderer->render($response, 'people-verify-view.php', $pageArgs);
@@ -41,7 +39,6 @@ function viewPeopleVerify(Request $request, Response $response, array $args)
function listPeople(Request $request, Response $response, array $args)
{
-
$renderer = new PhpRenderer('templates/people/');
// Filter received user input as needed
// Classification
@@ -50,19 +47,19 @@ function listPeople(Request $request, Response $response, array $args)
$members = PersonQuery::create();
// set default sMode
- $sMode = "Person";
+ $sMode = 'Person';
// by default show only active families
- $familyActiveStatus = "active";
- if ($_GET['familyActiveStatus'] == "inactive") {
- $familyActiveStatus = "inactive";
- } else if ($_GET['familyActiveStatus'] == "all") {
- $familyActiveStatus = "all";
+ $familyActiveStatus = 'active';
+ if ($_GET['familyActiveStatus'] == 'inactive') {
+ $familyActiveStatus = 'inactive';
+ } elseif ($_GET['familyActiveStatus'] == 'all') {
+ $familyActiveStatus = 'all';
}
- if ($familyActiveStatus == "active") {
+ if ($familyActiveStatus == 'active') {
$members->leftJoinFamily()->where('family_fam.fam_DateDeactivated is null');
} else {
- if ($familyActiveStatus == "inactive") {
+ if ($familyActiveStatus == 'inactive') {
$members->leftJoinFamily()->where('family_fam.fam_DateDeactivated is not null');
}
}
@@ -72,21 +69,20 @@ function listPeople(Request $request, Response $response, array $args)
$filterByClsId = '';
if (isset($_GET['Classification'])) {
$id = InputUtils::LegacyFilterInput($_GET['Classification']);
- $option = ListOptionQuery::create()->filterById(1)->filterByOptionId($id)->findOne();
+ $option = ListOptionQuery::create()->filterById(1)->filterByOptionId($id)->findOne();
if ($id == 0) {
$filterByClsId = gettext('Unassigned');
$sMode = $filterByClsId;
} else {
- $filterByClsId = $option->getOptionName();
+ $filterByClsId = $option->getOptionName();
$sMode = $filterByClsId;
}
-
}
$filterByFmrId = '';
if (isset($_GET['FamilyRole'])) {
$id = InputUtils::LegacyFilterInput($_GET['FamilyRole']);
- $option = ListOptionQuery::create()->filterById(2)->filterByOptionId($id)->findOne();
+ $option = ListOptionQuery::create()->filterById(2)->filterByOptionId($id)->findOne();
if ($id == 0) {
$filterByFmrId = gettext('Unassigned');
@@ -104,26 +100,26 @@ function listPeople(Request $request, Response $response, array $args)
switch ($id) {
case 0:
$filterByGender = gettext('Unassigned');
- $sMode = $sMode . " - " . $filterByGender;
+ $sMode = $sMode.' - '.$filterByGender;
break;
case 1:
$filterByGender = gettext('Male');
- $sMode = $sMode . " - " . $filterByGender;
+ $sMode = $sMode.' - '.$filterByGender;
break;
case 2:
- $filterByGender = gettext('Female');
- $sMode = $sMode . " - " . $filterByGender;
+ $filterByGender = gettext('Female');
+ $sMode = $sMode.' - '.$filterByGender;
break;
}
}
$pageArgs = [
- 'sMode' => $sMode,
- 'sRootPath' => SystemURLs::getRootPath(),
- 'members' => $members,
- 'filterByClsId' => $filterByClsId,
- 'filterByFmrId' => $filterByFmrId,
- 'filterByGender' => $filterByGender
+ 'sMode' => $sMode,
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'members' => $members,
+ 'filterByClsId' => $filterByClsId,
+ 'filterByFmrId' => $filterByFmrId,
+ 'filterByGender' => $filterByGender,
];
return $renderer->render($response, 'person-list.php', $pageArgs);
diff --git a/src/v2/routes/person.php b/src/v2/routes/person.php
index 146298c9a3..67bc233caa 100644
--- a/src/v2/routes/person.php
+++ b/src/v2/routes/person.php
@@ -9,15 +9,14 @@
$this->get('/not-found', 'viewPersonNotFound');
});
-
function viewPersonNotFound(Request $request, Response $response, array $args)
{
$renderer = new PhpRenderer('templates/common/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'memberType' => "Person",
- 'id' => $request->getParam("id")
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'memberType' => 'Person',
+ 'id' => $request->getParam('id'),
];
return $renderer->render($response, 'not-found-view.php', $pageArgs);
diff --git a/src/v2/routes/root.php b/src/v2/routes/root.php
index ba58bb99e6..56861d467b 100644
--- a/src/v2/routes/root.php
+++ b/src/v2/routes/root.php
@@ -17,44 +17,41 @@
$this->get('/dashboard', 'viewDashboard');
});
-
function viewDashboard(Request $request, Response $response, array $args)
{
$renderer = new PhpRenderer('templates/root/');
-
$dashboardCounts = [];
- $dashboardCounts["families"] = FamilyQuery::Create()
+ $dashboardCounts['families'] = FamilyQuery::Create()
->filterByDateDeactivated()
->count();
- $dashboardCounts["People"] = PersonQuery::create()
+ $dashboardCounts['People'] = PersonQuery::create()
->leftJoinWithFamily()
->where('Family.DateDeactivated is null')
->count();
- $dashboardCounts["SundaySchool"] = GroupQuery::create()
+ $dashboardCounts['SundaySchool'] = GroupQuery::create()
->filterByType(4)
->count();
- $dashboardCounts["Groups"] = GroupQuery::create()
+ $dashboardCounts['Groups'] = GroupQuery::create()
->filterByType(4, Criteria::NOT_EQUAL)
->count();
- $dashboardCounts["events"] = EventAttendQuery::create()
+ $dashboardCounts['events'] = EventAttendQuery::create()
->filterByCheckinDate(null, Criteria::NOT_EQUAL)
->filterByCheckoutDate(null, Criteria::EQUAL)
->find()
->count();
-
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'sPageTitle' => gettext('Welcome to').' '. ChurchMetaData::getChurchName(),
- 'dashboardCounts' => $dashboardCounts,
- 'sundaySchoolEnabled' => SystemConfig::getBooleanValue("bEnabledSundaySchool"),
- 'depositEnabled' => AuthenticationManager::GetCurrentUser()->isFinanceEnabled()
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'sPageTitle' => gettext('Welcome to').' '.ChurchMetaData::getChurchName(),
+ 'dashboardCounts' => $dashboardCounts,
+ 'sundaySchoolEnabled' => SystemConfig::getBooleanValue('bEnabledSundaySchool'),
+ 'depositEnabled' => AuthenticationManager::GetCurrentUser()->isFinanceEnabled(),
];
return $renderer->render($response, 'dashboard.php', $pageArgs);
diff --git a/src/v2/routes/user-current.php b/src/v2/routes/user-current.php
index fbf52922d3..91fb8e4df4 100644
--- a/src/v2/routes/user-current.php
+++ b/src/v2/routes/user-current.php
@@ -15,21 +15,18 @@
$this->post('/changepassword', 'changepassword');
});
-
-
function enroll2fa(Request $request, Response $response, array $args)
{
$renderer = new PhpRenderer('templates/user/');
$curUser = AuthenticationManager::GetCurrentUser();
$pageArgs = [
'sRootPath' => SystemURLs::getRootPath(),
- 'user' => $curUser,
+ 'user' => $curUser,
];
if (LocalAuthentication::GetIsTwoFactorAuthSupported()) {
return $renderer->render($response, 'manage-2fa.php', $pageArgs);
- }
- else {
+ } else {
return $renderer->render($response, 'unsupported-2fa.php', $pageArgs);
}
}
@@ -41,33 +38,32 @@ function changepassword(Request $request, Response $response, array $args)
$curUser = AuthenticationManager::GetCurrentUser();
$pageArgs = [
'sRootPath' => SystemURLs::getRootPath(),
- 'user' => $curUser,
+ 'user' => $curUser,
];
if ($authenticationProvider instanceof LocalAuthentication) {
// ChangePassword only works with LocalAuthentication
- if ($request->getMethod() == "POST") {
- $loginRequestBody = (object)$request->getParsedBody();
+ if ($request->getMethod() == 'POST') {
+ $loginRequestBody = (object) $request->getParsedBody();
+
try {
$curUser->userChangePassword($loginRequestBody->OldPassword, $loginRequestBody->NewPassword1);
- return $renderer->render($response,"common/success-changepassword.php",$pageArgs);
- }
- catch (PasswordChangeException $pwChangeExc) {
- $pageArgs['s'.$pwChangeExc->AffectedPassword.'PasswordError'] = $pwChangeExc->getMessage();
+
+ return $renderer->render($response, 'common/success-changepassword.php', $pageArgs);
+ } catch (PasswordChangeException $pwChangeExc) {
+ $pageArgs['s'.$pwChangeExc->AffectedPassword.'PasswordError'] = $pwChangeExc->getMessage();
}
}
return $renderer->render($response, 'user/changepassword.php', $pageArgs);
- }
- elseif (empty($authenticationProvider->GetPasswordChangeURL())) {
+ } elseif (empty($authenticationProvider->GetPasswordChangeURL())) {
// if the authentication provider includes a URL for self-service password change
// then direct the user there
// i.e. SSO will usually be a password change "portal," so we would redirect here.
// but this will come later when we add more AuthenticationProviders
RedirectUtils::AbsoluteRedirect($authenticationProvider->GetPasswordChangeURL());
- }
- else {
+ } else {
// we're not using LocalAuth, and the AuthProvider does not specify a password change url
// so tell the user we can't help them
return $renderer->render($response, 'common/unsupported-changepassword.php', $pageArgs);
diff --git a/src/v2/routes/user.php b/src/v2/routes/user.php
index 2c3e981d23..5a8e634413 100644
--- a/src/v2/routes/user.php
+++ b/src/v2/routes/user.php
@@ -21,20 +21,19 @@ function viewUserNotFound(Request $request, Response $response, array $args)
$renderer = new PhpRenderer('templates/common/');
$pageArgs = [
- 'sRootPath' => SystemURLs::getRootPath(),
- 'memberType' => "User",
- 'id' => $request->getParam("id")
+ 'sRootPath' => SystemURLs::getRootPath(),
+ 'memberType' => 'User',
+ 'id' => $request->getParam('id'),
];
return $renderer->render($response, 'not-found-view.php', $pageArgs);
}
-
function viewUser(Request $request, Response $response, array $args)
{
$renderer = new PhpRenderer('templates/user/');
$curUser = AuthenticationManager::GetCurrentUser();
- $userId = $args["id"];
+ $userId = $args['id'];
if (!$curUser->isAdmin() && $curUser->getId() != $userId) {
return $response->withStatus(403);
@@ -43,22 +42,21 @@ function viewUser(Request $request, Response $response, array $args)
$user = UserQuery::create()->findPk($userId);
if (empty($user)) {
- return $response->withRedirect(SystemURLs::getRootPath() . "/v2/admin/user/not-found?id=".$args["id"]);
+ return $response->withRedirect(SystemURLs::getRootPath().'/v2/admin/user/not-found?id='.$args['id']);
}
$pageArgs = [
'sRootPath' => SystemURLs::getRootPath(),
- 'user' => $user,
+ 'user' => $user,
];
return $renderer->render($response, 'user.php', $pageArgs);
-
}
function adminChangeUserPassword(Request $request, Response $response, array $args)
{
$renderer = new PhpRenderer('templates/');
- $userId = $args["id"];
+ $userId = $args['id'];
$curUser = AuthenticationManager::GetCurrentUser();
// make sure that the currently logged in user has
@@ -70,31 +68,31 @@ function adminChangeUserPassword(Request $request, Response $response, array $ar
$user = UserQuery::create()->findPk($userId);
if (empty($user)) {
- return $response->withRedirect(SystemURLs::getRootPath() . "/v2/admin/user/not-found?id=".$args["id"]);
+ return $response->withRedirect(SystemURLs::getRootPath().'/v2/admin/user/not-found?id='.$args['id']);
}
if ($user->equals($curUser)) {
// Don't allow the current user (if admin) to set their new password
// make the user go through the "self-service" password change procedure
- return $response->withRedirect(SystemURLs::getRootPath() . "/v2/user/current/changepassword");
+ return $response->withRedirect(SystemURLs::getRootPath().'/v2/user/current/changepassword');
}
$pageArgs = [
'sRootPath' => SystemURLs::getRootPath(),
- 'user' => $user,
+ 'user' => $user,
];
- if ($request->getMethod() == "POST") {
- $loginRequestBody = (object)$request->getParsedBody();
+ if ($request->getMethod() == 'POST') {
+ $loginRequestBody = (object) $request->getParsedBody();
+
try {
$user->adminSetUserPassword($loginRequestBody->NewPassword1);
- return $renderer->render($response,"common/success-changepassword.php",$pageArgs);
- }
- catch (PasswordChangeException $pwChangeExc) {
- $pageArgs['s'.$pwChangeExc->AffectedPassword.'PasswordError'] = $pwChangeExc->getMessage();
+
+ return $renderer->render($response, 'common/success-changepassword.php', $pageArgs);
+ } catch (PasswordChangeException $pwChangeExc) {
+ $pageArgs['s'.$pwChangeExc->AffectedPassword.'PasswordError'] = $pwChangeExc->getMessage();
}
}
return $renderer->render($response, 'admin/adminchangepassword.php', $pageArgs);
-
}