コード例 #1
0
ファイル: import.php プロジェクト: nadavkav/moodle-mod_oublog
 foreach ($posts as &$post) {
     $tagcol = '';
     if (isset($post->tags)) {
         // Create tag column for post.
         foreach ($post->tags as $tagid => $tag) {
             $newtagval = empty($tags) ? $tagid : $tags . ",{$tagid}";
             $turl = new moodle_url('/mod/oublog/import.php', array_merge($params, $stepinfo, array('tags' => $newtagval)));
             $tagcol .= html_writer::link($turl, format_text($tag, FORMAT_HTML), array('class' => 'oublog_import_tag'));
         }
     }
     if (empty($post->title)) {
         $post->title = get_string('untitledpost', 'oublog') . ' ' . $untitledcount;
         $untitledcount++;
     }
     $importcol = html_writer::checkbox('post_' . $post->id, $post->id, in_array($post->id, $preselected), get_string('import_step1_include_label', 'oublog', format_string($post->title)));
     $table->add_data(array(format_string($post->title), oublog_date($post->timeposted), $tagcol, $importcol));
 }
 $module = array('name' => 'mod_oublog');
 $module['fullpath'] = '/mod/oublog/module.js';
 $module['requires'] = array('node', 'node-event-delegate', 'querystring');
 $PAGE->requires->strings_for_js(array('import_step1_all', 'import_step1_none'), 'oublog');
 $PAGE->requires->js_init_call('M.mod_oublog.init_posttable', null, false, $module);
 $table->finish_output();
 echo html_writer::start_div();
 foreach (array_merge($params, $stepinfo, array('step' => 2, 'sesskey' => sesskey())) as $param => $value) {
     echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $param, 'value' => $value));
 }
 echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'submit', 'value' => get_string('import_step1_submit', 'oublog')));
 echo html_writer::empty_tag('input', array('type' => 'submit', 'name' => 'cancel', 'value' => get_string('cancel')));
 echo html_writer::end_div();
 echo html_writer::end_tag('form');
コード例 #2
0
 }
 $extraclasses = '';
 $extramessage = '';
 if ($comment->approval == OUBLOG_MODERATED_REJECTED) {
     $extraclasses = 'oublog-rejected';
     $extramessage = '<div class="oublog-rejected-info">' . get_string('moderated_rejectedon', 'oublog', oublog_date($comment->timeset)) . ' </div>';
 }
 $extraclasses .= ' oublog-hasuserpic';
 // Start of comment.
 print '<div class="oublog-comment ' . $extraclasses . '">' . $extramessage;
 // Title.
 if (trim(format_string($comment->title)) !== '') {
     print '<h2 class="oublog-comment-title">' . format_string($comment->title) . '</h2>';
 }
 // Date and author.
 print '<div class="oublog-comment-date">' . oublog_date($comment->timeposted) . ' </div>';
 print '<div class="oublog-postedby">' . get_string('moderated_postername', 'oublog', s($comment->authorname)) . ($canaudit ? ' (' . s($comment->authorip) . ')' : '') . '</div>';
 print '<div class="oublog-comment-content">' . format_text($comment->message, FORMAT_MOODLE) . '</div>';
 // You can only approve/reject it once; and we don't let admins
 // approve/reject (because there's no way of tracking who did it
 // and it displays the post owner as having approved it)...
 if ($comment->approval == OUBLOG_MODERATED_UNSET && $post->userid == $USER->id) {
     print '<form action="approve.php" method="post"><div>' . '<input type="hidden" name="sesskey" value="' . sesskey() . '" />' . '<input type="hidden" name="mcomment" value="' . $comment->id . '" />';
     if (count($moderated) == 1) {
         // Track if this is the last comment so we can jump to the
         // top of the page instead of the moderating bit.
         print '<input type="hidden" name="last" value="1" />';
     }
     print '<input type="submit" name="bapprove" value="' . get_string('moderated_approve', 'oublog') . '" /> ';
     print '<input type="submit" name="breject" value="' . get_string('moderated_reject', 'oublog') . '" />';
     print '</div></form>';
コード例 #3
0
/**
 * Generates oublog multiple users participation statistics output.
 * @param object $oublog
 * @param object $cm
 * @param mod_oublog_renderer $renderer
 * @param bool $ return data object rather than html
 */
function oublog_stats_output_participation($oublog, $cm, $renderer = null, $course, $allposts = false, $curindividual = -1, $globalindividual = null)
{
    global $PAGE, $DB, $USER, $OUTPUT;
    if (!$renderer) {
        $renderer = $PAGE->get_renderer('mod_oublog');
    }
    // Setup Participation capability checks.
    $curgroup = oublog_get_activity_group($cm);
    // Get blogtype, groupmode and individualmode
    $blogtype = $oublog->global;
    $groupmode = oublog_get_activity_groupmode($cm, $course);
    $individualmode = $oublog->individual;
    // Dont show on personal blogs if not logged in.
    if ($blogtype && !isloggedin()) {
        return;
    }
    // Dont show if current individual is not 0 and either separate individual blog or
    // visible individual with no comments.
    if (isset($curindividual) && $curindividual != 0 && $oublog->allowcomments == OUBLOG_COMMENTS_PREVENT && $individualmode != OUBLOG_NO_INDIVIDUAL_BLOGS) {
        return;
    }
    $context = context_module::instance($cm->id);
    $curindividual = $curindividual ? $curindividual : $globalindividual;
    if ($curindividual == -1) {
        $curindividual = $globalindividual;
    }
    // Get the participation object with counts of posts and comments.
    $limitnum = 8;
    $start = $end = $page = $limitfrom = $tab = 0;
    $getposts = $getcomments = true;
    if ($oublog->global) {
        // Dont want to see posts on personal blogs.
        $getposts = false;
    }
    if ($oublog->allowcomments < OUBLOG_COMMENTS_ALLOW) {
        // Dont want to see comments visible individual blogs.
        $getcomments = false;
    }
    $participation = oublog_get_participation_details($oublog, $curgroup, $curindividual, $start, $end, $page, $getposts, $getcomments, $limitfrom, $limitnum);
    // Generate content data to send to renderer.
    $maintitle = get_string('participation', 'oublog');
    // The title of the block 'section'.
    $content = '';
    $postedcount = $commentedcount = $commenttotal = 0;
    $postshow = 8;
    if (count($participation->comments) <= 4) {
        $commenttotal = count($participation->comments);
    } else {
        if (count($participation->comments) >= 4) {
            $commenttotal = 4;
        }
    }
    if (!$participation->posts) {
        if (!$blogtype && $individualmode != OUBLOG_VISIBLE_INDIVIDUAL_BLOGS) {
            $content .= html_writer::tag('p', get_string('nouserposts', 'oublog'));
        }
        // For visible individual blogs show post activity also when no individual selected.
    } else {
        $percent = $stat = null;
        $content .= html_writer::tag('p', get_string('recentposts', 'oublog'));
        foreach ($participation->posts as $post) {
            // Post user object required for oublog_statsinfo.
            $postuser = new object();
            $postuser->id = $post->userid;
            $postuser->groupid = $post->groupid;
            $fields = explode(',', user_picture::fields('', null, '', null));
            foreach ($fields as $field) {
                if ($field != 'id') {
                    $pfield = $field;
                    $postuser->{$field} = $post->{$field};
                }
            }
            $linktext = $name = $grpname = $dispname = '';
            $bparams = array();
            $a = (object) array('name' => $name, 'displayname' => $dispname);
            if ($postedcount >= $postshow - $commenttotal) {
                break;
            }
            $url = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
            $postname = !empty($post->title) ? $post->title : get_string('untitledpost', 'oublog');
            $label = html_writer::div(html_writer::link($url, $postname), 'oublogstats_posts_posttitle');
            if (oublog_get_displayname($oublog) && $postuser->id != $curindividual) {
                $dispname = oublog_get_displayname($oublog);
            }
            if ($post->blogname != "") {
                $name = $post->blogname;
            } else {
                if ($groupmode > NOGROUPS && $individualmode == OUBLOG_NO_INDIVIDUAL_BLOGS) {
                    if ($post->groupid != $curgroup) {
                        $bparams['id'] = $cm->id;
                        $bparams['group'] = $post->groupid;
                        $grpname = groups_get_group_name($post->groupid);
                        $a = (object) array('name' => $grpname, 'displayname' => $dispname);
                        $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                    }
                } else {
                    if ($individualmode != OUBLOG_NO_INDIVIDUAL_BLOGS) {
                        $bparams['individual'] = $post->userid;
                        if ($postuser->id != $curindividual) {
                            $name = fullname($postuser);
                            $a = (object) array('name' => $name, 'displayname' => $dispname);
                            $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                        }
                    }
                }
            }
            if (!$groupmode && $grpname != "" || $name != "") {
                $bparams['id'] = $cm->id;
                $bparams['individual'] = $post->userid;
                $a = (object) array('name' => $name, 'displayname' => $dispname);
                $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
            }
            $burl = new moodle_url('/mod/oublog/view.php', $bparams);
            if ($linktext != "") {
                // We output post time followed by a link.
                $label .= html_writer::div(oublog_date($post->timeposted) . html_writer::empty_tag('br', array()) . html_writer::link($burl, $linktext), 'oublogstats_commentposts_blogname');
            } else {
                // We output just post.
                $label .= html_writer::div(oublog_date($post->timeposted), 'oublogstats_commentposts_blogname');
            }
            $statinfo = new oublog_statsinfo($postuser, $percent, $stat, $url, $label);
            $content .= $renderer->render($statinfo);
            $postedcount++;
        }
    }
    // Pre test the numbers of posts/comments for display upto max.
    $postspluscount = count($participation->posts) - $postedcount;
    if ($postspluscount >= 1 && !$blogtype && !$individualmode) {
        $content .= html_writer::tag('p', get_string('numberpostsmore', 'oublog', $postspluscount));
    }
    unset($bparams);
    if (!$participation->comments && $getcomments) {
        $content .= html_writer::tag('p', get_string('nousercomments', 'oublog'));
    } else {
        $percent = $stat = null;
        // Removing all stats div.
        if ($blogtype || $getcomments) {
            $content .= html_writer::tag('p', get_string('recentcomments', 'oublog'));
        }
        foreach ($participation->comments as $comment) {
            // Comment user object required for oublog_statsinfo.
            $commentuser = new object();
            if (empty($comment->commenterid)) {
                $commentuser->id = -1;
            } else {
                $commentuser->id = $comment->commenterid;
            }
            $fields = explode(',', user_picture::fields('', null, '', 'commenter'));
            foreach ($fields as $field) {
                if ($field != 'id') {
                    $cfield = "commenter" . $field;
                    $commentuser->{$field} = $comment->{$cfield};
                }
            }
            // Comment poster object required.
            $commentposter = new object();
            $commentposter->id = $comment->posterid;
            $fields = explode(',', user_picture::fields('', null, '', 'poster'));
            foreach ($fields as $field) {
                if ($field != 'id') {
                    $cfield = "poster" . $field;
                    $commentposter->{$field} = $comment->{$cfield};
                }
            }
            $commentuser->groupid = $comment->groupid;
            if ($commentedcount + $postedcount >= $postshow) {
                break;
            }
            $url = new moodle_url('/mod/oublog/viewpost.php', array('post' => $comment->postid));
            $lnkurl = $url->out() . '#cid' . $comment->id;
            $commentname = !empty($comment->title) ? $comment->title : get_string('untitledcomment', 'oublog');
            $label = html_writer::div(html_writer::link($lnkurl, $commentname), 'oublogstats_commentposts_posttitle');
            $linktext = $name = $grpname = $dispname = '';
            $a = (object) array('name' => $name, 'displayname' => $dispname);
            $bparams = array();
            if (oublog_get_displayname($oublog) && $comment->posterid != $curindividual) {
                $dispname = oublog_get_displayname($oublog);
            }
            if ($comment->bloginstancename && $curindividual != $comment->posterid) {
                $bparams['user'] = $comment->posterid;
                $name = $comment->bloginstancename;
            } else {
                if ($groupmode > NOGROUPS && $individualmode == OUBLOG_NO_INDIVIDUAL_BLOGS) {
                    if ($comment->groupid != $curgroup) {
                        $bparams['id'] = $cm->id;
                        $bparams['group'] = $comment->groupid;
                        $grpname = groups_get_group_name($comment->groupid);
                        $a = (object) array('name' => $grpname, 'displayname' => $dispname);
                        $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                    }
                } else {
                    if ($individualmode != OUBLOG_NO_INDIVIDUAL_BLOGS) {
                        $bparams['id'] = $cm->id;
                        $bparams['individual'] = $comment->posterid;
                        if ($comment->posterid != $curindividual) {
                            $name = fullname($commentposter);
                            $a = (object) array('name' => $name, 'displayname' => $dispname);
                            $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                        }
                    }
                }
            }
            // Personal or Course Wide.
            if (!$groupmode && $grpname != "" || $name != "") {
                $bparams['individual'] = $comment->posterid;
                $a = (object) array('name' => $name, 'displayname' => $dispname);
                $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
            }
            if (!$groupmode && $oublog->individual == 0 && $comment->posterid != $curindividual) {
                if (!$oublog->global) {
                    $bparams['id'] = $cm->id;
                }
                $bparams['individual'] = $comment->posterid;
                if ($oublog->global) {
                    $linktext = $comment->bloginstancename;
                }
            }
            $burl = new moodle_url('/mod/oublog/view.php', $bparams);
            if ($linktext != "") {
                // We output post time followed by a link.
                $label .= html_writer::div(oublog_date($comment->timeposted) . html_writer::empty_tag('br', array()) . html_writer::link($burl, $linktext), 'oublogstats_commentposts_blogname');
            } else {
                // We output just post.
                $label .= html_writer::div(oublog_date($comment->timeposted), 'oublogstats_commentposts_blogname');
            }
            $statinfo = new oublog_statsinfo($commentuser, $percent, $stat, $url, $label);
            $content .= $renderer->render($statinfo);
            $commentedcount++;
        }
    }
    // If the number of comments is more than can be shown.
    $commentspluscount = count($participation->comments) - $commentedcount;
    if ($commentspluscount >= 1) {
        $content .= html_writer::tag('p', get_string('numbercommentsmore', 'oublog', $commentspluscount));
    }
    $params = array('id' => $cm->id, 'group' => $curgroup, 'individual' => $curindividual);
    if (!$blogtype) {
        if (!$allposts) {
            $url = new moodle_url('/mod/oublog/participationlist.php', $params);
            $viewparticipation = html_writer::div(html_writer::link($url, get_string('viewallparticipation', 'oublog')));
            $content .= html_writer::start_tag('div', array('class' => 'oublog-post-content'));
            $content .= html_writer::tag('h3', $viewparticipation, array('class' => 'oublog-post-title'));
            $content .= html_writer::end_tag('div');
        }
    }
    return $renderer->render_stats_view('participation', $maintitle, $content, null, null, null);
}
コード例 #4
0
 /**
  * Print comments which relate to a single blog post
  *
  * @param object $post Structure containing all post info and comments
  * @param object $oublog Blog object
  * @param bool $canmanagecomments Has capability toggle
  * @param bool $canaudit Has capability toggle
  * @param bool $forexport Export output rendering toggle
  * @param object $cm Current course module object
  * @return html
  */
 public function render_comments($post, $oublog, $canaudit, $canmanagecomments, $forexport, $cm, $format = false)
 {
     global $DB, $CFG, $USER, $OUTPUT;
     $viewfullnames = true;
     $strdelete = get_string('delete', 'oublog');
     $strcomments = get_string('comments', 'oublog');
     $output = '';
     $modcontext = context_module::instance($cm->id);
     if (!$canmanagecomments) {
         $context = context_module::instance($cm->id);
         $canmanagecomments = has_capability('mod/oublog:managecomments', $context);
     }
     $output .= html_writer::start_tag('div', array('class' => 'oublog-post-comments', 'id' => 'oublogcomments'));
     $counter = 0;
     foreach ($post->comments as $comment) {
         $extraclasses = $comment->deletedby ? ' oublog-deleted' : '';
         $extraclasses .= ' oublog-hasuserpic';
         $output .= html_writer::start_tag('div', array('class' => 'oublog-comment' . $extraclasses, 'id' => 'cid' . $comment->id));
         if ($counter == 0) {
             $output .= html_writer::tag('h2', format_string($strcomments), array('class' => 'oublog-commentstitle'));
         }
         if ($comment->deletedby) {
             $deluser = new stdClass();
             $fields = get_all_user_name_fields(false, null, 'del');
             foreach ($fields as $field => $dfield) {
                 $deluser->{$field} = $comment->{$dfield};
             }
             $a = new stdClass();
             $a->fullname = '<a href="../../user/view.php?id=' . $comment->deletedby . '">' . fullname($deluser) . '</a>';
             $a->timedeleted = oublog_date($comment->timedeleted);
             $output .= html_writer::tag('div', get_string('deletedby', 'oublog', $a), array('class' => 'oublog-comment-deletedby'));
         }
         if ($comment->userid && !$forexport) {
             $output .= html_writer::start_tag('div', array('class' => 'oublog-userpic'));
             $commentuser = new object();
             $fields = explode(',', user_picture::fields());
             foreach ($fields as $field) {
                 if ($field != 'id') {
                     $commentuser->{$field} = $comment->{$field};
                 }
             }
             $commentuser->id = $comment->userid;
             $output .= $OUTPUT->user_picture($commentuser, array('courseid' => $oublog->course, 'size' => 70));
             $output .= html_writer::end_tag('div');
         }
         if (trim(format_string($comment->title)) !== '') {
             $output .= html_writer::tag('h2', format_string($comment->title), array('class' => 'oublog-title'));
         } else {
             if (!$forexport) {
                 $commenttitle = get_accesshide(get_string('newcomment', 'mod_oublog'));
                 $output .= html_writer::tag('h2', $commenttitle, array('class' => 'oublog-title'));
             }
         }
         $output .= html_writer::start_tag('div', array('class' => 'oublog-post-date'));
         $output .= oublog_date($comment->timeposted);
         $output .= html_writer::start_tag('div', array('class' => 'oublog-postedby'));
         if ($comment->userid) {
             if (!$forexport) {
                 $output .= get_string('postedby', 'oublog', '<a href="../../user/view.php?id=' . $comment->userid . '&amp;course=' . $oublog->course . '">' . fullname($comment) . '</a>');
             } else {
                 $output .= get_string('postedby', 'oublog', fullname($comment));
             }
         } else {
             $output .= get_string($canaudit ? 'postedbymoderatedaudit' : 'postedbymoderated', 'oublog', (object) array('commenter' => s($comment->authorname), 'approver' => '<a href="../../user/view.php?id=' . $comment->userid . '&amp;course=' . $oublog->course . '">' . fullname($post) . '</a>', 'approvedate' => oublog_date($comment->timeapproved), 'ip' => s($comment->authorip)));
         }
         $output .= html_writer::end_tag('div');
         $output .= html_writer::end_tag('div');
         $output .= html_writer::start_tag('div', array('class' => 'oublog-comment-content'));
         if (!$forexport) {
             if ($post->visibility == OUBLOG_VISIBILITY_PUBLIC) {
                 $fileurlbase = 'mod/oublog/pluginfile.php';
             } else {
                 $fileurlbase = 'pluginfile.php';
             }
             $comment->message = file_rewrite_pluginfile_urls($comment->message, $fileurlbase, $modcontext->id, 'mod_oublog', 'messagecomment', $comment->id);
         } else {
             $comment->message = portfolio_rewrite_pluginfile_urls($comment->message, $modcontext->id, 'mod_oublog', 'messagecomment', $comment->id, $format);
         }
         $output .= format_text($comment->message, FORMAT_HTML);
         $output .= html_writer::end_tag('div');
         $output .= html_writer::start_tag('div', array('class' => 'oublog-post-links'));
         if (!$comment->deletedby) {
             // You can delete your own comments, or comments on your own
             // personal blog, or if you can manage comments.
             if ($comment->userid && $comment->userid == $USER->id || $oublog->global && $post->userid == $USER->id || $canmanagecomments) {
                 if (!$forexport) {
                     $output .= '<a href="deletecomment.php?comment=' . $comment->id . '">' . $strdelete . '</a>';
                 } else {
                     $output .= $strdelete;
                 }
             }
         }
         // Show OU Alerts reporting link.
         if (isloggedin() && oublog_oualerts_enabled() && oublog_get_reportingemail($oublog) && !($comment->userid == $USER->id) && !$comment->deletedby) {
             $itmurl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
             $itemurl = $itmurl->out() . '#cid' . $comment->id;
             $retnurl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
             $returnurl = $retnurl->out() . '#cid' . $comment->id;
             $reportlink = oualerts_generate_alert_form_url('oublog', $modcontext->id, 'comment', $comment->id, $itemurl, $returnurl, '', false, true);
             if ($reportlink != '') {
                 $output .= html_writer::tag('a', get_string('commentalert', 'oublog'), array('href' => $reportlink));
             }
         }
         $output .= html_writer::end_tag('div');
         $output .= html_writer::end_tag('div');
         $counter++;
     }
     $output .= html_writer::end_tag('div');
     return $output;
 }
コード例 #5
0
/**
 * 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;
}
コード例 #6
0
ファイル: lib.php プロジェクト: nadavkav/moodle-mod_oublog
/**
 * Print recent oublog activity for a course
 *
 * @param object $activity
 * @param int $courseid
 * @param bool $detail
 * @param array $modnames
 * @param bool $viewfullnames
 */
function oublog_print_recent_mod_activity($activity, $courseid, $detail, $modnames, $viewfullnames)
{
    global $CFG, $OUTPUT;
    echo '<table border="0" cellpadding="3" cellspacing="0" class=oublog-recent">';
    echo "<tr><td class=\"userpicture\" valign=\"top\">";
    echo $OUTPUT->user_picture($activity->user, array('courseid' => $courseid));
    echo "</td><td>";
    echo '<div class="title">';
    if ($detail) {
        echo "<img src=\"" . $OUTPUT->pix_url('icon', $activity->type) . "\" class=\"icon\" alt=\"" . s($activity->title) . "\" />";
    }
    echo "<a href=\"{$CFG->wwwroot}/mod/oublog/viewpost.php?post={$activity->content->postid}\">{$activity->content->title}</a>";
    echo '</div>';
    echo '<div class="user">';
    $fullname = fullname($activity->user, $viewfullnames);
    echo "<a href=\"{$CFG->wwwroot}/user/view.php?id={$activity->user->id}&amp;course={$courseid}\">" . "{$fullname}</a> - " . oublog_date($activity->timeposted);
    echo '</div>';
    echo "</td></tr></table>";
    return;
}
コード例 #7
0
    if ($extranav) {
        $navlinks = $navlinks + $extranav;
    }
    $navigation = build_navigation($navlinks, $cm);
    print_header_simple(format_string($oublog->name), "", $navigation, "", "", true, update_module_button($cm->id, $course->id, $stroublog), navmenu($course, $cm));
}
/// Print the main part of the page
echo '<div class="oublog-topofpage"></div>';
/// Print blog posts
?>
    <div id="middle-column">
        <div class="oublog-post">
            <h3><?php 
print format_string($edit->oldtitle);
?>
</h3>
            <div class="oublog-post-date">
                <?php 
print oublog_date($edit->timeupdated);
?>
            </div>
            <p><?php 
print format_text($edit->oldmessage, FORMAT_HTML);
?>
</p>
        </div>
    </div>
    <?php 
/// Finish the page
echo '<div class="clearfix"></div>';
print_footer($course);
コード例 #8
0
 /**
  * Print all user participation records for display
  *
  * @param object $cm current course module object
  * @param object $course current course object
  * @param object $oublog current oublog object
  * @param int $page html_table pagination page
  * @param array $participation mixed array of user participation values
  */
 public function render_all_users_participation_table($cm, $course, $oublog, $page, $limitnum, $participation, $getposts, $getcomments, $start, $end, $pagingurl)
 {
     global $DB, $CFG, $OUTPUT, $USER;
     require_once $CFG->dirroot . '/mod/oublog/participation_table.php';
     $groupmode = oublog_get_activity_groupmode($cm, $course);
     $thepagingbar = "";
     if (!empty($participation->posts) && $participation->postscount > $limitnum) {
         $thepagingbar = $OUTPUT->paging_bar($participation->postscount, $page, $limitnum, $pagingurl);
     } else {
         if (!empty($participation->comments) && $participation->commentscount > $limitnum) {
             $thepagingbar = $OUTPUT->paging_bar($participation->commentscount, $page, $limitnum, $pagingurl);
         }
     }
     if ($getposts) {
         $output = '';
         $output .= html_writer::tag('h2', $participation->postscount . ' ' . get_string('posts', 'oublog'));
         // Provide paging if postscount exceeds posts perpage.
         $output .= $thepagingbar;
         $poststable = new html_table();
         $poststable->head = array(get_string('user'), get_string('title', 'oublog'), get_string('date'), oublog_get_displayname($oublog, true));
         $poststable->size = array('25%', '25%', '25%', '25%');
         $poststable->colclasses = array('oublog_usersinfo_col', '', '', '');
         $poststable->attributes['class'] = 'oublog generaltable ';
         $poststable->data = array();
         foreach ($participation->posts as $post) {
             // Post user object required for user_picture.
             $postuser = new object();
             $postuser->id = $post->userid;
             $fields = explode(',', user_picture::fields('', null, '', 'poster'));
             foreach ($fields as $field) {
                 if ($field != 'id') {
                     $postuser->{$field} = $post->{$field};
                 }
             }
             $fullname = fullname($postuser);
             $row = array();
             $row[] = $OUTPUT->user_picture($postuser, array('class' => 'userpicture')) . $fullname;
             $url = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
             $postname = !empty($post->title) ? $post->title : get_string('untitledpost', 'oublog');
             $row[] = html_writer::div(html_writer::link($url, $postname), '');
             $row[] = html_writer::div(oublog_date($post->timeposted));
             $bparams = array('id' => $cm->id);
             $linktext = $name = $grpname = $dispname = '';
             if (oublog_get_displayname($oublog)) {
                 $dispname = oublog_get_displayname($oublog);
             }
             if ($post->blogname != "") {
                 $linktext = $post->blogname;
             } else {
                 if ($oublog->name != "") {
                     if ($groupmode > NOGROUPS && isset($post->groupid) && $post->groupid > 0) {
                         $bparams['group'] = $post->groupid;
                         $grpname = groups_get_group_name($post->groupid);
                     } else {
                         if ($oublog->individual != OUBLOG_NO_INDIVIDUAL_BLOGS) {
                             $bparams['individual'] = $post->userid;
                             $name = fullname($postuser);
                         }
                     }
                     if ($post->groupid == 0 && $oublog->individual > OUBLOG_NO_INDIVIDUAL_BLOGS) {
                         $name = fullname($postuser);
                     } else {
                         if (!$groupmode) {
                             $name = $oublog->name;
                         }
                     }
                     $a = (object) array('name' => $grpname . " " . $name, 'displayname' => $dispname);
                     $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                 }
             }
             if (!$groupmode && !$oublog->global && $oublog->individual == 0) {
                 $a = (object) array('name' => $grpname . " " . $name, 'displayname' => $dispname);
                 $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
             }
             if (!$groupmode) {
                 $linktext = $name;
             }
             $burl = new moodle_url('/mod/oublog/view.php', $bparams);
             $row[] = html_writer::link($burl, $linktext);
             $poststable->data[] = $row;
         }
         $output .= html_writer::table($poststable);
         $output .= $thepagingbar;
         return $output;
     }
     if ($getcomments) {
         $output = '';
         // Do the comments stuff here.
         if (!$participation->comments) {
             $output .= html_writer::tag('h2', get_string('nousercomments', 'oublog'));
         } else {
             $output .= html_writer::tag('h2', $participation->commentscount . ' ' . get_string('comments', 'oublog'));
             // Provide paging if commentscount exceeds posts perpage.
             $output .= $thepagingbar;
             $commenttable = new html_table();
             $commenttable->head = array(get_string('user'), get_string('title', 'oublog'), get_string('date'), get_string('post'));
             $commenttable->size = array('25%', '25%', '25%', '25%');
             $commenttable->colclasses = array('oublog_usersinfo_col ', '', '', 'oublog_postsinfo_col');
             $commenttable->attributes['class'] = 'oublog generaltable ';
             $commenttable->data = array();
             unset($bparams);
             foreach ($participation->comments as $comment) {
                 $row = array();
                 // Comment author object required for user_picture.
                 $commentauthor = new stdClass();
                 $commentauthor->id = $comment->commenterid;
                 $fields = explode(',', user_picture::fields('', null, '', 'commenter'));
                 foreach ($fields as $field) {
                     if ($field != 'id') {
                         $cfield = "commenter" . $field;
                         $commentauthor->{$field} = $comment->{$cfield};
                     }
                 }
                 $viewposturl = new moodle_url('/mod/oublog/viewpost.php', array('post' => $comment->postid));
                 $viewpostcommenturl = $viewposturl->out() . '#cid' . $comment->id;
                 $commenttitle = !empty($comment->title) ? $comment->title : get_string('untitledcomment', 'oublog');
                 $posttitle = !empty($comment->posttitle) ? $comment->posttitle : get_string('untitledpost', 'oublog');
                 $viewcommentlink = html_writer::link($viewpostcommenturl, s($commenttitle));
                 // User cell.
                 $usercell = $OUTPUT->user_picture($commentauthor, array('class' => 'userpicture'));
                 $usercell .= html_writer::start_tag('div', array('class' => ''));
                 $usercell .= fullname($commentauthor);
                 $usercell .= html_writer::end_tag('div');
                 $row[] = $usercell;
                 // Comments cell.
                 $row[] = $viewcommentlink;
                 // Comment date cell.
                 $row[] = userdate($comment->timeposted);
                 // Start of cell 4 code should resemble view page block code.
                 $postauthor = new stdClass();
                 $postauthor->id = $comment->posterid;
                 $postauthor->groupid = $comment->groupid;
                 $fields = explode(',', user_picture::fields('', null, '', 'poster'));
                 foreach ($fields as $field) {
                     if ($field != 'id') {
                         $pfield = "poster" . $field;
                         $postauthor->{$field} = $comment->{$pfield};
                     }
                 }
                 $bparams = array('id' => $cm->id);
                 $linktext = $name = $grpname = $dispname = '';
                 if (oublog_get_displayname($oublog)) {
                     $dispname = oublog_get_displayname($oublog);
                 }
                 if ($comment->bloginstancename != '') {
                     $bparams['individual'] = $comment->posterid;
                     $bparams['group'] = $comment->groupid;
                     $name = fullname($postauthor);
                 } else {
                     if ($oublog->name != "") {
                         if ($groupmode > NOGROUPS && isset($comment->groupid) && $comment->groupid > 0) {
                             $bparams['group'] = $comment->groupid;
                             $grpname = groups_get_group_name($comment->groupid);
                         } else {
                             if ($oublog->individual != OUBLOG_NO_INDIVIDUAL_BLOGS) {
                                 $bparams['individual'] = $comment->posterid;
                                 $name = fullname($postauthor);
                             }
                         }
                         if ($comment->groupid == 0 && $oublog->individual > OUBLOG_NO_INDIVIDUAL_BLOGS) {
                             $name = fullname($postauthor);
                         } else {
                             if (!$groupmode) {
                                 $name = $oublog->name;
                             }
                         }
                         $a = (object) array('name' => $grpname . $name, 'displayname' => $dispname);
                         $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                     }
                 }
                 if (!$groupmode && !$oublog->global && $oublog->individual == 0) {
                     // Personal or course wide.
                     $a = (object) array('name' => $grpname . $name, 'displayname' => $dispname);
                     $linktext = get_string('defaultpersonalblogname', 'oublog', $a);
                 }
                 if (!$groupmode) {
                     $linktext = $name;
                 }
                 $postauthorurl = new moodle_url('/mod/oublog/view.php', $bparams);
                 $postauthorlink = html_writer::link($postauthorurl, $linktext);
                 $viewpostlink = html_writer::link($viewposturl, s($posttitle));
                 // Posts cell.
                 $postscell = html_writer::start_tag('div', array('class' => 'oublog_postsinfo'));
                 $postscell .= $OUTPUT->user_picture($postauthor, array('courseid' => $oublog->course, 'class' => 'userpicture'));
                 $postscell .= html_writer::start_tag('div', array('class' => 'oublog_postscell'));
                 $postscell .= html_writer::start_tag('div', array('class' => 'oublog_postsinfo_label'));
                 $postscell .= html_writer::start_tag('div', array('class' => 'oublog_postscell_posttitle'));
                 $postscell .= html_writer::link($postauthorlink, $viewpostlink);
                 $postscell .= html_writer::end_tag('div');
                 $postscell .= html_writer::start_tag('div', array('class' => 'oublogstats_commentposts_blogname'));
                 $postscell .= html_writer::empty_tag('br', array());
                 $postscell .= oublog_date($comment->postdate);
                 $postscell .= html_writer::empty_tag('br', array());
                 $postscell .= $postauthorlink;
                 $postscell .= html_writer::end_tag('div');
                 $postscell .= html_writer::end_tag('div');
                 $postscell .= html_writer::end_tag('div');
                 $postscell .= html_writer::end_tag('div');
                 $postscell .= html_writer::end_tag('div');
                 $row[] = $postscell;
                 $commenttable->data[] = $row;
             }
             $output .= html_writer::table($commenttable);
             $output .= $thepagingbar;
             return $output;
         }
     }
 }
コード例 #9
0
/**
 * Generates oublog user participation statistics output.
 * @param object $oublog
 * @param object $cm
 * @param mod_oublog_renderer $renderer
 * @param bool $ajax true to return data object rather than html
 */
function oublog_stats_output_myparticipation($oublog, $cm, $renderer = null, $course, $currentindividual, $globalindividual = null)
{
    global $PAGE, $DB, $USER, $OUTPUT;
    if (!isloggedin()) {
        // My participation is only visible to actual users.
        return;
    }
    if (!$renderer) {
        $renderer = $PAGE->get_renderer('mod_oublog');
    }
    // Setup My Participation capability check.
    $curgroup = oublog_get_activity_group($cm);
    $canview = oublog_can_view_participation($course, $oublog, $cm, $curgroup);
    if ($oublog->global) {
        $currentindividual = $globalindividual;
    }
    // Dont show the 'block' if user cant participate.
    if ($oublog->global && $currentindividual != $USER->id || $oublog->individual > OUBLOG_NO_INDIVIDUAL_BLOGS && $currentindividual != $USER->id) {
        return;
    }
    if (!$oublog->global && $canview == OUBLOG_NO_PARTICIPATION) {
        return;
    }
    $context = context_module::instance($cm->id);
    // Get the participation object containing User, Posts and Comments.
    $participation = oublog_get_user_participation($oublog, $context, $USER->id, $curgroup, $cm, $course);
    // Generate content data to send to renderer.
    $maintitle = get_string('myparticipation', 'oublog');
    // The title of the block 'section'.
    $content = '';
    $postedcount = $commentedcount = $commenttotal = 0;
    $postshow = 8;
    $postscount = count($participation->posts);
    if (count($participation->comments) <= 4) {
        $commenttotal = count($participation->comments);
    } else {
        $commenttotal = 4;
    }
    if (!$participation->posts) {
        $content .= html_writer::tag('p', get_string('nouserposts', 'oublog'));
    } else {
        $percent = $stat = null;
        $content .= html_writer::tag('h3', get_string('numberposts', 'oublog', count($participation->posts)));
        foreach ($participation->posts as $post) {
            if ($postedcount >= $postshow - $commenttotal) {
                break;
            }
            $url = new moodle_url('/mod/oublog/viewpost.php', array('post' => $post->id));
            $postname = !empty($post->title) ? $post->title : get_string('untitledpost', 'oublog');
            $label = html_writer::div(html_writer::link($url, $postname), 'oublogstats_posts_posttitle');
            $label .= html_writer::div(oublog_date($post->timeposted), 'oublogstats_commentposts_blogname');
            $statinfo = new oublog_statsinfo($participation->user, $percent, $stat, $url, $label);
            $content .= $renderer->render($statinfo);
            $postedcount++;
        }
    }
    // Pre test the numbers of posts/comments for display upto max.
    $postspluscount = count($participation->posts) - $postedcount;
    if ($postspluscount >= 1) {
        $content .= html_writer::tag('p', get_string('numberpostsmore', 'oublog', $postspluscount));
    }
    if (!$participation->comments) {
        $content .= html_writer::tag('p', get_string('nousercomments', 'oublog'));
    } else {
        $percent = $stat = null;
        // Removing all stats div.
        $content .= html_writer::tag('h3', get_string('numbercomments', 'oublog', count($participation->comments)));
        foreach ($participation->comments as $comment) {
            if ($commentedcount + $postedcount >= $postshow) {
                break;
            }
            $url = new moodle_url('/mod/oublog/viewpost.php', array('post' => $comment->postid));
            $lnkurl = $url->out() . '#cid' . $comment->id;
            $commentname = !empty($comment->title) ? $comment->title : get_string('untitledcomment', 'oublog');
            $label = html_writer::div(html_writer::link($lnkurl, $commentname), 'oublogstats_commentposts_posttitle');
            $label .= html_writer::div(oublog_date($comment->timeposted), 'oublogstats_commentposts_blogname');
            $statinfo = new oublog_statsinfo($participation->user, $percent, $stat, $url, $label);
            $content .= $renderer->render($statinfo);
            $commentedcount++;
        }
    }
    // If the number of comments is more than can be shown.
    $commentspluscount = count($participation->comments) - $commentedcount;
    if ($commentspluscount >= 1) {
        $content .= html_writer::tag('p', get_string('numbercommentsmore', 'oublog', $commentspluscount));
    }
    $params = array('id' => $cm->id, 'group' => $curgroup, 'user' => $participation->user->id);
    $url = new moodle_url('/mod/oublog/userparticipation.php', $params);
    $viewmyparticipation = html_writer::link($url, get_string('viewmyparticipation', 'oublog'));
    $content .= html_writer::start_tag('div', array('class' => 'oublog-post-content'));
    $content .= html_writer::tag('h3', $viewmyparticipation, array('class' => 'oublog-post-title'));
    $content .= html_writer::end_tag('div');
    return $renderer->render_stats_view('myparticipation', $maintitle, $content, null, null, null, false);
}