mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +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
|
@ -1,6 +1,12 @@
|
|||
<?PHP // $Id$
|
||||
|
||||
/// CONSTANTS /////////////////////////////////////////////////////////////
|
||||
|
||||
define('SITEID', 1);
|
||||
|
||||
|
||||
/// FUNCTIONS FOR DATABASE HANDLING ////////////////////////////////
|
||||
|
||||
/**
|
||||
* execute a given sql command string
|
||||
*
|
||||
|
@ -947,9 +953,7 @@ function get_user_info_from_db($field, $value) {
|
|||
$user->admin = true;
|
||||
}
|
||||
|
||||
if ($site = get_site()) {
|
||||
$user->student[$site->id] = isstudent($site->id, $user->id);
|
||||
}
|
||||
$user->student[SITEID] = isstudent(SITEID, $user->id);
|
||||
|
||||
/// 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
|
||||
$select = "s.course = '$courseid' AND ";
|
||||
$site = get_site();
|
||||
if ($courseid == $site->id) {
|
||||
if ($courseid == SITEID) {
|
||||
$select = '';
|
||||
}
|
||||
|
||||
|
@ -1367,8 +1370,7 @@ function search_users($courseid, $groupid, $searchtext, $sort='', $exceptions=''
|
|||
$order = '';
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
if (!$courseid or $courseid == $site->id) {
|
||||
if (!$courseid or $courseid == SITEID) {
|
||||
if (!$admins = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$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
|
||||
}
|
||||
if (!$user and isset($USER->id)) {
|
||||
$site = get_site();
|
||||
if ($courseid == $site->id) {
|
||||
update_user_in_db();
|
||||
if ($courseid == SITEID) {
|
||||
$db->Execute("UPDATE {$CFG->prefix}user SET lastIP='$REMOTE_ADDR', lastaccess='$timenow'
|
||||
WHERE id = '$USER->id' ");
|
||||
} else if (isstudent($courseid)) {
|
||||
$db->Execute("UPDATE {$CFG->prefix}user_students SET timeaccess = '$timenow' ".
|
||||
"WHERE course = '$courseid' AND userid = '$userid'");
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
|
||||
global $CFG;
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Invalid site!");
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
|
|
|
@ -37,11 +37,7 @@
|
|||
|
||||
global $CFG;
|
||||
|
||||
if (! $site = get_site()) {
|
||||
error("Invalid site!");
|
||||
}
|
||||
|
||||
if ($course->id == $site->id) {
|
||||
if ($course->id == SITEID) {
|
||||
$strfiles = get_string("sitefiles");
|
||||
} else {
|
||||
$strfiles = get_string("files");
|
||||
|
@ -64,21 +60,21 @@
|
|||
|
||||
print_header();
|
||||
?>
|
||||
<script language="javscript" type="text/javascript">
|
||||
<!--
|
||||
function set_value(url) {
|
||||
var str_url = url;
|
||||
//if(document.all) {
|
||||
// window.returnValue = str_url;
|
||||
// window.close();
|
||||
//}
|
||||
//else {
|
||||
window.opener.document.forms[0].url.value = str_url;
|
||||
window.close();
|
||||
//}
|
||||
}
|
||||
<script language="javscript" type="text/javascript">
|
||||
<!--
|
||||
function set_value(url) {
|
||||
var str_url = url;
|
||||
//if(document.all) {
|
||||
// window.returnValue = str_url;
|
||||
// window.close();
|
||||
//}
|
||||
//else {
|
||||
window.opener.document.forms[0].url.value = str_url;
|
||||
window.close();
|
||||
//}
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
</script>
|
||||
<?php
|
||||
|
||||
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%">';
|
||||
|
@ -89,7 +85,7 @@
|
|||
echo '</tr>';
|
||||
echo '</table>';
|
||||
|
||||
if ($course->id == $site->id) {
|
||||
if ($course->id == SITEID) {
|
||||
print_heading(get_string("publicsitefileswarning"), "center", 2);
|
||||
}
|
||||
|
||||
|
@ -544,33 +540,33 @@
|
|||
break;
|
||||
|
||||
case "torte":
|
||||
if($_POST)
|
||||
{
|
||||
while(list($key, $val) = each($_POST))
|
||||
{
|
||||
if(ereg("file([0-9]+)", $key, $regs))
|
||||
{
|
||||
$file = $val;
|
||||
}
|
||||
}
|
||||
if(@filetype($CFG->dataroot ."/". $course->id . $file) == "file")
|
||||
{
|
||||
if(mimeinfo("icon", $file) == "image.gif")
|
||||
{
|
||||
$url = $CFG->wwwroot ."/file.php?file=/" .$course->id . $file;
|
||||
runjavascript($url);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File is not a image!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "You cannot insert FOLDER into richtext editor!!!";
|
||||
}
|
||||
}
|
||||
break;
|
||||
if($_POST)
|
||||
{
|
||||
while(list($key, $val) = each($_POST))
|
||||
{
|
||||
if(ereg("file([0-9]+)", $key, $regs))
|
||||
{
|
||||
$file = $val;
|
||||
}
|
||||
}
|
||||
if(@filetype($CFG->dataroot ."/". $course->id . $file) == "file")
|
||||
{
|
||||
if(mimeinfo("icon", $file) == "image.gif")
|
||||
{
|
||||
$url = $CFG->wwwroot ."/file.php?file=/" .$course->id . $file;
|
||||
runjavascript($url);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File is not a image!";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "You cannot insert FOLDER into richtext editor!!!";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "cancel";
|
||||
clearfilelist();
|
||||
|
||||
|
|
|
@ -383,8 +383,7 @@ function require_login($courseid=0, $autologinguest=true) {
|
|||
|
||||
// Check that the user account is properly set up
|
||||
if (user_not_fully_set_up($USER)) {
|
||||
$site = get_site();
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=$site->id");
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$USER->id&course=SITEID");
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -588,8 +587,7 @@ function isstudent($courseid, $userid=0) {
|
|||
return false;
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
if ($courseid == $site->id) {
|
||||
if ($courseid == SITEID) {
|
||||
if (!$userid) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
@ -968,9 +966,8 @@ function add_admin($userid) {
|
|||
$admin->userid = $userid;
|
||||
|
||||
// any admin is also a teacher on the site course
|
||||
$site = get_site();
|
||||
if (!record_exists('user_teachers', 'course', $site->id, 'userid', $userid)) {
|
||||
if (!add_teacher($userid, $site->id)) {
|
||||
if (!record_exists('user_teachers', 'course', SITEID, 'userid', $userid)) {
|
||||
if (!add_teacher($userid, SITEID)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -987,8 +984,7 @@ function remove_admin($userid) {
|
|||
global $db;
|
||||
|
||||
// remove also from the list of site teachers
|
||||
$site = get_site();
|
||||
remove_teacher($userid, $site->id);
|
||||
remove_teacher($userid, SITEID);
|
||||
|
||||
return delete_records("user_admins", "userid", $userid);
|
||||
}
|
||||
|
@ -1534,8 +1530,7 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml="", $a
|
|||
return true;
|
||||
} else {
|
||||
mtrace("ERROR: $mail->ErrorInfo");
|
||||
$site = get_site();
|
||||
add_to_log($site->id, "library", "mailer", $_SERVER["REQUEST_URI"], "ERROR: $mail->ErrorInfo");
|
||||
add_to_log(SITEID, "library", "mailer", $_SERVER["REQUEST_URI"], "ERROR: $mail->ErrorInfo");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue