Skip to content

Commit

Permalink
Recoginze "roles" in contacts
Browse files Browse the repository at this point in the history
Unit Test bootstrap configured by new way
  • Loading branch information
Vitexus committed Nov 20, 2023
1 parent 6594ef5 commit 70f3aa2
Show file tree
Hide file tree
Showing 18 changed files with 238 additions and 148 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -30,3 +30,4 @@ composer.lock
/debian/php-spojenet-abraflexi.debhelper.log
/debian/php-spojenet-abraflexi.substvars
/test/.phpunit.result.cache
/.env
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -18,7 +18,7 @@
"ext-json": "*",
"ext-curl": "*",
"ext-gettext": "*",
"vitexsoftware/ease-core": ">=1.40"
"vitexsoftware/ease-core": ">=1.41"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions debian/changelog
@@ -1,4 +1,4 @@
php-spojenet-abraflexi (2.24.1) UNRELEASED; urgency=medium
php-spojenet-abraflexi (2.25.0) UNRELEASED; urgency=medium

[ Vítězslav Dvořák ]
* ease-core based
Expand Down Expand Up @@ -51,8 +51,9 @@ php-spojenet-abraflexi (2.24.1) UNRELEASED; urgency=medium
* jenkins-Spoje.Net-php-spojenet-abraflexi-84
* jenkins-Spoje.Net-php-spojenet-abraflexi-86
* jenkins-Spoje.Net-php-spojenet-abraflexi-89
* Contact Roles support added

-- vitex <jenkins@vyvojar.spoje.net> Tue, 26 Sep 2023 09:57:02 +0000
-- vitex <info@vitexsoftware.cz> Mon, 20 Nov 2023 21:25:50 +0100

flexipeehp (1.12) experimental; urgency=medium

Expand Down
38 changes: 28 additions & 10 deletions src/AbraFlexi/Adresar.php
Expand Up @@ -35,12 +35,10 @@ class Adresar extends RW
*
* @param string $purpose Purpose - one of Fak|Obj|Nab|Ppt|Skl|Pok
*
* @return string email of primary contact or address email or null
* @return string|null email of primary contact or address email or null
*/
public function getNotificationEmailAddress(string $purpose = '')
{


$email = null;
$emailsRaw = $this->getFlexiData(
$this->getApiURL(),
Expand All @@ -52,12 +50,22 @@ public function getNotificationEmailAddress(string $purpose = '')
$email = $emails['email'];
}
if (array_key_exists('kontakty', $emails) && !empty($emails['kontakty'])) {
$candidates = [];
foreach ($emails['kontakty'] as $kontakt) {
if (array_key_exists('primarni', $kontakt) && ($kontakt['primarni'] == 'true') && strlen(trim($kontakt['email']))) {
$email = $kontakt['email'];
break;
if (strlen($purpose)) {
if ($kontakt['odesilat' . ucfirst($purpose)] == 'true') {
$candidates[] = $kontakt['email'];
}
} else {
if (array_key_exists('primarni', $kontakt) && ($kontakt['primarni'] == 'true') && strlen(trim($kontakt['email']))) {
$candidates = $kontakt['email'];
break;
}
}
}
if (count($candidates)) {
$email = implode(',', $candidates);
}
}
}
return $email;
Expand All @@ -83,12 +91,22 @@ public function getCellPhoneNumber(string $purpose = '')
$mobil = $mobils['mobil'];
}
if (array_key_exists('kontakty', $mobils) && !empty($mobils['kontakty'])) {
foreach ($mobils['kontakty'] as $kontakt) {
if (($kontakt['primarni'] == 'true') && strlen(trim($kontakt['mobil']))) {
$mobil = $kontakt['mobil'];
break;
$candidates = [];
foreach ($emails['kontakty'] as $kontakt) {
if (strlen($purpose)) {
if ($kontakt['odesilat' . ucfirst($purpose)] == 'true') {
$candidates[] = $kontakt['mobil'];
}
} else {
if (array_key_exists('primarni', $kontakt) && ($kontakt['primarni'] == 'true') && strlen(trim($kontakt['mobil']))) {
$candidates = $kontakt['mobil'];
break;
}
}
}
if (count($candidates)) {
$mobil = implode(',', $candidates);
}
}
}
return $mobil;
Expand Down
97 changes: 49 additions & 48 deletions src/AbraFlexi/RO.php
Expand Up @@ -932,7 +932,7 @@ public static function objectToID($object)
{
$resultID = null;
if (
is_object($object) && method_exists($object, '__toString')
is_object($object) && method_exists($object, '__toString')
) {
$resultID = $object->__toString();
} else {
Expand Down Expand Up @@ -1002,6 +1002,7 @@ public function updateApiURL()
}
$this->apiURL .= '.' . $this->format;
}

/*
* Add Default Url params to given url if not overrided
*
Expand Down Expand Up @@ -1243,10 +1244,10 @@ public function parseResponse($responseDecoded, $responseCode)
if (!empty($this->rowCount)) {
$this->responseStats = ['read' => $this->rowCount];
} elseif (
array_key_exists(
$responseEvidence,
$mainResult
)
array_key_exists(
$responseEvidence,
$mainResult
)
) {
$this->responseStats = ['read' => count($mainResult[$responseEvidence])];
} else {
Expand Down Expand Up @@ -1412,10 +1413,10 @@ public function setAction(string $action)
$result = false;
$actionsAvailable = $this->getActionsInfo();
if (
is_array($actionsAvailable) && array_key_exists(
$action,
$actionsAvailable
)
is_array($actionsAvailable) && array_key_exists(
$action,
$actionsAvailable
)
) {
$this->action = $action;
$result = true;
Expand Down Expand Up @@ -1576,10 +1577,10 @@ public function getFlexiData(string $suffix = '', $conditions = null)
$transactions = $this->performRequest($finalUrl, 'GET');
$responseEvidence = $this->getResponseEvidence();
if (
is_array($transactions) && array_key_exists(
$responseEvidence,
$transactions
)
is_array($transactions) && array_key_exists(
$responseEvidence,
$transactions
)
) {
$result = $transactions[$responseEvidence];
if ((count($result) == 1) && empty(current($result))) {
Expand Down Expand Up @@ -1792,7 +1793,7 @@ public function idExists($identifer = null)
[
'detail' => 'custom:' . $this->getKeyColumn(),
$this->getKeyColumn() => $identifer
]
]
);
$this->ignore404($ignorestate);
return ($this->lastResponseCode == 200) && !empty($cands);
Expand Down Expand Up @@ -1869,10 +1870,10 @@ public function getColumnsFromAbraFlexi(
$conditions = [$this->getmyKeyColumn() => $conditions];
case 'array': //Few Conditions
if (
!is_null($indexBy) && !array_key_exists(
$indexBy,
$columnsList
)
!is_null($indexBy) && !array_key_exists(
$indexBy,
$columnsList
)
) {
$columnsList[] = $indexBy;
}
Expand All @@ -1895,10 +1896,10 @@ public function getColumnsFromAbraFlexi(
$conditions['detail'] = $detail;
$flexiData = $this->getFlexiData('', $conditions);
if (
is_string($indexBy) && is_array($flexiData) && array_key_exists(
0,
$flexiData
) && array_key_exists($indexBy, $flexiData[0])
is_string($indexBy) && is_array($flexiData) && array_key_exists(
0,
$flexiData
) && array_key_exists($indexBy, $flexiData[0])
) {
$flexiData = \Ease\Functions::reindexArrayBy($flexiData, $indexBy);
}
Expand Down Expand Up @@ -2262,7 +2263,7 @@ public function getExternalID($want = null)
$ids = $this->getExternalIDs();
if (is_null($want)) {
if (!empty($ids)) {
$extid = is_object($ids) ? (is_array($ids->value) ? current($ids->value) : $ids) : current($ids) ;
$extid = is_object($ids) ? (is_array($ids->value) ? current($ids->value) : $ids) : current($ids);
}
} else {
if (!is_null($ids) && is_array($ids->value)) {
Expand Down Expand Up @@ -2345,10 +2346,10 @@ public function getResponseFormat()
public function unifyResponseFormat($responseBody)
{
if (
!is_array($responseBody) || array_key_exists(
'message',
$responseBody
)
!is_array($responseBody) || array_key_exists(
'message',
$responseBody
)
) { //Unifi response format
$response = $responseBody;
} else {
Expand Down Expand Up @@ -2769,10 +2770,10 @@ public function getInFormat(
$urlParams['report-name'] = $reportName;
}
if (
($this->doCurlRequest(\Ease\Functions::addUrlParams(
$this->apiURL,
$urlParams
), 'GET') == 200)
($this->doCurlRequest(\Ease\Functions::addUrlParams(
$this->apiURL,
$urlParams
), 'GET') == 200)
) {
$response = $this->lastCurlResponse;
}
Expand Down Expand Up @@ -2800,13 +2801,13 @@ public function downloadInFormat(
if ($this->setFormat($format)) {
$downloadTo = $destDir . $this->getEvidence() . '_' . $this->getMyKey() . '.' . $format;
if (
($this->doCurlRequest(empty($reportName) ? $this->apiURL : \Ease\Functions::addUrlParams(
$this->apiURL,
['report-name' => $reportName]
), 'GET') == 200) && (file_put_contents(
$downloadTo,
$this->lastCurlResponse
) !== false)
($this->doCurlRequest(empty($reportName) ? $this->apiURL : \Ease\Functions::addUrlParams(
$this->apiURL,
['report-name' => $reportName]
), 'GET') == 200) && (file_put_contents(
$downloadTo,
$this->lastCurlResponse
) !== false)
) {
$fileOnDisk = $downloadTo;
}
Expand Down Expand Up @@ -2856,7 +2857,7 @@ public function getReportsInfo()
$reports = [];
$reportsRaw = $this->getFlexiData($this->getEvidenceURL() . '/reports');
if (
!empty($reportsRaw) && array_key_exists('reports', $reportsRaw) && !empty($reportsRaw['reports']) && array_key_exists('report', $reportsRaw['reports']) &&
!empty($reportsRaw) && array_key_exists('reports', $reportsRaw) && !empty($reportsRaw['reports']) && array_key_exists('report', $reportsRaw['reports']) &&
!empty($reportsRaw['reports']['report'])
) {
if (\Ease\Functions::isAssoc($reportsRaw['reports']['report'])) {
Expand Down Expand Up @@ -2967,20 +2968,20 @@ public function error500Reporter($errorResponse)
}
$d->close();
if (
(strstr($this->url, '://localhost') || strstr(
$this->url,
'://127.'
)) && file_exists('/var/log/flexibee.log')
(strstr($this->url, '://localhost') || strstr(
$this->url,
'://127.'
)) && file_exists('/var/log/flexibee.log')
) {
$fl = fopen('/var/log/' . 'flexibee.log', 'r');
if ($fl) {
$tracelog = [];
for (
$x_pos = 0, $ln = 0, $output = array(); fseek(
$fl,
$x_pos,
SEEK_END
) !== -1; $x_pos--
$x_pos = 0, $ln = 0, $output = array(); fseek(
$fl,
$x_pos,
SEEK_END
) !== -1; $x_pos--
) {
$char = fgetc($fl);
if ($char === "\n") {
Expand Down

0 comments on commit 70f3aa2

Please sign in to comment.