From 265e6a621ed3a171c0672866105b92c61678c0dc Mon Sep 17 00:00:00 2001
From: Jayaram Pai
Date: Sun, 24 Nov 2013 12:28:34 +0530
Subject: adding timestamp, dynamic emails
---
cloud_comments.module | 45 ++++++++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 17 deletions(-)
(limited to 'cloud_comments.module')
diff --git a/cloud_comments.module b/cloud_comments.module
index 868319a..ff5bf9f 100755
--- a/cloud_comments.module
+++ b/cloud_comments.module
@@ -41,51 +41,53 @@ function cloud_comments_all() {
"Computer Programming",
"Others"
);
-
+
$page_content = "";
$query = "SELECT * FROM {scilab_cloud_comment}";
$query_result = db_query($query);
while ($row = db_fetch_object($query_result)) {
-
+
$border = $row->reply_status?"sent":"not-sent";
$page_content .= t("
");
+ $page_content .= t("
") . $row->date . t("
");
$page_content .= t("
From: ") . $row->email . t("
");
-
+
$page_content .= t("
Type: ") . $types[$row->type] . t("
");
-
+
$q = "SELECT book from {textbook_companion_preference} where id = '%d'";
$qr = db_query($q, $row->books);
$obj = db_fetch_object($qr);
$page_content .= t("
Book: ") . $obj->book . t("
");
-
+
$q = "SELECT name from {textbook_companion_chapter} where id = '%d'";
$qr = db_query($q, $row->chapter);
$obj = db_fetch_object($qr);
$chapter = $obj->name?$obj->name:"None";
$page_content .= t("
Chapter: ") . $chapter . t("
");
-
+
$page_content .= t("
Category: ") . $categories[$row->category] . t("
");
-
+
$q = "SELECT caption from {textbook_companion_example} where id = '%d'";
$qr = db_query($q, $row->example);
$obj = db_fetch_object($qr);
$example_link = $obj->caption?l($obj->caption,"http://cloud.scilab.in/index.php?eid=".$row->example):"None";
-
+
$page_content .= t("
Example: ") . $example_link .t("
");
-
+
$page_content .= t("");
-
+
if ($row->reply) {
$page_content .= t("
Reply Sent:
") . $row->reply . t("
");
}
else {
if (user_access("reply cloud_comments")) {
- $page_content .= t("
Reply");
+ $page_content .= t("
Reply");
$page_content .= t("
");
$page_content .= drupal_get_form("cloud_comments_reply_form_".$row->id, $row->id);
$page_content .= t("
");
+ $page_content .= t("
x");
}
}
$page_content .= t("
");
@@ -130,8 +132,12 @@ function cloud_comments_reply_form_submit($form, &$form_state) {
$query = "UPDATE {scilab_cloud_comment} SET reply = '%s', reply_status = 1 WHERE id = %d";
$query_result = db_query($query, $form_state["values"]["content"], $form_state["values"]["hidden"]);
+ $email_query = "SELECT email FROM {scilab_cloud_comment} WHERE id = %d";
+ $result = db_query($email_query, $form_state["values"]["hidden"]);
+ $obj = db_fetch_object($result);
+
$message = array(
- 'to' => 'rush2jrp@gmail.com',
+ 'to' => $obj->email,
'subject' => t("Comment Reply"),
'body' => t($form_state["values"]["content"]),
'headers' => array("Content-type" => "text/html; charset=iso-8859-1")
@@ -141,17 +147,22 @@ function cloud_comments_reply_form_submit($form, &$form_state) {
if (!$query_result) {
drupal_set_message("Database updation failed");
} else {
- drupal_set_message("Message sent. . . ");
+ drupal_set_message("Message sent. . .");
}
} // function reply_form_submit
function cloud_comments_delete($comment_id=NULL) {
if ($comment_id && user_access("reply cloud_comments")) {
- return $comment_id;
- } else {
- return "NULL";
+ $query = "DELETE FROM {scilab_cloud_comment} WHERE id = %d";
+ $query_result = db_query($query, $comment_id);
+ if (db_affected_rows() > 0) {
+ drupal_set_message("Deleted");
+ } else {
+ drupal_set_message("MySQL Error: row deletion failed.");
+ }
}
+ drupal_goto("cloud_comments");
}
function cloud_comments_menu() {
@@ -169,7 +180,7 @@ function cloud_comments_menu() {
'access arguments' => array("access cloud_comments"),
'type' => MENU_CALLBACK,
);
-
+
return $items;
} // function cloud_comments_menu
--
cgit
Comment:
") . $row->comment . t("