From a2b141ef477dfa2fcffdf9ddb8b4dfdb58e8b8e5 Mon Sep 17 00:00:00 2001 From: Jayaram R Pai Date: Fri, 20 Jun 2014 14:23:05 +0530 Subject: added filtering for an examples comment --- cloud_comments.module | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cloud_comments.module b/cloud_comments.module index 467cd52..26c444a 100755 --- a/cloud_comments.module +++ b/cloud_comments.module @@ -14,7 +14,7 @@ function cloud_comments_perm() { return array("access cloud_comments", "reply cloud_comments"); } // function cloud_comments_perm -function cloud_comments_all() { +function cloud_comments_all($example_id=0) { $types = array( "None", "Blank Code / Incorrect code", @@ -43,7 +43,11 @@ function cloud_comments_all() { ); $page_content = ""; - $query = "SELECT scc.*, tcc.number AS chapter_no, tce.number AS example_no FROM scilab_cloud_comment scc LEFT JOIN textbook_companion_chapter tcc ON tcc.id = scc.chapter LEFT JOIN textbook_companion_example tce ON tce.id = scc.example ORDER BY scc.date DESC"; + if($example_id) { + $query = "SELECT scc.*, tcc.number AS chapter_no, tce.number AS example_no FROM scilab_cloud_comment scc LEFT JOIN textbook_companion_chapter tcc ON tcc.id = scc.chapter LEFT JOIN textbook_companion_example tce ON tce.id = scc.example WHERE scc.example = {$example_id} ORDER BY scc.date DESC"; + } else { + $query = "SELECT scc.*, tcc.number AS chapter_no, tce.number AS example_no FROM scilab_cloud_comment scc LEFT JOIN textbook_companion_chapter tcc ON tcc.id = scc.chapter LEFT JOIN textbook_companion_example tce ON tce.id = scc.example ORDER BY scc.date DESC"; + } $query_result = pager_query($query, 5, 0 ); //$query_result = db_query($query); @@ -53,7 +57,9 @@ function cloud_comments_all() { $page_content .= t("
"); $page_content .= t("
") . $row->date . t("
"); - $page_content .= t("
From: ") . $row->email . t("
"); + if (user_access("reply cloud_comments")) { + $page_content .= t("
From: ") . $row->email . t("
"); + } $page_content .= t("
Type: ") . $types[$row->type] . t("
"); -- cgit