mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Changed <module>_print_recent_activity() functions so that they don't use $isteacher. However, I've left the $isteacher parameter in the functions, for backward compatibility so as not to break thrid party modules. Should we remove the parameter now?
This commit is contained in:
parent
57244db359
commit
583b57b42d
@ -1986,7 +1986,7 @@ function assignment_print_recent_activity($course, $isteacher, $timestart) {
|
||||
if ($assignments) {
|
||||
print_headline(get_string('newsubmissions', 'assignment').':');
|
||||
foreach ($assignments as $assignment) {
|
||||
print_recent_activity_note($assignment->time, $assignment, $isteacher, $assignment->name,
|
||||
print_recent_activity_note($assignment->time, $assignment, $assignment->name,
|
||||
$CFG->wwwroot.'/mod/assignment/'.$assignment->url);
|
||||
}
|
||||
$content = true;
|
||||
|
@ -357,7 +357,7 @@ function exercise_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$tempmod->id = $log->exerciseid;
|
||||
//Obtain the visible property from the instance
|
||||
if (instance_is_visible('exercise',$tempmod)) {
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/exercise/'.str_replace('&', '&', $log->url));
|
||||
}
|
||||
}
|
||||
@ -388,7 +388,7 @@ function exercise_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$tempmod->id = $log->exerciseid;
|
||||
//Obtain the visible property from the instance
|
||||
if (instance_is_visible('exercise',$tempmod)) {
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/exercise/'.str_replace('&', '&', $log->url));
|
||||
}
|
||||
}
|
||||
@ -419,7 +419,7 @@ function exercise_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$tempmod->id = $log->exerciseid;
|
||||
//Obtain the visible property from the instance
|
||||
if (instance_is_visible('exercise',$tempmod)) {
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/exercise/'.str_replace('&', '&', $log->url));
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@
|
||||
require_course_login($course);
|
||||
$currentgroup = get_current_group($course->id);
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
|
||||
|
||||
unset($SESSION->fromdiscussion);
|
||||
|
||||
|
@ -853,11 +853,6 @@ function forum_print_overview($courses,&$htmlarray) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NOTE:
|
||||
* $isteacher is to be deprecated. We will need to remove it from all
|
||||
* _print_recent_activity functions for all modules.
|
||||
*/
|
||||
function forum_print_recent_activity($course, $isteacher, $timestart) {
|
||||
/// Given a course and a date, prints a summary of all the new
|
||||
/// messages posted in the course since that date
|
||||
@ -876,9 +871,7 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
|
||||
|
||||
$strftimerecent = get_string('strftimerecent');
|
||||
|
||||
$isteacheredit = isteacheredit($course->id);
|
||||
$mygroupid = mygroupid($course->id);
|
||||
|
||||
$groupmode = array(); /// To cache group modes
|
||||
|
||||
foreach ($logs as $log) {
|
||||
@ -888,28 +881,26 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$tempmod->course = $log->course;
|
||||
$tempmod->id = $post->forum;
|
||||
//Obtain the visible property from the instance
|
||||
$modvisible = instance_is_visible('forum', $tempmod);
|
||||
$coursecontext = get_context_instance(COURSE_CONTEXT, $tempmod->course);
|
||||
$modvisible = instance_is_visible('forum', $tempmod)
|
||||
|| has_capability('moodle/course:viewhiddenactivities', $coursecontext);
|
||||
}
|
||||
|
||||
//Only if the post exists and mod is visible
|
||||
if ($post && $modvisible) {
|
||||
/// Check whether this is for teachers only
|
||||
$teacheronly = '';
|
||||
if ($post->forumtype == 'teacher') {
|
||||
if ($isteacher) {
|
||||
$teacheronly = 'class=\'teacheronly\'';
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($cm[$post->forum])) {
|
||||
$cm[$post->forum] = get_coursemodule_from_instance('forum', $post->forum, $course->id);
|
||||
}
|
||||
$modcontext = get_context_instance(CONTEXT_MODULE, $cm[$post->forum]->id);
|
||||
|
||||
/// Check whether this is belongs to a discussion in a group that
|
||||
/// should NOT be accessible to the current user
|
||||
if (!has_capability('moodle/site:accessallgroups', $modcontext)
|
||||
&& $post->groupid != -1) { /// Open discussions have groupid -1
|
||||
|
||||
if (!$isteacheredit and $post->groupid != -1) { /// Editing teachers or open discussions
|
||||
if (!isset($cm[$post->forum])) {
|
||||
$cm[$post->forum] = get_coursemodule_from_instance('forum', $post->forum, $course->id);
|
||||
$groupmode[$post->forum] = groupmode($course, $cm[$post->forum]);
|
||||
}
|
||||
$groupmode[$post->forum] = groupmode($course, $cm[$post->forum]);
|
||||
|
||||
if ($groupmode[$post->forum]) {
|
||||
//hope i didn't break anything
|
||||
if (!@in_array($mygroupid, $post->groupid))/*$mygroupid != $post->groupid*/{
|
||||
@ -927,9 +918,9 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
|
||||
|
||||
$subjectclass = ($log->action == 'add discussion') ? ' bold' : '';
|
||||
|
||||
echo '<div class="head'.$teacheronly.'">'.
|
||||
echo '<div class="head">'.
|
||||
'<div class="date">'.$date.'</div>'.
|
||||
'<div class="name">'.fullname($post, $isteacher).'</div>'.
|
||||
'<div class="name">'.fullname($post, has_capability('moodle/site:viewfullnames', $coursecontext)).'</div>'.
|
||||
'</div>';
|
||||
echo '<div class="info'.$subjectclass.'">';
|
||||
echo '"<a href="'.$CFG->wwwroot.'/mod/forum/'.str_replace('&', '&', $log->url).'">';
|
||||
@ -938,7 +929,6 @@ function forum_print_recent_activity($course, $isteacher, $timestart) {
|
||||
echo '</a>"</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
@ -1149,6 +1139,7 @@ function forum_get_readable_forums($userid, $courseid=0) {
|
||||
}
|
||||
|
||||
$selectforums = "SELECT DISTINCT(f.id) AS id,
|
||||
f.name AS name,
|
||||
f.type AS type,
|
||||
f.course AS course,
|
||||
cm.id AS cmid,
|
||||
@ -1159,7 +1150,8 @@ function forum_get_readable_forums($userid, $courseid=0) {
|
||||
WHERE cm.instance = f.id
|
||||
AND cm.course = {$course->id}
|
||||
AND cm.module = {$forummod->id}
|
||||
$selecthidden";
|
||||
$selecthidden
|
||||
ORDER BY f.name ASC";
|
||||
|
||||
if ($forums = get_records_sql($selectforums)) {
|
||||
|
||||
@ -1314,114 +1306,6 @@ function forum_search_posts($searchterms, $courseid=0, $limitfrom=0, $limitnum=5
|
||||
return get_records_sql($searchsql, $limitfrom, $limitnum);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* PRE-ROLES VERSION.
|
||||
* TODO: Remove this after testing. This is left here for convenience so that
|
||||
* we can compare with new implementation above.
|
||||
* Note that the argument $sepgroups has been removed in the new version.
|
||||
*/
|
||||
/*
|
||||
function forum_search_posts($searchterms, $courseid, $page=0, $recordsperpage=50,
|
||||
&$totalcount, $sepgroups=0, $extrasql='') {
|
||||
|
||||
global $CFG, $USER;
|
||||
require_once($CFG->libdir.'/searchlib.php');
|
||||
|
||||
if (!isteacher($courseid)) {
|
||||
$notteacherforum = "AND f.type <> 'teacher'";
|
||||
$forummodule = get_record("modules", "name", "forum");
|
||||
$onlyvisible = "AND d.forum = f.id AND f.id = cm.instance AND cm.visible = 1 AND cm.module = $forummodule->id";
|
||||
$onlyvisibletable = ", {$CFG->prefix}course_modules cm, {$CFG->prefix}forum f";
|
||||
if (!empty($sepgroups)) {
|
||||
$separategroups = SEPARATEGROUPS;
|
||||
$selectgroup = " AND ( NOT (cm.groupmode='$separategroups'".
|
||||
" OR (c.groupmode='$separategroups' AND c.groupmodeforce='1') )";//.
|
||||
$selectgroup .= " OR d.groupid = '-1'"; //search inside discussions for all groups too
|
||||
foreach ($sepgroups as $sepgroup){
|
||||
$selectgroup .= " OR d.groupid = '$sepgroup->id'";
|
||||
}
|
||||
$selectgroup .= ")";
|
||||
|
||||
// " OR d.groupid = '$groupid')";
|
||||
$selectcourse = " AND d.course = '$courseid' AND c.id='$courseid'";
|
||||
$coursetable = ", {$CFG->prefix}course c";
|
||||
} else {
|
||||
$selectgroup = '';
|
||||
$selectcourse = " AND d.course = '$courseid'";
|
||||
$coursetable = '';
|
||||
}
|
||||
} else {
|
||||
$notteacherforum = "";
|
||||
$selectgroup = '';
|
||||
$onlyvisible = "";
|
||||
$onlyvisibletable = "";
|
||||
$coursetable = '';
|
||||
if ($courseid == SITEID && isadmin()) {
|
||||
$selectcourse = '';
|
||||
} else {
|
||||
$selectcourse = " AND d.course = '$courseid'";
|
||||
}
|
||||
}
|
||||
|
||||
$timelimit = '';
|
||||
if (!empty($CFG->forum_enabletimedposts) && (!((isadmin() and !empty($CFG->admineditalways)) || isteacher($courseid)))) {
|
||||
$now = time();
|
||||
$timelimit = " AND (d.userid = $USER->id OR ((d.timestart = 0 OR d.timestart <= $now) AND (d.timeend = 0 OR d.timeend > $now)))";
|
||||
}
|
||||
|
||||
$limitfrom = $page;
|
||||
$limitnum = $recordsperpage;
|
||||
|
||||
/// Some differences in syntax for PostgreSQL
|
||||
if ($CFG->dbtype == "postgres7") {
|
||||
$LIKE = "ILIKE"; // case-insensitive
|
||||
$NOTLIKE = "NOT ILIKE"; // case-insensitive
|
||||
$REGEXP = "~*";
|
||||
$NOTREGEXP = "!~*";
|
||||
} else { //Note the LIKE are casesensitive for Oracle. Oracle 10g is required to use
|
||||
$LIKE = "LIKE"; //the caseinsensitive search using regexp_like() or NLS_COMP=LINGUISTIC :-(
|
||||
$NOTLIKE = "NOT LIKE"; //See http://docs.moodle.org/en/XMLDB_Problems#Case-insensitive_searches
|
||||
$REGEXP = "REGEXP";
|
||||
$NOTREGEXP = "NOT REGEXP";
|
||||
}
|
||||
|
||||
$messagesearch = "";
|
||||
$searchstring = "";
|
||||
// Need to concat these back together for parser to work.
|
||||
foreach($searchterms as $searchterm){
|
||||
if ($searchstring != "") {
|
||||
$searchstring .= " ";
|
||||
}
|
||||
$searchstring .= $searchterm;
|
||||
}
|
||||
|
||||
// We need to allow quoted strings for the search. The quotes *should* be stripped
|
||||
// by the parser, but this should be examined carefully for security implications.
|
||||
$searchstring = str_replace("\\\"","\"",$searchstring);
|
||||
$parser = new search_parser();
|
||||
$lexer = new search_lexer($parser);
|
||||
|
||||
if ($lexer->parse($searchstring)) {
|
||||
$parsearray = $parser->get_parsed_array();
|
||||
$messagesearch = search_generate_SQL($parsearray,'p.message','p.subject','p.userid','u.id','u.firstname','u.lastname','p.modified', 'd.forum');
|
||||
}
|
||||
|
||||
$selectsql = "{$CFG->prefix}forum_posts p,
|
||||
{$CFG->prefix}forum_discussions d,
|
||||
{$CFG->prefix}user u $onlyvisibletable $coursetable
|
||||
WHERE ($messagesearch)
|
||||
AND p.userid = u.id
|
||||
AND p.discussion = d.id $selectcourse $notteacherforum $onlyvisible $selectgroup $timelimit $extrasql";
|
||||
|
||||
$totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
|
||||
|
||||
return get_records_sql("SELECT p.*,d.forum, u.firstname,u.lastname,u.email,u.picture FROM
|
||||
$selectsql ORDER BY p.modified DESC", $limitfrom, $limitnum);
|
||||
}*/
|
||||
|
||||
|
||||
function forum_get_ratings($postid, $sort="u.firstname ASC") {
|
||||
/// Returns a list of ratings for a particular post - sorted.
|
||||
global $CFG;
|
||||
|
@ -276,7 +276,7 @@ function glossary_print_recent_activity($course, $isteacher, $timestart) {
|
||||
foreach ($entries as $entry) {
|
||||
$user = get_record('user','id',$entry->userid, '','', '','', 'firstname,lastname');
|
||||
|
||||
print_recent_activity_note($entry->timemodified, $user, $isteacher, $entry->concept,
|
||||
print_recent_activity_note($entry->timemodified, $user, $entry->concept,
|
||||
$CFG->wwwroot.'/mod/glossary/view.php?g='.$entry->glossaryid.
|
||||
'&mode=entry&hook='.$entry->id);
|
||||
}
|
||||
|
@ -890,40 +890,43 @@ function hotpot_print_recent_activity($course, $isteacher, $timestart) {
|
||||
/// Return true if there was output, or false is there was none.
|
||||
|
||||
global $CFG;
|
||||
|
||||
$result = false;
|
||||
if($isteacher){
|
||||
|
||||
$records = get_records_sql("
|
||||
SELECT
|
||||
h.id AS id,
|
||||
h.name AS name,
|
||||
COUNT(*) AS count_attempts
|
||||
FROM
|
||||
{$CFG->prefix}hotpot AS h,
|
||||
{$CFG->prefix}hotpot_attempts AS a
|
||||
WHERE
|
||||
h.course = $course->id
|
||||
AND h.id = a.hotpot
|
||||
AND a.id = a.clickreportid
|
||||
AND a.starttime > $timestart
|
||||
GROUP BY
|
||||
h.id, h.name
|
||||
");
|
||||
// note that PostGreSQL requires h.name in the GROUP BY clause
|
||||
$records = get_records_sql("
|
||||
SELECT
|
||||
h.id AS id,
|
||||
h.name AS name,
|
||||
COUNT(*) AS count_attempts
|
||||
FROM
|
||||
{$CFG->prefix}hotpot AS h,
|
||||
{$CFG->prefix}hotpot_attempts AS a
|
||||
WHERE
|
||||
h.course = $course->id
|
||||
AND h.id = a.hotpot
|
||||
AND a.id = a.clickreportid
|
||||
AND a.starttime > $timestart
|
||||
GROUP BY
|
||||
h.id, h.name
|
||||
");
|
||||
// note that PostGreSQL requires h.name in the GROUP BY clause
|
||||
|
||||
if($records) {
|
||||
|
||||
$names = array();
|
||||
foreach ($records as $id => $record){
|
||||
$href = "$CFG->wwwroot/mod/hotpot/view.php?hp=$id";
|
||||
$name = ' <a href="'.$href.'">'.$record->name.'</a>';
|
||||
if ($record->count_attempts > 1) {
|
||||
$name .= " ($record->count_attempts)";
|
||||
if($records) {
|
||||
$names = array();
|
||||
foreach ($records as $id => $record){
|
||||
if ($cm = get_coursemodule_from_instance('hotpot', $record->id, $course->id)) {
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (has_capability('mod/hotpot:viewreport', $context)) {
|
||||
$href = "$CFG->wwwroot/mod/hotpot/view.php?hp=$id";
|
||||
$name = ' <a href="'.$href.'">'.$record->name.'</a>';
|
||||
if ($record->count_attempts > 1) {
|
||||
$name .= " ($record->count_attempts)";
|
||||
}
|
||||
$names[] = $name;
|
||||
}
|
||||
$names[] = $name;
|
||||
}
|
||||
|
||||
}
|
||||
if (count($names) > 0) {
|
||||
print_headline(get_string('modulenameplural', 'hotpot').':');
|
||||
|
||||
if ($CFG->version >= 2005050500) { // Moodle 1.5+
|
||||
@ -931,7 +934,6 @@ function hotpot_print_recent_activity($course, $isteacher, $timestart) {
|
||||
} else { // Moodle 1.4.x (or less)
|
||||
echo '<font size="1">'.implode('<br />', $names).'</font>';
|
||||
}
|
||||
|
||||
$result = true;
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ function journal_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$content = true;
|
||||
print_headline(get_string('newjournalentries', 'journal').':');
|
||||
foreach ($journals as $journal) {
|
||||
print_recent_activity_note($journal->time, $journal, $isteacher, $journal->name,
|
||||
print_recent_activity_note($journal->time, $journal, $journal->name,
|
||||
$CFG->wwwroot.'/mod/journal/'.$journal->url);
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ function survey_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$content = true;
|
||||
print_headline(get_string('newsurveyresponses', 'survey').':');
|
||||
foreach ($surveys as $survey) {
|
||||
print_recent_activity_note($survey->time, $survey, $isteacher, $survey->name,
|
||||
print_recent_activity_note($survey->time, $survey, $survey->name,
|
||||
$CFG->wwwroot.'/mod/survey/'.$survey->url);
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ function wiki_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$content = true;
|
||||
print_headline(get_string('updatedwikipages', 'wiki').':', 3);
|
||||
foreach ($wikis as $wiki) {
|
||||
print_recent_activity_note($wiki->time, $wiki, $isteacher, $wiki->pagename,
|
||||
print_recent_activity_note($wiki->time, $wiki, $wiki->pagename,
|
||||
$CFG->wwwroot.'/mod/wiki/'.$wiki->url);
|
||||
}
|
||||
}
|
||||
|
@ -638,6 +638,10 @@ function workshop_is_recent_activity($course, $isteacher, $timestart) {//jlw1 ad
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NOTE: $isteacher usage should be converted to use roles.
|
||||
// TODO: Fix this function.
|
||||
//
|
||||
function workshop_print_recent_activity($course, $isteacher, $timestart) {
|
||||
global $CFG;
|
||||
|
||||
@ -669,7 +673,7 @@ function workshop_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$log->firstname = $course->student;
|
||||
$log->lastname = '';
|
||||
}
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/workshop/'.$log->url);
|
||||
}
|
||||
}
|
||||
@ -705,7 +709,7 @@ function workshop_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$log->firstname = $course->student;
|
||||
$log->lastname = '';
|
||||
}
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/workshop/'.$log->url);
|
||||
}
|
||||
}
|
||||
@ -738,7 +742,7 @@ function workshop_print_recent_activity($course, $isteacher, $timestart) {
|
||||
if (instance_is_visible("workshop",$tempmod)) {
|
||||
$log->firstname = $course->student; // Keep anonymous
|
||||
$log->lastname = '';
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/workshop/'.$log->url);
|
||||
}
|
||||
}
|
||||
@ -771,7 +775,7 @@ function workshop_print_recent_activity($course, $isteacher, $timestart) {
|
||||
if (instance_is_visible("workshop",$tempmod)) {
|
||||
$log->firstname = $course->teacher; // Keep anonymous
|
||||
$log->lastname = '';
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/workshop/'.$log->url);
|
||||
}
|
||||
}
|
||||
@ -802,7 +806,7 @@ function workshop_print_recent_activity($course, $isteacher, $timestart) {
|
||||
$tempmod->id = $log->workshopid;
|
||||
//Obtain the visible property from the instance
|
||||
if (instance_is_visible("workshop",$tempmod)) {
|
||||
print_recent_activity_note($log->time, $log, $isteacher, $log->name,
|
||||
print_recent_activity_note($log->time, $log, $log->name,
|
||||
$CFG->wwwroot.'/mod/workshop/'.$log->url);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user