Make widgets disappear if the user doesn't have permission to use them
This commit is contained in:
parent
14f401f355
commit
be892b007d
@ -12,4 +12,9 @@ $APPS["inventory_link"]["icon"] = "cubes";
|
||||
$APPS["inventory_link"]["type"] = "teal";
|
||||
$content = "<p class='mobile-app-hide'>" . lang("open inventory system", false) . '</p><a href="' . INVENTORY_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["inventory_link"]["content"] = $content;
|
||||
|
||||
require_once __DIR__ . "/../lib/login.php";
|
||||
if (account_has_permission($_SESSION['username'], "INV_VIEW") !== true) {
|
||||
unset($APPS['inventory_link']);
|
||||
}
|
||||
?>
|
@ -1,10 +1,12 @@
|
||||
<?php
|
||||
|
||||
dieifnotloggedin();
|
||||
require_once __DIR__ . "/../lib/login.php";
|
||||
addMultiLangStrings(["en_us" => [
|
||||
"qwikclock" => "QwikClock",
|
||||
"punch in" => "Punch in",
|
||||
"punch out" => "Punch out"
|
||||
"punch out" => "Punch out",
|
||||
"permission denied" => "You do not have permission to do that."
|
||||
]
|
||||
]);
|
||||
$APPS["qwikclock_inout"]["i18n"] = TRUE;
|
||||
@ -12,6 +14,9 @@ $APPS["qwikclock_inout"]["title"] = "qwikclock";
|
||||
$APPS["qwikclock_inout"]["icon"] = "clock-o";
|
||||
$APPS["qwikclock_inout"]["type"] = "blue";
|
||||
$content = "";
|
||||
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
|
||||
if (!is_empty($_GET['qwikclock']) && ($_GET['qwikclock'] === "punchin" || $_GET['qwikclock'] === "punchout")) {
|
||||
try {
|
||||
$client = new GuzzleHttp\Client();
|
||||
@ -28,6 +33,10 @@ if (!is_empty($_GET['qwikclock']) && ($_GET['qwikclock'] === "punchin" || $_GET[
|
||||
} else {
|
||||
$content = "<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . $resp['msg'] . "</div>";
|
||||
}
|
||||
} catch (ClientException $e) {
|
||||
if ($e->getResponse()->getStatusCode() == 403) {
|
||||
$content = "<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . lang("permission denied", false) . "</div>";
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$content = "<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\">×</button>" . lang("error loading widget", false) . " " . $e->getMessage() . "</div>";
|
||||
}
|
||||
@ -40,4 +49,9 @@ $content .= <<<END
|
||||
END;
|
||||
$content .= '<br /><a href="' . QWIKCLOCK_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["qwikclock_inout"]["content"] = $content;
|
||||
|
||||
|
||||
if (account_has_permission($_SESSION['username'], "QWIKCLOCK") !== true) {
|
||||
unset($APPS['qwikclock_inout']);
|
||||
}
|
||||
?>
|
@ -4,7 +4,8 @@ dieifnotloggedin();
|
||||
|
||||
use Endroid\QrCode\QrCode;
|
||||
|
||||
addMultiLangStrings(["en_us" => [
|
||||
if (MOBILE_ENABLED) {
|
||||
addMultiLangStrings(["en_us" => [
|
||||
"sync mobile" => "Sync Mobile App",
|
||||
"scan sync qrcode" => "Scan this code with the mobile app or enter the code manually.",
|
||||
"sync explained" => "Access your account and apps on the go. Use a sync code to securely connect your phone or tablet to Portal with the Netsyms Business mobile app.",
|
||||
@ -13,18 +14,18 @@ addMultiLangStrings(["en_us" => [
|
||||
"no active codes" => "No active codes.",
|
||||
"done adding sync code" => "Done adding code"
|
||||
]
|
||||
]);
|
||||
]);
|
||||
|
||||
$APPS["sync_mobile"]["title"] = lang("sync mobile", false);
|
||||
$APPS["sync_mobile"]["icon"] = "mobile";
|
||||
$APPS["sync_mobile"]["title"] = lang("sync mobile", false);
|
||||
$APPS["sync_mobile"]["icon"] = "mobile";
|
||||
|
||||
if (!is_empty($_GET['delsynccode'])) {
|
||||
if (!is_empty($_GET['delsynccode'])) {
|
||||
if ($database->has("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['delsynccode']]])) {
|
||||
$database->delete("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['delsynccode']]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($_GET['mobilecode'] == "generate") {
|
||||
if ($_GET['mobilecode'] == "generate") {
|
||||
if (!is_empty($_GET['showsynccode']) && $database->has("mobile_codes", ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['showsynccode']]])) {
|
||||
$code = $database->get("mobile_codes", 'code', ["AND" => ["uid" => $_SESSION['uid'], "codeid" => $_GET['showsynccode']]]);
|
||||
} else {
|
||||
@ -46,7 +47,7 @@ if ($_GET['mobilecode'] == "generate") {
|
||||
<div class="well well-sm" style="text-align: center; font-size: 110%; font-family: monospace;">$url</div>
|
||||
<a class="btn btn-success btn-sm btn-block" href="home.php?page=security">$lang_done</a>
|
||||
END;
|
||||
} else {
|
||||
} else {
|
||||
$activecodes = $database->select("mobile_codes", ["codeid", "code"], ["uid" => $_SESSION['uid']]);
|
||||
$content = '<div class="alert alert-info"><i class="fa fa-info-circle"></i> ' . lang("sync explained", false) . '</div>'
|
||||
. '<a class="btn btn-success btn-sm btn-block" href="home.php?page=security&mobilecode=generate">'
|
||||
@ -71,4 +72,5 @@ END;
|
||||
</style>
|
||||
END;
|
||||
$APPS["sync_mobile"]["content"] = $content;
|
||||
}
|
||||
}
|
@ -10,6 +10,9 @@ $APPS["taskfloor_messages"]["i18n"] = TRUE;
|
||||
$APPS["taskfloor_messages"]["title"] = "messages";
|
||||
$APPS["taskfloor_messages"]["icon"] = "comments";
|
||||
$APPS["taskfloor_messages"]["type"] = "deep-purple";
|
||||
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
|
||||
try {
|
||||
$client = new GuzzleHttp\Client();
|
||||
|
||||
@ -46,9 +49,15 @@ END;
|
||||
$content = "<div class=\"alert alert-info\">" . lang("no messages", false) . "</div>";
|
||||
}
|
||||
}
|
||||
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["taskfloor_messages"]["content"] = $content;
|
||||
} catch (ClientException $e) {
|
||||
if ($e->getResponse()->getStatusCode() == 403) {
|
||||
unset($APPS['taskfloor_messages']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$content = "<div class=\"alert alert-danger\">" . lang("error loading widget", false) . " " . $e->getMessage() . "</div>";
|
||||
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["taskfloor_messages"]["content"] = $content;
|
||||
}
|
||||
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["taskfloor_messages"]["content"] = $content;
|
||||
?>
|
@ -10,6 +10,9 @@ $APPS["taskfloor_tasks"]["i18n"] = TRUE;
|
||||
$APPS["taskfloor_tasks"]["title"] = "tasks";
|
||||
$APPS["taskfloor_tasks"]["icon"] = "tasks";
|
||||
$APPS["taskfloor_tasks"]["type"] = "blue-grey";
|
||||
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
|
||||
try {
|
||||
$client = new GuzzleHttp\Client();
|
||||
|
||||
@ -34,9 +37,15 @@ try {
|
||||
$content = "<div class=\"alert alert-success\">" . lang("no tasks found", false) . "</div>";
|
||||
}
|
||||
}
|
||||
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["taskfloor_tasks"]["content"] = $content;
|
||||
} catch (ClientException $e) {
|
||||
if ($e->getResponse()->getStatusCode() == 403) {
|
||||
unset($APPS['taskfloor_tasks']);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$content = "<div class=\"alert alert-danger\">" . lang("error loading widget", false) . " " . $e->getMessage() . "</div>";
|
||||
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["taskfloor_tasks"]["content"] = $content;
|
||||
}
|
||||
$content .= '<a href="' . TASKFLOOR_HOME . '" class="btn btn-primary btn-block mobile-app-hide">' . lang("open app", false) . ' <i class="fa fa-external-link-square"></i></a>';
|
||||
$APPS["taskfloor_tasks"]["content"] = $content;
|
||||
?>
|
13
home.php
13
home.php
@ -156,7 +156,15 @@ END;
|
||||
<div class="row widget-box">
|
||||
<?php
|
||||
// Center the widgets horizontally on the screen
|
||||
$appcount = count(APPS[$pageid]);
|
||||
$appcount = 0;
|
||||
foreach (APPS[$pageid] as $app) {
|
||||
if (file_exists(__DIR__ . "/apps/" . $app . ".php")) {
|
||||
include_once __DIR__ . "/apps/" . $app . ".php";
|
||||
if (isset($APPS[$app])) {
|
||||
$appcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($appcount == 1) {
|
||||
?>
|
||||
<div class="hidden-xs col-sm-3 col-md-4 col-lg-4">
|
||||
@ -175,6 +183,9 @@ END;
|
||||
foreach (APPS[$pageid] as $app) {
|
||||
if (file_exists(__DIR__ . "/apps/" . $app . ".php")) {
|
||||
include_once __DIR__ . "/apps/" . $app . ".php";
|
||||
if (!isset($APPS[$app])) {
|
||||
continue;
|
||||
}
|
||||
$apptitle = ($APPS[$app]['i18n'] === TRUE ? lang($APPS[$app]['title'], false) : $APPS[$app]['title']);
|
||||
$appicon = (is_empty($APPS[$app]['icon']) ? "" : "fa fa-fw fa-" . $APPS[$app]['icon']);
|
||||
$apptype = (is_empty($APPS[$app]['type']) ? "default" : $APPS[$app]['type']);
|
||||
|
Loading…
x
Reference in New Issue
Block a user