Skip to content

Commit

Permalink
Initial commit for manual editing of matchgrid entries (CO-1681) and …
Browse files Browse the repository at this point in the history
…constrained reference identifier selection (CO-1753)
  • Loading branch information
Benn Oshrin committed Feb 17, 2020
1 parent 597892d commit 10049c2
Show file tree
Hide file tree
Showing 21 changed files with 865 additions and 112 deletions.
54 changes: 18 additions & 36 deletions app/src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,44 +252,19 @@ protected function setMatchgrid() {
// Try to find the requested matchgrid
$mgid = null;

if($this->request->is('get')) {
// If this action allows unkeyed, asserted primary link IDs, check the query
// string (eg: 'add' or 'index' allow matchgrid_id to be passed in), and
// possibly dereference it if the primary key is not matchgrid_id.
if($this->$modelsName->allowUnkeyedPrimaryLink($this->request->getParam('action'))) {
if($link['linkattr'] == 'matchgrid_id') {
// Simply accept the passed matchgrid ID
$mgid = $this->request->getQuery('matchgrid_id');
} else {
// We already have the primary link object in a viewvar

$plObj = $this->viewVars['vv_primary_link_obj'];

if(!empty($plObj->matchgrid_id)) {
$mgid = $plObj->matchgrid_id;
}
}
} elseif($this->$modelsName->allowLookupPrimaryLink($this->request->getParam('action'))) {
// Try to map the requested object ID
$param = (int)$this->request->getParam('pass.0');

if(!empty($param)) {
$mgid = $this->$modelsName->calculateMatchgridId($param);
}
}
} elseif($this->request->is('post') || $this->request->is('put')) {
// If this action allows unkeyed, asserted primary link IDs, check the query
// string (eg: 'add' or 'index' allow matchgrid_id to be passed in), and
// possibly dereference it if the primary key is not matchgrid_id.
if($this->$modelsName->allowUnkeyedPrimaryLink($this->request->getParam('action'))) {
if($link['linkattr'] == 'matchgrid_id') {
// Simply accept the passed matchgrid ID
if(!empty($this->request->getData('matchgrid_id'))) {
$mgid = $this->request->getData('matchgrid_id');
} elseif(!empty($this->request->getData($modelName . ".matchgrid_id"))) {
$mgid = $this->request->getData($modelName . ".matchgrid_id");
} elseif($this->$modelsName->allowLookupPrimaryLink($this->request->getParam('action'))) {
// Try to map the requested object ID (this is probably a delete, so no attribute in post body)
$param = (int)$this->request->getParam('pass.0');

if(!empty($param)) {
$mgid = $this->$modelsName->calculateMatchgridId($param);
if($this->request->is('get')) {
$mgid = $this->request->getQuery('matchgrid_id');
} elseif($this->request->is('post') || $this->request->is('put')) {
if(!empty($this->request->getData('matchgrid_id'))) {
$mgid = $this->request->getData('matchgrid_id');
} elseif(!empty($this->request->getData($modelName . ".matchgrid_id"))) {
$mgid = $this->request->getData($modelName . ".matchgrid_id");
}
}
} else {
Expand All @@ -301,6 +276,13 @@ protected function setMatchgrid() {
$mgid = $plObj->matchgrid_id;
}
}
} elseif($this->$modelsName->allowLookupPrimaryLink($this->request->getParam('action'))) {
// Try to map the requested object ID
$param = (int)$this->request->getParam('pass.0');

if(!empty($param)) {
$mgid = $this->$modelsName->calculateMatchgridId($param);
}
}

if(!$mgid && !$this->$modelsName->allowEmptyMatchgrid()) {
Expand Down
Loading

0 comments on commit 10049c2

Please sign in to comment.