echo '<div id="middle-column" >'; echo '<div class="oublog-post-commented">'; echo $oublogoutput->render_post($cm, $oublog, $post, $returnurl, $blogtype, $canmanageposts, $canaudit, false, false); if (!empty($post->comments)) { // Code extracted to new renderer function. echo $oublogoutput->render_comments($post, $oublog, $canaudit, $canmanagecomments, false, $cm); } echo '</div>'; // If it is your own post, then see if there are any moderated comments - // for security reasons, you must also be allowed to comment on the post in // order to moderate it (because 'approving' a comment is basically equivalent // to commenting). // Logic should be if public comments are allowed and, // either post user and can comment, or can manage comments. $includeset = $canaudit; if ($post->allowcomments >= OUBLOG_COMMENTS_ALLOWPUBLIC && ($post->userid == $USER->id && oublog_can_comment($cm, $oublog, $post) || $canmanagecomments)) { // Also, if this is a personal global blog include accepted/rejected comments. if ($oublog->global) { $includeset = true; } $moderated = oublog_get_moderated_comments($oublog, $post, $includeset); $display = array(); foreach ($moderated as $comment) { if ($comment->approval != OUBLOG_MODERATED_APPROVED) { $display[] = $comment; } } if (count($display)) { print '<h2 id="awaiting">' . get_string('moderated_awaiting', 'oublog') . '</h2>'; print '<p>' . get_string('moderated_awaitingnote', 'oublog') . '</p>'; print '<div class="oublog-awaiting">';
} if (!($oubloginstance = $DB->get_record('oublog_instances', array('id' => $post->oubloginstancesid)))) { print_error('invalidblog', 'oublog'); } $url = new moodle_url('/mod/oublog/editcomment.php', array('blog' => $blog, 'post' => $postid, 'comment' => $commentid)); $PAGE->set_url($url); // Check security. $context = context_module::instance($cm->id); oublog_check_view_permissions($oublog, $context, $cm); $post->userid = $oubloginstance->userid; // oublog_can_view_post needs this if (!oublog_can_view_post($post, $USER, $context, $oublog->global)) { print_error('accessdenied', 'oublog'); } oublog_get_activity_groupmode($cm, $course); if (!oublog_can_comment($cm, $oublog, $post)) { print_error('accessdenied', 'oublog'); } if ($oublog->allowcomments == OUBLOG_COMMENTS_PREVENT || $post->allowcomments == OUBLOG_COMMENTS_PREVENT) { print_error('commentsnotallowed', 'oublog'); } $viewurl = 'viewpost.php?post=' . $post->id; if ($oublog->global) { $blogtype = 'personal'; if (!($oubloguser = $DB->get_record('user', array('id' => $oubloginstance->userid)))) { print_error('invaliduserid'); } } else { $blogtype = 'course'; } $renderer = $PAGE->get_renderer('mod_oublog');
} if (!($course = get_record("course", "id", $cm->course))) { print_error('error_unspecified', 'oublog', $backlink, 'A4'); } // Check state if ($mcomment->approval) { print_error('error_alreadyapproved', 'oublog', $backlink); } if ($email && $key !== $mcomment->secretkey) { print_error('error_wrongkey', 'oublog', $backlink); } // Require login, it to be your own post, and commenting permission require_login($course, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); oublog_check_view_permissions($oublog, $context, $cm); if ($USER->id !== $post->userid || !oublog_can_view_post($post, $USER, $context, $oublog->global) || !oublog_can_comment($cm, $oublog, $post)) { print_error('accessdenied', 'oublog', $backlink); } // The post must (still) allow public comments if ($post->allowcomments < OUBLOG_COMMENTS_ALLOWPUBLIC || $oublog->allowcomments < OUBLOG_COMMENTS_ALLOWPUBLIC) { print_error('error_moderatednotallowed', 'oublog', $backlink); } // OK they are actually allowed to approve / reject this if (!oublog_approve_comment($mcomment, $approve)) { print_error('error_unspecified', 'oublog', 'A5', $backlink); } // Redirect back to view post $target = 'viewpost.php?post=' . $post->id; if (!$email && $redirectlower) { $target .= '#awaiting'; }
/** * Print a single blog post * * @param object $oublog Blog object * @param object $post Structure containing all post info and comments * @param string $baseurl Base URL of current page * @param string $blogtype Blog level ie course or above * @param bool $canmanageposts Has capability toggle * @param bool $canaudit Has capability toggle * @param bool $cancomment Has capability toggle * @param bool $forexport Export output rendering toggle * @param bool $email Email output rendering toggle * @return bool */ public function render_post($cm, $oublog, $post, $baseurl, $blogtype, $canmanageposts = false, $canaudit = false, $commentcount = true, $forexport = false, $format = false, $email = false) { global $CFG, $USER; $output = ''; $modcontext = context_module::instance($cm->id); // Get rid of any existing tag from the URL as we only support one at a time. $baseurl = preg_replace('~&tag=[^&]*~', '', $baseurl); $strcomment = get_string('comment', 'oublog'); $strtags = get_string('tags', 'oublog'); $stredit = get_string('edit', 'oublog'); $strdelete = get_string('delete', 'oublog'); $strpermalink = get_string('permalink', 'oublog'); $row = ''; if (isset($post->row)) { $row = $post->row % 2 ? 'oublog-odd' : 'oublog-even'; } $extraclasses = $post->deletedby ? ' oublog-deleted' : ''; $extraclasses .= ' oublog-hasuserpic'; $extraclasses .= ' ' . $row; $output .= html_writer::start_tag('div', array('class' => 'oublog-post' . $extraclasses)); $output .= html_writer::start_tag('div', array('class' => 'oublog-post-top')); $fs = get_file_storage(); if ($files = $fs->get_area_files($modcontext->id, 'mod_oublog', 'attachment', $post->id, "timemodified", false)) { $output .= html_writer::start_tag('div', array('class' => 'oublog-post-attachments')); $output .= get_string('attachments', 'mod_oublog') . ': '; foreach ($files as $file) { if (!$forexport && !$email) { $filename = $file->get_filename(); $mimetype = $file->get_mimetype(); $iconimage = html_writer::empty_tag('img', array('src' => $this->output->pix_url(file_mimetype_icon($mimetype)), 'alt' => $mimetype, 'class' => 'icon')); if ($post->visibility == OUBLOG_VISIBILITY_PUBLIC) { $fileurlbase = '/mod/oublog/pluginfile.php'; } else { $fileurlbase = '/pluginfile.php'; } $filepath = '/' . $modcontext->id . '/mod_oublog/attachment/' . $post->id . '/' . $filename; $path = moodle_url::make_file_url($fileurlbase, $filepath, true); $output .= html_writer::start_tag('div', array('class' => 'oublog-post-attachment')); $output .= html_writer::tag('a', $iconimage, array('href' => $path)); $output .= html_writer::tag('a', s($filename), array('href' => $path)); $output .= html_writer::end_tag('div'); } else { $filename = $file->get_filename(); if (is_object($format)) { $output .= $format->file_output($file) . ' '; } else { $output .= $filename . ' '; } } } $output .= html_writer::end_tag('div'); } $output .= html_writer::start_tag('div', array('class' => 'oublog-post-top-content')); if (!$forexport) { $output .= html_writer::start_tag('div', array('class' => 'oublog-userpic')); $postuser = new object(); $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->email = $post->email; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; $postuser->firstnamephonetic = $post->firstnamephonetic; $postuser->lastnamephonetic = $post->lastnamephonetic; $postuser->middlename = $post->middlename; $postuser->alternatename = $post->alternatename; $output .= $this->output->user_picture($postuser, array('courseid' => $oublog->course, 'size' => 70)); $output .= html_writer::end_tag('div'); } $output .= html_writer::start_tag('div', array('class' => 'oublog-post-top-details')); $formattedtitle = format_string($post->title); if (trim($formattedtitle) !== '') { $output .= html_writer::tag('h2', format_string($post->title), array('class' => 'oublog-title')); } else { if (!$forexport) { $posttitle = get_accesshide(get_string('newpost', 'mod_oublog', oublog_get_displayname($oublog))); $output .= html_writer::tag('h2', $posttitle, array('class' => 'oublog-title')); } } if ($post->deletedby) { $deluser = new stdClass(); // Get user name fields. $delusernamefields = get_all_user_name_fields(false, null, 'del'); foreach ($delusernamefields as $namefield => $retnamefield) { $deluser->{$namefield} = $post->{$retnamefield}; } $a = new stdClass(); $a->fullname = html_writer::tag('a', fullname($deluser), array('href' => $CFG->wwwroot . '/user/view.php?id=' . $post->deletedby)); $a->timedeleted = oublog_date($post->timedeleted); $output .= html_writer::tag('div', get_string('deletedby', 'oublog', $a), array('class' => 'oublog-post-deletedby')); } $output .= html_writer::start_tag('div', array('class' => 'oublog-post-date')); $output .= oublog_date($post->timeposted); $output .= html_writer::empty_tag('br', array()); $output .= ' '; if ($blogtype == 'course' || strpos($_SERVER['REQUEST_URI'], 'allposts.php') != 0) { $output .= html_writer::start_tag('div', array('class' => 'oublog-postedby')); if (!$forexport) { $output .= get_string('postedby', 'oublog', '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $post->userid . '&course=' . $oublog->course . '">' . fullname($post) . '</a>'); } else { $output .= get_string('postedby', 'oublog', fullname($post)); } $output .= html_writer::end_tag('div'); } $output .= html_writer::end_tag('div'); if (!$oublog->individual) { $output .= html_writer::start_tag('div', array('class' => 'oublog-post-visibility')); $output .= oublog_get_visibility_string($post->visibility, $blogtype == 'personal'); $output .= html_writer::end_tag('div'); } if (isset($post->edits) && ($canaudit || $post->userid == $USER->id)) { $output .= html_writer::start_tag('div', array('class' => 'oublog-post-editsummary')); foreach ($post->edits as $edit) { $a = new stdClass(); $a->editby = fullname($edit); $a->editdate = oublog_date($edit->timeupdated); if (!$forexport && !$email) { if ($edit->userid == $post->userid) { $output .= '- ' . html_writer::tag('a', get_string('editsummary', 'oublog', $a), array('href' => $CFG->wwwroot . '/mod/oublog/viewedit.php?edit=' . $edit->id)); } else { $output .= '- ' . html_writer::tag('a', get_string('editonsummary', 'oublog', $a), array('href' => $CFG->wwwroot . '/mod/oublog/viewedit.php?edit=' . $edit->id)); } } else { if ($edit->userid == $post->userid) { $output .= '- ' . get_string('editsummary', 'oublog', $a); } else { $output .= '- ' . get_string('editonsummary', 'oublog', $a); } } $output .= html_writer::empty_tag('br', array()); } $output .= html_writer::end_tag('div'); } else { if ($post->lasteditedby) { $edit = new StdClass(); // Get user name fields. $editusernamefields = get_all_user_name_fields(false, null, 'ed'); foreach ($editusernamefields as $namefield => $retnamefield) { $edit->{$namefield} = $post->{$retnamefield}; } $a = new stdClass(); $a->editby = fullname($edit); $a->editdate = oublog_date($post->timeupdated); $output .= html_writer::tag('div', get_string('editsummary', 'oublog', $a), array('class' => 'oublog-post-editsummary')); } } $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); $output .= html_writer::start_tag('div', array('class' => 'oublog-post-content')); if (!$forexport) { if ($post->visibility == OUBLOG_VISIBILITY_PUBLIC || $email) { $fileurlbase = 'mod/oublog/pluginfile.php'; } else { $fileurlbase = 'pluginfile.php'; } $post->message = file_rewrite_pluginfile_urls($post->message, $fileurlbase, $modcontext->id, 'mod_oublog', 'message', $post->id); } else { require_once $CFG->libdir . '/portfoliolib.php'; $post->message = portfolio_rewrite_pluginfile_urls($post->message, $modcontext->id, 'mod_oublog', 'message', $post->id, $format); } $posttextoptions = new stdClass(); if (trusttext_active() && has_capability('moodle/site:trustcontent', $modcontext, $post->userid)) { // Support trusted text when initial author is safe (post editors are not checked!). $posttextoptions->trusted = true; $posttextoptions->context = $modcontext; } $output .= format_text($post->message, FORMAT_HTML, $posttextoptions); $output .= html_writer::end_tag('div'); $output .= html_writer::start_tag('div', array('class' => 'oublog-post-bottom')); if (isset($post->tags)) { $output .= html_writer::start_tag('div', array('class' => 'oublog-post-tags')) . $strtags . ': '; $tagcounter = 1; foreach ($post->tags as $taglink) { $taglinktext = $taglink; if ($tagcounter < count($post->tags)) { $taglinktext .= ','; } if (!$forexport && !$email) { $output .= html_writer::tag('a', $taglinktext, array('href' => $baseurl . '&tag=' . urlencode($taglink))) . ' '; } else { $output .= $taglinktext . ' '; } $tagcounter++; } $output .= html_writer::end_tag('div'); } $output .= html_writer::start_tag('div', array('class' => 'oublog-post-links')); if (!$forexport && !$email) { $output .= html_writer::tag('a', $strpermalink, array('href' => $CFG->wwwroot . '/mod/oublog/viewpost.php?post=' . $post->id)) . ' '; } if (!$post->deletedby) { if ($post->userid == $USER->id || $canmanageposts) { if (!$forexport && !$email) { $output .= html_writer::tag('a', $stredit, array('href' => $CFG->wwwroot . '/mod/oublog/editpost.php?blog=' . $post->oublogid . '&post=' . $post->id)) . ' '; if ($post->userid !== $USER->id) { // Add email and 'oublog_deleteandemail' to delete link. $output .= html_writer::tag('a', $strdelete, array('href' => $CFG->wwwroot . '/mod/oublog/deletepost.php?blog=' . $post->oublogid . '&post=' . $post->id . '&delete=1', 'class' => 'oublog_deleteandemail_' . $post->id)); self::render_oublog_print_delete_dialog($cm->id, $post->id); } else { $output .= html_writer::tag('a', $strdelete, array('href' => $CFG->wwwroot . '/mod/oublog/deletepost.php?blog=' . $post->oublogid . '&post=' . $post->id . '&delete=1')); } } } // Show portfolio export link. if (!empty($CFG->enableportfolios) && (has_capability('mod/oublog:exportpost', $modcontext) || $post->userid == $USER->id && has_capability('mod/oublog:exportownpost', $modcontext))) { if (!$forexport && !$email) { require_once $CFG->libdir . '/portfoliolib.php'; $button = new portfolio_add_button(); $button->set_callback_options('oublog_portfolio_caller', array('postid' => $post->id), 'mod_oublog'); if (empty($files)) { $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML); } else { $button->set_formats(PORTFOLIO_FORMAT_RICHHTML); } $output .= $button->to_html(PORTFOLIO_ADD_TEXT_LINK) . ' '; } } // Show OU Alerts reporting link. if (isloggedin() && oublog_oualerts_enabled() && oublog_get_reportingemail($oublog) && !($post->userid == $USER->id) && !$post->deletedby) { $itemnurl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id)); $reportlink = oualerts_generate_alert_form_url('oublog', $modcontext->id, 'post', $post->id, $itemnurl, $itemnurl, '', false, true); if ($reportlink != '' && !$forexport && !$email) { $output .= html_writer::tag('a', get_string('postalert', 'oublog'), array('href' => $reportlink)); } } // Show comments. if ($post->allowcomments) { // If this is the current user's post, show pending comments too. $showpendingcomments = $post->userid == $USER->id && !empty($post->pendingcomments); if ((isset($post->comments) || $showpendingcomments) && $commentcount) { // Show number of comments. if (isset($post->comments)) { $linktext = get_string(count($post->comments) == 1 ? 'onecomment' : 'ncomments', 'oublog', count($post->comments)); } // Show number of pending comments. if (isset($post->pendingcomments)) { // Use different string if we already have normal comments too. if (isset($post->comments)) { $linktext .= get_string($post->pendingcomments == 1 ? 'onependingafter' : 'npendingafter', 'oublog', $post->pendingcomments); } else { $linktext = get_string($post->pendingcomments == 1 ? 'onepending' : 'npending', 'oublog', $post->pendingcomments); } } if (!$forexport) { // Display link. $output .= html_writer::tag('a', $linktext, array('href' => $CFG->wwwroot . '/mod/oublog/viewpost.php?post=' . $post->id . '#oublogcomments')); } else { $output .= $linktext; } // Display information about most recent comment. if (isset($post->comments)) { $last = array_pop($post->comments); array_push($post->comments, $last); $a = new stdClass(); if ($last->userid) { $a->fullname = fullname($last); } else { $a->fullname = s($last->authorname); } $a->timeposted = oublog_date($last->timeposted, true); $output .= ' ' . get_string('lastcomment', 'oublog', $a); } } else { if (oublog_can_comment($cm, $oublog, $post)) { if (!$forexport && !$email) { $output .= html_writer::tag('a', $strcomment, array('href' => $CFG->wwwroot . '/mod/oublog/editcomment.php?blog=' . $post->oublogid . '&post=' . $post->id)); } } } } } $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); return $output; }
public function test_oublog_time_limits() { $this->resetAfterTest(); $course = $this->get_new_course(); $stud1 = $this->get_new_user('student', $course->id); // Future posts + comments start blog. $oublog = $this->get_new_oublog($course->id, array('postfrom' => 2524611600, 'commentfrom' => 2524611600)); // Past posts + comments start blog. $oublog1 = $this->get_new_oublog($course->id, array('postfrom' => 1262307600, 'commentfrom' => 1262307600)); // Future posts + comments end blog. $oublog2 = $this->get_new_oublog($course->id, array('postuntil' => 2524611600, 'commentuntil' => 2524611600)); // Past posts + comments end blog. $oublog3 = $this->get_new_oublog($course->id, array('postuntil' => 1262307600, 'commentuntil' => 1262307600)); $this->setAdminUser(); $this->assertTrue(oublog_can_post_now($oublog, context_module::instance($oublog->cm->id))); $this->assertTrue(oublog_can_post_now($oublog1, context_module::instance($oublog1->cm->id))); $this->assertTrue(oublog_can_post_now($oublog2, context_module::instance($oublog2->cm->id))); $this->assertTrue(oublog_can_post_now($oublog3, context_module::instance($oublog3->cm->id))); $post = (object) array('allowcomments' => true, 'visibility' => OUBLOG_VISIBILITY_COURSEUSER); $this->assertTrue(oublog_can_comment($oublog->cm, $oublog, $post)); $this->assertTrue(oublog_can_comment($oublog1->cm, $oublog1, $post)); $this->assertTrue(oublog_can_comment($oublog2->cm, $oublog2, $post)); $this->assertTrue(oublog_can_comment($oublog3->cm, $oublog3, $post)); $this->setUser($stud1); $this->assertFalse(oublog_can_post_now($oublog, context_module::instance($oublog->cm->id))); $this->assertTrue(oublog_can_post_now($oublog1, context_module::instance($oublog1->cm->id))); $this->assertTrue(oublog_can_post_now($oublog2, context_module::instance($oublog2->cm->id))); $this->assertFalse(oublog_can_post_now($oublog3, context_module::instance($oublog3->cm->id))); $post = (object) array('allowcomments' => true, 'visibility' => OUBLOG_VISIBILITY_COURSEUSER); $this->assertFalse(oublog_can_comment($oublog->cm, $oublog, $post)); $this->assertTrue(oublog_can_comment($oublog1->cm, $oublog1, $post)); $this->assertTrue(oublog_can_comment($oublog2->cm, $oublog2, $post)); $this->assertFalse(oublog_can_comment($oublog3->cm, $oublog3, $post)); }
/** * Print a single blog post * * @param object $oublog Blog object * @param object $post * @param string $baseurl * @param string $blogtype * @param bool $canmanageposts * @param bool $canaudit * @param bool $cancomment * @return bool */ function oublog_print_post($cm, $oublog, $post, $baseurl, $blogtype, $canmanageposts = false, $canaudit = false, $commentcount = true) { global $CFG, $USER; // Get rid of any existing tag from the URL as we only support one at a time $baseurl = preg_replace('~&tag=[^&]*~', '', $baseurl); $strcomment = get_string('comment', 'oublog'); $strtags = get_string('tags', 'oublog'); $stredit = get_string('edit', 'oublog'); $strdelete = get_string('delete', 'oublog'); $extraclasses = $post->deletedby ? ' oublog-deleted' : ''; if ($CFG->oublog_showuserpics) { $extraclasses .= ' oublog-hasuserpic'; } echo '<div class="oublog-post' . $extraclasses . '">'; if ($CFG->oublog_showuserpics) { print '<div class="oublog-userpic">'; $postuser = new object(); $postuser->id = $post->userid; $postuser->firstname = $post->firstname; $postuser->lastname = $post->lastname; $postuser->imagealt = $post->imagealt; $postuser->picture = $post->picture; print_user_picture($postuser, $oublog->course); print '</div>'; } $formattedtitle = format_string($post->title); if (trim($formattedtitle) !== '') { echo '<h2 class="oublog-title"><a href="viewpost.php?post=' . $post->id . '">' . format_string($post->title) . '</a></h2>'; } if ($post->deletedby) { $deluser = new stdClass(); $deluser->firstname = $post->delfirstname; $deluser->lastname = $post->dellastname; $a = new stdClass(); $a->fullname = '<a href="../../user/view.php?id=' . $post->deletedby . '">' . fullname($deluser) . '</a>'; $a->timedeleted = oublog_date($post->timedeleted); echo '<div class="oublog-post-deletedby">' . get_string('deletedby', 'oublog', $a) . '</div>'; } echo '<div class="oublog-post-date">'; echo oublog_date($post->timeposted); echo ' '; if ($blogtype == 'course' || strpos($_SERVER['REQUEST_URI'], 'allposts.php') != 0) { echo '<div class="oublog-postedby">'; echo get_string('postedby', 'oublog', '<a href="../../user/view.php?id=' . $post->userid . '&course=' . $oublog->course . '">' . fullname($post) . '</a>'); echo '</div> '; } echo '</div>'; if (isset($post->edits) && ($canaudit || $post->userid == $USER->id)) { echo '<div class="oublog-post-editsummary">'; foreach ($post->edits as $edit) { $a = new stdClass(); $a->editby = fullname($edit); $a->editdate = oublog_date($edit->timeupdated); if ($edit->userid == $post->userid) { echo '- <a href="viewedit.php?edit=' . $edit->id . '">' . get_string('editsummary', 'oublog', $a) . '</a><br />'; } else { echo '- <a href="viewedit.php?edit=' . $edit->id . '">' . get_string('editonsummary', 'oublog', $a) . '</a><br />'; } } echo '</div>'; } else { if ($post->lasteditedby) { $edit = new StdClass(); $edit->firstname = $post->edfirstname; $edit->lastname = $post->edlastname; $a = new stdClass(); $a->editby = fullname($edit); $a->editdate = oublog_date($post->timeupdated); echo '<div class="oublog-post-editsummary">' . get_string('editsummary', 'oublog', $a) . '</div>'; } } if (!$oublog->individual) { echo '<div class="oublog-post-visibility">'; echo oublog_get_visibility_string($post->visibility, $blogtype == 'personal'); echo '</div>'; } echo '<div class="oublog-post-content">'; //echo format_text($post->message, FORMAT_HTML); // Remove security checks and filtering of HTML tags (nadavkav 11-2-2012) echo $post->message; echo '</div>'; if (isset($post->tags)) { echo '<div class="oublog-post-tags">' . $strtags . ': '; foreach ($post->tags as $taglink) { echo '<a href="' . $baseurl . '&tag=' . urlencode($taglink) . '">' . $taglink . '</a> '; } echo '</div>'; } echo '<div class="oublog-post-links">'; if (!$post->deletedby) { if ($post->userid == $USER->id || $canmanageposts) { echo ' <a href="' . $CFG->wwwroot . '/mod/oublog/editpost.php?blog=' . $post->oublogid . '&post=' . $post->id . '">' . $stredit . '</a>'; echo ' <a href="' . $CFG->wwwroot . '/mod/oublog/deletepost.php?blog=' . $post->oublogid . '&post=' . $post->id . '">' . $strdelete . '</a>'; } if ($post->allowcomments) { // If this is the current user's post, show pending comments too $showpendingcomments = $post->userid == $USER->id && !empty($post->pendingcomments); if ((isset($post->comments) || $showpendingcomments) && $commentcount) { # // Show number of comments if (isset($post->comments)) { $linktext = get_string(count($post->comments) == 1 ? '1comment' : 'ncomments', 'oublog', count($post->comments)); } // Show number of pending comments if (isset($post->pendingcomments)) { // Use different string if we already have normal comments too if (isset($post->comments)) { $linktext .= get_string($post->pendingcomments == 1 ? '1pendingafter' : 'npendingafter', 'oublog', $post->pendingcomments); } else { $linktext = get_string($post->pendingcomments == 1 ? '1pending' : 'npending', 'oublog', $post->pendingcomments); } } // Show "Add new Comments" Button (nadavkav 10.4.2011) if (isset($post->comments)) { echo " <a href=\"{$CFG->wwwroot}/mod/oublog/viewpost.php?post={$post->id}\">" . $strcomment . "</a> "; } // Display link echo " <a href=\"{$CFG->wwwroot}/mod/oublog/viewpost.php?post={$post->id}\">" . $linktext . "</a> "; // Display information about most recent comment if (isset($post->comments)) { $last = array_pop($post->comments); array_push($post->comments, $last); $a = new stdClass(); if ($last->userid) { $a->fullname = fullname($last); } else { $a->fullname = s($last->authorname); } $a->timeposted = oublog_date($last->timeposted, true); echo get_string('lastcomment', 'oublog', $a); } } elseif (oublog_can_comment($cm, $oublog, $post)) { echo " <a href=\"{$CFG->wwwroot}/mod/oublog/editcomment.php?blog={$post->oublogid}&post={$post->id}\">{$strcomment}</a>"; } } // Share post with the outside world, if post is public (nadavkav) if ($post->userid == $USER->id || $canmanageposts) { echo '<br/><br/><a target="_new" href="http://www.addtoany.com/share_save?linkurl=' . $CFG->wwwroot . '/mod/oublog/viewpost.php?post=' . $post->id . '&linkname=' . format_string($post->title) . '"><img src="http://static.addtoany.com/buttons/share_save_171_16.png"></a>'; } } echo '</div>'; echo '</div>'; return true; }
echo $oublogoutput->render_time_limit_msg('afterendpost', $oublog->postuntil, $capable); } } // If timed comments show info. if ($posts) { $maxpost = (object) array('allowcomments' => false, 'visibility' => OUBLOG_VISIBILITY_COURSEUSER); foreach ($posts as $apost) { // Work out if any posts on page allow commenting + max visibility. if ($apost->allowcomments) { $maxpost->allowcomments = true; } if ($apost->visibility > $maxpost->visibility) { $maxpost->visibility = $apost->visibility; } } if (oublog_can_comment($cm, $oublog, $maxpost, true)) { $ccapable = has_capability('mod/oublog:ignorecommentperiod', $oublog->global ? context_system::instance() : $context); if ($oublog->commentfrom != 0 && $oublog->commentfrom > time()) { echo $oublogoutput->render_time_limit_msg('beforestartcomment', $oublog->commentfrom, $capable, 'comment'); } if ($oublog->commentuntil != 0) { if ($oublog->commentuntil > time()) { echo $oublogoutput->render_time_limit_msg('beforeendcomment', $oublog->commentuntil, $capable, 'comment'); } else { echo $oublogoutput->render_time_limit_msg('afterendcomment', $oublog->commentuntil, $capable, 'comment'); } } } } echo '<div id="oublogbuttons">'; if ($showpostbutton && oublog_can_post_now($oublog, $context)) {