Skip to content

Initial implementation of BasicAttributeCollector (CFM-415) #231

Merged
merged 1 commit into from Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -25,13 +25,37 @@
msgid "controller.AttributeCollectors"
msgstr "{0,plural,=1{Attribute Collector} other{Attribute Collectors}}"

msgid "controller.BasicAttributeCollectors"
msgstr "{0,plural,=1{Basic Attribute Collector} other{Basic Attribute Collectors}}"

msgid "controller.EnrollmentAttributes"
msgstr "{0,plural,=1{Enrollment Attribute} other{Enrollment Attributes}}"

# These are pseudo-enumerations, only used for fields.inc
msgid "enumeration.DefaultValueValidityType.after"
msgstr "Days After Finalization"

msgid "field.BasicAttributeCollectors.affiliation_type_id"
msgstr "Affiliation Type"

msgid "field.BasicAttributeCollectors.affiliation_type_id.desc"
msgstr "Affiliation assigned to Person Roles created by this Step"

msgid "field.BasicAttributeCollectors.cou_id.desc"
msgstr "If set, Person Roles created by this Step will be placed in this COU"

msgid "field.BasicAttributeCollectors.email_address_type_id"
msgstr "Email Address Type"

msgid "field.BasicAttributeCollectors.email_address_type_id.desc"
msgstr "Type assigned to the Email Address collected by this Step"

msgid "field.BasicAttributeCollectors.name_type_id"
msgstr "Name Type"

msgid "field.BasicAttributeCollectors.name_type_id.desc"
msgstr "Type assigned to the Name collected by this Step"

msgid "field.EnrollmentAttributes.address_required_fields"
msgstr "Required Address Fields"

Expand Down Expand Up @@ -108,4 +132,7 @@ msgid "field.EnrollmentAttributes.url_type_id"
msgstr "URL Type"

msgid "result.attr.saved"
msgstr "Petition Attributes recorded"
msgstr "Petition Attributes recorded"

msgid "result.basicattr.finalized"
msgstr "Name, Email Address, and Person Role created during finalization"
@@ -0,0 +1,107 @@
<?php
/**
* COmanage Registry Basic Attribute Collectors Controller
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry-plugins
* @since COmanage Registry v5.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace CoreEnroller\Controller;

use Cake\ORM\TableRegistry;
use App\Controller\StandardEnrollerController;
use App\Lib\Enum\PetitionStatusEnum;

class BasicAttributeCollectorsController extends StandardEnrollerController {
public $paginate = [
'order' => [
'BasicAttributeCollectors.id' => 'asc'
]
];

/**
* Dispatch an Enrollment Flow Step.
*
* @since COmanage Registry v5.1.0
* @param string $id Attribute Collector ID
*/

public function dispatch(string $id) {
$petition = $this->getPetition();

$CoSettings = TableRegistry::getTableLocator()->get('CoSettings');

$settings = $CoSettings->find()->where(['co_id' => $this->getCOID()])->firstOrFail();

$this->set('vv_permitted_name_fields', $settings->name_permitted_fields_array());
$this->set('vv_required_name_fields', $settings->name_required_fields_array());

if($this->request->is(['post', 'put'])) {

try {
$this->BasicAttributeCollectors->upsert(
id: (int)$id,
petitionId: $petition->id,
// Remove form metadata from the set of attributes we pass to upsert
attributes: array_diff_key($this->request->getData(), ['petition_id' => true, 'token' => true])
);

// On success, indicate the step is completed and generate a redirect
// to the next step

$link = $this->getPrimaryLink(true);

return $this->finishStep(
enrollmentFlowStepId: $link->value,
petitionId: $petition->id,
comment: __d('core_enroller', 'result.attr.saved')
);
}
catch(\Exception $e) {
$this->Flash->error($e->getMessage());
}
}

// Fall through and let the form render

$this->render('/Standard/dispatch');
}

/**
* Display information about this Step.
*
* @since COmanage Registry v5.1.0
* @param string $id Attribute Collector ID
*/

public function display(string $id) {
$petition = $this->getPetition();

$this->set('vv_basic_petition_attribute_set', $this->BasicAttributeCollectors
->BasicPetitionAttributeSets
->find()
->where(['BasicPetitionAttributeSets.petition_id' => $petition->id])
->firstOrFail());
}
}
@@ -0,0 +1,49 @@
<?php
/**
* COmanage Registry Basic Attribute Collector Entity
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry-plugins
* @since COmanage Registry v5.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace CoreEnroller\Model\Entity;

use Cake\ORM\Entity;

class BasicAttributeCollector extends Entity {
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected $_accessible = [
'*' => true,
'id' => false,
'slug' => false,
];
}
@@ -0,0 +1,49 @@
<?php
/**
* COmanage Registry Basic Petition Attribute Set Entity
*
* Portions licensed to the University Corporation for Advanced Internet
* Development, Inc. ("UCAID") under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership.
*
* UCAID licenses this file to you under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @link https://www.internet2.edu/comanage COmanage Project
* @package registry-plugins
* @since COmanage Registry v5.1.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types=1);

namespace CoreEnroller\Model\Entity;

use Cake\ORM\Entity;

class BasicPetitionAttributeSet extends Entity {
/**
* Fields that can be mass assigned using newEntity() or patchEntity().
*
* Note that when '*' is set to true, this allows all unspecified fields to
* be mass assigned. For security purposes, it is advised to set '*' to false
* (or remove it), and explicitly make individual fields accessible as needed.
*
* @var array<string, bool>
*/
protected $_accessible = [
'*' => true,
'id' => false,
'slug' => false,
];
}