Skip to content

Commit

Permalink
Fix wrong url id harvest (COmanage#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis authored and arlen committed Oct 14, 2024
1 parent 5781c13 commit 4c1e331
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
29 changes: 15 additions & 14 deletions app/src/Lib/Util/TableUtilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,21 @@ public static function treeTraversalFromId(string $modelName, int $id, array &$r
// Get the Record from the database
$resp = $ModelTable->find()
->where(['id' => $id])
->first()
->toArray();

// Find all the foreign keys and fetch the rest of the tree
foreach($resp as $col => $val) {
if (
$val !== null
&& $col !== $modelName
&& str_ends_with($col, '_id')
) {
$fkModel = StringUtilities::foreignKeyToClassName(($col));
$fk_table = Inflector::underscore($fkModel);
if (\in_array($fk_table, $listOfTables, true)) {
self::treeTraversalFromPrimaryLink($col, $val, $results);
->first()?->toArray();

if ($resp !== null) {
// Find all the foreign keys and fetch the rest of the tree
foreach($resp as $col => $val) {
if (
$val !== null
&& $col !== $modelName
&& str_ends_with($col, '_id')
) {
$fkModel = StringUtilities::foreignKeyToClassName(($col));
$fk_table = Inflector::underscore($fkModel);
if (\in_array($fk_table, $listOfTables, true)) {
self::treeTraversalFromPrimaryLink($col, $val, $results);
}
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions app/src/View/Helper/TabHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,20 +186,16 @@ public function tabBelongsToModelPath(string $tab, string $modelFullName, int &$
*/
public function getCurrentId(string $tabName = null, bool $isNested = false): int
{
$vv_person_id = $this->getView()->get('vv_person_id');
$vv_obj = $this->getView()->get('vv_obj');
$vv_primary_link = $this->getView()->get('vv_primary_link');
$vv_bc_title_links = $this->getView()->get('vv_bc_title_links');
$request = $this->getView()->getRequest();
$curController = $request->getParam('controller');
$curAction = $request->getParam('action');
$plugin = $this->getView()->getPlugin();
$vv_sub_nav_attributes = $this->getView()->get('vv_sub_nav_attributes');
$tab_actions = !$isNested ? $vv_sub_nav_attributes['action'] : $vv_sub_nav_attributes['nested']['action'];
$tabs = !$isNested ? $vv_sub_nav_attributes['tabs'] : $vv_sub_nav_attributes['nested']['tabs'];

$tid = $vv_person_id
?? $request->getQuery($vv_primary_link)
$tid = $request->getQuery($vv_primary_link)
?? $vv_obj->id
?? end($vv_bc_title_links[0]['target']);

Expand Down

0 comments on commit 4c1e331

Please sign in to comment.