diff options
Diffstat (limited to 'cloud_comments.module')
-rwxr-xr-x | cloud_comments.module | 45 |
1 files changed, 28 insertions, 17 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 |