MDL-13450 and MDL-13303 - sorry for changing forum API so late, but it was needed; major perf improvement for forum; fixed printing of user pictures; merged from MOODLE_19_STABLE
This commit is contained in:
@@ -28,7 +28,7 @@ class block_messages extends block_base {
|
||||
$this->content->footer = '<a href="'.$CFG->wwwroot.'/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'.get_string('messages', 'message').'</a>...';
|
||||
|
||||
$users = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count,
|
||||
u.firstname, u.lastname, u.picture, u.lastaccess
|
||||
u.firstname, u.lastname, u.picture, u.imagealt, u.lastaccess
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}message m
|
||||
WHERE m.useridto = '$USER->id'
|
||||
@@ -43,7 +43,7 @@ class block_messages extends block_base {
|
||||
foreach ($users as $user) {
|
||||
$timeago = format_time(time() - $user->lastaccess);
|
||||
$this->content->text .= '<li class="listentry"><div class="user"><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">';
|
||||
$this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 0, true, false, '', false);
|
||||
$this->content->text .= print_user_picture($user, $this->instance->pageid, $user->picture, 0, true, false, '', false);
|
||||
$this->content->text .= fullname($user).'</a></div>';
|
||||
$this->content->text .= '<div class="message"><a href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="this.target=\'message_'.$user->id.'\'; return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="'.$CFG->pixpath.'/t/message.gif" alt="" /> '.$user->count.'</a>';
|
||||
$this->content->text .= '</div></li>';
|
||||
|
||||
+1
-1
@@ -171,7 +171,7 @@
|
||||
echo '<table cellspacing="0" class="forumpost blogpost blog'.$template['publishstate'].'" width="100%">';
|
||||
|
||||
echo '<tr class="header"><td class="picture left">';
|
||||
print_user_picture($template['userid'], SITEID, $user->picture);
|
||||
print_user_picture($user, SITEID, $user->picture);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td class="topic starter"><div class="subject">'.$template['title'].'</div><div class="author">';
|
||||
|
||||
+16
-2
@@ -1074,6 +1074,16 @@ function &get_fast_modinfo(&$course, $userid=0) {
|
||||
|
||||
$modlurals = array();
|
||||
|
||||
$cmids = array();
|
||||
$contexts = null;
|
||||
foreach ($info as $mod) {
|
||||
$cmids[$mod->cm] = $mod->cm;
|
||||
}
|
||||
if ($cmids) {
|
||||
// preload all module contexts with one query
|
||||
$contexts = get_context_instance(CONTEXT_MODULE, $cmids);
|
||||
}
|
||||
|
||||
foreach ($info as $mod) {
|
||||
// reconstruct minimalistic $cm
|
||||
$cm = new object();
|
||||
@@ -1097,11 +1107,11 @@ function &get_fast_modinfo(&$course, $userid=0) {
|
||||
}
|
||||
$cm->modplural = $modlurals[$cm->modname];
|
||||
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id), $userid)) {
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $contexts[$cm->id], $userid)) {
|
||||
$cm->uservisible = false;
|
||||
|
||||
} else if (!empty($CFG->enablegroupings) and !empty($cm->groupmembersonly)
|
||||
and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id), $userid)) {
|
||||
and !has_capability('moodle/site:accessallgroups', $contexts[$cm->id], $userid)) {
|
||||
if (is_null($modinfo->groups)) {
|
||||
$modinfo->groups = groups_get_user_groups($course->id, $userid);
|
||||
}
|
||||
@@ -1440,6 +1450,10 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
|
||||
if (function_exists($gettypesfunc)) {
|
||||
$types = $gettypesfunc();
|
||||
foreach($types as $type) {
|
||||
if (!isset($type->modclass) or !isset($type->typestr)) {
|
||||
debugging('Incorrect ativity type in '.$modname);
|
||||
continue;
|
||||
}
|
||||
if ($type->modclass == MOD_CLASS_RESOURCE) {
|
||||
$resources[$type->type] = $type->typestr;
|
||||
} else {
|
||||
|
||||
+63
-14
@@ -2538,7 +2538,7 @@ function cleanup_contexts() {
|
||||
*/
|
||||
function get_context_instance($contextlevel, $instance=0) {
|
||||
|
||||
global $context_cache, $context_cache_id;
|
||||
global $context_cache, $context_cache_id, $CFG;
|
||||
static $allowed_contexts = array(CONTEXT_SYSTEM, CONTEXT_USER, CONTEXT_COURSECAT, CONTEXT_COURSE, CONTEXT_GROUP, CONTEXT_MODULE, CONTEXT_BLOCK);
|
||||
|
||||
if ($contextlevel === 'clearcache') {
|
||||
@@ -2561,30 +2561,79 @@ function get_context_instance($contextlevel, $instance=0) {
|
||||
error('Error: get_context_instance() called with incorrect context level "'.s($contextlevel).'"');
|
||||
}
|
||||
|
||||
/// Check the cache
|
||||
if (isset($context_cache[$contextlevel][$instance])) { // Already cached
|
||||
return $context_cache[$contextlevel][$instance];
|
||||
if (!is_array($instance)) {
|
||||
/// Check the cache
|
||||
if (isset($context_cache[$contextlevel][$instance])) { // Already cached
|
||||
return $context_cache[$contextlevel][$instance];
|
||||
}
|
||||
|
||||
/// Get it from the database, or create it
|
||||
if (!$context = get_record('context', 'contextlevel', $contextlevel, 'instanceid', $instance)) {
|
||||
$context = create_context($contextlevel, $instance);
|
||||
}
|
||||
|
||||
/// Only add to cache if context isn't empty.
|
||||
if (!empty($context)) {
|
||||
$context_cache[$contextlevel][$instance] = $context; // Cache it for later
|
||||
$context_cache_id[$context->id] = $context; // Cache it for later
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
/// Get it from the database, or create it
|
||||
if (!$context = get_record('context', 'contextlevel', $contextlevel, 'instanceid', $instance)) {
|
||||
$context = create_context($contextlevel, $instance);
|
||||
|
||||
/// ok, somebody wants to load several contexts to save some db queries ;-)
|
||||
$instances = $instance;
|
||||
$result = array();
|
||||
|
||||
foreach ($instances as $key=>$instance) {
|
||||
/// Check the cache first
|
||||
if (isset($context_cache[$contextlevel][$instance])) { // Already cached
|
||||
$result[$instance] = $context_cache[$contextlevel][$instance];
|
||||
unset($instances[$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/// Only add to cache if context isn't empty.
|
||||
if (!empty($context)) {
|
||||
$context_cache[$contextlevel][$instance] = $context; // Cache it for later
|
||||
$context_cache_id[$context->id] = $context; // Cache it for later
|
||||
if ($instances) {
|
||||
if (count($instances) > 1) {
|
||||
$instanceids = implode(',', $instances);
|
||||
$instanceids = "instanceid IN ($instanceids)";
|
||||
} else {
|
||||
$instance = reset($instances);
|
||||
$instanceids = "instanceid = $instance";
|
||||
}
|
||||
|
||||
if (!$contexts = get_records_sql("SELECT instanceid, id, contextlevel, path, depth
|
||||
FROM {$CFG->prefix}context
|
||||
WHERE contextlevel=$contextlevel AND $instanceids")) {
|
||||
$contexts = array();
|
||||
}
|
||||
|
||||
foreach ($instances as $instance) {
|
||||
if (isset($contexts[$instance])) {
|
||||
$context = $contexts[$instance];
|
||||
} else {
|
||||
$context = create_context($contextlevel, $instance);
|
||||
}
|
||||
|
||||
if (!empty($context)) {
|
||||
$context_cache[$contextlevel][$instance] = $context; // Cache it for later
|
||||
$context_cache_id[$context->id] = $context; // Cache it for later
|
||||
}
|
||||
|
||||
$result[$instance] = $context;
|
||||
}
|
||||
}
|
||||
|
||||
return $context;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a context instance as an object, from a given context id.
|
||||
* @param $id a context id.
|
||||
* @return object The context object.
|
||||
* @param mixed $id a context id or array of ids.
|
||||
* @return mixed object or array of the context object.
|
||||
*/
|
||||
function get_context_instance_by_id($id) {
|
||||
|
||||
|
||||
+14
-8
@@ -93,12 +93,12 @@ function groups_get_grouping($groupingid) {
|
||||
/**
|
||||
* Gets array of all groups in a specified course.
|
||||
* @param int $courseid The id of the course.
|
||||
* @param int $userid optional user id, returns only groups of the user.
|
||||
* @param mixed $userid optional user id or array of ids, returns only groups of the user.
|
||||
* @param int $groupingid optional returns only groups in the specified grouping.
|
||||
* @return array | false Returns an array of the group objects or false if no records
|
||||
* or an error occurred.
|
||||
* or an error occurred. (userid field returned if array in $userid)
|
||||
*/
|
||||
function groups_get_all_groups($courseid, $userid=0, $groupingid=0) {
|
||||
function groups_get_all_groups($courseid, $userid=0, $groupingid=0, $fields='g.*') {
|
||||
global $CFG;
|
||||
|
||||
// groupings are ignored when not enabled
|
||||
@@ -106,12 +106,18 @@ function groups_get_all_groups($courseid, $userid=0, $groupingid=0) {
|
||||
$groupingid = 0;
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
$userfrom = ", {$CFG->prefix}groups_members gm";
|
||||
$userwhere = "AND g.id = gm.groupid AND gm.userid = '$userid'";
|
||||
} else {
|
||||
if (empty($userid)) {
|
||||
$userfrom = "";
|
||||
$userwhere = "";
|
||||
|
||||
} else if (is_array($userid)) {
|
||||
$userids = implode(',', $userid);
|
||||
$userfrom = ", {$CFG->prefix}groups_members gm";
|
||||
$userwhere = "AND g.id = gm.groupid AND gm.userid IN ($userids)";
|
||||
|
||||
} else {
|
||||
$userfrom = ", {$CFG->prefix}groups_members gm";
|
||||
$userwhere = "AND g.id = gm.groupid AND gm.userid = '$userid'";
|
||||
}
|
||||
|
||||
if (!empty($groupingid)) {
|
||||
@@ -122,7 +128,7 @@ function groups_get_all_groups($courseid, $userid=0, $groupingid=0) {
|
||||
$groupingwhere = "";
|
||||
}
|
||||
|
||||
return get_records_sql("SELECT g.*
|
||||
return get_records_sql("SELECT $fields
|
||||
FROM {$CFG->prefix}groups g $userfrom $groupingfrom
|
||||
WHERE g.courseid = $courseid $userwhere $groupingwhere
|
||||
ORDER BY name ASC");
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
print_header(get_string('discussion', 'message').': '.fullname($user), '', '', 'edit-message');
|
||||
echo '<div class="message-discussion-noframes">';
|
||||
echo '<div id="userinfo">';
|
||||
echo print_user_picture($user->id, SITEID, $user->picture, 48, true, true, 'userwindow');
|
||||
echo print_user_picture($user, SITEID, $user->picture, 48, true, true, 'userwindow');
|
||||
echo '<div class="name"><h1>'.$userfullname.'</h1></div>';
|
||||
echo '<div class="commands"><ul>';
|
||||
if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@
|
||||
print_header('','','','','',false,'','',false,'');
|
||||
echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
|
||||
echo '<td width="100">';
|
||||
echo print_user_picture($user->id, SITEID, $user->picture, true, true, true, 'userwindow').'</td>';
|
||||
echo print_user_picture($user, SITEID, $user->picture, true, true, true, 'userwindow').'</td>';
|
||||
echo '<td valign="middle" align="center">';
|
||||
|
||||
echo '<div class="name">'.fullname($user).'</div>';
|
||||
|
||||
+1
-1
@@ -386,7 +386,7 @@ function chat_get_users($chatid, $groupid=0, $groupingid=0) {
|
||||
$groupingjoin = '';
|
||||
}
|
||||
|
||||
return get_records_sql("SELECT DISTINCT u.id, u.firstname, u.lastname, u.picture, c.lastmessageping, c.firstping
|
||||
return get_records_sql("SELECT DISTINCT u.id, u.firstname, u.lastname, u.picture, c.lastmessageping, c.firstping, u.imagealt
|
||||
FROM {$CFG->prefix}chat_users c
|
||||
INNER JOIN {$CFG->prefix}user u ON u.id = c.userid
|
||||
$groupingjoin
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@
|
||||
arsort($sessionusers);
|
||||
foreach ($sessionusers as $sessionuser => $usermessagecount) {
|
||||
if ($user = get_record('user', 'id', $sessionuser)) {
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
echo ' '.fullname($user, true); // XXX TODO use capability instead of true
|
||||
echo " ($usermessagecount)<br />";
|
||||
}
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@
|
||||
$lastping = $timenow - $chatuser->lastmessageping;
|
||||
echo '<tr><td class="chatuserimage">';
|
||||
echo "<a href=\"$CFG->wwwroot/user/view.php?id=$chatuser->id&course=$chat->course\">";
|
||||
print_user_picture($chatuser->id, 0, $chatuser->picture, false, false, false);
|
||||
print_user_picture($chatuser, 0, $chatuser->picture, false, false, false);
|
||||
echo '</a></td><td class="chatuserdetails">';
|
||||
echo '<p>';
|
||||
echo fullname($chatuser).'<br />';
|
||||
|
||||
+1
-1
@@ -1376,7 +1376,7 @@ function data_print_comment($data, $comment, $page=0) {
|
||||
echo '<table cellspacing="0" align="center" width="50%" class="datacomment forumpost">';
|
||||
|
||||
echo '<tr class="header"><td class="picture left">';
|
||||
print_user_picture($comment->userid, $data->course, $user->picture);
|
||||
print_user_picture($user, $data->course, $user->picture);
|
||||
echo '</td>';
|
||||
|
||||
echo '<td class="topic starter" align="left"><div class="author">';
|
||||
|
||||
+95
-95
@@ -3,39 +3,38 @@
|
||||
// Displays a post, and all the posts below it.
|
||||
// If no post is given, displays all posts in a discussion
|
||||
|
||||
require_once("../../config.php");
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once('lib.php');
|
||||
|
||||
$d = required_param('d', PARAM_INT); // Discussion ID
|
||||
$parent = optional_param('parent', 0, PARAM_INT); // If set, then display this post and all children.
|
||||
$mode = optional_param('mode', 0, PARAM_INT); // If set, changes the layout of the thread
|
||||
$move = optional_param('move', 0, PARAM_INT); // If set, moves this discussion to another forum
|
||||
$fromforum = optional_param('fromforum', 0, PARAM_INT); // Needs to be set when we want to move a discussion.
|
||||
$mark = optional_param('mark', '', PARAM_ALPHA); // Used for tracking read posts if user initiated.
|
||||
$postid = optional_param('postid', 0, PARAM_INT); // Used for tracking read posts if user initiated.
|
||||
|
||||
if (!$discussion = get_record("forum_discussions", "id", $d)) {
|
||||
if (!$discussion = get_record('forum_discussions', 'id', $d)) {
|
||||
error("Discussion ID was incorrect or no longer exists");
|
||||
}
|
||||
|
||||
if (!$course = get_record("course", "id", $discussion->course)) {
|
||||
if (!$course = get_record('course', 'id', $discussion->course)) {
|
||||
error("Course ID is incorrect - discussion is faulty");
|
||||
}
|
||||
|
||||
if (!$forum = get_record("forum", "id", $discussion->forum)) {
|
||||
if (!$forum = get_record('forum', 'id', $discussion->forum)) {
|
||||
notify("Bad forum ID stored in this discussion");
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
// move this down fix for MDL-6926
|
||||
require_once("lib.php");
|
||||
|
||||
require_course_login($course, true, $cm);
|
||||
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$canviewdiscussion = has_capability('mod/forum:viewdiscussion', $modcontext);
|
||||
|
||||
if ($forum->type == "news") {
|
||||
require_capability('mod/forum:viewdiscussion', $modcontext, NULL, true, 'noviewdiscussionspermission', 'forum');
|
||||
|
||||
if ($forum->type == 'news') {
|
||||
if (!($USER->id == $discussion->userid || (($discussion->timestart == 0
|
||||
|| $discussion->timestart <= time())
|
||||
&& ($discussion->timeend == 0 || $discussion->timeend > time())))) {
|
||||
@@ -43,45 +42,46 @@
|
||||
}
|
||||
}
|
||||
|
||||
/// move discussion if requested
|
||||
if ($move > 0 and confirm_sesskey()) {
|
||||
$return = $CFG->wwwroot.'/mod/forum/discussion.php?d='.$discussion->id;
|
||||
|
||||
if (!empty($move)) {
|
||||
|
||||
if (!$sourceforum = get_record('forum', 'id', $fromforum)) {
|
||||
error('Cannot find which forum this discussion is being moved from');
|
||||
}
|
||||
if ($sourceforum->type == 'single') {
|
||||
error('Cannot move discussion from a simple single discussion forum');
|
||||
}
|
||||
|
||||
require_capability('mod/forum:movediscussions', $modcontext);
|
||||
|
||||
if ($forum = get_record("forum", "id", $move)) {
|
||||
if (!forum_move_attachments($discussion, $move)) {
|
||||
notify("Errors occurred while moving attachment directories - check your file permissions");
|
||||
}
|
||||
set_field("forum_discussions", "forum", $forum->id, "id", $discussion->id);
|
||||
$discussion->forum = $forum->id;
|
||||
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
add_to_log($course->id, "forum", "move discussion", "discuss.php?d=$discussion->id", "$discussion->id",
|
||||
$cm->id);
|
||||
} else {
|
||||
add_to_log($course->id, "forum", "move discussion", "discuss.php?d=$discussion->id", "$discussion->id");
|
||||
}
|
||||
$discussionmoved = true;
|
||||
|
||||
require_once('rsslib.php');
|
||||
require_once($CFG->libdir.'/rsslib.php');
|
||||
|
||||
// Delete the RSS files for the 2 forums because we want to force
|
||||
// the regeneration of the feeds since the discussions have been
|
||||
// moved.
|
||||
if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($sourceforum)) {
|
||||
notify('Could not purge the cached RSS feeds for the source and/or'.
|
||||
'destination forum(s) - check your file permissionsforums');
|
||||
}
|
||||
} else {
|
||||
error('You can\'t move to that forum - it doesn\'t exist!');
|
||||
if ($forum->type == 'single') {
|
||||
error('Cannot move discussion from a simple single discussion forum', $return);
|
||||
}
|
||||
|
||||
if ($forumto = get_record('forum', 'id', $move)) {
|
||||
error('You can\'t move to that forum - it doesn\'t exist!', $return);
|
||||
}
|
||||
|
||||
if (!$cmto = get_coursemodule_from_instance('forum', $forumto->id, $course->id)) {
|
||||
error('Target forum not found in this course.', $return);
|
||||
}
|
||||
|
||||
if (!coursemodule_visible_for_user($cmto)) {
|
||||
error('Forum not visible', $return);
|
||||
}
|
||||
|
||||
if (!forum_move_attachments($discussion, $forumto)) {
|
||||
notify("Errors occurred while moving attachment directories - check your file permissions");
|
||||
}
|
||||
set_field('forum_discussions', 'forum', $forumto->id, 'id', $discussion->id);
|
||||
add_to_log($course->id, 'forum', 'move discussion', "discuss.php?d=$discussion->id", $discussion->id, $cmto->id);
|
||||
|
||||
require_once($CFG->libdir.'/rsslib.php');
|
||||
require_once('rsslib.php');
|
||||
|
||||
// Delete the RSS files for the 2 forums because we want to force
|
||||
// the regeneration of the feeds since the discussions have been
|
||||
// moved.
|
||||
if (!forum_rss_delete_file($forum) || !forum_rss_delete_file($sourceforum)) {
|
||||
error('Could not purge the cached RSS feeds for the source and/or'.
|
||||
'destination forum(s) - check your file permissionsforums', $return);
|
||||
}
|
||||
|
||||
redirect($return.'&moved=-1&sesskey='.sesskey());
|
||||
}
|
||||
|
||||
$logparameters = "d=$discussion->id";
|
||||
@@ -89,11 +89,7 @@
|
||||
$logparameters .= "&parent=$parent";
|
||||
}
|
||||
|
||||
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
add_to_log($course->id, "forum", "view discussion", "discuss.php?$logparameters", "$discussion->id", $cm->id);
|
||||
} else {
|
||||
add_to_log($course->id, "forum", "view discussion", "discuss.php?$logparameters", "$discussion->id");
|
||||
}
|
||||
add_to_log($course->id, 'forum', 'view discussion', "discuss.php?$logparameters", $discussion->id, $cm->id);
|
||||
|
||||
unset($SESSION->fromdiscussion);
|
||||
|
||||
@@ -104,45 +100,47 @@
|
||||
$displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
|
||||
|
||||
if ($parent) {
|
||||
if (abs($displaymode) == 1) { // If flat AND parent, then force nested display this time
|
||||
$displaymode = 3;
|
||||
// If flat AND parent, then force nested display this time
|
||||
if ($displaymode == FORUM_MODE_FLATOLDEST or $displaymode == FORUM_MODE_FLATNEWEST) {
|
||||
$displaymode = FORUM_MODE_NESTED;
|
||||
}
|
||||
} else {
|
||||
$parent = $discussion->firstpost;
|
||||
}
|
||||
|
||||
if (!forum_user_can_view_post($parent, $course, $cm, $forum, $discussion)) {
|
||||
error('You do not have permissions to view this post', "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
|
||||
}
|
||||
|
||||
if (! $post = forum_get_post_full($parent)) {
|
||||
error("Discussion no longer exists", "$CFG->wwwroot/mod/forum/view.php?f=$forum->id");
|
||||
}
|
||||
|
||||
$post->modcontext = $modcontext;
|
||||
|
||||
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum) &&
|
||||
$CFG->forum_usermarksread) {
|
||||
if ($mark == 'read') {
|
||||
forum_tp_add_read_record($USER->id, $postid, $discussion->id, $forum->id);
|
||||
} else if ($mark == 'unread') {
|
||||
forum_tp_delete_read_records($USER->id, $postid);
|
||||
}
|
||||
if (!forum_user_can_view_post($post, $course, $cm, $forum, $discussion)) {
|
||||
error('You do not have permissions to view this post', "$CFG->wwwroot/mod/forum/view.php?id=$forum->id");
|
||||
}
|
||||
|
||||
if ($mark == 'read' or $mark == 'unread') {
|
||||
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum) &&
|
||||
$CFG->forum_usermarksread) {
|
||||
if ($mark == 'read') {
|
||||
forum_tp_add_read_record($USER->id, $postid, $discussion->id, $forum->id);
|
||||
} else {
|
||||
// unread
|
||||
forum_tp_delete_read_records($USER->id, $postid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$searchform = forum_search_form($course);
|
||||
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => format_string($discussion->name,true), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
|
||||
$navlinks[] = array('name' => format_string($discussion->name), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
|
||||
if ($parent != $discussion->firstpost) {
|
||||
$navlinks[] = array('name' => format_string($post->subject,true), 'type' => 'title');
|
||||
$navlinks[] = array('name' => format_string($post->subject), 'type' => 'title');
|
||||
}
|
||||
|
||||
$navigation = build_navigation($navlinks, $cm);
|
||||
|
||||
$navigation = build_navigation($navlinks, $cm);
|
||||
print_header("$course->shortname: ".format_string($discussion->name), $course->fullname,
|
||||
$navigation, "", "", true, $searchform, navmenu($course, $cm));
|
||||
|
||||
|
||||
|
||||
/// Check to see if groups are being used in this forum
|
||||
/// If so, make sure the current person is allowed to see this discussion
|
||||
@@ -153,7 +151,7 @@
|
||||
} else {
|
||||
$capname = 'mod/forum:replypost';
|
||||
}
|
||||
|
||||
|
||||
$canreply = false;
|
||||
if (has_capability($capname, $modcontext)) {
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
@@ -173,19 +171,20 @@
|
||||
print_footer($course);
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
} else if ($groupmode == VISIBLEGROUPS) {
|
||||
if ($discussion->groupid == -1 or groups_is_member($discussion->groupid)) {
|
||||
$canreply = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$canreply = true;
|
||||
}
|
||||
} else { // allow guests to see the link
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
|
||||
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) {
|
||||
// User is a guest here ! guests are prompted to login later if try to reply
|
||||
$canreply = true;
|
||||
}
|
||||
}
|
||||
@@ -202,24 +201,30 @@
|
||||
|
||||
if ($forum->type != 'single'
|
||||
&& has_capability('mod/forum:movediscussions', $modcontext)) {
|
||||
|
||||
|
||||
// Popup menu to move discussions to other forums. The discussion in a
|
||||
// single discussion forum can't be moved.
|
||||
if ($forums = get_all_instances_in_course("forum", $course)) {
|
||||
$modinfo = get_fast_modinfo($course);
|
||||
if (isset($modinfo->instances['forum'])) {
|
||||
if ($course->format == 'weeks') {
|
||||
$strsection = get_string("week");
|
||||
} else {
|
||||
$strsection = get_string("topic");
|
||||
}
|
||||
$section = -1;
|
||||
foreach ($forums as $courseforum) {
|
||||
if (!empty($courseforum->section) and $section != $courseforum->section) {
|
||||
$forummenu[] = "-------------- $strsection $courseforum->section --------------";
|
||||
$forummenu = array();
|
||||
foreach ($modinfo->instances['forum'] as $forumcm) {
|
||||
if (!$forumcm->uservisible) {
|
||||
continue;
|
||||
}
|
||||
$section = $courseforum->section;
|
||||
if ($courseforum->id != $forum->id) {
|
||||
$url = "discuss.php?d=$discussion->id&fromforum=$discussion->forum&move=$courseforum->id";
|
||||
$forummenu[$url] = format_string($courseforum->name,true);
|
||||
|
||||
if (!empty($forumcm->sectionnum) and $section != $forumcm->sectionnum) {
|
||||
$forummenu[] = "-------------- $strsection $forumcm->sectionnum --------------";
|
||||
}
|
||||
$section = $forumcm->sectionnum;
|
||||
if ($forumcm->instance != $forum->id) {
|
||||
$url = "discuss.php?d=$discussion->id&move=$forumcm->instance&sesskey=".sesskey();
|
||||
$forummenu[$url] = format_string($forumcm->name);
|
||||
}
|
||||
}
|
||||
if (!empty($forummenu)) {
|
||||
@@ -233,7 +238,8 @@
|
||||
echo "</td></tr></table>";
|
||||
|
||||
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
|
||||
$a->blockafter = $forum->blockafter;
|
||||
$a = new object();
|
||||
$a->blockafter = $forum->blockafter;
|
||||
$a->blockperiod = get_string('secondstotime'.$forum->blockperiod);
|
||||
notify(get_string('thisforumisthrottled','forum',$a));
|
||||
}
|
||||
@@ -243,20 +249,14 @@
|
||||
notify(get_string('qandanotify','forum'));
|
||||
}
|
||||
|
||||
if (isset($discussionmoved)) {
|
||||
notify(get_string("discussionmoved", "forum", format_string($forum->name,true)));
|
||||
if ($move == -1 and confirm_sesskey()) {
|
||||
notify(get_string('discussionmoved', 'forum', format_string($forum->name,true)));
|
||||
}
|
||||
|
||||
$canrate = has_capability('mod/forum:rate', $modcontext);
|
||||
forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, $canreply, $canrate);
|
||||
|
||||
/// Print the actual discussion
|
||||
if (!$canviewdiscussion) {
|
||||
notice(get_string('noviewdiscussionspermission', 'forum'));
|
||||
} else {
|
||||
$canrate = has_capability('mod/forum:rate', $modcontext);
|
||||
forum_print_discussion($course, $forum, $discussion, $post, $displaymode, $canreply, $canrate);
|
||||
}
|
||||
|
||||
print_footer($course);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
+364
-214
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ class mod_forum_mod_form extends moodleform_mod {
|
||||
|
||||
function definition() {
|
||||
|
||||
global $CFG, $FORUM_TYPES, $COURSE;
|
||||
global $CFG, $COURSE;
|
||||
$mform =& $this->_form;
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@@ -15,8 +15,10 @@ class mod_forum_mod_form extends moodleform_mod {
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
|
||||
asort($FORUM_TYPES);
|
||||
$mform->addElement('select', 'type', get_string('forumtype', 'forum'), $FORUM_TYPES);
|
||||
$forum_types = forum_get_forum_types();
|
||||
|
||||
asort($forum_types);
|
||||
$mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forum_types);
|
||||
$mform->setHelpButton('type', array('forumtype', get_string('forumtype', 'forum'), 'forum'));
|
||||
$mform->setDefault('type', 'general');
|
||||
|
||||
@@ -163,7 +165,7 @@ class mod_forum_mod_form extends moodleform_mod {
|
||||
function data_preprocessing(&$default_values){
|
||||
if (empty($default_values['scale'])){
|
||||
$default_values['assessed'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($default_values['assessed'])){
|
||||
$default_values['ratingtime'] = 0;
|
||||
|
||||
+33
-24
@@ -55,7 +55,7 @@
|
||||
if (!get_referer()) { // No referer - probably coming in via email See MDL-9052
|
||||
require_login();
|
||||
}
|
||||
|
||||
|
||||
$navigation = build_navigation('', $cm);
|
||||
print_header($course->shortname, $course->fullname, $navigation, '' , '', true, "", navmenu($course, $cm));
|
||||
|
||||
@@ -74,8 +74,13 @@
|
||||
if (! $course = get_record("course", "id", $forum->course)) {
|
||||
error("The course number was incorrect ($forum->course)");
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
error("Incorrect course module");
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
if (! forum_user_can_post_discussion($forum)) {
|
||||
|
||||
if (! forum_user_can_post_discussion($forum, -1, -1, $cm)) {
|
||||
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
|
||||
$SESSION->wantsurl = $FULLME;
|
||||
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
|
||||
@@ -85,10 +90,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) {
|
||||
error(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $coursecontext)) {
|
||||
error(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
|
||||
if (isset($_SERVER["HTTP_REFERER"])) {
|
||||
@@ -140,7 +143,7 @@
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (! forum_user_can_post($forum)) {
|
||||
if (! forum_user_can_post($forum, null, $cm, $modcontext)) {
|
||||
if (has_capability('moodle/legacy:guest', $coursecontext, NULL, false)) { // User is a guest here!
|
||||
$SESSION->wantsurl = $FULLME;
|
||||
$SESSION->enrolcancel = $_SERVER['HTTP_REFERER'];
|
||||
@@ -313,21 +316,22 @@
|
||||
"post.php?delete=$delete&confirm=$delete",
|
||||
$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#p'.$post->id);
|
||||
|
||||
forum_print_post($post, $course->id, $ownpost=false, $reply=false, $link=false);
|
||||
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false);
|
||||
if (empty($post->edit)) {
|
||||
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
|
||||
$user_read_array = forum_tp_get_discussion_read_records($USER->id, $discussion->id);
|
||||
} else {
|
||||
$user_read_array = array();
|
||||
}
|
||||
forum_print_posts_nested($post->id, $course->id, false, false, $user_read_array, $forum->id);
|
||||
$posts = forum_get_all_discussion_posts($discussion->id, "created ASC");
|
||||
forum_print_posts_nested($course, $cm, $forum, $discussion, $post, false, false, $user_read_array, $posts);
|
||||
}
|
||||
} else {
|
||||
print_header();
|
||||
notice_yesno(get_string("deletesure", "forum", $replycount),
|
||||
"post.php?delete=$delete&confirm=$delete",
|
||||
$CFG->wwwroot.'/mod/forum/discuss.php?d='.$post->discussion.'#p'.$post->id);
|
||||
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
|
||||
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -402,7 +406,7 @@
|
||||
} else { // User just asked to prune something
|
||||
|
||||
$course = get_record('course', 'id', $forum->course);
|
||||
|
||||
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => format_string($post->subject, true), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
|
||||
$navlinks[] = array('name' => get_string("prune", "forum"), 'link' => '', 'type' => 'title');
|
||||
@@ -414,7 +418,7 @@
|
||||
|
||||
include('prune.html');
|
||||
|
||||
forum_print_post($post, $forum->course, $ownpost=false, $reply=false, $link=false);
|
||||
forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false);
|
||||
echo '</center>';
|
||||
}
|
||||
print_footer($course);
|
||||
@@ -478,7 +482,7 @@
|
||||
if (!forum_update_post($updatepost, $message)) {
|
||||
error(get_string("couldnotupdate", "forum"), $errordestination);
|
||||
}
|
||||
|
||||
|
||||
// MDL-11818
|
||||
if (($forum->type == 'single') && ($updatepost->parent == '0')){ // updating first post of single discussion type -> updating forum intro
|
||||
$forum->intro = $updatepost->message;
|
||||
@@ -523,7 +527,7 @@
|
||||
if (!empty($message)) { // if we're printing stuff about the file upload
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
||||
|
||||
if ($subscribemessage = forum_post_subscription($fromform)) {
|
||||
$timemessage = 4;
|
||||
}
|
||||
@@ -576,13 +580,13 @@
|
||||
if (!empty($message)) { // if we're printing stuff about the file upload
|
||||
$timemessage = 4;
|
||||
}
|
||||
|
||||
|
||||
if ($fromform->mailnow) {
|
||||
$message .= get_string("postmailnow", "forum");
|
||||
$timemessage = 4;
|
||||
} else {
|
||||
$message .= '<br />'.get_string("postadded", "forum", format_time($CFG->maxeditingtime));
|
||||
}
|
||||
}
|
||||
|
||||
if ($subscribemessage = forum_post_subscription($discussion)) {
|
||||
$timemessage = 4;
|
||||
@@ -624,7 +628,7 @@
|
||||
if (empty($post->edit)) {
|
||||
$post->edit = '';
|
||||
}
|
||||
|
||||
|
||||
if (empty($discussion->name)) {
|
||||
if (empty($discussion)) {
|
||||
$discussion = new object;
|
||||
@@ -646,21 +650,21 @@
|
||||
$navlinks = array();
|
||||
if ($post->parent) {
|
||||
$navlinks[] = array('name' => format_string($toppost->subject, true), 'link' => "discuss.php?d=$discussion->id", 'type' => 'title');
|
||||
$navlinks[] = array('name' => get_string('editing', 'forum'), 'link' => '', 'type' => 'title');
|
||||
$navlinks[] = array('name' => get_string('editing', 'forum'), 'link' => '', 'type' => 'title');
|
||||
} else {
|
||||
$navlinks[] = array('name' => format_string($toppost->subject), 'link' => '', 'type' => 'title');
|
||||
}
|
||||
$navigation = build_navigation($navlinks, $cm);
|
||||
|
||||
|
||||
print_header("$course->shortname: $strdiscussionname ".
|
||||
format_string($toppost->subject), $course->fullname,
|
||||
$navigation, $mform_post->focus($forcefocus), "", true, "", navmenu($course, $cm));
|
||||
|
||||
|
||||
// checkup
|
||||
if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post)) {
|
||||
if (!empty($parent) && !forum_user_can_see_post($forum, $discussion, $post, null, $cm)) {
|
||||
error("You cannot reply to this post");
|
||||
}
|
||||
if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum)) {
|
||||
if (empty($parent) && empty($edit) && !forum_user_can_post_discussion($forum, -1, -1, $cm, $modcontext)) {
|
||||
error("You cannot start a new discussion in this forum");
|
||||
}
|
||||
|
||||
@@ -674,7 +678,11 @@
|
||||
forum_check_throttling($forum);
|
||||
|
||||
if (!empty($parent)) {
|
||||
forum_print_post($parent, $course->id, $ownpost=false, $reply=false, $link=false);
|
||||
if (! $discussion = get_record('forum_discussions', 'id', $parent->discussion)) {
|
||||
error('This post is not part of a discussion!');
|
||||
}
|
||||
|
||||
forum_print_post($parent, $discussion, $forum, $cm, $course, false, false, false);
|
||||
if (empty($post->edit)) {
|
||||
if (forum_tp_can_track_forums($forum) && forum_tp_is_tracked($forum)) {
|
||||
$user_read_array = forum_tp_get_discussion_read_records($USER->id, $discussion->id);
|
||||
@@ -682,7 +690,8 @@
|
||||
$user_read_array = array();
|
||||
}
|
||||
if ($forum->type != 'qanda' || forum_user_can_see_discussion($forum, $discussion, $modcontext)) {
|
||||
forum_print_posts_threaded($parent->id, $course->id, 0, false, false, $user_read_array, $discussion->forum, $modcontext);
|
||||
$posts = forum_get_all_discussion_posts($discussion->id, "created ASC");
|
||||
forum_print_posts_threaded($course, $cm, $forum, $discussion, $parent, 0, false, false, $user_read_array, $posts);
|
||||
}
|
||||
}
|
||||
$heading = get_string("yourreply", "forum");
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
$sd->format = $defaultformat;
|
||||
$sd->mailnow = false;
|
||||
//Insert dicussion/post data
|
||||
$sdid = forum_add_discussion($sd, $sd->intro);
|
||||
$sdid = forum_add_discussion($sd, $sd->intro, $forum);
|
||||
//Now, mark the initial post of the discussion as mailed!
|
||||
if ($sdid) {
|
||||
set_field ('forum_posts','mailed', '1', 'discussion', $sdid);
|
||||
|
||||
+13
-9
@@ -98,12 +98,12 @@
|
||||
$strpage = get_string("page");
|
||||
|
||||
if (!$search || $showform) {
|
||||
|
||||
|
||||
$navlinks = array();
|
||||
$navlinks[] = array('name' => $strforums, 'link' => "index.php?id=$course->id", 'type' => 'activity');
|
||||
$navlinks[] = array('name' => $strsearch, 'link' => '', 'type' => 'title');
|
||||
$navigation = build_navigation($navlinks);
|
||||
|
||||
|
||||
print_header_simple("$strsearch", "", $navigation, 'search.words',
|
||||
"", "", " ", navmenu($course));
|
||||
|
||||
@@ -138,8 +138,8 @@
|
||||
print_footer($course);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
print_header_simple("$strsearchresults", "", $navigation, '', "", "", $searchform, navmenu($course));
|
||||
|
||||
echo '<div class="reportlink">';
|
||||
@@ -180,7 +180,7 @@
|
||||
foreach ($posts as $post) {
|
||||
|
||||
// Replace the simple subject with the three items forum name -> thread name -> subject
|
||||
// (if all three are appropriate) each as a link.
|
||||
// (if all three are appropriate) each as a link.
|
||||
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
|
||||
error('Discussion ID was incorrect');
|
||||
}
|
||||
@@ -188,6 +188,10 @@
|
||||
error("Could not find forum $discussion->forum");
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
|
||||
$post->subject = highlight($strippedsearch, $post->subject);
|
||||
$discussion->name = highlight($strippedsearch, $discussion->name);
|
||||
|
||||
@@ -228,7 +232,7 @@
|
||||
$fulllink = "<a href=\"discuss.php?d=$post->discussion#p$post->id\">".get_string("postincontext", "forum")."</a>";
|
||||
|
||||
// Now pring the post.
|
||||
forum_print_post($post, $course->id, false, false, false, false,
|
||||
forum_print_post($post, $discussion, $forum, $cm, $cours, false, false, false, false,
|
||||
$fulllink, $strippedsearch, -99, false);
|
||||
}
|
||||
|
||||
@@ -359,12 +363,12 @@ function forum_print_big_search_form($course) {
|
||||
}
|
||||
|
||||
/**
|
||||
* This function takes each word out of the search string, makes sure they are at least
|
||||
* This function takes each word out of the search string, makes sure they are at least
|
||||
* two characters long and returns an array containing every good word.
|
||||
*
|
||||
*
|
||||
* @param string $words String containing space-separated strings to search for
|
||||
* @param string $prefix String to prepend to the each token taken out of $words
|
||||
* @returns array
|
||||
* @returns array
|
||||
* @todo Take the hardcoded limit out of this function and put it into a user-specified parameter
|
||||
*/
|
||||
function forum_clean_search_terms($words, $prefix='') {
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
global $FORUM_LAYOUT_MODES; // make sure we have the pesky global
|
||||
|
||||
$settings->add(new admin_setting_configselect('forum_displaymode', get_string('displaymode', 'forum'),
|
||||
get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, $FORUM_LAYOUT_MODES));
|
||||
get_string('configdisplaymode', 'forum'), FORUM_MODE_NESTED, forum_get_layout_modes()));
|
||||
|
||||
$settings->add(new admin_setting_configcheckbox('forum_replytouser', get_string('replytouser', 'forum'),
|
||||
get_string('configreplytouser', 'forum'), 1));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
<form id="subscriberform" method="post" action="subscribers.php">
|
||||
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>" />
|
||||
<input type="hidden" name="previoussearch" value="<?php p($previoussearch) ?>" />
|
||||
<input type="hidden" name="id" value="<?php echo $id?>" />
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
@@ -56,7 +56,7 @@
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
|
||||
<input type="text" name="searchtext" size="30" value="<?php p($searchtext, true) ?>"
|
||||
onFocus ="getElementById('subscriberform').add.disabled=true;
|
||||
getElementById('subscriberform').remove.disabled=true;
|
||||
getElementById('subscriberform').removeselect.selectedIndex=-1;
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
echo '<table align="center" cellpadding="5" cellspacing="5">';
|
||||
foreach ($users as $user) {
|
||||
echo '<tr><td>';
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id);
|
||||
echo '</td><td>';
|
||||
echo fullname($user);
|
||||
echo '</td><td>';
|
||||
|
||||
+32
-10
@@ -24,7 +24,7 @@
|
||||
error("Course id is incorrect.");
|
||||
}
|
||||
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
$syscontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$usercontext = get_context_instance(CONTEXT_USER, $id);
|
||||
|
||||
// do not force parents to enrol
|
||||
@@ -89,16 +89,39 @@
|
||||
|
||||
print_paging_bar($totalcount, $page, $perpage,
|
||||
"user.php?id=$user->id&course=$course->id&mode=$mode&perpage=$perpage&");
|
||||
|
||||
$discussions = array();
|
||||
$forums = array();
|
||||
$cms = array();
|
||||
|
||||
foreach ($posts as $post) {
|
||||
|
||||
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
|
||||
error('Discussion ID was incorrect');
|
||||
|
||||
if (!isset($discussions[$post->discussion])) {
|
||||
if (! $discussion = get_record('forum_discussions', 'id', $post->discussion)) {
|
||||
error('Discussion ID was incorrect');
|
||||
}
|
||||
$discussions[$post->discussion] = $discussion;
|
||||
} else {
|
||||
$discussion = $discussions[$post->discussion];
|
||||
}
|
||||
if (! $forum = get_record('forum', 'id', "$discussion->forum")) {
|
||||
error("Could not find forum $discussion->forum");
|
||||
|
||||
if (!isset($forums[$discussion->forum])) {
|
||||
if (! $forum = get_record('forum', 'id', $discussion->forum)) {
|
||||
error("Could not find forum $discussion->forum");
|
||||
}
|
||||
$forums[$discussion->forum] = $forum;
|
||||
} else {
|
||||
$forum = $forums[$discussion->forum];
|
||||
}
|
||||
|
||||
|
||||
if (!isset($cms[$forum->id])) {
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
$cms[$forum->id] = $cm;
|
||||
unset($cm); // do not use cm directly, it would break caching
|
||||
}
|
||||
|
||||
$fullsubject = "<a href=\"view.php?f=$forum->id\">".format_string($forum->name,true)."</a>";
|
||||
if ($forum->type != 'single') {
|
||||
$fullsubject .= " -> <a href=\"discuss.php?d=$discussion->id\">".format_string($discussion->name,true)."</a>";
|
||||
@@ -107,8 +130,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM, SITEID);
|
||||
if ($course->id == SITEID && has_capability('moodle/site:config', $context)) {
|
||||
if ($course->id == SITEID && has_capability('moodle/site:config', $syscontext)) {
|
||||
$postcoursename = get_field('course', 'shortname', 'id', $forum->course);
|
||||
$fullsubject = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$forum->course.'">'.$postcoursename.'</a> -> '. $fullsubject;
|
||||
}
|
||||
@@ -118,7 +140,7 @@
|
||||
$fulllink = "<a href=\"discuss.php?d=$post->discussion#p$post->id\">".
|
||||
get_string("postincontext", "forum")."</a>";
|
||||
|
||||
forum_print_post($post, $course->id, false, false, false, false, $fulllink);
|
||||
forum_print_post($post, $discussion, $forum, $cms[$forum->id], $course, false, false, false, false, $fulllink);
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
|
||||
+13
-15
@@ -14,9 +14,9 @@
|
||||
$search = optional_param('search', ''); // search string
|
||||
|
||||
|
||||
$buttontext = '';
|
||||
|
||||
if ($id) {
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('forum', $id)) {
|
||||
error("Course Module ID was incorrect");
|
||||
}
|
||||
@@ -42,14 +42,12 @@
|
||||
$strforums = get_string("modulenameplural", "forum");
|
||||
$strforum = get_string("modulename", "forum");
|
||||
|
||||
if ($cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
$buttontext = update_module_button($cm->id, $course->id, $strforum);
|
||||
} else {
|
||||
$cm->id = 0;
|
||||
$cm->visible = 1;
|
||||
$cm->course = $course->id;
|
||||
$buttontext = "";
|
||||
if (!$cm = get_coursemodule_from_instance("forum", $forum->id, $course->id)) {
|
||||
error("Course Module missing");
|
||||
}
|
||||
|
||||
$buttontext = update_module_button($cm->id, $course->id, $strforum);
|
||||
|
||||
} else {
|
||||
error('Must specify a course module or a forum ID');
|
||||
}
|
||||
@@ -72,11 +70,11 @@
|
||||
if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
|
||||
|
||||
if (!has_capability('mod/forum:viewdiscussion', $context)) {
|
||||
notice(get_string('noviewdiscussionspermission', 'forum'));
|
||||
}
|
||||
|
||||
|
||||
/// find out current groups mode
|
||||
groups_print_activity_menu($cm, 'view.php?id=' . $cm->id);
|
||||
$currentgroup = groups_get_activity_group($cm);
|
||||
@@ -154,7 +152,7 @@
|
||||
echo "<span class=\"helplink\"><a href=\"subscribers.php?id=$forum->id\">$strshowsubscribers</a></span>";
|
||||
}
|
||||
|
||||
echo '<div class="helplink" id="subscriptionlink">', forum_get_subscribe_link($forum, $context,
|
||||
echo '<div class="helplink" id="subscriptionlink">', forum_get_subscribe_link($forum, $context,
|
||||
array('forcesubscribed' => '', 'cantsubscribe' => '')), '</div>';
|
||||
}
|
||||
|
||||
@@ -190,7 +188,7 @@
|
||||
|
||||
// print_box_end(); // forumcontrol
|
||||
|
||||
// print_box(' ', 'clearer');
|
||||
// print_box(' ', 'clearer');
|
||||
|
||||
|
||||
if (!empty($forum->blockafter) && !empty($forum->blockperiod)) {
|
||||
@@ -223,7 +221,7 @@
|
||||
}
|
||||
$displaymode = get_user_preferences("forum_displaymode", $CFG->forum_displaymode);
|
||||
$canrate = has_capability('mod/forum:rate', $context);
|
||||
forum_print_discussion($course, $forum, $discussion, $post, $displaymode, NULL, $canrate);
|
||||
forum_print_discussion($course, $cm, $forum, $discussion, $post, $displaymode, NULL, $canrate);
|
||||
break;
|
||||
|
||||
case 'eachuser':
|
||||
@@ -262,8 +260,8 @@
|
||||
} else {
|
||||
forum_print_latest_discussions($course, $forum, $CFG->forum_manydiscussions, 'header', '', $currentgroup, $groupmode, $page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
print_footer($course);
|
||||
|
||||
@@ -16,7 +16,7 @@ function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode='',
|
||||
|
||||
//Use this function to show author's image
|
||||
//Comments: Configuration not supported
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
|
||||
//Line separator to show this template fine. :-)
|
||||
echo '<br />';
|
||||
|
||||
@@ -13,7 +13,7 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode
|
||||
echo '<tr valign="top">';
|
||||
echo '<td class="left picture">';
|
||||
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
|
||||
echo '</td>';
|
||||
echo '<th class="entryheader">';
|
||||
|
||||
@@ -13,7 +13,7 @@ function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mo
|
||||
echo '<tr valign="top">';
|
||||
|
||||
echo '<td class="picture">';
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
echo '</td>';
|
||||
|
||||
echo '<th class="entryheader">';
|
||||
|
||||
@@ -1563,7 +1563,7 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
|
||||
echo '<table class="glossarycomment" cellspacing="0">';
|
||||
echo '<tr valign="top">';
|
||||
echo '<td class="left picture">';
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
echo '</td>';
|
||||
echo '<td class="entryheader">';
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@
|
||||
echo '<th align="left">';
|
||||
|
||||
$user = get_record("user","id",$entry->userid);
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
$pivottoshow = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
} else {
|
||||
echo '<th >';
|
||||
|
||||
+1
-1
@@ -184,7 +184,7 @@
|
||||
echo '<table class="generaltable generalbox quizreviewsummary"><tbody>';
|
||||
if ($attempt->userid <> $USER->id) {
|
||||
$student = get_record('user', 'id', $attempt->userid);
|
||||
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
||||
$picture = print_user_picture($student, $course->id, $student->picture, false, true);
|
||||
echo '<tr><th scope="row" class="cell">', $picture, '</th><td class="cell"><a href="', $CFG->wwwroot,
|
||||
'/user/view.php?id=', $student->id, '&course='.$course->id.'">',
|
||||
fullname($student, true), '</a></td></tr>';
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
if ($attempt->userid <> $USER->id) {
|
||||
// Print user picture and name
|
||||
$student = get_record('user', 'id', $attempt->userid);
|
||||
$picture = print_user_picture($student->id, $course->id, $student->picture, false, true);
|
||||
$picture = print_user_picture($student, $course->id, $student->picture, false, true);
|
||||
$table->data[] = array($picture, fullname($student, true));
|
||||
}
|
||||
// print quiz name
|
||||
|
||||
+1
-1
@@ -172,7 +172,7 @@ function note_print($note, $detail = NOTES_SHOW_FULL) {
|
||||
if($detail & NOTES_SHOW_HEAD) {
|
||||
echo '<div class="header">';
|
||||
echo '<div class="user">';
|
||||
print_user_picture($user->id, $note->courseid, $user->picture);
|
||||
print_user_picture($user, $note->courseid, $user->picture);
|
||||
echo fullname($user) . '</div>';
|
||||
echo '<div class="info">' .
|
||||
get_string('bynameondate', 'notes', $authoring) .
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class user_edit_form extends moodleform {
|
||||
if (!empty($CFG->gdversion)) {
|
||||
$image_el =& $mform->getElement('currentpicture');
|
||||
if ($user and $user->picture) {
|
||||
$image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64,true,false,'',true));
|
||||
$image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64,true,false,'',true));
|
||||
} else {
|
||||
$image_el->setValue(get_string('none'));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class user_editadvanced_form extends moodleform {
|
||||
if (!empty($CFG->gdversion)) {
|
||||
$image_el =& $mform->getElement('currentpicture');
|
||||
if ($user and $user->picture) {
|
||||
$image_el->setValue(print_user_picture($user->id, SITEID, $user->picture, 64, true, false, '', true));
|
||||
$image_el->setValue(print_user_picture($user, SITEID, $user->picture, 64, true, false, '', true));
|
||||
} else {
|
||||
$image_el->setValue(get_string('none'));
|
||||
}
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@
|
||||
echo '<table width="80%" class="userinfobox" summary="">';
|
||||
echo '<tr>';
|
||||
echo '<td class="side">';
|
||||
print_user_picture($user->id, $course->id, $user->picture, true, false, false);
|
||||
print_user_picture($user, $course->id, $user->picture, true, false, false);
|
||||
echo '</td><td class="content">';
|
||||
|
||||
// Print the description
|
||||
|
||||
Reference in New Issue
Block a user