Example #1
0
 /**
  * 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 . '&amp;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;
 }
Example #2
0
 public function definition()
 {
     global $CFG;
     $individualblog = $this->_customdata['individual'];
     $maxvisibility = $this->_customdata['maxvisibility'];
     $allowcomments = $this->_customdata['allowcomments'];
     $edit = $this->_customdata['edit'];
     $personal = $this->_customdata['personal'];
     $maxbytes = $this->_customdata['maxbytes'];
     $maxattachments = $this->_customdata['maxattachments'];
     $mform =& $this->_form;
     $mform->addElement('header', 'general', '');
     $mform->addElement('text', 'title', get_string('title', 'oublog'), 'size="48"');
     $mform->setType('title', PARAM_TEXT);
     $mform->addElement('editor', 'message', get_string('message', 'oublog'), array('cols' => 50, 'rows' => 30), array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $maxbytes));
     $mform->addRule('message', get_string('required'), 'required', null, 'client');
     $mform->addElement('textarea', 'tags', get_string('tagsfield', 'oublog'), array('cols' => 48, 'rows' => 2));
     $mform->setType('tags', PARAM_TAGLIST);
     $mform->addHelpButton('tags', 'tags', 'oublog');
     $options = array();
     if ($allowcomments) {
         $options[OUBLOG_COMMENTS_ALLOW] = get_string('logincomments', 'oublog');
         if ($allowcomments >= OUBLOG_COMMENTS_ALLOWPUBLIC && OUBLOG_VISIBILITY_PUBLIC <= $maxvisibility) {
             $maybepubliccomments = true;
             $options[OUBLOG_COMMENTS_ALLOWPUBLIC] = get_string('publiccomments', 'oublog');
         }
         $options[OUBLOG_COMMENTS_PREVENT] = get_string('no', 'oublog');
         $mform->addElement('select', 'allowcomments', get_string('allowcomments', 'oublog'), $options);
         $mform->setType('allowcomments', PARAM_INT);
         $mform->addHelpButton('allowcomments', 'allowcomments', 'oublog');
         if (isset($maybepubliccomments)) {
             // NOTE - module.js adds a listener to allowcomments that hides/shows this element as mforms doesn't support this.
             $mform->addElement('static', 'publicwarning', '', '<div id="publicwarningmarker"></div>' . get_string('publiccomments_info', 'oublog'));
         }
     } else {
         $mform->addElement('hidden', 'allowcomments', OUBLOG_COMMENTS_PREVENT);
         $mform->setType('allowcomments', PARAM_INT);
     }
     $options = array();
     if (OUBLOG_VISIBILITY_COURSEUSER <= $maxvisibility) {
         $options[OUBLOG_VISIBILITY_COURSEUSER] = oublog_get_visibility_string(OUBLOG_VISIBILITY_COURSEUSER, $personal);
     }
     if (OUBLOG_VISIBILITY_LOGGEDINUSER <= $maxvisibility) {
         $options[OUBLOG_VISIBILITY_LOGGEDINUSER] = oublog_get_visibility_string(OUBLOG_VISIBILITY_LOGGEDINUSER, $personal);
     }
     if (OUBLOG_VISIBILITY_PUBLIC <= $maxvisibility) {
         $options[OUBLOG_VISIBILITY_PUBLIC] = oublog_get_visibility_string(OUBLOG_VISIBILITY_PUBLIC, $personal);
     }
     if ($individualblog > OUBLOG_NO_INDIVIDUAL_BLOGS) {
         $mform->addElement('hidden', 'visibility', OUBLOG_VISIBILITY_COURSEUSER);
         $mform->setType('visibility', PARAM_INT);
     } else {
         if (OUBLOG_VISIBILITY_COURSEUSER != $maxvisibility) {
             $mform->addElement('select', 'visibility', get_string('visibility', 'oublog'), $options);
             $mform->setType('visibility', PARAM_INT);
             $mform->addHelpButton('visibility', 'visibility', 'oublog');
         } else {
             $mform->addElement('hidden', 'visibility', OUBLOG_VISIBILITY_COURSEUSER);
             $mform->setType('visibility', PARAM_INT);
         }
     }
     if ($maxattachments > 0) {
         $mform->addElement('filemanager', 'attachments', get_string('attachments', 'oublog'), null, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => $maxattachments));
         $mform->addHelpButton('attachments', 'attachments', 'oublog');
     }
     if ($edit) {
         $submitstring = get_string('savechanges');
     } else {
         $submitstring = get_string('addpost', 'oublog');
     }
     $this->add_action_buttons(true, $submitstring);
     // Hidden form vars.
     $mform->addElement('hidden', 'blog');
     $mform->setType('blog', PARAM_INT);
     $mform->addElement('hidden', 'post');
     $mform->setType('post', PARAM_INT);
 }
/**
 * 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('~&amp;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 . '&amp;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 . '&amp;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 . '&amp;post=' . $post->id . '">' . $stredit . '</a>';
            echo ' <a href="' . $CFG->wwwroot . '/mod/oublog/deletepost.php?blog=' . $post->oublogid . '&amp;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}&amp;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;
}