From 024c8d5f315988e480aa1fa25f0de3a59d25275e Mon Sep 17 00:00:00 2001 From: George Dawoud Date: Sat, 22 Oct 2016 11:15:45 -0700 Subject: [PATCH] Self Registration (#935) * setup for external site. * added missing sRootPath * more framework setup * added user pages * placeholders * fixed spelling * 2.0.0 RC2 * added gettext * family form created * fixed name * added error handling * passing date from family form 1 to form 2 * create a family object and store it in the seesion * Disable Self Registration / Verification by default * get Config by name * check self registration setting before offering the feature * forms are now complete * extra html * removed extra stuff for now * moving to a common file * moving to sub folders * common error handler file * reverted * "revert" * moved to new SystemService namespace * \ * added missing config * fixed path * added "sRootPath" => $_SESSION['sRootPath'] * fixed include path * moving settings.php * added settings * removed getConfig * added ConfigQuery * new button style * cleanner html and text for church = primary and button = next * moving system config to a single class * get all config not just general * renamed to $systemConfig * cleanup - added lastname by default - swtiched bithday to input mask * input-mask is now included by default * input-mask is now in all footers * /plugins/input-mask/ is in all footers * include church crm css * removed unused import * - added hide age - added phone type - added max to all fileds * Fixed Case for Family Phones * added getAddress * Now there is a final confirmation page * renamed family register * cleaner server path for registration * Confirm working * done working * Self Registration in timeline * working save person / family * Birthday and Phone are working now * Set Enterted By as Unknown * moved to ChurchCRM * fixed bath to reports * fresh install has self regestration disabled * cleanner class auto-loading * removed setting title as birthday * removed unset colummns to ensure we don't have a missmatch * added missing zip code * reverted to old way of require google Map is not a valid class * removed unsigned fro EnteredBy for Person and Family to support -1 as self regestration * self reg has EnteredBy = -1 * Note Created By Now works for Self Registration --- src/ChurchCRM/dto/SystemConfig.php | 54 ++++++++ src/FamilyEditor.php | 82 ++++++----- src/Include/Footer.php | 7 + src/Include/FooterNotLoggedIn.php | 10 ++ src/Include/GeoCoder.php | 2 + src/Include/HeaderNotLoggedIn.php | 7 +- src/Include/LoadConfigs.php | 9 +- src/{api => Include/slim}/error-handler.php | 0 src/{api => Include/slim}/settings.php | 0 src/Login.php | 15 +- src/PersonEditor.php | 4 - src/Service/DataSeedService.php | 2 +- src/Service/TimelineService.php | 20 ++- src/api/index.php | 4 +- src/composer.json | 5 +- src/external/.htaccess | 12 ++ src/external/index.php | 23 ++++ src/external/routes/register.php | 113 +++++++++++++++ .../registration/family-register-done.php | 49 +++++++ .../registration/family-register-members.php | 129 ++++++++++++++++++ .../registration/family-register.php | 85 ++++++++++++ src/mysql/install/Install.sql | 7 +- src/mysql/upgrade/2.2.0.sql | 2 +- src/mysql/upgrade/2.3.0.sql | 32 +++-- src/mysql/upgrade/update_config.sql | 1 + src/orm/conf/schema.xml | 12 +- src/orm/model/ChurchCRM/Config.php | 12 ++ src/orm/model/ChurchCRM/Family.php | 33 ++++- 28 files changed, 646 insertions(+), 85 deletions(-) create mode 100644 src/ChurchCRM/dto/SystemConfig.php rename src/{api => Include/slim}/error-handler.php (100%) rename src/{api => Include/slim}/settings.php (100%) create mode 100644 src/external/.htaccess create mode 100644 src/external/index.php create mode 100644 src/external/routes/register.php create mode 100644 src/external/templates/registration/family-register-done.php create mode 100644 src/external/templates/registration/family-register-members.php create mode 100644 src/external/templates/registration/family-register.php diff --git a/src/ChurchCRM/dto/SystemConfig.php b/src/ChurchCRM/dto/SystemConfig.php new file mode 100644 index 0000000000..fcbf9d2de5 --- /dev/null +++ b/src/ChurchCRM/dto/SystemConfig.php @@ -0,0 +1,54 @@ +configs = $configs; + } + + function getValue($name) + { + $config = $this->getRawConfig($name); + if (!is_null($config)) { + return $config->getValue(); + } + return NULL; + } + + function setValue($name, $value) + { + $config = $this->getRawConfig($name); + if (!is_null($config)) { + $config->setValue($value); + } + } + + /** + * @param $name + * @return Config + * + */ + function getRawConfig($name) + { + foreach ($this->configs as $config) { + if ($config->getName() == $name) { + return $config; + } + } + return NULL; + } +} diff --git a/src/FamilyEditor.php b/src/FamilyEditor.php index 4d97bb026a..1a56dd1702 100644 --- a/src/FamilyEditor.php +++ b/src/FamilyEditor.php @@ -87,7 +87,7 @@ $aFirstNameError = array(); $aBirthDateError = array(); -$aperFlags = array(); +$aperFlags = array(); //Is this the second pass? if (isset($_POST["FamilySubmit"]) || isset($_POST["FamilySubmitAndAdd"])) @@ -153,7 +153,7 @@ $nEnvelope = 0; if (array_key_exists ("Envelope", $_POST)) $nEnvelope = FilterInput($_POST["Envelope"], "int"); - + if(is_numeric($nEnvelope)){ // Only integers are allowed as Envelope Numbers if(intval($nEnvelope)==floatval($nEnvelope)) $nEnvelope= "'" . intval($nEnvelope) . "'"; @@ -182,7 +182,7 @@ $bNoFormat_HomePhone = isset($_POST["NoFormat_HomePhone"]); $bNoFormat_WorkPhone = isset($_POST["NoFormat_WorkPhone"]); $bNoFormat_CellPhone = isset($_POST["NoFormat_CellPhone"]); - + //Loop through the Family Member 'quick entry' form fields for ($iCount = 1; $iCount <= $iFamilyMemberRows; $iCount++) { @@ -211,7 +211,7 @@ } // Validate any family member birthdays - if ((strlen($aFirstNames[$iCount]) > 0) && (strlen($aBirthYears[$iCount]) > 0)) + if ((strlen($aFirstNames[$iCount]) > 0) && (strlen($aBirthYears[$iCount]) > 0)) { if (($aBirthYears[$iCount] > 2155) || ($aBirthYears[$iCount] < 1901)) { @@ -241,7 +241,7 @@ if ((strlen($dWeddingDate) > 0) && ($dWeddingDate != "0000-00-00")) { $dateString = parseAndValidateDate($dWeddingDate, $locale = "getCountryCode() ?>", $pasfut = "past"); if ( $dateString === FALSE ) { - $sWeddingDateError = "" + $sWeddingDateError = "" . gettext("Not a valid Wedding Date") . ""; $bErrorFlag = true; } else { @@ -255,7 +255,7 @@ if (strlen($sEmail) > 0) { if ( checkEmail($sEmail) == false ) { - $sEmailError = "" + $sEmailError = "" . gettext("Email is Not Valid") . ""; $bErrorFlag = true; } else { @@ -318,22 +318,22 @@ fam_Latitude, fam_Longitude, fam_Envelope) - VALUES ('" . - $sName . "','" . - $sAddress1 . "','" . - $sAddress2 . "','" . - $sCity . "','" . - $sState . "','" . - $sZip . "','" . - $sCountry . "','" . - $sHomePhone . "','" . - $sWorkPhone . "','" . - $sCellPhone . "','" . - $sEmail . "'," . - $dWeddingDate . ",'" . - date("YmdHis") . "'," . - $_SESSION['iUserID'] . "," . - $bSendNewsLetterString . "," . + VALUES ('" . + $sName . "','" . + $sAddress1 . "','" . + $sAddress2 . "','" . + $sCity . "','" . + $sState . "','" . + $sZip . "','" . + $sCountry . "','" . + $sHomePhone . "','" . + $sWorkPhone . "','" . + $sCellPhone . "','" . + $sEmail . "'," . + $dWeddingDate . ",'" . + date("YmdHis") . "'," . + $_SESSION['iUserID'] . "," . + $bSendNewsLetterString . "," . $bOkToCanvassString . ",'" . $iCanvasser . "'," . $nLatitude . "," . @@ -362,7 +362,7 @@ "fam_EditedBy = " . $_SESSION['iUserID'] . "," . "fam_SendNewsLetter = " . $bSendNewsLetterString; if ($_SESSION['bCanvasser']) - $sSQL .= ", fam_OkToCanvass = " . $bOkToCanvassString . + $sSQL .= ", fam_OkToCanvass = " . $bOkToCanvassString . ", fam_Canvasser = '" . $iCanvasser . "'"; $sSQL .= " WHERE fam_ID = " . $iFamilyID; $bGetKeyBack = false; @@ -381,7 +381,7 @@ $sSQL = "INSERT INTO `family_custom` (`fam_ID`) VALUES ('" . $iFamilyID . "')"; RunQuery($sSQL); - + // Add property if assigned if ($iPropertyID) { @@ -439,7 +439,7 @@ $aBirthYears[$iCount], $aClassification[$iCount])"; RunQuery($sSQL); - $sSQL = "INSERT INTO person_custom (per_ID) VALUES (" + $sSQL = "INSERT INTO person_custom (per_ID) VALUES (" . mysql_insert_id() . ")"; RunQuery($sSQL); RunQuery("UNLOCK TABLES"); @@ -484,7 +484,7 @@ $note->setEntered($_SESSION['iUserID']); $note->save(); } - + // Update the custom person fields. if ($numCustomFields > 0) { @@ -534,7 +534,7 @@ $sSQL = "SELECT * FROM family_fam WHERE fam_ID = " . $iFamilyID; $rsFamily = RunQuery($sSQL); extract(mysql_fetch_array($rsFamily)); - + $iFamilyID = $fam_ID; $sName = $fam_Name; $sAddress1 = $fam_Address1; @@ -562,16 +562,16 @@ $sSQL = "SELECT * FROM family_custom WHERE fam_ID = " . $iFamilyID; $rsCustomData = RunQuery($sSQL); $aCustomData = mysql_fetch_array($rsCustomData, MYSQL_BOTH); - + $aCustomErrors = array(); - + if ($numCustomFields >0) { mysql_data_seek($rsCustomFields,0); while ($rowCustomField = mysql_fetch_array($rsCustomFields, MYSQL_BOTH) ) { $aCustomErrors[$rowCustomField['fam_custom_Field']] = false; } } - + $sSQL = "SELECT * FROM person_per LEFT JOIN family_fam ON per_fam_ID = fam_ID WHERE per_fam_ID =" . $iFamilyID . " ORDER BY per_fmr_ID"; $rsMembers = RunQuery($sSQL); $iCount = 0; @@ -583,8 +583,8 @@ $iFamilyMemberRows++; $aFirstNames[$iCount] = $per_FirstName; $aMiddleNames[$iCount] = $per_MiddleName; - $aLastNames[$iCount] = $per_LastName; - $aSuffix[$iCount] = $per_Suffix; + $aLastNames[$iCount] = $per_LastName; + $aSuffix[$iCount] = $per_Suffix; $aGenders[$iCount] = $per_Gender; $aRoles[$iCount] = $per_fmr_ID; $aBirthMonths[$iCount] = $per_BirthMonth; @@ -608,7 +608,7 @@ $iClassification = "0"; $iFamilyMemberRows = 6; $bOkToCanvass = 1; - + $iFamilyID = -1; $sName = ""; $sAddress1 = ""; @@ -625,7 +625,7 @@ $iCanvasser = -1; $dWeddingDate = ""; $nLatitude = 0.0; - $nLongitude = 0.0; + $nLongitude = 0.0; //Loop through the Family Member 'quick entry' form fields for ($iCount = 1; $iCount <= $iFamilyMemberRows; $iCount++) @@ -644,7 +644,7 @@ $aPersonIDs[$iCount] = 0; $aUpdateBirthYear[$iCount] = 0; } - + $aCustomData = array (); $aCustomErrors = array (); if ($numCustomFields > 0) { @@ -654,7 +654,7 @@ $aCustomData[$fam_custom_Field] = ''; $aCustomErrors[$fam_custom_Field] = false; } - } + } } } @@ -1034,8 +1034,8 @@
@@ -1063,7 +1063,7 @@ echo ""; echo ""; } - + echo ""; echo ""; @@ -1076,10 +1076,6 @@ echo " onclick=\"javascript:document.location='FamilyList.php';\">"; echo ""; ?> - - - - + + + + + + + diff --git a/src/Include/FooterNotLoggedIn.php b/src/Include/FooterNotLoggedIn.php index 5ea0c6da9d..1c776ef3fb 100644 --- a/src/Include/FooterNotLoggedIn.php +++ b/src/Include/FooterNotLoggedIn.php @@ -2,6 +2,16 @@ + + + + + + + + + + - ChurchCRM: <?= gettext($sPageTitle) ?> + + ChurchCRM: <?= $sPageTitle ?> + diff --git a/src/Include/LoadConfigs.php b/src/Include/LoadConfigs.php index ee59f966e3..6e220d5201 100644 --- a/src/Include/LoadConfigs.php +++ b/src/Include/LoadConfigs.php @@ -36,9 +36,10 @@ use ChurchCRM\Service\SystemService; use ChurchCRM\Version; +use ChurchCRM\ConfigQuery; +use ChurchCRM\dto\SystemConfig; use ChurchCRM\dto\LocaleInfo; - if (!function_exists("mysql_failure")) { function mysql_failure($message) { @@ -48,7 +49,7 @@ function mysql_failure($message)

ChurchCRM – Setup failure

- +
init(ConfigQuery::create()->find()); + $sSQL = "SELECT cfg_name, IFNULL(cfg_value, cfg_default) AS value " . "FROM config_cfg WHERE cfg_section='General'"; $rsConfig = mysql_query($sSQL); // Can't use RunQuery -- not defined yet diff --git a/src/api/error-handler.php b/src/Include/slim/error-handler.php similarity index 100% rename from src/api/error-handler.php rename to src/Include/slim/error-handler.php diff --git a/src/api/settings.php b/src/Include/slim/settings.php similarity index 100% rename from src/api/settings.php rename to src/Include/slim/settings.php diff --git a/src/Login.php b/src/Login.php index 0f77f523b9..950555b709 100644 --- a/src/Login.php +++ b/src/Login.php @@ -34,8 +34,11 @@ require 'Include/Functions.php'; // Initialize the variables +use ChurchCRM\Service\SystemService; use ChurchCRM\UserQuery; +$systemService = new SystemService(); + // Is the user requesting to logoff or timed out? if (isset($_GET["Logoff"]) || isset($_GET['Timeout'])) { if (!isset($_SESSION['sshowPledges']) || ($_SESSION['sshowPledges'] == '')) @@ -258,6 +261,7 @@ // Search preference $_SESSION['bSearchFamily'] = $currentUser->getSearchfamily(); + $_SESSION['latestVersion'] = $systemService->getLatestRelese(); Redirect('CheckVersion.php'); exit; } @@ -266,6 +270,8 @@ // Turn ON output buffering ob_start(); +$enableSelfReg = $systemConfig->getRawConfig("sEnableSelfRegistration")->getBooleanValue(); + // Set the page title and include HTML header $sPageTitle = gettext("ChurchCRM - Login"); require ("Include/HeaderNotLoggedIn.php"); @@ -309,7 +315,7 @@
- +
@@ -320,8 +326,11 @@ // An array of authorized URL's is specified in Config.php in the $URL array checkAllowedURL(); ?> - + + +
+ + diff --git a/src/PersonEditor.php b/src/PersonEditor.php index a4953220d0..f7e7323487 100644 --- a/src/PersonEditor.php +++ b/src/PersonEditor.php @@ -1065,10 +1065,6 @@ class="form-control"> echo "SelectList.php?mode=person"; } ?>';"> - - - - + + +
+ + +
+ + +
+
+ " required> + +
+
+ " required> + +
+
+
+
+ " required> +
+
+ " required> +
+
+
+
+
+
+ " required> +
+
+ " required> +
+
+
+
+ "> + +
+
+ + +
+
+
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ + - @@ -114,15 +114,15 @@ - - - + + + - @@ -180,7 +180,7 @@ - diff --git a/src/orm/model/ChurchCRM/Config.php b/src/orm/model/ChurchCRM/Config.php index d3a6166403..23e8000aea 100644 --- a/src/orm/model/ChurchCRM/Config.php +++ b/src/orm/model/ChurchCRM/Config.php @@ -16,5 +16,17 @@ */ class Config extends BaseConfig { + function getBooleanValue() + { + return boolval($this->getValue()); + } + + function getValue() + { + if (is_null($this->cfg_value)) { + return $this->cfg_default; + } + return $this->cfg_value; + } } diff --git a/src/orm/model/ChurchCRM/Family.php b/src/orm/model/ChurchCRM/Family.php index 6e62ddabb0..77fba277db 100644 --- a/src/orm/model/ChurchCRM/Family.php +++ b/src/orm/model/ChurchCRM/Family.php @@ -2,8 +2,8 @@ namespace ChurchCRM; -use Propel\Runtime\Connection\ConnectionInterface; use ChurchCRM\Base\Family as BaseFamily; +use Propel\Runtime\Connection\ConnectionInterface; /** * Skeleton subclass for representing a row from the 'family_fam' table. @@ -18,6 +18,36 @@ class Family extends BaseFamily { + function getAddress() + { + + $address = array(); + if (!empty($this->getAddress1())) { + $tmp = $this->getAddress1(); + if (!empty($this->getAddress2())) { + $tmp = $tmp . " " . $this->getAddress2(); + } + array_push($address, $tmp); + } + + if (!empty($this->getCity())) { + array_push($address, $this->getCity() . ","); + } + + if (!empty($this->getState())) { + array_push($address, $this->getState()); + } + + if (!empty($this->getZip())) { + array_push($address, $this->getZip()); + } + if (!empty($this->getCountry())) { + array_push($address, $this->getCountry()); + } + + return implode(" ", $address); + } + public function postInsert(ConnectionInterface $con = null) { $this->createTimeLineNote(true); @@ -47,4 +77,5 @@ private function createTimeLineNote($new) $note->save(); } + }