MERGE_UAT_BUG_FIXES
This commit is contained in:
commit
9d7dee0714
@ -2406,6 +2406,36 @@ class EmployeeRestController extends AdminController
|
||||
// }
|
||||
// }
|
||||
|
||||
private function hasValidClientLogo(?string $logo): bool
|
||||
{
|
||||
if ($logo === null || trim($logo) === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$path = parse_url(trim($logo), PHP_URL_PATH) ?? trim($logo);
|
||||
$filename = basename(rtrim($path, '/'));
|
||||
|
||||
return $filename !== '' && strcasecmp($filename, 'logo') !== 0;
|
||||
}
|
||||
|
||||
private function getPreClientLogoUrl($preClientId): string
|
||||
{
|
||||
if (is_string($preClientId) && preg_match('/^[a-f0-9]{32}$/i', $preClientId)) {
|
||||
$preClient = $this->clientModel->where('MD5(id)', $preClientId)->first();
|
||||
} else {
|
||||
$preClient = $this->clientModel->where('id', $preClientId)->first();
|
||||
}
|
||||
|
||||
$logoFilename = $preClient['client_logo'] ?? '';
|
||||
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
|
||||
|
||||
if (!empty($logoFilename) && file_exists($logoPath)) {
|
||||
return base_url() . 'public/uploads/logo/' . $logoFilename;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getClientDetails()
|
||||
{
|
||||
try {
|
||||
@ -2430,18 +2460,8 @@ class EmployeeRestController extends AdminController
|
||||
&& !empty($postData['data']['client'])
|
||||
) {
|
||||
$postLogo = $postData['data']['client']['client_logo'] ?? '';
|
||||
if (empty($postLogo)) {
|
||||
if (is_string($pre_client_id) && preg_match('/^[a-f0-9]{32}$/i', $pre_client_id)) {
|
||||
$preClient = $this->clientModel->where('MD5(id)', $pre_client_id)->first();
|
||||
} else {
|
||||
$preClient = $this->clientModel->where('id', $pre_client_id)->first();
|
||||
}
|
||||
|
||||
$logoFilename = $preClient['client_logo'] ?? '';
|
||||
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
|
||||
if (!empty($logoFilename) && file_exists($logoPath)) {
|
||||
$postData['data']['client']['client_logo'] = base_url() . 'public/uploads/logo/' . $logoFilename;
|
||||
}
|
||||
if (!$this->hasValidClientLogo($postLogo)) {
|
||||
$postData['data']['client']['client_logo'] = $this->getPreClientLogoUrl($pre_client_id);
|
||||
}
|
||||
|
||||
return $this->respond($postData, 200);
|
||||
@ -2458,11 +2478,7 @@ class EmployeeRestController extends AdminController
|
||||
}
|
||||
|
||||
if ($client) {
|
||||
$logoFilename = $client['client_logo'] ?? '';
|
||||
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
|
||||
$client['client_logo'] = (!empty($logoFilename) && file_exists($logoPath))
|
||||
? base_url() . 'public/uploads/logo/' . $logoFilename
|
||||
: '';
|
||||
$client['client_logo'] = $this->getPreClientLogoUrl($pre_client_id);
|
||||
|
||||
$clientPolicy = $this->clientPolicyModel
|
||||
->where('client_id', $client['id'] ?? null)
|
||||
@ -2488,7 +2504,19 @@ class EmployeeRestController extends AdminController
|
||||
'client_id' => $post_client_id,
|
||||
'client_branch_id' => $post_branch_id
|
||||
];
|
||||
return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
|
||||
$postResponse = $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
|
||||
$postData = is_string($postResponse) ? json_decode($postResponse, true) : null;
|
||||
|
||||
if (
|
||||
is_array($postData)
|
||||
&& !empty($postData['data']['client'])
|
||||
&& !$this->hasValidClientLogo($postData['data']['client']['client_logo'] ?? '')
|
||||
) {
|
||||
$postData['data']['client']['client_logo'] = '';
|
||||
return $this->respond($postData, 200);
|
||||
}
|
||||
|
||||
return $postResponse;
|
||||
}
|
||||
|
||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user