diff options
author | Jayaram Pai | 2014-03-01 18:17:16 +0530 |
---|---|---|
committer | Jayaram Pai | 2014-03-01 18:17:16 +0530 |
commit | 3b83dad22ca304cd664c1b866ff6074656301e4b (patch) | |
tree | bccf9721345ad2011bf2cf71a751f5a1233a03b5 /tbc_external_review.module | |
parent | a08a9ade8ec5cb25561a63ee036a7a053617753f (diff) | |
download | tbc-external-review-3b83dad22ca304cd664c1b866ff6074656301e4b.tar.gz tbc-external-review-3b83dad22ca304cd664c1b866ff6074656301e4b.tar.bz2 tbc-external-review-3b83dad22ca304cd664c1b866ff6074656301e4b.zip |
added comments/view comments/new,
tabs for the external reviewers
Diffstat (limited to 'tbc_external_review.module')
-rw-r--r-- | tbc_external_review.module | 90 |
1 files changed, 86 insertions, 4 deletions
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 .= "<div id='lightbox-wrapper'>"; + $page_content .= "<div id='lightbox-inner'></div></div> "; + } else { + $query = " + SELECT * FROM textbook_companion_preference + WHERE id IN ( + SELECT preference_id FROM external_review_details + WHERE uid = %d + ) + "; + $result = db_query($query, $user->uid); + $headers = array( + "Book", "Author", + "Action" + ); + $rows = array(); + + while($row = db_fetch_object($result)) { + $item = array( + "{$row->book}", + "{$row->author}", + l("View", "tbc_external_review/comments/view/" . $row->id), + ); + array_push($rows, $item); + } + $page_content = theme("table", $headers, $rows); + } + return $page_content; + } + function tbc_external_review_comment_form($form_state) { $form = array(); global $user; @@ -635,7 +717,7 @@ $page_content = ""; if($preference_id) { global $user; - /* displaying comments of a particular user */ + /* displaying comments of a particular book */ $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 @@ -671,7 +753,7 @@ $page_content .= "<div id='lightbox-wrapper'>"; $page_content .= "<div id='lightbox-inner'></div></div> "; } else { - /* displaying the list of users */ + /* displaying the list of books */ $query = " SELECT DISTINCT erc.preference_id, pre.book, pre.author, usr_con.name AS contributor, usr_ext.name AS reviewer FROM external_review_comments erc |