-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polish on survey and core admin tools
Many survey aspects polished quite a bit, and code files organized and cleaned up ever more.
- Loading branch information
Morgan Lesko
authored and
Morgan Lesko
committed
Feb 11, 2019
1 parent
648d21d
commit f43a49d
Showing
59 changed files
with
6,030 additions
and
5,391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<?php | ||
namespace OpenPolice\Controllers; | ||
|
||
use DB; | ||
use Auth; | ||
use App\Models\SLEmailed; | ||
use OpenPolice\Controllers\OpenSessDataOverride; | ||
|
||
class OpenComplaintConditions extends OpenSessDataOverride | ||
{ | ||
// CUSTOM={OnlyIfNoAllegationsOtherThan:WrongStop,Miranda,PoliceRefuseID] | ||
protected function checkNodeConditionsCustom($nID, $condition = '') | ||
{ | ||
if ($condition == '#VehicleStop') { // could be replaced by OR functionality | ||
if (isset($this->sessData->dataSets["Scenes"]) && sizeof($this->sessData->dataSets["Scenes"]) > 0) { | ||
if (isset($this->sessData->dataSets["Scenes"][0]->ScnIsVehicle) | ||
&& trim($this->sessData->dataSets["Scenes"][0]->ScnIsVehicle) == 'Y') { | ||
return 1; | ||
} | ||
if (isset($this->sessData->dataSets["Scenes"][0]->ScnIsVehicleAccident) | ||
&& trim($this->sessData->dataSets["Scenes"][0]->ScnIsVehicleAccident) == 'Y') { | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} elseif ($condition == '#LawyerInvolved') { | ||
if ((isset($this->sessData->dataSets["Complaints"][0]->ComAttorneyHas) | ||
&& in_array(trim($this->sessData->dataSets["Complaints"][0]->ComAttorneyHas), ['Y', '?'])) | ||
|| (isset($this->sessData->dataSets["Complaints"][0]->ComAttorneyWant) | ||
&& in_array(trim($this->sessData->dataSets["Complaints"][0]->ComAttorneyWant), ['Y', '?']))) { | ||
return 1; | ||
} | ||
if ((isset($this->sessData->dataSets["Complaints"][0]->ComAnyoneCharged) | ||
&& in_array(trim($this->sessData->dataSets["Complaints"][0]->ComAnyoneCharged), ['Y', '?'])) | ||
&& (!isset($this->sessData->dataSets["Complaints"][0]->ComAllChargesResolved) | ||
|| trim($this->sessData->dataSets["Complaints"][0]->ComAllChargesResolved) != 'Y')) { | ||
return 1; | ||
} | ||
if (isset($this->sessData->dataSets["Complaints"][0]->ComAnyoneCharged) | ||
&& trim($this->sessData->dataSets["Complaints"][0]->ComAnyoneCharged) == 'N' | ||
&& isset($this->sessData->dataSets["Complaints"][0]->ComFileLawsuit) | ||
&& trim($this->sessData->dataSets["Complaints"][0]->ComFileLawsuit) == 'Y') { | ||
return 1; | ||
} | ||
return 0; | ||
} elseif ($condition == '#NoSexualAllegation') { | ||
$noSexAlleg = true; | ||
if (isset($this->sessData->dataSets["Allegations"]) | ||
&& sizeof($this->sessData->dataSets["Allegations"]) > 0) { | ||
foreach ($this->sessData->dataSets["Allegations"] as $alleg) { | ||
if (in_array($alleg->AlleType, [ | ||
$GLOBALS["SL"]->def->getID('Allegation Type', 'Sexual Assault'), | ||
$GLOBALS["SL"]->def->getID('Allegation Type', 'Sexual Harassment') | ||
])) { | ||
$noSexAlleg = false; | ||
} | ||
} | ||
} | ||
return ($noSexAlleg) ? 1 : 0; | ||
} elseif ($condition == '#IncidentHasAddress') { | ||
if (isset($this->sessData->dataSets["Incidents"]) | ||
&& isset($this->sessData->dataSets["Incidents"][0]->IncAddress) | ||
&& trim($this->sessData->dataSets["Incidents"][0]->IncAddress) != '') { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} elseif ($condition == '#HasArrestOrForce') { | ||
if ($this->sessData->dataHas('Arrests') || $this->sessData->dataHas('Force')) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} elseif ($condition == '#CivHasForce') { | ||
if (isset($GLOBALS["SL"]->closestLoop["itemID"])) { | ||
return $this->chkCivHasForce($GLOBALS["SL"]->closestLoop["itemID"]); | ||
} | ||
return 0; | ||
} elseif ($condition == '#HasForceHuman') { | ||
$ret = 0; | ||
if (isset($this->sessData->dataSets["Civilians"]) && sizeof($this->sessData->dataSets["Civilians"]) > 0) { | ||
foreach ($this->sessData->dataSets["Civilians"] as $civ) { | ||
if ($civ->CivRole == 'Victim' && $this->chkCivHasForce($civ->CivID) == 1) { | ||
$ret = 1; | ||
} | ||
} | ||
} | ||
return $ret; | ||
} elseif ($condition == '#HasInjury') { | ||
if (isset($this->sessData->dataSets["Civilians"]) && sizeof($this->sessData->dataSets["Civilians"]) > 0) { | ||
foreach ($this->sessData->dataSets["Civilians"] as $civ) { | ||
if ($civ->CivRole == 'Victim' && isset($civ->CivHasInjury) && trim($civ->CivHasInjury) == 'Y') { | ||
return 1; | ||
} | ||
} | ||
} | ||
return 0; | ||
} elseif ($condition == '#MedicalCareNotYou') { | ||
$civ = $this->sessData->getDataBranchRow('Civilians'); | ||
if ($civ && isset($civ->CivIsCreator) && trim($civ->CivIsCreator) == 'Y') { | ||
return 0; | ||
} | ||
} elseif ($condition == '#Property') { | ||
$search = $this->sessData->getChildRow('EventSequence', $GLOBALS["SL"]->closestLoop["itemID"], 'Searches'); | ||
if ((isset($search->SrchSeized) && trim($search->SrchSeized) == 'Y') | ||
|| (isset($search->SrchDamage) && trim($search->SrchDamage) == 'Y')) { | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} elseif ($condition == '#EmailConfirmSentToday') { | ||
if (isset($this->v["user"]) && isset($this->v["user"]->id)) { | ||
$cutoff = date("Y-m-d H:i:s", | ||
mktime(date("H"), date("i"), date("s"), date("n"), date("j")-1, date("Y"))); | ||
$chk = SLEmailed::where('EmailedEmailID', 1) | ||
->where('EmailedFromUser', $this->v["user"]->id) | ||
->where('created_at', '>', $cutoff) | ||
->get(); | ||
if ($chk->isNotEmpty()) { | ||
return 1; | ||
} | ||
} | ||
return 0; | ||
} elseif ($condition == '#HasUploads') { | ||
$uploads = $this->getUploadsMultNodes($this->cmplntUpNodes, $this->v["isAdmin"], $this->v["isOwner"]); | ||
if ($uploads && sizeof($uploads) > 0) { | ||
return 1; | ||
} | ||
return 0; | ||
} elseif ($condition == '#PrintAnonOnly') { | ||
if (isset($GLOBALS["SL"]->x["pageView"]) && in_array($GLOBALS["SL"]->x["pageView"], ['public', 'pdf']) | ||
&& isset($this->sessData->dataSets["Complaints"][0]->ComStatus) | ||
&& in_array(trim($this->sessData->dataSets["Complaints"][0]->ComStatus), | ||
$this->getUnPublishedStatusList())) { | ||
return 1; | ||
} | ||
if (isset($GLOBALS["SL"]->x["pageView"]) && in_array($GLOBALS["SL"]->x["pageView"], ['public', 'pdf']) | ||
&& isset($this->sessData->dataSets["Complaints"][0]->ComPrivacy) | ||
&& $this->sessData->dataSets["Complaints"][0]->ComPrivacy | ||
!= $GLOBALS["SL"]->def->getID('Privacy Types', 'Submit Publicly')) { | ||
return 1; | ||
} | ||
return 0; | ||
} elseif ($condition == '#PrintSensitiveReport') { | ||
if (isset($GLOBALS["SL"]->x["pageView"]) && in_array($GLOBALS["SL"]->x["pageView"], ['full', 'full-pdf'])) { | ||
return 1; | ||
} | ||
return 0; | ||
} elseif ($condition == '#IsOversightAgency') { | ||
return (($this->v["uID"] > 0 && $this->v["user"]->hasRole('oversight')) ? 1 : 0); | ||
} | ||
return -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.