fix ajax responses; re-add statistics link to main-domains for customers
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -121,11 +121,13 @@ class Ajax
|
||||
|
||||
public function errorResponse($message, int $response_code = 500)
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
return \Froxlor\Api\Response::jsonErrorResponse($message, $response_code);
|
||||
}
|
||||
|
||||
public function jsonResponse($value, int $response_code = 200)
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
return \Froxlor\Api\Response::jsonResponse($value, $response_code);
|
||||
}
|
||||
|
||||
@@ -197,7 +199,7 @@ class Ajax
|
||||
]);
|
||||
}
|
||||
|
||||
return $items;
|
||||
return $this->jsonResponse($items);
|
||||
} else {
|
||||
return $this->errorResponse('No Newsfeeds available at the moment.');
|
||||
}
|
||||
@@ -210,8 +212,8 @@ class Ajax
|
||||
try {
|
||||
$json_result = \Froxlor\Api\Commands\Froxlor::getLocal($this->userinfo)->checkUpdate();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
echo UI::twig()->render($this->theme . '/misc/version_top.html.twig', $result);
|
||||
exit;
|
||||
$result = UI::twig()->render($this->theme . '/misc/version_top.html.twig', $result);
|
||||
return $this->jsonResponse($result);
|
||||
} catch (Exception $e) {
|
||||
// don't display anything if just not allowed due to permissions
|
||||
if ($e->getCode() != 403) {
|
||||
|
||||
@@ -21,7 +21,6 @@ class Response
|
||||
{
|
||||
public static function jsonResponse($data = null, int $response_code = 200)
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
http_response_code($response_code);
|
||||
|
||||
return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
||||
|
||||
@@ -63,7 +63,16 @@ class Domain
|
||||
|
||||
public static function domainExternalLink(array $attributes)
|
||||
{
|
||||
return '<a href="http://' . $attributes['data'] . '" target="_blank">' . $attributes['data'] . '</a>';
|
||||
$result = '<a href="http://' . $attributes['data'] . '" target="_blank">' . $attributes['data'] . '</a>';
|
||||
// check for statistics if parentdomainid==0 to show stats-link for customers
|
||||
if ((int) UI::getCurrentUser()['adminsession'] == 0 && $attributes['fields']['parentdomainid'] == 0) {
|
||||
$statsapp = 'webalizer';
|
||||
if (Settings::Get('system.awstats_enabled') == '1') {
|
||||
$statsapp = 'awstats';
|
||||
}
|
||||
$result .= ' <a href="http://' . $attributes['data'] . '/' . $statsapp . '" rel="external" title="' . UI::getLng('domains.statstics') . '"><i class="fa-solid fa-chart-line text-secondary"></i></a>';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function canEdit(array $attributes): bool
|
||||
|
||||
Reference in New Issue
Block a user