diff --git a/classes/Alerts.php b/classes/Alerts.php index 2ba56bb..9d14542 100644 --- a/classes/Alerts.php +++ b/classes/Alerts.php @@ -8,7 +8,7 @@ class Alerts extends Base { // Variables. - private $current_user_id = ""; + private $current_user_name = ""; private $current_user_email = ""; private $pagination_size = 20; @@ -24,7 +24,7 @@ class Alerts extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/Base.php b/classes/Base.php index 9df77ae..104fa9b 100644 --- a/classes/Base.php +++ b/classes/Base.php @@ -24,9 +24,9 @@ class Base { const ENVIRONMENT = "BASEPROJECT_ENVIRONMENT"; const ACTIVE_SESSION = "BASEPROJECT_ACTIVE_SESSION"; - const USER_ID = "BASEPROJECT_USER_ID"; const USER_SERIAL = "BASEPROJECT_USER_SERIAL"; const USER_NAME = "BASEPROJECT_USER_NAME"; + const USER_FULL_NAME = "BASEPROJECT_USER_FULL_NAME"; const USER_EMAIL = "BASEPROJECT_USER_EMAIL"; const USER_ROLE = "BASEPROJECT_USER_ROLE"; const USER_AUTHENTICATED = "BASEPROJECT_USER_AUTHENTICATED"; @@ -86,6 +86,7 @@ class Base { $XSLParms["THEME"] = $_SESSION[self::THEME] ?? self::THEME; $XSLParms["ENVIRONMENT"] = $_SESSION[self::ENVIRONMENT] ?? "Production"; $XSLParms["USER_NAME"] = $_SESSION[self::USER_NAME] ?? ""; + $XSLParms["USER_FULL_NAME"] = $_SESSION[self::USER_FULL_NAME] ?? ""; $XSLParms["USER_ROLE"] = $_SESSION[self::USER_ROLE] ?? "Guest"; $XSLParms["RANDOM_NUMBER"] = rand(); $XSLParms["TODAY_YYYYMMDD"] = date("Y-m-d"); @@ -622,8 +623,8 @@ class Base { $_SESSION[self::ENVIRONMENT] = (string) ($settings->Environment ?? "Production"); $_SESSION[self::USER_AUTHENTICATED] = false; $_SESSION[self::USER_SERIAL] = 0; - $_SESSION[self::USER_ID] = ""; $_SESSION[self::USER_NAME] = ""; + $_SESSION[self::USER_FULL_NAME] = ""; $_SESSION[self::USER_EMAIL] = ""; $_SESSION[self::USER_ROLE] = "Guest"; $_SESSION[self::REPORTS_GET] = ""; diff --git a/classes/Dropdowns.php b/classes/Dropdowns.php index 2c0cb5f..f46dbda 100644 --- a/classes/Dropdowns.php +++ b/classes/Dropdowns.php @@ -8,7 +8,7 @@ class Dropdowns extends Base { // Variables. - private $current_user_id = ""; + private $current_user_name = ""; private $current_user_email = ""; private $pagination_size = 20; @@ -24,7 +24,7 @@ class Dropdowns extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/Journal.php b/classes/Journal.php index 2d58341..62ccc18 100644 --- a/classes/Journal.php +++ b/classes/Journal.php @@ -8,7 +8,6 @@ class Journal extends Base { // Variables. - private $current_user_id = ""; private $current_user_name = ""; private $current_user_email = ""; @@ -25,7 +24,6 @@ class Journal extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/Notes.php b/classes/Notes.php index 1a18ce3..8eb4dd3 100644 --- a/classes/Notes.php +++ b/classes/Notes.php @@ -12,7 +12,7 @@ class Notes extends Base { // Variables - private $current_user_id = ""; + private $current_user_name = ""; private $current_user_email = ""; @@ -26,7 +26,7 @@ class Notes extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; } diff --git a/classes/Popovers.php b/classes/Popovers.php index ef1ed82..aa4091f 100644 --- a/classes/Popovers.php +++ b/classes/Popovers.php @@ -8,7 +8,7 @@ class Popovers extends Base { // Variables. - private $current_user_id = ""; + private $current_user_name = ""; private $current_user_email = ""; private $pagination_size = 20; @@ -24,7 +24,7 @@ class Popovers extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/Reports.php b/classes/Reports.php index bd0195f..b399320 100644 --- a/classes/Reports.php +++ b/classes/Reports.php @@ -8,7 +8,7 @@ class Reports extends Base { // Variables. - private $current_user_id = ""; + private $current_user_name = ""; private $current_user_email = ""; private $pagination_size = 20; @@ -24,7 +24,7 @@ class Reports extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/SignIn.php b/classes/SignIn.php index ccaa198..5cdd277 100644 --- a/classes/SignIn.php +++ b/classes/SignIn.php @@ -8,10 +8,10 @@ class SignIn extends Base { // Variables - private $current_user_id = ""; - private $current_user_serial = ""; - private $current_user_name = ""; - private $current_user_email = ""; + private $current_user_serial = ""; + private $current_user_name = ""; + private $current_user_full_name = ""; + private $current_user_email = ""; // =============================== // __construct : Class Constructor @@ -23,9 +23,9 @@ class SignIn extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; - $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; - $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; + $this->current_user_full_name = $_SESSION[self::USER_FULL_NAME] ?? ""; + $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; } // ======================== @@ -63,12 +63,12 @@ class SignIn extends Base { die(); } - if ((int) $user->record->user_active === 0) { + if ((string) $user->record->user_status !== 'active') { echo $this->applyXSL("", $this->getXSL("signIn"), $XSLParms); die(); } - $stored_hashed_password = $user->record->user_password; + $stored_hashed_password = $user->record->user_password_hash; if (!password_verify($user_password, $stored_hashed_password)) { @@ -79,13 +79,12 @@ class SignIn extends Base { session_regenerate_id(true); $_SESSION[self::USER_AUTHENTICATED] = true; - $_SESSION[self::USER_SERIAL] = (int) $user->record->user_serial; - $_SESSION[self::USER_ID] = (string) $user->record->user_id; + $_SESSION[self::USER_SERIAL] = (int) $user->record->user_serial; $_SESSION[self::USER_NAME] = (string) $user->record->user_name; + $_SESSION[self::USER_FULL_NAME] = (string) $user->record->user_full_name; $_SESSION[self::USER_EMAIL] = (string) $user->record->user_email; $_SESSION[self::USER_ROLE] = (string) $user->record->user_role; - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; $this->current_user_serial = $_SESSION[self::USER_SERIAL] ?? 0; $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/Statuses.php b/classes/Statuses.php index ab4c499..0234e80 100644 --- a/classes/Statuses.php +++ b/classes/Statuses.php @@ -5,7 +5,7 @@ class Statuses extends Base { // Variables. private $current_user_serial = 0; - private $current_user_id = ""; + private $current_user_name = ""; private $current_user_email = ""; private $pagination_size = 20; @@ -22,7 +22,7 @@ class Statuses extends Base { date_default_timezone_set(self::TIMEZONE); $this->current_user_serial = $_SESSION[self::USER_SERIAL] ?? 0; - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; + $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; diff --git a/classes/Users.php b/classes/Users.php index 9f2b7d3..6525521 100644 --- a/classes/Users.php +++ b/classes/Users.php @@ -8,7 +8,7 @@ class Users extends Base { // Variables - private $current_user_id = ""; + private $current_user_serial = ""; private $current_user_name = ""; private $current_user_email = ""; @@ -25,10 +25,8 @@ class Users extends Base { date_default_timezone_set(self::TIMEZONE); - $this->current_user_id = $_SESSION[self::USER_ID] ?? ""; $this->current_user_name = $_SESSION[self::USER_NAME] ?? ""; $this->current_user_email = $_SESSION[self::USER_EMAIL] ?? ""; - $this->pagination_page = $_SESSION[self::PAGINATION_PAGE] ?? 1; } @@ -292,18 +290,18 @@ class Users extends Base { $SQL = "select view_users.* from view_users - where user_id = '{$user_name}'"; + where user_name = '{$user_name}'"; return $this->getTable("user", $SQL); } - // ====================== - // Return a User's Serial - // ====================== + // ===================== + // Return a Users Serial + // ===================== - public function getUserSerial($user_id = "") { + public function getUserSerial($user_name = "") { - $users = $this->getUserByUserId($user_id); + $users = $this->getUserByUserId($user_name); return ($users->count() === 0) ? 0 : (int) $users->record->user_serial; } @@ -440,19 +438,19 @@ class Users extends Base { public function userExists() { $user_serial = filter_input(INPUT_POST, "user_serial", FILTER_SANITIZE_NUMBER_INT) ?: 0; - $user_id = filter_input(INPUT_POST, "user_id") ?: ""; + $user_name = filter_input(INPUT_POST, "user_name") ?: ""; - $user_id = strtolower(trim(preg_replace("/\s+/", " ", $user_id))); + $user_name = strtolower(trim(preg_replace("/\s+/", " ", $user_name))); - $SQL = "select user_id + $SQL = "select user_name from view_users where user_serial != :user_serial - and user_id = :user_id"; + and user_name = :user_name"; $statement = $this->connect()->prepare($SQL); $statement->bindValue(":user_serial", $user_serial); - $statement->bindValue(":user_id", $user_id); + $statement->bindValue(":user_name", $user_name); $statement->execute(); diff --git a/tables/_createSystemTable.php b/tables/_createSystemTable.php index 9b37373..7d99885 100644 --- a/tables/_createSystemTable.php +++ b/tables/_createSystemTable.php @@ -35,8 +35,7 @@ define("INITIALIZATION_FILE_NAME", "../xml/settings.xml"); define("INIT_SCRIPT_USER", "Init Script"); -// Safety switch. -// Change this to true when you intentionally want to rebuild system tables. + // Safety switch - Change this to true when you intentionally want to rebuild system tables. $allow_rebuild = true; if (!$allow_rebuild) { @@ -44,9 +43,9 @@ exit(); } -// -------------------------- -// Load Application Settings -// -------------------------- + // -------------------------- + // Load Application Settings + // -------------------------- $applicationSettings = simplexml_load_file(INITIALIZATION_FILE_NAME); @@ -55,9 +54,9 @@ exit(); } -// --------------------- -// Database Connection -// --------------------- + // --------------------- + // Database Connection + // --------------------- $host = (string) $applicationSettings->DatabaseServer; $database = (string) $applicationSettings->DatabaseName; @@ -66,8 +65,7 @@ try { $connection = new PDO( - "mysql:host={$host};dbname={$database};charset=utf8mb4", - $user, + "mysql:host={$host};dbname={$database};charset=utf8mb4", $user, $password, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, @@ -82,17 +80,13 @@ exit(); } -// ---------------------------- -// Get Table Definition Files -// ---------------------------- + // ---------------------------- + // Get Table Definition Files + // ---------------------------- $tableFiles = glob("*.php"); - $excludedFiles = [ - "_createSystemTable.php", - "_createTable.php", - basename(__FILE__), - ]; + $excludedFiles = ["_createSystemTable.php", "_createTable.php", basename(__FILE__),]; $tableFiles = array_values(array_filter($tableFiles, function ($file) use ($excludedFiles) { return !in_array($file, $excludedFiles, true); @@ -100,9 +94,9 @@ sort($tableFiles); -// ---------------------------- -// Process Table Files -// ---------------------------- + // ------------------- + // Process Table Files + // ------------------- foreach ($tableFiles as $tableFile) { @@ -160,9 +154,9 @@ echoLog("System tables created successfully.", "success"); -// ------------------------- -// Helper Functions -// ------------------------- + // ---------------- + // Helper Functions + // ---------------- function runSQL($SQL, PDO $connection, $context = "query") { try { @@ -221,23 +215,20 @@ ], ]; - $SQL = " - INSERT INTO popovers ( - popover_name, - popover_title, - popover_placeholder, - popover_text, - popover_created, - popover_creator - ) VALUES ( - :popover_name, - :popover_title, - :popover_placeholder, - :popover_text, - CURDATE(), - :popover_creator - ) - "; + $SQL = " INSERT INTO popovers ( + popover_name, + popover_title, + popover_placeholder, + popover_text, + popover_created, + popover_creator + ) VALUES ( + :popover_name, + :popover_title, + :popover_placeholder, + :popover_text, + CURDATE(), + :popover_creator )"; $statement = $connection->prepare($SQL); @@ -258,40 +249,33 @@ $password = password_hash("349Jamot@", PASSWORD_DEFAULT); - $SQL = " - INSERT INTO users ( - user_id, - user_name, - user_email, - user_password, - user_role, - user_change_password, - user_active, - user_creator, - user_created - ) VALUES ( - :user_id, - :user_name, - :user_email, - :user_password, - :user_role, - :user_change_password, - :user_active, - :user_creator, - CURDATE() - ) - "; + $SQL = "INSERT INTO users ( + user_name, + user_first_name, + user_last_name, + user_email, + user_password_hash, + user_role, + user_creator + + ) VALUES ( + :user_name, + :user_first_name, + :user_last_name, + :user_email, + :user_password_hash, + :user_role, + :user_creator )"; $statement = $connection->prepare($SQL); $statement->execute([ - ":user_id" => "DSYSADMIN", - ":user_name" => "James Richie", + ":user_name" => "jric11", + ":user_first_name" => "James", + ":user_last_name" => "Richie", ":user_email" => "james.richie@onesourceits.com", - ":user_password" => $password, + ":user_password_hash" => $password, ":user_role" => "Administrator", - ":user_change_password" => 1, - ":user_active" => 1, ":user_creator" => INIT_SCRIPT_USER, ]); diff --git a/tables/alerts.php b/tables/alerts.php index aeddf57..901cd56 100644 --- a/tables/alerts.php +++ b/tables/alerts.php @@ -19,5 +19,5 @@ $SQL = "create table alerts ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/dropdowns.php b/tables/dropdowns.php index 1a8987d..40ee31a 100644 --- a/tables/dropdowns.php +++ b/tables/dropdowns.php @@ -25,6 +25,6 @@ $SQL = "create table dropdowns ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/dropdowntypes.php b/tables/dropdowntypes.php index 0048630..f7e500f 100644 --- a/tables/dropdowntypes.php +++ b/tables/dropdowntypes.php @@ -20,6 +20,6 @@ $SQL = "create table dropdowntypes ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/journal.php b/tables/journal.php index 24014c4..59cb6d7 100644 --- a/tables/journal.php +++ b/tables/journal.php @@ -15,6 +15,6 @@ $SQL = "create table journal ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/notes.php b/tables/notes.php index 9eed4eb..d7ee102 100644 --- a/tables/notes.php +++ b/tables/notes.php @@ -18,5 +18,5 @@ $SQL = "create table notes ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/popovers.php b/tables/popovers.php index d59e65d..9293245 100644 --- a/tables/popovers.php +++ b/tables/popovers.php @@ -19,6 +19,6 @@ $SQL = "create table popovers ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/reports.php b/tables/reports.php index f8c4dda..a46d5ad 100644 --- a/tables/reports.php +++ b/tables/reports.php @@ -19,6 +19,6 @@ $SQL = "create table reports ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/statuses.php b/tables/statuses.php index 588268c..ef04095 100644 --- a/tables/statuses.php +++ b/tables/statuses.php @@ -19,6 +19,6 @@ $SQL = "create table statuses ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/tables/users.php b/tables/users.php index 23fe406..358fd5b 100644 --- a/tables/users.php +++ b/tables/users.php @@ -1,29 +1,31 @@ diff --git a/tables/zipcodes.php b/tables/zipcodes.php index f377076..eae5e8a 100644 --- a/tables/zipcodes.php +++ b/tables/zipcodes.php @@ -16,6 +16,6 @@ $SQL = "create table zipcodes ) - default character set = utf8"; + default character set = utf8mb4"; ?> diff --git a/views/view_users.php b/views/view_users.php index e2c6fbc..77ce2ec 100644 --- a/views/view_users.php +++ b/views/view_users.php @@ -3,10 +3,9 @@ $SQL = "create view view_users as select users.*, - date_format(user_login, '%c/%e/%Y %l:%i %p') as user_login_verbose, - date_format(user_created, '%c/%e/%Y %l:%i %p') as user_created_verbose, - date_format(user_changed, '%c/%e/%Y %l:%i %p') as user_changed_verbose - from users - - order by users.user_name"; + date_format(user_last_login, '%c/%e/%Y %l:%i %p') as user_login_verbose, + date_format(user_created, '%c/%e/%Y %l:%i %p') as user_created_verbose, + date_format(user_changed, '%c/%e/%Y %l:%i %p') as user_changed_verbose, + concat_ws(' ', NULLIF(TRIM(user_first_name), ''), NULLIF(TRIM(user_last_name), '') ) AS user_full_name + from users"; ?> \ No newline at end of file diff --git a/xsl/content.xsl b/xsl/content.xsl index 607dae8..0413c17 100644 --- a/xsl/content.xsl +++ b/xsl/content.xsl @@ -28,7 +28,7 @@ - + @@ -68,7 +68,7 @@
- + @@ -163,7 +163,7 @@ - + @@ -182,10 +182,6 @@ Alerts - - Counties - - Dropdown Types @@ -206,10 +202,10 @@ Statuses - - Subscriptions - - + @@ -261,7 +257,7 @@ Copyright © | - DEC International, LLC | All Rights Reserved + OneSource IT Solutions | All Rights Reserved
diff --git a/xsl/home.xsl b/xsl/home.xsl index 4b93091..5253eb8 100644 --- a/xsl/home.xsl +++ b/xsl/home.xsl @@ -9,8 +9,8 @@
- - DEC Data Manager + + Base Project Template