From 8a6d60675b48217108abb8b49620c78b94e574e6 Mon Sep 17 00:00:00 2001
From: Jayaram Pai
Date: Fri, 7 Mar 2014 11:03:07 +0530
Subject: added hide/show comments feature
---
tbc_external_review.module | 37 +++++++++++++++++++++++++++++++++----
1 file changed, 33 insertions(+), 4 deletions(-)
(limited to 'tbc_external_review.module')
diff --git a/tbc_external_review.module b/tbc_external_review.module
index 1c1c83b..8f89ac9 100644
--- a/tbc_external_review.module
+++ b/tbc_external_review.module
@@ -681,7 +681,7 @@
while($row = db_fetch_object($result)) {
$data .= "";
}
- } else if($item = "comment" && $key) {
+ } else if($item == "comment" && $key) {
$query = "
SELECT * FROM external_review_comments erc
LEFT JOIN textbook_companion_example_files tcef
@@ -711,6 +711,14 @@
$data .= "";
$data .= "";
+ } else if($item == "hide-show" && $key) {
+ $query = "
+ UPDATE external_review_comments
+ SET hidden = !hidden
+ WHERE id = %d
+ ";
+ $result = db_query($query, $key);
+ $data .= $key;
}
echo $data;
exit();
@@ -819,7 +827,7 @@
LEFT JOIN textbook_companion_chapter cha ON cha.id = erc.chapter_id
LEFT JOIN textbook_companion_example exa ON exa.id = erc.example_id
WHERE erc.preference_id = %d
- ORDER BY erc.time DESC
+ ORDER BY erc.chapter_id, erc.example_id
";
$result = db_query($query, $preference_id);
$headers = array(
@@ -828,7 +836,7 @@
);
$rows = array();
while($row = db_fetch_object($result)) {
- $options = array(
+ $view_options = array(
/* # linking in drupal l() */
"fragment" => " ",
"external" => TRUE,
@@ -837,6 +845,15 @@
"data-comment" => "{$row->id}",
)
);
+ $hide_options= array(
+ /* # linking in drupal l() */
+ "fragment" => " ",
+ "external" => TRUE,
+ "attributes" => array(
+ "class" => "hide-show",
+ "data-comment" => "{$row->id}",
+ )
+ );
/* scoring comments */
$score = 0;
@@ -857,13 +874,24 @@
"{$row->example}",
"{$row->time}",
"{$score}",
- l("View", "", $options),
+ l("View", "", $view_options),
),
);
if($row->sfu == 1 || $row->sum == 0 || $row->amt == 1) {
$error_class = array("class" => "error-comment");
$item = array_merge($item, $error_class);
}
+ if($row->hidden) {
+ $item["class"] .= " dull";
+ }
+ /* hide/unhide link */
+ end($item["data"]);
+ $key= key($item["data"]);
+ if($row->hidden) {
+ $item["data"][$key] .= " | " . l("Show", "", $hide_options);
+ } else {
+ $item["data"][$key] .= " | " . l("Hide", "", $hide_options);
+ }
array_push($rows, $item);
}
$page_content .= theme("table", $headers, $rows);
@@ -1047,6 +1075,7 @@
function tbc_external_review_test_all() {
global $user;
$page_content = "";
+
/* sending mail */
$to = "rush2jrp@gmail.com";
$from = "jayaram@iitb.ac.in";
--
cgit