diff options
author | Jayaram Pai | 2013-11-24 12:28:34 +0530 |
---|---|---|
committer | Jayaram Pai | 2013-11-24 12:28:34 +0530 |
commit | 265e6a621ed3a171c0672866105b92c61678c0dc (patch) | |
tree | c032a8407fc8a83648df6d7d12bbf1e8b9ccc29b | |
parent | fce5d489e1e90cb0ca58b54e249ec72eef00e86a (diff) | |
download | cloud-comments-265e6a621ed3a171c0672866105b92c61678c0dc.tar.gz cloud-comments-265e6a621ed3a171c0672866105b92c61678c0dc.tar.bz2 cloud-comments-265e6a621ed3a171c0672866105b92c61678c0dc.zip |
adding timestamp, dynamic emails
-rwxr-xr-x | cloud_comments.module | 45 | ||||
-rw-r--r-- | css/cloud_comments.css | 25 | ||||
-rw-r--r-- | js/cloud_comments.js | 27 |
3 files changed, 75 insertions, 22 deletions
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("<div class='feedback {$border}'>"); + $page_content .= t("<div class='timestamp'>") . $row->date . t("</div>"); $page_content .= t("<div class='from'> <b>From:</b> ") . $row->email . t("</div>"); - + $page_content .= t("<div class='type'> <b>Type:</b> ") . $types[$row->type] . t("</div>"); - + $q = "SELECT book from {textbook_companion_preference} where id = '%d'"; $qr = db_query($q, $row->books); $obj = db_fetch_object($qr); $page_content .= t("<div class='type'> <b>Book:</b> ") . $obj->book . t("</div>"); - + $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("<div class='type'> <b>Chapter: </b> ") . $chapter . t("</div>"); - + $page_content .= t("<div class='type'> <b>Category: </b>") . $categories[$row->category] . t("</div>"); - + $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("<div class='example'> <b>Example: </b>") . $example_link .t("</div>"); - + $page_content .= t("<div class='comment'> <br><b>Comment:</b><br>") . $row->comment . t("</div>"); - + if ($row->reply) { $page_content .= t("<div class='reply'> <br><b>Reply Sent:</b><br>") . $row->reply . t("</div>"); } else { if (user_access("reply cloud_comments")) { - $page_content .= t("<a class='form_{$row->id}' href='#form_{$row->id}'>Reply</a><br>"); + $page_content .= t("<span class='btn-reply'><a class='form_{$row->id}' href='#form_{$row->id}'>Reply</a></span><br>"); $page_content .= t("<div id='form_{$row->id}' class='form-wrapper'>"); $page_content .= drupal_get_form("cloud_comments_reply_form_".$row->id, $row->id); $page_content .= t("</div>"); + $page_content .= t("<a href='cloud_comments/delete/{$row->id}' id='del_{$row->id}' class='delete'>x</a>"); } } $page_content .= t("</div>"); @@ -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 diff --git a/css/cloud_comments.css b/css/cloud_comments.css index cffaa7e..6392101 100644 --- a/css/cloud_comments.css +++ b/css/cloud_comments.css @@ -1,6 +1,7 @@ .feedback { + position: relative; padding: 10px; - margin: 10px; + margin: 15px 10px; min-height: 100px; background: #f5f5f5; -webkit-border-radius: 5px; @@ -8,9 +9,31 @@ -o-border-radius: 5px; border-radius: 5px; } +.timestamp { + position: absolute; + right: 55px; + top: 10px; + color: #aaaaaa; +} .sent { border: 2px solid #86c543; } .not-sent { border: 2px solid tomato; } +.btn-reply { + position: absolute; + right: 10px; + bottom: 10px; + padding: 5px; + background: brown; +} +.btn-reply a{ + text-decoration: none; + color: #ffffff; +} +.delete { + position: absolute; + top: 10px; + right: 10px; +} diff --git a/js/cloud_comments.js b/js/cloud_comments.js index 9f4c2ad..59523d4 100644 --- a/js/cloud_comments.js +++ b/js/cloud_comments.js @@ -1,10 +1,29 @@ $(document).ready(function(){ - $(".feedback a").click(function(){ + /* to avoid CKE partial loading... */ + $('.form-wrapper').slideToggle(); + + /* reply button action */ + $(".btn-reply a").click(function(){ var clicked = $(this).attr("class"); - console.log(clicked); $('#'+clicked).slideToggle(); + console.log($(this).html()); + if ($(this).html() == "Reply") { + $(this).html("Close"); + } else { + $(this).html("Reply"); + } }); - /* to avoid CKE partial loading... */ - $('.form-wrapper').slideToggle(); + /* delete link */ + $(".delete").click(function(e){ + sure = confirm("Are you sure ?"); + console.log(sure); + if (sure) { + window.location.href = $(this).attr("href"); + } + else { + console.log("nopees"); + } + e.preventDefault(); + }); }); |