/** * Render comments * @return string XHTML item */ public function getCommentHtml($shareComment = FALSE) { global $CFG; $mysql = new mysqlquery(); // WORKAROUND: Allow the page to accessed both ways if (!$_GET) { $_GET = $_POST; } // Get a list of comments and put them in an array called ${$_SESSION['RealS_prefix']}comments. $query = "SELECT {$_SESSION['RealS_prefix']}webcells.*, {$_SESSION['RealS_prefix']}comments.*, {$_SESSION['RealS_prefix']}members.*, {$_SESSION['RealS_prefix']}items.item_parent_item, {$_SESSION['RealS_prefix']}items.item_default_type\r\n\t\t\t\t\tFROM {$_SESSION['RealS_prefix']}items\r\n\t\t\t\t\t\tLEFT JOIN {$_SESSION['RealS_prefix']}webcells ON {$_SESSION['RealS_prefix']}webcells.webcell_id={$_SESSION['RealS_prefix']}items.item_webcell\r\n\t\t\t\t\t\tLEFT JOIN {$_SESSION['RealS_prefix']}comments ON {$_SESSION['RealS_prefix']}comments.comment_item={$_SESSION['RealS_prefix']}items.item_id\r\n\t\t\t\t\t\tLEFT JOIN {$_SESSION['RealS_prefix']}members ON {$_SESSION['RealS_prefix']}members.mb_id={$_SESSION['RealS_prefix']}webcells.webcell_member\r\n\t\t\t\t\tWHERE {$_SESSION['RealS_prefix']}items.item_parent_item = " . $mysql->escape_value($this->comment_parent_item_id, 'int') . "\r\n\t\t\t\t\t\tAND {$_SESSION['RealS_prefix']}items.item_default_type = 9\r\n\t\t\t\t\t\tAND {$_SESSION['RealS_prefix']}comments.comment_share = " . $mysql->escape_value($this->share_id, 'int') . "\r\n\t\t\t\t\tORDER BY {$_SESSION['RealS_prefix']}comments.comment_date DESC"; // Debugging //echo $query; $comments = $mysql->runsql($query); $html = ''; if (count($comments) > 0) { //$this->renderSupportingJavascript(); $userview = new userviews(); //$mentorMemberId = $userview->getShareOrRequestMentorId($this->share_id); //$mentorName = $userview->getMemberName($mentorMemberId); $i = 1; foreach ($comments as $comment) { // Return the number of ratings for this item $query = "select count(*) as itemCount\r\n\t\t\t\t\t\t\tfrom {$_SESSION['RealS_prefix']}item_rating\r\n\t\t\t\t\t\t\twhere ir_itemid=" . $comment['comment_item']; $mysql = new mysqlquery(); $ratings = $mysql->runsql($query); $itemRating = $ratings[0]['itemCount']; $mentorId = 0; // Do highlight table $html .= "<table"; //if ( $_GET['item_highlight'] === $comment['comment_item'] ) { // $html .= " style=\"border: 3px solid red;\""; //} $html .= "><tr><td>"; $reportQuery = "select count(*) as reportCount\r\n\t\t\t\t\t\t\tfrom {$_SESSION['RealS_prefix']}item_reports\r\n\t\t\t\t\t\t\twhere ir_itemid=" . $comment['comment_item'] . "\r\n\t\t\t\t\t\t\t\tand ir_status!='DECLINED'"; $reportResult = $mysql->runsql($reportQuery); $itemReports = $reportResult[0]['reportCount']; $html .= "\n\n<!-- Comment " . $comment['comment_item'] . " start -->\n\n"; if ($itemReports == 0 || isset($_GET['viewall'])) { $html .= "<div class=\"profile\">"; if ($comment['mb_pic'] != "") { $html .= "<img src=\"" . $CFG->wwwroot . "/mod/rafl/st_pictures/" . $comment['mb_pic'] . "\" width=\"62\" height=\"62\" alt=\"" . $comment['mb_firstname'] . " " . $comment['mb_surmame'] . "\" />"; } else { $html .= "<img src=\"" . $CFG->wwwroot . "/mod/rafl/images/learner.gif\" width=\"62\" height=\"62\" alt=\"" . $comment['mb_firstname'] . " " . $comment['mb_surmame'] . "\" />"; } $html .= "</div>"; $html .= '<div class="comment_content" id="com_' . $i . '">'; $html .= '<div class="comment_title">' . $comment['webcell_title'] . '</div>'; // Stop public pages from having any comment functions if (strlen($_SESSION['USER']->id)) { // Rate this if ($comment['mb_id'] != $_SESSION['USER']->id) { // Do review smiley $html .= "<div class=\"comment_review\"><p>"; $html .= "<span id=\"rating" . $comment['comment_item'] . "\">" . $itemRating . "</span>"; $html .= "<a href=\"#rate\" title=\"I found this useful\" onclick=\"rateItem(" . $comment['comment_item'] . "," . $_SESSION['USER']->id . ");\"><img src=\"" . $CFG->wwwroot . "/mod/rafl/images/review.gif\" width=\"18\" height=\"16\" alt=\"Review\" style=\"margin-left:4px;\" /></a>"; $html .= "</p></div>"; } } $html .= '<div class="comment_info">'; $html .= '<span class="member_name">'; $html .= date('d.m.y | H:i', strtotime($comment['comment_date'])); $html .= '</div>'; $html .= '<div class="comment_webcell" id="body' . $i . '">' . $comment['webcell_text'] . '</div>'; // Stop public pages from having any comment functions if (strlen($_SESSION['USER']->id)) { $html .= '<div class="comment_tools">'; $html .= '<p id="close_' . $i . '" style="display: block;">'; $comment_tool_items = array(); // Rate this if ($comment['mb_id'] != $_SESSION['USER']->id) { $comment_tool_items[] = '<a href="#rate" title="I found this useful" onclick="rateItem(' . $comment['comment_item'] . ',' . $_SESSION['USER']->id . ');">I found this useful</a>'; } // Comment on this if ($shareComment == 1) { if ($comment['mb_id'] == $_SESSION['USER']->id) { $add_phrase = 'add to my comment'; } else { $add_phrase = 'add to this comment'; } $comment_tool_items[] = '<a href="#" title="quote" onclick="displayComment(' . $this->comment_parent_item_id . '); quoteItem(' . $comment['comment_item'] . ');">' . $add_phrase . '</a>'; } // Edit/delete or report if ($comment['mb_id'] == $_SESSION['USER']->id) { // Edit and delete is only shown if you were the author of this comment $comment_tool_items[] = "<a href=\"#\" title=\"edit\" onclick=\"displayEdit(" . $this->comment_parent_item_id . "); editComment(" . $comment['comment_item'] . ");\">edit my comment</a>"; $comment_tool_items[] = "<a href=\"#\" title=\"delete\" onclick=\"deleteItem(" . $comment['comment_item'] . "," . $i . ");\">delete my comment</a>"; } else { // We only show report if there is a mentor in charge of this share //if ( $mentorMemberId !== FALSE && $shareComment == 1) { //$comment_tool_items[] = "<a href=\"#\" title=\"report\" onclick=\"reportItem(".$comment['comment_item'].",".$_SESSION['USER']->id.",".$comment['comment_share'].",".$mentorMemberId.",".$i.");\">report this comment to " . $mentorName . "</a>"; //} } $html .= implode(' | ', $comment_tool_items); $html .= '</p>'; $html .= '</div>'; } $html .= '</div>'; } else { $html .= "This comment has been reported."; } $html .= "\n\n<!-- Comment " . $comment['comment_item'] . " end -->\n\n"; // End highlight table $html .= "</td></tr></table>"; // Do dotted line $html .= "<div class=\"comment\"></div>"; $comment_ids_viewed[] = $comment['comment_item']; // The comments is getting viewed now on this page, so reset the "unviewed" counter //$obj_count = new commentEvidenceCount(); //$obj_count->resetCommentCounter($comment['comment_item']); $i++; } } $comment_html = ''; if ($shareComment == 1) { $comment_html .= $this->getAddCommentLink('Add a comment') . '<br />'; } if (strlen($html)) { $comment_html .= $html; if ($shareComment == 1) { $comment_html .= $this->getAddCommentLink('Add a comment') . '<br />'; } } if (strlen($this->comment_parent_item_id)) { $comment_html = '<div id="comment_container_' . $this->comment_parent_item_id . '">' . $comment_html . '</div>'; } return $comment_html; }
function getWebcellTitle($arg_item_id) { $mysql = new mysqlquery(); $query = "SELECT webcell_title\r\n\t\t FROM {$_SESSION['RealS_prefix']}webcells\r\n\t\t \tINNER JOIN {$_SESSION['RealS_prefix']}items ON item_webcell = webcell_id\r\n\t\t WHERE item_id = " . $mysql->escape_value($arg_item_id, 'int'); if ($row = $mysql->getrow($query)) { return $row['webcell_title']; } }
<?php //---------------------------------------------------------------------------------------------- // Desc: Gets a mentor's comment based on a success criteria // Depd: This page is an AJAX snipplet //---------------------------------------------------------------------------------------------- // Gimme libraries require_once "../../config.php"; include_once 'includes/rlsmart/header.php'; require_once 'userviews_class.php'; require_once 'classes/item/Comments.class.php'; require_once 'classes/class_text_editor.php'; $userview = new userviews(); $parent_data = $userview->findParent($_GET['item_id'], "rafl"); if (strlen($_GET['share_id'])) { $userview->checkSharedRights($_GET['share_id']); } else { $userview->checkViewRights(); } $mysql = new mysqlquery(); // Gimme the evidence item id $sql = "SELECT {$_SESSION['RealS_prefix']}items.item_id AS evidence_item_id\r\n\t FROM {$_SESSION['RealS_prefix']}items\r\n\t \tINNER JOIN {$_SESSION['RealS_prefix']}webcells ON {$_SESSION['RealS_prefix']}items.item_webcell = {$_SESSION['RealS_prefix']}webcells.webcell_id\r\n\t WHERE {$_SESSION['RealS_prefix']}items.item_parent_item = " . $mysql->escape_value($_GET['success_id'], "int") . "\r\n\t \tAND {$_SESSION['RealS_prefix']}items.item_default_type = 6"; $row = $mysql->getrow($sql); // Gimme the mentor's comments on the evidence $obj_comment = new rs_itemComments($mysql, 1, 'rafl', $_GET['share_id'], $parent_data['item_id'], $row['evidence_item_id'], 'layouts/rafl_css.php'); //$obj_comment->renderSupportingJavascript(); echo $obj_comment->getCommentHtml($userview->shareComment);