Skip to content

Commit

Permalink
Fix Enrollment Flow Step petition preview. Fix CAKEPHP deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Feb 18, 2025
1 parent d966733 commit b3e89e3
Show file tree
Hide file tree
Showing 24 changed files with 88 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,15 @@ public function display(int $petitionId): void
{
$vv_enrollment_atttributes_ids = Hash::extract($this->vv_obj->petition_attributes, '{n}.enrollment_attribute_id');
$vv_enrollment_atttributes_ids = array_unique($vv_enrollment_atttributes_ids);
$vv_enrollment_attributes = [];

$vv_enrollment_attributes = $this->fetchTable('EnrollmentAttributes')
->find()
->where(fn(QueryExpression $exp, Query $q) => $exp->in('id', $vv_enrollment_atttributes_ids))
->order(['ordr' => 'ASC'])
->toArray();
if (!empty($vv_enrollment_atttributes_ids)) {
$vv_enrollment_attributes = $this->fetchTable('EnrollmentAttributes')
->find()
->where(fn(QueryExpression $exp, Query $q) => $exp->in('id', $vv_enrollment_atttributes_ids))
->order(['ordr' => 'ASC'])
->toArray();
}

$this->set('vv_enrollment_attributes', $vv_enrollment_attributes);
$this->set('vv_step', $this->vv_step);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@

declare(strict_types = 1);

if (empty($vv_enrollment_attributes)) {
print $this->element('emptyPetitionFlowStep', [], [
'cache' => '_html_elements',
]);
return;
}

?>

<ul>
Expand Down
38 changes: 22 additions & 16 deletions app/plugins/CoreEnroller/templates/cell/EmailVerifiers/display.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,27 @@

use App\Lib\Enum\VerificationMethodEnum;

if (empty($vv_pv)) {
print $this->element('emptyPetitionFlowStep', [], [
'cache' => '_html_elements',
]);
return;
}

?>

<?php if(!empty($vv_pv)): ?>
<ul>
<?php foreach($vv_pv as $pv): ?>
<li><?= $pv->mail ?>:
<?php if(!empty($pv->verification) && $pv->verification->isVerified()): ?>
<?= __d('result', 'Verifications.status', [
VerificationMethodEnum::getLocalization($pv->verification->method),
$this->Time->nice($pv->verification->verification_time, $viewVars["vv_tz"])
]) ?>
<?php else: ?>
<span class="mr-1 badge bg-warning unverified"><?= __d('field','unverified') ?></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>

<ul>
<?php foreach($vv_pv as $pv): ?>
<li><?= $pv->mail ?>:
<?php if(!empty($pv->verification) && $pv->verification->isVerified()): ?>
<?= __d('result', 'Verifications.status', [
VerificationMethodEnum::getLocalization($pv->verification->method),
$this->Time->nice($pv->verification->verification_time, $viewVars["vv_tz"])
]) ?>
<?php else: ?>
<span class="mr-1 badge bg-warning unverified"><?= __d('field','unverified') ?></span>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
10 changes: 5 additions & 5 deletions app/src/Controller/ApiV2Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function initialize(): void {

public function add() {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -180,7 +180,7 @@ public function calculateRequestedCOID(): ?int {

public function delete($id) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -230,7 +230,7 @@ protected function dispatchIndex(string $mode = 'default') {
}

// $modelsName = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand Down Expand Up @@ -260,7 +260,7 @@ protected function dispatchIndex(string $mode = 'default') {

public function edit($id) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -380,7 +380,7 @@ public function index() {

public function view($id = null) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down
20 changes: 10 additions & 10 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {

public function beforeRender(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

// Views can also inspect the request object to determine the current
// controller and action, but it seems slightly easier to do it once here.
Expand Down Expand Up @@ -223,7 +223,7 @@ public function getCOID(): ?int {
protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool
{
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

// If this action allows unkeyed, asserted primary link IDs, check the query
// string (e.g.: 'add' or 'index' allow matchgrid_id to be passed in)
Expand Down Expand Up @@ -257,7 +257,7 @@ protected function primaryLinkOnGet(string $potentialPrimaryLink): Object|bool
protected function primaryLinkOnPost(string $potentialPrimaryLink): Object|bool
{
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

// Post = add, where we can have a list of objects and nothing in /objects/{id}
// We don't support different primary links across objects, so we throw an error
Expand Down Expand Up @@ -290,7 +290,7 @@ protected function primaryLinkOnPost(string $potentialPrimaryLink): Object|bool
protected function primaryLinkOnPut(): Object|bool
{
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
$param = (int)$this->request->getParam('pass.0');

// Put = edit, so we should look up the parent ID via the object itself
Expand All @@ -313,7 +313,7 @@ protected function primaryLinkOnPut(): Object|bool
protected function populatedPrimaryLink(string $potentialPrimaryLink): Object
{
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $potentialPrimaryLink will be something like 'attribute_collector_id'
// $potentialPrimaryLinkTable will be something like 'CoreEnroller.AttributeCollectors'
$potentialPrimaryLinkTable = $this->$modelsName->getPrimaryLinkTableName($potentialPrimaryLink);
Expand Down Expand Up @@ -351,7 +351,7 @@ protected function populatedPrimaryLink(string $potentialPrimaryLink): Object
protected function primaryLinkLookup(): void
{
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
$availablePrimaryLinks = $this->$modelsName->getPrimaryLinks();

// Iterate over all the potential primary links and pick the appropriate one
Expand Down Expand Up @@ -423,7 +423,7 @@ public function getPrimaryLink(bool $lookup=false): Object
}

// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

$this->cur_pl = new \stdClass();

Expand Down Expand Up @@ -485,7 +485,7 @@ public function getPrimaryLink(bool $lookup=false): Object

protected function getRedirectGoal(string $action): ?string {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

// PrimaryLinkTrait
if(method_exists($this->$modelsName, "getRedirectGoal")) {
Expand Down Expand Up @@ -608,7 +608,7 @@ protected function setCO() {

if(!$coid) {
// $this->name = Models, unless we're in an API call
$modelsName = $this->name;
$modelsName = $this->getName();

$attrs = $this->request->getAttributes();

Expand Down Expand Up @@ -718,7 +718,7 @@ protected function setCO() {

protected function setTZ() {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

// See if we've collected it from the browser in a previous page load. Otherwise,
// use the system default. If the user set a preferred timezone, we'll catch that below.
Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/MVEAController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MVEAController extends StandardController {

public function beforeFilter(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

if(!$this->request->is('restful') && $this->request->getParam('action') != 'deleted') {
// Provide additional hints to BreadcrumbsComponent. This needs to be here
Expand Down Expand Up @@ -139,7 +139,7 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {

public function beforeRender(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// field = model (or model_name)
$fieldName = Inflector::underscore(Inflector::singularize($modelsName));

Expand Down
24 changes: 12 additions & 12 deletions app/src/Controller/StandardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class StandardController extends AppController {

public function add() {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -176,7 +176,7 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {
// XXX can we merge calls ot (eg) getPrimaryLink and populateAutoViewVars here?
public function beforeRender(\Cake\Event\EventInterface $event) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand Down Expand Up @@ -241,7 +241,7 @@ public function beforeRender(\Cake\Event\EventInterface $event) {

public function delete($id) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand Down Expand Up @@ -329,7 +329,7 @@ public function delete($id) {
public function deleted() {
// Set the title when not set at the individual controller
if(empty($this->viewBuilder()->getVar('vv_title'))) {
$modelsName = $this->name;
$modelsName = $this->getName();
$fieldName = Inflector::singularize($modelsName);
if(__d('result', $fieldName . '.deleted') != $fieldName . '.deleted') {
// Use the standard (singular) deleted message for the field when it exists
Expand Down Expand Up @@ -357,7 +357,7 @@ public function deleted() {

public function edit(string $id) {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -569,7 +569,7 @@ public function generateRedirect($entity) {

protected function getFieldTypes() {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand All @@ -592,7 +592,7 @@ protected function getFieldTypes() {

protected function getRequiredFields() {
// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand All @@ -619,7 +619,7 @@ protected function getRequiredFields() {

public function index() {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -660,7 +660,7 @@ public function index() {

protected function populateAutoViewVars(object $obj=null) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand All @@ -681,7 +681,7 @@ protected function populateAutoViewVars(object $obj=null) {

public function provision($id) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down Expand Up @@ -726,7 +726,7 @@ public function provision($id) {

public function unfreeze($id) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand Down Expand Up @@ -757,7 +757,7 @@ public function unfreeze($id) {

public function view($id = null) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;
// $tableName = models
Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/StandardEnrollerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public function calculatePermission(): bool {
if($action == 'dispatch') {
// We already validated the petition state in willHandleAuth

$modelsName = $this->name;
$modelsName = $this->getName();
$modelId = $this->request->getParam('pass.0'); // XXX check if empty

if(!$modelId) {
Expand Down Expand Up @@ -212,7 +212,7 @@ public function willHandleAuth(\Cake\Event\EventInterface $event): string {
// For this, we need the current step's authorization.

// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
$modelId = $this->request->getParam('pass.0');

if(empty($modelId)) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/StandardPluggableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function configure(string $id) {
// potentially many times on an index view for links that may not be used.)

// $this->name = Models (ie: from ModelsTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand Down
4 changes: 2 additions & 2 deletions app/src/Controller/StandardPluginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class StandardPluginController extends StandardController {

public function beforeFilter(\Cake\Event\EventInterface $event) {
// $this->name = Models
$modelsName = $this->name;
$modelsName = $this->getName();

if(!$this->request->is('restful')) {
// Provide additional hints to BreadcrumbsComponent. This needs to be here
Expand Down Expand Up @@ -83,7 +83,7 @@ public function beforeFilter(\Cake\Event\EventInterface $event) {

public function beforeRender(\Cake\Event\EventInterface $event) {
// $this->name = Models (ie: from ModelsTable, eg FileProvisionersTable)
$modelsName = $this->name;
$modelsName = $this->getName();
// $table = the actual table object
$table = $this->$modelsName;

Expand Down
Loading

0 comments on commit b3e89e3

Please sign in to comment.