/** * 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 checkSharedRights($shareId) { if (!strlen($this->parentData['item_id'])) { echo '<script type="text/javascript">alert("Error: No parent found.")</script>'; exit; } else { // Check shareid and itemid match $query = "SELECT {$_SESSION['RealS_prefix']}share.*, {$_SESSION['RealS_prefix']}subjects.*, {$_SESSION['RealS_prefix']}share_type.*, {$_SESSION['RealS_prefix']}cohorts.cohort_name, {$_SESSION['RealS_prefix']}members.mb_type\r\n\t\t\t FROM {$_SESSION['RealS_prefix']}share\r\n\t \t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}members ON {$_SESSION['RealS_prefix']}members.mb_id = {$_SESSION['RealS_prefix']}share.share_member\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}share_cohort ON {$_SESSION['RealS_prefix']}share_cohort.share_cohort_share = {$_SESSION['RealS_prefix']}share.share_id\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}cohorts ON {$_SESSION['RealS_prefix']}cohorts.cohort_id = {$_SESSION['RealS_prefix']}share_cohort.share_cohort_cohort\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}subjects ON {$_SESSION['RealS_prefix']}share.share_subject = {$_SESSION['RealS_prefix']}subjects.subject_id\r\n\t\t\t \tLEFT JOIN {$_SESSION['RealS_prefix']}share_type ON {$_SESSION['RealS_prefix']}share_type.invite_type_id = {$_SESSION['RealS_prefix']}share.share_type\r\n\t\t\t WHERE share_item = " . $this->parentData['item_id'] . "\r\n\t\t\t \tAND share_id = " . $shareId; $mysql = new mysqlquery(); $share_data = $mysql->runsql($query); $this->shareData = $share_data[0]; $this->sharePublic = $share_data[0]['share_public']; $this->shareType = $share_data[0]['invite_type_name']; $this->cohortName = $share_data[0]['cohort_name']; // Debugging //die($query); $_SESSION['RealS_usertype'] = 'learner'; // Check share rights if (!strlen($_SESSION['USER']->id) && $this->sharePublic == 0) { // Not logged in and not public require_once "main/failed.php"; exit(0); } elseif (count($this->shareData) == 0) { // Wrong share id echo '<script type="text/javascript">alert(\'Wrong share id.\')</script>'; exit; } elseif ($this->shareData['share_active'] == "PENDING" || $this->shareData['share_active'] == "DECLINED") { // Not accepted echo '<script type="text/javascript">alert(\'You can not view a ' . $this->shareData['share_active'] . ' share. Please check your sharing request status for this item.\')</script>'; exit; } elseif (strlen($_SESSION['USER']->id)) { if ($this->shareData['share_member'] == $_SESSION['USER']->id) { // You are the sharer $this->shareComment = 1; $this->sharer = 1; if ($this->shareData['mb_type'] == 'mentor') { $this->shareMentor = 1; $_SESSION['RealS_usertype'] = 'mentor'; } } else { if ($this->shareData['share_permission'] == $_SESSION['USER']->id) { // You are the request mentor $this->shareComment = 1; $this->shareMentor = 1; $_SESSION['RealS_usertype'] = 'mentor'; } else { if (isset($_SESSION['USER']->id)) { // Check if you are an additional share mentor $query = "SELECT {$_SESSION['RealS_prefix']}share_mentor.share_mentor_mentor, {$_SESSION['RealS_prefix']}share_mentor.share_mentor_status\r\n\t\t\t\t\t FROM {$_SESSION['RealS_prefix']}share\r\n\t\t\t\t\t INNER JOIN {$_SESSION['RealS_prefix']}share_mentor ON {$_SESSION['RealS_prefix']}share.share_id = {$_SESSION['RealS_prefix']}share_mentor.share_mentor_share\r\n\t\t\t\t\t WHERE {$_SESSION['RealS_prefix']}share_mentor.share_mentor_mentor = " . $_SESSION['USER']->id . "\r\n\t\t\t\t\t AND {$_SESSION['RealS_prefix']}share_mentor.share_mentor_share=" . $shareId; // Debugging //die($query . '-' . $_SESSION['USER']->id); $mysql = new mysqlquery(); $result = $mysql->runsql($query); if (count($result) > 0) { // You are an additional mentor of this item $this->shareComment = 1; $this->shareMentor = 1; $_SESSION['RealS_usertype'] = 'mentor'; if ($result[0]['share_mentor_mentor'] == $_SESSION['USER']->id && $result[0]['share_mentor_status'] == 'NEW') { // Update status $query = "UPDATE {$_SESSION['RealS_prefix']}share_mentor\r\n\t\t\t\t\t\t\t SET share_mentor_status = 'OLD'\r\n\t\t\t\t\t\t\t WHERE share_mentor_share = " . $this->shareData['share_id'] . "\r\n\t\t\t\t\t\t\t AND share_mentor_mentor = " . $_SESSION['USER']->id; $mysql = new mysqlquery(); $result = $mysql->runsql2($query); } } } } } } // Allow public shares if (strlen($_SESSION['USER']->id)) { // Update sharer status if ($this->shareData['share_member'] == $_SESSION['USER']->id && $this->shareData['share_status'] == 'NEW') { //update status $query = "UPDATE {$_SESSION['RealS_prefix']}share\r\n\t\t\t\t\t SET share_status = 'OLD'\r\n\t\t\t\t\t WHERE share_id = " . $this->shareData['share_id']; $mysql = new mysqlquery(); $result = $mysql->runsql2($query); } // Check if you are part of cohort $query = "SELECT {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_member, {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_status\r\n\t\t\t\t FROM {$_SESSION['RealS_prefix']}share\r\n\t\t\t\t \tINNER JOIN {$_SESSION['RealS_prefix']}share_cohort_members ON {$_SESSION['RealS_prefix']}share.share_id = {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_share\r\n\t\t\t\t WHERE {$_SESSION['RealS_prefix']}share_cohort_members.s_c_m_member = " . $_SESSION['USER']->id . "\r\n\t\t\t\t \tAND {$_SESSION['RealS_prefix']}share.share_id = " . $shareId; $mysql = new mysqlquery(); $result = $mysql->runsql($query); if (count($result) > 0) { // This is shared with you $this->shareComment = 1; $this->shareMember = 1; if ($result[0]['s_c_m_member'] == $_SESSION['USER']->id && $result[0]['s_c_m_status'] == 'NEW') { // Update cohort member status $query = "UPDATE {$_SESSION['RealS_prefix']}share_cohort_members\r\n\t\t\t\t\t\t SET s_c_m_status = 'OLD'\r\n\t\t\t\t\t\t WHERE s_c_m_share = " . $this->shareData['share_id'] . "\r\n\t\t\t\t\t\t AND s_c_m_member = " . $_SESSION['USER']->id; $mysql = new mysqlquery(); $result = $mysql->runsql2($query); } } else { if ($this->sharer == 0 && $this->shareMentor == 0 && $this->sharePublic == 0) { // Nothing to do with you and not public echo '<script type="text/javascript">alert(\'You may need to login to view this page.\')</script>'; exit; } } } } }
} if (strlen($_SESSION['USER']->id)) { $userData = $mysql->getRow("SELECT mb_icon FROM {$_SESSION['RealS_prefix']}members WHERE mb_id=" . $_SESSION['USER']->id); $icon = $userData['mb_icon']; } $colname_rs_success = "-1"; if (isset($_GET['item_id'])) { $colname_rs_success = $_GET['item_id']; } mysql_select_db($CFG->dbname, $smart); // Gimme all success criteria // Subquery: Conclude from the comment item id what the comment count for each success item must be $query_rs_success = "SELECT\r\n\t \t{$_SESSION['RealS_prefix']}items.item_id,\r\n\t \t{$_SESSION['RealS_prefix']}webcells.webcell_title,\r\n\t \t{$_SESSION['RealS_prefix']}webcells.webcell_text,\r\n\t \t{$_SESSION['RealS_prefix']}rafl.rafl_collective,\r\n\t \t{$_SESSION['RealS_prefix']}rafl.rafl_success_evid_req,\r\n\t \t{$_SESSION['RealS_prefix']}rafl.rafl_success_obj\r\n\t FROM {$_SESSION['RealS_prefix']}items\r\n\t \tLEFT OUTER JOIN {$_SESSION['RealS_prefix']}webcells ON {$_SESSION['RealS_prefix']}webcells.webcell_id={$_SESSION['RealS_prefix']}items.item_webcell\r\n\t \tLEFT OUTER JOIN {$_SESSION['RealS_prefix']}rafl ON {$_SESSION['RealS_prefix']}rafl.rafl_item={$_SESSION['RealS_prefix']}items.item_id\r\n\t \tLEFT OUTER JOIN {$_SESSION['RealS_prefix']}members ON {$_SESSION['RealS_prefix']}webcells.webcell_member = {$_SESSION['RealS_prefix']}members.mb_id\r\n\t WHERE {$_SESSION['RealS_prefix']}items.item_parent_item = " . GetSQLValueString($colname_rs_success, "int") . "\r\n\t \tAND {$_SESSION['RealS_prefix']}items.item_default_type = 1\r\n\t ORDER BY {$_SESSION['RealS_prefix']}rafl.rafl_order"; //$query_rs_success = sprintf("SELECT {$_SESSION['RealS_prefix']}webcells.*, {$_SESSION['RealS_prefix']}items.item_id, {$_SESSION['RealS_prefix']}rafl.* FROM rafl INNER JOIN items ON {$_SESSION['RealS_prefix']}rafl.rafl_item = {$_SESSION['RealS_prefix']}items.item_id INNER JOIN webcells ON {$_SESSION['RealS_prefix']}items.item_webcell = {$_SESSION['RealS_prefix']}webcells.webcell_id WHERE item_parent_item = %s", GetSQLValueString($colname_rs_success, "int")); $mysql = new mysqlquery(); $successes = $mysql->runsql($query_rs_success); //$rs_success = mysql_query($query_rs_success, $smart) or die(mysql_error()); //$success = mysql_fetch_assoc($rs_success); $Javascript = ""; if (count($successes) > 0) { ?> <table cellspacing="2" class="successTable" id="successTable" summary="Rating of a success criteria"> <tr> <th class="task_a"><?php if ($successes[0]['rafl_collective'] != "1") { ?> I <?php } else { ?> WE