Merge ../BusinessAppTemplate

master
Skylar Ittner 5 years ago
commit f9b6d7213e

@ -1,19 +1,7 @@
Copyright (c) 2018 Netsyms Technologies. Copyright (c) 2017-2019 Netsyms Technologies. Some rights reserved.
If you modify and redistribute this project, you must replace the branding Licensed under the Mozilla Public License Version 2.0. Files without MPL header
assets with your own. comments, including third party code, may be under a different license.
The branding assets include:
* the application icon
* the Netsyms N punchcard logo
* the Netsyms for Business graph logo
If you are unsure if your usage is allowed, please contact us:
https://netsyms.com/contact
legal@netsyms.com
All other portions of this application,
unless otherwise noted (in comments, headers, etc), are licensed as follows:
Mozilla Public License Version 2.0 Mozilla Public License Version 2.0
================================== ==================================

@ -18,4 +18,4 @@ Setup Tips
* Run `git submodule init` and `git submodule update` to install several other dependencies * Run `git submodule init` and `git submodule update` to install several other dependencies
* Install the database using `database.mwb` or `database.sql` * Install the database using `database.mwb` or `database.sql`
* Copy `settings.template.php` to `settings.php` and customize * Copy `settings.template.php` to `settings.php` and customize
* You'll also need to setup [AccountHub](https://source.netsyms.com/Business/AccountHub) * You'll also need to setup [AccountHub](https://source.netsyms.com/Business/AccountHub)

@ -10,6 +10,8 @@ require __DIR__ . '/../required.php';
require __DIR__ . '/functions.php'; require __DIR__ . '/functions.php';
require __DIR__ . '/apisettings.php'; require __DIR__ . '/apisettings.php';
header("Access-Control-Allow-Origin: *");
$VARS = $_GET; $VARS = $_GET;
if ($_SERVER['REQUEST_METHOD'] != "GET") { if ($_SERVER['REQUEST_METHOD'] != "GET") {
$VARS = array_merge($VARS, $_POST); $VARS = array_merge($VARS, $_POST);

@ -173,33 +173,65 @@ HTMLTOP;
$required = $item["required"] ? "required" : ""; $required = $item["required"] ? "required" : "";
$id = empty($item["id"]) ? "" : "id=\"$item[id]\""; $id = empty($item["id"]) ? "" : "id=\"$item[id]\"";
$pattern = empty($item["pattern"]) ? "" : "pattern=\"$item[pattern]\""; $pattern = empty($item["pattern"]) ? "" : "pattern=\"$item[pattern]\"";
if (empty($item['type'])) {
$item['type'] = "text";
}
$itemhtml = ""; $itemhtml = "";
$itemlabel = "";
if ($item['type'] == "textarea") {
$itemlabel = "<label class=\"mb-0\"><i class=\"$item[icon]\"></i> $item[label]:</label>";
} else if ($item['type'] != "checkbox") {
$itemlabel = "<label class=\"mb-0\">$item[label]:</label>";
}
$strippedlabel = strip_tags($item['label']);
$itemhtml .= <<<ITEMTOP $itemhtml .= <<<ITEMTOP
\n\n <div class="col-12 col-md-$item[width]"> \n\n <div class="col-12 col-md-$item[width]">
<div class="form-group mb-3"> <div class="form-group mb-3">
<label class="mb-0">$item[label]:</label> $itemlabel
<div class="input-group"> ITEMTOP;
$inputgrouptop = <<<INPUTG
\n <div class="input-group">
<div class="input-group-prepend"> <div class="input-group-prepend">
<span class="input-group-text"><i class="$item[icon]"></i></span> <span class="input-group-text"><i class="$item[icon]"></i></span>
</div> </div>
ITEMTOP; INPUTG;
if (empty($item['type']) || $item['type'] != "select") { switch ($item['type']) {
$itemhtml .= <<<INPUT case "select":
\n <input type="$item[type]" name="$item[name]" $id class="form-control" aria-label="$item[label]" minlength="$item[minlength]" maxlength="$item[maxlength]" $pattern value="$item[value]" $required /> $itemhtml .= $inputgrouptop;
INPUT; $itemhtml .= <<<SELECT
} else { \n <select class="form-control" name="$item[name]" aria-label="$strippedlabel" $required>
$itemhtml .= <<<SELECT
\n <select class="form-control" name="$item[name]" aria-label="$item[label]" $required>
SELECT; SELECT;
foreach ($item['options'] as $value => $label) { foreach ($item['options'] as $value => $label) {
$selected = ""; $selected = "";
if (!empty($item['value']) && $value == $item['value']) { if (!empty($item['value']) && $value == $item['value']) {
$selected = " selected"; $selected = " selected";
}
$itemhtml .= "\n <option value=\"$value\"$selected>$label</option>";
} }
$itemhtml .= "\n <option value=\"$value\"$selected>$label</option>"; $itemhtml .= "\n </select>";
} break;
$itemhtml .= "\n </select>"; case "checkbox":
$itemhtml .= $inputgrouptop;
$itemhtml .= <<<CHECKBOX
\n <div class="form-group form-check">
<input type="checkbox" name="$item[name]" $id class="form-check-input" value="$item[value]" $required aria-label="$strippedlabel">
<label class="form-check-label">$item[label]</label>
</div>
CHECKBOX;
break;
case "textarea":
$val = htmlentities($item['value']);
$itemhtml .= <<<TEXTAREA
\n <textarea class="form-control" id="info" name="$item[name]" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $required>$val</textarea>
TEXTAREA;
break;
default:
$itemhtml .= $inputgrouptop;
$itemhtml .= <<<INPUT
\n <input type="$item[type]" name="$item[name]" $id class="form-control" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $pattern value="$item[value]" $required />
INPUT;
break;
} }
if (!empty($item["error"])) { if (!empty($item["error"])) {
@ -209,9 +241,11 @@ SELECT;
</div> </div>
ERROR; ERROR;
} }
if ($item["type"] != "textarea") {
$itemhtml .= "\n </div>";
}
$itemhtml .= <<<ITEMBOTTOM $itemhtml .= <<<ITEMBOTTOM
\n </div> \n </div>
</div>
</div>\n </div>\n
ITEMBOTTOM; ITEMBOTTOM;
$html .= $itemhtml; $html .= $itemhtml;
@ -224,7 +258,7 @@ ITEMBOTTOM;
HTMLBOTTOM; HTMLBOTTOM;
if (!empty($this->buttons)) { if (!empty($this->buttons)) {
$html .= "\n <div class=\"card-footer\">"; $html .= "\n <div class=\"card-footer d-flex\">";
foreach ($this->buttons as $btn) { foreach ($this->buttons as $btn) {
$btnhtml = ""; $btnhtml = "";
$inner = "<i class=\"$btn[icon]\"></i> $btn[text]"; $inner = "<i class=\"$btn[icon]\"></i> $btn[text]";

@ -8,10 +8,6 @@
* Mobile app API * Mobile app API
*/ */
// The name of the permission needed to log in.
// Set to null if you don't need it.
$access_permission = null;
require __DIR__ . "/../required.php"; require __DIR__ . "/../required.php";
header('Content-Type: application/json'); header('Content-Type: application/json');
@ -70,13 +66,14 @@ switch ($VARS['action']) {
if ($user->exists()) { if ($user->exists()) {
if ($user->getStatus()->getString() == "NORMAL") { if ($user->getStatus()->getString() == "NORMAL") {
if ($user->checkPassword($VARS['password'])) { if ($user->checkPassword($VARS['password'])) {
if (is_null($access_permission) || $user->hasPermission($access_permission)) { foreach ($SETTINGS['permissions'] as $perm) {
Session::start($user); if (!$user->hasPermission($perm)) {
$_SESSION['mobile'] = true; exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("no permission", false)]));
exit(json_encode(["status" => "OK"])); }
} else {
exit(json_encode(["status" => "ERROR", "msg" => $Strings->get("no admin permission", false)]));
} }
Session::start($user);
$_SESSION['mobile'] = true;
exit(json_encode(["status" => "OK"]));
} }
} }
} }

@ -1,24 +0,0 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/*
* This file demonstrates creating a form with the FormBuilder class.
*/
$form = new FormBuilder("Sample Form", "fas fa-code", "", "GET");
$form->setID("sampleform");
$form->addHiddenInput("page", "form");
$form->addInput("name", "John", "text", true, null, null, "Your name", "fas fa-user", 6, 5, 20, "John(ny)?|Steve", "Invalid name, please enter John, Johnny, or Steve.");
$form->addInput("location", "", "select", true, null, ["1" => "Here", "2" => "There"], "Location", "fas fa-map-marker");
$form->addButton("Submit", "fas fa-save", null, "submit", "savebtn");
$form->generate();

@ -131,11 +131,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
define("GET", true); define("GET", true);
} }
function dieifnotloggedin() { function dieifnotloggedin() {
global $SETTINGS;
if ($_SESSION['loggedin'] != true) { if ($_SESSION['loggedin'] != true) {
sendError("Session expired. Please log out and log in again."); sendError("Session expired. Please log out and log in again.");
} }
$user = new User($_SESSION['uid']);
foreach ($SETTINGS['permissions'] as $perm) {
if (!$user->hasPermission($perm)) {
session_destroy();
die("You don't have permission to be here.");
}
}
} }
/** /**
@ -156,8 +163,17 @@ function checkDBError($specials = []) {
} }
function redirectIfNotLoggedIn() { function redirectIfNotLoggedIn() {
global $SETTINGS;
if ($_SESSION['loggedin'] !== TRUE) { if ($_SESSION['loggedin'] !== TRUE) {
header('Location: ' . $SETTINGS['url'] . '/index.php'); header('Location: ' . $SETTINGS['url'] . '/index.php');
die(); die();
} }
$user = new User($_SESSION['uid']);
foreach ($SETTINGS['permissions'] as $perm) {
if (!$user->hasPermission($perm)) {
session_destroy();
header('Location: ./index.php');
die("You don't have permission to be here.");
}
}
} }

@ -1,16 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$("#savebtn").click(function (event) {
var form = $("#sampleform");
if (form[0].checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.addClass('was-validated');
});
Loading…
Cancel
Save