From eadb83ceb120ba306715caab4a018c709555a3fe Mon Sep 17 00:00:00 2001 From: Skylar Date: Thu, 19 May 2016 00:41:51 -0600 Subject: [PATCH] Add comments/documentation --- database.php | 5 ++++- dieifnotloggedin.php | 4 +++- getitem.php | 4 +++- getlocation.php | 4 +++- getmodel.php | 4 +++- getstatus.php | 4 +++- login.php | 5 ++++- readfrom.php | 5 ++++- required.php | 29 +++++++++++++++++++---------- search.php | 5 ++++- updateitem.php | 7 +++++-- 11 files changed, 55 insertions(+), 21 deletions(-) diff --git a/database.php b/database.php index 5a0619c..87ab2d6 100644 --- a/database.php +++ b/database.php @@ -1,5 +1,8 @@ 'mysql', diff --git a/dieifnotloggedin.php b/dieifnotloggedin.php index b68e9f1..3fc2ad3 100644 --- a/dieifnotloggedin.php +++ b/dieifnotloggedin.php @@ -1,5 +1,7 @@ select('users', ['password'], [$qf => $username])[0]['password']; @@ -59,6 +58,11 @@ function is_empty($str) { return (!isset($str) || $str == '' || $str == null); } +/** + * Send a generic OK message. + * @param string $message Optional message text. + * @param boolean $die End execution after sending message (default true). + */ function sendOK($message = "", $die = true) { if (!is_empty($message) && JSON) { echo '{ "status": "OK", "message": "' . $message . '" }'; @@ -74,6 +78,11 @@ function sendOK($message = "", $die = true) { } } +/** + * Send an error message. + * @param string $error Error text. + * @param boolean $die End execution after sending error (default true). + */ function sendError($error, $die = true) { if (JSON) { echo '{ "status": "ERROR", "message": "' . $error . '" }'; diff --git a/search.php b/search.php index 8111594..e12f1c5 100644 --- a/search.php +++ b/search.php @@ -1,5 +1,7 @@ select($from, '*', ['OR' => ['name[~]' => $q, 'asset_tag[~]' => $q, 'serial[~]' => $q, 'order_number[~]' => $q]]); } else { diff --git a/updateitem.php b/updateitem.php index 869448c..d74bdfb 100644 --- a/updateitem.php +++ b/updateitem.php @@ -1,5 +1,7 @@ select('users', 'id', ['username' => $_SESSION['user']])[0]; $database->insert($from, ['name' => $_POST['name'], 'user_id' => $user_id, 'asset_tag' => $_POST['asset_tag'], 'rtd_location_id' => $_POST['location'], 'order_number' => $_POST['order_number'], 'status_id' => $_POST['status'], 'serial' => $_POST['serial'], 'model_id' => $_POST['model'], '#updated_at' => 'NOW()', '#created_at' => 'NOW()', '_snipeit_hard_drive_secure__y_n_' => $_POST['hdd_secure']]); @@ -19,7 +22,7 @@ if (is_empty($id)) { $database->insert($from, ['name' => $_POST['name'], 'location_id' => $_POST['location'], 'qty' => $_POST['qty'], 'order_number' => $_POST['order_number'], '#updated_at' => 'NOW()', '#created_at' => 'NOW()']); } } else { - + // Update an existing item by id if ($from == 'assets') { $database->update($from, ['name' => $_POST['name'], 'asset_tag' => $_POST['asset_tag'], 'rtd_location_id' => $_POST['location'], 'order_number' => $_POST['order_number'], 'status_id' => $_POST['status'], 'serial' => $_POST['serial'], 'model_id' => $_POST['model'], '#updated_at' => 'NOW()', '_snipeit_hard_drive_secure__y_n_' => $_POST['hdd_secure']], ['id' => $id]); } else {