Skip to content

Commit

Permalink
Contain PrimaryName properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ioigoume committed Feb 16, 2024
1 parent d8bec8c commit 666b1a3
Show file tree
Hide file tree
Showing 23 changed files with 210 additions and 111 deletions.
2 changes: 1 addition & 1 deletion app/AvailablePlugin/UnixCluster/Model/UnixCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function assign($cluster, $coPersonId) {
$args['conditions']['CoPerson.co_id'] = $cluster['Cluster']['co_id'];
$args['contain'] = array(
'Identifier' => array('conditions' => array('Identifier.status' => SuspendableStatusEnum::Active)),
'PrimaryName'
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))
);

$coPerson = $this->Cluster->Co->CoPerson->find('first', $args);
Expand Down
12 changes: 8 additions & 4 deletions app/Controller/AdHocAttributesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ class AdHocAttributesController extends MVPAController {

public $edit_contains = array(
'CoDepartment',
'CoPersonRole' => array('CoPerson' => 'PrimaryName'),
'CoPersonRole' => array('CoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))
)),
'Organization',
'OrgIdentity' => array('PrimaryName')
'OrgIdentity' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)))
);

public $view_contains = array(
'CoDepartment',
'CoPersonRole' => array('CoPerson' => 'PrimaryName'),
'CoPersonRole' => array('CoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))
)),
'Organization',
'OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource'),
'PrimaryName'),
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))),
'SourceAdHocAttribute'
);

Expand Down
16 changes: 12 additions & 4 deletions app/Controller/AddressesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,25 @@ class AddressesController extends MVPAController {

public $edit_contains = array(
'CoDepartment',
'CoPersonRole' => array('CoPerson' => 'PrimaryName'),
'CoPersonRole' => array(
'CoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
)),
'Organization',
'OrgIdentity' => array('PrimaryName')
'OrgIdentity' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
)
);

public $view_contains = array(
'CoDepartment',
'CoPersonRole' => array('CoPerson' => 'PrimaryName'),
'CoPersonRole' => array('CoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
)),
'Organization',
'OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource'),
'PrimaryName'),
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'SourceAddress'
);

Expand Down
4 changes: 3 additions & 1 deletion app/Controller/AuthenticatorsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ public function status() {

$args = array();
$args['conditions']['CoPerson.id'] = $this->request->params['named']['copersonid'];
$args['contain'][] = 'PrimaryName';
$args['contain'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
);

$this->set('vv_co_person', $this->Authenticator->Co->CoPerson->find('first', $args));
}
Expand Down
20 changes: 15 additions & 5 deletions app/Controller/CoNotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ class CoNotificationsController extends StandardController {
// For rendering views, we need more information than just the various ID numbers
// stored in a petition.
public $view_contains = array(
'SubjectCoPerson' => 'PrimaryName',
'ActorCoPerson' => 'PrimaryName',
'RecipientCoPerson' => 'PrimaryName',
'SubjectCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'ActorCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'RecipientCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'RecipientCoGroup',
'ResolverCoPerson' => 'PrimaryName'
'ResolverCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
)
);

/**
Expand Down Expand Up @@ -199,7 +207,9 @@ public function index() {

$args = array();
$args['conditions']['SubjectCoPerson.id'] = $this->cur_co_person_id;
$args['contain'][] = 'PrimaryName';
$args['contain'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
);

$cop = $this->CoNotification->SubjectCoPerson->find('first', $args);

Expand Down
4 changes: 3 additions & 1 deletion app/Controller/CoOrgIdentityLinksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ function checkWriteDependencies($reqdata, $curdata = null) {
}

// Can't contain OrgIdentity completely since Name is used for display
$this->CoOrgIdentityLink->OrgIdentity->contain('PrimaryName');
$this->CoOrgIdentityLink->OrgIdentity->contain(
array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)))
);
$orgIdentity = $this->CoOrgIdentityLink->OrgIdentity->findById($reqdata['CoOrgIdentityLink']['org_identity_id']);

if(empty($orgIdentity))
Expand Down
38 changes: 28 additions & 10 deletions app/Controller/CoPeopleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,19 @@ class CoPeopleController extends StandardController {
public $delete_contains = array(
'CoPersonRole',
'Name',
'PrimaryName'
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
);

// Use edit_contains to select the associated models we need for canvas.
public $edit_contains = array(
'CoGroupMember' => array('CoGroup'),
'CoNsfDemographic',
'CoOrgIdentityLink' => array('OrgIdentity' => array('Identifier', 'PrimaryName')),
'CoOrgIdentityLink' => array(
'OrgIdentity' => array(
'Identifier',
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
)
),
'CoPersonRole' => array('CoPetition', 'Cou', 'order' => 'CoPersonRole.ordr ASC'),
// This deep nesting will allow us to display the source of the attribute
'EmailAddress' => array('SourceEmailAddress' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource')))),
Expand All @@ -75,7 +80,7 @@ class CoPeopleController extends StandardController {
'EmailAddress',
'Identifier',
'Name',
'PrimaryName',
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
'Url'
);

Expand Down Expand Up @@ -695,7 +700,9 @@ public function generateDisplayKey($c = null) {
// Pull the PrimaryName (we're probably here from an edit directly on canvas)
$args = array();
$args['conditions']['CoPerson.id'] = $this->request->data['CoPerson']['id'];
$args['contain'][] = 'PrimaryName';
$args['contain'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
);

$p = $this->CoPerson->find('first', $args);

Expand Down Expand Up @@ -822,7 +829,9 @@ public function index() {
public function invite() {
$args = array();
$args['conditions']['OrgIdentity.id'] = $this->request->params['named']['orgidentityid'];
$args['contain'] = array('PrimaryName');
$args['contain'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))
);

$orgp = $this->CoPerson->CoOrgIdentityLink->OrgIdentity->find('first', $args);

Expand Down Expand Up @@ -1126,7 +1135,10 @@ public function link($copersonid=null) {
if(!empty($this->request->params['named']['orgidentityid'])) {
$args = array();
$args['conditions']['OrgIdentity.id'] = $this->request->params['named']['orgidentityid'];
$args['contain'] = array('CoPetition', 'PrimaryName');
$args['contain'] = array(
'CoPetition',
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
);

$this->set('vv_org_identity', $this->CoPerson->CoOrgIdentityLink->OrgIdentity->find('first', $args));
$this->set('title_for_layout', _txt('op.link'));
Expand All @@ -1141,7 +1153,9 @@ public function link($copersonid=null) {
if(!empty($copersonid)) {
$args = array();
$args['conditions']['CoPerson.id'] = $copersonid;
$args['contain'] = 'PrimaryName';
$args['contain'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))
);

$this->set('vv_co_person', $this->CoPerson->find('first', $args));
}
Expand Down Expand Up @@ -1362,7 +1376,7 @@ public function provision($id) {
$args = array();
$args['conditions']['CoPerson.id'] = $id;
$args['contain'] = array(
'PrimaryName',
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
'CoGroupMember',
'CoOrgIdentityLink' => array('OrgIdentity' => array('OrgIdentitySourceRecord')),
'Identifier'
Expand Down Expand Up @@ -1451,7 +1465,9 @@ function getPrimaryName($names) {
if(!empty($this->request->params['named']['copersonroleid'])) {
$args = array();
$args['conditions']['CoPersonRole.id'] = $this->request->params['named']['copersonroleid'];
$args['contain']['CoPerson'] = 'PrimaryName';
$args['contain']['CoPerson'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
);
$args['contain'][] = 'CoPetition';

$this->set('vv_co_person_role', $this->CoPerson->CoPersonRole->find('first', $args));
Expand All @@ -1460,7 +1476,9 @@ function getPrimaryName($names) {
if(!empty($this->request->params['named']['tocopersonid'])) {
$args = array();
$args['conditions']['CoPerson.id'] = $this->request->params['named']['tocopersonid'];
$args['contain'][] = 'PrimaryName';
$args['contain'] = array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))
);

$this->set('vv_to_co_person', $this->CoPerson->find('first', $args));
$this->set('title_for_layout', _txt('op.relink'));
Expand Down
14 changes: 7 additions & 7 deletions app/Controller/CoPersonRolesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class CoPersonRolesController extends StandardController {
'Address' => array('SourceAddress' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource')))),
'AdHocAttribute' => array('SourceAdHocAttribute' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource')))),
'CoPerson', // Used to check status recalculation on save
'ManagerCoPerson' => array('PrimaryName'),
'SponsorCoPerson' => array('PrimaryName'),
'ManagerCoPerson' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))),
'SponsorCoPerson' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))),
'TelephoneNumber' => array('SourceTelephoneNumber' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource'))))
);

Expand All @@ -62,8 +62,8 @@ class CoPersonRolesController extends StandardController {
'Address' => array('SourceAddress' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource')))),
'AdHocAttribute' => array('SourceAdHocAttribute' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource')))),
'Cou',
'ManagerCoPerson' => array('PrimaryName'),
'SponsorCoPerson' => array('PrimaryName'),
'ManagerCoPerson' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))),
'SponsorCoPerson' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true))),
'TelephoneNumber' => array('SourceTelephoneNumber' => array('OrgIdentity' => array('OrgIdentitySourceRecord' => array('OrgIdentitySource'))))
);

Expand Down Expand Up @@ -131,7 +131,7 @@ function beforeFilter() {
$args = array();
$args['conditions']['CoPerson.id'] = $copid;
$args['contain'] = array('CoOrgIdentityLink' => array('OrgIdentity'),
'PrimaryName');
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$cop = $this->CoPersonRole->CoPerson->find('all', $args);

Expand Down Expand Up @@ -739,7 +739,7 @@ public function relink($id) {

$args = array();
$args['conditions']['CoPersonRole.id'] = $id;
$args['contain']['CoPerson'] = 'PrimaryName';
$args['contain']['CoPerson'] = array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$copr = $this->CoPersonRole->find('first', $args);

Expand All @@ -752,7 +752,7 @@ public function relink($id) {

$args = array();
$args['conditions']['CoPerson.id'] = filter_var($this->request->data['CoPersonRole']['co_person_id'],FILTER_SANITIZE_SPECIAL_CHARS);
$args['contain'][] = 'PrimaryName';
$args['contain'] = array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$newcop = $this->CoPersonRole->CoPerson->find('first', $args);

Expand Down
4 changes: 2 additions & 2 deletions app/Controller/CoPetitionHistoryRecordsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class CoPetitionHistoryRecordsController extends StandardController {
'modified' => 'asc'
),
'contain' => array(
'ActorCoPerson' => 'PrimaryName'
'ActorCoPerson' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)))
)
);

Expand All @@ -48,7 +48,7 @@ class CoPetitionHistoryRecordsController extends StandardController {
// For rendering views, we need more information than just the various ID numbers
// stored in a petition.
public $view_contains = array(
'ActorCoPerson' => 'PrimaryName'
'ActorCoPerson' => array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)))
);

/**
Expand Down
32 changes: 22 additions & 10 deletions app/Controller/CoPetitionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,24 @@ class CoPetitionsController extends StandardController {
// For rendering views, we need more information than just the various ID numbers
// stored in a petition.
public $view_contains = array(
'ApproverCoPerson' => 'PrimaryName',
'EnrolleeCoPerson' => 'PrimaryName',
'EnrolleeOrgIdentity' => 'PrimaryName',
'PetitionerCoPerson' => 'PrimaryName',
'SponsorCoPerson' => 'PrimaryName',
'ApproverCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'EnrolleeCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'EnrolleeOrgIdentity' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'PetitionerCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'SponsorCoPerson' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'CoPetitionHistoryRecord' => array(
'ActorCoPerson' => array(
'PrimaryName'
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
)
),
'CoEnrollmentFlow' => array(
Expand All @@ -107,7 +117,9 @@ class CoPetitionsController extends StandardController {
'CoInvite',
'Cou',
'OrgIdentitySourceRecord' => array(
'OrgIdentity' => 'PrimaryName',
'OrgIdentity' => array(
'PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)),
),
'OrgIdentitySource'
)
);
Expand Down Expand Up @@ -493,7 +505,7 @@ function beforeRender() {
if(!empty($a[$t.'_co_person_id'])) {
$args = array();
$args['conditions']['CoPerson.id'] = $a[$t.'_co_person_id'];
$args['contain'] = array('PrimaryName');
$args['contain'] = array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$pName = $this->CoPetition->Co->CoPerson->find('first', $args);

Expand Down Expand Up @@ -598,7 +610,7 @@ function beforeRender() {
if($defaultCoPersonId) {
$args = array();
$args['conditions']['CoPerson.id'] = $defaultCoPersonId;
$args['contain'] = array('PrimaryName');
$args['contain'] = array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$this->set('vv_default_sponsor', $this->CoPetition->Co->CoPerson->find('first', $args));
}
Expand All @@ -618,7 +630,7 @@ function beforeRender() {
if($defaultCoPersonId) {
$args = array();
$args['conditions']['CoPerson.id'] = $defaultCoPersonId;
$args['contain'] = array('PrimaryName');
$args['contain'] = array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$this->set('vv_default_manager', $this->CoPetition->Co->CoPerson->find('first', $args));
}
Expand Down
2 changes: 1 addition & 1 deletion app/Controller/CoTermsAndConditionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function review() {
// And also this CO Person
$args = array();
$args['conditions']['CoPerson.id'] = $this->params['named']['copersonid'];
$args['contain'][] = 'PrimaryName';
$args['contain'] = array('PrimaryName' => array('conditions' => array('PrimaryName.primary_name' => true)));

$this->set('vv_co_person', $this->Co->CoPerson->find('first', $args));
}
Expand Down
Loading

0 comments on commit 666b1a3

Please sign in to comment.