diff --git a/.DS_Store b/.DS_Store index f7d6119..724a6ec 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 72df7dc..d9107b8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ src/Views/.DS_Store .DS_Store .DS_Store .DS_Store +.DS_Store +.DS_Store +.DS_Store diff --git a/README.md b/README.md index 85a8e47..134536b 100755 --- a/README.md +++ b/README.md @@ -78,8 +78,7 @@ Next, install Laravel's out-of-the-box user authentication tools, Survloop, and ``` % php artisan key:generate % php artisan cache:clear -% COMPOSER_MEMORY_LIMIT=-1 composer require laravel/ui paragonie/random_compat mpdf/mpdf rockhopsoft/survloop flexyourrights/openpolice -% php artisan ui vue --auth +% COMPOSER_MEMORY_LIMIT=-1 composer require mpdf/mpdf rockhopsoft/survloop flexyourrights/openpolice % nano composer.json ``` @@ -95,6 +94,7 @@ $ nano composer.json ... "FlexYourRights\\OpenPolice\\": "vendor/flexyourrights/openpolice/src/", "RockHopSoft\\Survloop\\": "vendor/rockhopsoft/survloop/src/", + "Predis\\": "vendor/predis/predis/src/", } ... }, ... @@ -108,6 +108,7 @@ $ nano config/app.php ... 'providers' => [ ... + App\Providers\FortifyServiceProvider::class, FlexYourRights\OpenPolice\OpenPoliceServiceProvider::class, RockHopSoft\Survloop\SurvloopServiceProvider::class, ... @@ -128,9 +129,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 config:cache -% php artisan route:cache -% php artisan view:cache +% php artisan config:clear +% php artisan route:clear +% php artisan view:clear % echo "0" | php artisan vendor:publish --force % composer dump-autoload % curl http://myopenpolice.local/css-reload diff --git a/src/Controllers/DepartmentScores.php b/src/Controllers/DepartmentScores.php index 6782ea3..4c1378c 100644 --- a/src/Controllers/DepartmentScores.php +++ b/src/Controllers/DepartmentScores.php @@ -28,129 +28,121 @@ class DepartmentScores public $deptNames = []; public $deptOvers = []; public $deptScore = []; - + public $chartFlds = []; public $gradeColor = []; public $stats = []; public $searchFilts = []; - + protected $loaded = false; - + public function __construct() { - $GLOBALS["SL"]->x["defOverIA"] = $GLOBALS["SL"]->def->getID( - 'Investigative Agency Types', - 'Internal Affairs' - ); - $GLOBALS["SL"]->x["defOverCiv"] = $GLOBALS["SL"]->def->getID( - 'Investigative Agency Types', - 'Civilian Oversight' - ); - + $this->loadOverDefs(); $this->vals = []; $this->vals["WebForm"] = new DeptFldScore( - 20, - 'over_complaint_web_form', - '', + 20, + 'over_complaint_web_form', + '', '', 'Has online-submittable complaint form (not just a PDF)' ); $this->vals["WebInfo"] = new DeptFldScore( - 14, - 'over_web_complaint_info', - '', + 14, + 'over_web_complaint_info', + '', '', 'Has complaint information on unique web page (not just on PDF)' ); $this->vals["WebInfoHome"] = new DeptFldScore( - 10, - 'over_homepage_complaint_link', - '', + 10, + 'over_homepage_complaint_link', + '', 'Y', 'Complaint information link visible on police department homepage' ); $this->vals["PdfForm"] = new DeptFldScore( - 10, - 'over_complaint_pdf', - '', + 10, + 'over_complaint_pdf', + '', '', 'Has complaint form PDF on website' ); $this->vals["ByEmail"] = new DeptFldScore( - 10, - 'over_way_sub_email', - '', + 10, + 'over_way_sub_email', + '', '1', 'Investigates complaints sent via email' ); $this->vals["OfficForm"] = new DeptFldScore( - 10, - 'over_official_form_not_req', - '', + 10, + 'over_official_form_not_req', + '', '1', 'Official department form not required for investigation' ); $this->vals["Anonymous"] = new DeptFldScore( - 10, - 'over_official_anon', - '', + 10, + 'over_official_anon', + '', '1', 'Anonymous complaints investigated' ); $this->vals["HasWebsite"] = new DeptFldScore( - 3, - 'over_website', - '', + 3, + 'over_website', + '', '', 'Has unique department website' ); $this->vals["HasFace"] = new DeptFldScore( - 3, - 'over_facebook', - '', + 3, + 'over_facebook', + '', '', 'Has a Facebook page (with public comments on)' ); $this->vals["HasTwit"] = new DeptFldScore( - 3, - 'over_twitter', - '', + 3, + 'over_twitter', + '', '', 'Has a Twitter account' ); $this->vals["HasYou"] = new DeptFldScore( - 3, - 'over_youtube', - '', + 3, + 'over_youtube', + '', '', 'Has a YouTube channel' ); $this->vals["ByPhone"] = new DeptFldScore( - 2, - 'over_way_sub_verbal_phone', - '', + 2, + 'over_way_sub_verbal_phone', + '', '1', 'Investigates complaints sent via phone' ); $this->vals["ByPostal"] = new DeptFldScore( - 2, - 'over_way_sub_paper_mail', - '', + 2, + 'over_way_sub_paper_mail', + '', '1', 'Investigates complaints sent via postal mail' ); $this->vals["InPerson"] = new DeptFldScore( - 0, - 'over_way_sub_paper_in_person', - '', + 0, + 'over_way_sub_paper_in_person', + '', '1', 'Requires complaints to be filed in person' ); $this->vals["Notary"] = new DeptFldScore( - -10, - 'over_way_sub_notary', - '', + -10, + 'over_way_sub_notary', + '', '1', 'Requires notary or in-person signature (for one or more types of complaint)' ); @@ -192,17 +184,17 @@ public function __construct() '', 'Have a Twitter Feed' ], [ - 'Never Requires Notary', - 'Notary', + 'Never Requires Notary', + 'Notary', '', 'Never Require Notary to Submit Complaint' ] ]; $this->gradeColors = [ '#2B3493', - $GLOBALS["SL"]->printColorFadeHex(0.3, '#FFFFFF', '#2B3493'), - $GLOBALS["SL"]->printColorFadeHex(0.6, '#FFFFFF', '#2B3493'), - $GLOBALS["SL"]->printColorFadeHex(0.3, '#FFFFFF', '#FF6059'), + $GLOBALS["SL"]->colorFadeHex(0.3, '#FFFFFF', '#2B3493'), + $GLOBALS["SL"]->colorFadeHex(0.6, '#FFFFFF', '#2B3493'), + $GLOBALS["SL"]->colorFadeHex(0.3, '#FFFFFF', '#FF6059'), '#FF6059' ]; $this->stats = [ @@ -214,37 +206,49 @@ public function __construct() } return true; } - + + private function loadOverDefs() + { + $GLOBALS["SL"]->x["defOverIA"] = $GLOBALS["SL"]->def->getID( + 'Investigative Agency Types', + 'Internal Affairs' + ); + $GLOBALS["SL"]->x["defOverCiv"] = $GLOBALS["SL"]->def->getID( + 'Investigative Agency Types', + 'Civilian Oversight' + ); + } + public function loadAllDepts($searchFilts = []) { if (!$this->loaded) { $flts = ""; if (isset($searchFilts["deptID"]) && trim($searchFilts["deptID"]) != '') { $flts .= "->where('dept_id', '" . trim($searchFilts["deptID"]) . "')"; - } elseif (isset($searchFilts["state"]) + } elseif (isset($searchFilts["state"]) && trim($searchFilts["state"]) != '') { $flts .= "->where('dept_address_state', '" . trim($searchFilts["state"]) . "')"; } $eval = "\$this->scoreDepts = App\\Models\\OPDepartments" - . "::where('dept_verified', '>', '2015-08-01 00:00:00')" + . "::where('dept_verified', '>', '2015-08-01 00:00:00')" . $flts . "->orderBy('dept_score_openness', 'desc')->get();"; eval($eval); if ($this->scoreDepts->isNotEmpty()) { foreach ($this->scoreDepts as $i => $dept) { - //if (sizeof($searchFilts) == 0) { - // || !isset($searchFilts["state"]) + //if (sizeof($searchFilts) == 0) { + // || !isset($searchFilts["state"]) // || $searchFilts["state"] == $dept->dept_address_state $deptName = trim($dept->dept_name); //$deptName = str_replace('Police Dept', 'PD', $deptName); //$deptName = str_replace('Police Department', 'PD', $deptName); //$deptName = trim(str_replace('Department', 'Dept.', $deptName)); - $this->deptNames[$dept->dept_id] = $deptName + $this->deptNames[$dept->dept_id] = $deptName . ', ' . $dept->dept_address_state; - $this->deptOvers[$dept->dept_id]["ia"] + $this->deptOvers[$dept->dept_id]["ia"] = OPOversight::where('over_dept_id', $dept->dept_id) ->where('over_type', $GLOBALS["SL"]->x["defOverIA"]) ->first(); - $this->deptOvers[$dept->dept_id]["civ"] + $this->deptOvers[$dept->dept_id]["civ"] = OPOversight::where('over_dept_id', $dept->dept_id) ->where('over_type', $GLOBALS["SL"]->x["defOverCiv"]) ->first(); @@ -255,7 +259,7 @@ public function loadAllDepts($searchFilts = []) } return true; } - + protected function recheckVerified() { $verifList = $verifDates = $verifCnt = []; @@ -264,7 +268,7 @@ protected function recheckVerified() ->orWhere('zed_over_made_dept_call', 1) ->orWhere('zed_over_made_ia_call', 1); }) - ->select('zed_over_over_dept_id', 'zed_over_online_research', + ->select('zed_over_over_dept_id', 'zed_over_online_research', 'zed_over_made_dept_call', 'zed_over_made_ia_call', 'created_at') ->orderBy('created_at', 'desc') ->get(); @@ -275,15 +279,15 @@ protected function recheckVerified() if (!isset($verifCnt[$deptID])) { $verifCnt[$deptID] = 0; } - if (isset($dept->zed_over_online_research) + if (isset($dept->zed_over_online_research) && intVal($dept->zed_over_online_research) == 1) { $verifCnt[$deptID]++; } - if (isset($dept->zed_over_made_dept_call) + if (isset($dept->zed_over_made_dept_call) && intVal($dept->zed_over_made_dept_call) == 1) { $verifCnt[$deptID]++; } - if (isset($dept->zed_over_made_ia_call) + if (isset($dept->zed_over_made_ia_call) && intVal($dept->zed_over_made_ia_call) == 1) { $verifCnt[$deptID]++; } @@ -309,7 +313,7 @@ protected function recheckVerified() } return true; } - + public function recalcAllDepts() { if ($GLOBALS["SL"]->REQ->has('recalc')) { @@ -359,7 +363,7 @@ public function recalcAllDepts() } return true; } - + public function checkRecFld($specs, $deptID, $overrow = null) { if ($overrow === null) { @@ -375,7 +379,7 @@ public function checkRecFld($specs, $deptID, $overrow = null) } } if (trim($specs->ifIs) != '') { - if (isset($overrow->{ $specs->fld }) + if (isset($overrow->{ $specs->fld }) && trim($overrow->{ $specs->fld }) == $specs->ifIs) { return $specs->score; } @@ -386,7 +390,7 @@ public function checkRecFld($specs, $deptID, $overrow = null) } return 0; } - + public function printTotsBars($searchFilts = []) { $this->loadAllDepts($searchFilts); @@ -415,9 +419,9 @@ public function printTotsBars($searchFilts = []) $datOut[] = $datTmp[$ind]; $done[] = $ind; } - + return view( - 'vendor.openpolice.nodes.1816-depts-score-criteria-bars', + 'vendor.openpolice.nodes.1816-depts-score-criteria-bars', [ "datOut" => $datOut, "colorG" => $this->gradeColors[0], @@ -425,12 +429,15 @@ public function printTotsBars($searchFilts = []) ] )->render(); } - + public function loadDeptStuff($deptID = -3, $complaintID = -3) { if (!isset($GLOBALS["SL"]->x["depts"])) { $GLOBALS["SL"]->x["depts"] = []; } + if (!isset($GLOBALS["SL"]->x["defOverIA"])) { + $this->loadOverDefs(); + } $GLOBALS["SL"]->x["deptsCnt"] = 0; if ($deptID > 0 && !isset($GLOBALS["SL"]->x["depts"][$deptID])) { $d = [ "id" => $deptID ]; @@ -445,56 +452,61 @@ public function loadDeptStuff($deptID = -3, $complaintID = -3) if (!isset($d["iaRow"]) || !$d["iaRow"]) { $d["iaRow"] = new OPOversight; $d["iaRow"]->over_dept_id = $deptID; + $d["iaRow"]->over_type = $GLOBALS["SL"]->x["defOverIA"]; if ($d["deptRow"] && isset($d["deptRow"]->dept_name)) { - $d["iaRow"]->over_type = $GLOBALS["SL"]->x["defOverIA"]; - $d["iaRow"]->over_agnc_name = $d["deptRow"]->dept_name; - $d["iaRow"]->over_address = $d["deptRow"]->dept_address; - $d["iaRow"]->over_address2 = $d["deptRow"]->dept_address2; - $d["iaRow"]->over_address_city = $d["deptRow"]->dept_address_city; - $d["iaRow"]->over_address_state = $d["deptRow"]->dept_address_state; - $d["iaRow"]->over_address_zip = $d["deptRow"]->dept_address_zip; - $d["iaRow"]->over_phone_work = $d["deptRow"]->dept_phone_work; + $d["iaRow"]->over_agnc_name = $d["deptRow"]->dept_name; } $d["iaRow"]->save(); } - if (isset($d["deptRow"]->dept_name) + if (!isset($d["iaRow"]->over_address) + && $d["deptRow"] + && isset($d["deptRow"]->dept_name)) { + $d["iaRow"]->over_address = $d["deptRow"]->dept_address; + $d["iaRow"]->over_address2 = $d["deptRow"]->dept_address2; + $d["iaRow"]->over_address_city = $d["deptRow"]->dept_address_city; + $d["iaRow"]->over_address_state = $d["deptRow"]->dept_address_state; + $d["iaRow"]->over_address_zip = $d["deptRow"]->dept_address_zip; + $d["iaRow"]->over_phone_work = $d["deptRow"]->dept_phone_work; + $d["iaRow"]->save(); + } + if (isset($d["deptRow"]->dept_name) && trim($d["deptRow"]->dept_name) != '') { - if (!isset($d["iaRow"]->over_agnc_name) + if (!isset($d["iaRow"]->over_agnc_name) || trim($d["iaRow"]->over_agnc_name) == '') { $d["iaRow"]->over_agnc_name = $d["deptRow"]->dept_name; $d["iaRow"]->save(); } if ($d["deptRow"] && isset($d["deptRow"]->dept_address)) { $d["deptAddy"] = $d["deptRow"]->dept_address . ', '; - if (isset($d["deptRow"]->dept_address2) + if (isset($d["deptRow"]->dept_address2) && trim($d["deptRow"]->dept_address2) != '') { $d["deptAddy"] .= $d["deptRow"]->dept_address2 . ', '; } - $d["deptAddy"] .= $d["deptRow"]->dept_address_city . ', ' - . $d["deptRow"]->dept_address_state . ' ' + $d["deptAddy"] .= $d["deptRow"]->dept_address_city . ', ' + . $d["deptRow"]->dept_address_state . ' ' . $d["deptRow"]->dept_address_zip; $d["iaAddy"] = ''; - if (isset($d["iaRow"]->over_address) + if (isset($d["iaRow"]->over_address) && trim($d["iaRow"]->over_address) != '') { $d["iaAddy"] = $d["iaRow"]->over_address . ', '; - if (isset($d["iaRow"]->over_address2) + if (isset($d["iaRow"]->over_address2) && trim($d["iaRow"]->over_address2) != '') { $d["iaAddy"] .= $d["iaRow"]->over_address2 . ', '; } - $d["iaAddy"] .= $d["iaRow"]->over_address_city - . ', ' . $d["iaRow"]->over_address_state + $d["iaAddy"] .= $d["iaRow"]->over_address_city + . ', ' . $d["iaRow"]->over_address_state . ' ' . $d["iaRow"]->over_address_zip; } $d["civAddy"] = ''; - if (isset($d["civRow"]->over_address) + if (isset($d["civRow"]->over_address) && trim($d["civRow"]->over_address) != '') { $d["civAddy"] = $d["civRow"]->over_address . ', '; - if (isset($d["civRow"]->over_address2) + if (isset($d["civRow"]->over_address2) && trim($d["civRow"]->over_address2) != '') { $d["civAddy"] .= $d["civRow"]->over_address2 . ', '; } - $d["civAddy"] .= $d["civRow"]->over_address_city - . ', ' . $d["civRow"]->over_address_state + $d["civAddy"] .= $d["civRow"]->over_address_city + . ', ' . $d["civRow"]->over_address_state . ' ' . $d["civRow"]->over_address_zip; } } @@ -517,9 +529,9 @@ public function loadDeptStuff($deptID = -3, $complaintID = -3) $GLOBALS["SL"]->x["deptsCnt"]++; } } - + $d["whichOver"] = $which = 'iaRow'; - if (isset($d["civRow"]) + if (isset($d["civRow"]) && isset($d["civRow"]->over_agnc_name) && trim($d["civRow"]->over_agnc_name) != '') { $d["whichOver"] = $which = 'civRow'; @@ -557,31 +569,30 @@ public function loadDeptStuff($deptID = -3, $complaintID = -3) } return true; } - + public function printMapScoreDesc($deptID = 0) { - if (!isset($GLOBALS["SL"]->x["depts"]) + if (!isset($GLOBALS["SL"]->x["depts"]) || !isset($GLOBALS["SL"]->x["depts"][$deptID])) { return ''; } return view( - 'vendor.openpolice.dept-kml-desc', + 'vendor.openpolice.dept-kml-desc', [ "dept" => $GLOBALS["SL"]->x["depts"][$deptID] ] )->render(); } - - + } class DeptFldScore { public $fld = ''; public $label = ''; - + public $score = 0; public $ifNot = ''; public $ifIs = ''; - + public function __construct($score = 0, $fld = '', $ifNot = '', $ifIs = '', $label = '') { $this->fld = $fld; diff --git a/src/Controllers/OpenAjax.php b/src/Controllers/OpenAjax.php index 5c14fd7..d97997e 100644 --- a/src/Controllers/OpenAjax.php +++ b/src/Controllers/OpenAjax.php @@ -23,7 +23,7 @@ class OpenAjax extends OpenAjaxCachePrep { /** - * Check for ajax requests customized beyond + * 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. @@ -55,12 +55,23 @@ public function ajaxChecksCustom(Request $request, $type = '') $this->ajaxComplaintPreloads($request); } elseif ($type == 'complaint-preloads-staff') { $this->ajaxStaffComplaintPreloads($request); + + } elseif (in_array($type, ['dash-stats-top', 'dash-stats-graph'])) { + $this->initAdmDash(); + if (Auth::user() + && Auth::user()->hasRole('administrator|staff|partner')) { + if ($type == 'dash-stats-top') { + return $this->v["openDash"]->printDashTopLevStats($request); + } elseif ($type == 'dash-stats-graph') { + return $this->v["openDash"]->printDashSessGraph($request); + } + } } return ''; } /** - * Check for ajax requests customized beyond + * Check for ajax requests customized beyond * Survloop's default behavior, called via /ajax/{type}. * e.g. flexyourrights/openpolice-extension * @@ -100,9 +111,9 @@ public function ajaxLoadSearchComplaintPreviews(Request $request) $GLOBALS["SL"]->x["isPublicList"] = true; return $this->printComplaintListing(2384, 'lrg'); } - + /** - * Run the ajax request to search police departments + * Run the ajax request to search police departments * and return clickable results. * * @param Illuminate\Http\Request $request @@ -141,7 +152,7 @@ public function ajaxPoliceDeptSearch(Request $request, $view = 'survey') $this->getDeptStateFltNames(); list($sortLab, $sortDir) = $this->chkDeptSorts($this->v["reqState"]); - $loadUrl .= $this->v["reqLike"] . '&states=' . implode(',', $this->v["reqState"]) + $loadUrl .= $this->v["reqLike"] . '&states=' . implode(',', $this->v["reqState"]) . '&sortLab=' . $sortLab . '&sortDir=' . $sortDir; $ret = $GLOBALS["SL"]->chkCache($loadUrl, 'search', 36); if (trim($ret) == '' || $request->has('refresh')) { @@ -152,17 +163,17 @@ public function ajaxPoliceDeptSearch(Request $request, $view = 'survey') if ($view == 'survey') { $drop = $GLOBALS["SL"]->states->stateDrop($this->v["reqState"][0], true); $ret = view( - 'vendor.openpolice.ajax.search-police-dept', + 'vendor.openpolice.ajax.search-police-dept', [ - "depts" => $this->v["depts"], - "search" => $searchStr, - "stateName" => $this->v["stateNames"], + "depts" => $this->v["depts"], + "search" => $searchStr, + "stateName" => $this->v["stateNames"], "newDeptStateDrop" => $drop ] )->render(); } else { $ret = view( - 'vendor.openpolice.ajax.department-previews', + 'vendor.openpolice.ajax.department-previews', [ "depts" => $this->v["depts"], "deptSearch" => $searchStr, @@ -177,7 +188,7 @@ public function ajaxPoliceDeptSearch(Request $request, $view = 'survey') echo $ret; exit; } - + /** * Run the ranked search for police departments. * @@ -187,8 +198,8 @@ public function ajaxPoliceDeptSearch(Request $request, $view = 'survey') protected function ajaxRunDeptSearch($str) { if (!isset($this->v["deptIDs"])) { - $this->v["deptIDs"] - = $this->v["depts"] + $this->v["deptIDs"] + = $this->v["depts"] = []; } if (!isset($this->v["reqState"])) { @@ -206,7 +217,7 @@ protected function ajaxRunDeptSearch($str) } return true; } - + /** * Run the ranked search for police departments within certain states. * @@ -230,7 +241,7 @@ private function ajaxRunDeptSearchBasic($str, $states = false) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get();"; @@ -244,7 +255,7 @@ private function ajaxRunDeptSearchBasic($str, $states = false) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get();"; @@ -258,7 +269,7 @@ private function ajaxRunDeptSearchBasic($str, $states = false) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get();"; @@ -272,7 +283,7 @@ private function ajaxRunDeptSearchBasic($str, $states = false) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get();"; @@ -281,7 +292,7 @@ private function ajaxRunDeptSearchBasic($str, $states = false) } return true; } - + /** * Run the ranked search for police departments within certain states. * @@ -295,7 +306,7 @@ private function ajaxRunDeptSearchStates($str) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get(); @@ -325,7 +336,7 @@ private function ajaxRunDeptSearchStates($str) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get(); @@ -335,7 +346,7 @@ private function ajaxRunDeptSearchStates($str) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get(); @@ -345,7 +356,7 @@ private function ajaxRunDeptSearchStates($str) } return true; } - + /** * Run the ranked search for police departments within certain federal jurisdictions. * @@ -367,7 +378,7 @@ private function ajaxRunDeptSearchFederal($str) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get(); @@ -379,7 +390,7 @@ private function ajaxRunDeptSearchFederal($str) ->orderBy('dept_jurisdiction_population', 'desc') ->orderBy('dept_tot_officers', 'desc') ->orderBy('dept_name', 'asc') - ->select('dept_address_state', 'dept_address_county', 'dept_name', + ->select('dept_address_state', 'dept_address_county', 'dept_name', 'dept_id', 'dept_slug', 'dept_score_openness', 'dept_verified', 'dept_address_city', 'dept_address_state') ->get(); @@ -493,7 +504,7 @@ protected function printDataSetResultsAjaxDepts(Request $request, $limit) $str = $this->chkDeptSearchFlt($request); $this->ajaxRunDeptSearch($str); return view( - 'vendor.openpolice.ajax.department-previews-table', + 'vendor.openpolice.ajax.department-previews-table', [ "limit" => $limit, "depts" => $this->v["depts"] @@ -514,7 +525,7 @@ protected function chkDeptSearchAddState($abbr) if (!in_array($abbr, $this->v["reqState"])) { $this->v["reqState"][] = $abbr; } - if (isset($this->searcher) + if (isset($this->searcher) && isset($this->searcher->searchFilts) && isset($this->searcher->searchFilts["states"]) && !in_array($abbr, $this->searcher->searchFilts["states"])) { @@ -545,7 +556,7 @@ protected function chkDeptStateFlt($request) if (sizeof($filts) > 0) { foreach ($filts as $flt) { $filtParts = $GLOBALS["SL"]->mexplode('_', $flt); - if (sizeof($filtParts) == 2 + if (sizeof($filtParts) == 2 && $filtParts[0] == 'states') { $this->v["reqState"] = $GLOBALS["SL"]->mexplode(',', $filtParts[1]); } @@ -553,7 +564,7 @@ protected function chkDeptStateFlt($request) } } return $this->v["reqState"]; - } + } /** * Get the written list of state filters. @@ -574,7 +585,7 @@ protected function getDeptStateFltNames() } } return $this->v["stateNames"]; - } + } /** * Check for sorting specific to department listings. @@ -586,15 +597,15 @@ protected function chkDeptSorts() $sortLab = 'match'; $sortDir = 'asc'; if (sizeof($this->v["reqState"]) > 0 - && (!isset($this->v["reqLike"]) + && (!isset($this->v["reqLike"]) || trim($this->v["reqLike"]) == '')) { $sortLab = 'name'; } - if ($GLOBALS["SL"]->REQ->has('sDeptSort') + if ($GLOBALS["SL"]->REQ->has('sDeptSort') && trim($GLOBALS["SL"]->REQ->get('sDeptSort')) != '') { $sortLab = trim($GLOBALS["SL"]->REQ->get('sDeptSort')); } - if ($GLOBALS["SL"]->REQ->has('sDeptSortDir') + if ($GLOBALS["SL"]->REQ->has('sDeptSortDir') && trim($GLOBALS["SL"]->REQ->get('sDeptSortDir')) != '') { $sortDir = trim($GLOBALS["SL"]->REQ->get('sDeptSortDir')); } elseif ($sortLab == 'score') { @@ -625,14 +636,14 @@ protected function applyDeptSorts(&$depts, $sortLab, $sortDir) if ($sortDir == 'desc') { usort($depts, function($a, $b) { return (strcasecmp( - $a->dept_address_state . $a->dept_address_city, + $a->dept_address_state . $a->dept_address_city, $b->dept_address_state . $b->dept_address_city ) <= 0); }); } else { usort($depts, function($a, $b) { return (strcasecmp( - $a->dept_address_state . $a->dept_address_city, + $a->dept_address_state . $a->dept_address_city, $b->dept_address_state . $b->dept_address_city ) > 0); }); @@ -650,7 +661,7 @@ protected function applyDeptSorts(&$depts, $sortLab, $sortDir) } return $depts; } - + /** * Pull and print the department description to appear when * clicking it inside the Google map. @@ -667,7 +678,7 @@ public function ajaxDeptKmlDesc(Request $request) } return ''; } - + /** * Add a new set of departments ($deptsIn) into the larger * sets of results. @@ -703,7 +714,7 @@ protected function printDataSetResultsAjaxComplaints(Request $request, $limit) $this->ajaxRunComplaintSearch($str); $this->prepDataSetPreviewComplaints(); return view( - 'vendor.openpolice.nodes.1221-search-results-multi-data-sets-complaints', + 'vendor.openpolice.nodes.1221-search-results-multi-data-sets-complaints', [ "limit" => $limit, "isStaff" => $this->isStaffOrAdmin(), @@ -711,9 +722,9 @@ protected function printDataSetResultsAjaxComplaints(Request $request, $limit) ] )->render(); } - + /** - * Load baseline data fields needed to preview complaints + * Load baseline data fields needed to preview complaints * for multi-set search results. * * @param string $str @@ -728,7 +739,7 @@ private function prepDataSetPreviewComplaints() } return true; } - + /** * Run the ranked search for complaints. * @@ -738,9 +749,9 @@ private function prepDataSetPreviewComplaints() protected function ajaxRunComplaintSearch($str) { if (!isset($this->v["comIDs"])) { - $this->v["comIDs"] - = $this->v["complaints"] - = $this->v["allIncIDs"] + $this->v["comIDs"] + = $this->v["complaints"] + = $this->v["allIncIDs"] = []; } $this->v["comSearchTxt"] = $GLOBALS["SL"]->parseSearchWords($str); @@ -759,7 +770,7 @@ protected function ajaxRunComplaintSearch($str) } return true; } - + /** * Run the ranked search for complaints. * @@ -776,11 +787,11 @@ protected function ajaxRunComplaintSearchAddBasic() ->where('op_civilians.civ_is_creator', 'LIKE', 'Y') ->whereIn('op_civilians.civ_complaint_id', $this->v["allComIDsPubCiv"]) ->where(function ($query) { - return $query->where('op_person_contact.prsn_name_first', + return $query->where('op_person_contact.prsn_name_first', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_person_contact.prsn_name_last', + ->orWhere('op_person_contact.prsn_name_last', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_person_contact.prsn_nickname', + ->orWhere('op_person_contact.prsn_nickname', 'LIKE', $GLOBALS["strLike"]); }) ->select('op_civilians.civ_complaint_id') @@ -794,11 +805,11 @@ protected function ajaxRunComplaintSearchAddBasic() '=', 'op_incidents.inc_id') ->whereIn('op_complaints.com_id', $this->v["allComIDs"]) ->where(function ($query) { - return $query->where('op_incidents.inc_address_city', + return $query->where('op_incidents.inc_address_city', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_incidents.inc_address', + ->orWhere('op_incidents.inc_address', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_incidents.inc_landmarks', + ->orWhere('op_incidents.inc_landmarks', 'LIKE', $GLOBALS["strLike"]); }) ->select('op_complaints.com_id') @@ -814,11 +825,11 @@ protected function ajaxRunComplaintSearchAddBasic() ->where('op_civilians.civ_is_creator', 'NOT LIKE', 'Y') ->whereIn('op_civilians.civ_complaint_id', $this->v["allComIDs"]) ->where(function ($query) { - return $query->where('op_person_contact.prsn_name_first', + return $query->where('op_person_contact.prsn_name_first', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_person_contact.prsn_name_last', + ->orWhere('op_person_contact.prsn_name_last', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_person_contact.prsn_nickname', + ->orWhere('op_person_contact.prsn_nickname', 'LIKE', $GLOBALS["strLike"]); }) ->select('op_civilians.civ_complaint_id') @@ -833,11 +844,11 @@ protected function ajaxRunComplaintSearchAddBasic() '=', 'op_officers.off_person_id') ->whereIn('op_officers.off_complaint_id', $this->v["allComIDsPubOff"]) ->where(function ($query) { - return $query->where('op_person_contact.prsn_name_first', + return $query->where('op_person_contact.prsn_name_first', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_person_contact.prsn_name_last', + ->orWhere('op_person_contact.prsn_name_last', 'LIKE', $GLOBALS["strLike"]) - ->orWhere('op_person_contact.prsn_nickname', + ->orWhere('op_person_contact.prsn_nickname', 'LIKE', $GLOBALS["strLike"]); }) ->select('op_officers.off_complaint_id') @@ -859,7 +870,7 @@ protected function ajaxRunComplaintSearchAddBasic() } return true; } - + /** * Load the list of all complaint IDs in the searching pool. * @@ -867,9 +878,9 @@ protected function ajaxRunComplaintSearchAddBasic() */ protected function ajaxRunComplaintSearchLoadAll() { - $this->v["allComIDs"] - = $this->v["allComIDsPubCiv"] - = $this->v["allComIDsPubOff"] + $this->v["allComIDs"] + = $this->v["allComIDsPubCiv"] + = $this->v["allComIDsPubOff"] = []; $chk = null; if ($this->isStaffOrAdmin()) { @@ -878,7 +889,7 @@ protected function ajaxRunComplaintSearchLoadAll() ->orderBy('com_id', 'desc') ->select('com_id') ->get(); - $this->v["allComIDs"] = $GLOBALS["SL"]->resultsToArrIds($chk, 'com_id'); + $this->v["allComIDs"] = $GLOBALS["SL"]->resToArrIds($chk, 'com_id'); $this->v["allComIDsPubCiv"] = $this->v["allComIDs"]; $this->v["allComIDsPubOff"] = $this->v["allComIDs"]; } else { @@ -888,7 +899,7 @@ protected function ajaxRunComplaintSearchLoadAll() ->orderBy('com_id', 'desc') ->select('com_id') ->get(); - $this->v["allComIDs"] = $GLOBALS["SL"]->resultsToArrIds($chk, 'com_id'); + $this->v["allComIDs"] = $GLOBALS["SL"]->resToArrIds($chk, 'com_id'); $chk = OPComplaints::whereNotNull('com_summary') ->where('com_summary', 'NOT LIKE', '') ->whereIn('com_status', $this->getPublishedStatusList('complaints')) @@ -896,7 +907,7 @@ protected function ajaxRunComplaintSearchLoadAll() ->orderBy('com_id', 'desc') ->select('com_id') ->get(); - $this->v["allComIDsPubCiv"] = $GLOBALS["SL"]->resultsToArrIds($chk, 'com_id'); + $this->v["allComIDsPubCiv"] = $GLOBALS["SL"]->resToArrIds($chk, 'com_id'); $chk = OPComplaints::whereNotNull('com_summary') ->where('com_summary', 'NOT LIKE', '') ->whereIn('com_status', $this->getPublishedStatusList('complaints')) @@ -904,13 +915,13 @@ protected function ajaxRunComplaintSearchLoadAll() ->orderBy('com_id', 'desc') ->select('com_id') ->get(); - $this->v["allComIDsPubOff"] = $GLOBALS["SL"]->resultsToArrIds($chk, 'com_id'); + $this->v["allComIDsPubOff"] = $GLOBALS["SL"]->resToArrIds($chk, 'com_id'); } return $chk; } - + /** - * Add a new set of complaints into the larger sets of results, + * Add a new set of complaints into the larger sets of results, * based on the requested data field. * * @param array $complaintsIn @@ -930,7 +941,7 @@ protected function addComplaintToResults($complaintsIn, $fld = '') return true; } - + } class ComplaintPreview @@ -950,14 +961,15 @@ public function __construct($comID) ->join('op_complaints', 'op_complaints.com_incident_id', '=', 'op_incidents.inc_id') ->where('op_complaints.com_id', $comID) - ->select('op_complaints.com_id', - 'op_complaints.com_public_id', - 'op_complaints.com_status', + ->select('op_complaints.com_id', + 'op_complaints.com_public_id', + 'op_complaints.com_status', 'op_complaints.com_record_submitted', - 'op_complaints.com_publish_user_name', - 'op_complaints.com_publish_officer_name', - 'op_incidents.inc_address_city', - 'op_incidents.inc_address_state') + 'op_complaints.com_publish_user_name', + 'op_complaints.com_publish_officer_name', + 'op_incidents.inc_address_city', + 'op_incidents.inc_address_state', + 'op_incidents.inc_address_zip') ->first(); OPComplaints::find($comID); if ($this->complaint && isset($this->complaint->com_id)) { @@ -966,7 +978,7 @@ public function __construct($comID) '=', 'op_civilians.civ_person_id') ->where('op_civilians.civ_complaint_id', $comID) ->where('op_civilians.civ_is_creator', 'Y') - ->select('op_person_contact.prsn_name_first', + ->select('op_person_contact.prsn_name_first', 'op_person_contact.prsn_name_last', 'op_person_contact.prsn_nickname') ->first(); @@ -975,7 +987,7 @@ public function __construct($comID) '=', 'op_officers.off_person_id') ->where('op_officers.off_complaint_id', $comID) ->orderBy('op_officers.off_id', 'asc') - ->select('op_person_contact.prsn_name_first', + ->select('op_person_contact.prsn_name_first', 'op_person_contact.prsn_name_last', 'op_person_contact.prsn_nickname') ->get(); @@ -984,8 +996,8 @@ public function __construct($comID) '=', 'op_departments.dept_id') ->where('op_links_complaint_dept.lnk_com_dept_complaint_id', $comID) ->orderBy('op_departments.dept_name', 'asc') - ->select('op_departments.dept_id', - 'op_departments.dept_name', + ->select('op_departments.dept_id', + 'op_departments.dept_name', 'op_departments.dept_slug') ->get(); } diff --git a/src/Controllers/OpenAjaxCachePrep.php b/src/Controllers/OpenAjaxCachePrep.php index ec07c99..33d0cfe 100644 --- a/src/Controllers/OpenAjaxCachePrep.php +++ b/src/Controllers/OpenAjaxCachePrep.php @@ -30,16 +30,16 @@ public function ajaxComplaintPreloads(Request $request) ->select('com_id', 'com_public_id') ->orderBy('com_id', 'asc') ->get(); - //$comIDs = $GLOBALS["SL"]->resultsToArrIds($coms, 'com_id'); + //$comIDs = $GLOBALS["SL"]->resToArrIds($coms, 'com_id'); if ($coms->isNotEmpty()) { foreach ($coms as $com) { $cachKey = 'page-complaint/read-' . $com->com_public_id . '-visitor-c_' . $com->com_id . '-p_public.html'; $content = $GLOBALS["SL"]->chkCache($cachKey, 'page', 42, $com->com_id); if (trim($content) == '') { - echo '/complaint/read-' . $com->com_public_id - . '
' + echo '/complaint/read-' . $com->com_public_id + . '
' . $this->ajaxAgainComplaintPreloads(); exit; } else { @@ -68,12 +68,12 @@ public function ajaxComplaintPreloads(Request $request) $log->log_new_name = 'Rec ' . $com->com_id; $log->save(); } - echo 'Search Cache ' . $com->com_id + echo 'Search Cache ' . $com->com_id . $this->ajaxAgainComplaintPreloads(); exit; } } - } + } } echo 'No cache prep needed.'; exit; @@ -86,7 +86,7 @@ public function ajaxComplaintPreloads(Request $request) */ private function ajaxAgainComplaintPreloads() { - return ''; } @@ -113,8 +113,8 @@ public function ajaxStaffComplaintPreloads(Request $request) $content = $GLOBALS["SL"]->chkCache($cachKey, 'page', 42, $com->com_id); if (trim($content) == '') { echo '/complaint/read-' . $com->com_public_id . '/full?ajax=1&wdg=1' - . '
' + . '
' . $this->ajaxAgainStaffComplaintPreloads(); exit; } else { @@ -135,8 +135,8 @@ public function ajaxStaffComplaintPreloads(Request $request) $content = $GLOBALS["SL"]->chkCache($cachKey, 'page', 42, $com->com_id); if (trim($content) == '') { echo '/complaint/readi-' . $com->com_id . '/full?ajax=1&wdg=1' - . '
' + . '
' . $this->ajaxAgainStaffComplaintPreloads(); exit; } else { @@ -196,7 +196,7 @@ private function ajaxStaffComplaintPreloadDump($comID, $content) */ private function ajaxAgainStaffComplaintPreloads() { - return ''; } diff --git a/src/Controllers/OpenComplaintConditions.php b/src/Controllers/OpenComplaintConditions.php index a4febe2..34681b6 100644 --- a/src/Controllers/OpenComplaintConditions.php +++ b/src/Controllers/OpenComplaintConditions.php @@ -1,6 +1,6 @@ sessData->dataSets["complaints"]) + if (isset($this->sessData->dataSets["complaints"]) && isset($this->sessData->dataSets["complaints"][0]) && isset($this->sessData->dataSets["complaints"][0]->com_id)) { $complaint = $this->sessData->dataSets["complaints"][0]; @@ -177,23 +177,23 @@ protected function extensionCheckNodeConditions($nID, $condition = '') { return -1; } - + /** - * Checks whether or not this incident began + * Checks whether or not this incident began * with a vehicle stop. * * @return int */ protected function condVehicleStop() { - if (isset($this->sessData->dataSets["scenes"]) + if (isset($this->sessData->dataSets["scenes"]) && sizeof($this->sessData->dataSets["scenes"]) > 0) { $scene = $this->sessData->dataSets["scenes"][0]; - if (isset($scene->scn_is_vehicle) + if (isset($scene->scn_is_vehicle) && trim($scene->scn_is_vehicle) == 'Y') { return 1; } - if (isset($scene->scn_is_vehicle_accident) + if (isset($scene->scn_is_vehicle_accident) && trim($scene->scn_is_vehicle_accident) == 'Y') { return 1; } @@ -202,29 +202,29 @@ protected function condVehicleStop() } /** - * Checks whether or not this complaint is + * Checks whether or not this complaint is * associated with a partner's intake process. * * @return int */ protected function condPartnerIntake($complaint) { - if (isset($complaint->com_att_id) + if (isset($complaint->com_att_id) && intVal($complaint->com_att_id) > 0) { return 1; } return 0; } - + /** - * Checks whether or not this complaint is + * Checks whether or not this complaint is * associated with an attorney partner's intake process. * * @return int */ protected function condAttorneyIntake($complaint) { - if (isset($complaint->com_att_id) + if (isset($complaint->com_att_id) && intVal($complaint->com_att_id) > 0) { $attID = intVal($complaint->com_att_id); $attDef = $GLOBALS["SL"]->def->getID('Partner Types', 'Attorney'); @@ -237,9 +237,9 @@ protected function condAttorneyIntake($complaint) } return 0; } - + /** - * Checks whether or not this complaint is + * Checks whether or not this complaint is * associated with an attorney partner's intake process. * * @return int @@ -253,7 +253,7 @@ protected function condIntakeOnlyNotFiling($complaint) } return 0; } - + /** * Checks whether or not this complaint has or needs * a lawyer to be involved. @@ -262,24 +262,24 @@ protected function condIntakeOnlyNotFiling($complaint) */ protected function condLawyerInvolved($complaint) { - if (isset($complaint->com_attorney_has) + if (isset($complaint->com_attorney_has) && in_array(trim($complaint->com_attorney_has), ['Y', '?'])) { - if (isset($complaint->com_attorney_oked) + if (isset($complaint->com_attorney_oked) && trim($complaint->com_attorney_oked) == 'Y') { return 0; } else { return 1; } - } elseif (isset($complaint->com_attorney_want) + } elseif (isset($complaint->com_attorney_want) && in_array(trim($complaint->com_attorney_want), ['Y'])) { return 1; } if ($this->condPendingChargs($complaint) == 1) { return 1; } - if (isset($complaint->com_anyone_charged) + if (isset($complaint->com_anyone_charged) && trim($complaint->com_anyone_charged) == 'N' - && isset($complaint->com_file_lawsuit) + && isset($complaint->com_file_lawsuit) && trim($complaint->com_file_lawsuit) == 'Y') { return 1; } @@ -293,9 +293,9 @@ protected function condLawyerInvolved($complaint) */ protected function condPendingChargs($complaint) { - if ((isset($complaint->com_anyone_charged) + if ((isset($complaint->com_anyone_charged) && in_array(trim($complaint->com_anyone_charged), ['Y', '?'])) - && (!isset($complaint->com_all_charges_resolved) + && (!isset($complaint->com_all_charges_resolved) || trim($complaint->com_all_charges_resolved) != 'Y')) { return 1; } @@ -303,20 +303,20 @@ protected function condPendingChargs($complaint) } /** - * Checks if this complaint does not need an attorney, + * Checks if this complaint does not need an attorney, * but unlikely to find one — by automated standards. * * @return int */ protected function condWantsAttorneyButNotLikely($complaint) { - if (isset($complaint->com_attorney_has) + if (isset($complaint->com_attorney_has) && in_array(trim($complaint->com_attorney_has), ['Y', '?']) - && isset($complaint->com_attorney_oked) + && isset($complaint->com_attorney_oked) && trim($complaint->com_attorney_oked) == 'Y') { return 0; } - if (isset($complaint->com_attorney_want) + if (isset($complaint->com_attorney_want) && trim($complaint->com_attorney_want) == 'Y' && $this->condPendingChargs($complaint) == 0) { if (isset($this->sessData->dataSets["alleg_silver"]) @@ -348,16 +348,16 @@ protected function condPublishingOptionsInSurvey($complaint) && $this->condAttorneyIntake($complaint) == 0 && (!isset($complaint->com_anon) || intVal($complaint->com_anon) == 0)) { - if (isset($complaint->com_attorney_has) + if (isset($complaint->com_attorney_has) && in_array(trim($complaint->com_attorney_has), ['Y', '?'])) { - if (isset($complaint->com_attorney_oked) + if (isset($complaint->com_attorney_oked) && trim($complaint->com_attorney_oked) == 'Y') { return 1; } } elseif ($this->condPendingChargs($complaint) == 0) { - if (isset($complaint->com_attorney_want) + if (isset($complaint->com_attorney_want) && trim($complaint->com_attorney_want) == 'Y') { - if (isset($complaint->com_want_attorney_but_file) + if (isset($complaint->com_want_attorney_but_file) && intVal($complaint->com_want_attorney_but_file) == 1) { return 1; } @@ -370,7 +370,7 @@ protected function condPublishingOptionsInSurvey($complaint) } /** - * Checks if no sexual allegations were made + * Checks if no sexual allegations were made * related to this complaint. * * @return int @@ -379,10 +379,10 @@ protected function condNoSexualAllegation() { $noSexAlleg = true; $types = [ - $GLOBALS["SL"]->def->getID('Allegation Type', 'Sexual Assault'), + $GLOBALS["SL"]->def->getID('Allegation Type', 'Sexual Assault'), $GLOBALS["SL"]->def->getID('Allegation Type', 'Sexual Harassment') ]; - if (isset($this->sessData->dataSets["allegations"]) + if (isset($this->sessData->dataSets["allegations"]) && sizeof($this->sessData->dataSets["allegations"]) > 0) { foreach ($this->sessData->dataSets["allegations"] as $alleg) { if (in_array($alleg->alle_type, $types)) { @@ -392,7 +392,7 @@ protected function condNoSexualAllegation() } return ($noSexAlleg) ? 1 : 0; } - + /** * Checks whether or not this incident * has an associated street address. @@ -409,7 +409,7 @@ protected function condIncidentHasAddress() } return 0; } - + /** * Checks whether or not this complaint includes * an arrest of any use of force. @@ -418,13 +418,13 @@ protected function condIncidentHasAddress() */ protected function condHasArrestOrForce() { - if ($this->sessData->dataHas('arrests') + if ($this->sessData->dataHas('arrests') || $this->sessData->dataHas('force')) { return 1; } return 0; } - + /** * Checks whether or not this complaint includes * any use of force. @@ -438,7 +438,7 @@ protected function condCivHasForce() } return 0; } - + /** * Checks whether or not this complaint includes * any use of force on civilians (not animals). @@ -448,10 +448,10 @@ protected function condCivHasForce() protected function condHasForceHuman() { $ret = 0; - if (isset($this->sessData->dataSets["civilians"]) + if (isset($this->sessData->dataSets["civilians"]) && sizeof($this->sessData->dataSets["civilians"]) > 0) { foreach ($this->sessData->dataSets["civilians"] as $civ) { - if ($civ->civ_role == 'Victim' + if ($civ->civ_role == 'Victim' && $this->chkCivHasForce($civ->civ_id) == 1) { $ret = 1; } @@ -459,7 +459,7 @@ protected function condHasForceHuman() } return $ret; } - + /** * Checks whether or not this complaint includes * any civilian injuries reported. @@ -472,8 +472,8 @@ protected function condHasInjury() $civs = $this->sessData->dataSets["civilians"]; if (sizeof($civs) > 0) { foreach ($civs as $civ) { - if ($civ->civ_role == 'Victim' - && isset($civ->civ_has_injury) + if ($civ->civ_role == 'Victim' + && isset($civ->civ_has_injury) && trim($civ->civ_has_injury) == 'Y') { return 1; } @@ -482,24 +482,24 @@ protected function condHasInjury() } return 0; } - + /** - * Checks whether or not the current - * civilian is the complainant. + * Checks whether or not the current + * civilian is the complainant. * * @return int */ protected function currCivIsCreator() { $civ = $this->sessData->getDataBranchRow('civilians'); - return ($civ - && isset($civ->civ_is_creator) + return ($civ + && isset($civ->civ_is_creator) && trim($civ->civ_is_creator) == 'Y'); } - + /** * Checks whether or not the current civilian is not - * the complainant. This helps avoid impossibly asking + * the complainant. This helps avoid impossibly asking * if the user had fatal injuries. * * @return int @@ -511,7 +511,7 @@ protected function condMedicalCareNotYou() } return -1; } - + /** * Checks whether or not the complaint involved * property seizure and/or damage. @@ -540,9 +540,9 @@ protected function cntAllegations() $allegs = $GLOBALS["SL"]->mexplode(',', $this->commaAllegationList()); return sizeof($allegs); } - + /** - * Checks whether or not this complaint has + * Checks whether or not this complaint has * "too many" allegations selected. * * @return boolean @@ -551,9 +551,9 @@ protected function hasTooManyAllegations() { return ($this->cntAllegations() > 8); } - + /** - * Checks whether or not this complaint has + * Checks whether or not this complaint has * no allegations selected. * * @return boolean @@ -564,7 +564,7 @@ protected function hasNoAllegations() return (sizeof($this->allegations) == 0); //return ($this->cntAllegations() == 0); } - + /** * Checks whether or not this complaint passes an audit. * If not they should be alerted to fix things. @@ -578,7 +578,7 @@ protected function condNeedsAudit() } return 0; } - + /** * Checks whether or not this user has had a * confirmationed email send to them today. @@ -588,7 +588,7 @@ protected function condNeedsAudit() protected function condEmailConfirmSentToday() { if (isset($this->v["user"]) && isset($this->v["user"]->id)) { - $cutoff = mktime(date("H"), date("i"), date("s"), + $cutoff = mktime(date("H"), date("i"), date("s"), date("n"), date("j")-1, date("Y")); $cutoff = date("Y-m-d H:i:s", $cutoff); $chk = SLEmailed::where('emailed_email_id', 1) @@ -596,21 +596,21 @@ protected function condEmailConfirmSentToday() ->where('created_at', '>', $cutoff) ->get(); if ($chk->isNotEmpty()) { - return 1; + return 1; } } return 0; } /** - * Checks whether or not this complainant responded + * Checks whether or not this complainant responded * to qeustions about their feelings. * * @return int */ protected function complaintHasFeelings() { - if (isset($this->sessData->dataSets["scenes"]) + if (isset($this->sessData->dataSets["scenes"]) && isset($this->sessData->dataSets["scenes"][0])) { $scene = $this->sessData->dataSets["scenes"][0]; if ((isset($scene->scn_how_feel) @@ -628,7 +628,7 @@ protected function complaintHasFeelings() } return 0; } - + /** * Checks whether or not this complaint has any uploaded * photos, documents, or linked videos. @@ -638,8 +638,8 @@ protected function complaintHasFeelings() protected function complaintHasUploads() { $uploads = $this->getUploadsMultNodes( - $this->cmplntUpNodes, - $this->isStaffOrAdmin(), + $this->cmplntUpNodes, + $this->isStaffOrAdmin(), $this->v["isOwner"] ); if ($uploads && sizeof($uploads) > 0) { @@ -647,7 +647,7 @@ protected function complaintHasUploads() } return 0; } - + /** * Checks whether or not this complaint's uploads * should be shown to the current user. @@ -658,7 +658,7 @@ protected function complaintHasUploads() protected function complaintShowUploads($complaint = null) { if ((!$complaint || $complaint === null) - && isset($this->sessData->dataSets["complaints"]) + && isset($this->sessData->dataSets["complaints"]) && isset($this->sessData->dataSets["complaints"][0])) { $complaint = $this->sessData->dataSets["complaints"][0]; } @@ -681,7 +681,7 @@ protected function complaintShowUploads($complaint = null) } return 0; } - + /** * Checks whether or not this complaint's uploads * can be editted by the current user. @@ -695,7 +695,7 @@ protected function complaintCanEditUploads() } return -1; } - + /** * Checks whether or not this complaint should only * be printed with anonymized data. @@ -710,13 +710,13 @@ protected function condPrintAnonOnly($complaint) } $unPub = $this->getUnPublishedStatusList(); $types = [ 'public', 'pdf' ]; - if (isset($GLOBALS["SL"]->pageView) + if (isset($GLOBALS["SL"]->pageView) && in_array($GLOBALS["SL"]->pageView, $types) && isset($complaint->com_status) && in_array($complaint->com_status, $unPub)) { return 1; } - if (isset($GLOBALS["SL"]->pageView) + if (isset($GLOBALS["SL"]->pageView) && in_array($GLOBALS["SL"]->pageView, $types) && !$this->isPublic()) { return 1; @@ -725,18 +725,18 @@ protected function condPrintAnonOnly($complaint) } /** - * Checks whether or not the incident record indicates + * Checks whether or not the incident record indicates * that the location should be printed. * * @return int */ protected function canPrintIncidentLocation() { - return (isset($this->sessData->dataSets["incidents"]) + return (isset($this->sessData->dataSets["incidents"]) && isset($this->sessData->dataSets["incidents"][0]) && isset($this->sessData->dataSets["incidents"][0]->inc_public) && intVal($this->sessData->dataSets["incidents"][0]->inc_public) == 1 - && in_array($this->sessData->dataSets["complaints"][0]->com_status, + && in_array($this->sessData->dataSets["complaints"][0]->com_status, [200, 201, 202, 203, 204])); } @@ -785,7 +785,7 @@ protected function condPrintOfficerName() } /** - * Checks whether or not the current Officer or Civilian + * Checks whether or not the current Officer or Civilian * name should be printed for the current page load. * * @return int @@ -811,7 +811,7 @@ protected function condPrintName($type = 'user') } return 0; } - + /** * Checks whether or not this complaint should only * be printed in full — though still not sensitive data. @@ -829,7 +829,7 @@ protected function condPrintFullReport() } /** - * Checks whether or not this complainant + * Checks whether or not this complainant * did full transparency. * * @return int @@ -843,7 +843,7 @@ protected function condIsTransparent() } /** - * Checks whether or not this complainant + * Checks whether or not this complainant * did not chose full transparency. * * @return int @@ -855,7 +855,7 @@ protected function condIsNotTransparent() } return 0; } - + /** * Checks whether or not this complaint should only * be printed in full including sensitive data. @@ -864,7 +864,7 @@ protected function condIsNotTransparent() */ protected function condPrintSensitiveReport() { - if (isset($GLOBALS["SL"]->pageView) + if (isset($GLOBALS["SL"]->pageView) && in_array($GLOBALS["SL"]->pageView, ['full', 'full-pdf'])) { if (!$GLOBALS["SL"]->REQ->has('publicView')) { return 1; @@ -872,9 +872,9 @@ protected function condPrintSensitiveReport() } return 0; } - + /** - * Checks whether or not this complaint's + * Checks whether or not this complaint's * publishing is on hold. * * @param App\Models\OPComplaints $complaint @@ -883,7 +883,7 @@ protected function condPrintSensitiveReport() protected function condPrintPublishingOnHold($complaint = null) { if ((!$complaint || $complaint === null) - && isset($this->sessData->dataSets["complaints"]) + && isset($this->sessData->dataSets["complaints"]) && isset($this->sessData->dataSets["complaints"][0])) { $complaint = $this->sessData->dataSets["complaints"][0]; } @@ -901,7 +901,7 @@ protected function condPrintPublishingOnHold($complaint = null) } return 0; } - + /** * Checks whether or not the current user is a * partner investigative agency. @@ -910,13 +910,13 @@ protected function condPrintPublishingOnHold($complaint = null) */ protected function condIsOversightAgency() { - if ($this->v["uID"] > 0 + if ($this->v["uID"] > 0 && $this->v["user"]->hasRole('oversight')) { return 1; } return 0; } - + /** * Checks whether or not this complaint is complete, * or the current user has staff permissions of higher. @@ -928,7 +928,7 @@ protected function condComplaintNotIncompleteOrCurrIsStaff($complaint) { $defSet = 'Complaint Status'; $incDef = $GLOBALS["SL"]->def->getID($defSet, 'Incomplete'); - if (isset($complaint->com_status) + if (isset($complaint->com_status) && intVal($complaint->com_status) != $incDef) { return 1; } @@ -937,9 +937,9 @@ protected function condComplaintNotIncompleteOrCurrIsStaff($complaint) } return 0; } - + /** - * Checks whether or not this partner only helps users + * Checks whether or not this partner only helps users * of OpenPolice.org via in-person clinics. * * @param int $nID @@ -948,7 +948,7 @@ protected function condComplaintNotIncompleteOrCurrIsStaff($complaint) protected function condPartnerDoesOnlyClinics($nID) { $capDef = $GLOBALS["SL"]->def->getID( - 'Organization Capabilities', + 'Organization Capabilities', 'Hosts Clinics for Using OpenPolice.org' ); $caps = []; @@ -960,16 +960,16 @@ protected function condPartnerDoesOnlyClinics($nID) $caps = OPPartnerCapac::where('prt_cap_part_id', $partID) ->get(); } - if (sizeof($caps) == 1 + if (sizeof($caps) == 1 && $caps[0]->prt_cap_capacity == $capDef) { return 1; } return 0; } - + /** - * Checks whether or not this partner - * is actively working with OpenPolice.org, + * Checks whether or not this partner + * is actively working with OpenPolice.org, * or the current URL has the ?test=1 parameter. * * @return int @@ -979,7 +979,7 @@ protected function condPartnerActiveOrTestLink() if (isset($this->sessData->dataSets["partners"]) && isset($this->sessData->dataSets["partners"][0])) { $partner = $this->sessData->dataSets["partners"][0]; - if (isset($partner->part_status) + if (isset($partner->part_status) && intVal($partner->part_status) == 1) { return 1; } @@ -989,16 +989,16 @@ protected function condPartnerActiveOrTestLink() } return 0; } - + /** - * Checks whether or not this complainant is unsure + * Checks whether or not this complainant is unsure * about one or more department involved in this incident. * * @return int */ protected function condNotSureAboutDepartment() { - if (isset($this->sessData->dataSets["departments"]) + if (isset($this->sessData->dataSets["departments"]) && sizeof($this->sessData->dataSets["departments"]) > 0) { foreach ($this->sessData->dataSets["departments"] as $dept) { if (isset($dept->dept_name) diff --git a/src/Controllers/OpenComplaintEmails.php b/src/Controllers/OpenComplaintEmails.php index 8c03de9..eedf163 100644 --- a/src/Controllers/OpenComplaintEmails.php +++ b/src/Controllers/OpenComplaintEmails.php @@ -23,17 +23,17 @@ class OpenComplaintEmails extends OpenPoliceEvents protected function postContactEmail($nID) { $this->postNodeLoadEmail($nID); - if ($GLOBALS["SL"]->REQ->has('n831fld') + if ($GLOBALS["SL"]->REQ->has('n831fld') && trim($GLOBALS["SL"]->REQ->n831fld) != '') { return true; } $emaSubject = $this->postDumpFormEmailSubject(); $emaContent = view('vendor.openpolice.contact-form-email-admin')->render(); $this->sendEmail( - $emaContent, - $emaSubject, - $this->v["emaTo"], - $this->v["emaCC"], + $emaContent, + $emaSubject, + $this->v["emaTo"], + $this->v["emaCC"], $this->v["emaBCC"], [ 'noreply@openpolice.org', 'OpenPolice.org Contact' ] ); @@ -43,24 +43,24 @@ protected function postContactEmail($nID) } $emaID = ((isset($currEmail->email_id)) ? $currEmail->email_id : -3); $this->logEmailSent( - $emaContent, - $emaSubject, - $this->v["toList"], - $emaID, - $this->treeID, + $emaContent, + $emaSubject, + $this->v["toList"], + $emaID, + $this->treeID, $this->coreID, $this->v["uID"] ); $this->manualLogContact( - $nID, - $emaContent, - $emaSubject, - $this->v["toList"], + $nID, + $emaContent, + $emaSubject, + $this->v["toList"], $GLOBALS["SL"]->REQ->n829fld ); return true; } - + protected function postEmailFrom() { if ($this->treeID == 13) { @@ -68,7 +68,7 @@ protected function postEmailFrom() } return []; } - + protected function postDumpFormEmailSubject() { if ($this->treeID == 13 && $GLOBALS["SL"]->REQ->has('n829fld')) { @@ -90,20 +90,20 @@ protected function postDumpFormEmailSubject() } return $ret; } - return $GLOBALS["SL"]->sysOpts["site-name"] . ': ' + return $GLOBALS["SL"]->sysOpts["site-name"] . ': ' . $GLOBALS["SL"]->treeRow->tree_name; } - + protected function processTokenAccessRedirExtra() { return ''; } - + public function emailRecordSwap($emaTxt) { $deptID = -3; $this->loadDeptStuff(); - if (isset($this->sessData->dataSets["links_complaint_dept"]) + if (isset($this->sessData->dataSets["links_complaint_dept"]) && sizeof($this->sessData->dataSets["links_complaint_dept"]) > 0) { foreach ($this->sessData->dataSets["links_complaint_dept"] as $deptLnk) { $this->loadDeptStuff($deptLnk->lnk_com_dept_dept_id); @@ -113,9 +113,10 @@ public function emailRecordSwap($emaTxt) $emaTxt = $this->sendEmailBlurbs($emaTxt, $deptID); return $emaTxt; } - - public function sendEmailBlurbsCustom($emailBody, $deptID = -3) + + public function sendEmailBlurbsCustom($emailBody, $recID = 0) { + $deptID = $recID; $this->loadDeptStuff(); if (isset($this->v["deptID"]) && intVal($this->v["deptID"]) > 0 && $deptID <= 0) { $deptID = $this->v["deptID"]; @@ -123,61 +124,66 @@ public function sendEmailBlurbsCustom($emailBody, $deptID = -3) } $this->emailBlurbsLoadDept($deptID); $this->swapBlurbsInvestigativeAgency($emailBody, $deptID); - + $dynamos = [ - '[{ Complaint ID }]', - '[{ Complaint URL }]', - '[{ Complaint URL Link }]', - '[{ Complaint URL PDF }]', - '[{ Complaint URL PDF Link }]', - '[{ Complaint URL JSON }]', - '[{ Complaint URL JSON Link }]', - '[{ Complainant Name }]', - '[{ Confirmation URL }]', - '[{ Days From Now: 7, mm/dd/yyyy }]', - '[{ Complaint Number of Weeks Old }]', - '[{ Analyst Name }]', - '[{ Analyst Email }]', - '[{ Complaint Department Submission Ways }]', - '[{ Complaint Police Department }]', - '[{ Complaint Police Department URL }]', - '[{ Complaint Police Department URL Link }]', - '[{ Complaint Police Department URL How }]', + '[{ Complaint ID }]', + '[{ Complaint URL }]', + '[{ Complaint URL Link }]', + '[{ Complaint URL PDF }]', + '[{ Complaint URL PDF Link }]', + '[{ Complaint URL JSON }]', + '[{ Complaint URL JSON Link }]', + '[{ Incident Date }]', + '[{ Complainant Name }]', + '[{ Complainant Full Name }]', + '[{ Complainant Email }]', + '[{ Complainant Phone }]', + '[{ Confirmation URL }]', + '[{ Days From Now: 7, mm/dd/yyyy }]', + '[{ Complaint Number of Weeks Old }]', + '[{ Analyst Name }]', + '[{ Analyst Email }]', + '[{ Complaint Department Submission Ways }]', + '[{ Complaint Police Department }]', + '[{ Complaint Police Department URL }]', + '[{ Complaint Police Department URL Link }]', + '[{ Complaint Police Department URL How }]', + '[{ Police Department Address }]', '[{ Police Department State Abbr }]', '[{ Police Department Zip Code }]', - '[{ Dear Primary Investigative Agency }]', - '[{ Complaint Investigability Score & Description }]', - '[{ Complaint Allegation List }]', - '[{ Complaint Allegation List Lower Bold }]', - '[{ Complaint Top Three Allegation List Lower Bold }]', - '[{ Complaint Worst Allegation }]', - '[{ Oversight Complaint Token URL Link }]', + '[{ Dear Primary Investigative Agency }]', + '[{ Complaint Investigability Score & Description }]', + '[{ Complaint Allegation List }]', + '[{ Complaint Allegation List Lower Bold }]', + '[{ Complaint Top Three Allegation List Lower Bold }]', + '[{ Complaint Worst Allegation }]', + '[{ Oversight Complaint Token URL Link }]', '[{ Oversight Complaint Secure MFA }]', - '[{ Complaint Department Complaint PDF }]', - '[{ Complaint Department Complaint Web }]', - '[{ Complaint Officers Reference }]', - '[{ Complaint Auto-Sent For Investigation }]', + '[{ Complaint Department Complaint PDF }]', + '[{ Complaint Department Complaint Web }]', + '[{ Complaint Officers Reference }]', + '[{ Complaint Auto-Sent For Investigation }]', '[{ Flex Article Suggestions Based On Responses }]' ]; - + foreach ($dynamos as $dy) { if (strpos($emailBody, $dy) !== false) { //echo 'found!.. ' . $dy . ' - deptID: ' . $deptID . ',
'; print_r($GLOBALS["SL"]->x["depts"]); echo '
'; exit; $emailBody = $this->swapBlurbsDynamo($emailBody, $dy, $deptID); } } - + $emailBody = str_replace('Hello Complainant,', 'Hello,', $emailBody); $emailBody = str_replace('Hi, [{ Complainant Name }],', 'Hi,', $emailBody); $emailBody = str_replace( - 'Congratulations, [{ Complainant Name }]!', - 'Congratulations!', + 'Congratulations, [{ Complainant Name }]!', + 'Congratulations!', $emailBody ); return $emailBody; } - + protected function emailBlurbsLoadDept($deptID = -3) { if (!isset($GLOBALS["SL"]->x["depts"]) || empty($GLOBALS["SL"]->x["depts"])) { @@ -209,7 +215,7 @@ protected function emailBlurbsLoadDept($deptID = -3) } return true; } - + protected function swapBlurbsInvestigativeAgency(&$emailBody, $deptID = -3) { $swap = '[{ Complaint Investigative Agency }]'; @@ -224,8 +230,8 @@ protected function swapBlurbsInvestigativeAgency(&$emailBody, $deptID = -3) if ($overName == '') { $overName = $d["deptRow"]->dept_name; } - $forDept = (($overName != $d["deptRow"]->dept_name) - ? ' (for the ' . $d["deptRow"]->dept_name . ')' + $forDept = (($overName != $d["deptRow"]->dept_name) + ? ' (for the ' . $d["deptRow"]->dept_name . ')' : (($d["whichOver"] == 'iaRow') ? ' Internal Affairs' : '')); $splits = $GLOBALS["SL"]->mexplode($swap, $emailBody); $emailBody = $splits[0] . $overName . $forDept; @@ -239,13 +245,13 @@ protected function swapBlurbsInvestigativeAgency(&$emailBody, $deptID = -3) } } $emailBody = str_replace( - '[{ Complaint Investigative Agency }]', - '', + '[{ Complaint Investigative Agency }]', + '', $emailBody ); return $emailBody; } - + protected function swapBlurbsSentForInvestigation($deptID = -3) { if (sizeof($GLOBALS["SL"]->x["depts"]) == 1) { @@ -258,7 +264,7 @@ protected function swapBlurbsSentForInvestigation($deptID = -3) $submittedDepts = []; foreach ($GLOBALS["SL"]->x["depts"] as $dID => $dept) { if ($dID != $deptID - && in_array($dID, $compliant) + && in_array($dID, $compliant) && in_array($dID, $submitted)) { $submittedDepts[] = $dept["deptRow"]->dept_name; } @@ -280,14 +286,14 @@ protected function swapBlurbsSentForInvestigation($deptID = -3) } return ''; } - + protected function swapBlurbsDynamo($emailBody, $dy, $deptID) { $swap = $dy; $dyCore = str_replace('[{ ', '', str_replace(' }]', '', $dy)); $url = $GLOBALS["SL"]->sysOpts["app-url"]; switch ($dy) { - case '[{ Complaint ID }]': + case '[{ Complaint ID }]': $swap = $this->corePublicID; break; case '[{ Complaint URL }]': @@ -297,7 +303,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) $swap = $url . '/complaint/read-' . $this->corePublicID; break; case '[{ Complaint URL PDF }]': - $swap = 'corePublicID . '/pdf" target="_blank">Download full complaint as a PDF'; break; case '[{ Complaint URL PDF Link }]': @@ -305,7 +311,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) break; case '[{ Complaint URL XML }]': case '[{ Complaint URL JSON }]': - $swap = 'corePublicID . '/xml" target="_blank">Download full complaint as an XML'; break; case '[{ Complaint URL XML Link }]': @@ -313,24 +319,31 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) $swap = $url . '/complaint/read-' . $this->corePublicID . '/xml'; break; case '[{ Complaint URL XML }]': - $swap = 'corePublicID . '/xml" target="_blank">Download full complaint as an OPC Data File ' . '(XML)'; break; case '[{ Complaint URL XML Link }]': $swap = $url . '/complaint/read-' . $this->corePublicID . '/xml'; break; - case '[{ Complainant Name }]': - if (isset($this->sessData->dataSets["civilians"])) { - $civ = $this->sessData->dataSets["civilians"][0]; - if (isset($civ->civ_person_id) && intVal($civ->civ_person_id) > 0) { - $contact = $this->sessData->getRowById('person_contact', $civ->civ_person_id); - if ($contact && isset($contact->prsn_name_first)) { - $swap = $contact->prsn_name_first; - } - } + case '[{ Incident Date }]': + if (isset($this->sessData->dataSets["incidents"])) { + $date = $this->sessData->dataSets["incidents"][0]->inc_time_start; + $swap = date('n/j/y', strtotime($date)); } - $swap = ' '; + break; + case '[{ Complainant Name }]': + $swap = $this->getComplainantContact('prsn_name_first'); + break; + case '[{ Complainant Full Name }]': + $swap = trim($this->getComplainantContact('prsn_name_first') + . ' ' . $this->getComplainantContact('prsn_name_last')); + break; + case '[{ Complainant Email }]': + $swap = $this->getComplainantContact('prsn_email'); + break; + case '[{ Complainant Phone }]': + $swap = $this->getComplainantContact('prsn_phone_home'); break; case '[{ Days From Now: 7, mm/dd/yyyy }]': $swap = date('n/j/y', mktime(0, 0, 0, date("n"), (7+date("j")), date("Y"))); @@ -350,17 +363,17 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) break; case '[{ Complaint Police Department }]': $swap = '-'; - if (isset($GLOBALS["SL"]->x["depts"]) - && isset($GLOBALS["SL"]->x["depts"][$deptID]) + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_name)) { $swap = $GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_name; } break; case '[{ Complaint Police Department URL }]': - if (isset($GLOBALS["SL"]->x["depts"]) - && isset($GLOBALS["SL"]->x["depts"][$deptID]) + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_slug)) { - $swap = $GLOBALS["SL"]->swapURLwrap($url . '/dept/' + $swap = $GLOBALS["SL"]->swapURLwrap($url . '/dept/' . $GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_slug); } if (trim($swap) == '') { @@ -372,8 +385,8 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) break; case '[{ Complaint Police Department URL Link }]': $swap = '-'; - if (isset($GLOBALS["SL"]->x["depts"]) - && isset($GLOBALS["SL"]->x["depts"][$deptID]) + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_name)) { $swap = $GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_name; } @@ -383,26 +396,34 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) break; case '[{ Complaint Police Department URL How }]': $swap = '-'; - if (isset($GLOBALS["SL"]->x["depts"]) - && isset($GLOBALS["SL"]->x["depts"][$deptID]) + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_slug)) { - $url = $url . '/dept/' + $url = $url . '/dept/' . $GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_slug . '#how'; $swap = $GLOBALS["SL"]->swapURLwrap($url); } break; + case '[{ Police Department Address }]': + $swap = '-'; + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_address_state)) { + $swap = $GLOBALS["SL"]->printRowAddy($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"], 'dept_', true); + } + break; case '[{ Police Department State Abbr }]': $swap = '-'; - if (isset($GLOBALS["SL"]->x["depts"]) - && isset($GLOBALS["SL"]->x["depts"][$deptID]) + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_address_state)) { $swap = $GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_address_state; } break; case '[{ Police Department Zip Code }]': $swap = '-'; - if (isset($GLOBALS["SL"]->x["depts"]) - && isset($GLOBALS["SL"]->x["depts"][$deptID]) + if (isset($GLOBALS["SL"]->x["depts"]) + && isset($GLOBALS["SL"]->x["depts"][$deptID]) && isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_address_zip)) { $swap = $GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_address_zip; } @@ -455,12 +476,12 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) $swap = '#'; } else { $token = $this->createToken( - 'Sensitive', - $this->treeID, - $this->coreID, + 'Sensitive', + $this->treeID, + $this->coreID, $deptUser->id ); - $swap = $url . '/complaint/read-' + $swap = $url . '/complaint/read-' . $this->corePublicID . '/full/t-' . $token; } $swap = '' . $swap . ''; @@ -472,20 +493,20 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) . 'DEPARTMENT IS NOT OPENPOLICE-FRIENDLY *'; } else { $swap = $this->createToken( - 'MFA', - $this->treeID, - $this->coreID, + 'MFA', + $this->treeID, + $this->coreID, $deptUser->id ); } break; case '[{ Complaint Department Complaint PDF }]': - if (isset($GLOBALS["SL"]->x["depts"]) + if (isset($GLOBALS["SL"]->x["depts"]) && isset($deptID) && isset($GLOBALS["SL"]->x["depts"][$deptID])) { $d = $GLOBALS["SL"]->x["depts"]; $which = $d[$deptID]["whichOver"]; - if (isset($d[$deptID][$which]->over_complaint_pdf) + if (isset($d[$deptID][$which]->over_complaint_pdf) && trim($d[$deptID][$which]->over_complaint_pdf) != '') { $swap = ''; if (sizeof($d) > 1) { @@ -499,7 +520,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) $swap .= '
'; } $which = $d[$i]["whichOver"]; - $swap .= $d[$deptID][$which]->over_agnc_name . ': ' + $swap .= $d[$deptID][$which]->over_agnc_name . ': ' . $GLOBALS["SL"]->swapURLwrap($d[$i][$which]->over_complaint_pdf); } } @@ -513,7 +534,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) && isset($GLOBALS["SL"]->x["depts"][$deptID])) { $d = $GLOBALS["SL"]->x["depts"]; $which = $d[$deptID]["whichOver"]; - if (isset($d[$deptID][$which]->over_complaint_web_form) + if (isset($d[$deptID][$which]->over_complaint_web_form) && trim($d[$deptID][$which]->over_complaint_web_form) != '') { $swap = ''; if (sizeof($d) > 1) { @@ -527,7 +548,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) $swap .= '
'; } $currWhich = $d[$i]["whichOver"]; - $swap .= $d[$deptID][$which]->over_agnc_name . ': ' + $swap .= $d[$deptID][$which]->over_agnc_name . ': ' . $GLOBALS["SL"]->swapURLwrap($d[$i][$which]->over_complaint_web_form); } } @@ -540,9 +561,9 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) if (isset($this->v["allUrls"])) { $this->loadRelatedArticles(); $swap = view( - 'vendor.openpolice.nodes.1708-report-flex-articles-email', + 'vendor.openpolice.nodes.1708-report-flex-articles-email', [ - "allUrls" => $this->v["allUrls"], + "allUrls" => $this->v["allUrls"], "showVidUrls" => true ] )->render(); @@ -555,7 +576,7 @@ protected function swapBlurbsDynamo($emailBody, $dy, $deptID) $emailBody = trim(str_replace('Hi ,', 'Hi,', str_replace(' ', ' ', $emailBody))); return str_replace($dy, $swap, $emailBody); } - + public function processEmail($emailID, $deptID = -3) { $email = [ @@ -577,15 +598,15 @@ public function processEmail($emailID, $deptID = -3) $email["rec"] = $e; } } - if ($email["rec"] !== false - && isset($email["rec"]->email_body) + if ($email["rec"] !== false + && isset($email["rec"]->email_body) && trim($email["rec"]->email_body) != '') { $email["body"] = $this->sendEmailBlurbsCustom( - $GLOBALS["SL"]->swapEmailBlurbs($email["rec"]->email_body), + $GLOBALS["SL"]->swapEmailBlurbs($email["rec"]->email_body), $deptID ); $email["subject"] = $this->sendEmailBlurbsCustom( - $GLOBALS["SL"]->swapEmailBlurbs($email["rec"]->email_subject), + $GLOBALS["SL"]->swapEmailBlurbs($email["rec"]->email_subject), $deptID ); } @@ -593,7 +614,21 @@ public function processEmail($emailID, $deptID = -3) } return $email; } - + + protected function getComplainantContact($fld = '') + { + if (isset($this->sessData->dataSets["civilians"])) { + $civ = $this->sessData->dataSets["civilians"][0]; + if (isset($civ->civ_person_id) && intVal($civ->civ_person_id) > 0) { + $contact = $this->sessData->getRowById('person_contact', $civ->civ_person_id); + if ($contact && isset($contact->{ $fld })) { + return $contact->{ $fld }; + } + } + } + return ' '; + } + protected function processTokenAccessEmail() { $ret = ''; @@ -608,15 +643,15 @@ protected function processTokenAccessEmail() if ($emailRow && isset($emailRow->email_body)) { $body = $this->sendEmailBlurbsCustom($emailRow->email_body, $deptID); $subject = $this->sendEmailBlurbsCustom($emailRow->email_subject, $deptID); - //echo '

' . $subject . '

to ' . $user->email + //echo '

' . $subject . '

to ' . $user->email // . '

' . $body . '

'; exit; $this->sendNewEmailSimple( - $body, - $subject, - $user->email, - $emailRow->email_id, - $this->treeID, - $this->coreID, + $body, + $subject, + $user->email, + $emailRow->email_id, + $this->treeID, + $this->coreID, $user->id ); $ret .= ' + @if ($comDate != '')
Incident Date @@ -72,6 +73,7 @@
{{ $comDateAb }}
+ @endif @if ($uID > 0 && ((isset($complaint->{ $coreAbbr . 'user_id' }) && $complaint->{ $coreAbbr . 'user_id' } == $uID) diff --git a/src/Views/inc-documentation-navigation.blade.php b/src/Views/inc-documentation-navigation.blade.php index 4153ecb..3051e2e 100644 --- a/src/Views/inc-documentation-navigation.blade.php +++ b/src/Views/inc-documentation-navigation.blade.php @@ -6,7 +6,7 @@
{{ $category[0] }}
@forelse ($category[1] as $j => $nav)
- {!! $nav[1] !!} @if (sizeof($nav) > 2 && is_array($nav[2]) && sizeof($nav[2]) == 2) @@ -18,10 +18,8 @@ @empty @endforelse -
+ - -




\ No newline at end of file diff --git a/src/Views/nodes/1190-report-basic-stats.blade.php b/src/Views/nodes/1190-report-basic-stats.blade.php new file mode 100644 index 0000000..075e352 --- /dev/null +++ b/src/Views/nodes/1190-report-basic-stats.blade.php @@ -0,0 +1,108 @@ + + + Excel +*/ ?> +

Complaint Basic Statistics

+ +

+ {{ sizeof($coreRecs) }} Completed Complaints
+ + Numbers in grey are the raw record counts. + You should be able to copy and paste these tables directly into a spreadsheet. + +

+


+ +

Table 1: Frequency of Allegations within Complaints

+

+ If relevant to an incident, allegation questions are revealed and required. +

+{!! str_replace( + 'Wrongful Entry', + 'Wrongful Entry*', + $statAllegs->printTblPercHasDat('chrg', $GLOBALS["CUST"]->getAllegIDs('aleg')) +) !!} +pieTblMutliPercHas($fltRow, $fltCol) !!} */ ?> +

+ * Wrongful Entry allegations can only be made by 'Gold-level' complaints + with a stop or detention: {{ number_format($goldStopCnt) }} out of all + completed complaints, or {{ $GLOBALS["SL"]->sigFigs((100*$goldStopPerc), 3) }}%. + Then out of those complaints, some were offered this allegation because + an officer also entered a private home or workplace without permission. +

+ +


+


+ + +

Table 2: Frequency of Complainants 'Going Gold'

+{!! $statEvents->pieTblMutliPercHasHgt('gold', '', 240) !!} + +


+


+ +

Table 3: Frequency of Incident Events within Complaints

+

+ Responding to these questions is optional, and not all complaints + have allegations tied to these types of events within one incident. +

+{!! $statEvents->printTblPercHasDat('gold', $GLOBALS["CUST"]->getAllEventAbbrs('eve')) !!} + + +


+


+ +

Table 4: Frequency of Fully Published Complaints

+

+ +

+{!! $publishTbl->print() !!} +{!! print_r($publishCnts) !!} +{!! $statPublish->printTblPercHasDat('status', ['transpar']) !!} +{!! $statPublish->pieTblMutliPercHasHgt('status', 'transpar', 240) !!} +*/ ?> + +


+


+ +

Table 5: Frequency of Complaints with New Departments

+

+ +

+{!! $newDeptTbl->print() !!} +{!! print_r($deptCnts) !!} +{!! $statDeptsNew->printTblPercHasDat('week2', ['newDept']) !!} +{!! $statDeptsNew->pieTblMutliPercHasHgt('week2', 'newDept', 240) !!} +*/ ?> + +


+


+ +

Table 6: Frequency of Complaints by State

+
+
+

Sorted Alphabetically

+ {!! $statesTbl->print() !!} +
+
+
+

Sorted by Number of Complaints

+ {!! $statesTbl2->print() !!} +
+
+ +


+


+ +

Refresh Report

+ + diff --git a/src/Views/nodes/1225-volun-dept-edit-header.blade.php b/src/Views/nodes/1225-volun-dept-edit-header.blade.php index d8d7950..2d3f226 100644 --- a/src/Views/nodes/1225-volun-dept-edit-header.blade.php +++ b/src/Views/nodes/1225-volun-dept-edit-header.blade.php @@ -3,21 +3,21 @@

{{ $deptRow->dept_name }}

- Accessibility Score: -
{{ + Accessibility Score: +
{{ intVal($deptRow->dept_score_openness) }}
-
+ + diff --git a/src/Views/nodes/1710-report-inc-share.blade.php b/src/Views/nodes/1710-report-inc-share.blade.php index 6cc260b..cb9259b 100644 --- a/src/Views/nodes/1710-report-inc-share.blade.php +++ b/src/Views/nodes/1710-report-inc-share.blade.php @@ -4,40 +4,40 @@

Read, Print, or Download

@if (in_array($GLOBALS["SL"]->pageView, ['pdf', 'full-pdf']))

- + {{ $GLOBALS['SL']->sysOpts['app-url'] }}/complaint/read-{{ $pubID }}

Print Complaint or Save as PDF -
{{ $GLOBALS['SL']->sysOpts['app-url'] +
{{ $GLOBALS['SL']->sysOpts['app-url'] }}/complaint/read-{{ $pubID }}/{{ $viewPrfx }}pdf

- + Download Raw Complaint Data As XML File -
{{ $GLOBALS['SL']->sysOpts['app-url'] +
{{ $GLOBALS['SL']->sysOpts['app-url'] }}/complaint/read-{{ $pubID }}/{{ $viewPrfx }}xml

@else
- @if (isset($published) && $published && isset($GLOBALS["SL"]->pageView) + @if (isset($published) && $published && isset($GLOBALS["SL"]->pageView) && in_array($GLOBALS["SL"]->pageView, ['public', 'full']) && !in_array($GLOBALS["SL"]->pageView, ['pdf', 'full-pdf']))

Share

{!! $GLOBALS["SL"]->twitShareBtn( - $GLOBALS["SL"]->sysOpts["app-url"] . '/complaint/read-' . $pubID, + $GLOBALS["SL"]->sysOpts["app-url"] . '/complaint/read-' . $pubID, 'Check out this police complaint!' ) !!}
@@ -68,10 +68,10 @@ @elseif (in_array($GLOBALS["SL"]->pageView, ['pdf', 'full-pdf']))

What is OpenPolice.org?

- OpenPolice.org is a web app that helps people to prepare, file, and - track police conduct reports. It's designed to serve the needs of - oversight investigators, attorneys, police chiefs, and others working - to advance constitutional and community policing. + OpenPolice.org is a nonprofit website to help people prepare, file, + and track police conduct reports. We designed it to serve the needs + of oversight investigators, attorneys, police chiefs, and others + working to advance constitutional and community policing.

@endif
diff --git a/src/Views/nodes/1712-report-inc-staff-tools-email-form.blade.php b/src/Views/nodes/1712-report-inc-staff-tools-email-form.blade.php index 1bd6f25..dc9f461 100644 --- a/src/Views/nodes/1712-report-inc-staff-tools-email-form.blade.php +++ b/src/Views/nodes/1712-report-inc-staff-tools-email-form.blade.php @@ -10,20 +10,20 @@ -REQ->has('d')) value="0" @else value="{{ intVal($GLOBALS['SL']->REQ->get('d')) }}" @endif > -
@if ($emailID == 12 && $deptID > 0) - @if (!isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_op_compliant) + @if (!isset($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_op_compliant) || intVal($GLOBALS["SL"]->x["depts"][$deptID]["deptRow"]->dept_op_compliant) != 1) @endif @@ -31,19 +31,19 @@ class=" @if (intVal($emailID) > 0) disBlo @else disNon @endif ">
@forelse ($currEmail as $j => $email) - @if ($j > 0)

- @else
+ @if ($j > 0)

+ @else
@endif Send To @if (isset($email['rec']->email_type) && isset($emailsTo[$email['rec']->email_type]) && sizeof($emailsTo[$email['rec']->email_type]) > 0) -
Recipient Email -
@@ -77,34 +77,35 @@ class="form-control form-control-lg" >
CC (in addition to yourself) -
BCC - +
Attachment -
@if ($emailID == 12) @endif Email Body -