$enrol = new enrolment_plugin;
}
- if (! $site = get_site()) {
- error("Could not find a site!");
- }
-
-
print_simple_box_start("center", "$width", $THEME->cellcontent, 5, "coursebox");
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
$teacher->role = $course->teacher;
}
$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>";
rebuild_course_cache($cm->course);
- $site = get_site();
- if ($site->id == $cm->course) {
+ if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id=$cm->course");
rebuild_course_cache($section->course);
- $site = get_site();
- if ($site->id == $section->course) {
+ if (SITEID == $section->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id=$section->course");
error("Could not update the indent level on that course module");
}
- $site = get_site();
- if ($site->id == $cm->course) {
+ if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id=$cm->course");
rebuild_course_cache($cm->course);
- $site = get_site();
- if ($site->id == $cm->course) {
+ if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id=$cm->course");
error("This module doesn't exist");
}
- $site = get_site();
-
- if ($module->visible and ($section->visible or ($site->id == $cm->course))) {
+ if ($module->visible and ($section->visible or (SITEID == $cm->course))) {
show_course_module($cm->id);
rebuild_course_cache($cm->course);
}
- if ($site->id == $cm->course) {
+ if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id=$cm->course");
rebuild_course_cache($cm->course);
- $site = get_site();
- if ($site->id == $cm->course) {
+ if (SITEID == $cm->course) {
redirect($CFG->wwwroot);
} else {
redirect("view.php?id=$cm->course");
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");
$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",
"<a href=\"../$CFG->admin/index.php\">".get_string("administration").
"</a> -> $fullnav", $formfield);
global $CFG;
if (empty($courseid)) {
- if ($site = get_site()) {
- $courseid = $site->id;
- }
+ $courseid = SITEID;
}
$course = get_record("course","id",$courseid);
<?PHP // $Id$
+/// CONSTANTS /////////////////////////////////////////////////////////////
+
+define('SITEID', 1);
+
+
/// FUNCTIONS FOR DATABASE HANDLING ////////////////////////////////
+
/**
* execute a given sql command string
*
$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
// make sure it works on the site course
$select = "s.course = '$courseid' AND ";
- $site = get_site();
- if ($courseid == $site->id) {
+ if ($courseid == SITEID) {
$select = '';
}
$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
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'");
global $CFG;
- if (! $site = get_site()) {
- error("Invalid site!");
- }
-
?>
<html>
<head>
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");
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%">';
echo '</tr>';
echo '</table>';
- if ($course->id == $site->id) {
+ if ($course->id == SITEID) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
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();
// 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;
}
return false;
}
- $site = get_site();
- if ($courseid == $site->id) {
+ if ($courseid == SITEID) {
if (!$userid) {
$userid = $USER->id;
}
$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;
}
}
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);
}
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;
}
}
<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");
} else {
- $site = get_site();
- add_to_log($site->id, "user", "change password", "view.php?id=$user->id&course=$site->id", "$course->id");
+ add_to_log(SITEID, "user", "change password", "view.php?id=$user->id&course=".SITEID, "$course->id");
print_header($strpasswordchanged, $strpasswordchanged, $strpasswordchanged, "");
notice($strpasswordchanged, "$CFG->wwwroot/");
}
$SESSION->justloggedin = true;
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);
} else if (strpos($wantsurl, $CFG->wwwroot) === 0) { /// Matches site address
redirect($wantsurl);
AND a.userid = g.userid ");
} else {
$select = "s.course = '$assignment->course' AND";
- $site = get_site();
- if ($assignment->course == $site->id) {
+ if ($assignment->course == SITEID) {
$select = '';
}
return count_records_sql("SELECT COUNT(*)
}
$select = "s.course = '$assignment->course' AND";
- $site = get_site();
- if ($assignment->course == $site->id) {
+ if ($assignment->course == SITEID) {
$select = '';
}
return get_records_sql("SELECT a.*
global $CFG;
$select = "s.course = '$assignment->course' AND";
- $site = get_site();
- if ($assignment->course == $site->id) {
+ if ($assignment->course == SITEID) {
$select = '';
}
return get_records_sql("SELECT u.*
AND s.assignment = a.id
AND s.userid = us.userid
AND a.course = us.course");
- $site = get_site();
- if (record_exists('assignment', 'course', $site->id)) {
+ $siteid = SITEID;
+ if (record_exists('assignment', 'course', $siteid)) {
$records += get_records_sql("SELECT s.*, a.course, a.name
FROM {$CFG->prefix}assignment_submissions s,
{$CFG->prefix}assignment a,
AND s.timemarked > 0
AND s.assignment = a.id
AND s.userid = us.userid
- AND a.course = $site->id");
+ AND a.course = $siteid");
}
}
// make sure it works on the site course
$select = "s.course = '$courseid' AND";
- $site = get_site();
- if ($courseid == $site->id) {
+ if ($courseid == SITEID) {
$select = '';
}
return get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.maildisplay, u.mailformat,
// make sure it works on the site course
$select = "s.course = '$dialogue->course' AND";
- $site = get_site();
- if ($courseid == $site->id) {
+ if ($courseid == SITEID) {
$select = '';
}
if (!$students = get_records_sql("SELECT u.*
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$exercise->course' AND";
- $site = get_site();
- if ($exercise->course == $site->id) {
+ if ($exercise->course == SITEID) {
$select = '';
}
global $CFG;
if (empty($courseid)) {
- if ($site = get_site()) {
- $courseid = $site->id;
- }
+ $courseid = SITEID;
}
$GLOSSARY_CONCEPT_IS_ENTRY = 0;
// make sure it works on the site course
$select = "s.course = '$journal->course' AND";
- $site = get_site();
- if ($journal->course == $site->id) {
+ if ($journal->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "s.course = '$journal->course' AND";
- $site = get_site();
- if ($journal->course == $site->id) {
+ if ($journal->course == SITEID) {
$select = '';
}
global $CFG,$THEME;
- 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");
print_header();
?>
- <script language="javascript" type="text/javascript">
- <!--
- function set_value(txt) {
- opener.document.forms['form'].reference.value = txt;
- window.close();
- }
+ <script language="javascript" type="text/javascript">
+ <!--
+ function set_value(txt) {
+ opener.document.forms['form'].reference.value = txt;
+ window.close();
+ }
-->
- </script>
+ </script>
<?php
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%">';
echo '</tr>';
echo '</table>';
- if ($course->id == $site->id) {
+ if ($course->id == SITEID) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
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();
global $CFG;
if (empty($courseid)) {
- if ($site = get_site()) {
- $courseid = $site->id;
- }
+ $courseid = SITEID;
}
switch ($CFG->dbtype) {
////////////////////////////////////////////////////////////////////////////////
$module->version = 2004080801;
-$module->requires = 2004073000; // Requires this Moodle version
+$module->requires = 2004092901; // Requires this Moodle version
$module->cron = 0;
?>
global $CFG,$THEME,$ME;
- 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");
print_header();
?>
- <script language="javascript" type="text/javascript">
- <!--
- function set_value(txt) {
- opener.document.forms['form'].reference.value = txt;
- window.close();
- }
+ <script language="javascript" type="text/javascript">
+ <!--
+ function set_value(txt) {
+ opener.document.forms['form'].reference.value = txt;
+ window.close();
+ }
-->
- </script>
+ </script>
<?php
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%">';
echo '</tr>';
echo '</table>';
- if ($course->id == $site->id) {
+ if ($course->id == SITEID) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
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();
$dirlist[] = $file;
} else {
if ((basename(strtolower($file),".zip") != basename(strtolower($file))) || (basename(strtolower($file),".pif") != basename(strtolower($file))))
- $filelist[] = $file;
+ $filelist[] = $file;
}
}
closedir($directory);
-<?PHP // $Id$\r
- //This function provides automatic linking to\r
- //wiki pages when its page title is found inside every Moodle text\r
- //It's based in the glosssary filter by Williams Castillo\r
- //Modifications by mchurch. Enjoy! :-)\r
-\r
- require_once($CFG->dirroot.'/mod/wiki/lib.php');\r
-\r
- function wiki_filter($courseid, $text) {\r
-\r
- global $CFG;\r
-\r
- if (empty($courseid)) {\r
- if ($site = get_site()) {\r
- $courseid = $site->id;\r
- }\r
- }\r
-\r
- if (!($course = get_record('course', 'id', $courseid))) {\r
- return $text;\r
- }\r
-\r
-// Get all wikis for this course.\r
- $wikis = wiki_get_course_wikis($courseid);\r
- if (empty($wikis)) {\r
- return $text;\r
- }\r
-\r
-// Walk through each wiki, and get entries.\r
- foreach ($wikis as $wiki) {\r
- if ($wiki_entries = wiki_get_entries($wiki)) {\r
-\r
-// Walk through each entry and get the pages.\r
- foreach ($wiki_entries as $wiki_entry) {\r
- if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id)) {\r
-\r
-// Walk through each page and filter.\r
- foreach ($wiki_pages as $wiki_page) {\r
- $startlink = '<a class="autolink" title="Wiki" href="'\r
- .$CFG->wwwroot.'/mod/wiki/view.php?wid='.$wiki->id\r
- .'&userid='.$wiki_entry->userid\r
- .'&groupid='.$wiki_entry->groupid\r
- .'&wikipage='.$wiki_page->pagename.'">';\r
- $text = wiki_link_names($text, $wiki_page->pagename, $startlink, '</a>');\r
- }\r
- }\r
- }\r
- }\r
- }\r
-\r
- return $text;\r
- }\r
- \r
- function wiki_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>") {\r
-\r
- $list_of_words_cp = strip_tags($name);\r
-\r
- $list_of_words_cp = trim($list_of_words_cp,'|');\r
-\r
- $list_of_words_cp = trim($list_of_words_cp);\r
-\r
- $list_of_words_cp = preg_quote($list_of_words_cp,'/');\r
-\r
- $invalidprefixs = "([a-zA-Z0-9])";\r
- $invalidsufixs = "([a-zA-Z0-9])";\r
-\r
- //Avoid seaching in the string if it's inside invalidprefixs and invalidsufixs\r
- $words = array();\r
- $regexp = '/'.$invalidprefixs.'('.$list_of_words_cp.')|('.$list_of_words_cp.')'.$invalidsufixs.'/is';\r
- preg_match_all($regexp,$text,$list_of_words);\r
-\r
- foreach (array_unique($list_of_words[0]) as $key=>$value) {\r
- $words['<*'.$key.'*>'] = $value;\r
- }\r
- if (!empty($words)) {\r
- $text = str_replace($words,array_keys($words),$text);\r
- }\r
-\r
- //Now avoid searching inside the <nolink>tag\r
- $excludes = array();\r
- preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);\r
- foreach (array_unique($list_of_excludes[0]) as $key=>$value) {\r
- $excludes['<+'.$key.'+>'] = $value;\r
- }\r
- if (!empty($excludes)) {\r
- $text = str_replace($excludes,array_keys($excludes),$text);\r
- }\r
-\r
- //Now avoid searching inside links\r
- $links = array();\r
- preg_match_all('/<A[\s](.+?)>(.+?)<\/A>/is',$text,$list_of_links);\r
- foreach (array_unique($list_of_links[0]) as $key=>$value) {\r
- $links['<@'.$key.'@>'] = $value;\r
- }\r
- if (!empty($links)) {\r
- $text = str_replace($links,array_keys($links),$text);\r
- }\r
-\r
- //Now avoid searching inside every tag\r
- $final = array();\r
- preg_match_all('/<(.+?)>/is',$text,$list_of_tags);\r
- foreach (array_unique($list_of_tags[0]) as $key=>$value) {\r
- $final['<|'.$key.'|>'] = $value;\r
- }\r
- if (!empty($final)) {\r
- $text = str_replace($final,array_keys($final),$text);\r
- }\r
-\r
- $text = preg_replace('/('.$list_of_words_cp.')/is', $href_tag_begin.'$1'.$href_tag_end,$text);\r
-\r
- //Now rebuild excluded areas\r
- if (!empty($final)) {\r
- $text = str_replace(array_keys($final),$final,$text);\r
- }\r
- if (!empty($links)) {\r
- $text = str_replace(array_keys($links),$links,$text);\r
- }\r
- if (!empty($excludes)) {\r
- $text = str_replace(array_keys($excludes),$excludes,$text);\r
- }\r
- if (!empty($words)) {\r
- $text = str_replace(array_keys($words),$words,$text);\r
- }\r
- return $text;\r
- }\r
-?>\r
+<?PHP // $Id$\r\r //This function provides automatic linking to\r\r //wiki pages when its page title is found inside every Moodle text\r\r //It's based in the glosssary filter by Williams Castillo\r\r //Modifications by mchurch. Enjoy! :-)\r\r\r\r require_once($CFG->dirroot.'/mod/wiki/lib.php');\r\r\r\r function wiki_filter($courseid, $text) {\r\r\r\r global $CFG;\r\r\r\r if (empty($courseid)) {\r\r $courseid = SITEID;\r\r }\r\r }\r\r\r\r if (!($course = get_record('course', 'id', $courseid))) {\r\r return $text;\r\r }\r\r\r\r// Get all wikis for this course.\r\r $wikis = wiki_get_course_wikis($courseid);\r\r if (empty($wikis)) {\r\r return $text;\r\r }\r\r\r\r// Walk through each wiki, and get entries.\r\r foreach ($wikis as $wiki) {\r\r if ($wiki_entries = wiki_get_entries($wiki)) {\r\r\r\r// Walk through each entry and get the pages.\r\r foreach ($wiki_entries as $wiki_entry) {\r\r if ($wiki_pages = get_records('wiki_pages', 'wiki', $wiki_entry->id)) {\r\r\r\r// Walk through each page and filter.\r\r foreach ($wiki_pages as $wiki_page) {\r\r $startlink = '<a class="autolink" title="Wiki" href="'\r\r .$CFG->wwwroot.'/mod/wiki/view.php?wid='.$wiki->id\r\r .'&userid='.$wiki_entry->userid\r\r .'&groupid='.$wiki_entry->groupid\r\r .'&wikipage='.$wiki_page->pagename.'">';\r\r $text = wiki_link_names($text, $wiki_page->pagename, $startlink, '</a>');\r\r }\r\r }\r\r }\r\r }\r\r }\r\r\r\r return $text;\r\r }\r\r \r\r function wiki_link_names($text,$name,$href_tag_begin,$href_tag_end = "</a>") {\r\r\r\r $list_of_words_cp = strip_tags($name);\r\r\r\r $list_of_words_cp = trim($list_of_words_cp,'|');\r\r\r\r $list_of_words_cp = trim($list_of_words_cp);\r\r\r\r $list_of_words_cp = preg_quote($list_of_words_cp,'/');\r\r\r\r $invalidprefixs = "([a-zA-Z0-9])";\r\r $invalidsufixs = "([a-zA-Z0-9])";\r\r\r\r //Avoid seaching in the string if it's inside invalidprefixs and invalidsufixs\r\r $words = array();\r\r $regexp = '/'.$invalidprefixs.'('.$list_of_words_cp.')|('.$list_of_words_cp.')'.$invalidsufixs.'/is';\r\r preg_match_all($regexp,$text,$list_of_words);\r\r\r\r foreach (array_unique($list_of_words[0]) as $key=>$value) {\r\r $words['<*'.$key.'*>'] = $value;\r\r }\r\r if (!empty($words)) {\r\r $text = str_replace($words,array_keys($words),$text);\r\r }\r\r\r\r //Now avoid searching inside the <nolink>tag\r\r $excludes = array();\r\r preg_match_all('/<nolink>(.+?)<\/nolink>/is',$text,$list_of_excludes);\r\r foreach (array_unique($list_of_excludes[0]) as $key=>$value) {\r\r $excludes['<+'.$key.'+>'] = $value;\r\r }\r\r if (!empty($excludes)) {\r\r $text = str_replace($excludes,array_keys($excludes),$text);\r\r }\r\r\r\r //Now avoid searching inside links\r\r $links = array();\r\r preg_match_all('/<A[\s](.+?)>(.+?)<\/A>/is',$text,$list_of_links);\r\r foreach (array_unique($list_of_links[0]) as $key=>$value) {\r\r $links['<@'.$key.'@>'] = $value;\r\r }\r\r if (!empty($links)) {\r\r $text = str_replace($links,array_keys($links),$text);\r\r }\r\r\r\r //Now avoid searching inside every tag\r\r $final = array();\r\r preg_match_all('/<(.+?)>/is',$text,$list_of_tags);\r\r foreach (array_unique($list_of_tags[0]) as $key=>$value) {\r\r $final['<|'.$key.'|>'] = $value;\r\r }\r\r if (!empty($final)) {\r\r $text = str_replace($final,array_keys($final),$text);\r\r }\r\r\r\r $text = preg_replace('/('.$list_of_words_cp.')/is', $href_tag_begin.'$1'.$href_tag_end,$text);\r\r\r\r //Now rebuild excluded areas\r\r if (!empty($final)) {\r\r $text = str_replace(array_keys($final),$final,$text);\r\r }\r\r if (!empty($links)) {\r\r $text = str_replace(array_keys($links),$links,$text);\r\r }\r\r if (!empty($excludes)) {\r\r $text = str_replace(array_keys($excludes),$excludes,$text);\r\r }\r\r if (!empty($words)) {\r\r $text = str_replace(array_keys($words),$words,$text);\r\r }\r\r return $text;\r\r }\r\r?>\r\r
\ No newline at end of file
$mygroupid = mygroupid($course->id);
$isteacher = isteacher($course->id, $user->id);
$isteacheredit = isteacheredit($course->id, $user->id);
- $site = get_site();
switch ($wiki->wtype) {
case 'student':
/// Get all the existing entries for this wiki.
$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
/// 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)) {
/// Default pagename is dependent on the wiki settings.
/// group (for separate groups) or there are visible groups, or if this is
/// a site-level wiki, and they are an administrator.
if (($groupmode == VISIBLEGROUPS) or
- (($site->id == $course->id) and isadmin())) {
+ ((SITEID == $course->id) and isadmin())) {
$viewall = true;
}
else if ($groupmode == SEPARATEGROUPS) {
/// Get the groupmode. It's been added to the wiki object.
$groupmode = groupmode($course, $wiki);
$mygroupid = mygroupid($course->id);
- $site = get_site();
switch ($wiki->wtype) {
/// A user can create their own wiki at the site level.
if ($userid == 0) {
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
/// a non-editing teacher, if not assigned to a group can create any student wiki, or if assigned to a group can
/// If mode is 'nogroups', then all participants can add wikis.
if (!$groupmode) {
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.
else if ($groupid == 0) {
case 'teacher':
/// If mode is 'nogroups', then all teachers can add wikis.
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.
else if ($groupid == 0) {
$can_edit = false;
$groupmode = groupmode($course, $wiki);
$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,
/// or all wikis if group mode is 'no groups' or they don't belong to a group.
/// If mode is 'nogroups', then all participants can edit the wiki.
else {
$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;
$can_edit = (isteacher($course->id, $user->id) and ismember($wiki_entry->groupid, $user->id));
}
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;
}
global $CFG, $THEME, $ME;
- 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");
print_header();
?>
- <script language="javascript" type="text/javascript">
- <!--
- function set_value(txt) {
- opener.document.forms['form'].initialcontent.value = txt;
- window.close();
- }
+ <script language="javascript" type="text/javascript">
+ <!--
+ function set_value(txt) {
+ opener.document.forms['form'].initialcontent.value = txt;
+ window.close();
+ }
-->
- </script>
+ </script>
<?php
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%">';
echo '</tr>';
echo '</table>';
- if ($course->id == $site->id) {
+ if ($course->id == SITEID) {
print_heading(get_string("publicsitefileswarning"), "center", 2);
}
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();
// make sure it works on the site course
$select = "u.course = '$workshop->course' AND";
- $site = get_site();
- if ($workshop->course == $site->id) {
+ if ($workshop->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "s.course = '$workshop->course' AND";
- $site = get_site();
- if ($workshop->course == $site->id) {
+ if ($workshop->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$workshop->course' AND";
- $site = get_site();
- if ($workshop->course == $site->id) {
+ if ($workshop->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$workshop->course' AND";
- $site = get_site();
- if ($workshop->course == $site->id) {
+ if ($workshop->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "u.course = '$workshop->course' AND";
- $site = get_site();
- if ($workshop->course == $site->id) {
+ if ($workshop->course == SITEID) {
$select = '';
}
// make sure it works on the site course
$select = "s.course = '$workshop->course' AND";
- $site = get_site();
- if ($workshop->course == $site->id) {
+ if ($workshop->course == SITEID) {
$select = '';
}
$guest = get_guest();
$exceptions .= $guest->id;
- $site = get_site();
- if ($course->id == $site->id) { // Show all site users (even unconfirmed)
+ if ($course->id == SITEID) { // Show all site users (even unconfirmed)
$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
if ($firstinitial or $lastinitial) {