diff --git a/App/Enumerators/SessionElement.php b/App/Enumerators/SessionElement.php
new file mode 100644
index 0000000..13d4c19
--- /dev/null
+++ b/App/Enumerators/SessionElement.php
@@ -0,0 +1,10 @@
+RunSelect(
+ queryBuilder: \App\Wrappers\SQLQueryBuilderWrapper::SELECT(
+ table: 'Tunes'
+ )
+ ->where(cond: 'T.CreatedBy LIKE :__user_id__')
+ ->bindValue(name: '__user_id__', value: $_SESSION[SessionElement::USER_ID->value])
+);
+
+TwigWrapper::RenderTwig(
+ target: "Pages/profile.html.twig",
+ arguments: [
+ "YourTunes" => $yourTunes,
+ "YourDances" => [],
+ ],
+);
diff --git a/Pages/tune/uuid.php b/Pages/tune/uuid.php
index 41b0e7a..851d118 100644
--- a/Pages/tune/uuid.php
+++ b/Pages/tune/uuid.php
@@ -15,14 +15,6 @@ $tuneDetails = $db->RunOneSelect(
),
);
-$variants = $db->RunSelect(
- queryBuilder: SQLQueryBuilderWrapper::SELECT(
- table: 'TuneVariants',
- )
- ->where(cond: 'T.TuneID=:__tune_id__')
- ->bindValue(name: '__tune_id__', value: $_GET["tune-id"])
-);
-
$dances = $db->RunSelect(
queryBuilder: SQLQueryBuilderWrapper::SELECT(
table: 'Dances',
@@ -73,7 +65,6 @@ TwigWrapper::RenderTwig(
target: "Pages/tune/uuid.html.twig",
arguments: [
"TuneDetails"=>$tuneDetails,
- "TuneVariants"=>$variants,
"Dances"=>$dances,
]
);
diff --git a/Public/API/V1/GetABCFile.php b/Public/API/V1/GetABCFile.php
index ec503cb..b62f014 100644
--- a/Public/API/V1/GetABCFile.php
+++ b/Public/API/V1/GetABCFile.php
@@ -14,24 +14,23 @@ $db = new DatabaseInteractions();
$variantDetails = $db->RunOneSelect(
queryBuilder: SQLQueryBuilderWrapper::SELECT_ONE(
- table: 'TuneVariants',
+ table: 'Tunes',
id: $targetTuneVariantID
)
->cols([
- 'T.ID AS TuneVariantID',
- 'T.TuneID AS TuneID',
+ 'T.ID AS TuneID',
"CONCAT('[', GROUP_CONCAT(
CONCAT(
- '{\"TimeSignature\":', JSON_QUOTE(T_TVP.TimeSignature), ',',
- '\"KeySignature\":', JSON_QUOTE(T_TVP.KeySignature), ',',
- '\"ABCNotation\":', JSON_QUOTE(T_TVP.ABCNotation), '}'
+ '{\"TimeSignature\":', JSON_QUOTE(T_TP.TimeSignature), ',',
+ '\"KeySignature\":', JSON_QUOTE(T_TP.KeySignature), ',',
+ '\"ABCNotation\":', JSON_QUOTE(T_TP.ABCNotation), '}'
)
), ']') AS Parts"
])
->join(
join: 'INNER',
- spec: 'TuneVariantParts AS T_TVP',
- cond: 'T.ID = T_TVP.TuneVariantID'
+ spec: 'TuneParts AS T_TP',
+ cond: 'T.ID = T_TP.TuneID'
)
->groupBy(spec: [
'T.ID',
diff --git a/Public/FormHandling/Login.php b/Public/FormHandling/Login.php
new file mode 100644
index 0000000..daabdcf
--- /dev/null
+++ b/Public/FormHandling/Login.php
@@ -0,0 +1,45 @@
+RunSelect(
+ queryBuilder: SQLQueryBuilderWrapper::SELECT(
+ table: 'Users'
+ )
+ ->where(cond: 'T.Username LIKE :__username__')
+ ->bindValue(name: '__username__', value: $username)
+ ->limit(limit: 1)
+);
+
+if(sizeof($result) != 1)
+{
+ echo "invalid user";
+ die();
+}
+
+$result = $result[0];
+
+if (!password_verify($sha512Hash, $result['PasswordHash']))
+{
+ echo "invalid password";
+ die();
+}
+
+$_SESSION[SessionElement::IS_LOGGED_IN->value] = true;
+$_SESSION[SessionElement::USER_ID->value] = $result['ID'];
+$_SESSION[SessionElement::USERNAME->value] = $result['Username'];
+
+header("Location: /");
diff --git a/Routing/Router.php b/Routing/Router.php
index 54ec3d7..5b059ac 100644
--- a/Routing/Router.php
+++ b/Routing/Router.php
@@ -15,13 +15,23 @@ $requestElements = explode("/", trim($requestUri, "/"));
switch($requestElements[0])
{
case "favicon.ico":
- case "API":
case "Static":
+ case "API":
+ case "FormHandling":
default:
return false;
case "":
require_once __DIR__ . '/../Pages/index.php';
return true;
+ case "login":
+ require_once __DIR__ . '/../Pages/login.php';
+ return true;
+ case "logout":
+ require_once __DIR__ . '/../Pages/logout.php';
+ return true;
+ case "profile":
+ require_once __DIR__ . '/../Pages/profile.php';
+ return true;
case "tune":
$_GET['tune-id'] = $requestElements[1];
if(sizeof($requestElements) == 2)
diff --git a/Templates/Bases/StandardWebPage.html.twig b/Templates/Bases/StandardWebPage.html.twig
index a89c9dd..deee8e4 100644
--- a/Templates/Bases/StandardWebPage.html.twig
+++ b/Templates/Bases/StandardWebPage.html.twig
@@ -31,7 +31,11 @@
- About
+ {% if _SESSION_.IS_LOGGED_IN %}
+ My Account
+ {% else %}
+ Login
+ {% endif %}
diff --git a/Templates/Pages/login.html.twig b/Templates/Pages/login.html.twig
new file mode 100644
index 0000000..501c5b9
--- /dev/null
+++ b/Templates/Pages/login.html.twig
@@ -0,0 +1,25 @@
+{% extends "/Bases/StandardWebPage.html.twig" %}
+
+{% block content %}
+
+
Ceilidh Kit Login
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Templates/Pages/profile.html.twig b/Templates/Pages/profile.html.twig
new file mode 100644
index 0000000..6c0dcce
--- /dev/null
+++ b/Templates/Pages/profile.html.twig
@@ -0,0 +1,48 @@
+{% extends "/Bases/StandardWebPage.html.twig" %}
+
+{% block content %}
+
+
{{ "Your Profile"|translate }}
+
+
+
{{ "Summary"|translate }}
+
+ {{ "User ID"|translate }}
+ {{ _SESSION_.USER_ID }}
+
+ {{ "Username"|translate }}
+ {{ _SESSION_.USERNAME }}
+
+
+
+
{{ "Your Tunes"|translate }}
+
+
+
+ {{ "Title"|translate }}
+ {{ "Created At"|translate }}
+ {{ "Copyright"|translate }}
+
+
+
+ {% for tuneDetails in YourTunes %}
+
+ {{ tuneDetails.Title }}
+ {{ tuneDetails.CreatedAt }}
+ {{ tuneDetails.Copyright }}
+
+ {% endfor %}
+
+
+
+
{{ "Your Dances"|translate }}
+
+
+
+ {{ "Title"|translate }}
+ {{ "Created At"|translate }}
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Templates/Pages/tune/uuid.html.twig b/Templates/Pages/tune/uuid.html.twig
index 0224c0f..7936aa3 100644
--- a/Templates/Pages/tune/uuid.html.twig
+++ b/Templates/Pages/tune/uuid.html.twig
@@ -8,57 +8,42 @@
-
- {% for x in TuneVariants %}
-
-
{{ "Variant"|translate }} {{ loop.index }}
-
-
-
-
-
- {{ "Time Signature"|translate }}
- {{ x.TimeSignature }}
-
- {{ "Key Signature"|translate }}
- {{ x.KeySignature }}
-
- {{ "Copyright"|translate }}
- {{ TuneDetails.Copyright }}
-
- {{ "Number of Parts"|translate }}
- {{ TuneDetails.Parts|json_encode }}
-
-
-
-
-
-
-
{{ "ABC Notation"|translate }}
-
-
-
-
-
-
-
{{ "Audio"|translate }}
-
-
-
+
{{ TuneDetails.Title }}
+
+
+
+
+
+ {{ "Time Signature"|translate }}
+ {{ TuneDetails.TimeSignature }}
+
+ {{ "Key Signature"|translate }}
+ {{ TuneDetails.KeySignature }}
+
+ {{ "Copyright"|translate }}
+ {{ TuneDetails.Copyright }}
+
+ {{ "Number of Parts"|translate }}
+ {{ TuneDetails.Parts|json_encode }}
+
+
+
+
+
+
+
{{ "ABC Notation"|translate }}
+
+
+
+
+
{{ "Audio"|translate }}
+
+
+
- {% endfor %}
+
@@ -75,7 +60,7 @@
{% for x in Dances %}
-
{{ x.Title }}
+
{{ TuneDetails.Title }}
Steps
@@ -86,7 +71,7 @@
- {% for step in x.Steps %}
+ {% for step in TuneDetails.Steps %}
{{ step.BarCountAtStart }}
{{ step.BarCountAtEnd }}
@@ -182,9 +167,7 @@
}
- {% for x in TuneVariants %}
- RenderABC('{{ x.ID }}');
- {% endfor %}
+ RenderABC('{{ TuneDetails.ID }}');
});
{% endblock %}
\ No newline at end of file