Skip to content

Commit

Permalink
Self Registration (#935)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
DawoudIO authored Oct 22, 2016
1 parent 43b1eb3 commit 024c8d5
Show file tree
Hide file tree
Showing 28 changed files with 646 additions and 85 deletions.
54 changes: 54 additions & 0 deletions src/ChurchCRM/dto/SystemConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace ChurchCRM\dto;

use ChurchCRM\Child;
use ChurchCRM\Config;

class SystemConfig
{
/**
* @var Config[]
*/
private $configs;

/**
* @param Config[] $configs
*/
function init($configs)
{
$this->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;
}
}
82 changes: 39 additions & 43 deletions src/FamilyEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

$aFirstNameError = array();
$aBirthDateError = array();
$aperFlags = array();
$aperFlags = array();

//Is this the second pass?
if (isset($_POST["FamilySubmit"]) || isset($_POST["FamilySubmitAndAdd"]))
Expand Down Expand Up @@ -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) . "'";
Expand Down Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -241,7 +241,7 @@
if ((strlen($dWeddingDate) > 0) && ($dWeddingDate != "0000-00-00")) {
$dateString = parseAndValidateDate($dWeddingDate, $locale = "<?= $localeInfo->getCountryCode() ?>", $pasfut = "past");
if ( $dateString === FALSE ) {
$sWeddingDateError = "<span style=\"color: red; \">"
$sWeddingDateError = "<span style=\"color: red; \">"
. gettext("Not a valid Wedding Date") . "</span>";
$bErrorFlag = true;
} else {
Expand All @@ -255,7 +255,7 @@
if (strlen($sEmail) > 0)
{
if ( checkEmail($sEmail) == false ) {
$sEmailError = "<span style=\"color: red; \">"
$sEmailError = "<span style=\"color: red; \">"
. gettext("Email is Not Valid") . "</span>";
$bErrorFlag = true;
} else {
Expand Down Expand Up @@ -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 . "," .
Expand Down Expand Up @@ -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;
Expand All @@ -381,7 +381,7 @@

$sSQL = "INSERT INTO `family_custom` (`fam_ID`) VALUES ('" . $iFamilyID . "')";
RunQuery($sSQL);

// Add property if assigned
if ($iPropertyID)
{
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -484,7 +484,7 @@
$note->setEntered($_SESSION['iUserID']);
$note->save();
}

// Update the custom person fields.
if ($numCustomFields > 0)
{
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -608,7 +608,7 @@
$iClassification = "0";
$iFamilyMemberRows = 6;
$bOkToCanvass = 1;

$iFamilyID = -1;
$sName = "";
$sAddress1 = "";
Expand All @@ -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++)
Expand All @@ -644,7 +644,7 @@
$aPersonIDs[$iCount] = 0;
$aUpdateBirthYear[$iCount] = 0;
}

$aCustomData = array ();
$aCustomErrors = array ();
if ($numCustomFields > 0) {
Expand All @@ -654,7 +654,7 @@
$aCustomData[$fam_custom_Field] = '';
$aCustomErrors[$fam_custom_Field] = false;
}
}
}
}
}

Expand Down Expand Up @@ -1034,8 +1034,8 @@
<input name="BirthYear<?= $iCount ?>" type="text" value="<?= $aBirthYears[$iCount] ?>" size="4" maxlength="4">
<div><font color="red"><?php if (array_key_exists ($iCount, $aBirthDateError)) echo $aBirthDateError[$iCount]; ?></font></div>
<?php }
else
{
else
{
$UpdateBirthYear = 0;
}
?>
Expand Down Expand Up @@ -1063,7 +1063,7 @@
echo "</table>";
echo "</div></div>";
}

echo "<td colspan=\"2\" align=\"center\">";
echo "<input type=\"hidden\" Name=\"UpdateBirthYear\" value=\"".$UpdateBirthYear."\">";

Expand All @@ -1076,10 +1076,6 @@
echo " onclick=\"javascript:document.location='FamilyList.php';\">";
echo "</td></tr></form></table>";
?>
<!-- InputMask -->
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>

<script type="text/javascript">
$(function() {
Expand Down
7 changes: 7 additions & 0 deletions src/Include/Footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
<!-- AdminLTE App -->
<script src="<?= $sRootPath ?>/skin/adminlte/dist/js/app.min.js"></script>

<!-- InputMask -->
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/datepicker/bootstrap-datepicker.js" type="text/javascript"></script>


<script src="<?= $sRootPath ?>/skin/js/DataTables.js"></script>
<script src="<?= $sRootPath ?>/skin/js/Tooltips.js"></script>
<script src="<?= $sRootPath ?>/skin/js/Events.js"></script>
Expand Down
10 changes: 10 additions & 0 deletions src/Include/FooterNotLoggedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
<script src="<?= $sRootPath ?>/skin/adminlte/bootstrap/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/iCheck/icheck.min.js"></script>

<!-- AdminLTE App -->
<script src="<?= $sRootPath ?>/skin/adminlte/dist/js/app.min.js"></script>

<!-- InputMask -->
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.date.extensions.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/input-mask/jquery.inputmask.extensions.js" type="text/javascript"></script>
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/datepicker/bootstrap-datepicker.js" type="text/javascript"></script>

<script>
$(function () {
$('input').iCheck({
Expand Down
2 changes: 2 additions & 0 deletions src/Include/GeoCoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*
******************************************************************************/

require "bin/google-map/GoogleMap.php";

$googleMapObj = new GoogleMapAPI('map');
$googleMapObj->setLookupService('GOOGLE'); // or 'YAHOO'

Expand Down
7 changes: 6 additions & 1 deletion src/Include/HeaderNotLoggedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

<!-- Custom ChurchCRM styles -->
<link rel="stylesheet" href="<?= $sRootPath ?>/skin/churchcrm.min.css">

<!-- Bootstrap 3.3.5 -->
<link rel="stylesheet" href="<?= $sRootPath ?>/skin/adminlte/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
Expand All @@ -21,7 +24,9 @@

<!-- jQuery JS -->
<script src="<?= $sRootPath ?>/skin/adminlte/plugins/jQuery/jQuery-2.2.0.min.js"></script>
<title>ChurchCRM: <?= gettext($sPageTitle) ?></title>

<title>ChurchCRM: <?= $sPageTitle ?></title>

</head>
<body class="hold-transition login-page">

Expand Down
9 changes: 7 additions & 2 deletions src/Include/LoadConfigs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -48,7 +49,7 @@ function mysql_failure($message)
<h3>ChurchCRM – Setup failure</h3>

<div class='alert alert-danger text-center' style='margin-top: 20px;'>
<?= $message ?>
<?= gettext($message) ?>
</div>
</div>
<?php
Expand Down Expand Up @@ -96,6 +97,10 @@ function mysql_failure($message)

// Read values from config table into local variables
// **************************************************

$systemConfig = new SystemConfig();
$systemConfig->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
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 024c8d5

Please sign in to comment.