Skip to content

Commit

Permalink
Feature/p#119563 link address (#944)
Browse files Browse the repository at this point in the history
* remove unset(id), hide on detail

* add Function to get Addresslink

* fix test

* add return empty string when no id found

---------

Co-authored-by: Sascha Vogl <s.vogl@onoffice.com>
  • Loading branch information
Vogl01 and Sascha Vogl authored Nov 8, 2024
1 parent b316305 commit 8bcc17d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
7 changes: 4 additions & 3 deletions plugin/AddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,6 @@ private function fillAddressesById(array $records)
$elements = $address['elements'];

$additionalContactData = $this->collectAdditionalContactData($elements);
unset($elements['id']);
$this->_addressesById[$address['id']] = array_merge($elements, $additionalContactData);
}
}
Expand Down Expand Up @@ -580,8 +579,10 @@ public function generateImageAlt(int $addressId): string
public function getAddressLink(string $addressId): string
{
$pageId = $this->_pEnvironment->getDataAddressDetailViewHandler()
->getAddressDetailView()->getPageId();

->getAddressDetailView()->getPageId();
if($pageId == 0) {
return "";
}
$currentAddress = $this->getAddressById($addressId);
$firstName = $currentAddress['Vorname'] ?? '';
$lastName = $currentAddress['Name'] ?? '';
Expand Down
10 changes: 9 additions & 1 deletion plugin/EstateDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,5 +330,13 @@ public function getShowEstateMarketingStatus(): bool
{
return $this->getDataView()->getShowStatus();
}

/**
* Returns addresslink for given addressid
* @param string $id
* @return string
*/
public function getAddressLink(string $id) : string
{
return $this->getEnvironment()->getAddressList()->getAddressLink($id);
}
}
2 changes: 1 addition & 1 deletion templates.dist/address/default_detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<div class="oo-address-fieldlist">
<?php
foreach ($escapedValues as $field => $value) {
if (in_array($field, $addressName) || empty($value)) {
if (in_array($field, $addressName) || empty($value) || $field == 'id') {
continue;
}
echo '<div class="oo-address-field">';
Expand Down
2 changes: 2 additions & 0 deletions tests/TestClassAddressList.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ class TestClassAddressList
'01234567890',
'01122334455',
],
'id' => 13
),
37 => array(
'Name' => 'Fleißig',
'KdNr' => 12,
'Vorname' => 'Heinrich',
'id' => 37
),
];

Expand Down

0 comments on commit 8bcc17d

Please sign in to comment.