Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #43 from noten-app/user-unique-ids
Browse files Browse the repository at this point in the history
User unique ids
  • Loading branch information
CuzImBisonratte authored Nov 22, 2023
2 parents bd62f4e + 4c78f5d commit 152cc6c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions homework/add/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
// Create given-date
$date_given = date("Y-m-d");

// Add subject to DB and get inserted ID
if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, subject, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?)')) {
$stmt->bind_param('sisssss', $_SESSION["user_id"], $subject, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]);
// Generate id (8char random string)
$entryId = bin2hex(random_bytes(4));

// Add subject to DB
if ($stmt = $con->prepare('INSERT INTO ' . $config["db"]["tables"]["homework"] . ' (user_id, entry_id, subject, given, deadline, text, type, year) VALUES (?, ?, ?, ?, ?, ?, ?, ?)')) {
$stmt->bind_param('ssssssss', $_SESSION["user_id"], $entryId, $subject, $date_given, $date_due, $task, $type, $_SESSION["setting_years"]);
$stmt->execute();
$stmt->close();
exit("success");
Expand Down
2 changes: 1 addition & 1 deletion homework/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
foreach ($hw_dategroup as $hw_entry) {
echo '<div class="homework_entry">';
echo '<div class="classname">';
foreach ($subjects as $subject) if ($subject["id"] == $hw_entry["class"]) echo $subject["name"];
foreach ($subjects as $subject) if ($subject["id"] == $hw_entry["subject"]) echo $subject["name"];
echo '</div><div class="task" onclick="location.assign(\'./edit/?task=' . $hw_entry["entry_id"] . '\')"><span>' . $hw_entry["text"] . '</span></div>';
echo '<div class="dot" id="dot-' . $hw_entry["entry_id"] . '" onclick="toggleState(\'' . $hw_entry["entry_id"] . '\')">';
if ($hw_entry["status"] == 0) echo '<i class="fa-regular fa-circle"></i></div>';
Expand Down

0 comments on commit 152cc6c

Please sign in to comment.