Verified Commit 7ee8f61c authored by Armando Lüscher's avatar Armando Lüscher

Merge develop into autolanguage

parents 936c5a4c 16af008b
......@@ -9,6 +9,7 @@
* Store full country name, store days monitored each pod
* Store detectedlanguage
* DB migrations see db/version.md
* rename table rating_comments to ratingcomments for redbean support
## Cleanup
* Use the git API for release versions, check development releases on pods https://github.com/diasporg/Poduptime/issues/143
......
ALTER TABLE masterversions ADD devlastcommit timestamp;
ALTER TABLE masterversions ADD releasedate timestamp;
ALTER TABLE pods ADD daysmonitored int, ADD countryname text;
ALTER TABLE rating_comments RENAME TO ratingcomments;
ALTER TABLE pods ADD detectedlanguage text;
......@@ -3,11 +3,11 @@
use RedBeanPHP\R;
// Required parameters.
($_username = $_POST['username'] ?? null) || die('no username given');
($_userurl = $_POST['userurl'] ?? null) || die('no userurl given');
($_username = $_POST['username'] ?? null) || die('Name is required');
//($_userurl = $_POST['userurl'] ?? null) || die('no userurl given');//lets not annoy people on this for now
($_domain = $_POST['domain'] ?? null) || die('no pod domain given');
($_comment = $_POST['comment'] ?? null) || die('no comment');
($_rating = $_POST['rating'] ?? null) || die('no rating given');
($_comment = $_POST['comment'] ?? null) || die('A comment is required');
($_rating = $_POST['rating'] ?? null) || die('A rating is required, move the slider to a score');
// Other parameters.
$_email = $_POST['email'] ?? '';
......@@ -23,7 +23,7 @@ R::testConnection() || die('Error in DB connection');
R::usePartialBeans(true);
try {
$r = R::dispense('rating_comments');
$r = R::dispense('ratingcomments');
$r['domain'] = $_domain;
$r['comment'] = $_comment;
$r['rating'] = $_rating;
......@@ -47,4 +47,4 @@ $message_lines = [
];
@mail($to, $subject, implode("\r\n", $message_lines), implode("\r\n", $headers));
echo 'Comment posted!';
print 1;
......@@ -52,7 +52,7 @@ CREATE TABLE pods (
date_created timestamp DEFAULT current_timestamp
);
CREATE TABLE rating_comments (
CREATE TABLE ratingcomments (
id serial8 UNIQUE PRIMARY KEY,
domain text NOT NULL,
comment text,
......
......@@ -32,7 +32,7 @@ R::usePartialBeans(true);
$(document).ready(function () {
$('#addrating').click(function () {
$('#commentform').show('slow');
$('#ratings').hide('slow');
$('.ratings').hide('slow');
});
$('#submitrating').click(function () {
var domain = '<?php echo $_domain; ?>';
......@@ -41,9 +41,9 @@ R::usePartialBeans(true);
url: 'db/saverating.php',
data: 'username=' + $('#username').val() + '&userurl=' + $('#userurl').val() + '&comment=' + $('#comment').val() + '&rating=' + $('#rating').val() + '&domain=' + domain,
success: function (msg) {
$('#submitrating').unbind('click');
if (msg == 1) {
$('#commentform').replaceWith('<h3>Your comment was saved, Thank You!</h3>');
$('#submitrating').unbind('click');
} else {
$('#errortext').html(msg);
$('#error').slideDown(633).delay(2500).slideUp(633);
......@@ -53,7 +53,7 @@ R::usePartialBeans(true);
});
$('#slider').slider({
animate: true, max: 10, min: 1, step: 1, value: 10, stop: function (event, ui) {
animate: true, max: 10, min: 1, step: 1, value: 5, stop: function (event, ui) {
var value = $('#slider').slider('option', 'value');
$('#rating').prop('value', value)
}
......@@ -61,17 +61,17 @@ R::usePartialBeans(true);
});
</script>
</head>
<body>
<div>
<?php
try {
$ratings = R::findAll('rating_comments', 'domain LIKE ?', [$_domain]);
$ratings = R::findAll('ratingcomments', 'domain LIKE ? ORDER BY date_created DESC LIMIT 8', [$_domain]);
} catch (\RedBeanPHP\RedException $e) {
die('Error in SQL query: ' . $e->getMessage());
}
echo '<input id="addrating" class="btn primary" style="float:right;margin-right:15px;" type="submit" value="Add a Rating"><h3>Podupti.me ratings for ' . $_domain . ' pod</h3><div id="ratings"><hr>';
echo '<div class="container ratings"><div class="row"><div class="col col-10"><h3>Podupti.me ratings for ' . $_domain . ' pod</h3></div></div>';
if (empty($ratings)) {
echo '<b>This pod has no rating yet!</b>';
} else {
......@@ -80,21 +80,21 @@ R::usePartialBeans(true);
echo 'Poduptime Approved Comment - User: <b>' . $rating['username'] . '</b> Url: <a href="' . $rating['userurl'] . '">' . $rating['userurl'] . '</a> Rating: <b>' . $rating['rating'] . '</b> <br>';
echo '<i>' . $rating['comment'] . '</i><span class="label" title="id: ' . $rating['id'] . '" style="float:right;margin-right:115px;">' . $rating['date_created'] . '</span><hr>';
} else {
echo 'User Comment - User: <b>' . $rating['username'] . '</b> Url: <a href="' . $rating['userurl'] . '">' . $rating['userurl'] . '</a> Rating: <b>' . $rating['rating'] . '</b> <br>';
echo '<i>' . $rating['comment'] . '</i><span class="label" title="id: ' . $rating['id'] . '" style="float:right;margin-right:115px;">' . $rating['date_created'] . '</span><hr style="margin-top:0;margin-bottom:15px;">';
echo '<div class="m-1 rounded bg-light"><div class="row"><div class="col-10">Comment from: <b>' . $rating['username'] . '</b></div> <div class="col">Rating: ' . $rating['rating'] . '</div></div>';
echo '<div class="row"><div class="col-10"><i>' . $rating['comment'] . '</i></div><div="col" title="id: ' . $rating['id'] . '">' . date('Y-m-d', strtotime($rating['date_created'])) . '</div></div>';
}
}
}
?>
</div>
<input id="addrating" class="btn primary" type="submit" value="Add a Rating">
</div>
<div id="commentform" style="display:none">
Would you like to add a comment?<br>
<label>Your Name (or Diaspora handle)?<br><input id="username" name="username"></label><br>
<label>Your Profile URL?<br><input id="userurl" name="userurl"></label><br>
<label>Comment<br><textarea id="comment" name="comment"></textarea></label><br>
<label>Your Name:<br><input id="username" name="username"></label><br>
<label>Comment:<br><textarea id="comment" name="comment"></textarea></label><br>
Rating (1-10 scale, 10 high)<br>
<div id="slider"></div>
<input class="disabled" disabled="" id="rating" name="rating" value="10"><br>
<input class="disabled" disabled="" id="rating" name="rating" value=""><br>
<input class="btn primary" id="submitrating" type="submit" value="Submit your Rating">
<div class="alert-message warning" id="error" style="display:none">
<span id="errortext">Some Error</span>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment