From 3b83dad22ca304cd664c1b866ff6074656301e4b Mon Sep 17 00:00:00 2001 From: Jayaram Pai Date: Sat, 1 Mar 2014 18:17:16 +0530 Subject: added comments/view comments/new, tabs for the external reviewers --- tbc_external_review.module | 90 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 4 deletions(-) (limited to 'tbc_external_review.module') diff --git a/tbc_external_review.module b/tbc_external_review.module index b573bf9..ea3f635 100644 --- a/tbc_external_review.module +++ b/tbc_external_review.module @@ -33,10 +33,26 @@ "type" => MENU_NORMAL_ITEM ); $items["tbc_external_review/comments"] = array( - "title" => "External Review Comments", + "title" => "Comments", "page callback" => "tbc_external_review_comments_all", "access arguments" => array("download tbc_external_review"), - "type" => MENU_NORMAL_ITEM + "access callback" => TRUE, + "weight" => 30, + "type" => MENU_NORMAL_ITEM, + ); + $items["tbc_external_review/comments/new"] = array( + "title" => "New Comment", + "page callback" => "tbc_external_review_comments_all", + "access callback" => TRUE, + "weight" => 1, + "type" => MENU_DEFAULT_LOCAL_TASK, + ); + $items["tbc_external_review/comments/view"] = array( + "title" => "View Comments", + "page callback" => "tbc_external_review_comments_view_all", + "access callback" => TRUE, + "weight" => 2, + "type" => MENU_LOCAL_TASK, ); $items["tbc_external_review/manage_comments"] = array( "title" => "ER Manage Comments", @@ -374,6 +390,72 @@ return $page_content; } + function tbc_external_review_comments_view_all($preference_id = 0) { + global $user; + $page_content = ""; + if($preference_id) { + $query = " + SELECT erc.*, cha.number AS chapter, exa.number AS example FROM external_review_comments erc + 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 + "; + $result = db_query($query, $preference_id); + $headers = array( + "Chapter", "Example", + "Time", "Action" + ); + $rows = array(); + while($row = db_fetch_object($result)) { + $options = array( + /* # linking in drupal l() */ + "fragment" => " ", + "external" => TRUE, + "attributes" => array( + "class" => "view-comment", + "data-comment" => "{$row->id}", + ) + ); + $item = array( + "{$row->chapter}", + "{$row->example}", + "{$row->time}", + l("View", "", $options), + ); + array_push($rows, $item); + } + $page_content .= theme("table", $headers, $rows); + $page_content .= "