From 4631d6c1dd47968f7733f54ed84a65f85ccb4b6b Mon Sep 17 00:00:00 2001 From: Morgan Lesko <15270653+rockhopsoft@users.noreply.github.com> Date: Sat, 30 Jan 2021 09:25:21 -0500 Subject: [PATCH] Prepped for Extension Package --- README.md | 12 +- src/Controllers/DepartmentScores.php | 2 +- src/Controllers/OpenAjax.php | 22 ++- src/Controllers/OpenAjaxCachePrep.php | 2 +- src/Controllers/OpenComplaintConditions.php | 24 ++- src/Controllers/OpenComplaintEmails.php | 2 +- src/Controllers/OpenComplaintPrints.php | 2 +- src/Controllers/OpenComplaintSaves.php | 25 ++- src/Controllers/OpenDashAdmin.php | 2 +- src/Controllers/OpenDeptStats.php | 2 +- src/Controllers/OpenDepts.php | 2 +- src/Controllers/OpenDevelopment.php | 2 +- src/Controllers/OpenInitExtras.php | 111 ++++++++++- src/Controllers/OpenListFilters.php | 2 +- src/Controllers/OpenListing.php | 2 +- src/Controllers/OpenOfficers.php | 2 +- src/Controllers/OpenPartners.php | 2 +- src/Controllers/OpenPolice.php | 187 ++++++++---------- src/Controllers/OpenPoliceAdmin.php | 2 +- src/Controllers/OpenPoliceAdminMenu.php | 2 +- src/Controllers/OpenPoliceAllegations.php | 2 +- src/Controllers/OpenPoliceEvents.php | 2 +- src/Controllers/OpenPoliceGlobals.php | 2 +- src/Controllers/OpenPolicePCIF.php | 2 +- src/Controllers/OpenPolicePeople.php | 2 +- src/Controllers/OpenPoliceSearcher.php | 2 +- src/Controllers/OpenPoliceUserLoad.php | 2 +- src/Controllers/OpenPoliceUtils.php | 2 +- src/Controllers/OpenPoliceVars.php | 2 +- src/Controllers/OpenReport.php | 2 +- src/Controllers/OpenReportTools.php | 2 +- src/Controllers/OpenReportToolsAdmin.php | 2 +- src/Controllers/OpenReportToolsOversight.php | 2 +- src/Controllers/OpenSessDataOverride.php | 24 ++- src/Controllers/OpenVolunteers.php | 2 +- src/Controllers/VolunteerLeaderboard.php | 2 +- ..._01_28_000000_create_openpolice_tables.php | 2 - src/OpenPoliceFacade.php | 6 +- src/OpenPoliceServiceProvider.php | 9 + 39 files changed, 330 insertions(+), 150 deletions(-) diff --git a/README.md b/README.md index a3b023b..85a8e47 100755 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ Among other methods, the resulting data can also be provided as XML included an ``` -Edit the environment file to connect the default MYSQL database: +Edit these lines of the environment file to connect the default MYSQL database: ``` % nano .env ``` @@ -128,7 +128,9 @@ If installing on a server, you might also need to fix some permissions before th Clear caches and publish the package migrations... ``` -% php artisan optimize:clear +% php artisan config:cache +% php artisan route:cache +% php artisan view:cache % echo "0" | php artisan vendor:publish --force % composer dump-autoload % curl http://myopenpolice.local/css-reload @@ -158,13 +160,13 @@ $ php artisan db:seed --class=ZipCodeSeeder4 ### Initialize OpenPolice Installation Then browsing to the home page should prompt you to create the first admin user account:
-http://openpolice.local +http://myopenpolice.local If everything looks janky, then manually load the style sheets, etc:
-http://openpolice.local/css-reload +http://myopenpolice.local/css-reload After logging in as an admin, this link rebuilds many supporting files:
-http://openpolice.local/dashboard/settings?refresh=2 +http://myopenpolice.local/dashboard/settings?refresh=2 # Documentation diff --git a/src/Controllers/DepartmentScores.php b/src/Controllers/DepartmentScores.php index 47f4b78..6782ea3 100644 --- a/src/Controllers/DepartmentScores.php +++ b/src/Controllers/DepartmentScores.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.7 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenAjax.php b/src/Controllers/OpenAjax.php index ac0f153..5c14fd7 100644 --- a/src/Controllers/OpenAjax.php +++ b/src/Controllers/OpenAjax.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; @@ -25,6 +25,8 @@ class OpenAjax extends OpenAjaxCachePrep /** * Check for ajax requests customized beyond * Survloop's default behavior, called via /ajax/{type}. + * This overrides the ajaxChecks function in + * RockHopSoft\Survloop\Controllers\Tree\TreeSurv. * * @param Illuminate\Http\Request $request * @param string $type @@ -32,6 +34,10 @@ class OpenAjax extends OpenAjaxCachePrep */ public function ajaxChecksCustom(Request $request, $type = '') { + $extension = $this->extensionAjaxChecks($request, $type); + if (trim($extension) != '') { + return $extension; + } if ($type == 'dept-kml-desc') { return $this->ajaxDeptKmlDesc($request); } elseif ($type == 'save-default-state') { @@ -53,6 +59,20 @@ public function ajaxChecksCustom(Request $request, $type = '') return ''; } + /** + * Check for ajax requests customized beyond + * Survloop's default behavior, called via /ajax/{type}. + * e.g. flexyourrights/openpolice-extension + * + * @param Illuminate\Http\Request $request + * @param string $type + * @return boolean + */ + protected function extensionAjaxChecks(Request $request, $type = '') + { + return ''; + } + /** * Print home page complaints previews. * diff --git a/src/Controllers/OpenAjaxCachePrep.php b/src/Controllers/OpenAjaxCachePrep.php index 2698593..ec07c99 100644 --- a/src/Controllers/OpenAjaxCachePrep.php +++ b/src/Controllers/OpenAjaxCachePrep.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenComplaintConditions.php b/src/Controllers/OpenComplaintConditions.php index df2f539..a4febe2 100644 --- a/src/Controllers/OpenComplaintConditions.php +++ b/src/Controllers/OpenComplaintConditions.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.15 */ namespace FlexYourRights\OpenPolice\Controllers; @@ -22,6 +22,9 @@ class OpenComplaintConditions extends OpenSessDataOverride /** * Delegate the conditional checks which are customized from * the simpler default Survloop existing thus far. + * This overrides the parseConditions function in + * RockHopSoft\Survloop\Controllers\Tree\TreeSurvConds. + * Return 0 or 1 (instead of -1) to override. * * @param int $nID * @param string $condition @@ -29,6 +32,10 @@ class OpenComplaintConditions extends OpenSessDataOverride */ protected function checkNodeConditionsCustom($nID, $condition = '') { + $extension = $this->extensionCheckNodeConditions($nID, $condition); + if (in_array($extension, [0, 1])) { + return $extension; + } $complaint = null; if (isset($this->sessData->dataSets["complaints"]) && isset($this->sessData->dataSets["complaints"][0]) @@ -155,6 +162,21 @@ protected function checkNodeConditionsCustom($nID, $condition = '') } return -1; } + + /** + * Delegate the conditional checks which are customized from + * the simpler default OpenPolice.org & Survloop existing thus far. + * Return 0 or 1 (instead of -1) to override. + * e.g. flexyourrights/openpolice-extension + * + * @param int $nID + * @param string $condition + * @return int + */ + protected function extensionCheckNodeConditions($nID, $condition = '') + { + return -1; + } /** * Checks whether or not this incident began diff --git a/src/Controllers/OpenComplaintEmails.php b/src/Controllers/OpenComplaintEmails.php index 238f0dd..8c03de9 100644 --- a/src/Controllers/OpenComplaintEmails.php +++ b/src/Controllers/OpenComplaintEmails.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenComplaintPrints.php b/src/Controllers/OpenComplaintPrints.php index 5c81e9e..eea179c 100644 --- a/src/Controllers/OpenComplaintPrints.php +++ b/src/Controllers/OpenComplaintPrints.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenComplaintSaves.php b/src/Controllers/OpenComplaintSaves.php index 1c198bb..6d72494 100644 --- a/src/Controllers/OpenComplaintSaves.php +++ b/src/Controllers/OpenComplaintSaves.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; @@ -26,14 +26,18 @@ class OpenComplaintSaves extends OpenComplaintConditions /** * Override default behavior for submitting survey forms, * delegateing specifc saving procedures for custom nodes. + * This overrides the postNodePublic function in + * RockHopSoft\Survloop\Controllers\Tree\TreeSurvInput. * - * @param int $nID - * @param string $nIDtxt - * @param array $tmpSubTier + * @param TreeNodeSurv $curr * @return boolean */ protected function postNodePublicCustom(&$curr) { + $extension = $this->extensionPostNodePublic($curr); + if ($extension !== false) { + return $extension; + } $nID = $curr->nID; if (empty($tmpSubTier)) { $tmpSubTier = $this->loadNodeSubTier($nID); @@ -89,6 +93,19 @@ protected function postNodePublicCustom(&$curr) } return false; // false to continue standard post processing } + + /** + * Override default behavior for submitting survey forms, + * delegateing specifc saving procedures for custom nodes. + * e.g. flexyourrights/openpolice-extension + * + * @param TreeNodeSurv $curr + * @return boolean + */ + protected function extensionPostNodePublic(&$curr) + { + return false; // false to continue standard post processing + } /** * Store the start date — and optionally start time — of the incident. diff --git a/src/Controllers/OpenDashAdmin.php b/src/Controllers/OpenDashAdmin.php index 4c47736..ac8dd8c 100644 --- a/src/Controllers/OpenDashAdmin.php +++ b/src/Controllers/OpenDashAdmin.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenDeptStats.php b/src/Controllers/OpenDeptStats.php index 0efafd3..0a918d2 100644 --- a/src/Controllers/OpenDeptStats.php +++ b/src/Controllers/OpenDeptStats.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.18 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenDepts.php b/src/Controllers/OpenDepts.php index dcb844d..a0efa66 100644 --- a/src/Controllers/OpenDepts.php +++ b/src/Controllers/OpenDepts.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenDevelopment.php b/src/Controllers/OpenDevelopment.php index 9a8e146..9c177b7 100644 --- a/src/Controllers/OpenDevelopment.php +++ b/src/Controllers/OpenDevelopment.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.1 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenInitExtras.php b/src/Controllers/OpenInitExtras.php index 91f75a0..cb867cd 100644 --- a/src/Controllers/OpenInitExtras.php +++ b/src/Controllers/OpenInitExtras.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.15 */ namespace FlexYourRights\OpenPolice\Controllers; @@ -22,6 +22,7 @@ use App\Models\OPPersonContact; use App\Models\OPTesterBeta; use App\Models\OPzVolunUserInfo; +use FlexYourRights\OpenPolice\Controllers\OpenDashAdmin; use FlexYourRights\OpenPolice\Controllers\OpenPartners; class OpenInitExtras extends OpenPartners @@ -449,6 +450,86 @@ protected function loadExtra() return true; } + /** + * Look up the person contact record and physical description record + * for a civilian or officer. + * + * @return boolean + */ + protected function chkPersonRecs() + { + // This should've been automated via the data table subset option + // but for now, I'm replacing that complication with this check... + $found = false; + $types = [ + ['civilians', 'civ'], + ['officers', 'off'] + ]; + foreach ($types as $type) { + if (isset($this->sessData->dataSets[$type[0]]) + && sizeof($this->sessData->dataSets[$type[0]]) > 0) { + foreach ($this->sessData->dataSets[$type[0]] as $i => $civ) { + if (!isset($civ->{ $type[1] . '_person_id' }) + || intVal($civ->{ $type[1] . '_person_id' }) <= 0) { + $new = new OPPersonContact; + $new->save(); + $this->sessData->dataSets[$type[0]][$i]->update([ + $type[1] . '_person_id' => $new->getKey() + ]); + $found = true; + } + if (!isset($civ->{ $type[1] . '_phys_desc_id' }) + || intVal($civ->{ $type[1] . '_phys_desc_id' }) <= 0) { + $new = new OPPhysicalDesc; + $new->save(); + $this->sessData->dataSets[$type[0]][$i]->update([ + $type[1] . '_phys_desc_id' => $new->getKey() + ]); + $found = true; + } + } + } + } + if ($found) { + $this->sessData->refreshDataSets(); + } + // // // // + return true; + } + + /** + * Look up the record linking fields which should be skipped + * when auto-creating a new loop item's database record. + * + * @return array + */ + protected function newLoopItemSkipLinks($tbl = '') + { + // Until this can be auto-inferred for + // outgoing linkages to data subsets + if ($tbl == 'civilians') { + return [ 'civ_person_id', 'civ_phys_desc_id' ]; + } elseif ($tbl == 'officers') { + return [ 'off_person_id', 'off_phys_desc_id' ]; + } + return []; + } + + /** + * Double-check behavior after a new item has been created for a data loop. + * + * @param string $tbl + * @param int $itemID + * @return boolean + */ + protected function afterCreateNewDataLoopItem($tbl = '', $itemID = -3) + { + if (in_array($tbl, ['civilians', 'officers']) && $itemID > 0) { + $this->chkPersonRecs(); + } + return true; + } + /** * Run any validation and cleanup needed specific to OP.org * @@ -677,6 +758,32 @@ protected function loadSessionClear($coreTbl = '', $coreID = -3) { $this->allegations = []; return true; - } + } + + /** + * Print warning message for uploading tool. + * + * @param int $nID + * @return string + */ + protected function uploadWarning($nID) + { + return 'WARNING: If documents show sensitive personal information, set this to "private." + This includes addresses, phone numbers, emails, or social security numbers.'; + } + + /** + * Initializes the admin dashboard side-class. + * + * @return boolean + */ + protected function initAdmDash() + { + $this->v["isDash"] = true; + if (!isset($this->v["openDash"])) { + $this->v["openDash"] = new OpenDashAdmin; + } + return true; + } } \ No newline at end of file diff --git a/src/Controllers/OpenListFilters.php b/src/Controllers/OpenListFilters.php index c59431d..4582d2b 100644 --- a/src/Controllers/OpenListFilters.php +++ b/src/Controllers/OpenListFilters.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.18 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenListing.php b/src/Controllers/OpenListing.php index e308d4e..e462979 100644 --- a/src/Controllers/OpenListing.php +++ b/src/Controllers/OpenListing.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenOfficers.php b/src/Controllers/OpenOfficers.php index 480b86a..924ad5d 100644 --- a/src/Controllers/OpenOfficers.php +++ b/src/Controllers/OpenOfficers.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.5 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPartners.php b/src/Controllers/OpenPartners.php index c311af8..d7d06e8 100644 --- a/src/Controllers/OpenPartners.php +++ b/src/Controllers/OpenPartners.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPolice.php b/src/Controllers/OpenPolice.php index 3fedd98..b560215 100755 --- a/src/Controllers/OpenPolice.php +++ b/src/Controllers/OpenPolice.php @@ -1,11 +1,14 @@ + * @author Morgan Lesko * @since v0.0.1 */ namespace FlexYourRights\OpenPolice\Controllers; @@ -15,7 +18,6 @@ use Illuminate\Http\Request; use App\Models\OPPersonContact; use App\Models\OPPhysicalDesc; -use FlexYourRights\OpenPolice\Controllers\OpenDashAdmin; use FlexYourRights\OpenPolice\Controllers\OpenInitExtras; class OpenPolice extends OpenInitExtras @@ -24,12 +26,18 @@ class OpenPolice extends OpenInitExtras * Overrides primary Survloop printing of individual nodes from * surveys and site pages. This is one of the main routing hubs * for OpenPolice.org customizations beyond Survloop defaults. + * This overrides the printNodePublicDefault function in + * RockHopSoft\Survloop\Tree\TreeSurvForm. * * @param TreeNodeSurv $curr * @return string */ protected function customNodePrint(&$curr = null) { + $ret = $this->extensionNodePrint($curr); + if (trim($ret) != '') { + return $ret; + } $nID = $curr->nID; // Main Complaint Survey if (in_array($nID, [145, 920])) { @@ -391,28 +399,71 @@ protected function customNodePrint(&$curr = null) } /** - * Overrides default Survloop behavior for responses to multiple-choice questions. + * Overrides primary OpenPolice.org printing of individual nodes from + * surveys and site pages. This is one of the main routing hubs + * for OpenPoliceExtension customizations beyond Survloop defaults. + * e.g. flexyourrights/openpolice-extension + * + * @param TreeNodeSurv $curr + * @return string + */ + protected function extensionNodePrint(&$curr = null) + { + return ''; + } + + /** + * Overrides default Survloop behavior for responses + * to multiple-choice questions. + * This overrides the printNodePublicElements function in + * RockHopSoft\Survloop\Tree\TreeSurvForm. * - * @param int $nID * @param SLNode &$curr * @return SLNode */ - protected function customResponses($nID, &$curr) + protected function customResponses(&$curr) { + $extension = $this->extensionResponses($curr); + if ($extension !== null) { + $curr = $extension; + } else { + // custom OpenPolice.org behavior + } return $curr; } + /** + * Overrides default OpenPolice.org & Survloop behavior + * for responses to multiple-choice questions. + * Return $curr (instead of null) to override. + * e.g. flexyourrights/openpolice-extension + * + * @param SLNode &$curr + * @return SLNode + */ + protected function extensionResponses(&$curr) + { + return null; + } + /** * Overrides primary Survloop printing of individual nodes from * surveys and site pages. This is one of the main routing hubs * for OpenPolice.org customizations beyond Survloop defaults. + * Return null to leave defaults alone. Otherwise, return + * report detail array used by nodePrintVertProgress + * in RockHopSoft\Survloop\Tree\TreeSurvDataPrint. * * @param TreeNodeSurv $curr * @param string $var - * @return string + * @return array */ protected function customNodePrintVertProgress(&$curr = null, $val = null) { + $extension = $this->extensionNodePrintVertProgress($curr, $val); + if ($extension !== null) { + return $extension; + } if (in_array($curr->nID, [1700, 1697, 1698, 1699, 3176])) { return $this->printReportNoResponseTime($curr, $val); } @@ -420,28 +471,38 @@ protected function customNodePrintVertProgress(&$curr = null, $val = null) } /** - * Initializes the admin dashboard side-class. + * Overrides OpenPolice.org & Survloop printing of individual nodes from + * surveys and site pages. This is one of the main routing hubs + * for OpenPolice.org customizations beyond Survloop defaults. + * Return null to leave defaults alone. Otherwise, return + * report detail array used by nodePrintVertProgress + * e.g. flexyourrights/openpolice-extension * - * @return boolean + * @param TreeNodeSurv $curr + * @param string $var + * @return array */ - protected function initAdmDash() + protected function extensionNodePrintVertProgress(&$curr = null, $val = null) { - $this->v["isDash"] = true; - if (!isset($this->v["openDash"])) { - $this->v["openDash"] = new OpenDashAdmin; - } - return true; + return null; } /** - * Overrides or disables the default printing of survey Back/Next buttons. + * Overrides or disables the default Survloop printing + * of survey Back/Next buttons. + * This overrides the nodePrintButton function in + * RockHopSoft\Survloop\Tree\TreeSurvFormUtils. * * @param int $nID * @param string $promptNotes * @return string */ protected function customNodePrintButton($nID = -3, $promptNotes = '') - { + { + $extension = $this->extensionNodePrintButton($nID, $promptNotes); + if (trim($extension) != '') { + return $extension; + } if (in_array($nID, [270, 973])) { return ''; } @@ -449,95 +510,17 @@ protected function customNodePrintButton($nID = -3, $promptNotes = '') } /** - * Look up the person contact record and physical description record - * for a civilian or officer. - * - * @return boolean - */ - protected function chkPersonRecs() - { - // This should've been automated via the data table subset option - // but for now, I'm replacing that complication with this check... - $found = false; - $types = [ - ['civilians', 'civ'], - ['officers', 'off'] - ]; - foreach ($types as $type) { - if (isset($this->sessData->dataSets[$type[0]]) - && sizeof($this->sessData->dataSets[$type[0]]) > 0) { - foreach ($this->sessData->dataSets[$type[0]] as $i => $civ) { - if (!isset($civ->{ $type[1] . '_person_id' }) - || intVal($civ->{ $type[1] . '_person_id' }) <= 0) { - $new = new OPPersonContact; - $new->save(); - $this->sessData->dataSets[$type[0]][$i]->update([ - $type[1] . '_person_id' => $new->getKey() - ]); - $found = true; - } - if (!isset($civ->{ $type[1] . '_phys_desc_id' }) - || intVal($civ->{ $type[1] . '_phys_desc_id' }) <= 0) { - $new = new OPPhysicalDesc; - $new->save(); - $this->sessData->dataSets[$type[0]][$i]->update([ - $type[1] . '_phys_desc_id' => $new->getKey() - ]); - $found = true; - } - } - } - } - if ($found) { - $this->sessData->refreshDataSets(); - } - // // // // - return true; - } - - /** - * Look up the record linking fields which should be skipped - * when auto-creating a new loop item's database record. - * - * @return array - */ - protected function newLoopItemSkipLinks($tbl = '') - { - // Until this can be auto-inferred for - // outgoing linkages to data subsets - if ($tbl == 'civilians') { - return [ 'civ_person_id', 'civ_phys_desc_id' ]; - } elseif ($tbl == 'officers') { - return [ 'off_person_id', 'off_phys_desc_id' ]; - } - return []; - } - - /** - * Double-check behavior after a new item has been created for a data loop. - * - * @param string $tbl - * @param int $itemID - * @return boolean - */ - protected function afterCreateNewDataLoopItem($tbl = '', $itemID = -3) - { - if (in_array($tbl, ['civilians', 'officers']) && $itemID > 0) { - $this->chkPersonRecs(); - } - return true; - } - - /** - * Print warning message for uploading tool. + * Overrides or disables the default Survloop & OpenPolice.org + * printing of survey Back/Next buttons. + * e.g. flexyourrights/openpolice-extension * * @param int $nID + * @param string $promptNotes * @return string */ - protected function uploadWarning($nID) + protected function extensionNodePrintButton($nID = -3, $promptNotes = '') { - return 'WARNING: If documents show sensitive personal information, set this to "private." - This includes addresses, phone numbers, emails, or social security numbers.'; + return ''; } } \ No newline at end of file diff --git a/src/Controllers/OpenPoliceAdmin.php b/src/Controllers/OpenPoliceAdmin.php index e2a0de6..df6608b 100755 --- a/src/Controllers/OpenPoliceAdmin.php +++ b/src/Controllers/OpenPoliceAdmin.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.1 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceAdminMenu.php b/src/Controllers/OpenPoliceAdminMenu.php index f920424..227af1d 100644 --- a/src/Controllers/OpenPoliceAdminMenu.php +++ b/src/Controllers/OpenPoliceAdminMenu.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.1 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceAllegations.php b/src/Controllers/OpenPoliceAllegations.php index 44370d2..d02aa4d 100644 --- a/src/Controllers/OpenPoliceAllegations.php +++ b/src/Controllers/OpenPoliceAllegations.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.5 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceEvents.php b/src/Controllers/OpenPoliceEvents.php index b275ce6..b1ec40b 100644 --- a/src/Controllers/OpenPoliceEvents.php +++ b/src/Controllers/OpenPoliceEvents.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.5 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceGlobals.php b/src/Controllers/OpenPoliceGlobals.php index 12352c5..cca3766 100644 --- a/src/Controllers/OpenPoliceGlobals.php +++ b/src/Controllers/OpenPoliceGlobals.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.19 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPolicePCIF.php b/src/Controllers/OpenPolicePCIF.php index d7c864a..08eeb94 100644 --- a/src/Controllers/OpenPolicePCIF.php +++ b/src/Controllers/OpenPolicePCIF.php @@ -6,7 +6,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.17 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPolicePeople.php b/src/Controllers/OpenPolicePeople.php index 84c6ba7..f173f2b 100644 --- a/src/Controllers/OpenPolicePeople.php +++ b/src/Controllers/OpenPolicePeople.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.5 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceSearcher.php b/src/Controllers/OpenPoliceSearcher.php index 172d191..805d5a8 100644 --- a/src/Controllers/OpenPoliceSearcher.php +++ b/src/Controllers/OpenPoliceSearcher.php @@ -4,7 +4,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceUserLoad.php b/src/Controllers/OpenPoliceUserLoad.php index dc66207..e3d087e 100644 --- a/src/Controllers/OpenPoliceUserLoad.php +++ b/src/Controllers/OpenPoliceUserLoad.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.29 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceUtils.php b/src/Controllers/OpenPoliceUtils.php index ee625d0..b5164e2 100644 --- a/src/Controllers/OpenPoliceUtils.php +++ b/src/Controllers/OpenPoliceUtils.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenPoliceVars.php b/src/Controllers/OpenPoliceVars.php index 91f873d..44cc216 100644 --- a/src/Controllers/OpenPoliceVars.php +++ b/src/Controllers/OpenPoliceVars.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.25 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenReport.php b/src/Controllers/OpenReport.php index 8668cc1..3f7394b 100644 --- a/src/Controllers/OpenReport.php +++ b/src/Controllers/OpenReport.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenReportTools.php b/src/Controllers/OpenReportTools.php index 7508613..14240c8 100644 --- a/src/Controllers/OpenReportTools.php +++ b/src/Controllers/OpenReportTools.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenReportToolsAdmin.php b/src/Controllers/OpenReportToolsAdmin.php index fdc5708..1b48ec8 100644 --- a/src/Controllers/OpenReportToolsAdmin.php +++ b/src/Controllers/OpenReportToolsAdmin.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.4 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenReportToolsOversight.php b/src/Controllers/OpenReportToolsOversight.php index 2b56f23..f72430d 100644 --- a/src/Controllers/OpenReportToolsOversight.php +++ b/src/Controllers/OpenReportToolsOversight.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.2.4 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/OpenSessDataOverride.php b/src/Controllers/OpenSessDataOverride.php index 18ac8d5..1ba6712 100644 --- a/src/Controllers/OpenSessDataOverride.php +++ b/src/Controllers/OpenSessDataOverride.php @@ -6,7 +6,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.15 */ namespace FlexYourRights\OpenPolice\Controllers; @@ -21,12 +21,18 @@ class OpenSessDataOverride extends OpenComplaintPrints * Delegate the custom overrides for Survloop default * methods to retrieve current session data required * by the current node. + * This overrides the printNodePublicCurrData function in + * RockHopSoft\Survloop\Controllers\Tree\TreeSurvFormPrintLoad. * * @param TreeNodeSurv $curr * @return array */ protected function printNodeSessDataOverride(&$curr) { + $extension = $this->extensionPrintNodeSessData($curr); + if (sizeof($extension) > 0) { + return $extension; + } if (empty($this->sessData->dataSets)) { return []; } @@ -157,6 +163,22 @@ protected function printNodeSessDataOverride(&$curr) return []; } + /** + * Delegate the custom overrides for Survloop default + * methods to retrieve current session data required + * by the current node. + * This overrides the printNodePublicCurrData function in + * RockHopSoft\Survloop\Controllers\Tree\TreeSurvFormPrintLoad. + * e.g. flexyourrights/openpolice-extension + * + * @param TreeNodeSurv $curr + * @return array + */ + protected function extensionPrintNodeSessData(&$curr) + { + return []; + } + /** * Overrides current session data for the first batch of ways to file complaints. * diff --git a/src/Controllers/OpenVolunteers.php b/src/Controllers/OpenVolunteers.php index 52dc053..12f4a21 100644 --- a/src/Controllers/OpenVolunteers.php +++ b/src/Controllers/OpenVolunteers.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.12 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Controllers/VolunteerLeaderboard.php b/src/Controllers/VolunteerLeaderboard.php index 62e6ea4..65eb812 100755 --- a/src/Controllers/VolunteerLeaderboard.php +++ b/src/Controllers/VolunteerLeaderboard.php @@ -5,7 +5,7 @@ * * OpenPolice.org * @package flexyourrights/openpolice - * @author Morgan Lesko + * @author Morgan Lesko * @since v0.0.1 */ namespace FlexYourRights\OpenPolice\Controllers; diff --git a/src/Database/2021_01_28_000000_create_openpolice_tables.php b/src/Database/2021_01_28_000000_create_openpolice_tables.php index 0bc8838..7a78378 100644 --- a/src/Database/2021_01_28_000000_create_openpolice_tables.php +++ b/src/Database/2021_01_28_000000_create_openpolice_tables.php @@ -4,7 +4,6 @@ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -use Illuminate\Support\Facades\DB; class CreateOpenPoliceTables extends Migration { @@ -15,7 +14,6 @@ class CreateOpenPoliceTables extends Migration */ public function up() { - DB::statement('SET SESSION sql_require_primary_key=0'); Schema::create('op_complaints', function(Blueprint $table) { $table->increments('com_id'); diff --git a/src/OpenPoliceFacade.php b/src/OpenPoliceFacade.php index f6269a4..8d54bca 100644 --- a/src/OpenPoliceFacade.php +++ b/src/OpenPoliceFacade.php @@ -3,9 +3,9 @@ * OpenPoliceFacade in Laravel is a class which redirects static * method calls to the dynamic methods of an underlying class * - * Survloop - All Our Data Are Belong - * @package rockhopsoft/survloop - * @author Morgan Lesko + * OpenPolice.org + * @package flexyourrights/openpolice + * @author Morgan Lesko * @since 0.2.8 */ namespace FlexYourRights\OpenPolice; diff --git a/src/OpenPoliceServiceProvider.php b/src/OpenPoliceServiceProvider.php index 7602bcb..4fad44b 100755 --- a/src/OpenPoliceServiceProvider.php +++ b/src/OpenPoliceServiceProvider.php @@ -1,4 +1,13 @@ + * @since v0.3.0 + */ namespace FlexYourRights\OpenPolice; use Illuminate\Support\ServiceProvider;