From 036b8fcc803cd41676ed44525153d38a110562a1 Mon Sep 17 00:00:00 2001 From: posweg Date: Tue, 1 Sep 2020 10:40:22 +0000 Subject: [PATCH] Show "(private)" if question is private for clarity --- action/publish-question.php | 4 +++- action/reply.php | 2 +- include/header.php | 3 ++- themes/minimalpunk/css/user.css.php | 6 ++++++ user.php | 14 +++++++++++++- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/action/publish-question.php b/action/publish-question.php index 6bac38e..452e8b9 100644 --- a/action/publish-question.php +++ b/action/publish-question.php @@ -18,11 +18,13 @@ if(isset($_POST["post-submit"])){ $u = $p_user["id"]; $by = 0; $question = htmlspecialchars($_POST["post-text"], ENT_QUOTES); + $priv = 0; if(isset($_SESSION["uid"]) && !$_POST["anon"]) $by = $_SESSION["uid"]; + if($_POST["priv"]) $priv = 1; // Insert user into DB - $db->exec("INSERT INTO questions(user,by,question,q_date) VALUES ('$u','$by','$question',". strtotime('now') .");"); + $db->exec("INSERT INTO questions(user,by,question,q_date,private) VALUES ('$u','$by','$question',". strtotime('now') .",$priv);"); unset($_POST["post-text"]); if($fancy_urls) header("Location: /user/" . $p_user["username"]); else header("Location: /user.php?q=" . $p_user["username"]); diff --git a/action/reply.php b/action/reply.php index 39e0deb..d5238ab 100644 --- a/action/reply.php +++ b/action/reply.php @@ -63,7 +63,7 @@ else{ // echo strlen($tweet) . " - " . strlen($question["answer"]) . "

\n"; // echo $tweet; - if($user["tw_oauth_token"] && $user["tw_oauth_verify"]){ + if($user["tw_oauth_token"] && $user["tw_oauth_verify"] && $question['private'] != 1){ include("../include/tw-post.php"); post_tweet(htmlspecialchars_decode($tweet, ENT_QUOTES)); } diff --git a/include/header.php b/include/header.php index 01b943d..1026899 100644 --- a/include/header.php +++ b/include/header.php @@ -24,7 +24,8 @@ $db->exec("CREATE TABLE IF NOT EXISTS questions( q_date INTEGER, answer TEXT, a_date INTEGER, - status INTEGER + status INTEGER, + private INTEGER );"); if(!$db->querySingle("SELECT EXISTS(SELECT * FROM users where id = 0);")){ diff --git a/themes/minimalpunk/css/user.css.php b/themes/minimalpunk/css/user.css.php index 2c72f62..fcc749d 100644 --- a/themes/minimalpunk/css/user.css.php +++ b/themes/minimalpunk/css/user.css.php @@ -122,6 +122,12 @@ color: white; } +.question-private{ + font-size: 15px; + font-weight: normal; + color: +} + .answer{ clear: both; padding: 10px; diff --git a/user.php b/user.php index c4dbd43..bde57e5 100644 --- a/user.php +++ b/user.php @@ -123,6 +123,7 @@ if(isset($_GET["p"])){
"/>

name="anon"/> Post anonymously

+

Private

$errorMsg

\n"; ?> @@ -136,11 +137,17 @@ if(isset($_GET["p"])){ if(!$p_offset || $p_offset <= 0) $p_offset = 0; // TODO: Build a mechanism to make off-limits pages show as the last one + + + + $private_filter = ""; + if(!$is_current_user) $private_filter = "AND private IS NOT 1 AND answer IS NOT NULL"; + $q_count = $db->query('SELECT COUNT(*) FROM questions WHERE user = "' . $p_user["id"] . '";')->fetchArray(SQLITE3_ASSOC)['COUNT(*)']; $u_prep = $db->prepare("SELECT * FROM users WHERE id = :id"); - $qs = $db->query("SELECT * FROM questions WHERE user = '". $p_user["id"] ."' ORDER BY id DESC LIMIT ". $p_limit ." OFFSET ". $p_offset .";"); + $qs = $db->query("SELECT * FROM questions WHERE user = '". $p_user["id"] . "' " . $private_filter . " ORDER BY id DESC LIMIT ". $p_limit ." OFFSET ". $p_offset .";"); /** QUESTIONS MAIN LOOP **/ @@ -167,8 +174,13 @@ if(isset($_GET["p"])){ $new_get["q"] = $q_user["name"]; echo("" . $q_user["name"] .""); } + if($current["private"] == 1){ + echo(" "); + echo("(private)"); + } echo("

\n"); + // Actual text body echo("\t\t\t\t"); echo("

". $current["question"] ."

\n");