Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System Settings Cleanup #2392

Merged
merged 22 commits into from
May 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demo/ChurchCRM-Database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ CREATE TABLE `config_cfg` (
LOCK TABLES `config_cfg` WRITE;
/*!40000 ALTER TABLE `config_cfg` DISABLE KEYS */;
SET autocommit=0;
INSERT INTO `config_cfg` VALUES (23,'sDefaultCountry','United States'),(27,'sSMTPHost','127.0.0.1:1025'),(10,'aFinanceQueries','28,30,31,32'),(28,'sSMTPAuth',''),(48,'bHideFriendDate',''),(49,'bHideFamilyNewsletter',''),(50,'bHideWeddingDate',''),(51,'bHideLatLon',''),(52,'bUseDonationEnvelopes',''),(58,'bUseScannedChecks',''),(65,'sTimeZone','America/Detroit'),(67,'cfgForceUppercaseZip',''),(72,'bEnableNonDeductible',''),(80,'sEnableSelfRegistration','1'),(999,'bRegistered',''),(1003,'sChurchName','Main St. Cathedral'),(1004,'sChurchAddress','123 Main St'),(1005,'sChurchCity','Kansas City'),(1006,'sChurchState','MO'),(1007,'sChurchZip','64106'),(1008,'sChurchPhone','555 123 4234'),(1009,'sChurchEmail','demo@churchcrm.io'),(1010,'sHomeAreaCode','555'),(1014,'sTaxSigner','Elder Joe Smith'),(1016,'sReminderSigner','Elder Joe Smith'),(1025,'sConfirmSigner','Elder Joe Smith'),(1027,'sPledgeSummary2','as of'),(1028,'sDirectoryDisclaimer1','Every effort was made to insure the accuracy of this directory. If there are any errors or omissions, please contact the church office.This directory is for the use of the people of'),(1034,'sChurchChkAcctNum','111111111'),(1035,'sEnableGravatarPhotos','1'),(1036,'sEnableExternalBackupTarget',''),(1037,'sExternalBackupType','WebDAV'),(1046,'sLastIntegrityCheckTimeStamp','2017-04-15 17:17:51'),(1047,'sChurchCountry','United States'),(21,'sDefaultCity','Kansas City'),(22,'sDefaultState','MO');
INSERT INTO `config_cfg` VALUES (23,'sDefaultCountry','United States'),(27,'sSMTPHost','127.0.0.1:1025'),(10,'aFinanceQueries','28,30,31,32'),(28,'bSMTPAuth',''),(48,'bHideFriendDate',''),(49,'bHideFamilyNewsletter',''),(50,'bHideWeddingDate',''),(51,'bHideLatLon',''),(52,'bUseDonationEnvelopes',''),(58,'bUseScannedChecks',''),(65,'sTimeZone','America/Detroit'),(67,'cfgForceUppercaseZip',''),(72,'bEnableNonDeductible',''),(80,'bEnableSelfRegistration','1'),(999,'bRegistered',''),(1003,'sChurchName','Main St. Cathedral'),(1004,'sChurchAddress','123 Main St'),(1005,'sChurchCity','Kansas City'),(1006,'sChurchState','MO'),(1007,'sChurchZip','64106'),(1008,'sChurchPhone','555 123 4234'),(1009,'sChurchEmail','demo@churchcrm.io'),(1010,'sHomeAreaCode','555'),(1014,'sTaxSigner','Elder Joe Smith'),(1016,'sReminderSigner','Elder Joe Smith'),(1025,'sConfirmSigner','Elder Joe Smith'),(1027,'sPledgeSummary2','as of'),(1028,'sDirectoryDisclaimer1','Every effort was made to insure the accuracy of this directory. If there are any errors or omissions, please contact the church office.This directory is for the use of the people of'),(1034,'sChurchChkAcctNum','111111111'),(1035,'bEnableGravatarPhotos','1'),(1036,'bEnableExternalBackupTarget',''),(1037,'sExternalBackupType','WebDAV'),(1046,'sLastIntegrityCheckTimeStamp','2017-04-15 17:17:51'),(1047,'sChurchCountry','United States'),(21,'sDefaultCity','Kansas City'),(22,'sDefaultState','MO');
/*!40000 ALTER TABLE `config_cfg` ENABLE KEYS */;
UNLOCK TABLES;
COMMIT;
Expand Down
2 changes: 1 addition & 1 deletion docs/Installation/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ At the top right of the page select the gear icon ⚙ then select >>Edit General
* Set `sHeader`. You can add a custom header to ChurchCRM by entering the HTML for the custom header.
Example: If you enter ``<H2>My Church</H2>``, ChurchCRM will display "My Church" in large,
bold letters at the top of each page.
* Set `mailChimpApiKey`. MailChimp is a web service that makes it easy to send and track bulk emails. If you do not have an account, create a free one here: http://mailchimp.com/signup. Once you have an account, create an API Key at http://kb.mailchimp.com/accounts/management/about-api-keys and enter that value into this setting.
* Set `sMailChimpApiKey`. MailChimp is a web service that makes it easy to send and track bulk emails. If you do not have an account, create a free one here: http://mailchimp.com/signup. Once you have an account, create an API Key at http://kb.mailchimp.com/accounts/management/about-api-keys and enter that value into this setting.


### Report Settings
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/Administration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ See the [Users](Users.md) help topic.

In General Settings | System Settings, modify the following values:

* **sEnableExternalBackupTarget**
* **bEnableExternalBackupTarget**
If you enable the external backup target, the system will allow you to do automatic and manual backups to a remote location specified below.

* **sExternalBackupType**
Expand Down
2 changes: 1 addition & 1 deletion docs/user-guide/Email.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The recommended method for mass emailing your members is via MailChimp.

- You must first signup and generate an api key via _Mailchimp_ http://kb.mailchimp.com/accounts/management/about-api-keys

- Add Mailchimp API key to `mailChimpApiKey` under _"Edit General Settings"_ accessible in the ⚙ (gear) menu.
- Add Mailchimp API key to `sMailChimpApiKey` under _"Edit General Settings"_ accessible in the ⚙ (gear) menu.

- Enable newsletter under _"Family View"_ for each family that wishes to be part of the Newsletter

Expand Down
3 changes: 1 addition & 2 deletions docs/user-guide/MailChimp.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ MailChimp is an email marketing service, which can be used to send emails to the
## What do i need for use MailChimp
1. Create an Account
2. [Generate an API Key] (http://kb.mailchimp.com/accounts/management/about-api-keys)
3. Add the key to the "General Configuration Settings" page, under "mailChimpApiKey"
3. Add the key to the "General Configuration Settings" page, under "sMailChimpApiKey"





2 changes: 1 addition & 1 deletion locale/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ msgstr ""
msgid ""
"As part of the restore, external backups have been disabled. If you wish to "
"continue automatic backups, you must manuall re-enable the "
"sEnableExternalBackupTarget setting."
"bEnableExternalBackupTarget setting."
msgstr ""

#: ChurchCRM/Service/TimelineService.php:116
Expand Down
7 changes: 3 additions & 4 deletions src/CartView.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@
}
if ($sEmailLink) {
// Add default email if default email has been set and is not already in string
if (SystemConfig::getValue('sToEmailAddress') != '' && SystemConfig::getValue('sToEmailAddress') != 'myReceiveEmailAddress'
&& !stristr($sEmailLink, SystemConfig::getValue('sToEmailAddress'))) {
if (SystemConfig::getValue('sToEmailAddress') != '' && !stristr($sEmailLink, SystemConfig::getValue('sToEmailAddress'))) {
$sEmailLink .= $sMailtoDelimiter.SystemConfig::getValue('sToEmailAddress');
}
$sEmailLink = urlencode($sEmailLink); // Mailto should comply with RFC 2368
Expand Down Expand Up @@ -299,7 +298,7 @@ function codename()
<th><?= gettext('Family Role') ?></th>
</tr>
</thead>

<tbody>
<?php
$sEmailLink = '';
Expand Down Expand Up @@ -342,7 +341,7 @@ function codename()

$personName = $per_FirstName.' '.$per_LastName;
$thumbnail = SystemURLs::getRootPath().'/api/persons/'.$per_ID.'/thumbnail'; ?>

<tr>
<td>
<img data-name="<?= $personName; ?>" data-src="<?= $thumbnail ?>" class="direct-chat-img initials-image">&nbsp
Expand Down
2 changes: 1 addition & 1 deletion src/ChurchCRM/Emails/BaseEmail.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private function setConnection()
$this->mail->CharSet = 'UTF-8';
$this->mail->Timeout = intval(SystemConfig::getValue("iSMTPTimeout"));
$this->mail->Host = SystemConfig::getValue("sSMTPHost");
if (SystemConfig::getBooleanValue("sSMTPAuth")) {
if (SystemConfig::getBooleanValue("bSMTPAuth")) {
$this->mail->SMTPAuth = true;
$this->mail->Username = SystemConfig::getValue("sSMTPUser");
$this->mail->Password = SystemConfig::getValue("sSMTPPass");
Expand Down
4 changes: 2 additions & 2 deletions src/ChurchCRM/Service/MailChimpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ class MailChimpService

public function __construct()
{
if (SystemConfig::getValue('mailChimpApiKey') != '') {
if (!empty(SystemConfig::getValue('sMailChimpApiKey'))) {
$this->isActive = true;
$this->myMailchimp = new \Mailchimp(SystemConfig::getValue('mailChimpApiKey'));
$this->myMailchimp = new \Mailchimp(SystemConfig::getValue('sMailChimpApiKey'));
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/ChurchCRM/Service/SystemService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function restoreDatabaseFromBackup($file)
FileSystemUtils::recursiveRemoveDirectory($restoreResult->backupDir,true);
throw new Exception(gettext("Backup archive does not contain a database").": " . $file['name']);
}

} elseif ($restoreResult->type2 == 'sql') {
$restoreResult->SQLfile = $restoreResult->backupDir . str_replace('.gz', '', $file['name']);
file_put_contents($restoreResult->SQLfile, gzopen($restoreResult->uploadedFileDestination, r));
Expand All @@ -92,8 +92,8 @@ public function restoreDatabaseFromBackup($file)
SQLUtils::sqlImport(SystemURLs::getDocumentRoot() . '/mysql/upgrade/rebuild_nav_menus.sql', $connection);
//When restoring a database, do NOT let the database continue to create remote backups.
//This can be very troublesome for users in a testing environment.
SystemConfig::setValue('sEnableExternalBackupTarget', '0');
array_push($restoreResult->Messages, gettext('As part of the restore, external backups have been disabled. If you wish to continue automatic backups, you must manuall re-enable the sEnableExternalBackupTarget setting.'));
SystemConfig::setValue('bEnableExternalBackupTarget', '0');
array_push($restoreResult->Messages, gettext('As part of the restore, external backups have been disabled. If you wish to continue automatic backups, you must manuall re-enable the bEnableExternalBackupTarget setting.'));
SystemConfig::setValue('sLastIntegrityCheckTimeStamp', null);

return $restoreResult;
Expand Down Expand Up @@ -338,7 +338,7 @@ public function reportIssue($data)
'Reporting Browser |' . $_SERVER['HTTP_USER_AGENT'] . "\r\n".
'Prerequisite Status |' . ( AppIntegrityService::arePrerequisitesMet() ? "All Prerequisites met" : "Missing Prerequisites: " .json_encode(AppIntegrityService::getUnmetPrerequisites()))."\r\n".
'Integrity check status |' . file_get_contents(SystemURLs::getDocumentRoot() . '/integrityCheck.json')."\r\n";

if (function_exists('apache_get_modules')) {
$issueDescription .= 'Apache Modules |' . implode(',', apache_get_modules());
}
Expand All @@ -354,7 +354,7 @@ public function reportIssue($data)
curl_setopt($curlService, CURLOPT_POSTFIELDS, json_encode($postdata));
curl_setopt($curlService, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlService, CURLOPT_CONNECTTIMEOUT, 1);

$result = curl_exec($curlService);
if ($result === false) {
throw new \Exception('Unable to reach the issue bridge', 500);
Expand All @@ -370,7 +370,7 @@ public function runTimerJobs()
NotificationService::updateNotifications();
}
//start the external backup timer job
if (SystemConfig::getValue('sEnableExternalBackupTarget') && SystemConfig::getValue('sExternalBackupAutoInterval') > 0) { //if remote backups are enabled, and the interval is greater than zero
if (SystemConfig::getBooleanValue('bEnableExternalBackupTarget') && SystemConfig::getValue('sExternalBackupAutoInterval') > 0) { //if remote backups are enabled, and the interval is greater than zero
try {
$now = new \DateTime(); //get the current time
$previous = new \DateTime(SystemConfig::getValue('sLastBackupTimeStamp')); // get a DateTime object for the last time a backup was done.
Expand All @@ -384,11 +384,11 @@ public function runTimerJobs()
// an error in the auto-backup shouldn't prevent the page from loading...
}
}
if (SystemConfig::getValue('sEnableIntegrityCheck') && SystemConfig::getValue('sIntegrityCheckInterval') > 0) {
if (SystemConfig::getBooleanValue('bEnableIntegrityCheck') && SystemConfig::getValue('iIntegrityCheckInterval') > 0) {
$now = new \DateTime(); //get the current time
$previous = new \DateTime(SystemConfig::getValue('sLastIntegrityCheckTimeStamp')); // get a DateTime object for the last time a backup was done.
$diff = $previous->diff($now); // calculate the difference.
if (!SystemConfig::getValue('sLastIntegrityCheckTimeStamp') || $diff->h >= SystemConfig::getValue('sIntegrityCheckInterval')) { // if there was no previous backup, or if the interval suggests we do a backup now.
if (!SystemConfig::getValue('sLastIntegrityCheckTimeStamp') || $diff->h >= SystemConfig::getValue('iIntegrityCheckInterval')) { // if there was no previous backup, or if the interval suggests we do a backup now.
$integrityCheckFile = SystemURLs::getDocumentRoot() . '/integrityCheck.json';
$appIntegrity = AppIntegrityService::verifyApplicationIntegrity();
file_put_contents($integrityCheckFile, json_encode($appIntegrity));
Expand Down Expand Up @@ -465,7 +465,7 @@ public function getMaxUploadFileSize($humanFormat=true) {
{
return $this->human_filesize(min($max_upload, $max_post, $memory_limit));
}
else
else
{
return min($max_upload, $max_post, $memory_limit);
}
Expand All @@ -482,7 +482,7 @@ private function parse_size($size) {
return round($size);
}
}

function human_filesize($bytes, $decimals = 2) {
$size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB');
$factor = floor((strlen($bytes) - 1) / 3);
Expand Down
12 changes: 6 additions & 6 deletions src/ChurchCRM/dto/ChurchMetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@ public static function getChurchPhone()

public static function getChurchLatitude()
{
if (empty(SystemConfig::getValue('nChurchLatitude'))) {
if (empty(SystemConfig::getValue('iChurchLatitude'))) {
self::updateLatLng();
}
return SystemConfig::getValue('nChurchLatitude');
return SystemConfig::getValue('iChurchLatitude');
}

public static function getChurchLongitude()
{
if (empty(SystemConfig::getValue('nChurchLongitude'))) {
if (empty(SystemConfig::getValue('iChurchLongitude'))) {
self::updateLatLng();
}
return SystemConfig::getValue('nChurchLongitude');
return SystemConfig::getValue('iChurchLongitude');
}

private static function updateLatLng()
{
if (!empty(self::getChurchFullAddress())) {
$latLng = GeoUtils::getLatLong(self::getChurchFullAddress());
if (!empty($latLng['Latitude']) && !empty($latLng['Longitude'])) {
SystemConfig::setValue('nChurchLatitude', $latLng['Latitude']);
SystemConfig::setValue('nChurchLongitude', $latLng['Longitude']);
SystemConfig::setValue('iChurchLatitude', $latLng['Latitude']);
SystemConfig::setValue('iChurchLongitude', $latLng['Longitude']);
}
}
}
Expand Down
43 changes: 25 additions & 18 deletions src/ChurchCRM/dto/ConfigItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,44 @@

class ConfigItem
{
private $id, $name, $value, $type, $default, $tooltip, $data, $dbConfigItem;
public function __construct($id, $name, $type, $default, $tooltip, $data='') {
private $id, $name, $value, $type, $default, $tooltip, $url, $data, $dbConfigItem;
public function __construct($id, $name, $type, $default, $tooltip='', $url='', $data='') {
$this->id = $id;
$this->name = $name;
$this->type = $type;
$this->default = $default;
$this->default = $default;
$this->tooltip = $tooltip;
$this->data = $data;
$this->url = $url;
}

public function getId()
{
return $this->id;
}

public function getName()
{
return $this->name;
}

public function setDBConfigObject($dbConfigItem)

public function getUrl()
{
return $this->url;
}


public function setDBConfigObject($dbConfigItem)
{
$this->dbConfigItem = $dbConfigItem;
$this->value = $dbConfigItem->getValue();
}

public function getDBConfigObject()
{
return $this->dbConfigItem ;
}

public function getValue()
{
if ( isset( $this->value ) )
Expand All @@ -52,7 +59,7 @@ public function getBooleanValue()
{
return boolval($this->getValue());
}

public function setValue($value)
{
if ( $value == $this->getDefault() )
Expand Down Expand Up @@ -80,36 +87,36 @@ public function setValue($value)
$this->value=$value;
}
}

public function getDefault()
{
return $this->default;
}


public function getType()
{
return $this->type;
}

public function getTooltip()
{
return $this->tooltip;
}

public function getSection()
{
return $this->section;
}

public function getCategory()
{
return $this->category;
}

public function getData()
{
return $this->data;
}

}
}
Loading