mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
removed unnecessary calls to get_site()
This commit is contained in:
parent
afd97e8449
commit
222ac91bc9
26 changed files with 219 additions and 415 deletions
|
@ -1252,11 +1252,6 @@ function print_course($course, $width="100%") {
|
||||||
$enrol = new enrolment_plugin;
|
$enrol = new enrolment_plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
|
||||||
error("Could not find a site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
print_simple_box_start("center", "$width", $THEME->cellcontent, 5, "coursebox");
|
print_simple_box_start("center", "$width", $THEME->cellcontent, 5, "coursebox");
|
||||||
|
|
||||||
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
|
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
|
||||||
|
@ -1274,7 +1269,7 @@ function print_course($course, $width="100%") {
|
||||||
$teacher->role = $course->teacher;
|
$teacher->role = $course->teacher;
|
||||||
}
|
}
|
||||||
$fullname = fullname($teacher, isteacher($course->id)); // is the USER a teacher of that course
|
$fullname = fullname($teacher, isteacher($course->id)); // is the USER a teacher of that course
|
||||||
echo "$teacher->role: <a href=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=$site->id\">$fullname</a><br />";
|
echo "$teacher->role: <a href=\"$CFG->wwwroot/user/view.php?id=$teacher->id&course=".SITEID."\">$fullname</a><br />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "</font></p>";
|
echo "</font></p>";
|
||||||
|
|
|
@ -179,8 +179,7 @@
|
||||||
|
|
||||||
rebuild_course_cache($cm->course);
|
rebuild_course_cache($cm->course);
|
||||||
|
|
||||||
$site = get_site();
|
if (SITEID == $cm->course) {
|
||||||
if ($site->id == $cm->course) {
|
|
||||||
redirect($CFG->wwwroot);
|
redirect($CFG->wwwroot);
|
||||||
} else {
|
} else {
|
||||||
redirect("view.php?id=$cm->course");
|
redirect("view.php?id=$cm->course");
|
||||||
|
@ -224,8 +223,7 @@
|
||||||
|
|
||||||
rebuild_course_cache($section->course);
|
rebuild_course_cache($section->course);
|
||||||
|
|
||||||
$site = get_site();
|
if (SITEID == $section->course) {
|
||||||
if ($site->id == $section->course) {
|
|
||||||
redirect($CFG->wwwroot);
|
redirect($CFG->wwwroot);
|
||||||
} else {
|
} else {
|
||||||
redirect("view.php?id=$section->course");
|
redirect("view.php?id=$section->course");
|
||||||
|
@ -249,8 +247,7 @@
|
||||||
error("Could not update the indent level on that course module");
|
error("Could not update the indent level on that course module");
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = get_site();
|
if (SITEID == $cm->course) {
|
||||||
if ($site->id == $cm->course) {
|
|
||||||
redirect($CFG->wwwroot);
|
redirect($CFG->wwwroot);
|
||||||
} else {
|
} else {
|
||||||
redirect("view.php?id=$cm->course");
|
redirect("view.php?id=$cm->course");
|
||||||
|
@ -271,8 +268,7 @@
|
||||||
|
|
||||||
rebuild_course_cache($cm->course);
|
rebuild_course_cache($cm->course);
|
||||||
|
|
||||||
$site = get_site();
|
if (SITEID == $cm->course) {
|
||||||
if ($site->id == $cm->course) {
|
|
||||||
redirect($CFG->wwwroot);
|
redirect($CFG->wwwroot);
|
||||||
} else {
|
} else {
|
||||||
redirect("view.php?id=$cm->course");
|
redirect("view.php?id=$cm->course");
|
||||||
|
@ -297,14 +293,12 @@
|
||||||
error("This module doesn't exist");
|
error("This module doesn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = get_site();
|
if ($module->visible and ($section->visible or (SITEID == $cm->course))) {
|
||||||
|
|
||||||
if ($module->visible and ($section->visible or ($site->id == $cm->course))) {
|
|
||||||
show_course_module($cm->id);
|
show_course_module($cm->id);
|
||||||
rebuild_course_cache($cm->course);
|
rebuild_course_cache($cm->course);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($site->id == $cm->course) {
|
if (SITEID == $cm->course) {
|
||||||
redirect($CFG->wwwroot);
|
redirect($CFG->wwwroot);
|
||||||
} else {
|
} else {
|
||||||
redirect("view.php?id=$cm->course");
|
redirect("view.php?id=$cm->course");
|
||||||
|
@ -325,8 +319,7 @@
|
||||||
|
|
||||||
rebuild_course_cache($cm->course);
|
rebuild_course_cache($cm->course);
|
||||||
|
|
||||||
$site = get_site();
|
if (SITEID == $cm->course) {
|
||||||
if ($site->id == $cm->course) {
|
|
||||||
redirect($CFG->wwwroot);
|
redirect($CFG->wwwroot);
|
||||||
} else {
|
} else {
|
||||||
redirect("view.php?id=$cm->course");
|
redirect("view.php?id=$cm->course");
|
||||||
|
|
|
@ -34,11 +34,7 @@
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
if ($course->id == SITEID) {
|
||||||
error("Invalid site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
|
||||||
$strfiles = get_string("sitefiles");
|
$strfiles = get_string("sitefiles");
|
||||||
} else {
|
} else {
|
||||||
$strfiles = get_string("files");
|
$strfiles = get_string("files");
|
||||||
|
@ -59,7 +55,7 @@
|
||||||
$fullnav = "<a href=\"index.php?id=$course->id&wdir=/\">$strfiles</a> $navigation -> ".$dirs[$numdirs-1];
|
$fullnav = "<a href=\"index.php?id=$course->id&wdir=/\">$strfiles</a> $navigation -> ".$dirs[$numdirs-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
if ($course->id == SITEID) {
|
||||||
print_header("$course->shortname: $strfiles", "$course->fullname",
|
print_header("$course->shortname: $strfiles", "$course->fullname",
|
||||||
"<a href=\"../$CFG->admin/index.php\">".get_string("administration").
|
"<a href=\"../$CFG->admin/index.php\">".get_string("administration").
|
||||||
"</a> -> $fullnav", $formfield);
|
"</a> -> $fullnav", $formfield);
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (empty($courseid)) {
|
if (empty($courseid)) {
|
||||||
if ($site = get_site()) {
|
$courseid = SITEID;
|
||||||
$courseid = $site->id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$course = get_record("course","id",$courseid);
|
$course = get_record("course","id",$courseid);
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
<?PHP // $Id$
|
<?PHP // $Id$
|
||||||
|
|
||||||
|
/// CONSTANTS /////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
define('SITEID', 1);
|
||||||
|
|
||||||
|
|
||||||
/// FUNCTIONS FOR DATABASE HANDLING ////////////////////////////////
|
/// FUNCTIONS FOR DATABASE HANDLING ////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* execute a given sql command string
|
* execute a given sql command string
|
||||||
*
|
*
|
||||||
|
@ -947,9 +953,7 @@ function get_user_info_from_db($field, $value) {
|
||||||
$user->admin = true;
|
$user->admin = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($site = get_site()) {
|
$user->student[SITEID] = isstudent(SITEID, $user->id);
|
||||||
$user->student[$site->id] = isstudent($site->id, $user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Determine enrolments based on current enrolment module
|
/// Determine enrolments based on current enrolment module
|
||||||
|
|
||||||
|
@ -1173,8 +1177,7 @@ function get_course_students($courseid, $sort="s.timeaccess", $dir="", $page=0,
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$courseid' AND ";
|
$select = "s.course = '$courseid' AND ";
|
||||||
$site = get_site();
|
if ($courseid == SITEID) {
|
||||||
if ($courseid == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1367,8 +1370,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
|
||||||
$order = '';
|
$order = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = get_site();
|
if (!$courseid or $courseid == SITEID) {
|
||||||
if (!$courseid or $courseid == $site->id) {
|
|
||||||
if (!$admins = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
|
if (!$admins = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
|
||||||
FROM {$CFG->prefix}user u,
|
FROM {$CFG->prefix}user u,
|
||||||
{$CFG->prefix}user_admins s
|
{$CFG->prefix}user_admins s
|
||||||
|
@ -2279,9 +2281,9 @@ function add_to_log($courseid, $module, $action, $url="", $info="", $cm=0, $user
|
||||||
echo "<P>Error: Could not insert a new entry to the Moodle log</P>"; // Don't throw an error
|
echo "<P>Error: Could not insert a new entry to the Moodle log</P>"; // Don't throw an error
|
||||||
}
|
}
|
||||||
if (!$user and isset($USER->id)) {
|
if (!$user and isset($USER->id)) {
|
||||||
$site = get_site();
|
if ($courseid == SITEID) {
|
||||||
if ($courseid == $site->id) {
|
$db->Execute("UPDATE {$CFG->prefix}user SET lastIP='$REMOTE_ADDR', lastaccess='$timenow'
|
||||||
update_user_in_db();
|
WHERE id = '$USER->id' ");
|
||||||
} else if (isstudent($courseid)) {
|
} else if (isstudent($courseid)) {
|
||||||
$db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
|
$db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
|
||||||
"WHERE course = '$courseid' AND userid = '$userid'");
|
"WHERE course = '$courseid' AND userid = '$userid'");
|
||||||
|
|
|
@ -38,10 +38,6 @@
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
|
||||||
error("Invalid site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
|
|
@ -37,11 +37,7 @@
|
||||||
|
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
if ($course->id == SITEID) {
|
||||||
error("Invalid site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
|
||||||
$strfiles = get_string("sitefiles");
|
$strfiles = get_string("sitefiles");
|
||||||
} else {
|
} else {
|
||||||
$strfiles = get_string("files");
|
$strfiles = get_string("files");
|
||||||
|
@ -89,7 +85,7 @@
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
if ($course->id == SITEID) {
|
||||||
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,8 +383,7 @@ function require_login($courseid=0, $autologinguest=true) {
|
||||||
|
|
||||||
// Check that the user account is properly set up
|
// Check that the user account is properly set up
|
||||||
if (user_not_fully_set_up($USER)) {
|
if (user_not_fully_set_up($USER)) {
|
||||||
$site = get_site();
|
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=SITEID");
|
||||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
|
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -588,8 +587,7 @@ function isstudent($courseid, $userid=0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = get_site();
|
if ($courseid == SITEID) {
|
||||||
if ($courseid == $site->id) {
|
|
||||||
if (!$userid) {
|
if (!$userid) {
|
||||||
$userid = $USER->id;
|
$userid = $USER->id;
|
||||||
}
|
}
|
||||||
|
@ -968,9 +966,8 @@ function add_admin($userid) {
|
||||||
$admin->userid = $userid;
|
$admin->userid = $userid;
|
||||||
|
|
||||||
// any admin is also a teacher on the site course
|
// any admin is also a teacher on the site course
|
||||||
$site = get_site();
|
if (!record_exists('user_teachers', 'course', SITEID, 'userid', $userid)) {
|
||||||
if (!record_exists('user_teachers', 'course', $site->id, 'userid', $userid)) {
|
if (!add_teacher($userid, SITEID)) {
|
||||||
if (!add_teacher($userid, $site->id)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -987,8 +984,7 @@ function remove_admin($userid) {
|
||||||
global $db;
|
global $db;
|
||||||
|
|
||||||
// remove also from the list of site teachers
|
// remove also from the list of site teachers
|
||||||
$site = get_site();
|
remove_teacher($userid, SITEID);
|
||||||
remove_teacher($userid, $site->id);
|
|
||||||
|
|
||||||
return delete_records("user_admins", "userid", $userid);
|
return delete_records("user_admins", "userid", $userid);
|
||||||
}
|
}
|
||||||
|
@ -1534,8 +1530,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
mtrace("ERROR: $mail->ErrorInfo");
|
mtrace("ERROR: $mail->ErrorInfo");
|
||||||
$site = get_site();
|
add_to_log(SITEID, "library", "mailer", $_SERVER["REQUEST_URI"], "ERROR: $mail->ErrorInfo");
|
||||||
add_to_log($site->id, "library", "mailer", $_SERVER["REQUEST_URI"], "ERROR: $mail->ErrorInfo");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,7 @@
|
||||||
<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$fullname</A> -> $strpasswordchanged", $focus);
|
<A HREF=\"$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id\">$fullname</A> -> $strpasswordchanged", $focus);
|
||||||
notice($strpasswordchanged, "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id");
|
notice($strpasswordchanged, "$CFG->wwwroot/user/view.php?id=$USER->id&course=$id");
|
||||||
} else {
|
} else {
|
||||||
$site = get_site();
|
add_to_log(SITEID, "user", "change password", "view.php?id=$user->id&course=".SITEID, "$course->id");
|
||||||
add_to_log($site->id, "user", "change password", "view.php?id=$user->id&course=$site->id", "$course->id");
|
|
||||||
print_header($strpasswordchanged, $strpasswordchanged, $strpasswordchanged, "");
|
print_header($strpasswordchanged, $strpasswordchanged, $strpasswordchanged, "");
|
||||||
notice($strpasswordchanged, "$CFG->wwwroot/");
|
notice($strpasswordchanged, "$CFG->wwwroot/");
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,8 +74,7 @@
|
||||||
$SESSION->justloggedin = true;
|
$SESSION->justloggedin = true;
|
||||||
|
|
||||||
if (user_not_fully_set_up($USER)) {
|
if (user_not_fully_set_up($USER)) {
|
||||||
$site = get_site();
|
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=".SITEID);
|
||||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
|
|
||||||
|
|
||||||
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) { /// Matches site address
|
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) { /// Matches site address
|
||||||
redirect($wantsurl);
|
redirect($wantsurl);
|
||||||
|
|
|
@ -425,8 +425,7 @@ function assignment_count_real_submissions($assignment, $groupid=0) {
|
||||||
AND a.userid = g.userid ");
|
AND a.userid = g.userid ");
|
||||||
} else {
|
} else {
|
||||||
$select = "s.course = '$assignment->course' AND";
|
$select = "s.course = '$assignment->course' AND";
|
||||||
$site = get_site();
|
if ($assignment->course == SITEID) {
|
||||||
if ($assignment->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
return count_records_sql("SELECT COUNT(*)
|
return count_records_sql("SELECT COUNT(*)
|
||||||
|
@ -451,8 +450,7 @@ function assignment_get_all_submissions($assignment, $sort="", $dir="DESC") {
|
||||||
}
|
}
|
||||||
|
|
||||||
$select = "s.course = '$assignment->course' AND";
|
$select = "s.course = '$assignment->course' AND";
|
||||||
$site = get_site();
|
if ($assignment->course == SITEID) {
|
||||||
if ($assignment->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
return get_records_sql("SELECT a.*
|
return get_records_sql("SELECT a.*
|
||||||
|
@ -470,8 +468,7 @@ function assignment_get_users_done($assignment) {
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
$select = "s.course = '$assignment->course' AND";
|
$select = "s.course = '$assignment->course' AND";
|
||||||
$site = get_site();
|
if ($assignment->course == SITEID) {
|
||||||
if ($assignment->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
return get_records_sql("SELECT u.*
|
return get_records_sql("SELECT u.*
|
||||||
|
@ -497,8 +494,8 @@ function assignment_get_unmailed_submissions($cutofftime) {
|
||||||
AND s.assignment = a.id
|
AND s.assignment = a.id
|
||||||
AND s.userid = us.userid
|
AND s.userid = us.userid
|
||||||
AND a.course = us.course");
|
AND a.course = us.course");
|
||||||
$site = get_site();
|
$siteid = SITEID;
|
||||||
if (record_exists('assignment', 'course', $site->id)) {
|
if (record_exists('assignment', 'course', $siteid)) {
|
||||||
$records += get_records_sql("SELECT s.*, a.course, a.name
|
$records += get_records_sql("SELECT s.*, a.course, a.name
|
||||||
FROM {$CFG->prefix}assignment_submissions s,
|
FROM {$CFG->prefix}assignment_submissions s,
|
||||||
{$CFG->prefix}assignment a,
|
{$CFG->prefix}assignment a,
|
||||||
|
@ -508,7 +505,7 @@ function assignment_get_unmailed_submissions($cutofftime) {
|
||||||
AND s.timemarked > 0
|
AND s.timemarked > 0
|
||||||
AND s.assignment = a.id
|
AND s.assignment = a.id
|
||||||
AND s.userid = us.userid
|
AND s.userid = us.userid
|
||||||
AND a.course = $site->id");
|
AND a.course = $siteid");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,8 +387,7 @@ function attendance_get_course_students($courseid, $sort="u.lastaccess DESC") {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$courseid' AND";
|
$select = "s.course = '$courseid' AND";
|
||||||
$site = get_site();
|
if ($courseid == SITEID) {
|
||||||
if ($courseid == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat,
|
return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat,
|
||||||
|
|
|
@ -235,8 +235,7 @@ function dialogue_get_users_done($dialogue) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$dialogue->course' AND";
|
$select = "s.course = '$dialogue->course' AND";
|
||||||
$site = get_site();
|
if ($courseid == SITEID) {
|
||||||
if ($courseid == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
if (!$students = get_records_sql("SELECT u.*
|
if (!$students = get_records_sql("SELECT u.*
|
||||||
|
|
|
@ -239,8 +239,7 @@ function exercise_count_student_submissions($exercise) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,8 +488,7 @@ function exercise_get_best_submission_grades($exercise) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,8 +541,7 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid =
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,8 +567,7 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid =
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -591,8 +587,7 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid =
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,8 +610,7 @@ function exercise_get_student_submissions($exercise, $order = "time", $groupid =
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -670,8 +664,7 @@ function exercise_get_ungraded_assessments_student($exercise) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$exercise->course' AND";
|
$select = "u.course = '$exercise->course' AND";
|
||||||
$site = get_site();
|
if ($exercise->course == SITEID) {
|
||||||
if ($exercise->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (empty($courseid)) {
|
if (empty($courseid)) {
|
||||||
if ($site = get_site()) {
|
$courseid = SITEID;
|
||||||
$courseid = $site->id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOSSARY_CONCEPT_IS_ENTRY = 0;
|
$GLOSSARY_CONCEPT_IS_ENTRY = 0;
|
||||||
|
|
|
@ -316,8 +316,7 @@ function journal_get_users_done($journal) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$journal->course' AND";
|
$select = "s.course = '$journal->course' AND";
|
||||||
$site = get_site();
|
if ($journal->course == SITEID) {
|
||||||
if ($journal->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,8 +368,7 @@ function journal_count_entries($journal, $groupid=0) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$journal->course' AND";
|
$select = "s.course = '$journal->course' AND";
|
||||||
$site = get_site();
|
if ($journal->course == SITEID) {
|
||||||
if ($journal->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,7 @@
|
||||||
|
|
||||||
global $CFG,$THEME;
|
global $CFG,$THEME;
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
if ($course->id == SITEID) {
|
||||||
error("Invalid site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
|
||||||
$strfiles = get_string("sitefiles");
|
$strfiles = get_string("sitefiles");
|
||||||
} else {
|
} else {
|
||||||
$strfiles = get_string("files");
|
$strfiles = get_string("files");
|
||||||
|
@ -82,7 +78,7 @@
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
if ($course->id == SITEID) {
|
||||||
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,7 @@
|
||||||
global $CFG;
|
global $CFG;
|
||||||
|
|
||||||
if (empty($courseid)) {
|
if (empty($courseid)) {
|
||||||
if ($site = get_site()) {
|
$courseid = SITEID;
|
||||||
$courseid = $site->id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($CFG->dbtype) {
|
switch ($CFG->dbtype) {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
$module->version = 2004080801;
|
$module->version = 2004080801;
|
||||||
$module->requires = 2004073000; // Requires this Moodle version
|
$module->requires = 2004092901; // Requires this Moodle version
|
||||||
$module->cron = 0;
|
$module->cron = 0;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -37,11 +37,7 @@
|
||||||
|
|
||||||
global $CFG,$THEME,$ME;
|
global $CFG,$THEME,$ME;
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
if ($course->id == SITEID) {
|
||||||
error("Invalid site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
|
||||||
$strfiles = get_string("sitefiles");
|
$strfiles = get_string("sitefiles");
|
||||||
} else {
|
} else {
|
||||||
$strfiles = get_string("files");
|
$strfiles = get_string("files");
|
||||||
|
@ -82,7 +78,7 @@
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
if ($course->id == SITEID) {
|
||||||
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,126 +1 @@
|
||||||
<?PHP // $Id$
|
<?PHP // $Id$
//This function provides automatic linking to
//wiki pages when its page title is found inside every Moodle text
//It's based in the glosssary filter by Williams Castillo
//Modifications by mchurch. Enjoy! :-)
require_once($CFG->dirroot.'/mod/wiki/lib.php');
function wiki_filter($courseid, $text) {
global $CFG;
if (empty($courseid)) {
$courseid = SITEID;
}
}
if (!($course = get_record('course', 'id', $courseid))) {
return $text;
}
// Get all wikis for this course.
$wikis = wiki_get_course_wikis($courseid);
if (empty($wikis)) {
return $text;
}
// Walk through each wiki, and get entries.
foreach ($wikis as $wiki) {
if ($wiki_entries = wiki_get_entries($wiki)) {
// Walk through each entry and get the pages.
foreach ($wiki_entries as $wiki_entry) {
if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id)) {
// Walk through each page and filter.
foreach ($wiki_pages as $wiki_page) {
$startlink = '<a class="autolink" title="Wiki" href="'
.$CFG->wwwroot.'/mod/wiki/view.php?wid='.$wiki->id
.'&userid='.$wiki_entry->userid
.'&groupid='.$wiki_entry->groupid
.'&wikipage='.$wiki_page->pagename.'">';
$text = wiki_link_names($text, $wiki_page->pagename, $startlink, '</a>');
}
}
}
}
}
return $text;
}
function wiki_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>") {
$list_of_words_cp = strip_tags($name);
$list_of_words_cp = trim($list_of_words_cp,'|');
$list_of_words_cp = trim($list_of_words_cp);
$list_of_words_cp = preg_quote($list_of_words_cp,'/');
$invalidprefixs = "([a-zA-Z0-9])";
$invalidsufixs = "([a-zA-Z0-9])";
//Avoid seaching in the string if it's inside invalidprefixs and invalidsufixs
$words = array();
$regexp = '/'.$invalidprefixs.'('.$list_of_words_cp.')|('.$list_of_words_cp.')'.$invalidsufixs.'/is';
preg_match_all($regexp,$text,$list_of_words);
foreach (array_unique($list_of_words[0]) as $key=>$value) {
$words['<*'.$key.'*>'] = $value;
}
if (!empty($words)) {
$text = str_replace($words,array_keys($words),$text);
}
//Now avoid searching inside the <nolink>tag
$excludes = array();
preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);
foreach (array_unique($list_of_excludes[0]) as $key=>$value) {
$excludes['<+'.$key.'+>'] = $value;
}
if (!empty($excludes)) {
$text = str_replace($excludes,array_keys($excludes),$text);
}
//Now avoid searching inside links
$links = array();
preg_match_all('/<A[\s](.+?)>(.+?)<\/A>/is',$text,$list_of_links);
foreach (array_unique($list_of_links[0]) as $key=>$value) {
$links['<@'.$key.'@>'] = $value;
}
if (!empty($links)) {
$text = str_replace($links,array_keys($links),$text);
}
//Now avoid searching inside every tag
$final = array();
preg_match_all('/<(.+?)>/is',$text,$list_of_tags);
foreach (array_unique($list_of_tags[0]) as $key=>$value) {
$final['<|'.$key.'|>'] = $value;
}
if (!empty($final)) {
$text = str_replace($final,array_keys($final),$text);
}
$text = preg_replace('/('.$list_of_words_cp.')/is', $href_tag_begin.'$1'.$href_tag_end,$text);
//Now rebuild excluded areas
if (!empty($final)) {
$text = str_replace(array_keys($final),$final,$text);
}
if (!empty($links)) {
$text = str_replace(array_keys($links),$links,$text);
}
if (!empty($excludes)) {
$text = str_replace(array_keys($excludes),$excludes,$text);
}
if (!empty($words)) {
$text = str_replace(array_keys($words),$words,$text);
}
return $text;
}
?>
|
||||||
//This function provides automatic linking to
|
|
||||||
//wiki pages when its page title is found inside every Moodle text
|
|
||||||
//It's based in the glosssary filter by Williams Castillo
|
|
||||||
//Modifications by mchurch. Enjoy! :-)
|
|
||||||
|
|
||||||
require_once($CFG->dirroot.'/mod/wiki/lib.php');
|
|
||||||
|
|
||||||
function wiki_filter($courseid, $text) {
|
|
||||||
|
|
||||||
global $CFG;
|
|
||||||
|
|
||||||
if (empty($courseid)) {
|
|
||||||
if ($site = get_site()) {
|
|
||||||
$courseid = $site->id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($course = get_record('course', 'id', $courseid))) {
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get all wikis for this course.
|
|
||||||
$wikis = wiki_get_course_wikis($courseid);
|
|
||||||
if (empty($wikis)) {
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Walk through each wiki, and get entries.
|
|
||||||
foreach ($wikis as $wiki) {
|
|
||||||
if ($wiki_entries = wiki_get_entries($wiki)) {
|
|
||||||
|
|
||||||
// Walk through each entry and get the pages.
|
|
||||||
foreach ($wiki_entries as $wiki_entry) {
|
|
||||||
if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id)) {
|
|
||||||
|
|
||||||
// Walk through each page and filter.
|
|
||||||
foreach ($wiki_pages as $wiki_page) {
|
|
||||||
$startlink = '<a class="autolink" title="Wiki" href="'
|
|
||||||
.$CFG->wwwroot.'/mod/wiki/view.php?wid='.$wiki->id
|
|
||||||
.'&userid='.$wiki_entry->userid
|
|
||||||
.'&groupid='.$wiki_entry->groupid
|
|
||||||
.'&wikipage='.$wiki_page->pagename.'">';
|
|
||||||
$text = wiki_link_names($text, $wiki_page->pagename, $startlink, '</a>');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
|
|
||||||
function wiki_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>") {
|
|
||||||
|
|
||||||
$list_of_words_cp = strip_tags($name);
|
|
||||||
|
|
||||||
$list_of_words_cp = trim($list_of_words_cp,'|');
|
|
||||||
|
|
||||||
$list_of_words_cp = trim($list_of_words_cp);
|
|
||||||
|
|
||||||
$list_of_words_cp = preg_quote($list_of_words_cp,'/');
|
|
||||||
|
|
||||||
$invalidprefixs = "([a-zA-Z0-9])";
|
|
||||||
$invalidsufixs = "([a-zA-Z0-9])";
|
|
||||||
|
|
||||||
//Avoid seaching in the string if it's inside invalidprefixs and invalidsufixs
|
|
||||||
$words = array();
|
|
||||||
$regexp = '/'.$invalidprefixs.'('.$list_of_words_cp.')|('.$list_of_words_cp.')'.$invalidsufixs.'/is';
|
|
||||||
preg_match_all($regexp,$text,$list_of_words);
|
|
||||||
|
|
||||||
foreach (array_unique($list_of_words[0]) as $key=>$value) {
|
|
||||||
$words['<*'.$key.'*>'] = $value;
|
|
||||||
}
|
|
||||||
if (!empty($words)) {
|
|
||||||
$text = str_replace($words,array_keys($words),$text);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Now avoid searching inside the <nolink>tag
|
|
||||||
$excludes = array();
|
|
||||||
preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);
|
|
||||||
foreach (array_unique($list_of_excludes[0]) as $key=>$value) {
|
|
||||||
$excludes['<+'.$key.'+>'] = $value;
|
|
||||||
}
|
|
||||||
if (!empty($excludes)) {
|
|
||||||
$text = str_replace($excludes,array_keys($excludes),$text);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Now avoid searching inside links
|
|
||||||
$links = array();
|
|
||||||
preg_match_all('/<A[\s](.+?)>(.+?)<\/A>/is',$text,$list_of_links);
|
|
||||||
foreach (array_unique($list_of_links[0]) as $key=>$value) {
|
|
||||||
$links['<@'.$key.'@>'] = $value;
|
|
||||||
}
|
|
||||||
if (!empty($links)) {
|
|
||||||
$text = str_replace($links,array_keys($links),$text);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Now avoid searching inside every tag
|
|
||||||
$final = array();
|
|
||||||
preg_match_all('/<(.+?)>/is',$text,$list_of_tags);
|
|
||||||
foreach (array_unique($list_of_tags[0]) as $key=>$value) {
|
|
||||||
$final['<|'.$key.'|>'] = $value;
|
|
||||||
}
|
|
||||||
if (!empty($final)) {
|
|
||||||
$text = str_replace($final,array_keys($final),$text);
|
|
||||||
}
|
|
||||||
|
|
||||||
$text = preg_replace('/('.$list_of_words_cp.')/is', $href_tag_begin.'$1'.$href_tag_end,$text);
|
|
||||||
|
|
||||||
//Now rebuild excluded areas
|
|
||||||
if (!empty($final)) {
|
|
||||||
$text = str_replace(array_keys($final),$final,$text);
|
|
||||||
}
|
|
||||||
if (!empty($links)) {
|
|
||||||
$text = str_replace(array_keys($links),$links,$text);
|
|
||||||
}
|
|
||||||
if (!empty($excludes)) {
|
|
||||||
$text = str_replace(array_keys($excludes),$excludes,$text);
|
|
||||||
}
|
|
||||||
if (!empty($words)) {
|
|
||||||
$text = str_replace(array_keys($words),$words,$text);
|
|
||||||
}
|
|
||||||
return $text;
|
|
||||||
}
|
|
||||||
?>
|
|
|
@ -407,18 +407,17 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||||
$mygroupid = mygroupid($course->id);
|
$mygroupid = mygroupid($course->id);
|
||||||
$isteacher = isteacher($course->id, $user->id);
|
$isteacher = isteacher($course->id, $user->id);
|
||||||
$isteacheredit = isteacheredit($course->id, $user->id);
|
$isteacheredit = isteacheredit($course->id, $user->id);
|
||||||
$site = get_site();
|
|
||||||
|
|
||||||
switch ($wiki->wtype) {
|
switch ($wiki->wtype) {
|
||||||
|
|
||||||
case 'student':
|
case 'student':
|
||||||
/// Get all the existing entries for this wiki.
|
/// Get all the existing entries for this wiki.
|
||||||
$wiki_entries = wiki_get_entries($wiki, 'student');
|
$wiki_entries = wiki_get_entries($wiki, 'student');
|
||||||
if ($isteacher and ($site->id != $course->id)) {
|
if ($isteacher and (SITEID != $course->id)) {
|
||||||
|
|
||||||
/// If the user is an editing teacher, or a non-editing teacher not assigned to a group, show all student
|
/// If the user is an editing teacher, or a non-editing teacher not assigned to a group, show all student
|
||||||
/// wikis, regardless of creation.
|
/// wikis, regardless of creation.
|
||||||
if (($site->id != $course->id) and ($isteacheredit or ($groupmode == NOGROUPS))) {
|
if ((SITEID != $course->id) and ($isteacheredit or ($groupmode == NOGROUPS))) {
|
||||||
|
|
||||||
if ($students = get_course_students($course->id)) {
|
if ($students = get_course_students($course->id)) {
|
||||||
/// Default pagename is dependent on the wiki settings.
|
/// Default pagename is dependent on the wiki settings.
|
||||||
|
@ -494,7 +493,7 @@ function wiki_get_other_wikis(&$wiki, &$user, &$course, $currentid=0) {
|
||||||
/// group (for separate groups) or there are visible groups, or if this is
|
/// group (for separate groups) or there are visible groups, or if this is
|
||||||
/// a site-level wiki, and they are an administrator.
|
/// a site-level wiki, and they are an administrator.
|
||||||
if (($groupmode == VISIBLEGROUPS) or
|
if (($groupmode == VISIBLEGROUPS) or
|
||||||
(($site->id == $course->id) and isadmin())) {
|
((SITEID == $course->id) and isadmin())) {
|
||||||
$viewall = true;
|
$viewall = true;
|
||||||
}
|
}
|
||||||
else if ($groupmode == SEPARATEGROUPS) {
|
else if ($groupmode == SEPARATEGROUPS) {
|
||||||
|
@ -706,7 +705,6 @@ function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
|
||||||
/// Get the groupmode. It's been added to the wiki object.
|
/// Get the groupmode. It's been added to the wiki object.
|
||||||
$groupmode = groupmode($course, $wiki);
|
$groupmode = groupmode($course, $wiki);
|
||||||
$mygroupid = mygroupid($course->id);
|
$mygroupid = mygroupid($course->id);
|
||||||
$site = get_site();
|
|
||||||
|
|
||||||
switch ($wiki->wtype) {
|
switch ($wiki->wtype) {
|
||||||
|
|
||||||
|
@ -715,7 +713,7 @@ function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
|
||||||
/// A user can create their own wiki at the site level.
|
/// A user can create their own wiki at the site level.
|
||||||
if ($userid == 0) {
|
if ($userid == 0) {
|
||||||
return (isstudent($course->id, $user->id) or
|
return (isstudent($course->id, $user->id) or
|
||||||
(($site->id == $course->id) and !empty($user) and !isguest()));
|
((SITEID == $course->id) and !empty($user) and !isguest()));
|
||||||
}
|
}
|
||||||
/// An editing teacher can create any student wiki, or
|
/// An editing teacher can create any student wiki, or
|
||||||
/// a non-editing teacher, if not assigned to a group can create any student wiki, or if assigned to a group can
|
/// a non-editing teacher, if not assigned to a group can create any student wiki, or if assigned to a group can
|
||||||
|
@ -730,7 +728,7 @@ function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
|
||||||
/// If mode is 'nogroups', then all participants can add wikis.
|
/// If mode is 'nogroups', then all participants can add wikis.
|
||||||
if (!$groupmode) {
|
if (!$groupmode) {
|
||||||
return (isstudent($course->id, $user->id) or isteacher($course->id, $user->id) or
|
return (isstudent($course->id, $user->id) or isteacher($course->id, $user->id) or
|
||||||
(($site->id == $course->id) and !empty($user) and !isguest()));
|
((SITEID == $course->id) and !empty($user) and !isguest()));
|
||||||
}
|
}
|
||||||
/// If not requesting a group, must be a member of a group.
|
/// If not requesting a group, must be a member of a group.
|
||||||
else if ($groupid == 0) {
|
else if ($groupid == 0) {
|
||||||
|
@ -747,7 +745,7 @@ function wiki_can_add_entry(&$wiki, &$user, &$course, $userid=0, $groupid=0) {
|
||||||
case 'teacher':
|
case 'teacher':
|
||||||
/// If mode is 'nogroups', then all teachers can add wikis.
|
/// If mode is 'nogroups', then all teachers can add wikis.
|
||||||
if (!$groupmode) {
|
if (!$groupmode) {
|
||||||
return (isteacher($course->id, $user->id) or (($site->id == $course->id) and isadmin()));
|
return (isteacher($course->id, $user->id) or ((SITEID == $course->id) and isadmin()));
|
||||||
}
|
}
|
||||||
/// If not requesting a group, must be a member of a group.
|
/// If not requesting a group, must be a member of a group.
|
||||||
else if ($groupid == 0) {
|
else if ($groupid == 0) {
|
||||||
|
@ -771,7 +769,6 @@ function wiki_can_edit_entry(&$wiki_entry, &$wiki, &$user, &$course) {
|
||||||
$can_edit = false;
|
$can_edit = false;
|
||||||
$groupmode = groupmode($course, $wiki);
|
$groupmode = groupmode($course, $wiki);
|
||||||
$mygroupid = mygroupid($course->id);
|
$mygroupid = mygroupid($course->id);
|
||||||
$site = get_site();
|
|
||||||
|
|
||||||
/// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups,
|
/// Editing teacher's and admins can edit all wikis, non-editing teachers can edit wikis in their groups,
|
||||||
/// or all wikis if group mode is 'no groups' or they don't belong to a group.
|
/// or all wikis if group mode is 'no groups' or they don't belong to a group.
|
||||||
|
@ -798,7 +795,7 @@ function wiki_can_edit_entry(&$wiki_entry, &$wiki, &$user, &$course) {
|
||||||
/// If mode is 'nogroups', then all participants can edit the wiki.
|
/// If mode is 'nogroups', then all participants can edit the wiki.
|
||||||
else {
|
else {
|
||||||
$can_edit = (isstudent($course->id, $user->id) or isteacher($course->id, $user->id) or
|
$can_edit = (isstudent($course->id, $user->id) or isteacher($course->id, $user->id) or
|
||||||
(($site->id == $course->id) and !empty($user) and !isguest()));
|
((SITEID == $course->id) and !empty($user) and !isguest()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -809,7 +806,7 @@ function wiki_can_edit_entry(&$wiki_entry, &$wiki, &$user, &$course) {
|
||||||
$can_edit = (isteacher($course->id, $user->id) and ismember($wiki_entry->groupid, $user->id));
|
$can_edit = (isteacher($course->id, $user->id) and ismember($wiki_entry->groupid, $user->id));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$can_edit = (isteacher($course->id, $user->id) or (($site->id == $course->id) and isadmin()));
|
$can_edit = (isteacher($course->id, $user->id) or ((SITEID == $course->id) and isadmin()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,7 @@
|
||||||
|
|
||||||
global $CFG, $THEME, $ME;
|
global $CFG, $THEME, $ME;
|
||||||
|
|
||||||
if (! $site = get_site()) {
|
if ($course->id == SITEID) {
|
||||||
error("Invalid site!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
|
||||||
$strfiles = get_string("sitefiles");
|
$strfiles = get_string("sitefiles");
|
||||||
} else {
|
} else {
|
||||||
$strfiles = get_string("files");
|
$strfiles = get_string("files");
|
||||||
|
@ -82,7 +78,7 @@
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
|
||||||
if ($course->id == $site->id) {
|
if ($course->id == SITEID) {
|
||||||
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1205,8 +1205,7 @@ function workshop_get_student_submissions($workshop, $order = "title") {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$workshop->course' AND";
|
$select = "u.course = '$workshop->course' AND";
|
||||||
$site = get_site();
|
if ($workshop->course == SITEID) {
|
||||||
if ($workshop->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,8 +250,7 @@ function workshop_count_student_submissions($workshop) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$workshop->course' AND";
|
$select = "s.course = '$workshop->course' AND";
|
||||||
$site = get_site();
|
if ($workshop->course == SITEID) {
|
||||||
if ($workshop->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,8 +514,7 @@ function workshop_get_student_assessments($workshop, $user) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$workshop->course' AND";
|
$select = "u.course = '$workshop->course' AND";
|
||||||
$site = get_site();
|
if ($workshop->course == SITEID) {
|
||||||
if ($workshop->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,8 +536,7 @@ function workshop_get_student_submission_assessments($workshop) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$workshop->course' AND";
|
$select = "u.course = '$workshop->course' AND";
|
||||||
$site = get_site();
|
if ($workshop->course == SITEID) {
|
||||||
if ($workshop->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,8 +605,7 @@ function workshop_get_ungraded_assessments_student($workshop) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "u.course = '$workshop->course' AND";
|
$select = "u.course = '$workshop->course' AND";
|
||||||
$site = get_site();
|
if ($workshop->course == SITEID) {
|
||||||
if ($workshop->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -668,8 +664,7 @@ function workshop_get_users_done($workshop) {
|
||||||
|
|
||||||
// make sure it works on the site course
|
// make sure it works on the site course
|
||||||
$select = "s.course = '$workshop->course' AND";
|
$select = "s.course = '$workshop->course' AND";
|
||||||
$site = get_site();
|
if ($workshop->course == SITEID) {
|
||||||
if ($workshop->course == $site->id) {
|
|
||||||
$select = '';
|
$select = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,7 @@
|
||||||
$guest = get_guest();
|
$guest = get_guest();
|
||||||
$exceptions .= $guest->id;
|
$exceptions .= $guest->id;
|
||||||
|
|
||||||
$site = get_site();
|
if ($course->id == SITEID) { // Show all site users (even unconfirmed)
|
||||||
if ($course->id == $site->id) { // Show all site users (even unconfirmed)
|
|
||||||
$students = get_users(true, '', true, $exceptions, $sort.' '.$dir, $firstinitial, $lastinitial, $page*$perpage, $perpage);
|
$students = get_users(true, '', true, $exceptions, $sort.' '.$dir, $firstinitial, $lastinitial, $page*$perpage, $perpage);
|
||||||
$totalcount = get_users(false, '', true, '', '', '', '') - 1; // -1 to not count guest user
|
$totalcount = get_users(false, '', true, '', '', '', '') - 1; // -1 to not count guest user
|
||||||
if ($firstinitial or $lastinitial) {
|
if ($firstinitial or $lastinitial) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue