Skip to content

Commit

Permalink
Initial implementation of EmailAddress (CFM-14) and Identifier (CFM-15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benn Oshrin committed Jan 26, 2022
1 parent 9ccb9cc commit 7037c3b
Show file tree
Hide file tree
Showing 24 changed files with 920 additions and 20 deletions.
28 changes: 24 additions & 4 deletions app/config/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
"id": {},
"co_id": {},
"address_required_fields": { "type": "string", "size": 160 },
"email_address_default_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" } },
"identifier_default_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" } },
"name_default_type_id": { "type": "integer", "foreignkey": { "table": "types", "column": "id" } },
"name_permitted_fields": { "type": "string", "size": 160 },
"name_required_fields": { "type": "string", "size": 160 }
Expand All @@ -74,7 +76,9 @@
"typeIsDefault will make queries using these columns, but rarely and won't usually have enough rows to need the index"
],
"columns": [ "name_default_type_id" ]
}
},
"co_settings_i3": { "columns": [ "email_address_default_type_id" ] },
"co_settings_i4": { "columns": [ "identifier_default_type_id" ] }
}
},

Expand Down Expand Up @@ -176,14 +180,13 @@
"display_name": { "type": "string", "size": 256 }
},
"indexes": {
"names_i1": { "columns": [ "type_id"] }
"names_i1": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"sourced": true
},

"identifiers": {
"XXX": [ "add index for co_provision_target_id+co_person_id" ],
"columns": {
"id": {},
"identifier": { "type": "string", "size": 512 },
Expand All @@ -194,7 +197,24 @@
"indexes": {
"identifiers_i1": { "columns": [ "identifier", "type_id", "person_id" ] },
"identifiers_i2": { "columns": [ "identifier", "type_id", "external_identity_id" ] },
"identifiers_i3": { "columns": [ "type_id"] }
"identifiers_i3": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"sourced": true
},

"email_addresses": {
"columns": {
"id": {},
"mail": { "type": "string", "size": 256 },
"description": {},
"type_id": {},
"verified": { "type": "boolean" }
},
"indexes": {
"email_addresses_i1": { "columns": [ "mail", "type_id", "person_id" ] },
"email_addresses_i2": { "columns": [ "mail", "type_id", "external_identity_id" ] },
"email_addresses_i3": { "columns": [ "type_id" ] }
},
"mvea": [ "person", "external_identity" ],
"sourced": true
Expand Down
6 changes: 6 additions & 0 deletions app/resources/locales/en_US/controller.po
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ msgstr "{0,plural,=1{COU} other{COUs}}"
msgid "Dashboards"
msgstr "{0,plural,=1{Dashboard} other{Dashboards}}"

msgid "EmailAddresses"
msgstr "{0,plural,=1{Email Address} other{Email Addresses}}"

msgid "ExternalIdentities"
msgstr "{0,plural,=1{External Identity} other{External Identities}}"

msgid "Identifiers"
msgstr "{0,plural,=1{Identifier} other{Identifiers}}"

msgid "Names"
msgstr "{0,plural,=1{Name} other{Names}}"

Expand Down
75 changes: 75 additions & 0 deletions app/resources/locales/en_US/defaultType.po
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,81 @@

# Labels for default types when a new CO is created

msgid "EmailAddresses.delivery"
msgstr "Delivery"

msgid "EmailAddresses.forwarding"
msgstr "Forwarding"

msgid "EmailAddresses.list"
msgstr "Mailing List"

msgid "EmailAddresses.official"
msgstr "Official"

msgid "EmailAddresses.personal"
msgstr "Personal"

msgid "EmailAddresses.preferred"
msgstr "Preferred"

msgid "EmailAddresses.recovery"
msgstr "Recovery"

msgid "Identifiers.badge"
msgstr "Badge"

msgid "Identifiers.enterprise"
msgstr "Enterprise"

msgid "Identifiers.eppn"
msgstr "ePPN"

msgid "Identifiers.eptid"
msgstr "ePTID"

msgid "Identifiers.epuid"
msgstr "ePUID"

msgid "Identifiers.gid"
msgstr "GID"

msgid "Identifiers.mail"
msgstr "Mail"

msgid "Identifiers.national"
msgstr "National"

msgid "Identifiers.network"
msgstr "Network"

msgid "Identifiers.oidcsub"
msgstr "OIDC Sub"

msgid "Identifiers.openid"
msgstr "OpenID"

msgid "Identifiers.orcid"
msgstr "ORCiD"

msgid "Identifiers.provisioningtarget"
msgstr "Provisioning Target"

msgid "Identifiers.reference"
msgstr "Match Reference"

msgid "Identifiers.pairwiseid"
msgstr "SAML Pairwise"

msgid "Identifiers.subjectid"
msgstr "SAML Subject"

msgid "Identifiers.sorid"
msgstr "System of Record"

msgid "Identifiers.uid"
msgstr "UID"

msgid "Names.alternate"
msgstr "Alternate"

Expand Down
18 changes: 18 additions & 0 deletions app/resources/locales/en_US/field.po
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ msgstr "Attribute"
msgid "CoSettings.address_required_fields"
msgstr "Address Required Fields"

msgid "CoSettings.email_address_default_type_id"
msgstr "Default Email Address Type"

msgid "CoSettings.identifier_default_type_id"
msgstr "Default Identifier Type"

msgid "CoSettings.name_default_type_id"
msgstr "Default Name Type"

Expand Down Expand Up @@ -75,12 +81,21 @@ msgstr "Honorific"
msgid "honorific.desc"
msgstr "(Dr, Hon, etc)"

msgid "identifier"
msgstr "Identifier"

msgid "full_name"
msgstr "Full Name"

msgid "language"
msgstr "Language"

msgid "login"
msgstr "Login"

msgid "mail"
msgstr "Email Address"

msgid "middle"
msgstr "Middle"

Expand Down Expand Up @@ -152,3 +167,6 @@ msgstr "Database Value"

msgid "Types.value.desc"
msgstr "Database value for this type, characters must be alphanumeric, dot, or dash"

msgid "verified"
msgstr "Verified"
31 changes: 30 additions & 1 deletion app/src/Command/TransmogrifyCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ class TransmogrifyCommand extends Command {
'elect_strategy_primary_name' => null,
'co_dashboard_id' => null,
'co_theme_id' => null,
'global_search_limit' => null
'global_search_limit' => null,
'person_picker_email_type' => null,
'person_picker_identifier_type' => null,
'person_picker_display_types' => null
]
],
'api_users' => [
Expand Down Expand Up @@ -158,6 +161,20 @@ class TransmogrifyCommand extends Command {
'co_provisioning_target_id' => null,
'organization_id' => null
]
],
'email_addresses' => [
'source' => 'cm_email_addresses',
'displayField' => 'id',
'booleans' => [ 'verified' ],
'fieldMap' => [
'co_person_id' => 'person_id',
'org_identity_id' => 'external_identity_id',
'type_id' => '&map_email_type',
'type' => null,
// XXX temporary until tables are migrated
'co_department_id' => null,
'organization_id' => null
]
]
];

Expand Down Expand Up @@ -498,6 +515,18 @@ protected function mapFields(string $table, array &$row) {
}
}

/**
* Map an email type string to a foreign key.
*
* @since COmanage Registry v5.0.0
* @param array $row Row of table data (ignored)
* @return int type_id
*/

protected function map_email_type(array $row) {
return $this->map_type($row, 'EmailAddresses.type', $this->findCoId($row));
}

/**
* Map an Extended Type attribute name for model name changes.
*
Expand Down
2 changes: 1 addition & 1 deletion app/src/Controller/Component/RegistryAuthComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public function calculatePermissionsForView(string $action, ?int $id=null): arra
* @return string The authenticated user identifier or false if no authenticated user
*/

public function getAuthenticatedUser(): string {
public function getAuthenticatedUser(): ?string {
return $this->authenticatedUser;
}

Expand Down
64 changes: 64 additions & 0 deletions app/src/Controller/EmailAddressesController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* COmanage Registry Email Addresses 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
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

namespace App\Controller;

// XXX not doing anything with Log yet
use Cake\Log\Log;
use Cake\ORM\TableRegistry;

class EmailAddressesController extends MVEAController {
public $pagination = [
'order' => [
'EmailAddresses.mail' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @since COmanage Registry v5.0.0
* @param EventInterface $event Cake Event
* @return \Cake\Http\Response HTTP Response
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
if(!$this->request->is('restful')) {
// XXX maybe $CoSettings should be available via AppController, like $this->getCOID()?
$CoSettings = TableRegistry::getTableLocator()->get('CoSettings');

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

// XXX move this into MVEAController or a trait
$this->set('vv_default_type', $settings->email_address_default_type_id);
}

return parent::beforeRender($event);
}
}
64 changes: 64 additions & 0 deletions app/src/Controller/IdentifiersController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* COmanage Registry Identifiers 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
* @since COmanage Registry v5.0.0
* @license Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/

declare(strict_types = 1);

namespace App\Controller;

// XXX not doing anything with Log yet
use Cake\Log\Log;
use Cake\ORM\TableRegistry;

class IdentifiersController extends MVEAController {
public $pagination = [
'order' => [
'Identifiers.identifier' => 'asc'
]
];

/**
* Callback run prior to the request render.
*
* @since COmanage Registry v5.0.0
* @param EventInterface $event Cake Event
* @return \Cake\Http\Response HTTP Response
*/

public function beforeRender(\Cake\Event\EventInterface $event) {
if(!$this->request->is('restful')) {
// XXX maybe $CoSettings should be available via AppController, like $this->getCOID()?
$CoSettings = TableRegistry::getTableLocator()->get('CoSettings');

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

// XXX move this into MVEAController or a trait
$this->set('vv_default_type', $settings->identifier_default_type_id);
}

return parent::beforeRender($event);
}
}
Loading

0 comments on commit 7037c3b

Please sign in to comment.