Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e8fb94a3cd | |||
| 79dd6106dd | |||
| 031dd5f017 | |||
| 507ee65e59 | |||
| 56b19c309e | |||
| 99dac04aeb | |||
| 12f18ea1ab | |||
| 1626376373 | |||
| 7729acff90 | |||
| b35cd9c592 | |||
| a69a278684 | |||
| 61cc70ae45 |
@@ -1,89 +0,0 @@
|
||||
|
||||
<form name="adminform" id="adminform" method="post" action="admin.php">
|
||||
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php echo count($admins) . " ". $strexistingadmins ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php echo $usercount . " " . $strpotentialadmins ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple
|
||||
onFocus="document.adminform.add.disabled=true;
|
||||
document.adminform.remove.disabled=false;
|
||||
document.adminform.addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
if (count($admins) == 1) {
|
||||
$disabled = 'disabled';
|
||||
$removebuttontype = 'hidden';
|
||||
} else {
|
||||
$disabled = '';
|
||||
$removebuttontype = 'submit';
|
||||
}
|
||||
|
||||
foreach ($admins as $admin) {
|
||||
$fullname = fullname($admin, true);
|
||||
echo "<option value=\"$admin->id\" $disabled>".$fullname.", ".$admin->email."</option>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="<?php echo $removebuttontype ?>" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple
|
||||
onFocus="document.adminform.add.disabled=false;
|
||||
document.adminform.remove.disabled=true;
|
||||
document.adminform.removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
|
||||
foreach ($searchusers as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
|
||||
onFocus ="document.adminform.add.disabled=true;
|
||||
document.adminform.remove.disabled=true;
|
||||
document.adminform.removeselect.selectedIndex=-1;
|
||||
document.adminform.addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
document.adminform.previoussearch.value=1;
|
||||
document.adminform.submit();
|
||||
} " />
|
||||
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>" />
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
+90
-56
@@ -19,10 +19,6 @@
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// If you want any administrator to have the ability to assign admin
|
||||
@@ -36,11 +32,16 @@
|
||||
"assignadmins",
|
||||
"administration",
|
||||
"existingadmins",
|
||||
"noexistingadmins",
|
||||
"potentialadmins",
|
||||
"nopotentialadmins",
|
||||
"addadmin",
|
||||
"removeadmin",
|
||||
"search",
|
||||
"searchagain",
|
||||
"toomanytoshow",
|
||||
"users",
|
||||
"searchresults",
|
||||
"showall"
|
||||
"searchresults"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
@@ -48,74 +49,107 @@
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassignadmins",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strassignadmins", "adminform.searchtext");
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> -> $strassignadmins", "");
|
||||
|
||||
|
||||
if (!$frm = data_submitted()) {
|
||||
print_simple_box("<center>".get_string("adminhelpassignadmins")."</center>", "center", "50%");
|
||||
|
||||
/// A form was submitted so process the input
|
||||
|
||||
} else {
|
||||
if (!empty($frm->add) and !empty($frm->addselect)) {
|
||||
foreach ($frm->addselect as $addadmin) {
|
||||
if (! add_admin($addadmin)) {
|
||||
error("Could not add admin with user id $addadmin!");
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
|
||||
$admins = get_admins();
|
||||
if (count($admins) > count($frm->removeselect)) {
|
||||
foreach ($frm->removeselect as $removeadmin) {
|
||||
if (! remove_admin($removeadmin)) {
|
||||
error("Could not remove admin with user id $removeadmin!");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->showall)) {
|
||||
unset($frm->searchtext);
|
||||
$frm->previoussearch = 0;
|
||||
/// Add an admin if one is specified
|
||||
if (!empty($_GET['add'])) {
|
||||
if (! add_admin($add)) {
|
||||
error("Could not add that admin!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Is there a current search?
|
||||
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
|
||||
/// Remove an admin if one is specified.
|
||||
if (!empty($_GET['remove'])) {
|
||||
if (! remove_admin($remove)) {
|
||||
error("Could not remove that admin!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Print a help notice about this page
|
||||
if (empty($add) and empty($remove) and empty($search)) {
|
||||
print_simple_box("<center>".get_string("adminhelpassignadmins")."</center>", "center", "50%");
|
||||
}
|
||||
|
||||
/// Get all existing admins
|
||||
$admins = get_admins();
|
||||
|
||||
/// Print the lists of existing and potential admins
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingadmins</th><th width=50%>$strpotentialadmins</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
$adminarray = array();
|
||||
foreach ($admins as $admin) {
|
||||
$adminarray[] = $admin->id;
|
||||
}
|
||||
$adminlist = implode(',', $adminarray);
|
||||
/// First, show existing admins
|
||||
|
||||
unset($adminarray);
|
||||
if (! $admins) {
|
||||
echo "<p align=center>$strnoexistingadmins</p>";
|
||||
$adminlist = "";
|
||||
|
||||
} else {
|
||||
$adminarray = array();
|
||||
|
||||
/// Get search results excluding any current admins
|
||||
if (!empty($frm->searchtext) and $previoussearch) {
|
||||
$searchusers = get_users(true, $frm->searchtext, true, $adminlist, 'firstname ASC, lastname ASC',
|
||||
'', '', 0, 99999, 'id, firstname, lastname, email');
|
||||
$usercount = get_users(false, '', true, $adminlist);
|
||||
}
|
||||
|
||||
/// If no search results then get potential users excluding current admins
|
||||
if (empty($searchusers)) {
|
||||
if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email') ) {
|
||||
$users = array();
|
||||
foreach ($admins as $admin) {
|
||||
$adminarray[] = $admin->id;
|
||||
echo "<p align=right>".fullname($admin, true).",
|
||||
$admin->email ";
|
||||
if ($primaryadmin->id == $admin->id){
|
||||
print_spacer(10, 9, false);
|
||||
} else {
|
||||
echo "<a href=\"admin.php?remove=$admin->id\"
|
||||
title=\"$strremoveadmin\"><img src=\"../pix/t/right.gif\"
|
||||
border=0></A>";
|
||||
}
|
||||
echo "</p>";
|
||||
}
|
||||
$usercount = count($users);
|
||||
|
||||
$adminlist = implode(",",$adminarray);
|
||||
unset($adminarray);
|
||||
}
|
||||
|
||||
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
|
||||
$previoussearch = ($previoussearch) ? '1' : '0';
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
include('./admin.html');
|
||||
/// Print list of potential admins
|
||||
|
||||
$usercount = get_users(false, $search, true, $adminlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialadmins</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow ($usercount) </p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $adminlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
echo "<p align=left><a href=\"admin.php?add=$user->id\"".
|
||||
"title=\"$straddadmin\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> ".fullname($user).", $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action=admin.php method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
+4
-9
@@ -12,13 +12,10 @@
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
if ($config = data_submitted()) {
|
||||
|
||||
$config = (array)$config;
|
||||
validate_form($config, $err);
|
||||
@@ -30,7 +27,7 @@
|
||||
notify("Problem saving config $name as $value");
|
||||
}
|
||||
}
|
||||
redirect("auth.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
redirect("auth.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
|
||||
} else {
|
||||
@@ -38,7 +35,7 @@
|
||||
$focus = "form.$key";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
@@ -56,7 +53,6 @@
|
||||
} else {
|
||||
$auth = $config->auth;
|
||||
}
|
||||
$auth = clean_filename($auth);
|
||||
require_once("$CFG->dirroot/auth/$auth/lib.php"); //just to make sure that current authentication functions are loaded
|
||||
if (! isset($config->guestloginbutton)) {
|
||||
$config->guestloginbutton = 1;
|
||||
@@ -97,10 +93,9 @@
|
||||
|
||||
echo "<CENTER><P><B>";
|
||||
echo "<form TARGET=\"{$CFG->framename}\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
print_string("chooseauthmethod","auth");
|
||||
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?sesskey=$USER->sesskey&auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
choose_from_menu ($options, "auth", $auth, "","document.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
|
||||
|
||||
echo "</B></P></CENTER>";
|
||||
|
||||
|
||||
+1
-5
@@ -15,10 +15,6 @@
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
//Initialise error variables
|
||||
$error = false;
|
||||
$sche_destination_error = "";
|
||||
@@ -77,7 +73,7 @@
|
||||
}
|
||||
if ($status) {
|
||||
//get courses
|
||||
if ($courses = get_records('course', '', '', '', 'id,shortname')) {
|
||||
if ($courses = get_records("course")) {
|
||||
//For each course, we check (insert, update) the backup_course table
|
||||
//with needed data
|
||||
foreach ($courses as $course) {
|
||||
|
||||
+4
-8
@@ -14,10 +14,6 @@
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
require_variable($_REQUEST['block']);
|
||||
$blockid = intval($_REQUEST['block']);
|
||||
|
||||
@@ -32,13 +28,13 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($config = data_submitted()) {
|
||||
unset($config->block); // This will always be set if we have reached this point
|
||||
$block->handle_config($config);
|
||||
if ($config = data_submitted()) {
|
||||
unset($config['block']); // This will always be set if we have reached this point
|
||||
$block->handle_config($config);
|
||||
print_header();
|
||||
redirect("$CFG->wwwroot/$CFG->admin/blocks.php", get_string("changessaved"), 1);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise print the form.
|
||||
|
||||
|
||||
+9
-14
@@ -44,21 +44,21 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($_GET['hide']) and confirm_sesskey()) {
|
||||
if (!empty($_GET['hide'])) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['hide'])) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('blocks', 'visible', '0', 'id', $block->id); // Hide block
|
||||
}
|
||||
|
||||
if (!empty($_GET['show']) and confirm_sesskey() ) {
|
||||
if (!empty($_GET['show'])) {
|
||||
if (!$block = get_record('blocks', 'id', $_GET['show'])) {
|
||||
error("Block doesn't exist!");
|
||||
}
|
||||
set_field('blocks', 'visible', '1', 'id', $block->id); // Show block
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
if (!empty($delete)) {
|
||||
|
||||
if (!$block = get_record('blocks', 'id', $delete)) {
|
||||
error("Block doesn't exist!");
|
||||
@@ -69,7 +69,7 @@
|
||||
|
||||
if (!$_GET['confirm']) {
|
||||
notice_yesno(get_string('blockdeleteconfirm', '', $strblockname),
|
||||
'blocks.php?delete='.$block->id.'&confirm=1&sesskey='.$USER->sesskey,
|
||||
'blocks.php?delete='.$block->id.'&confirm=1',
|
||||
'blocks.php');
|
||||
print_footer();
|
||||
exit;
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (false === ($blocks = get_records('blocks'))) {
|
||||
if (!$blocks = get_records('blocks')) {
|
||||
error('No blocks found!'); // Should never happen
|
||||
}
|
||||
|
||||
@@ -117,11 +117,6 @@
|
||||
$blockbyname[$blockobject->get_title()] = $block->id;
|
||||
$blockobjects[$block->id] = $blockobject;
|
||||
}
|
||||
|
||||
if(empty($blockbyname)) {
|
||||
error('One or more blocks are registered in the database, but they all failed to load!');
|
||||
}
|
||||
|
||||
ksort($blockbyname);
|
||||
|
||||
/// Print the table of all blocks
|
||||
@@ -148,21 +143,21 @@
|
||||
//$icon = "<img src=\"$modpixpath/$block->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
$blockobject = $blockobjects[$blockid];
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strdelete.'</a>';
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'">'.$strdelete.'</a>';
|
||||
|
||||
$settings = ''; // By default, no configuration
|
||||
if($blockobject->has_config()) {
|
||||
$settings = '<a href="block.php?block='.$blockid.'&sesskey='.$USER->sesskey.'">'.$strsettings.'</a>';
|
||||
$settings = '<a href="block.php?block='.$blockid.'">'.$strsettings.'</a>';
|
||||
}
|
||||
|
||||
$count = blocks_get_courses_using_block_by_id($blockid);
|
||||
$class = ''; // Nothing fancy, by default
|
||||
|
||||
if ($blocks[$blockid]->visible) {
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strhide.'">'.
|
||||
$visible = '<a href="blocks.php?hide='.$blockid.'" title="'.$strhide.'">'.
|
||||
'<img src="'.$pixpath.'/i/hide.gif" style="height: 16px; width: 16px;" /></a>';
|
||||
} else {
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'&sesskey='.$USER->sesskey.'" title="'.$strshow.'">'.
|
||||
$visible = '<a href="blocks.php?show='.$blockid.'" title="'.$strshow.'">'.
|
||||
'<img src="'.$pixpath.'/i/show.gif" style="height: 16px; width: 16px;" /></a>';
|
||||
$class = ' class="dimmed_text"'; // Leading space required!
|
||||
}
|
||||
|
||||
+102
-225
@@ -2,8 +2,8 @@
|
||||
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><p>lang:</td>
|
||||
<td>
|
||||
<td align=right><p>lang:</td>
|
||||
<td>
|
||||
<?php choose_from_menu (get_list_of_languages(), "lang", $config->lang, "", "", ""); ?>
|
||||
</td>
|
||||
<td>
|
||||
@@ -11,9 +11,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langmenu:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>langmenu:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
@@ -26,8 +26,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>langlist:</td>
|
||||
<td>
|
||||
<td align=right><p>langlist:</td>
|
||||
<td>
|
||||
<input name=langlist type=text size=40 value="<?php p($config->langlist) ?>">
|
||||
</td>
|
||||
<td>
|
||||
@@ -35,8 +35,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>locale:</td>
|
||||
<td>
|
||||
<td align=right><p>locale:</td>
|
||||
<td>
|
||||
<input name=locale type=text size=10 value="<?php p($config->locale) ?>">
|
||||
</td>
|
||||
<td>
|
||||
@@ -44,23 +44,22 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>timezone:</td>
|
||||
<td align=right><p>timezone:</td>
|
||||
<td><?php
|
||||
if (abs($config->timezone) > 13) {
|
||||
$config->timezone = 99;
|
||||
}
|
||||
$timenow = time();
|
||||
$timeformat = get_string('strftimedaytime');
|
||||
|
||||
for ($tz = -26; $tz <= 26; $tz++) {
|
||||
$zone = (float)$tz/2.0;
|
||||
$usertime = $timenow + ($tz * 1800);
|
||||
if ($tz == 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT)";
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT)";
|
||||
} else if ($tz < 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT$zone)";
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT$zone)";
|
||||
} else {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT+$zone)";
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT+$zone)";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,16 +71,16 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>country:</td>
|
||||
<td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
|
||||
</td>
|
||||
<td align=right><p>country:</td>
|
||||
<td><?php choose_from_menu (get_list_of_countries(), "country", $config->country, get_string("selectacountry"), "") ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configcountry") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtphosts:</td>
|
||||
<td>
|
||||
<td align=right><p>smtphosts:</td>
|
||||
<td>
|
||||
<input name=smtphosts type=text size=30 value="<?php p($config->smtphosts)?>">
|
||||
</td>
|
||||
<td>
|
||||
@@ -89,8 +88,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtpuser:</td>
|
||||
<td>
|
||||
<td align=right><p>smtpuser:</td>
|
||||
<td>
|
||||
<input name=smtpuser type=text size=10 value="<?php p($config->smtpuser)?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
@@ -98,24 +97,15 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>smtppass:</td>
|
||||
<td>
|
||||
<td align=right><p>smtppass:</td>
|
||||
<td>
|
||||
<input name=smtppass type=text size=10 value="<?php p($config->smtppass)?>">
|
||||
</td>
|
||||
</tr>
|
||||
</TR>
|
||||
<tr valign=top>
|
||||
<td align=right><p>noreplyaddress:</td>
|
||||
<td>
|
||||
<input name=noreplyaddress type=text size=30 value="<?php p($config->noreplyaddress)?>">
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("confignoreplyaddress") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>gdversion:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>gdversion:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("gdnot");
|
||||
$options[1] = get_string("gd1");
|
||||
@@ -131,9 +121,23 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxeditingtime:</td>
|
||||
<td align=right><p>htmleditor:</td>
|
||||
<td>
|
||||
<?php
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("allownot");
|
||||
$options[1] = get_string("allow");
|
||||
choose_from_menu ($options, "htmleditor", $config->htmleditor, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("confightmleditor") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxeditingtime:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[3600] = get_string("numminutes", "", 60);
|
||||
$options[2700] = get_string("numminutes", "", 45);
|
||||
@@ -150,9 +154,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>longtimenosee:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>longtimenosee:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[1000] = get_string("numdays", "", 1000);
|
||||
$options[365] = get_string("numdays", "", 365);
|
||||
@@ -174,9 +178,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>deleteunconfirmed:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>deleteunconfirmed:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("never");
|
||||
$options[168] = get_string("numdays", "", 7);
|
||||
@@ -198,9 +202,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>loglifetime:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>loglifetime:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("neverdeletelogs");
|
||||
$options[1000] = get_string("numdays", "", 1000);
|
||||
@@ -219,56 +223,10 @@
|
||||
<?php print_string("configloglifetime") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>displayloginfailures:</p></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[''] = get_string('nobody');
|
||||
$options['admin'] = get_string('administrators');
|
||||
$options['teacher'] = get_string('administratorsandteachers');
|
||||
$options['everybody'] = get_string('everybody');
|
||||
choose_from_menu($options, "displayloginfailures",$config->displayloginfailures,"","","");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configdisplayloginfailures") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>notifyloginfailures:</p></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[''] = get_string('nobody');
|
||||
$options['mainadmin'] = get_string('administrator');
|
||||
$options['alladmins'] = get_string('administratorsall');
|
||||
choose_from_menu($options,"notifyloginfailures",$config->notifyloginfailures,"","","");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('confignotifyloginfailures') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<td align="right"><p>notifyloginthreshold:</p></td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
for ($i=1; $i<=100; $i++) {
|
||||
$options[$i] = "$i";
|
||||
}
|
||||
choose_from_menu($options,"notifyloginthreshold",$config->notifyloginthreshold,"","","");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string('confignotifyloginthreshold') ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessiontimeout:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>sessiontimeout:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[14400] = get_string("numhours", "", 4);
|
||||
$options[10800] = get_string("numhours", "", 3);
|
||||
@@ -288,8 +246,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>sessioncookie:</td>
|
||||
<td>
|
||||
<td align=right><p>sessioncookie:</td>
|
||||
<td>
|
||||
<input name=sessioncookie type=text size=10 value="<?php p($config->sessioncookie)?>">
|
||||
</td>
|
||||
<td>
|
||||
@@ -297,8 +255,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>zip:</td>
|
||||
<td>
|
||||
<td align=right><p>zip:</td>
|
||||
<td>
|
||||
<input name=zip type=text size=30 value="<?php p($config->zip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
@@ -306,8 +264,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>unzip:</td>
|
||||
<td>
|
||||
<td align=right><p>unzip:</td>
|
||||
<td>
|
||||
<input name=unzip type=text size=30 value="<?php p($config->unzip) ?>">
|
||||
</td>
|
||||
<td>
|
||||
@@ -315,8 +273,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>slasharguments:</td>
|
||||
<td>
|
||||
<td align=right><p>slasharguments:</td>
|
||||
<td>
|
||||
<?php unset($options);
|
||||
$options[0] = "file.php?file=/pic.jpg";
|
||||
$options[1] = "file.php/pic.jpg";
|
||||
@@ -329,8 +287,8 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyhost:</td>
|
||||
<td>
|
||||
<td align=right><p>proxyhost:</td>
|
||||
<td>
|
||||
<input name=proxyhost type=text size=30 value="<?php p($config->proxyhost) ?>">
|
||||
</td>
|
||||
<td rowspan=2>
|
||||
@@ -338,15 +296,15 @@
|
||||
</td>
|
||||
</TR>
|
||||
<tr valign=top>
|
||||
<td align=right><p>proxyport:</td>
|
||||
<td>
|
||||
<td align=right><p>proxyport:</td>
|
||||
<td>
|
||||
<input name=proxyport type=text size=5 value="<?php p($config->proxyport) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>debug:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>debug:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[7] = get_string("no");
|
||||
$options[15] = get_string("yes");
|
||||
@@ -359,9 +317,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>framename:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>framename:</td>
|
||||
<td>
|
||||
<?php
|
||||
if (empty($config->framename)) {
|
||||
$config->framename = "_top";
|
||||
}
|
||||
@@ -373,9 +331,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>secureforms:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>secureforms:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
@@ -387,27 +345,10 @@
|
||||
<?php print_string("configsecureforms") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>loginhttps:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "loginhttps", $config->loginhttps, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configloginhttps") ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>teacherassignteachers:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>teacherassignteachers:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
@@ -420,39 +361,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>allusersaresitestudents:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
|
||||
choose_from_menu ($options, "allusersaresitestudents", $config->allusersaresitestudents, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configallusersaresitestudents") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>showsiteparticipantslist:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("siteteachers");
|
||||
$options[1] = get_string("allteachers");
|
||||
$options[2] = get_string("studentsandteachers");
|
||||
choose_from_menu ($options, "showsiteparticipantslist", $config->showsiteparticipantslist, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configshowsiteparticipantslist") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>allowunenroll:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>allowunenroll:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
@@ -465,9 +376,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>maxbytes:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>maxbytes:</td>
|
||||
<td>
|
||||
<?php
|
||||
$options = get_max_upload_sizes();
|
||||
choose_from_menu ($options, "maxbytes", $config->maxbytes, "");
|
||||
?>
|
||||
@@ -477,9 +388,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>fullnamedisplay:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>fullnamedisplay:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options['language'] = get_string('language');
|
||||
$options['firstname lastname'] = get_string('firstname') . ' + ' . get_string('lastname');
|
||||
@@ -494,9 +405,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>extendedusernamechars:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>extendedusernamechars:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
@@ -509,24 +420,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>autologinguests:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
|
||||
choose_from_menu ($options, "autologinguests", $config->autologinguests, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configautologinguests") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>forcelogin:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>forcelogin:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
@@ -539,9 +435,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>forceloginforprofiles:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>forceloginforprofiles:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string('no');
|
||||
$options[1] = get_string('yes');
|
||||
@@ -554,9 +450,9 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p>opentogoogle:</td>
|
||||
<td>
|
||||
<?php
|
||||
<td align=right><p>opentogoogle:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("no");
|
||||
$options[1] = get_string("yes");
|
||||
@@ -581,38 +477,19 @@
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
<?php
|
||||
print_string("configenablerssfeeds");
|
||||
//Check for required functions...
|
||||
if(!function_exists('utf8_encode')) {
|
||||
echo "<font color=\"red\"> You need to add XML support to your PHP installation.</font>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><p>digestmailtime:</td>
|
||||
<td>
|
||||
<?php
|
||||
$hours = array();
|
||||
for ($i=0; $i<=23; $i++) {
|
||||
$hours[$i] = sprintf("%02d",$i);
|
||||
}
|
||||
choose_from_menu($hours, 'digestmailtime', $config->digestmailtime, "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
print_string('configdigestmailtime');
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan=3 align=center>
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>">
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
+4
-26
@@ -3,6 +3,7 @@
|
||||
|
||||
require_once("../config.php");
|
||||
|
||||
|
||||
if ($site = get_site()) { // If false then this is a new installation
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
@@ -21,12 +22,6 @@
|
||||
|
||||
if ($config = data_submitted($match)) {
|
||||
|
||||
if (!empty($USER->id)) { // Additional identity check
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
}
|
||||
|
||||
validate_form($config, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
@@ -87,28 +82,10 @@
|
||||
echo "<br />";
|
||||
}
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("config.html");
|
||||
print_simple_box_end();
|
||||
|
||||
/// Lock some options
|
||||
|
||||
$httpsurl = str_replace('http://', 'https://', $CFG->wwwroot);
|
||||
if ($httpsurl != $CFG->wwwroot) {
|
||||
if (ini_get('allow_url_fopen')) {
|
||||
if ((($fh = @fopen($httpsurl, 'r')) == false) and ($config->loginhttps == 0)) {
|
||||
echo '<script>'."\n";
|
||||
echo '<!--'."\n";
|
||||
echo "eval('document.form.loginhttps.disabled=true');\n";
|
||||
echo '-->'."\n";
|
||||
echo '</script>'."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($site) {
|
||||
print_footer();
|
||||
}
|
||||
@@ -119,9 +96,10 @@
|
||||
|
||||
function validate_form(&$form, &$err) {
|
||||
|
||||
// Currently no checks are needed ...
|
||||
// if (empty($form->fullname))
|
||||
// $err["fullname"] = get_string("missingsitename");
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-5
@@ -34,16 +34,13 @@
|
||||
get_string("adminhelpmanagemodules"));
|
||||
$table->data[] = array("<b><a href=\"blocks.php\">".get_string("manageblocks")."</a></b>",
|
||||
get_string("adminhelpmanageblocks"));
|
||||
$table->data[] = array("<b><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"filters.php\">".get_string("managefilters")."</a></b>",
|
||||
get_string("adminhelpmanagefilters"));
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$table->data[] = array("<b><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"backup.php\">".get_string("backup")."</a></b>",
|
||||
get_string("adminhelpbackup"));
|
||||
}
|
||||
|
||||
$table->data[]= array("<b><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a></b>",
|
||||
get_string("adminhelpeditorsettings"));
|
||||
|
||||
print_table($table);
|
||||
|
||||
print_footer($site);
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
|
||||
<form name="creatorsform" id="creatorsform" method="post" action="creators.php">
|
||||
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<?php echo count($creators) . " ". $strexistingcreators ?>
|
||||
</td>
|
||||
<td></td>
|
||||
<td valign="top">
|
||||
<?php echo $usercount . " " . $strpotentialcreators ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<select name="removeselect[]" size="20" id="removeselect" multiple
|
||||
onFocus="document.creatorsform.add.disabled=true;
|
||||
document.creatorsform.remove.disabled=false;
|
||||
document.creatorsform.addselect.selectedIndex=-1;">
|
||||
<?php
|
||||
foreach ($creators as $creator) {
|
||||
$fullname = fullname($creator, true);
|
||||
echo "<option value=\"$creator->id\">".$fullname.", ".$creator->email."</option>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
</select></td>
|
||||
<td valign="top">
|
||||
<br />
|
||||
<input name="add" type="submit" id="add" value="←" />
|
||||
<br />
|
||||
<input name="remove" type="submit" id="remove" value="→" />
|
||||
<br />
|
||||
</td>
|
||||
<td valign="top">
|
||||
<select name="addselect[]" size="20" id="addselect" multiple
|
||||
onFocus="document.creatorsform.add.disabled=false;
|
||||
document.creatorsform.remove.disabled=true;
|
||||
document.creatorsform.removeselect.selectedIndex=-1;">
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo "<optgroup label=\"$strsearchresults (" . count($searchusers) . ")\">\n";
|
||||
foreach ($searchusers as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
echo "</optgroup>\n";
|
||||
}
|
||||
if (!empty($users)) {
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, true);
|
||||
echo "<option value=\"$user->id\">".$fullname.", ".$user->email."</option>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<script>
|
||||
function
|
||||
</script>
|
||||
<input type="text" name="searchtext" size="30" value="<?php echo $searchtext ?>"
|
||||
onFocus ="document.creatorsform.add.disabled=true;
|
||||
document.creatorsform.remove.disabled=true;
|
||||
document.creatorsform.removeselect.selectedIndex=-1;
|
||||
document.creatorsform.addselect.selectedIndex=-1;"
|
||||
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
|
||||
if (keyCode == 13) {
|
||||
document.creatorsform.previoussearch.value=1;
|
||||
document.creatorsform.submit();
|
||||
} " />
|
||||
<input name="search" id="search" type="submit" value="<?php p($strsearch) ?>"/>
|
||||
<?php
|
||||
if (!empty($searchusers)) {
|
||||
echo '<input name="showall" id="showall" type="submit" value="'.$strshowall.'" />'."\n";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
+86
-54
@@ -19,10 +19,6 @@
|
||||
error("You must be an administrator to use this page.");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$primaryadmin = get_admin();
|
||||
|
||||
/// assign all of the configurable language strings
|
||||
@@ -30,11 +26,16 @@
|
||||
"assigncreators",
|
||||
"administration",
|
||||
"existingcreators",
|
||||
"noexistingcreators",
|
||||
"potentialcreators",
|
||||
"nopotentialcreators",
|
||||
"addcreator",
|
||||
"removecreator",
|
||||
"search",
|
||||
"searchagain",
|
||||
"users",
|
||||
"searchresults",
|
||||
"showall"
|
||||
"toomanytoshow",
|
||||
"searchresults"
|
||||
);
|
||||
|
||||
foreach ($stringstoload as $stringtoload){
|
||||
@@ -42,74 +43,105 @@
|
||||
$$strstringtoload = get_string($stringtoload);
|
||||
}
|
||||
|
||||
if ($search) {
|
||||
$searchstring = $strsearchagain;
|
||||
} else {
|
||||
$searchstring = $strsearch;
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $strassigncreators",
|
||||
"$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
|
||||
$strassigncreators", "creatorsform.searchtext");
|
||||
$strassigncreators", "");
|
||||
|
||||
/// Add a creator if one is specified
|
||||
|
||||
if (!$frm = data_submitted()) {
|
||||
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
|
||||
|
||||
/// A form was submitted so process the input
|
||||
|
||||
} else {
|
||||
if (!empty($frm->add) and !empty($frm->addselect)) {
|
||||
foreach ($frm->addselect as $addcreator) {
|
||||
if (! add_creator($addcreator)) {
|
||||
error("Could not add course creator with user id $addcreator!");
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
|
||||
foreach ($frm->removeselect as $removecreator) {
|
||||
if (! remove_creator($removecreator)) {
|
||||
error("Could not remove course creator with user id $removecreator!");
|
||||
}
|
||||
}
|
||||
} else if (!empty($frm->showall)) {
|
||||
unset($frm->searchtext);
|
||||
$frm->previoussearch = 0;
|
||||
if (!empty($_GET['add'])) {
|
||||
if (! add_creator($add)) {
|
||||
error("Could not add that creator!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Is there a current search?
|
||||
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
|
||||
/// Remove a creator if one is specified.
|
||||
|
||||
if (!empty($_GET['remove'])) {
|
||||
if (! remove_creator($remove)) {
|
||||
error("Could not remove that creator!");
|
||||
}
|
||||
}
|
||||
|
||||
/// Print a help notice about this page
|
||||
if (empty($add) and empty($remove) and empty($search)) {
|
||||
print_simple_box("<center>".get_string("adminhelpassigncreators")."</center>", "center", "50%");
|
||||
}
|
||||
|
||||
/// Get all existing creators
|
||||
if (! $creators = get_creators()) {
|
||||
$creators = array();
|
||||
}
|
||||
$creators = get_creators();
|
||||
|
||||
$creatorsarray = array();
|
||||
foreach ($creators as $creator) {
|
||||
$creatorsarray[] = $creator->id;
|
||||
}
|
||||
$creatorlist = implode(',', $creatorsarray);
|
||||
/// Print the lists of existing and potential creators
|
||||
echo "<table cellpadding=2 cellspacing=10 align=center>";
|
||||
echo "<tr><th width=50%>$strexistingcreators</th><th width=50%>$strpotentialcreators</th></tr>";
|
||||
echo "<tr><td width=50% nowrap valign=top>";
|
||||
|
||||
unset($creatorarray);
|
||||
/// First, show existing creators
|
||||
|
||||
if (! $creators) {
|
||||
echo "<p align=center>$strnoexistingcreators</a>";
|
||||
|
||||
/// Get search results excluding any current admins
|
||||
if (!empty($frm->searchtext) and $previoussearch) {
|
||||
$searchusers = get_users(true, $frm->searchtext, true, $creatorlist, 'firstname ASC, lastname ASC',
|
||||
'', '', 0, 99999, 'id, firstname, lastname, email');
|
||||
$usercount = get_users(false, '', true, $creatorlist);
|
||||
}
|
||||
$creatorlist = "";
|
||||
|
||||
/// If no search results then get potential users excluding current creators
|
||||
if (empty($searchusers)) {
|
||||
if (!$users = get_users(true, '', true, $creatorlist, 'firstname ASC, lastname ASC', '', '',
|
||||
0, 99999, 'id, firstname, lastname, email') ) {
|
||||
$users = array();
|
||||
} else {
|
||||
$creatorarray = array();
|
||||
foreach ($creators as $creator) {
|
||||
$creatorarray[] = $creator->id;
|
||||
echo "<p align=right>".fullname($creator, true).", $creator->email ";
|
||||
echo "<a href=\"creators.php?remove=$creator->id\"
|
||||
title=\"$strremovecreator\"><img src=\"../pix/t/right.gif\"
|
||||
border=0></a>";
|
||||
echo "</p>";
|
||||
}
|
||||
$usercount = count($users);
|
||||
$creatorlist = implode(",",$creatorarray);
|
||||
unset($creatorarray);
|
||||
}
|
||||
|
||||
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
|
||||
$previoussearch = ($previoussearch) ? '1' : '0';
|
||||
echo "<td width=50% nowrap valign=top>";
|
||||
|
||||
include('./creators.html');
|
||||
/// Print list of potential creators
|
||||
|
||||
$usercount = get_users(false, $search, true, $creatorlist);
|
||||
|
||||
if ($usercount == 0) {
|
||||
echo "<p align=center>$strnopotentialcreators</p>";
|
||||
|
||||
} else if ($usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<p align=center>$strtoomanytoshow ($usercount) </p>";
|
||||
|
||||
} else {
|
||||
|
||||
if ($search) {
|
||||
echo "<p align=center>($strsearchresults : $search)</p>";
|
||||
}
|
||||
|
||||
if (!$users = get_users(true, $search, true, $creatorlist)) {
|
||||
error("Could not get users!");
|
||||
}
|
||||
|
||||
foreach ($users as $user) {
|
||||
$fullname = fullname($user, TRUE);
|
||||
echo "<p align=left><a href=\"creators.php?add=$user->id\"".
|
||||
"title=\"$straddcreator\"><img src=\"../pix/t/left.gif\"".
|
||||
"border=0></a> $fullname, $user->email";
|
||||
}
|
||||
}
|
||||
|
||||
if ($search or $usercount > MAX_USERS_PER_PAGE) {
|
||||
echo "<form action=creators.php method=post>";
|
||||
echo "<input type=text name=search size=20>";
|
||||
echo "<input type=submit value=\"$searchstring\">";
|
||||
echo "</form>";
|
||||
}
|
||||
|
||||
echo "</tr></table>";
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
+32
-54
@@ -11,12 +11,9 @@
|
||||
/// eg wget -q -O /dev/null 'http://moodle.somewhere.edu/admin/cron.php'
|
||||
/// or php /web/moodle/admin/cron.php
|
||||
|
||||
$FULLME = "cron";
|
||||
|
||||
$starttime = microtime();
|
||||
|
||||
/// The following is a hack necessary to allow this script to work well
|
||||
/// from the command line.
|
||||
|
||||
define('FULLME', 'cron');
|
||||
|
||||
/// The current directory in PHP version 4.3.0 and above isn't necessarily the
|
||||
/// directory of the script when run from the command line. The require_once()
|
||||
@@ -36,16 +33,13 @@
|
||||
$USER = get_admin(); /// Temporarily, to provide environment for this script
|
||||
}
|
||||
|
||||
/// Start output log
|
||||
echo "<pre>\n";
|
||||
|
||||
$timenow = time();
|
||||
|
||||
mtrace("<pre>");
|
||||
mtrace("Server Time: ".date('r',$timenow)."\n\n");
|
||||
echo "Server Time: ".date('r',$timenow)."\n\n";
|
||||
|
||||
/// Run all cron jobs for each module
|
||||
|
||||
mtrace("Starting activity modules");
|
||||
if ($mods = get_records_select("modules", "cron > 0 AND (($timenow - lastcron) > cron)")) {
|
||||
foreach ($mods as $mod) {
|
||||
$libfile = "$CFG->dirroot/mod/$mod->name/lib.php";
|
||||
@@ -53,18 +47,15 @@
|
||||
include_once($libfile);
|
||||
$cron_function = $mod->name."_cron";
|
||||
if (function_exists($cron_function)) {
|
||||
mtrace("Processing module function $cron_function ...", '');
|
||||
if ($cron_function()) {
|
||||
if (! set_field("modules", "lastcron", $timenow, "id", $mod->id)) {
|
||||
mtrace("Error: could not update timestamp for $mod->fullname");
|
||||
echo "Error: could not update timestamp for $mod->fullname\n";
|
||||
}
|
||||
}
|
||||
mtrace("done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
mtrace("Finished activity modules");
|
||||
|
||||
/// Run all core cron jobs, but not every time since they aren't too important.
|
||||
/// These don't have a timer to reduce load, so we'll use a random number
|
||||
@@ -74,7 +65,7 @@
|
||||
$random100 = rand(0,100);
|
||||
|
||||
if ($random100 < 20) { // Approximately 20% of the time.
|
||||
mtrace("Running clean-up tasks...");
|
||||
echo "Running clean-up tasks...\n";
|
||||
|
||||
/// Unenrol users who haven't logged in for $CFG->longtimenosee
|
||||
|
||||
@@ -83,7 +74,7 @@
|
||||
if ($students = get_users_longtimenosee($longtime)) {
|
||||
foreach ($students as $student) {
|
||||
if (unenrol_student($student->userid, $student->course)) {
|
||||
mtrace("Deleted student enrolment for user $student->userid from course $student->course");
|
||||
echo "Deleted student enrolment for user $student->userid from course $student->course\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -96,11 +87,22 @@
|
||||
if ($users = get_users_unconfirmed($oneweek)) {
|
||||
foreach ($users as $user) {
|
||||
if (delete_records("user", "id", $user->id)) {
|
||||
mtrace("Deleted unconfirmed user for ".fullname($user, true)." ($user->id)");
|
||||
echo "Deleted unconfirmed user for ".fullname($user, true)." ($user->id)\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
flush();
|
||||
|
||||
|
||||
/// Delete duplicate enrolments (don't know what causes these yet - expired sessions?)
|
||||
|
||||
if ($users = get_records_select("user_students", "userid > 0 GROUP BY course, userid ".
|
||||
"HAVING count(*) > 1", "", "*,count(*)")) {
|
||||
foreach ($users as $user) {
|
||||
delete_records_select("user_students", "userid = '$user->userid' ".
|
||||
"AND course = '$user->course' AND id <> '$user->id'");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Delete old logs to save space (this might need a timer to slow it down...)
|
||||
|
||||
@@ -108,7 +110,6 @@
|
||||
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
|
||||
delete_records_select("log", "time < '$loglifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
/// Delete old cached texts
|
||||
|
||||
@@ -116,22 +117,9 @@
|
||||
$cachelifetime = time() - $CFG->cachetext;
|
||||
delete_records_select("cache_text", "timemodified < '$cachelifetime'");
|
||||
}
|
||||
flush();
|
||||
|
||||
if (!empty($CFG->langcache)) {
|
||||
get_list_of_languages();
|
||||
}
|
||||
flush();
|
||||
|
||||
if (!empty($CFG->notifyloginfailures)) {
|
||||
notify_login_failures();
|
||||
}
|
||||
flush();
|
||||
|
||||
} // End of occasional clean-up tasks
|
||||
}
|
||||
|
||||
if (file_exists("$CFG->dataroot/cronextra.php")) {
|
||||
mtrace("Running extra commands in $CFG->dataroot/cronextra.php ...");
|
||||
include("$CFG->dataroot/cronextra.php");
|
||||
}
|
||||
|
||||
@@ -139,7 +127,7 @@
|
||||
//Execute backup's cron
|
||||
//Perhaps a long time and memory could help in large sites
|
||||
@set_time_limit(0);
|
||||
@raise_memory_limit("128M");
|
||||
ini_set("memory_limit","56M");
|
||||
if (file_exists("$CFG->dirroot/backup/backup_scheduled.php") and
|
||||
file_exists("$CFG->dirroot/backup/backuplib.php") and
|
||||
file_exists("$CFG->dirroot/backup/lib.php") and
|
||||
@@ -148,12 +136,13 @@
|
||||
include_once("$CFG->dirroot/backup/backuplib.php");
|
||||
include_once("$CFG->dirroot/backup/lib.php");
|
||||
require_once ("$CFG->libdir/blocklib.php");
|
||||
mtrace("Running backups if required...");
|
||||
echo "Running backups if required...\n";
|
||||
flush();
|
||||
|
||||
if (! schedule_backup_cron()) {
|
||||
mtrace("ERORR: Something went wrong while performing backup tasks!!!");
|
||||
echo "Something went wrong while performing backup tasks!!!\n";
|
||||
} else {
|
||||
mtrace("Backup tasks finished.");
|
||||
echo "Backup tasks finished\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,31 +150,20 @@
|
||||
if (!empty($CFG->enablerssfeeds)) { //Defined in admin/variables page
|
||||
if (file_exists("$CFG->dirroot/rss/rsslib.php")) {
|
||||
include_once("$CFG->dirroot/rss/rsslib.php");
|
||||
mtrace("Running rssfeeds if required...");
|
||||
echo "Running rssfeeds if required...\n";
|
||||
flush();
|
||||
|
||||
if ( ! cron_rss_feeds()) {
|
||||
mtrace("Something went wrong while generating rssfeeds!!!");
|
||||
echo "Something went wrong while generating rssfeeds!!!\n";
|
||||
} else {
|
||||
mtrace("Rssfeeds finished");
|
||||
echo "Rssfeeds finished\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the enrolment cron, if any
|
||||
require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
|
||||
$enrol = new enrolment_plugin();
|
||||
$enrol->cron();
|
||||
if (!empty($enrol->log)) {
|
||||
mtrace($enrol->log);
|
||||
}
|
||||
|
||||
//Unset session variables and destroy it
|
||||
@session_unset();
|
||||
@session_destroy();
|
||||
|
||||
mtrace("Cron script completed correctly");
|
||||
echo "Cron script completed correctly\n";
|
||||
|
||||
$difftime = microtime_diff($starttime, microtime());
|
||||
mtrace("Execution took ".$difftime." seconds");
|
||||
echo "Execution took ".$difftime." seconds\n";
|
||||
|
||||
?>
|
||||
|
||||
+17
-24
@@ -3,38 +3,31 @@
|
||||
// Deletes the moodledata directory, COMPLETELY!!
|
||||
// BE VERY CAREFUL USING THIS!
|
||||
|
||||
require_once('../config.php');
|
||||
require_once("../config.php");
|
||||
|
||||
require_login();
|
||||
|
||||
$sure = optional_param('sure', '');
|
||||
$reallysure = optional_param('reallysure', '');
|
||||
|
||||
if (!isadmin()) {
|
||||
error('You must be admin to use this script!');
|
||||
error("You must be admin to use this script!");
|
||||
}
|
||||
|
||||
$deletedir = $CFG->dataroot; // The directory to delete!
|
||||
|
||||
if (empty($sure)) {
|
||||
notice_yesno ('Are you completely sure you want to delete everything inside the directory '. $deletedir .' ?', 'delete.php?sure=yes&sesskey='.set_user_sesskey(), 'index.php');
|
||||
if (!$sure) {
|
||||
notice_yesno ("Are you completely sure you want to delete everything inside the directory $deletedir ?", "delete.php?sure=yes", "index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (empty($reallysure)) {
|
||||
notice_yesno ('Are you REALLY REALLY completely sure you want to delete everything inside the directory '. $deletedir .' (this includes all user images, and any other course files that have been created) ?', 'delete.php?sure=yes&reallysure=yes&sesskey='.set_user_sesskey(), 'index.php');
|
||||
if (!$reallysure) {
|
||||
notice_yesno ("Are you REALLY REALLY completely sure you want to delete everything inside the directory $deletedir (this includes all user images, and any other course files that have been created) ?", "delete.php?sure=yes&reallysure=yes", "index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error('This script was called wrongly');
|
||||
}
|
||||
|
||||
/// OK, here goes ...
|
||||
|
||||
delete_subdirectories($deletedir);
|
||||
|
||||
echo '<h1 align="center">Done!</h1>';
|
||||
echo "<H1 align=center>Done!</H1>";
|
||||
print_continue($CFG->wwwroot);
|
||||
exit;
|
||||
|
||||
@@ -44,22 +37,22 @@ function delete_subdirectories($rootdir) {
|
||||
$dir = opendir($rootdir);
|
||||
|
||||
while ($file = readdir($dir)) {
|
||||
if ($file != '.' and $file != '..') {
|
||||
$fullfile = $rootdir .'/'. $file;
|
||||
if (filetype($fullfile) == 'dir') {
|
||||
if ($file != "." and $file != "..") {
|
||||
$fullfile = "$rootdir/$file";
|
||||
if (filetype($fullfile) == "dir") {
|
||||
delete_subdirectories($fullfile);
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
echo "Deleting $fullfile ... ";
|
||||
if (rmdir($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
echo "Done.<BR>";
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
echo "FAILED.<BR>";
|
||||
}
|
||||
} else {
|
||||
echo 'Deleting '. $fullfile .' ... ';
|
||||
if (unlink($fullfile)) {
|
||||
echo 'Done.<br />';
|
||||
echo "Deleting $fullfile ... ";
|
||||
if (unlink("$fullfile")) {
|
||||
echo "Done.<BR>";
|
||||
} else {
|
||||
echo 'FAILED.<br />';
|
||||
echo "FAILED.<BR>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
<form method="post" action="editor.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table border="0" cellpadding="4" cellspacing="2">
|
||||
<tr valign=top>
|
||||
<td align=right><p>htmleditor:</td>
|
||||
<td>
|
||||
<?php
|
||||
unset($options);
|
||||
$options[0] = get_string("allownot");
|
||||
$options[1] = get_string("allow");
|
||||
choose_from_menu ($options, "htmleditor", $CFG->htmleditor, "", "", "");
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("confightmleditor") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorbackgroundcolor:</td>
|
||||
<td valign="top"><input type="text" name="backgroundcolor" size="10" value="<?php print($CFG->editorbackgroundcolor);?>"></td>
|
||||
<td valign="top"><?php print_string("edhelpbgcolor");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorfontfamily:</td>
|
||||
<td valign="top"><input type="text" name="fontfamily" size="30" value="<?php print($CFG->editorfontfamily);?>"></td>
|
||||
<td valign="top"><?php print_string("edhelpfontfamily");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorfontsize:</td>
|
||||
<td valign="top"><input type="text" name="fontsize" size="10" value="<?php print($CFG->editorfontsize);?>"></td>
|
||||
<td valign="top"><?php print_string("edhelpfontsize");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorkillword:</td>
|
||||
<td valign="top"><select name="killword">
|
||||
<option value="1"<?php print(!$CFG->editorkillword)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
|
||||
<option value="0"<?php print(!$CFG->editorkillword)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
|
||||
</select></td>
|
||||
<td valign="top"><?php print_string("edhelpcleanword");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top">editorspelling:</td>
|
||||
<td valign="top"><select name="spelling"<?php
|
||||
if (empty($CFG->aspellpath)) {
|
||||
echo " disabled=\"disabled\"";
|
||||
$CFG->editorspelling = false;
|
||||
}
|
||||
?>>
|
||||
<option value="1"<?php print(!$CFG->editorspelling)?"":" selected=\"selected\"";?>><?php print_string("yes");?></option>
|
||||
<option value="0"<?php print(!$CFG->editorspelling)?" selected=\"selected\"":"";?>><?php print_string("no");?></option>
|
||||
</select></td>
|
||||
<td valign="top"><?php print_string("edhelpenablespelling");?></td>
|
||||
</tr>
|
||||
<tr><td colspan="3"><br /><?php print_string("edhelpfontlist");?></td></tr>
|
||||
<?php
|
||||
if(is_array($fontlist)) {
|
||||
foreach($fontlist as $fontkey => $fontvalue) {
|
||||
?>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="<?php print($fontkey);?>">
|
||||
<input type="text" name="fontnamevalue[]" size="30" value="<?php print($fontvalue);?>"></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td colspan="2"><input type="text" name="fontname[]" size="15" value="">
|
||||
<input type="text" name="fontnamevalue[]" size="30" value=""></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center"><input type="submit" value="<?php print_string("savechanges");?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<form method="post" action="<?php print($GLOBALS['ME']);?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<center>
|
||||
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
|
||||
</center>
|
||||
</form>
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
<?php // $Id$
|
||||
/// configuration routines for HTMLArea editor
|
||||
|
||||
require_once("../config.php");
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only admins can access this page");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if ($data = data_submitted()) {
|
||||
|
||||
// do we want default values?
|
||||
if (isset($data->resettodefaults)) {
|
||||
if(!(reset_to_defaults())) {
|
||||
error("Editor settings could not be restored!");
|
||||
}
|
||||
} else {
|
||||
|
||||
if(!(editor_update_config($data))) {
|
||||
error("Editor settings could not be updated!");
|
||||
}
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/editor.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
|
||||
} else {
|
||||
// Generate edit form
|
||||
|
||||
$fontlist = editor_convert_to_array($CFG->editorfontlist);
|
||||
|
||||
$stradmin = get_string("administration");
|
||||
$strconfiguration = get_string("configuration");
|
||||
$streditorsettings = get_string("editorsettings");
|
||||
$streditorsettingshelp = get_string("adminhelpeditorsettings");
|
||||
print_header("Editor settings","Editor settings",
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $streditorsettings");
|
||||
print_heading($streditorsettings);
|
||||
print_simple_box("<center>$streditorsettingshelp</center>","center","50%");
|
||||
print("<br />\n");
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("editor.html");
|
||||
print_simple_box_end();
|
||||
print_footer();
|
||||
}
|
||||
|
||||
|
||||
/// FUNCTIONS
|
||||
|
||||
function editor_convert_to_array ($string) {
|
||||
/// Converts $CFG->editorfontlist to array
|
||||
|
||||
if(empty($string) || !is_string($string)) {
|
||||
return false;
|
||||
}
|
||||
$fonts = array();
|
||||
|
||||
$lines = explode(";", $string);
|
||||
foreach($lines as $line) {
|
||||
if(!empty($line)) {
|
||||
list($fontkey, $fontvalue) = explode(":", $line);
|
||||
$fonts[$fontkey] = $fontvalue;
|
||||
}
|
||||
}
|
||||
|
||||
return $fonts;
|
||||
}
|
||||
|
||||
function editor_update_config ($data) {
|
||||
/// Updates the editor config values.
|
||||
|
||||
if(!is_object($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make array for unwanted characters.
|
||||
$nochars = array(chr(33),chr(34),chr(35),chr(36),chr(37),
|
||||
chr(38),chr(39),chr(40),chr(41),chr(42),
|
||||
chr(43),chr(46),chr(47),chr(58),chr(59),
|
||||
chr(60),chr(61),chr(62),chr(63),chr(64),
|
||||
chr(91),chr(92),chr(93),chr(94),chr(95),
|
||||
chr(96),chr(123),chr(124),chr(125),chr(126));
|
||||
|
||||
$fontlist = '';
|
||||
|
||||
// make font string
|
||||
for($i = 0; $i < count($data->fontname); $i++) {
|
||||
if(!empty($data->fontname[$i])) {
|
||||
$fontlist .= str_replace($nochars, "", $data->fontname[$i]) .":";
|
||||
$fontlist .= str_replace($nochars, "", $data->fontnamevalue[$i]) .";";
|
||||
}
|
||||
}
|
||||
// strip last semicolon
|
||||
$fontlist = substr($fontlist, 0, strlen($fontlist) - 1);
|
||||
|
||||
// make array of values to update
|
||||
$updatedata = array();
|
||||
$updatedata['htmleditor'] = $data->htmleditor;
|
||||
$updatedata['editorbackgroundcolor'] = !empty($data->backgroundcolor) ? $data->backgroundcolor : "#ffffff";
|
||||
$updatedata['editorfontfamily'] = !empty($data->fontfamily) ? str_replace($nochars,"",$data->fontfamily) : "Times New Roman, Times";
|
||||
$updatedata['editorfontsize'] = !empty($data->fontsize) ? $data->fontsize : "";
|
||||
$updatedata['editorkillword'] = !empty($data->killword) ? $data->killword : "true";
|
||||
$updatedata['editorspelling'] = !empty($data->spelling) ? $data->spelling : 0;
|
||||
$updatedata['editorfontlist'] = $fontlist;
|
||||
|
||||
foreach($updatedata as $name => $value) {
|
||||
if(!(set_config($name, $value))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset_to_defaults () {
|
||||
global $CFG;
|
||||
include_once($CFG->dirroot .'/lib/defaults.php');
|
||||
|
||||
$updatedata = array();
|
||||
|
||||
$updatedata['htmleditor'] = $defaults['htmleditor'];
|
||||
$updatedata['editorbackgroundcolor'] = $defaults['editorbackgroundcolor'];
|
||||
$updatedata['editorfontfamily'] = $defaults['editorfontfamily'];
|
||||
$updatedata['editorfontsize'] = $defaults['editorfontsize'];
|
||||
$updatedata['editorkillword'] = $defaults['editorkillword'];
|
||||
$updatedata['editorspelling'] = $defaults['editorspelling'];
|
||||
$updatedata['editorfontlist'] = $defaults['editorfontlist'];
|
||||
|
||||
foreach($updatedata as $name => $value) {
|
||||
if(!(set_config($name, $value))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
?>
|
||||
@@ -1,89 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
// enrol.php - allows admin to edit all enrollment variables
|
||||
// Yes, enrol is correct English spelling.
|
||||
|
||||
include("../config.php");
|
||||
|
||||
$enrol = optional_param('enrol', $CFG->enrol);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
$enrol = clean_filename($enrol);
|
||||
require_once("$CFG->dirroot/enrol/$enrol/enrol.php"); /// Open the class
|
||||
|
||||
$enrolment = new enrolment_plugin();
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($frm = data_submitted()) {
|
||||
if ($enrolment->process_config($frm)) {
|
||||
set_config('enrol', $frm->enrol);
|
||||
redirect("enrol.php?sesskey=$USER->sesskey", get_string("changessaved"), 1);
|
||||
}
|
||||
} else {
|
||||
$frm = $CFG;
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
|
||||
|
||||
|
||||
$modules = get_list_of_plugins("enrol");
|
||||
foreach ($modules as $module) {
|
||||
$options[$module] = get_string("enrolname", "enrol_$module");
|
||||
}
|
||||
asort($options);
|
||||
|
||||
print_header("$site->shortname: $str->enrolments", "$site->fullname",
|
||||
"<a href=\"index.php\">$str->administration</a> ->
|
||||
<a href=\"users.php\">$str->users</a> -> $str->enrolments");
|
||||
|
||||
echo "<form target=\"{$CFG->framename}\" name=\"enrolmenu\" method=\"post\" action=\"enrol.php\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">";
|
||||
echo "<div align=\"center\"><p><b>";
|
||||
|
||||
|
||||
/// Choose an enrolment method
|
||||
echo get_string('chooseenrolmethod').': ';
|
||||
choose_from_menu ($options, "enrol", $enrol, "",
|
||||
"document.location='enrol.php?sesskey=$USER->sesskey&enrol='+document.enrolmenu.enrol.options[document.enrolmenu.enrol.selectedIndex].value", "");
|
||||
|
||||
echo "</b></p></div>";
|
||||
|
||||
/// Print current enrolment type description
|
||||
print_simple_box_start("center", "80%", "$THEME->cellheading");
|
||||
print_heading($options[$enrol]);
|
||||
|
||||
print_simple_box_start("center", "60%", "$THEME->cellcontent");
|
||||
print_string("description", "enrol_$enrol");
|
||||
print_simple_box_end();
|
||||
|
||||
echo "<hr>";
|
||||
// print_heading($str->settings);
|
||||
|
||||
$enrolment->config_form($frm);
|
||||
|
||||
echo "<center><p><input type=\"submit\" value=\"".get_string("savechanges")."\"></p></center>\n";
|
||||
echo "</form>";
|
||||
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
exit;
|
||||
?>
|
||||
@@ -1,7 +1,6 @@
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="filters" id="filters" method="post" action="filters.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<table align="center" border="0" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<td valign="top"><div align="right">
|
||||
@@ -81,7 +80,6 @@
|
||||
<?php print_simple_box_start("center", "", "$THEME->cellheading"); ?>
|
||||
|
||||
<form name="options" id="options" method="post" action="filters.php">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $USER->sesskey ?>">
|
||||
<input type="hidden" name="options" value="1">
|
||||
<table cellpadding="20">
|
||||
<tr valign=top>
|
||||
|
||||
@@ -10,16 +10,11 @@
|
||||
optional_variable($up);
|
||||
optional_variable($down);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$site = get_site()) {
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
+151
-59
@@ -1,13 +1,13 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
/// Check that config.php exists, if not then call the install script
|
||||
/// Check that config.php exists
|
||||
if (!file_exists("../config.php")) {
|
||||
header('Location: ../install.php');
|
||||
echo "<H2 align=center>You need to create a config.php.<BR>
|
||||
See the <A HREF=\"http://moodle.com/doc/?frame=install.html\">installation instructions</A>.</H2>";
|
||||
die;
|
||||
}
|
||||
|
||||
require_once("../config.php");
|
||||
include_once("$CFG->dirroot/lib/adminlib.php"); // Contains various admin-only functions
|
||||
|
||||
|
||||
/// Check that PHP is of a sufficient version
|
||||
@@ -122,26 +122,6 @@
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/// Insert default values for any important configuration variables
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php");
|
||||
}
|
||||
|
||||
|
||||
/// Check version of Moodle code on disk compared with database
|
||||
/// and upgrade if possible.
|
||||
|
||||
@@ -223,14 +203,133 @@
|
||||
|
||||
/// Check all blocks and load (or upgrade them if necessary)
|
||||
upgrade_blocks_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Check all enrolment plugins and upgrade if necessary
|
||||
upgrade_enrol_plugins("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
|
||||
/// Find and check all main modules and load them up or upgrade them if necessary
|
||||
upgrade_activity_modules("$CFG->wwwroot/$CFG->admin/index.php"); // Return here afterwards
|
||||
/// Find and check all modules and load them up or upgrade them if necessary
|
||||
|
||||
if (!$mods = get_list_of_plugins("mod") ) {
|
||||
error("No modules installed!");
|
||||
}
|
||||
|
||||
foreach ($mods as $mod) {
|
||||
|
||||
if ($mod == "NEWMODULE") { // Someone has unzipped the template, ignore it
|
||||
continue;
|
||||
}
|
||||
|
||||
$fullmod = "$CFG->dirroot/mod/$mod";
|
||||
|
||||
unset($module);
|
||||
|
||||
if ( is_readable("$fullmod/version.php")) {
|
||||
include_once("$fullmod/version.php"); # defines $module with version etc
|
||||
} else {
|
||||
notify("Module $mod: $fullmod/version.php was not readable");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_readable("$fullmod/db/$CFG->dbtype.php")) {
|
||||
include_once("$fullmod/db/$CFG->dbtype.php"); # defines upgrading function
|
||||
} else {
|
||||
notify("Module $mod: $fullmod/db/$CFG->dbtype.php was not readable");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($module)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!empty($module->requires)) {
|
||||
if ($module->requires > $CFG->version) {
|
||||
$info->modulename = $mod;
|
||||
$info->moduleversion = $module->version;
|
||||
$info->currentmoodle = $CFG->version;
|
||||
$info->requiremoodle = $module->requires;
|
||||
notify(get_string('modulerequirementsnotmet', 'error', $info));
|
||||
unset($info);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$module->name = $mod; // The name MUST match the directory
|
||||
|
||||
if ($currmodule = get_record("modules", "name", $module->name)) {
|
||||
if ($currmodule->version == $module->version) {
|
||||
// do nothing
|
||||
} else if ($currmodule->version < $module->version) {
|
||||
if (empty($updated_modules)) {
|
||||
$strmodulesetup = get_string("modulesetup");
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, " ", " ");
|
||||
}
|
||||
print_heading("$module->name module needs upgrading");
|
||||
$upgrade_function = $module->name."_upgrade";
|
||||
if (function_exists($upgrade_function)) {
|
||||
$db->debug=true;
|
||||
if ($upgrade_function($currmodule->version, $module)) {
|
||||
$db->debug=false;
|
||||
// OK so far, now update the modules record
|
||||
$module->id = $currmodule->id;
|
||||
if (! update_record("modules", $module)) {
|
||||
error("Could not update $module->name record in modules table!");
|
||||
}
|
||||
notify(get_string("modulesuccess", "", $module->name), "green");
|
||||
echo "<HR>";
|
||||
} else {
|
||||
$db->debug=false;
|
||||
notify("Upgrading $module->name from $currmodule->version to $module->version FAILED!");
|
||||
}
|
||||
}
|
||||
$updated_modules = true;
|
||||
} else {
|
||||
error("Version mismatch: $module->name can't downgrade $currmodule->version -> $module->version !");
|
||||
}
|
||||
|
||||
} else { // module not installed yet, so install it
|
||||
if (empty($updated_modules)) {
|
||||
$strmodulesetup = get_string("modulesetup");
|
||||
print_header($strmodulesetup, $strmodulesetup, $strmodulesetup, "", "", false, " ", " ");
|
||||
}
|
||||
print_heading($module->name);
|
||||
$updated_modules = true;
|
||||
$db->debug = true;
|
||||
@set_time_limit(0); // To allow slow databases to complete the long SQL
|
||||
if (modify_database("$fullmod/db/$CFG->dbtype.sql")) {
|
||||
$db->debug = false;
|
||||
if ($module->id = insert_record("modules", $module)) {
|
||||
notify(get_string("modulesuccess", "", $module->name), "green");
|
||||
echo "<HR>";
|
||||
} else {
|
||||
error("$module->name module could not be added to the module list!");
|
||||
}
|
||||
} else {
|
||||
error("$module->name tables could NOT be set up successfully!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($updated_modules)) {
|
||||
print_continue("index.php");
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/// Insert default values for any important configuration variables
|
||||
|
||||
include_once("$CFG->dirroot/lib/defaults.php");
|
||||
|
||||
foreach ($defaults as $name => $value) {
|
||||
if (!isset($CFG->$name)) {
|
||||
$CFG->$name = $value;
|
||||
set_config($name, $value);
|
||||
$configchange = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// If any new configurations were found then send to the config page to check
|
||||
|
||||
if (!empty($configchange)) {
|
||||
redirect("config.php");
|
||||
}
|
||||
|
||||
/// Set up the overall site name etc.
|
||||
if (! $site = get_site()) {
|
||||
@@ -249,6 +348,7 @@
|
||||
error("You need to be an admin user to use this page.", "$CFG->wwwroot/login/index.php");
|
||||
}
|
||||
|
||||
|
||||
/// At this point everything is set up and the user is an admin, so print menu
|
||||
|
||||
$stradministration = get_string("administration");
|
||||
@@ -262,12 +362,6 @@
|
||||
print_spacer(10,10);
|
||||
}
|
||||
|
||||
/// If no recently cron run
|
||||
$lastcron = get_field_sql('SELECT max(lastcron) FROM ' . $CFG->prefix . 'modules');
|
||||
if (time() - $lastcron > 3600 * 24) {
|
||||
print_simple_box(get_string('cronwarning', 'admin') , 'center');
|
||||
}
|
||||
|
||||
$table->tablealign = "right";
|
||||
$table->align = array ("right", "left");
|
||||
$table->wrap = array ("nowrap", "nowrap");
|
||||
@@ -287,46 +381,43 @@
|
||||
get_string("adminhelpmanagemodules")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"blocks.php\">".get_string("manageblocks")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanageblocks")."</font><br />";
|
||||
$configdata .= "<font size=+1> </font><a href=\"filters.php?sesskey=$USER->sesskey\">".get_string("managefilters")."</a> - <font size=1>".
|
||||
$configdata .= "<font size=+1> </font><a href=\"filters.php\">".get_string("managefilters")."</a> - <font size=1>".
|
||||
get_string("adminhelpmanagefilters")."</font><br />";
|
||||
if (!isset($CFG->disablescheduledbackups)) {
|
||||
$configdata .= "<font size=+1> </font><a href=\"backup.php?sesskey=$USER->sesskey\">".get_string("backup")."</a> - <font size=1>".
|
||||
$configdata .= "<font size=+1> </font><a href=\"backup.php\">".get_string("backup")."</a> - <font size=1>".
|
||||
get_string("adminhelpbackup")."</font><br />";
|
||||
}
|
||||
$configdata .= "<font size=+1> </font><a href=\"editor.php?sesskey=$USER->sesskey\">". get_string("editorsettings") ."</a> - <font size=1>".
|
||||
get_string("adminhelpeditorsettings")."</font><br />";
|
||||
|
||||
$table->data[] = array("<font size=+1><b><a href=\"configure.php\">".get_string("configuration")."</a></b>",
|
||||
$configdata);
|
||||
|
||||
|
||||
$userdata = "<font size=+1> </font><a href=\"auth.php?sesskey=$USER->sesskey\">".get_string("authentication")."</a> - <font size=1>".
|
||||
$userdata = "<font size=+1> </font><a href=\"auth.php\">".get_string("authentication")."</a> - <font size=1>".
|
||||
get_string("adminhelpauthentication")."</font><br />";
|
||||
|
||||
if (is_internal_auth()) {
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true\">".
|
||||
get_string("addnewuser")."</a> - <font size=1>".
|
||||
get_string("adminhelpaddnewuser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php\">".
|
||||
get_string("uploadusers")."</a> - <font size=1>".
|
||||
get_string("adminhelpuploadusers")."</font><br />";
|
||||
}
|
||||
$userdata .= "<font size=+1> </font><a href=\"user.php\">".get_string("edituser")."</a> - <font size=1>".
|
||||
get_string("adminhelpedituser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".
|
||||
get_string("addnewuser")."</a> - <font size=1>".
|
||||
get_string("adminhelpaddnewuser")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".
|
||||
get_string("uploadusers")."</a> - <font size=1>".
|
||||
get_string("adminhelpuploadusers")."</font><br />";
|
||||
|
||||
$userdata .= "<hr><font size=+1> </font><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a> - <font size=1>".
|
||||
get_string("adminhelpenrolments")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignstudents")."</font><br />";
|
||||
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a> - <font size=1>".
|
||||
$userdata .= "<font size=+1> </font><a href=\"admin.php\">".get_string("assignadmins")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignadmins")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"creators.php\">".get_string("assigncreators")."</a> - <font size=1>".
|
||||
get_string("adminhelpassigncreators")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=on\">".get_string("assignteachers")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignteachers").
|
||||
" <img src=\"../pix/t/user.gif\" height=11 width=11></font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a> - <font size=1>".
|
||||
get_string("adminhelpassigncreators")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignadmins")."</font><br />";
|
||||
$userdata .= "<font size=+1> </font><a href=\"../course/index.php?edit=off\">".get_string("assignstudents")."</a> - <font size=1>".
|
||||
get_string("adminhelpassignstudents")."</font>";
|
||||
|
||||
$table->data[] = array("<font size=+1><b><a href=\"users.php\">".get_string("users")."</a></b>", $userdata);
|
||||
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("courses")."</a></b>",
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/index.php?edit=on\">".get_string("courses")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelpcourses"));
|
||||
$table->data[] = array("<font size=+1><b><a href=\"../course/log.php?id=$site->id\">".get_string("logs")."</a></b>",
|
||||
"<font size=+1> </font>".get_string("adminhelplogs"));
|
||||
@@ -359,8 +450,7 @@
|
||||
echo "</td>";
|
||||
|
||||
echo "<td align=center width=33%>";
|
||||
$options['sesskey'] = $USER->sesskey;
|
||||
print_single_button("register.php", $options, get_string("registration"));
|
||||
print_single_button("register.php", NULL, get_string("registration"));
|
||||
echo "</td>";
|
||||
echo "<tr></table>";
|
||||
|
||||
@@ -369,3 +459,5 @@
|
||||
print_footer($site);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
+23
-41
@@ -27,23 +27,14 @@
|
||||
case "missing":
|
||||
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strmissingstrings";
|
||||
$title = $strmissingstrings;
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="compare" />'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
|
||||
'<input type="submit" value="'.$strcomparelanguage.'" /></form>';
|
||||
break;
|
||||
case "compare":
|
||||
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strcomparelanguage";
|
||||
$title = $strcomparelanguage;
|
||||
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/'.$CFG->admin.'/lang.php">'.
|
||||
'<input type="hidden" name="mode" value="missing" />'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />'.
|
||||
'<input type="submit" value="'.$strmissingstrings.'" /></form>';
|
||||
break;
|
||||
default:
|
||||
$title = $strlanguage;
|
||||
$navigation = $strlanguage;
|
||||
$button = '';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -51,8 +42,7 @@
|
||||
|
||||
print_header("$site->shortname: $title", "$site->fullname",
|
||||
"<a href=\"index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $navigation",
|
||||
'', '', true, $button);
|
||||
"<a href=\"configure.php\">$strconfiguration</a> -> $navigation");
|
||||
|
||||
if (!$mode) {
|
||||
$currlang = current_language();
|
||||
@@ -60,10 +50,10 @@
|
||||
echo "<table align=center><tr><td align=\"right\">";
|
||||
echo "<b>$strcurrentlanguage:</b>";
|
||||
echo "</td><td>";
|
||||
echo popup_form ("$CFG->wwwroot/$CFG->admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
echo popup_form ("$CFG->wwwroot/admin/lang.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
echo "</td></tr></table>";
|
||||
print_heading("<a href=\"lang.php?mode=missing&sesskey=$USER->sesskey\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare&sesskey=$USER->sesskey\">$strcomparelanguage</a>");
|
||||
print_heading("<a href=\"lang.php?mode=missing\">$strmissingstrings</a>");
|
||||
print_heading("<a href=\"lang.php?mode=compare\">$strcomparelanguage</a>");
|
||||
echo "<center><hr noshade size=1>";
|
||||
$options["lang"] = $currentlang;
|
||||
print_single_button("http://moodle.org/download/lang/", $options, get_string("latestlanguagepack"));
|
||||
@@ -87,7 +77,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($mode == "missing" and confirm_sesskey()) {
|
||||
if ($mode == "missing") {
|
||||
// For each file, check that a counterpart exists, then check all the strings
|
||||
|
||||
foreach ($stringfiles as $file) {
|
||||
@@ -112,18 +102,15 @@
|
||||
$value = str_replace("$"."a", "\\$"."a", $value);
|
||||
$value = str_replace("%%","%",$value);
|
||||
if ($first) {
|
||||
echo "<p><b>".get_string("stringsnotset","","$langdir/$file")."</b></p><pre>";
|
||||
echo "</PRE><HR><P><B>".get_string("stringsnotset","","$langdir/$file")."</B></P><PRE>";
|
||||
$first = false;
|
||||
$somethingfound = true;
|
||||
}
|
||||
echo "$"."string['$key'] = \"$value\";<br />";
|
||||
echo "$"."string['$key'] = \"$value\";<BR>";
|
||||
}
|
||||
}
|
||||
if (!$first) {
|
||||
echo '</pre><hr />';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $files = get_directory_list("$CFG->dirroot/lang/en/help", "CVS")) {
|
||||
error("Could not find English language help files!");
|
||||
}
|
||||
@@ -153,7 +140,7 @@
|
||||
notice(get_string("languagegood"), "lang.php");
|
||||
}
|
||||
|
||||
} else if ($mode == "compare" and confirm_sesskey()) {
|
||||
} else if ($mode == "compare") {
|
||||
|
||||
if (isset($_POST['currentfile'])){ // Save a file
|
||||
$newstrings = $_POST;
|
||||
@@ -161,7 +148,7 @@
|
||||
if (lang_save_file($langdir, $currentfile, $newstrings)) {
|
||||
notify(get_string("changessaved")." ($langdir/$currentfile)", "green");
|
||||
} else {
|
||||
error("Could not save the file '$currentfile'!", "lang.php?mode=compare¤tfile=$currentfile&sesskey=$USER->sesskey");
|
||||
error("Could not save the file '$currentfile'!", "lang.php?mode=compare¤tfile=$currentfile");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,7 +160,7 @@
|
||||
if ($file == $currentfile) {
|
||||
echo "<b>$file</b> ";
|
||||
} else {
|
||||
echo "<a href=\"lang.php?mode=compare¤tfile=$file&sesskey=$USER->sesskey\">$file</a> ";
|
||||
echo "<a href=\"lang.php?mode=compare¤tfile=$file\">$file</a> ";
|
||||
}
|
||||
}
|
||||
echo '</font></center>';
|
||||
@@ -203,12 +190,6 @@
|
||||
unset($string);
|
||||
include("$enlangdir/$currentfile");
|
||||
$enstring = $string;
|
||||
if ($currentlang != 'en' and $currentfile == 'moodle.php') {
|
||||
$enstring['thislanguage'] = "<< TRANSLATORS: Specify the name of your language here. If possible use Unicode Numeric Character References >>";
|
||||
$enstring['thischarset'] = "<< TRANSLATORS: Specify the character set of your language here. Note that all text created while this language is active will be stored using this character set, so don't change it once you have set it. Example: iso-8859-1 >>";
|
||||
$enstring['thisdirection'] = "<< TRANSLATORS: This string specifies the direction of your text, either left-to-right or right-to-left. Insert either 'ltr' or 'rtl' here. >>";
|
||||
$enstring['parentlanguage'] = "<< TRANSLATORS: If your language has a Parent Language that Moodle should use when strings are missing from your language pack, then specify the code for it here. If you leave this blank then English will be used. Example: nl >>";
|
||||
}
|
||||
ksort($enstring);
|
||||
|
||||
unset($string);
|
||||
@@ -216,7 +197,6 @@
|
||||
|
||||
if ($editable) {
|
||||
echo "<form name=\"$currentfile\" action=\"lang.php\" method=\"post\">";
|
||||
echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
|
||||
}
|
||||
echo "<table width=\"100%\" cellpadding=2 cellspacing=3 border=0>";
|
||||
foreach ($enstring as $key => $envalue) {
|
||||
@@ -225,24 +205,26 @@
|
||||
$envalue = str_replace("%%","%",$envalue);
|
||||
$envalue = str_replace("\\","",$envalue); // Delete all slashes
|
||||
|
||||
echo "\n\n<tr>";
|
||||
echo "<td dir=ltr lang=en width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>\n";
|
||||
echo "<td dir=ltr lang=en width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>\n";
|
||||
echo "<tr>";
|
||||
echo "<td dir=ltr lang=en width=20% bgcolor=\"$THEME->cellheading\" nowrap valign=top>$key</td>";
|
||||
echo "<td dir=ltr lang=en width=40% bgcolor=\"$THEME->cellheading\" valign=top>$envalue</td>";
|
||||
|
||||
$value = $string[$key];
|
||||
$value = str_replace("\r","",$value); // Bad character caused by Windows
|
||||
$value = preg_replace("/\n{3,}/", "\n\n", $value); // Collapse runs of blank lines
|
||||
$value = trim($value, "\n"); // Delete leading/trailing lines
|
||||
$value = str_replace("\n\n\n\n\n\n","\n",$value); // Collapse runs of blank lines
|
||||
$value = str_replace("\n\n\n\n\n","\n",$value);
|
||||
$value = str_replace("\n\n\n\n","\n",$value);
|
||||
$value = str_replace("\n\n\n","\n",$value);
|
||||
$value = str_replace("\n\n\n","\n",$value);
|
||||
$value = str_replace("\\","",$value); // Delete all slashes
|
||||
$value = str_replace("%%","%",$value);
|
||||
$value = str_replace("<","<",$value);
|
||||
$value = str_replace(">",">",$value);
|
||||
$value = str_replace('"',""",$value);
|
||||
|
||||
$cellcolour = $value ? $THEME->cellcontent: $THEME->highlight;
|
||||
|
||||
if ($editable) {
|
||||
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>\n";
|
||||
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>";
|
||||
if (isset($string[$key])) {
|
||||
$valuelen = strlen($value);
|
||||
} else {
|
||||
@@ -251,17 +233,17 @@
|
||||
$cols=50;
|
||||
if (strstr($value, "\r") or strstr($value, "\n") or $valuelen > $cols) {
|
||||
$rows = ceil($valuelen / $cols);
|
||||
echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>\n";
|
||||
echo "<textarea name=\"string-$key\" cols=\"$cols\" rows=\"$rows\">$value</textarea>";
|
||||
} else {
|
||||
if ($valuelen) {
|
||||
$cols = $valuelen + 2;
|
||||
}
|
||||
echo "<input type=\"text\" name=\"string-$key\" value=\"$value\" size=\"$cols\"></td>";
|
||||
}
|
||||
echo "</TD>\n";
|
||||
echo "</TD>";
|
||||
|
||||
} else {
|
||||
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>\n";
|
||||
echo "<td width=40% bgcolor=\"$cellcolour\" valign=top>$value</td>";
|
||||
}
|
||||
}
|
||||
if ($editable) {
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
error("Site isn't defined!");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
@@ -32,7 +29,6 @@
|
||||
|
||||
require_variable($module);
|
||||
|
||||
$module = clean_filename($module);
|
||||
require_once("$CFG->dirroot/mod/$module/lib.php");
|
||||
|
||||
|
||||
|
||||
+8
-10
@@ -9,8 +9,6 @@
|
||||
optional_variable($delete);
|
||||
optional_variable($confirm);
|
||||
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only administrators can use this page!");
|
||||
}
|
||||
@@ -42,7 +40,7 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if (!empty($hide) and confirm_sesskey()) {
|
||||
if (!empty($hide)) {
|
||||
if (!$module = get_record("modules", "name", $hide)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
@@ -50,7 +48,7 @@
|
||||
set_field("course_modules", "visible", "0", "module", $module->id); // Hide all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($show) and confirm_sesskey()) {
|
||||
if (!empty($show)) {
|
||||
if (!$module = get_record("modules", "name", $show)) {
|
||||
error("Module doesn't exist!");
|
||||
}
|
||||
@@ -58,13 +56,13 @@
|
||||
set_field("course_modules", "visible", "1", "module", $module->id); // Show all related activity modules
|
||||
}
|
||||
|
||||
if (!empty($delete) and confirm_sesskey()) {
|
||||
if (!empty($delete)) {
|
||||
|
||||
$strmodulename = get_string("modulename", "$delete");
|
||||
|
||||
if (empty($confirm)) {
|
||||
notice_yesno(get_string("moduledeleteconfirm", "", $strmodulename),
|
||||
"modules.php?delete=$delete&confirm=$delete&sesskey=$USER->sesskey",
|
||||
"modules.php?delete=$delete&confirm=$delete",
|
||||
"modules.php");
|
||||
print_footer();
|
||||
exit;
|
||||
@@ -162,10 +160,10 @@
|
||||
|
||||
$icon = "<img src=\"$modpixpath/$module->name/icon.gif\" hspace=10 height=16 width=16 border=0>";
|
||||
|
||||
$delete = "<a href=\"modules.php?delete=$module->name&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
$delete = "<a href=\"modules.php?delete=$module->name\">$strdelete</a>";
|
||||
|
||||
if (file_exists("$CFG->dirroot/mod/$module->name/config.html")) {
|
||||
$settings = "<a href=\"module.php?module=$module->name&sesskey=$USER->sesskey\">$strsettings</a>";
|
||||
$settings = "<a href=\"module.php?module=$module->name\">$strsettings</a>";
|
||||
} else {
|
||||
$settings = "";
|
||||
}
|
||||
@@ -173,11 +171,11 @@
|
||||
$count = count_records("$module->name");
|
||||
|
||||
if ($module->visible) {
|
||||
$visible = "<a href=\"modules.php?hide=$module->name&sesskey=$USER->sesskey\" title=\"$strhide\">".
|
||||
$visible = "<a href=\"modules.php?hide=$module->name\" title=\"$strhide\">".
|
||||
"<img src=\"$pixpath/i/hide.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "";
|
||||
} else {
|
||||
$visible = "<a href=\"modules.php?show=$module->name&sesskey=$USER->sesskey\" title=\"$strshow\">".
|
||||
$visible = "<a href=\"modules.php?show=$module->name\" title=\"$strshow\">".
|
||||
"<img src=\"$pixpath/i/show.gif\" align=\"absmiddle\" height=16 width=16 border=0></a>";
|
||||
$class = "class=\"dimmed_text\"";
|
||||
}
|
||||
|
||||
+8
-8
@@ -13,10 +13,6 @@
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
error("No admins");
|
||||
}
|
||||
@@ -25,8 +21,12 @@
|
||||
$admin->country = $CFG->country;
|
||||
}
|
||||
|
||||
if (empty($CFG->siteidentifier)) { // Unique site identification code
|
||||
set_config('siteidentifier', random_string(32));
|
||||
if (!$admin->secret) { // secret field hasn't been set yet
|
||||
$admin->secret = random_string(15);
|
||||
|
||||
if (!set_field("user", "secret", $admin->secret, "id", $admin->id)) {
|
||||
error("Could not set admin's secret string!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
print_header("$site->shortname: $strregistration", "$site->fullname",
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strregistration");
|
||||
|
||||
print_heading($strregistration);
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
print_simple_box($strregistrationinfo, "center", "70%");
|
||||
echo "<br />";
|
||||
@@ -60,7 +60,7 @@
|
||||
echo "<!-- is flagged as a new entry and will be manually checked by the list maintainer -->\n";
|
||||
|
||||
echo "<input type=\"hidden\" name=\"url\" value=\"$CFG->wwwroot\">\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$CFG->siteidentifier\">\n";
|
||||
echo "<input type=\"hidden\" name=\"secret\" value=\"$admin->secret\">\n";
|
||||
echo "<input type=\"hidden\" name=\"host\" value=\"".$_SERVER["HTTP_HOST"]."\">\n";
|
||||
echo "<input type=\"hidden\" name=\"lang\" value=\"".current_language()."\">\n";
|
||||
echo "</td></tr>\n";
|
||||
|
||||
+25
-30
@@ -1,14 +1,14 @@
|
||||
<form method="post" action="site.php" name="form">
|
||||
<form method="post" action="site.php" name="form" <?php echo $onsubmit ?>>
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("fullsitename") ?>:</td>
|
||||
<td><input type="text" name="fullname" size="50" maxlength="254" value="<?php p($form->fullname) ?>">
|
||||
<td><input type="text" name="fullname" size=50 value="<?php p($form->fullname) ?>">
|
||||
<?php if (isset($err["fullname"])) formerr($err["fullname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><P><?php print_string("shortsitename") ?>:</td>
|
||||
<td><input type="text" name="shortname" size="15" maxlength="15" value="<?php p($form->shortname) ?>">
|
||||
<td><input type="text" name="shortname" size=50 value="<?php p($form->shortname) ?>">
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -66,42 +66,32 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("sitesection") ?>:</td>
|
||||
<td><?php
|
||||
unset($choices);
|
||||
$choices["0"] = get_string("no");
|
||||
$choices["1"] = get_string("yes");
|
||||
choose_from_menu ($choices, "numsections", $form->numsections, "");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" maxlength="100" size="25" value="<?php p($form->teacher) ?>">
|
||||
(<?php print_string("wordforteachereg") ?>)
|
||||
<td align=right><p><?php print_string("wordforteacher") ?>:</td>
|
||||
<td><input type="text" name="teacher" maxlength="100" size=25 value="<?php p($form->teacher) ?>">
|
||||
(<?php print_string("wordforteachereg") ?>)
|
||||
<?php if (isset($err["teacher"])) formerr($err["teacher"]); ?>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" maxlength="100" size="25" value="<?php p($form->teachers) ?>">
|
||||
(<?php print_string("wordforteacherseg") ?>)
|
||||
<td align=right><p><?php print_string("wordforteachers") ?>:</td>
|
||||
<td><input type="text" name="teachers" maxlength="100" size=25 value="<?php p($form->teachers) ?>">
|
||||
(<?php print_string("wordforteacherseg") ?>)
|
||||
<?php if (isset($err["teachers"])) formerr($err["teachers"]); ?>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" maxlength="100" size="25" value="<?php p($form->student) ?>">
|
||||
(<?php print_string("wordforstudenteg") ?>)
|
||||
<td align=right><p><?php print_string("wordforstudent") ?>:</td>
|
||||
<td><input type="text" name="student" maxlength="100" size=25 value="<?php p($form->student) ?>">
|
||||
(<?php print_string("wordforstudenteg") ?>)
|
||||
<?php if (isset($err["student"])) formerr($err["student"]); ?>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align=right><p><?php print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" maxlength="100" size="25" value="<?php p($form->students) ?>">
|
||||
(<?php print_string("wordforstudentseg") ?>)
|
||||
<td align=right><p><?php print_string("wordforstudents") ?>:</td>
|
||||
<td><input type="text" name="students" maxlength="100" size=25 value="<?php p($form->students) ?>">
|
||||
(<?php print_string("wordforstudentseg") ?>)
|
||||
<?php if (isset($err["students"])) formerr($err["students"]); ?>
|
||||
</td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
@@ -111,5 +101,10 @@
|
||||
<input type="hidden" name="id" value="<?php p($form->id) ?>">
|
||||
<input type="hidden" name="category" value="<?php p($form->category) ?>">
|
||||
<input type="hidden" name="format" value="<?php p($form->format) ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if ($usehtmleditor) {
|
||||
print_richedit_javascript("form", "summary", "no");
|
||||
}
|
||||
?>
|
||||
|
||||
+5
-24
@@ -3,7 +3,6 @@
|
||||
require_once("../config.php");
|
||||
|
||||
if ($site = get_site()) {
|
||||
require_login();
|
||||
if (!isadmin()) {
|
||||
error("You need to be admin to edit this page");
|
||||
}
|
||||
@@ -14,12 +13,6 @@
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if (!empty($USER->id)) { // Additional identity check
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
}
|
||||
|
||||
validate_form($form, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
@@ -35,11 +28,6 @@
|
||||
error("Serious Error! Could not update the site record! (id = $form->id)");
|
||||
}
|
||||
} else {
|
||||
// [pj] We are about to create the site, so let's add some blocks...
|
||||
// calendar_month is included as a Moodle feature advertisement ;-)
|
||||
require_once($CFG->dirroot.'/lib/blocklib.php');
|
||||
$form->blockinfo = blocks_get_default_blocks(NULL, BLOCKS_DEFAULT_SITE);
|
||||
|
||||
if ($newid = insert_record("course", $form)) {
|
||||
$cat->name = get_string("miscellaneous");
|
||||
if (insert_record("course_categories", $cat)) {
|
||||
@@ -71,7 +59,6 @@
|
||||
$form->shortname = "";
|
||||
$form->summary = "";
|
||||
$form->newsitems = 3;
|
||||
$form->numsections = 0;
|
||||
$form->id = "";
|
||||
$form->category = 0;
|
||||
$form->format = "social";
|
||||
@@ -114,23 +101,17 @@
|
||||
print_heading($strsitesettings);
|
||||
}
|
||||
|
||||
if (empty($USER->id)) { // New undefined admin user
|
||||
$USER->htmleditor = true;
|
||||
$sesskey = '';
|
||||
} else {
|
||||
$sesskey = $USER->sesskey;
|
||||
}
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
$defaultformat = FORMAT_HTML;
|
||||
if ($usehtmleditor = can_use_richtext_editor()) {
|
||||
$onsubmit = "onsubmit=\"copyrichtext(form.summary);\"";
|
||||
} else {
|
||||
$onsubmit = "";
|
||||
}
|
||||
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("site.html");
|
||||
print_simple_box_end();
|
||||
|
||||
if ($usehtmleditor) {
|
||||
use_html_editor();
|
||||
}
|
||||
|
||||
if (!$firsttime) {
|
||||
print_footer();
|
||||
}
|
||||
|
||||
+7
-9
@@ -17,7 +17,7 @@
|
||||
|
||||
print_heading("");
|
||||
|
||||
if (isset($zone) and confirm_sesskey()) {
|
||||
if (isset($zone)) {
|
||||
$db->debug = true;
|
||||
echo "<center>";
|
||||
execute_sql("UPDATE {$CFG->prefix}user SET timezone = '$zone'");
|
||||
@@ -33,26 +33,24 @@
|
||||
$user->timezone = 99;
|
||||
}
|
||||
$timenow = time();
|
||||
$timeformat = get_string('strftimedaytime');
|
||||
|
||||
for ($tz = -26; $tz <= 26; $tz++) {
|
||||
$zone = (float)$tz/2.0;
|
||||
$usertime = $timenow + ($tz * 1800);
|
||||
if ($tz == 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT)";
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT)";
|
||||
} else if ($tz < 0) {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT$zone)";
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT$zone)";
|
||||
} else {
|
||||
$timezones["$zone"] = gmstrftime($timeformat, $usertime)." (GMT+$zone)";
|
||||
$timezones["$zone"] = gmstrftime("%a, %I:%M %p", $usertime)." (GMT+$zone)";
|
||||
}
|
||||
}
|
||||
|
||||
echo '<center><form action="timezone.php" method="get">';
|
||||
echo "<center><form action=timezone.php method=get>";
|
||||
echo "$strusers ($strall): ";
|
||||
choose_from_menu ($timezones, "zone", $user->timezone, get_string("serverlocaltime"), "", "99");
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
|
||||
echo "<input type=\"submit\" value=\"$strsavechanges\">";
|
||||
echo "</form></center>";
|
||||
echo "<input type=submit value=\"$strsavechanges\">";
|
||||
echo "</form>";
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
@@ -33,12 +33,10 @@
|
||||
|
||||
if (empty($_GET['confirm'])) {
|
||||
notice_yesno(get_string("upgradelogsinfo", "admin"),
|
||||
"upgradelogs.php?confirm=true&sesskey=$USER->sesskey",
|
||||
"upgradelogs.php?confirm=true",
|
||||
"index.php");
|
||||
print_footer();
|
||||
exit;
|
||||
} else if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+6
-16
@@ -17,10 +17,6 @@
|
||||
error("Could not find site-level course");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
if (!$adminuser = get_admin()) {
|
||||
error("Could not find site admin");
|
||||
}
|
||||
@@ -109,7 +105,7 @@
|
||||
foreach ($header as $i => $h) {
|
||||
$h = trim($h); $header[$i] = $h; // remove whitespace
|
||||
if (!($required[$h] or $optionalDefaults[$h] or $optional[$h])) {
|
||||
error(get_string('invalidfieldname', 'error', $h), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
error(get_string('invalidfieldname', 'error', $h), 'uploaduser.php');
|
||||
}
|
||||
if ($required[$h]) {
|
||||
$required[$h] = 2;
|
||||
@@ -118,7 +114,7 @@
|
||||
// check for required fields
|
||||
foreach ($required as $key => $value) {
|
||||
if ($value < 2) {
|
||||
error(get_string('fieldrequired', 'error', $key), 'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
error(get_string('fieldrequired', 'error', $key), 'uploaduser.php');
|
||||
}
|
||||
}
|
||||
$linenum = 2; // since header is line 1
|
||||
@@ -143,23 +139,18 @@
|
||||
// check for required values
|
||||
if ($required[$name] and !$value) {
|
||||
error(get_string('missingfield', 'error', $name). " ".
|
||||
get_string('erroronline', 'error', $linenum) .". ".
|
||||
get_string('processingstops', 'error'),
|
||||
'uploaduser.php?sesskey='.$USER->sesskey);
|
||||
get_string('erroronline', 'error', $linenum),
|
||||
'uploaduser.php');
|
||||
}
|
||||
// password needs to be encrypted
|
||||
else if ($name == "password") {
|
||||
$user->password = md5($value);
|
||||
}
|
||||
else if ($name == "username") {
|
||||
$user->username = addslashes(moodle_strtolower($value));
|
||||
}
|
||||
// normal entry
|
||||
else {
|
||||
$user->{$name} = addslashes($value);
|
||||
}
|
||||
}
|
||||
$user->auth = 'manual';
|
||||
$user->confirmed = 1;
|
||||
$user->timemodified = time();
|
||||
$linenum++;
|
||||
@@ -174,7 +165,7 @@
|
||||
$addgroup[2] = $user->group3;
|
||||
$addgroup[3] = $user->group4;
|
||||
$addgroup[4] = $user->group5;
|
||||
$courses = get_courses("all",'c.sortorder','c.id,c.shortname,c.fullname,c.sortorder');
|
||||
$courses = get_courses("all");
|
||||
for ($i=0; $i<5; $i++) {
|
||||
$courseid[$i]=0;
|
||||
}
|
||||
@@ -185,7 +176,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
if (get_record("user","username",$username) || !($user->id = insert_record("user", $user))) {
|
||||
if (! $user->id = insert_record("user", $user)) {
|
||||
if (!$user = get_record("user", "username", "changeme")) { // half finished user from another time
|
||||
//Record not added - probably because user is already registered
|
||||
//In this case, output userid from previous registration
|
||||
@@ -266,7 +257,6 @@
|
||||
echo '<center>';
|
||||
echo '<form method="post" enctype="multipart/form-data" action="uploaduser.php">'.
|
||||
$strchoose.':<input type="hidden" name="MAX_FILE_SIZE" value="'.$maxuploadsize.'">'.
|
||||
'<input type="hidden" name="sesskey" value="'.$USER->sesskey.'">'.
|
||||
'<input type="file" name="userfile" size=30>'.
|
||||
'<input type="submit" value="'.$struploadusers.'">'.
|
||||
'</form></br>';
|
||||
|
||||
+11
-21
@@ -10,9 +10,6 @@
|
||||
optional_variable($dir, "ASC");
|
||||
optional_variable($page, 0);
|
||||
optional_variable($search, "");
|
||||
if (!empty($search)) {
|
||||
$search=trim($search);
|
||||
}
|
||||
optional_variable($lastinitial, ""); // only show students with this last initial
|
||||
optional_variable($firstinitial, ""); // only show students with this first initial
|
||||
optional_variable($perpage, "30"); // how many per page
|
||||
@@ -21,8 +18,6 @@
|
||||
unset($admin);
|
||||
unset($teacher);
|
||||
|
||||
$search = trim($search);
|
||||
|
||||
if (! record_exists("user_admins")) { // No admin user yet
|
||||
|
||||
$user->firstname = get_string("admin");
|
||||
@@ -66,7 +61,6 @@
|
||||
$USER->admin = true;
|
||||
$USER->teacher["$site->id"] = true;
|
||||
$USER->newadminuser = true;
|
||||
set_user_sesskey(); // for added security, used to check script parameters
|
||||
|
||||
redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
|
||||
exit;
|
||||
@@ -83,8 +77,7 @@
|
||||
error("You must be an administrator to edit users this way.");
|
||||
}
|
||||
|
||||
if ($newuser and confirm_sesskey()) { // Create a new user
|
||||
$user->auth = "manual";
|
||||
if ($newuser) { // Create a new user
|
||||
$user->firstname = "";
|
||||
$user->lastname = "";
|
||||
$user->username = "changeme";
|
||||
@@ -124,7 +117,7 @@
|
||||
"<a href=\"users.php\">$strusers</a> -> $stredituser");
|
||||
}
|
||||
|
||||
if ($confirmuser and confirm_sesskey()) {
|
||||
if ($confirmuser) {
|
||||
if (!$user = get_record("user", "id", "$confirmuser")) {
|
||||
error("No such user!");
|
||||
}
|
||||
@@ -140,7 +133,7 @@
|
||||
notify(get_string("usernotconfirmed", "", fullname($user, true)));
|
||||
}
|
||||
|
||||
} else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation
|
||||
} else if ($delete) { // Delete a selected user, after confirmation
|
||||
if (!$user = get_record("user", "id", "$delete")) {
|
||||
error("No such user!");
|
||||
}
|
||||
@@ -153,7 +146,7 @@
|
||||
if ($confirm != md5($delete)) {
|
||||
$fullname = fullname($user, true);
|
||||
notice_yesno(get_string("deletecheckfull", "", "'$fullname'"),
|
||||
"user.php?delete=$delete&confirm=".md5($delete)."&sesskey=$USER->sesskey", "user.php");
|
||||
"user.php?delete=$delete&confirm=".md5($delete), "user.php");
|
||||
|
||||
exit;
|
||||
} else if (!$user->deleted) {
|
||||
@@ -188,11 +181,11 @@
|
||||
$columndir = "ASC";
|
||||
}
|
||||
} else {
|
||||
$columndir = $dir == "ASC" ? "DESC":"ASC";
|
||||
$columndir = $dir == "asc" ? "desc":"asc";
|
||||
if ($column == "lastaccess") {
|
||||
$columnicon = $dir == "ASC" ? "up":"down";
|
||||
$columnicon = $dir == "asc" ? "up":"down";
|
||||
} else {
|
||||
$columnicon = $dir == "ASC" ? "down":"up";
|
||||
$columnicon = $dir == "asc" ? "down":"up";
|
||||
}
|
||||
$columnicon = " <img src=\"$CFG->pixpath/t/$columnicon.gif\" />";
|
||||
|
||||
@@ -306,7 +299,7 @@
|
||||
if ($user->id == $USER->id or $user->username == "changeme") {
|
||||
$deletebutton = "";
|
||||
} else {
|
||||
$deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>";
|
||||
$deletebutton = "<a href=\"user.php?delete=$user->id\">$strdelete</a>";
|
||||
}
|
||||
if ($user->lastaccess) {
|
||||
$strlastaccess = format_time(time() - $user->lastaccess);
|
||||
@@ -314,7 +307,7 @@
|
||||
$strlastaccess = get_string("never");
|
||||
}
|
||||
if ($user->confirmed == 0) {
|
||||
$confirmbutton = "<a href=\"user.php?confirmuser=$user->id&sesskey=$USER->sesskey\">" . get_string("confirm") . "</a>";
|
||||
$confirmbutton = "<a href=\"user.php?confirmuser=$user->id\">" . get_string("confirm") . "</a>";
|
||||
} else {
|
||||
$confirmbutton = "";
|
||||
}
|
||||
@@ -338,9 +331,6 @@
|
||||
}
|
||||
echo "</form>";
|
||||
echo "</td></tr></table>";
|
||||
if (is_internal_auth()){
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
|
||||
}
|
||||
|
||||
print_table($table);
|
||||
|
||||
@@ -350,8 +340,8 @@
|
||||
|
||||
}
|
||||
|
||||
if (is_internal_auth()){
|
||||
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
|
||||
if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual"){
|
||||
print_heading("<a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a>");
|
||||
}
|
||||
|
||||
print_footer();
|
||||
|
||||
+12
-15
@@ -22,28 +22,25 @@
|
||||
|
||||
$table->align = array ("right", "left");
|
||||
|
||||
$table->data[] = array("<b><a href=\"auth.php?sesskey=$USER->sesskey\">".get_string("authentication")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"auth.php\">".get_string("authentication")."</a></b>",
|
||||
get_string("adminhelpauthentication"));
|
||||
|
||||
$table->data[] = array("<b><a href=\"user.php\">".get_string("edituser")."</a></b>",
|
||||
get_string("adminhelpedituser"));
|
||||
if (is_internal_auth()) {
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/user.php?newuser=true\">".get_string("addnewuser")."</a></b>",
|
||||
get_string("adminhelpaddnewuser"));
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php?sesskey=$USER->sesskey\">".get_string("uploadusers")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php\">".get_string("uploadusers")."</a></b>",
|
||||
get_string("adminhelpuploadusers"));
|
||||
}
|
||||
$table->data[] = array('', '<hr />');
|
||||
$table->data[] = array("<b><a href=\"enrol.php?sesskey=$USER->sesskey\">".get_string("enrolments")."</a></b>",
|
||||
get_string("adminhelpenrolments"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=off&sesskey=$USER->sesskey\">".get_string("assignstudents")."</a></b>",
|
||||
get_string("adminhelpassignstudents"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=on&sesskey=$USER->sesskey\">".get_string("assignteachers")."</a></b>",
|
||||
get_string("adminhelpassignteachers")." <img src=\"../pix/t/user.gif\" height=11 width=11>");
|
||||
$table->data[] = array("<b><a href=\"creators.php?sesskey=$USER->sesskey\">".get_string("assigncreators")."</a></b>",
|
||||
get_string("adminhelpassigncreators"));
|
||||
$table->data[] = array("<b><a href=\"admin.php?sesskey=$USER->sesskey\">".get_string("assignadmins")."</a></b>",
|
||||
$table->data[] = array("<b><a href=\"user.php\">".get_string("edituser")."</a></b>",
|
||||
get_string("adminhelpedituser"));
|
||||
$table->data[] = array("<b><a href=\"admin.php\">".get_string("assignadmins")."</a></b>",
|
||||
get_string("adminhelpassignadmins"));
|
||||
$table->data[] = array("<b><a href=\"creators.php\">".get_string("assigncreators")."</a></b>",
|
||||
get_string("adminhelpassigncreators"));
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=on\">".get_string("assignteachers")."</a></b>",
|
||||
get_string("adminhelpassignteachers")." <img src=\"../pix/t/user.gif\" height=11 width=11>");
|
||||
$table->data[] = array("<b><a href=\"../course/index.php?edit=off\">".get_string("assignstudents")."</a></b>",
|
||||
get_string("adminhelpassignstudents"));
|
||||
|
||||
print_table($table);
|
||||
|
||||
|
||||
+2
-4
@@ -12,9 +12,7 @@ function auth_user_login ($username, $password) {
|
||||
// two databases of the same kind ... it seems to get confused when trying to access
|
||||
// the first database again, after having accessed the second.
|
||||
// The following hack will make the database explicit which keeps it happy
|
||||
if ($CFG->dbtype != 'postgres7') {
|
||||
$CFG->prefix = "$CFG->dbname.$CFG->prefix";
|
||||
}
|
||||
$CFG->prefix = "$CFG->dbname.$CFG->prefix";
|
||||
|
||||
// Connect to the external database
|
||||
$authdb = &ADONewConnection($CFG->auth_dbtype);
|
||||
@@ -67,7 +65,7 @@ function auth_get_userinfo($username){
|
||||
if ($rs = $authdb->Execute("SELECT ".$config["auth_user_$field"]." FROM $CFG->auth_dbtable
|
||||
WHERE $CFG->auth_dbfielduser = '$username'")) {
|
||||
if ( $rs->RecordCount() == 1 ) {
|
||||
$result["$field"] = $rs->fields[0];
|
||||
$result["$field"] = $rs->fields[$config["auth_user_$field"]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
Moodle - FirstClass authentication module
|
||||
-----------------------------------------
|
||||
This module uses the FirstClass Flexible Provisining Protocol (FPP) to communicate between the FirstClass server
|
||||
and the Moodle host.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
1. Enable FPP on the FirstClass server
|
||||
FPP is not doumented in the FirstClass documentation and is not enable by default.
|
||||
To enable the protocol you need to edit the file \FCPO\Server\Netinfo. Open the file and insert the
|
||||
following lines.
|
||||
|
||||
// TCP port for Flexible Provisioning Protocol (FPP).
|
||||
TCPFPPPORT = 3333
|
||||
|
||||
|
||||
2. Create an account on the FirstClass server with privilege "Subadministrator".
|
||||
Using the FPP protocoll this module logs in to the FirstClass server and issuess batch admin commands.
|
||||
Batch admin command can only be issued in the context of a user with subadministrative privileges.
|
||||
|
||||
Default account name is "fcMoodle".
|
||||
|
||||
|
||||
3. Check that the FPP protocoll is working by running a Telnet session. If everyting is working you
|
||||
should get a "+0" answer from the server.
|
||||
|
||||
> telnet yourhost.domain.com 3333
|
||||
+0
|
||||
|
||||
Check that the "fcMoodle" is working by entering the following sequens of commands:
|
||||
|
||||
> telnet yourhost.domain.com 3333
|
||||
+0
|
||||
fcMoodle
|
||||
+0
|
||||
|
||||
the_password_you_gave_fcmoodle
|
||||
+0
|
||||
|
||||
Get user some_user_id 1201
|
||||
|
||||
1201 0 some_user_id
|
||||
+0
|
||||
|
||||
|
||||
|
||||
4. On the Moodle host go to the directory where you have installed Moodle.
|
||||
Open the folder "auth", where all other authentication modules are installed,
|
||||
and create a new directory with the name "fc".
|
||||
|
||||
Copy the files "config.html", "fcFPP.php" and "lib.php" to the "auth" directory.
|
||||
|
||||
Now you need to add som strings to the language file. This distribution contains
|
||||
string for the English (en) and Swedish (sv) translation.
|
||||
|
||||
Open the file "auth.php" in the folder "lang/sv" and paste the text from the file
|
||||
"auth.php - sv.txt" at the end of the file above the line "?>"
|
||||
|
||||
Open the file "auth.php" in the folder "lang/en" and paste the text from the file
|
||||
"auth.php - en.txt" at the end of the file above the line "?>"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
<?PHP
|
||||
if (!isset($config->auth_fchost)) {
|
||||
$config->auth_fchost = "127.0.0.1";
|
||||
}
|
||||
if (!isset($config->auth_fcfppport)) {
|
||||
$config->auth_fcfppport = "3333";
|
||||
}
|
||||
if (!isset($config->auth_fcuserid)) {
|
||||
$config->auth_fcuserid = "fcMoodle";
|
||||
}
|
||||
if (!isset($config->auth_fcpasswd)) {
|
||||
$config->auth_fcpasswd = "";
|
||||
}
|
||||
if (!isset($config->auth_fccreators)) {
|
||||
$config->auth_fccreators = "";
|
||||
}
|
||||
?>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fchost:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fchost TYPE=text SIZE=30 VALUE="<?php echo $config->auth_fchost?>">
|
||||
<?php if (isset($err["auth_fchost"])) formerr($err["auth_fchost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fchost","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fcfppport:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fcfppport TYPE=text SIZE=30 VALUE="<?php echo $config->auth_fcfppport?>">
|
||||
<?php if (isset($err["auth_fcfppport"])) formerr($err["auth_fchost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fcfppport","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fcuserid:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fcuserid TYPE=text SIZE=30 MAXLENGTH=15 VALUE="<?php echo $config->auth_fcuserid?>">
|
||||
<?php if (isset($err["auth_fcuserid"])) formerr($err["auth_fcuserid"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fcuserid","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fcpasswd:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fcpasswd TYPE=password SIZE=30 MAXLENGTH=12 VALUE="<?php echo $config->auth_fcpasswd?>">
|
||||
<?php if (isset($err["auth_fcpasswd"])) formerr($err["auth_fcpasswd"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fcpasswd","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_fccreators:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_fccreators TYPE=text SIZE=30 VALUE="<?php echo $config->auth_fccreators?>">
|
||||
<?php if (isset($err["auth_fccreators"])) formerr($err["auth_fccreators"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_fccreators","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</TD>
|
||||
</TR>
|
||||
@@ -1,218 +0,0 @@
|
||||
<?php
|
||||
/************************************************************************/
|
||||
/* fcFPP: Php class for FirstClass Flexible Provisining Protocol */
|
||||
/* ============================================================= */
|
||||
/* */
|
||||
/* Copyright (c) 2004 SKERIA Utveckling, Teknous */
|
||||
/* http://skeria.skelleftea.se */
|
||||
/* */
|
||||
/* Flexible Provisioning Protocol is a real-time, IP based protocol */
|
||||
/* which provides direct access to the scriptable remote administration */
|
||||
/* subsystem of the core FirstClass Server. Using FPP, it is possible to*/
|
||||
/* implement automated provisioning and administration systems for */
|
||||
/* FirstClass, avoiding the need for a point and click GUI. FPP can also*/
|
||||
/* be used to integrate FirstClass components into a larger unified */
|
||||
/* system. */
|
||||
/* */
|
||||
/* This program is free software. You can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 2 of the License. */
|
||||
/************************************************************************/
|
||||
/* Author: Torsten Anderson, torsten.anderson@skeria.skelleftea.se
|
||||
*/
|
||||
|
||||
class fcFPP
|
||||
{
|
||||
var $_hostname; // hostname of FirstClass server we are connection to
|
||||
var $_port; // port on which fpp is running
|
||||
var $_conn = 0; // socket we are connecting on
|
||||
var $_debug = FALSE; // set to true to see some debug info
|
||||
|
||||
// class constructor
|
||||
function fcFPP($host="localhost", $port="3333")
|
||||
{
|
||||
$this->_hostname = $host;
|
||||
$this->_port = $port;
|
||||
$this->_user = "";
|
||||
$this->_pwd = "";
|
||||
}
|
||||
|
||||
// open a connection to the FirstClass server
|
||||
function open()
|
||||
{
|
||||
if($this->_debug) echo "Connecting to host ";
|
||||
$host = $this->_hostname;
|
||||
$port = $this->_port;
|
||||
|
||||
if($this->_debug) echo "[$host:$port]..";
|
||||
|
||||
// open the connection to the FirstClass server
|
||||
$conn = fsockopen($host, $port, $errno, $errstr, 5);
|
||||
if(!$conn)
|
||||
{
|
||||
echo "connection failed!".$errno. $errstr;
|
||||
return false;
|
||||
}
|
||||
|
||||
// We are connected
|
||||
if($this->_debug) echo "connected!";
|
||||
|
||||
// Read connection message.
|
||||
$line = fgets ($conn); //+0
|
||||
$line = fgets ($conn); //new line
|
||||
|
||||
// store the connection in this class, so we can use it later
|
||||
$this->_conn = & $conn;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// close any open connections
|
||||
function close()
|
||||
{
|
||||
// get the current connection
|
||||
$conn = &$this->_conn;
|
||||
|
||||
// close it if it's open
|
||||
if($conn)
|
||||
{
|
||||
fclose($conn);
|
||||
|
||||
// cleanup the variable
|
||||
unset($this->_conn);
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Authenticate to the FirstClass server
|
||||
function login($userid, $passwd)
|
||||
{
|
||||
// we did have a connection right?!
|
||||
if($this->_conn)
|
||||
{
|
||||
# Send username
|
||||
fputs($this->_conn,"$userid\r\n");
|
||||
|
||||
$line = fgets ($this->_conn); //new line
|
||||
$line = fgets ($this->_conn); //+0
|
||||
$line = fgets ($this->_conn); //new line
|
||||
|
||||
# Send password
|
||||
fputs($this->_conn,"$passwd\r\n");
|
||||
$line = fgets ($this->_conn); //new line
|
||||
$line = fgets ($this->_conn); //+0
|
||||
$line = fgets ($this->_conn); //+0 or message
|
||||
|
||||
if($this->_debug) echo $line;
|
||||
|
||||
if (preg_match ("/^\+0/", $line)) { //+0, user with subadmin privileges
|
||||
$this->_user = $userid;
|
||||
$this->_pwd = $passwd;
|
||||
return TRUE;
|
||||
} elseif (preg_match ("/^\Sorry/",$line)){ //Denied access but a valid user and password
|
||||
return TRUE;
|
||||
} else { //Invalid user or password
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Get the list of groups the user is a member of
|
||||
function getGroups($userid){
|
||||
|
||||
$groups = array();
|
||||
|
||||
// we must be logged in as a user with subadmin privileges
|
||||
if($this->_conn AND $this->_user) {
|
||||
# Send BA-command to get groups
|
||||
fputs($this->_conn,"GET USER '" . $userid . "' 4 -1\r");
|
||||
$line = "";
|
||||
while (!$line) {
|
||||
$line = trim(fgets ($this->_conn));
|
||||
}
|
||||
$n = 0;
|
||||
while ($line AND !preg_match("/^\+0/", $line) AND $line != "-1003") {
|
||||
list( , , $groups[$n++]) = explode(" ",$line,3);
|
||||
$line = trim(fgets ($this->_conn));
|
||||
}
|
||||
if($this->_debug) echo "getGroups:" . implode(",",$groups);
|
||||
}
|
||||
|
||||
return $groups;
|
||||
}
|
||||
|
||||
// Check if the user is member of any of the groups.
|
||||
// Return the list of groups the user is member of.
|
||||
function isMemberOf($userid, $groups){
|
||||
|
||||
$usergroups = array_map("strtolower",$this->getGroups($userid));
|
||||
$groups = array_map("strtolower",$groups);
|
||||
|
||||
$result = array_intersect($groups,$usergroups);
|
||||
|
||||
if($this->_debug) echo "isMemberOf:" . implode(",",$result);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function getUserInfo($userid, $field){
|
||||
|
||||
$userinfo = "";
|
||||
|
||||
if($this->_conn AND $this->_user) {
|
||||
# Send BA-command to get data
|
||||
fputs($this->_conn,"GET USER '" . $userid . "' " . $field . "\r");
|
||||
$line = "";
|
||||
while (!$line) {
|
||||
$line = trim(fgets ($this->_conn));
|
||||
}
|
||||
$n = 0;
|
||||
while ($line AND !preg_match("/^\+0/", $line)) {
|
||||
list( , , $userinfo) = explode(" ",$line,3);
|
||||
$line = trim(fgets ($this->_conn));
|
||||
}
|
||||
if($this->_debug) echo "getUserInfo:" . $userinfo;
|
||||
}
|
||||
|
||||
return str_replace('\r',' ',trim($userinfo,'"'));
|
||||
|
||||
}
|
||||
|
||||
function getResume($userid){
|
||||
|
||||
$resume = "";
|
||||
|
||||
$pattern = "/\[.+:.+\..+\]/"; // Remove references to pictures in resumes
|
||||
|
||||
if($this->_conn AND $this->_user) {
|
||||
# Send BA-command to get data
|
||||
fputs($this->_conn,"GET RESUME '" . $userid . "' 6\r");
|
||||
$line = "";
|
||||
while (!$line) {
|
||||
$line = trim(fgets ($this->_conn));
|
||||
}
|
||||
$n = 0;
|
||||
while ($line AND !preg_match("/^\+0/", $line)) {
|
||||
$resume .= preg_replace($pattern,"",str_replace('\r',"\n",trim($line,'6 ')));
|
||||
$line = trim(fgets ($this->_conn));
|
||||
//print $line;
|
||||
|
||||
}
|
||||
if($this->_debug) echo "getResume:" . $resume;
|
||||
}
|
||||
|
||||
return $resume;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
-154
@@ -1,154 +0,0 @@
|
||||
<?php // $Id$
|
||||
|
||||
// FirstClass authentication using FirstClass Flexible Provisining Protocol
|
||||
|
||||
/* Author: Torsten Anderson, torsten.anderson@skeria.skelleftea.se
|
||||
|
||||
CHANGELOG
|
||||
|
||||
README
|
||||
Module will authenticate user against FirstClass server and check if user belongs to any of
|
||||
the defined creator groups.
|
||||
User authenticates using their existing FirstClass username and password.
|
||||
Where possible userdata is copied from the FirstClass directory to Moodle. You may
|
||||
want to modify this.
|
||||
Module requires the fcFPP class to do it's jobb.
|
||||
*/
|
||||
|
||||
|
||||
require('fcFPP.php');
|
||||
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
/// Returns true if the username and password work
|
||||
/// and false if they don't
|
||||
|
||||
global $CFG;
|
||||
|
||||
$hostname = $CFG->auth_fchost;
|
||||
$port = $CFG->auth_fcfppport;
|
||||
|
||||
$retval = FALSE;
|
||||
|
||||
if (!$username or !$password) { // Don't allow blank usernames or passwords
|
||||
return $retval;
|
||||
}
|
||||
|
||||
|
||||
$fpp = new fcFPP($hostname,$port);
|
||||
if ($fpp->open()) {
|
||||
if ($fpp->login($username,$password)){
|
||||
$retval = TRUE;
|
||||
}
|
||||
}
|
||||
$fpp->close();
|
||||
|
||||
return $retval;
|
||||
|
||||
|
||||
}
|
||||
|
||||
function auth_get_userinfo($username){
|
||||
// Get user information from FirstCLass server and return it in an array.
|
||||
// Localize this routine to fit your needs.
|
||||
|
||||
/*
|
||||
Moodle FirstCLass fieldID in UserInfo form
|
||||
------ -----------------------------------
|
||||
firstname 1202
|
||||
lastname 1204
|
||||
email 1252
|
||||
icq -
|
||||
phone1 1206
|
||||
phone2 1207 (Fax)
|
||||
institution -
|
||||
department -
|
||||
address 1205
|
||||
city -
|
||||
country -
|
||||
lang -
|
||||
timezone 8030 (Not used yet. Need to figure out how FC codes timezones)
|
||||
|
||||
description Get data from users resume. Pictures will be removed.
|
||||
|
||||
*/
|
||||
|
||||
global $CFG;
|
||||
|
||||
$hostname = $CFG->auth_fchost;
|
||||
$port = $CFG->auth_fcfppport;
|
||||
$userid = $CFG->auth_fcuserid;
|
||||
$passwd = $CFG->auth_fcpasswd;
|
||||
|
||||
$userinfo = array();
|
||||
|
||||
$fpp = new fcFPP($hostname,$port);
|
||||
if ($fpp->open()) {
|
||||
if ($fpp->login($userid,$passwd)){
|
||||
|
||||
$userinfo['firstname'] = $fpp->getUserInfo($username,"1202");
|
||||
$userinfo['lastname'] = $fpp->getUserInfo($username,"1204");
|
||||
$userinfo['email'] = strtok($fpp->getUserInfo($username,"1252"),',');
|
||||
$userinfo['phone1'] = $fpp->getUserInfo($username,"1206");
|
||||
$userinfo['phone2'] = $fpp->getUserInfo($username,"1207");
|
||||
$userinfo['description'] = $fpp->getResume($username);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$fpp->close();
|
||||
|
||||
foreach($userinfo as $key => $value) {
|
||||
if (!$value) {
|
||||
unset($userinfo[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
return $userinfo;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function auth_iscreator($username=0) {
|
||||
//Get users group membership from the FirstClass server user and check if
|
||||
// user is member of one of the groups of creators.
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
if (! $CFG->auth_fccreators) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $username) {
|
||||
$username=$USER->username;
|
||||
}
|
||||
|
||||
$fcgroups = array();
|
||||
|
||||
$hostname = $CFG->auth_fchost;
|
||||
$port = $CFG->auth_fcfppport;
|
||||
$userid = $CFG->auth_fcuserid;
|
||||
$passwd = $CFG->auth_fcpasswd;
|
||||
|
||||
$fpp = new fcFPP($hostname,$port);
|
||||
if ($fpp->open()) {
|
||||
if ($fpp->login($userid,$passwd)){
|
||||
$fcgroups = $fpp->getGroups($username);
|
||||
}
|
||||
}
|
||||
$fpp->close();
|
||||
|
||||
|
||||
if ((! $fcgroups)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$creators = explode(";",$CFG->auth_fccreators);
|
||||
|
||||
foreach($creators as $creator) {
|
||||
If (in_array($creator, $fcgroups)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
+46
-80
@@ -20,52 +20,36 @@
|
||||
if (empty($config->ldap_version)) {
|
||||
$config->ldap_version = "2";
|
||||
}
|
||||
if (empty($config->ldap_memberattribute)) {
|
||||
$config->ldap_memberattribute = "";
|
||||
}
|
||||
if (empty($config->ldap_creators)) {
|
||||
$config->ldap_creators = "";
|
||||
}
|
||||
if (empty($config->ldap_create_context)) {
|
||||
$config->ldap_create_context = "";
|
||||
}
|
||||
if (empty($config->ldap_objectclass)) {
|
||||
$config->ldap_objectclass = "";
|
||||
}
|
||||
if (empty($config->auth_user_guid)) {
|
||||
$config->auth_user_guid = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_host_url:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_host_url:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_host_url?>">
|
||||
<?php if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
|
||||
</TD>
|
||||
<?php if (isset($err["ldap_host_url"])) formerr($err["ldap_host_url"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_host_url","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_version:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_version:</TD>
|
||||
<TD>
|
||||
<?php
|
||||
$versions[2] = "2";
|
||||
$versions[3] = "3";
|
||||
choose_from_menu($versions, "ldap_version", $config->ldap_version, "");
|
||||
if (isset($err["ldap_version"])) formerr($err["ldap_version"]);
|
||||
if (isset($err["ldap_version"])) formerr($err["ldap_version"]);
|
||||
?>
|
||||
</TD>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_version","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_contexts:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_contexts:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_contexts?>">
|
||||
<?php if (isset($err["ldap_contexts"])) formerr($err["ldap_contexts"]); ?>
|
||||
</TD>
|
||||
@@ -75,8 +59,8 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_user_attribute:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_user_attribute?>">
|
||||
<?php if (isset($err["ldap_user_attribute"])) formerr($err["ldap_user_attribute"]); ?>
|
||||
</TD>
|
||||
@@ -86,19 +70,8 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_objectclass:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_objectclass TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_objectclass?>">
|
||||
<?php if (isset($err["ldap_objectclass"])) formerr($err["ldap_objectclass"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_ldap_objectclass","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?php echo $config->ldap_search_sub?>">
|
||||
<?php if (isset($err["ldap_search_sub"])) formerr($err["ldap_search_sub"]); ?>
|
||||
</TD>
|
||||
@@ -108,8 +81,8 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_dn?>">
|
||||
<?php if (isset($err["ldap_bind_dn"])) formerr($err["ldap_bind_dn"]); ?>
|
||||
</TD><TD>
|
||||
@@ -118,8 +91,8 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_bind_pw:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_bind_pw?>">
|
||||
<?php if (isset($err["ldap_bind_pw"])) formerr($err["ldap_bind_pw"]); ?>
|
||||
</TD><TD>
|
||||
@@ -148,8 +121,8 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>ldap_create_context:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P>ldap_create_context:</TD>
|
||||
<TD>
|
||||
<INPUT name=ldap_create_context TYPE=text SIZE=30 VALUE="<?php echo $config->ldap_create_context?>">
|
||||
<?php if (isset($err["ldap_create_context"])) formerr($err["ldap_create_context"]); ?>
|
||||
</TD><TD>
|
||||
@@ -158,8 +131,8 @@
|
||||
</TR>
|
||||
|
||||
<TR>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("firstname") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("firstname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_firstname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_firstname?>">
|
||||
</TD>
|
||||
<TD rowspan=12 VALIGN=CENTER>
|
||||
@@ -168,93 +141,86 @@
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("lastname") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("lastname") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lastname" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lastname?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("email") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("email") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_email" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_email?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 1:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 1:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone1" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone1?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 2:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("phone") ?> 2:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_phone2" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_phone2?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("department") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("department") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_department" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_department?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("address") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("address") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_address" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_address?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("city") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("city") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_city" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_city?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("country") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("country") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_country" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_country?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("description") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("description") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_description" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_description?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("idnumber") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("idnumber") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_idnumber" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_idnumber?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("language") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("language") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_lang" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_lang?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("guid") ?>:</TD>
|
||||
<TD>
|
||||
<INPUT name="auth_user_guid" TYPE="text" SIZE="30" VALUE="<?php echo $config->auth_user_guid?>">
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
<TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><?php p($config->auth_instructions) ?></TEXTAREA>
|
||||
</TD>
|
||||
<TD>
|
||||
|
||||
+35
-265
@@ -1,65 +1,29 @@
|
||||
<?PHP // $Id$
|
||||
//CHANGELOG:
|
||||
//15.08.2004 Added support for user syncronization
|
||||
//24.02.2003 Added support for coursecreators
|
||||
//20.02.2003 Added support for user creation
|
||||
//12.10.2002 Reformatted source for consistency
|
||||
//03.10.2002 First version to CVS
|
||||
//29.09.2002 Clean up and splitted code to functions v. 0.02
|
||||
//29.09.2002 LDAP authentication functions v. 0.01
|
||||
//Distributed under GPL (c)Petri Asikainen 2002-2004
|
||||
//Distributed under GPL (c)Petri Asikainen 2002-2003
|
||||
|
||||
/* README!
|
||||
Module is quite complete and most functinality can be configured from
|
||||
configinterfave /admin/auth.php. Some of latest additions/features need to
|
||||
be configured by modifying source code.
|
||||
|
||||
USER CREATION FEATURE
|
||||
If you plan to use user creation feature, look function auth_user_create
|
||||
and modify it for your needs.
|
||||
You have to change all hardcoded attribute values to fit your LDAP-server.
|
||||
User-creation makes posible that your current
|
||||
users can authenticate with existings usernames/password and new users can
|
||||
create own accounts to LDAP-directory. I'm using this feature and new users
|
||||
are created to LDAP different context, without rights to other system. When
|
||||
user-creation feature is set like that, there's no known security issues.
|
||||
|
||||
If you plan to use user creation feature, look function auth_user_create
|
||||
and modify it for your needs.
|
||||
You have to change all hardcoded attribute values to fit your LDAP-server.
|
||||
|
||||
I write ldap-module on Novell E-directory / Linux & Solaris ,
|
||||
so all default values are for it.
|
||||
|
||||
LDAP USER SYNCRONIZATION
|
||||
|
||||
BACKUP
|
||||
This is first version of usersync so backup your database, if you like to test this feature!
|
||||
|
||||
BINARY FIELDS
|
||||
I'm testing this against Novell eDirectory where guid field is binary
|
||||
so I have to use bin2hex() in function auth_get_users (), If your guid field is not binary
|
||||
comment that line out.
|
||||
|
||||
EXISTING USERS
|
||||
For existing systems there no way to figure out is account from ldap or not.
|
||||
So sysadmin, you have to update 'auth' and 'guid' fields for your existing ldap-users by hand (or scripting)
|
||||
If your users usernamed are stabile, you can use auth_get_users() for this.
|
||||
|
||||
AUTOMATING SYNCRONIZATION
|
||||
Right now moodle does not automaticly run auth_sync_users() so you have to create
|
||||
your own script like:
|
||||
auth/ldap/cron.php
|
||||
<?
|
||||
require_once("../../config.php");
|
||||
require_once("../../course/lib.php");
|
||||
require_once('../../lib/blocklib.php');
|
||||
require_once("../../mod/resource/lib.php");
|
||||
require_once("lib.php");
|
||||
require_once("../../mod/forum/lib.php");
|
||||
auth_sync_users();
|
||||
?>
|
||||
|
||||
Usersync is quite heavy process, it could be good idea to place that script outside of webroot and run it with cron.
|
||||
|
||||
|
||||
Any feedback is wellcome,
|
||||
|
||||
Petri Asikainen paca@sci.fi
|
||||
@@ -122,7 +86,7 @@ function auth_get_userinfo($username){
|
||||
|
||||
$user_dn = auth_ldap_find_userdn($ldap_connection, $username);
|
||||
|
||||
if (empty($CFG->ldap_objectclass)) { // Can't send empty filter
|
||||
if (! isset($CFG->ldap_objectclass)) {
|
||||
$CFG->ldap_objectclass="objectClass=*";
|
||||
}
|
||||
|
||||
@@ -132,14 +96,13 @@ function auth_get_userinfo($username){
|
||||
$user_entry = ldap_get_entries($ldap_connection, $user_info_result);
|
||||
foreach ($attrmap as $key=>$value){
|
||||
if(isset($user_entry[0][strtolower($value)][0])){
|
||||
$result[$key]=addslashes(stripslashes(utf8_decode($user_entry[0][strtolower($value)][0])));
|
||||
$result[$key]=$user_entry[0][strtolower($value)][0];
|
||||
}
|
||||
}
|
||||
$result['guid']='ldap';
|
||||
}
|
||||
|
||||
@ldap_close($ldap_connection);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -186,154 +149,6 @@ function auth_user_create ($userobject,$plainpass) {
|
||||
|
||||
}
|
||||
|
||||
function auth_get_users($filter='*') {
|
||||
//returns all userobjects from external database
|
||||
global $CFG;
|
||||
|
||||
$fresult = array();
|
||||
$ldap_connection = auth_ldap_connect();
|
||||
|
||||
auth_ldap_bind($ldap_connection);
|
||||
|
||||
if (! isset($CFG->ldap_objectclass)) {
|
||||
$CFG->ldap_objectclass="objectClass=*";
|
||||
}
|
||||
|
||||
if ($filter=="*") {
|
||||
$filter = "(&(".$CFG->ldap_user_attribute."=*)(".$CFG->ldap_objectclass."))";
|
||||
}
|
||||
|
||||
$contexts = explode(";",$CFG->ldap_contexts);
|
||||
|
||||
if (!empty($CFG->ldap_create_context)){
|
||||
array_push($contexts, $CFG->ldap_create_context);
|
||||
}
|
||||
|
||||
$attrmap = auth_ldap_attributes();
|
||||
|
||||
$search_attribs = array();
|
||||
|
||||
foreach ($attrmap as $key=>$value) {
|
||||
if (!in_array($value, $search_attribs)) {
|
||||
array_push($search_attribs, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach ($contexts as $context) {
|
||||
|
||||
$context = trim($context);
|
||||
if (empty($context)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($CFG->ldap_search_sub) {
|
||||
//use ldap_search to find first user from subtree
|
||||
$ldap_result = ldap_search($ldap_connection, $context,
|
||||
$filter,
|
||||
$search_attribs);
|
||||
} else {
|
||||
//search only in this context
|
||||
$ldap_result = ldap_list($ldap_connection, $context,
|
||||
$filter,
|
||||
$search_attribs);
|
||||
}
|
||||
|
||||
$users = auth_ldap_get_entries($ldap_connection, $ldap_result);
|
||||
|
||||
//add found users to list
|
||||
foreach ($users as $ldapuser=>$attribs) {
|
||||
$user = new object();
|
||||
foreach ($attrmap as $key=>$value){
|
||||
if(isset($users[$ldapuser][$value][0])){
|
||||
$user->$key=$users[$ldapuser][$value][0];
|
||||
}
|
||||
}
|
||||
//quick way to get around binarystrings
|
||||
$user->guid=bin2hex($user->guid);
|
||||
//add authentication source stamp
|
||||
$user->auth='ldap';
|
||||
$fresult[$user->username]=$user;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return $fresult;
|
||||
}
|
||||
|
||||
function auth_sync_users () {
|
||||
//Syncronizes userdb with ldap
|
||||
//This will add, rename
|
||||
global $CFG ;
|
||||
$users = auth_get_users();
|
||||
$usedguids = Array();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$usedguids[] = $user->guid; //we will need all used guids later
|
||||
//update modified time
|
||||
$user->modified = time();
|
||||
//All users are confirmed
|
||||
$user->confirmed = 1;
|
||||
// if user does not exist create it
|
||||
if (!record_exists('user','auth', 'ldap', 'guid', $user->guid)) {
|
||||
if (insert_record ('user',$user)) {
|
||||
echo "inserted user $user->username with guid $user->guid \n";
|
||||
} else {
|
||||
echo "error inserting user $user->username with guid $user->guid \n";
|
||||
}
|
||||
continue ;
|
||||
} else {
|
||||
//update username
|
||||
set_field('user', 'username', $user->username , 'auth', 'ldap', 'guid', $user->guid);
|
||||
//no id-information in ldap so get now
|
||||
$userid = get_field('user', 'id', 'auth', 'ldap', 'guid', $user->guid);
|
||||
|
||||
if (auth_iscreator($user->username)) {
|
||||
if (! record_exists("user_coursecreators", "userid", $userid)) {
|
||||
$cdata['userid']=$userid;
|
||||
$creator = insert_record("user_coursecreators",$cdata);
|
||||
if (! $creator) {
|
||||
error("Cannot add user to course creators.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( record_exists("user_coursecreators", "userid", $userid)) {
|
||||
$creator = delete_records("user_coursecreators", "userid", $userid);
|
||||
if (! $creator) {
|
||||
error("Cannot remove user from course creators.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//find nonexisting users from moodles userdb
|
||||
$sql = "SELECT * FROM ".$CFG->prefix."user WHERE deleted = '0' AND auth = 'ldap' AND guid NOT IN ('".implode('\' , \'',$usedguids)."');" ;
|
||||
$result = get_records_sql($sql);
|
||||
|
||||
if (!empty($result)){
|
||||
foreach ($result as $user) {
|
||||
//following is copy pasted from admin/user.php
|
||||
//maybe this should moved to function in lib/datalib.php
|
||||
unset($updateuser);
|
||||
$updateuser->id = $user->id;
|
||||
$updateuser->deleted = "1";
|
||||
$updateuser->username = "$user->email.".time(); // Remember it just in case
|
||||
$updateuser->email = ""; // Clear this field to free it up
|
||||
$updateuser->timemodified = time();
|
||||
if (update_record("user", $updateuser)) {
|
||||
unenrol_student($user->id); // From all courses
|
||||
remove_teacher($user->id); // From all courses
|
||||
remove_admin($user->id);
|
||||
notify(get_string("deletedactivity", "", fullname($user, true)) );
|
||||
} else {
|
||||
notify(get_string("deletednot", "", fullname($user, true)));
|
||||
}
|
||||
//copy pasted part ends
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function auth_user_activate ($username) {
|
||||
//activate new ldap-user after email-address is confirmed
|
||||
global $CFG;
|
||||
@@ -367,52 +182,38 @@ function auth_user_disable ($username) {
|
||||
|
||||
function auth_iscreator($username=0) {
|
||||
///if user is member of creator group return true
|
||||
global $USER , $CFG;
|
||||
if (! $username) {
|
||||
$username=$USER->username;
|
||||
}
|
||||
|
||||
if ((! $CFG->ldap_creators) OR (! $CFG->ldap_memberattribute)) {
|
||||
return null;
|
||||
}
|
||||
global $CFG, $USER;
|
||||
|
||||
$ldapconnect = auth_ldap_connect();
|
||||
$ldapbind = auth_ldap_bind($ldapconnect);
|
||||
|
||||
if (! $username) {
|
||||
$username=$USER->username;
|
||||
}
|
||||
|
||||
if ((! $CFG->ldap_creators) OR (! $CFG->ldap_memberattribute)) {
|
||||
return false;
|
||||
} else {
|
||||
$groups = explode(";",$CFG->ldap_creators);
|
||||
}
|
||||
|
||||
|
||||
//build filter
|
||||
$filter = "(& ($CFG->ldap_user_attribute=$username)(|";
|
||||
foreach ($groups as $group){
|
||||
$filter .= "($CFG->ldap_memberattribute=$group)";
|
||||
}
|
||||
$filter .= "))";
|
||||
//search
|
||||
$result = auth_ldap_get_userlist($filter);
|
||||
|
||||
return count($result);
|
||||
|
||||
return auth_ldap_isgroupmember($username, $CFG->ldap_creators);
|
||||
|
||||
}
|
||||
|
||||
//PRIVATE FUNCTIONS starts
|
||||
//private functions are named as auth_ldap*
|
||||
|
||||
function auth_ldap_isgroupmember ($username='', $groupdns='') {
|
||||
// Takes username and groupdn(s) , separated by ;
|
||||
// Returns true if user is member of any given groups
|
||||
|
||||
global $CFG, $USER;
|
||||
|
||||
$ldapconnect = auth_ldap_connect();
|
||||
$ldapbind = auth_ldap_bind($ldapconnect);
|
||||
|
||||
if (empty($username) OR empty($groupdns)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$groups = explode(";",$groupdns);
|
||||
|
||||
//build filter
|
||||
$filter = "(& ($CFG->ldap_user_attribute=$username)(|";
|
||||
foreach ($groups as $group){
|
||||
$group = trim($group);
|
||||
if(!empty($group)) {
|
||||
$filter .= "($CFG->ldap_memberattribute=$group)";
|
||||
}
|
||||
}
|
||||
$filter .= "))";
|
||||
//search
|
||||
$result = auth_ldap_get_userlist($filter);
|
||||
|
||||
return count($result);
|
||||
|
||||
}
|
||||
function auth_ldap_connect(){
|
||||
/// connects to ldap-server
|
||||
global $CFG;
|
||||
@@ -481,10 +282,7 @@ function auth_ldap_find_userdn ($ldap_connection, $username){
|
||||
|
||||
foreach ($ldap_contexts as $context) {
|
||||
|
||||
$context = trim($context);
|
||||
if (empty($context)) {
|
||||
continue;
|
||||
}
|
||||
$context == trim($context);
|
||||
|
||||
if ($CFG->ldap_search_sub){
|
||||
//use ldap_search to find first user from subtree
|
||||
@@ -513,7 +311,7 @@ function auth_ldap_attributes (){
|
||||
$config = (array)$CFG;
|
||||
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
|
||||
"department", "address", "city", "country", "description",
|
||||
"idnumber", "lang", "guid");
|
||||
"idnumber", "lang");
|
||||
|
||||
$moodleattributes = array();
|
||||
foreach ($fields as $field) {
|
||||
@@ -521,7 +319,6 @@ function auth_ldap_attributes (){
|
||||
$moodleattributes[$field] = $config["auth_user_$field"];
|
||||
}
|
||||
}
|
||||
$moodleattributes['username']=$config["ldap_user_attribute"];
|
||||
return $moodleattributes;
|
||||
}
|
||||
|
||||
@@ -550,11 +347,6 @@ function auth_ldap_get_userlist($filter="*") {
|
||||
|
||||
foreach ($contexts as $context) {
|
||||
|
||||
$context = trim($context);
|
||||
if (empty($context)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($CFG->ldap_search_sub) {
|
||||
//use ldap_search to find first user from subtree
|
||||
$ldap_result = ldap_search($ldap_connection, $context,
|
||||
@@ -578,26 +370,4 @@ function auth_ldap_get_userlist($filter="*") {
|
||||
return $fresult;
|
||||
}
|
||||
|
||||
function auth_ldap_get_entries($conn, $searchresult){
|
||||
//Returns values like ldap_get_entries but is
|
||||
//binary compatible
|
||||
$i=0;
|
||||
$fresult=array();
|
||||
$entry = ldap_first_entry($conn, $searchresult);
|
||||
do {
|
||||
$attributes = ldap_get_attributes($conn, $entry);
|
||||
for($j=0; $j<$attributes['count']; $j++) {
|
||||
$values = ldap_get_values_len($conn, $entry,$attributes[$j]);
|
||||
$fresult[$i][$attributes[$j]] = $values;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
while ($entry = ldap_next_entry($conn, $entry));
|
||||
//we're done
|
||||
return ($fresult);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
<tr valign="top">
|
||||
<td align="right"><p><?php print_string("instructions", "auth") ?>:</p></td>
|
||||
<td><textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php p($config->auth_instructions) ?></textarea>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("authinstructions","auth") ?>
|
||||
<?php helpbutton("text", get_string("helptext")) ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1,42 +0,0 @@
|
||||
<?PHP // $Id$
|
||||
//
|
||||
// PAM (Pluggable Authentication Modules) for Moodle
|
||||
//
|
||||
// Description:
|
||||
// Authentication by using the PHP4 PAM module:
|
||||
// http://www.math.ohio-state.edu/~ccunning/pam_auth/
|
||||
//
|
||||
// Version 0.2: 2004/09/01 by Martin Vögeli (stable version)
|
||||
// Version 0.1: 2004/08/30 by Martin Vögeli (first draft)
|
||||
//
|
||||
// Contact: martinvoegeli@gmx.ch
|
||||
// Website 1: http://elearning.zhwin.ch/
|
||||
// Website 2: http://birdy1976.com/
|
||||
//
|
||||
// License: GPL License v2
|
||||
// // // // // // // // // // // // // // // // // // //
|
||||
|
||||
function auth_user_login ($username, $password) {
|
||||
global $CFG;
|
||||
// returns true if the username and password work
|
||||
// and false if they are wrong or don't exist
|
||||
// variable to store possible errors during authentication
|
||||
$strErrorPAM = " ";
|
||||
// the maximal length of returned messages is 512
|
||||
// let's double the number to give it enough space ;)
|
||||
// (the errror variable is passed by reference)
|
||||
for ($i = 1; $i <= 1024; $i++) {
|
||||
$strErrorPAM += "{$strErrorPAM} ";
|
||||
}
|
||||
// just for testing and debugging
|
||||
// error_reporting(E_ALL);
|
||||
// finally the actual authentication part...
|
||||
if (pam_auth($username, $password, &$strErrorPAM)) {
|
||||
// authentication success
|
||||
return true;
|
||||
} else {
|
||||
// authentication failure
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
+1
-15
@@ -1,4 +1,4 @@
|
||||
<?PHP // $Id$
|
||||
<?PHP
|
||||
if (!isset($config->auth_pop3host)) {
|
||||
$config->auth_pop3host = "127.0.0.1";
|
||||
}
|
||||
@@ -8,9 +8,6 @@
|
||||
if (!isset($config->auth_pop3port)) {
|
||||
$config->auth_pop3port = "110";
|
||||
}
|
||||
if (!isset($config->auth_pop3mailbox)) {
|
||||
$config->auth_pop3mailbox = "INBOX";
|
||||
}
|
||||
?>
|
||||
<tr valign="top" BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3host:</TD>
|
||||
@@ -50,17 +47,6 @@
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP BGCOLOR="<?php echo $THEME->cellheading2 ?>">
|
||||
<TD ALIGN=RIGHT><P>auth_pop3mailbox:</TD>
|
||||
<TD>
|
||||
<INPUT name=auth_pop3mailbox TYPE=text SIZE=6 VALUE="<?php echo $config->auth_pop3mailbox?>">
|
||||
<?php if (isset($err["auth_pop3mailbox"])) formerr($err["auth_pop3mailbox"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_pop3mailbox","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR VALIGN=TOP>
|
||||
<TD ALIGN=RIGHT><P><?php print_string("instructions", "auth") ?>:</TD>
|
||||
<TD>
|
||||
|
||||
+4
-9
@@ -12,26 +12,21 @@ function auth_user_login ($username, $password) {
|
||||
foreach ($hosts as $host) { // Try each host in turn
|
||||
|
||||
$host = trim($host);
|
||||
|
||||
// remove any trailing slash
|
||||
if (substr($host, -1) == '/') {
|
||||
$host = substr($host, 0, strlen($host) - 1);
|
||||
}
|
||||
|
||||
switch ($CFG->auth_pop3type) {
|
||||
case "pop3":
|
||||
$host = '{'.$host.":$CFG->auth_pop3port/pop3}$CFG->auth_pop3mailbox";
|
||||
$host = '{'.$host.":$CFG->auth_pop3port/pop3}INBOX";
|
||||
break;
|
||||
case "pop3notls":
|
||||
$host = '{'.$host.":$CFG->auth_pop3port/pop3/notls}$CFG->auth_pop3mailbox";
|
||||
$host = '{'.$host.":$CFG->auth_pop3port/pop3/notls}INBOX";
|
||||
break;
|
||||
case "pop3cert":
|
||||
$host = '{'.$host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}$CFG->auth_pop3mailbox";
|
||||
$host = '{'.$host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
|
||||
break;
|
||||
}
|
||||
|
||||
error_reporting(0);
|
||||
$connection = imap_open($host, $username, $password);
|
||||
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
||||
error_reporting($CFG->debug);
|
||||
|
||||
if ($connection) {
|
||||
|
||||
+4
-4
@@ -49,11 +49,11 @@
|
||||
print_header("$site->shortname: $strcoursebackup", $site->fullname,
|
||||
"<A HREF=\"$CFG->wwwroot/$CFG->admin/index.php\">$stradministration</A> -> $strcoursebackup");
|
||||
|
||||
if ($courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname')) {
|
||||
if ($courses = get_courses()) {
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
foreach ($courses as $course) {
|
||||
echo "<A HREF=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
|
||||
echo "<A HREF=\"backup.php?id=$course->id\">$course->fullname ($course->shortname)</A><BR>";
|
||||
}
|
||||
print_simple_box_end();
|
||||
} else {
|
||||
@@ -87,8 +87,8 @@
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("128M");
|
||||
ini_set("max_execution_time","3000");
|
||||
ini_set("memory_limit","80M");
|
||||
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
}
|
||||
?>
|
||||
|
||||
<form name="form" method="post" action="backup.php">
|
||||
<form name="form" method="post" action="<?php echo $ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?php
|
||||
|
||||
@@ -115,8 +115,6 @@
|
||||
$backup_name .= userdate(time(),$backup_date_format,99,false);
|
||||
//The extension
|
||||
$backup_name .= ".zip";
|
||||
//And finally, clean everything
|
||||
$backup_name = clean_filename($backup_name);
|
||||
|
||||
//Add as text field
|
||||
echo "<input type=\"text\" name=\"backup_name\" size=\"40\" value=\"".$backup_name."\">";
|
||||
|
||||
@@ -88,8 +88,7 @@
|
||||
if (!isset($backup_name)) {
|
||||
error ("Backup name not specified");
|
||||
}
|
||||
//We clean it again (to prevent diacritics entered manually)
|
||||
$preferences->backup_name = clean_filename($backup_name);
|
||||
$preferences->backup_name = $backup_name;
|
||||
|
||||
if (!isset($backup_unique_code)) {
|
||||
error ("Backup unique code not specified");
|
||||
@@ -114,7 +113,7 @@
|
||||
echo "<td align=\"right\"><P><B>";
|
||||
echo get_string("name").":";
|
||||
echo "</B></td><td>";
|
||||
echo $preferences->backup_name;
|
||||
echo $backup_name;
|
||||
echo "</td></tr>";
|
||||
|
||||
//Start the main tr, where all the backup progress is done
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
?>
|
||||
|
||||
<form name="form" method="post" action="backup.php">
|
||||
<form name="form" method="post" action="<?php echo $ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?php
|
||||
if ($allmods = get_records("modules") ) {
|
||||
|
||||
+55
-105
@@ -13,7 +13,7 @@ function schedule_backup_cron() {
|
||||
|
||||
//Check for required functions...
|
||||
if(!function_exists('utf8_encode')) {
|
||||
mtrace(" ERROR: You need to add XML support to your PHP installation!");
|
||||
echo " ERROR: You need to add XML support to your PHP installation!\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ function schedule_backup_cron() {
|
||||
|
||||
//First of all, we have to see if the scheduled is active and detect
|
||||
//that there isn't another cron running
|
||||
mtrace(" Checking backup status",'...');
|
||||
echo " Checking backup status";
|
||||
$backup_config = backup_get_config();
|
||||
if(!isset($backup_config->backup_sche_active) || !$backup_config->backup_sche_active) {
|
||||
mtrace("INACTIVE");
|
||||
echo "...INACTIVE\n";
|
||||
return true;
|
||||
} else if (isset($backup_config->backup_sche_running) && $backup_config->backup_sche_running) {
|
||||
mtrace("RUNNING");
|
||||
echo "...RUNNING\n";
|
||||
//Now check if it's a really running task or something very old looking
|
||||
//for info in backup_logs to unlock status as necessary
|
||||
$timetosee = 1800; //Half an hour looking for activity
|
||||
@@ -36,55 +36,33 @@ function schedule_backup_cron() {
|
||||
$numofrec = count_records_select ("backup_log","time > $timeafter");
|
||||
if (!$numofrec) {
|
||||
$timetoseemin = $timetosee/60;
|
||||
mtrace(" No activity in last ".$timetoseemin." minutes. Unlocking status");
|
||||
echo " No activity in last ".$timetoseemin." minutes. Unlocking status\n";
|
||||
} else {
|
||||
mtrace(" Scheduled backup seems to be running. Execution delayed");
|
||||
echo " Scheduled backup seems to be running. Execution delayed\n";
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
mtrace("OK");
|
||||
echo "...OK\n";
|
||||
//Mark backup_sche_running
|
||||
backup_set_config("backup_sche_running","1");
|
||||
}
|
||||
|
||||
//Now we get the main admin user (we'll use his timezone, mail...)
|
||||
mtrace(" Getting admin info");
|
||||
echo " Getting admin info\n";
|
||||
$admin = get_admin();
|
||||
if (!$admin) {
|
||||
$status = false;
|
||||
}
|
||||
|
||||
//Delete old_entries from backup tables
|
||||
if ($status) {
|
||||
mtrace(" Deleting old data");
|
||||
$status = backup_delete_old_data();
|
||||
}
|
||||
|
||||
//Now we get a list of courses in the server
|
||||
if ($status) {
|
||||
mtrace(" Checking courses");
|
||||
//First of all, we delete everything from backup tables related to deleted courses
|
||||
mtrace(" Skipping deleted courses");
|
||||
$skipped = 0;
|
||||
if ($bckcourses = get_records('backup_courses')) {
|
||||
foreach($bckcourses as $bckcourse) {
|
||||
//Search if it exists
|
||||
if (!$exists = get_record('course', 'id', "$bckcourse->courseid")) {
|
||||
//Doesn't exist, so delete from backup tables
|
||||
delete_records('backup_courses', 'courseid', "$bckcourse->courseid");
|
||||
delete_records('backup_log', 'courseid', "$bckcourse->courseid");
|
||||
$skipped++;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtrace(" $skipped courses");
|
||||
//Now process existing courses
|
||||
echo " Checking courses\n";
|
||||
$courses = get_records("course");
|
||||
//For each course, we check (insert, update) the backup_course table
|
||||
//with needed data
|
||||
foreach ($courses as $course) {
|
||||
if ($status) {
|
||||
mtrace(" $course->fullname");
|
||||
echo " $course->fullname\n";
|
||||
//We check if the course exists in backup_course
|
||||
$backup_course = get_record("backup_courses","courseid",$course->id);
|
||||
//If it doesn't exist, create
|
||||
@@ -96,30 +74,25 @@ function schedule_backup_cron() {
|
||||
}
|
||||
//If it doesn't exist now, error
|
||||
if (!$backup_course) {
|
||||
mtrace(" ERROR (in backup_courses detection)");
|
||||
echo " ERROR (in backup_courses detection)\n";
|
||||
$status = false;
|
||||
}
|
||||
//Now we backup every course with nextstarttime < now
|
||||
if ($backup_course->nextstarttime > 0 && $backup_course->nextstarttime < $now) {
|
||||
//Set laststarttime
|
||||
$starttime = time();
|
||||
set_field("backup_courses","laststarttime",$starttime,"courseid",$backup_course->courseid);
|
||||
//Launch backup
|
||||
$course_status = schedule_backup_launch_backup($course,$starttime);
|
||||
//We have to send a email because we have included at least one backup
|
||||
$emailpending = true;
|
||||
//Only make the backup if laststatus isn't 2-UNFINISHED (uncontrolled error)
|
||||
if ($backup_course->laststatus != 2) {
|
||||
//Set laststarttime
|
||||
$starttime = time();
|
||||
set_field("backup_courses","laststarttime",$starttime,"courseid",$backup_course->courseid);
|
||||
//Set course status to unfinished, the process will reset it
|
||||
set_field("backup_courses","laststatus","2","courseid",$backup_course->courseid);
|
||||
//Launch backup
|
||||
$course_status = schedule_backup_launch_backup($course,$starttime);
|
||||
//Set lastendtime
|
||||
set_field("backup_courses","lastendtime",time(),"courseid",$backup_course->courseid);
|
||||
//Set laststatus
|
||||
if ($course_status) {
|
||||
set_field("backup_courses","laststatus","1","courseid",$backup_course->courseid);
|
||||
} else {
|
||||
set_field("backup_courses","laststatus","0","courseid",$backup_course->courseid);
|
||||
}
|
||||
//Set lastendtime
|
||||
set_field("backup_courses","lastendtime",time(),"courseid",$backup_course->courseid);
|
||||
//Set laststatus
|
||||
if ($course_status) {
|
||||
set_field("backup_courses","laststatus","1","courseid",$backup_course->courseid);
|
||||
} else {
|
||||
set_field("backup_courses","laststatus","0","courseid",$backup_course->courseid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,59 +105,37 @@ function schedule_backup_cron() {
|
||||
if ($nextstarttime > 0) {
|
||||
$showtime = userdate($nextstarttime,"",$admin->timezone);
|
||||
}
|
||||
mtrace(" Next execution: $showtime");
|
||||
echo " Next execution: $showtime\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Delete old logs
|
||||
if (!empty($CFG->loglifetime)) {
|
||||
mtrace(" Deleting old logs");
|
||||
echo " Deleting old logs\n";
|
||||
$loglifetime = $now - ($CFG->loglifetime * 86400);
|
||||
delete_records_select("backup_log", "laststarttime < '$loglifetime'");
|
||||
}
|
||||
|
||||
//Send email to admin if necessary
|
||||
//Send email to admin
|
||||
if ($emailpending) {
|
||||
mtrace(" Sending email to admin");
|
||||
echo " Sending email to admin\n";
|
||||
$message = "";
|
||||
|
||||
//Get info about the status of courses
|
||||
$count_all = count_records('backup_courses');
|
||||
$count_ok = count_records('backup_courses','laststatus','1');
|
||||
$count_error = count_records('backup_courses','laststatus','0');
|
||||
$count_unfinished = count_records('backup_courses','laststatus','2');
|
||||
|
||||
//Build the message text
|
||||
//Summary
|
||||
$message .= get_string('summary')."\n";
|
||||
$message .= "==================================================\n";
|
||||
$message .= " ".get_string('courses').": ".$count_all."\n";
|
||||
$message .= " ".get_string('ok').": ".$count_ok."\n";
|
||||
$message .= " ".get_string('error').": ".$count_error."\n";
|
||||
$message .= " ".get_string('unfinished').": ".$count_unfinished."\n\n";
|
||||
|
||||
//Reference
|
||||
if ($count_error != 0 || $count_unfinished != 0) {
|
||||
$message .= " ".get_string('backupfailed')."\n\n";
|
||||
$dest_url = $CFG->wwwroot.'/backup/log.php';
|
||||
$message .= " ".get_string('backuptakealook','',$dest_url)."\n\n";
|
||||
//Reset unfinished to error
|
||||
set_field('backup_courses','laststatus','0','laststatus','2');
|
||||
} else {
|
||||
$message .= " ".get_string('backupfinished')."\n";
|
||||
//Build the message text (future versions should handle html messages too!!)
|
||||
$logs = get_records_select ("backup_log","laststarttime >= '$now'","id");
|
||||
if ($logs) {
|
||||
$currentcourse = 1;
|
||||
foreach ($logs as $log) {
|
||||
if ($currentcourse != $log->courseid) {
|
||||
$message .= "\n==================================================\n\n";
|
||||
$currentcourse = $log->courseid;
|
||||
}
|
||||
$message .= userdate($log->time,"%T",$admin->timezone)." ".$log->info."\n";
|
||||
}
|
||||
}
|
||||
|
||||
//Build the message subject
|
||||
$site = get_site();
|
||||
$prefix = $site->shortname.": ";
|
||||
if ($count_error != 0 || $count_unfinished != 0) {
|
||||
$prefix .= "[".strtoupper(get_string('error'))."] ";
|
||||
}
|
||||
$subject = $prefix.get_string("scheduledbackupstatus");
|
||||
|
||||
//Send the message
|
||||
email_to_user($admin,$admin,$subject,$message);
|
||||
$site = get_site();
|
||||
email_to_user($admin,$admin,"$site->shortname: ".get_string("scheduledbackupstatus"),$message);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +152,7 @@ function schedule_backup_launch_backup($course,$starttime = 0) {
|
||||
$preferences = false;
|
||||
$status = false;
|
||||
|
||||
mtrace(" Executing backup");
|
||||
echo " Executing backup\n";
|
||||
schedule_backup_log($starttime,$course->id,"Start backup course $course->fullname");
|
||||
schedule_backup_log($starttime,$course->id," Phase 1: Checking and counting:");
|
||||
$preferences = schedule_backup_course_configure($course,$starttime);
|
||||
@@ -210,7 +161,6 @@ function schedule_backup_launch_backup($course,$starttime = 0) {
|
||||
schedule_backup_log($starttime,$course->id," Phase 2: Executing and copying:");
|
||||
$status = schedule_backup_course_execute($preferences,$starttime);
|
||||
}
|
||||
|
||||
if ($status && $preferences) {
|
||||
//Only if the backup_sche_keep is set
|
||||
if ($preferences->backup_keep) {
|
||||
@@ -218,12 +168,11 @@ function schedule_backup_launch_backup($course,$starttime = 0) {
|
||||
$status = schedule_backup_course_delete_old_files($preferences,$starttime);
|
||||
}
|
||||
}
|
||||
|
||||
if ($status && $preferences) {
|
||||
mtrace(" End backup OK");
|
||||
echo " End backup OK\n";
|
||||
schedule_backup_log($starttime,$course->id,"End backup course $course->fullname - OK");
|
||||
} else {
|
||||
mtrace(" End backup with ERROR");
|
||||
echo " End backup with ERROR\n";
|
||||
schedule_backup_log($starttime,$course->id,"End backup course $course->fullname - ERROR!!");
|
||||
}
|
||||
|
||||
@@ -238,7 +187,7 @@ function schedule_backup_log($starttime,$courseid,$message) {
|
||||
$log->courseid = $courseid;
|
||||
$log->time = time();
|
||||
$log->laststarttime = $starttime;
|
||||
$log->info = addslashes($message);
|
||||
$log->info = $message;
|
||||
|
||||
insert_record ("backup_log",$log);
|
||||
}
|
||||
@@ -425,15 +374,11 @@ function schedule_backup_course_configure($course,$starttime = 0) {
|
||||
$backup_name .= userdate(time(),$backup_date_format,99,false);
|
||||
//The extension
|
||||
$backup_name .= ".zip";
|
||||
//And finally, clean everything
|
||||
$backup_name = clean_filename($backup_name);
|
||||
|
||||
//Calculate the string to match the keep preference
|
||||
$keep_name = $backup_word."-";
|
||||
//The shortname
|
||||
$keep_name .= strtolower($backup_shortname)."-";
|
||||
//And finally, clean everything
|
||||
$keep_name = clean_filename($keep_name);
|
||||
|
||||
$preferences->backup_name = $backup_name;
|
||||
$preferences->keep_name = $keep_name;
|
||||
@@ -534,12 +479,17 @@ function schedule_backup_course_execute($preferences,$starttime = 0) {
|
||||
//Create them as needed
|
||||
schedule_backup_log($starttime,$preferences->backup_course," checking temp structures");
|
||||
$status = check_and_create_backup_dir($preferences->backup_unique_code);
|
||||
//Empty backup dir
|
||||
//Empty dir
|
||||
if ($status) {
|
||||
schedule_backup_log($starttime,$preferences->backup_course," cleaning current dir");
|
||||
schedule_backup_log($starttime,$preferences->backup_course," cleaning old data");
|
||||
$status = clear_backup_dir($preferences->backup_unique_code);
|
||||
}
|
||||
|
||||
//Delete old_entries from backup tables
|
||||
if ($status) {
|
||||
$status = backup_delete_old_data();
|
||||
}
|
||||
|
||||
//Create the moodle.xml file
|
||||
if ($status) {
|
||||
schedule_backup_log($starttime,$preferences->backup_course," creating backup file");
|
||||
@@ -699,7 +649,7 @@ function schedule_backup_course_delete_old_files($preferences,$starttime=0) {
|
||||
$dirtocheck = $CFG->dataroot."/".$preferences->backup_course."/backupdata";
|
||||
}
|
||||
schedule_backup_log($starttime,$preferences->backup_course," checking $dirtocheck");
|
||||
mtrace(" Keeping backup files in $dirtocheck");
|
||||
echo " Keeping backup files in $dirtocheck\n";
|
||||
|
||||
//Get all the files in $dirtocheck
|
||||
$files = get_directory_list($dirtocheck,"",false);
|
||||
@@ -718,16 +668,16 @@ function schedule_backup_course_delete_old_files($preferences,$starttime=0) {
|
||||
//Count matching files
|
||||
$countmatching = count($matchingfiles);
|
||||
schedule_backup_log($starttime,$preferences->backup_course," found $countmatching backup files");
|
||||
mtrace(" found $countmatching backup files");
|
||||
echo " found $countmatching backup files\n";
|
||||
if ($preferences->backup_keep < $countmatching) {
|
||||
schedule_backup_log($starttime,$preferences->backup_course," keep limit ($preferences->backup_keep) reached. Deleting old files");
|
||||
mtrace(" keep limit ($preferences->backup_keep) reached. Deleting old files");
|
||||
echo " keep limit ($preferences->backup_keep) reached. Deleting old files\n";
|
||||
$filestodelete = $countmatching - $preferences->backup_keep;
|
||||
$filesdeleted = 0;
|
||||
foreach ($matchingfiles as $matchfile) {
|
||||
if ($filesdeleted < $filestodelete) {
|
||||
schedule_backup_log($starttime,$preferences->backup_course," $matchfile deleted");
|
||||
mtrace(" $matchfile deleted");
|
||||
echo " $matchfile deleted\n";
|
||||
$filetodelete = $dirtocheck."/".$matchfile;
|
||||
unlink($filetodelete);
|
||||
$filesdeleted++;
|
||||
|
||||
+54
-40
@@ -9,7 +9,7 @@
|
||||
$status = true;
|
||||
$status = execute_sql("INSERT INTO {$CFG->prefix}backup_ids
|
||||
(backup_code, table_name, old_id)
|
||||
SELECT DISTINCT $backup_unique_code,'quiz_categories',t.category
|
||||
SELECT DISTINCT '$backup_unique_code','quiz_categories',t.category
|
||||
FROM {$CFG->prefix}quiz_questions t,
|
||||
{$CFG->prefix}quiz_question_grades g,
|
||||
{$CFG->prefix}quiz q
|
||||
@@ -261,9 +261,8 @@
|
||||
$rootdir = $CFG->dataroot."/users";
|
||||
//Check if directory exists
|
||||
if (is_dir($rootdir)) {
|
||||
//Get directories without descend
|
||||
$userdirs = get_directory_list($rootdir,"",false,true,false);
|
||||
foreach ($userdirs as $dir) {
|
||||
$coursedirs = get_directory_list($rootdir);
|
||||
foreach ($coursedirs as $dir) {
|
||||
//Extracts user id from file path
|
||||
$tok = strtok($dir,"/");
|
||||
if ($tok) {
|
||||
@@ -314,8 +313,7 @@
|
||||
$rootdir = $CFG->dataroot."/$course";
|
||||
//Check if directory exists
|
||||
if (is_dir($rootdir)) {
|
||||
//Get files and directories without descend
|
||||
$coursedirs = get_directory_list($rootdir,$CFG->moddata,false,true,true);
|
||||
$coursedirs = get_directory_list($rootdir,$CFG->moddata);
|
||||
$backupdata_dir = "backupdata";
|
||||
foreach ($coursedirs as $dir) {
|
||||
//Check it isn't backupdata_dir
|
||||
@@ -466,13 +464,6 @@
|
||||
fwrite ($bf,full_tag("DATE",2,false,$preferences->backup_unique_code));
|
||||
//The original site wwwroot
|
||||
fwrite ($bf,full_tag("ORIGINAL_WWWROOT",2,false,$CFG->wwwroot));
|
||||
//The zip method used
|
||||
if (!empty($CFG->zip)) {
|
||||
$zipmethod = 'external';
|
||||
} else {
|
||||
$zipmethod = 'internal';
|
||||
}
|
||||
fwrite ($bf,full_tag("ZIP_METHOD",2,false,$zipmethod));
|
||||
//Te includes tag
|
||||
fwrite ($bf,start_tag("DETAILS",2,true));
|
||||
//Now, go to mod element of preferences to print its status
|
||||
@@ -543,12 +534,18 @@
|
||||
fwrite ($bf,start_tag("HEADER",2,true));
|
||||
|
||||
//Get info from course
|
||||
$course = get_record("course","id",$preferences->backup_course);
|
||||
$course=false;
|
||||
if ($courses = get_records("course","id",$preferences->backup_course)) {
|
||||
$course = $courses[$preferences->backup_course];
|
||||
}
|
||||
if ($course) {
|
||||
//Prints course info
|
||||
fwrite ($bf,full_tag("ID",3,false,$course->id));
|
||||
//Obtain the category
|
||||
$category = get_record("course_categories","id","$course->category");
|
||||
$category = false;
|
||||
if ($categories = get_records("course_categories","id","$course->category")) {
|
||||
$category = $categories[$course->category];
|
||||
}
|
||||
if ($category) {
|
||||
//Prints category info
|
||||
fwrite ($bf,start_tag("CATEGORY",3,true));
|
||||
@@ -560,7 +557,6 @@
|
||||
fwrite ($bf,full_tag("PASSWORD",3,false,$course->password));
|
||||
fwrite ($bf,full_tag("FULLNAME",3,false,$course->fullname));
|
||||
fwrite ($bf,full_tag("SHORTNAME",3,false,$course->shortname));
|
||||
fwrite ($bf,full_tag("IDNUMBER",3,false,$course->idnumber));
|
||||
fwrite ($bf,full_tag("SUMMARY",3,false,$course->summary));
|
||||
fwrite ($bf,full_tag("FORMAT",3,false,$course->format));
|
||||
fwrite ($bf,full_tag("SHOWGRADES",3,false,$course->showgrades));
|
||||
@@ -572,7 +568,6 @@
|
||||
fwrite ($bf,full_tag("STUDENTS",3,false,$course->students));
|
||||
fwrite ($bf,full_tag("GUEST",3,false,$course->guest));
|
||||
fwrite ($bf,full_tag("STARTDATE",3,false,$course->startdate));
|
||||
fwrite ($bf,full_tag("ENROLPERIOD",3,false,$course->enrolperiod));
|
||||
fwrite ($bf,full_tag("NUMSECTIONS",3,false,$course->numsections));
|
||||
//fwrite ($bf,full_tag("SHOWRECENT",3,false,$course->showrecent)); INFO: This is out in 1.3
|
||||
fwrite ($bf,full_tag("MAXBYTES",3,false,$course->maxbytes));
|
||||
@@ -580,7 +575,6 @@
|
||||
fwrite ($bf,full_tag("GROUPMODE",3,false,$course->groupmode));
|
||||
fwrite ($bf,full_tag("GROUPMODEFORCE",3,false,$course->groupmodeforce));
|
||||
fwrite ($bf,full_tag("LANG",3,false,$course->lang));
|
||||
fwrite ($bf,full_tag("COST",3,false,$course->cost));
|
||||
fwrite ($bf,full_tag("MARKER",3,false,$course->marker));
|
||||
fwrite ($bf,full_tag("VISIBLE",3,false,$course->visible));
|
||||
fwrite ($bf,full_tag("HIDDENSECTIONS",3,false,$course->hiddensections));
|
||||
@@ -723,7 +717,6 @@
|
||||
fwrite ($bf,start_tag("USER",3,true));
|
||||
//Output all user data
|
||||
fwrite ($bf,full_tag("ID",4,false,$user_data->id));
|
||||
fwrite ($bf,full_tag("AUTH",4,false,$user_data->auth));
|
||||
fwrite ($bf,full_tag("CONFIRMED",4,false,$user_data->confirmed));
|
||||
fwrite ($bf,full_tag("DELETED",4,false,$user_data->deleted));
|
||||
fwrite ($bf,full_tag("USERNAME",4,false,$user_data->username));
|
||||
@@ -753,7 +746,6 @@
|
||||
fwrite ($bf,full_tag("URL",4,false,$user_data->url));
|
||||
fwrite ($bf,full_tag("DESCRIPTION",4,false,$user_data->description));
|
||||
fwrite ($bf,full_tag("MAILFORMAT",4,false,$user_data->mailformat));
|
||||
fwrite ($bf,full_tag("MAILDIGEST",4,false,$user_data->maildigest));
|
||||
fwrite ($bf,full_tag("MAILDISPLAY",4,false,$user_data->maildisplay));
|
||||
fwrite ($bf,full_tag("HTMLEDITOR",4,false,$user_data->htmleditor));
|
||||
fwrite ($bf,full_tag("AUTOSUBSCRIBE",4,false,$user_data->autosubscribe));
|
||||
@@ -802,8 +794,6 @@
|
||||
fwrite ($bf,full_tag("AUTHORITY",6,false,$tea->authority));
|
||||
fwrite ($bf,full_tag("TEA_ROLE",6,false,$tea->role));
|
||||
fwrite ($bf,full_tag("EDITALL",6,false,$tea->editall));
|
||||
fwrite ($bf,full_tag("TIMESTART",6,false,$tea->timestart));
|
||||
fwrite ($bf,full_tag("TIMEEND",6,false,$tea->timeend));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",6,false,$tea->timemodified));
|
||||
fwrite ($bf,full_tag("TIMEACCESS",6,false,$tea->timeaccess));
|
||||
//Print ROLE end
|
||||
@@ -1066,10 +1056,8 @@
|
||||
fwrite ($bf,full_tag("TIMECREATED",4,false,$group->timecreated));
|
||||
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$group->timemodified));
|
||||
|
||||
//Now, backup groups_members, only if users are included
|
||||
if ($preferences->backup_users != 2) {
|
||||
$status2 = backup_groups_members_info($bf,$preferences,$group->id);
|
||||
}
|
||||
//Now, backup groups_members
|
||||
$status2 = backup_groups_members_info($bf,$preferences,$group->id);
|
||||
|
||||
//End group tag
|
||||
fwrite ($bf,end_tag("GROUP",3,true));
|
||||
@@ -1146,9 +1134,8 @@
|
||||
|
||||
//This function encode things to make backup multi-site fully functional
|
||||
//It does this conversions:
|
||||
// - $CFG->wwwroot/file.php/courseid ------------------> $@FILEPHP@$ (slasharguments links)
|
||||
// - $CFG->wwwroot/file.php?file=/courseid ------------> $@FILEPHP@$ (non-slasharguments links)
|
||||
// - Every module xxxx_encode_content_links() is executed too
|
||||
// - $CFG->wwwroot/file.php/courseid ----------------------> $@FILEPHP@$
|
||||
// - Links to forums everywhere (DB) are encoded.
|
||||
//
|
||||
function backup_encode_absolute_links($content) {
|
||||
|
||||
@@ -1165,10 +1152,9 @@
|
||||
}
|
||||
|
||||
//First, we check for every call to file.php inside the course
|
||||
$search = array($CFG->wwwroot.'/file.php/'.$mypreferences->backup_course,
|
||||
$CFG->wwwroot.'/file.php?file=/'.$mypreferences->backup_course);
|
||||
$search = array($CFG->wwwroot."/file.php/".$mypreferences->backup_course);
|
||||
|
||||
$replace = array('$@FILEPHP@$','$@FILEPHP@$');
|
||||
$replace = array("$@FILEPHP@$");
|
||||
|
||||
$result = str_replace($search,$replace,$content);
|
||||
|
||||
@@ -1271,20 +1257,48 @@
|
||||
$status = true;
|
||||
|
||||
//Base dir where everything happens
|
||||
$basedir = cleardoubleslashes($CFG->dataroot."/temp/backup/".$preferences->backup_unique_code);
|
||||
$basedir = $CFG->dataroot."/temp/backup/".$preferences->backup_unique_code;
|
||||
//Backup zip file name
|
||||
$name = $preferences->backup_name;
|
||||
//List of files and directories
|
||||
//List base_dir files and directories
|
||||
$filelist = list_directories_and_files ($basedir);
|
||||
|
||||
//Convert them to full paths
|
||||
$files = array();
|
||||
foreach ($filelist as $file) {
|
||||
$files[] = "$basedir/$file";
|
||||
if (empty($CFG->zip)) { // Use built-in php-based zip function
|
||||
//echo "<br>Using pclzip"; //Debug
|
||||
$files = array();
|
||||
foreach ($filelist as $file) {
|
||||
//If directory, append "/"
|
||||
//Commented. Not needed wit version 2.0 of pclzip !!
|
||||
//if (is_dir($basedir."/".$file)) {
|
||||
// $file = $file."/";
|
||||
//}
|
||||
//Include into array
|
||||
//echo "<br>Adding file/dir ".$file; //Debug
|
||||
$files[] = $basedir."/".$file;
|
||||
}
|
||||
include_once("$CFG->dirroot/lib/pclzip/pclzip.lib.php");
|
||||
//include_once("$CFG->dirroot/lib/pclzip/pclerror.lib.php"); //Debug
|
||||
//include_once("$CFG->dirroot/lib/pclzip/pcltrace.lib.php"); //Debug
|
||||
//PclTraceOn(2); //Debug
|
||||
$archive = new PclZip("$basedir/$name");
|
||||
if (($list = $archive->create($files,PCLZIP_OPT_REMOVE_PATH,$basedir)) == 0) {
|
||||
error($archive->errorInfo(true));
|
||||
$status = false;
|
||||
}
|
||||
//PclTraceDisplay(); //Debug
|
||||
//PclTraceOff(); //Debug
|
||||
} else { // Use external zip program
|
||||
//echo "<br>Using external zip"; //Debug
|
||||
$files = "";
|
||||
foreach ($filelist as $file) {
|
||||
$files .= basename($file);
|
||||
$files .= " ";
|
||||
}
|
||||
$command = "cd $basedir ; $CFG->zip -r $name $files";
|
||||
//echo "<br>Executing command: ".$command; //Debug
|
||||
$status = Exec($command);
|
||||
}
|
||||
|
||||
$status = zip_files($files, "$basedir/$name");
|
||||
|
||||
//echo "<br>Status: ".$status; //Debug
|
||||
return $status;
|
||||
|
||||
|
||||
+1
-2
@@ -82,7 +82,6 @@
|
||||
$keep_array[500] = "500";
|
||||
?>
|
||||
<form method="post" action="backup.php" name="form">
|
||||
<?php echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">"; ?>
|
||||
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
<tr valign=top>
|
||||
@@ -197,7 +196,7 @@
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td colspan = 3 align=center>
|
||||
<?php print_string("saveto") ?>: <input name="backup_sche_destination" type="text" size="40" value="<?php p($backup_config->backup_sche_destination) ?>"><?php helpbutton("directorypaths", strip_tags(get_string("directorypaths"))) ?><br><?php if (!empty($sche_destination_error)) { formerr($sche_destination_error); echo "<br>"; } ?><?php print_string("backupsavetohelp") ?>
|
||||
<?php print_string("saveto") ?>: <input name="backup_sche_destination" type="text" size="40" value="<?php p($backup_config->backup_sche_destination) ?>"><br><?php if (!empty($sche_destination_error)) { formerr($sche_destination_error); echo "<br>"; } ?><?php print_string("backupsavetohelp") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
+4
-5
@@ -25,15 +25,15 @@
|
||||
}
|
||||
|
||||
//Delete old data in backup tables (if exists)
|
||||
//Four hours seem to be appropiate now that backup is stable
|
||||
//Two days seems to be apropiate
|
||||
function backup_delete_old_data() {
|
||||
|
||||
global $CFG;
|
||||
|
||||
//Change this if you want !!
|
||||
$hours = 4;
|
||||
$days = 2;
|
||||
//End change this
|
||||
$seconds = $hours * 60 * 60;
|
||||
$seconds = $days * 24 * 60 * 60;
|
||||
$delete_from = time()-$seconds;
|
||||
//Now delete from tables
|
||||
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids
|
||||
@@ -56,8 +56,7 @@
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
//Get files and directories in the temp backup dir witout descend
|
||||
$list = get_directory_list($CFG->dataroot."/temp/backup", "", false, true, true);
|
||||
$list = get_directory_list($CFG->dataroot."/temp/backup", "", false);
|
||||
foreach ($list as $file) {
|
||||
$file_path = $CFG->dataroot."/temp/backup/".$file;
|
||||
$moddate = filemtime($file_path);
|
||||
|
||||
+6
-9
@@ -28,7 +28,6 @@
|
||||
$strftimetime = get_string("strftimetime").":%S";
|
||||
$strerror = get_string("error");
|
||||
$strok = get_string("ok");
|
||||
$strunfinished = get_string("unfinished");
|
||||
$strcourse = get_string("course");
|
||||
$strtimetaken = get_string("timetaken","quiz");
|
||||
$strstatus = get_string("status");
|
||||
@@ -40,7 +39,7 @@
|
||||
print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname,
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"../$CFG->admin/configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"../$CFG->admin/backup.php?sesskey=$USER->sesskey\">$strbackup</a> -> ".
|
||||
"<a href=\"../$CFG->admin/backup.php\">$strbackup</a> -> ".
|
||||
$strlogs);
|
||||
|
||||
print_heading($backuploglaststatus);
|
||||
@@ -67,12 +66,10 @@
|
||||
echo "<td nowrap><font size=2>".userdate($course->laststarttime,$strftimedatetime)."</td>";
|
||||
echo "<td nowrap><font size=2> - </td>";
|
||||
echo "<td nowrap><font size=2>".userdate($course->lastendtime,$strftimedatetime)."</td>";
|
||||
if ($course->laststatus == 1) {
|
||||
echo "<td nowrap align=center><font size=2 color=green>".$strok."</td>";
|
||||
} else if ($course->laststatus == 2) {
|
||||
echo "<td nowrap align=center><font size=2 color=red>".$strunfinished."</td>";
|
||||
} else {
|
||||
if (!$course->laststatus) {
|
||||
echo "<td nowrap align=center><font size=2 color=red>".$strerror."</td>";
|
||||
} else {
|
||||
echo "<td nowrap align=center><font size=2 color=green>".$strok."</td>";
|
||||
}
|
||||
echo "<td nowrap><font size=2>".userdate($course->nextstarttime,$strftimedatetime)."</td>";
|
||||
echo "</tr>";
|
||||
@@ -86,7 +83,7 @@
|
||||
print_header("$site->shortname: $strconfiguration: $strbackup", $site->fullname,
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradmin</a> -> ".
|
||||
"<a href=\"../$CFG->admin/configure.php\">$strconfiguration</a> -> ".
|
||||
"<a href=\"../$CFG->admin/backup.php?sesskey=$USER->sesskey\">$strbackup</a> -> ".
|
||||
"<a href=\"../$CFG->admin/backup.php\">$strbackup</a> -> ".
|
||||
"<a href=\"log.php\">$strlogs</a> -> ".
|
||||
$strbackupdetails);
|
||||
|
||||
@@ -118,7 +115,7 @@
|
||||
FROM {$CFG->prefix}backup_log
|
||||
WHERE courseid = '$courseid' AND
|
||||
laststarttime = '$execution->laststarttime'
|
||||
ORDER BY id");
|
||||
ORDER BY time");
|
||||
if ($logs) {
|
||||
foreach ($logs as $log) {
|
||||
echo "<tr nowrap>";
|
||||
|
||||
+2
-2
@@ -94,8 +94,8 @@
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("memory_limit","128M");
|
||||
ini_set("max_execution_time","3000");
|
||||
ini_set("memory_limit","80M");
|
||||
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
|
||||
@@ -116,18 +116,18 @@
|
||||
}
|
||||
|
||||
//Depending the selected restoreto:
|
||||
// If user is a teacher (and not creator):
|
||||
// If user is a teacher (and nor admin):
|
||||
// 0-Current course, deleting: Put $restore->course_id and $restore->deleting (true), create the restore object
|
||||
// 1-Current course, adding: Put $restore->course_id and $restore->deleting (false), create the restore object
|
||||
// If the uses is a creator:
|
||||
// If the uses is an admin:
|
||||
// 0-Existing course, deleting: Select the destination course and launch the check again, then
|
||||
// put $restore->course_id and $restore->deleting (true), create the restore object.
|
||||
// 1-Existing course, adding: Select the destination course and launch the check again, then
|
||||
// put $restore->course_id and $restore->deleting (false), create the restore object.
|
||||
// 2-New course: Create the restore object and launch the execute.
|
||||
|
||||
//If the user is a teacher and not a creator
|
||||
if (isteacheredit($id) and !iscreator()) {
|
||||
//If the user is a teacher and not an admin
|
||||
if (isteacher($id) and !isadmin()) {
|
||||
$restore->course_id = $id;
|
||||
if ($restore->restoreto == 0) {
|
||||
$restore->deleting = true;
|
||||
@@ -136,8 +136,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
//If the user is a creator (or admin)
|
||||
if (iscreator()) {
|
||||
//If the user is an admin
|
||||
if (isadmin()) {
|
||||
//Set restore->deleting as needed
|
||||
if ($restore->restoreto == 0) {
|
||||
$restore->deleting = true;
|
||||
@@ -147,8 +147,8 @@
|
||||
}
|
||||
|
||||
//Now, select the course if needed
|
||||
if (($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id == 0) and (iscreator())) {
|
||||
if ($courses = get_courses("all","c.fullname","c.id,c.fullname,c.shortname")) {
|
||||
if (($restore->restoreto == 0 or $restore->restoreto == 1) and ($restore->course_id == 0) and (isadmin())) {
|
||||
if ($courses = get_courses("all","c.fullname")) {
|
||||
print_heading(get_string("choosecourse"));
|
||||
print_simple_box_start("CENTER");
|
||||
foreach ($courses as $course) {
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
//Saving conversion id variables into backup_tables
|
||||
if ($restore->restoreto == 2) {
|
||||
echo "<li>".get_string("creatingnewcourse");
|
||||
$oldidnumber = $course_header->course_idnumber;
|
||||
if (!$status = restore_create_new_course($restore,$course_header)) {
|
||||
notify("Error while creating the new empty course.");
|
||||
}
|
||||
@@ -73,9 +72,6 @@
|
||||
echo "<ul>";
|
||||
echo "<li>".$course_header->course_fullname." (".$course_header->course_shortname.")";
|
||||
echo "<li>".get_string("category").": ".$course_header->category->name;
|
||||
if (!empty($oldidnumber)) {
|
||||
echo "<li>".get_string("nomoreidnumber","moodle",$oldidnumber)."</li>";
|
||||
}
|
||||
echo "</ul>";
|
||||
//Put the destination course_id
|
||||
$restore->course_id = $course_header->course_id;
|
||||
@@ -294,21 +290,13 @@
|
||||
//Now if all is OK, update:
|
||||
// - course modinfo field
|
||||
// - categories table
|
||||
// - add user as teacher
|
||||
if ($status) {
|
||||
echo "<li>".get_string("checkingcourse");
|
||||
//modinfo field
|
||||
rebuild_course_cache($restore->course_id);
|
||||
//categories table
|
||||
$course = get_record("course","id",$restore->course_id);
|
||||
fix_course_sortorder();
|
||||
//Make the user a teacher if the course hasn't teachers (bug 2381)
|
||||
if (!isadmin()) {
|
||||
if (!$checktea = get_records('user_teachers','course', $restore->course_id)) {
|
||||
//Add the teacher to the course
|
||||
$status = add_teacher($USER->id, $restore->course_id);
|
||||
}
|
||||
}
|
||||
fix_course_sortorder($course->category);
|
||||
}
|
||||
|
||||
//Cleanup temps (files and db)
|
||||
|
||||
+10
-11
@@ -101,19 +101,18 @@
|
||||
<SCRIPT LANGUAGE="JavaScript">
|
||||
<!--
|
||||
function selectItemInMenuByName(formId, menuName, selectIndex ) {
|
||||
myForm = document.getElementById(formId)
|
||||
for (i=0,n=myForm.elements.length;i<n;i++) {
|
||||
myLen = menuName.length;
|
||||
myName = myForm.elements[i].name;
|
||||
myType = myForm.elements[i].type;
|
||||
if (myName.substring(0,myLen) == menuName && myType == "select-one")
|
||||
myForm.elements[i].options[selectIndex].selected = true;
|
||||
}
|
||||
myForm = document.getElementById(formId)
|
||||
for (i=0,n=myForm.elements.length;i<n;i++) {
|
||||
myLen = menuName.length;
|
||||
myName = myForm.elements[i].name;
|
||||
if (myName.substring(0,myLen) == menuName)
|
||||
myForm.elements[i].options[selectIndex].selected = true;
|
||||
}
|
||||
}
|
||||
-->
|
||||
</script>
|
||||
|
||||
<form name="form1" id="form1" method="post" action="restore.php">
|
||||
<form name="form1" id="form1" method="post" action="<?php echo $ME ?>">
|
||||
<table cellpadding=5>
|
||||
<?php
|
||||
|
||||
@@ -123,11 +122,11 @@ function selectItemInMenuByName(formId, menuName, selectIndex ) {
|
||||
echo "<td align=\"right\"><P><b>";
|
||||
echo get_string("restoreto").":</b>";
|
||||
echo "</td><td>";
|
||||
if (isteacheredit($id) and !iscreator()) {
|
||||
if (isteacheredit($id) and !isadmin()) {
|
||||
$restore_restoreto_options[0] = get_string("currentcoursedeleting");
|
||||
$restore_restoreto_options[1] = get_string("currentcourseadding");
|
||||
}
|
||||
if (iscreator()) {
|
||||
if (isadmin()) {
|
||||
$restore_restoreto_options[0] = get_string("existingcoursedeleting");
|
||||
$restore_restoreto_options[1] = get_string("existingcourseadding");
|
||||
$restore_restoreto_options[2] = get_string("newcourse");
|
||||
|
||||
@@ -52,10 +52,10 @@
|
||||
$backup_unique_code = time();
|
||||
|
||||
//Now check and create the backup dir (if it doesn't exist)
|
||||
echo "<li>".get_string("creatingtemporarystructures");
|
||||
$status = check_and_create_backup_dir($backup_unique_code);
|
||||
//Empty dir
|
||||
if ($status) {
|
||||
echo "<li>".get_string("creatingtemporarystructures");
|
||||
$status = clear_backup_dir($backup_unique_code);
|
||||
}
|
||||
|
||||
@@ -109,16 +109,6 @@
|
||||
echo "</tr></td>";
|
||||
echo "</table>";
|
||||
|
||||
//We compare Moodle's versions
|
||||
if ($CFG->version < $info->backup_moodle_version && $status) {
|
||||
$message->serverversion = $CFG->version;
|
||||
$message->serverrelease = $CFG->release;
|
||||
$message->backupversion = $info->backup_moodle_version;
|
||||
$message->backuprelease = $info->backup_moodle_release;
|
||||
print_simple_box(get_string('noticenewerbackup','',$message), "center", "70%", "$THEME->cellheading2", "20", "noticebox");
|
||||
|
||||
}
|
||||
|
||||
//Now we print in other table, the backup and the course it contains info
|
||||
if ($info and $course_header and $status) {
|
||||
//First, the course info
|
||||
|
||||
+42
-99
@@ -5,8 +5,27 @@
|
||||
//It automatically uses pclzip or command line unzip
|
||||
function restore_unzip ($file) {
|
||||
|
||||
return unzip_file($file, '', false);
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
||||
if (empty($CFG->unzip)) { // Use built-in php-based unzip function
|
||||
include_once("$CFG->dirroot/lib/pclzip/pclzip.lib.php");
|
||||
//include_once("$CFG->dirroot/lib/pclzip/pclerror.lib.php"); //Debug
|
||||
//include_once("$CFG->dirroot/lib/pclzip/pcltrace.lib.php"); //Debug
|
||||
//PclTraceOn(2); //Debug
|
||||
$archive = new PclZip($file);
|
||||
if (!$list = $archive->extract(dirname($file))) {
|
||||
$status = false;
|
||||
}
|
||||
//PclTraceDisplay(); //Debug
|
||||
//PclTraceOff(); //Debug
|
||||
} else { // Use external unzip program
|
||||
$command = "cd ".dirname($file)."; $CFG->unzip -o ".basename($file);
|
||||
Exec($command);
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
//This function checks if moodle.xml seems to be a valid xml file
|
||||
@@ -106,22 +125,19 @@
|
||||
}
|
||||
|
||||
$formatwiki = FORMAT_WIKI;
|
||||
$typewiki = WIKITEXT;
|
||||
|
||||
//FORUM: Decode every POST (message) in the course
|
||||
//Check we are restoring forums
|
||||
if ($restore->mods['forum']->restore == 1) {
|
||||
echo "<li>".get_string("from")." ".get_string("modulenameplural","forum");
|
||||
//Get all course posts being restored
|
||||
//Get all course posts
|
||||
if ($posts = get_records_sql ("SELECT p.id, p.message
|
||||
FROM {$CFG->prefix}forum_posts p,
|
||||
{$CFG->prefix}forum_discussions d,
|
||||
{$CFG->prefix}backup_ids b
|
||||
{$CFG->prefix}forum_discussions d
|
||||
WHERE d.course = $restore->course_id AND
|
||||
p.discussion = d.id AND
|
||||
p.format = $formatwiki AND
|
||||
b.backup_code = $restore->backup_unique_code AND
|
||||
b.table_name = 'forum_posts' AND
|
||||
b.new_id = p.id")) {
|
||||
p.format = $formatwiki")) {
|
||||
//Iterate over each post->message
|
||||
$i = 0; //Counter to send some output to the browser to avoid timeouts
|
||||
foreach ($posts as $post) {
|
||||
@@ -156,16 +172,11 @@
|
||||
//Check we are restoring resources
|
||||
if ($restore->mods['resource']->restore == 1) {
|
||||
echo "<li>".get_string("from")." ".get_string("modulenameplural","resource");
|
||||
//Get all course resources of type='text' and options=FORMAT_WIKI being restored
|
||||
//Get all course resources of type=8 WIKITEXT
|
||||
if ($resources = get_records_sql ("SELECT r.id, r.alltext
|
||||
FROM {$CFG->prefix}resource r,
|
||||
{$CFG->prefix}backup_ids b
|
||||
FROM {$CFG->prefix}resource r
|
||||
WHERE r.course = $restore->course_id AND
|
||||
r.type = 'text' AND
|
||||
r.options = $formatwiki AND
|
||||
b.backup_code = $restore->backup_unique_code AND
|
||||
b.table_name = 'resource' AND
|
||||
b.new_id = r.id")) {
|
||||
r.type = $typewiki")) {
|
||||
//Iterate over each resource->alltext
|
||||
$i = 0; //Counter to send some output to the browser to avoid timeouts
|
||||
foreach ($resources as $resource) {
|
||||
@@ -517,9 +528,7 @@
|
||||
$course->password = addslashes($course_header->course_password);
|
||||
$course->fullname = addslashes($course_header->course_fullname);
|
||||
$course->shortname = addslashes($course_header->course_shortname);
|
||||
$course->idnumber = addslashes($course_header->course_idnumber);
|
||||
$course->idnumber = ''; //addslashes($course_header->course_idnumber); // we don't want this at all.
|
||||
$course->summary = restore_decode_absolute_links(addslashes($course_header->course_summary));
|
||||
$course->summary = addslashes($course_header->course_summary);
|
||||
$course->format = addslashes($course_header->course_format);
|
||||
$course->showgrades = addslashes($course_header->course_showgrades);
|
||||
$course->blockinfo = addslashes($course_header->blockinfo);
|
||||
@@ -530,7 +539,6 @@
|
||||
$course->students = addslashes($course_header->course_students);
|
||||
$course->guest = addslashes($course_header->course_guest);
|
||||
$course->startdate = addslashes($course_header->course_startdate);
|
||||
$course->enrolperiod = addslashes($course_header->course_enrolperiod);
|
||||
$course->numsections = addslashes($course_header->course_numsections);
|
||||
//$course->showrecent = addslashes($course_header->course_showrecent); INFO: This is out in 1.3
|
||||
$course->maxbytes = addslashes($course_header->course_maxbytes);
|
||||
@@ -538,22 +546,11 @@
|
||||
$course->groupmode = addslashes($course_header->course_groupmode);
|
||||
$course->groupmodeforce = addslashes($course_header->course_groupmodeforce);
|
||||
$course->lang = addslashes($course_header->course_lang);
|
||||
$course->cost = addslashes($course_header->course_cost);
|
||||
$course->marker = addslashes($course_header->course_marker);
|
||||
$course->visible = addslashes($course_header->course_visible);
|
||||
$course->hiddensections = addslashes($course_header->course_hiddensections);
|
||||
$course->timecreated = addslashes($course_header->course_timecreated);
|
||||
$course->timemodified = addslashes($course_header->course_timemodified);
|
||||
//Calculate sortorder field
|
||||
$sortmax = get_record_sql('SELECT MAX(sortorder) AS max
|
||||
FROM ' . $CFG->prefix . 'course
|
||||
WHERE category=' . $course->category);
|
||||
if (!empty($sortmax->max)) {
|
||||
$course->sortorder = $sortmax->max + 1;
|
||||
unset($sortmax);
|
||||
} else {
|
||||
$course->sortorder = 100;
|
||||
}
|
||||
//Adjust blockinfo field.
|
||||
//If the info doesn't exist in backup, we create defaults, else we recode it
|
||||
//to current site blocks.
|
||||
@@ -609,7 +606,7 @@
|
||||
$sequence = "";
|
||||
$section->course = $restore->course_id;
|
||||
$section->section = $sect->number;
|
||||
$section->summary = restore_decode_absolute_links(addslashes($sect->summary));
|
||||
$section->summary = addslashes($sect->summary);
|
||||
$section->visible = $sect->visible;
|
||||
$section->sequence = "";
|
||||
//Now calculate the section's newid
|
||||
@@ -799,20 +796,7 @@
|
||||
$user->address = addslashes($user->address);
|
||||
$user->city = addslashes($user->city);
|
||||
$user->url = addslashes($user->url);
|
||||
$user->description = restore_decode_absolute_links(addslashes($user->description));
|
||||
|
||||
//We need to analyse the AUTH field to recode it:
|
||||
// - if the field isn't set, we are in a pre 1.4 backup and we'll
|
||||
// use $CFG->auth
|
||||
// - if the destination site has any kind of INTERNAL authentication,
|
||||
// then apply it to the new user.
|
||||
// - if the destination site has any kind of EXTERNAL authentication,
|
||||
// then leave the original authentication of the user.
|
||||
|
||||
if ((! isset($user->auth)) || is_internal_auth($CFG->auth)) {
|
||||
$user->auth = $CFG->auth;
|
||||
}
|
||||
|
||||
$user->description = addslashes($user->description);
|
||||
//We are going to create the user
|
||||
//The structure is exactly as we need
|
||||
$newid = insert_record ("user",$user);
|
||||
@@ -938,16 +922,13 @@
|
||||
if ($info !== true) {
|
||||
//Iterate over each category
|
||||
foreach ($info as $category) {
|
||||
//Skip empty categories (some backups can contain them)
|
||||
if (!empty($category->id)) {
|
||||
$catrestore = "quiz_restore_question_categories";
|
||||
if (function_exists($catrestore)) {
|
||||
//print_object ($category); //Debug
|
||||
$status = $catrestore($category,$restore);
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
}
|
||||
$catrestore = "quiz_restore_question_categories";
|
||||
if (function_exists($catrestore)) {
|
||||
//print_object ($category); //Debug
|
||||
$status = $catrestore($category,$restore);
|
||||
} else {
|
||||
//Something was wrong. Function should exist.
|
||||
$status = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1111,11 +1092,8 @@
|
||||
backup_putid($restore->backup_unique_code,"group",
|
||||
$group->id, $newid);
|
||||
}
|
||||
//Now restore members in the groups_members, only if
|
||||
//users are included
|
||||
if ($restore->users != 2) {
|
||||
$status2 = restore_create_groups_members($newid,$info,$restore);
|
||||
}
|
||||
//Now restore members in the groups_members
|
||||
$status2 = restore_create_groups_members($newid,$info,$restore);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1271,8 +1249,7 @@
|
||||
|
||||
//This function decode things to make restore multi-site fully functional
|
||||
//It does this conversions:
|
||||
// - $@FILEPHP@$ ---|------------> $CFG->wwwroot/file.php/courseid (slasharguments on)
|
||||
// |------------> $CFG->wwwroot/file.php?file=/courseid (slasharguments off)
|
||||
// - $@FILEPHP@$ -------------------------------> $CFG->wwwroot/file.php/courseid
|
||||
//
|
||||
//Note: Inter-activities linking is being implemented as a final
|
||||
//step in the restore execution, because we need to have it
|
||||
@@ -1283,16 +1260,8 @@
|
||||
|
||||
//Now decode wwwroot and file.php calls
|
||||
$search = array ("$@FILEPHP@$");
|
||||
|
||||
//Check for the status of the slasharguments config variable
|
||||
$slash = $CFG->slasharguments;
|
||||
|
||||
//Build the replace string as needed
|
||||
if ($slash == 1) {
|
||||
$replace = array ($CFG->wwwroot."/file.php/".$restore->course_id);
|
||||
} else {
|
||||
$replace = array ($CFG->wwwroot."/file.php?file=/".$restore->course_id);
|
||||
}
|
||||
$replace = array ($CFG->wwwroot."/file.php/".$restore->course_id);
|
||||
|
||||
$result = str_replace($search,$replace,$content);
|
||||
|
||||
@@ -1679,11 +1648,6 @@
|
||||
$log->info = "";
|
||||
$toinsert = true;
|
||||
break;
|
||||
case "recent":
|
||||
$log->url = "recent.php?id=".$log->course;
|
||||
$log->info = "";
|
||||
$toinsert = true;
|
||||
break;
|
||||
default:
|
||||
echo "action (".$log->module."-".$log->action.") unknow. Not restored<br>"; //Debug
|
||||
break;
|
||||
@@ -2196,9 +2160,6 @@
|
||||
case "SHORTNAME":
|
||||
$this->info->course_shortname = $this->getContents();
|
||||
break;
|
||||
case "IDNUMBER":
|
||||
$this->info->course_idnumber = $this->getContents();
|
||||
break;
|
||||
case "SUMMARY":
|
||||
$this->info->course_summary = $this->getContents();
|
||||
break;
|
||||
@@ -2232,9 +2193,6 @@
|
||||
case "STARTDATE":
|
||||
$this->info->course_startdate = $this->getContents();
|
||||
break;
|
||||
case "ENROLPERIOD":
|
||||
$this->info->course_enrolperiod = $this->getContents();
|
||||
break;
|
||||
case "NUMSECTIONS":
|
||||
$this->info->course_numsections = $this->getContents();
|
||||
break;
|
||||
@@ -2256,9 +2214,6 @@
|
||||
case "LANG":
|
||||
$this->info->course_lang = $this->getContents();
|
||||
break;
|
||||
case "COST":
|
||||
$this->info->course_cost = $this->getContents();
|
||||
break;
|
||||
case "MARKER":
|
||||
$this->info->course_marker = $this->getContents();
|
||||
break;
|
||||
@@ -2438,9 +2393,6 @@
|
||||
$this->info->users[$this->getContents()] = $this->getContents();
|
||||
$this->info->tempuser->id = $this->getContents();
|
||||
break;
|
||||
case "AUTH":
|
||||
$this->info->tempuser->auth = $this->getContents();
|
||||
break;
|
||||
case "CONFIRMED":
|
||||
$this->info->tempuser->confirmed = $this->getContents();
|
||||
break;
|
||||
@@ -2528,9 +2480,6 @@
|
||||
case "MAILFORMAT":
|
||||
$this->info->tempuser->mailformat = $this->getContents();
|
||||
break;
|
||||
case "MAILDIGEST":
|
||||
$this->info->tempuser->maildigest = $this->getContents();
|
||||
break;
|
||||
case "MAILDISPLAY":
|
||||
$this->info->tempuser->maildisplay = $this->getContents();
|
||||
break;
|
||||
@@ -2573,12 +2522,6 @@
|
||||
case "EDITALL":
|
||||
$this->info->temprole->editall = $this->getContents();
|
||||
break;
|
||||
case "TIMESTART":
|
||||
$this->info->temprole->timestart = $this->getContents();
|
||||
break;
|
||||
case "TIMEEND":
|
||||
$this->info->temprole->timeend = $this->getContents();
|
||||
break;
|
||||
case "TIMEMODIFIED":
|
||||
$this->info->temprole->timemodified = $this->getContents();
|
||||
break;
|
||||
@@ -2959,7 +2902,7 @@
|
||||
|
||||
$status = true;
|
||||
|
||||
$xml_parser = xml_parser_create('UTF-8');
|
||||
$xml_parser = xml_parser_create();
|
||||
$moodle_parser = new MoodleParser();
|
||||
$moodle_parser->todo = $todo;
|
||||
$moodle_parser->preferences = $preferences;
|
||||
|
||||
+3
-4
@@ -1,9 +1,8 @@
|
||||
<?PHP //$Id$
|
||||
<?php
|
||||
require_once ("../config.php");
|
||||
require_once ("backup_scheduled.php");
|
||||
require_once ("lib.php");
|
||||
require_once ("backuplib.php");
|
||||
require_once ("$CFG->libdir/blocklib.php");
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -20,8 +19,8 @@
|
||||
backup_required_functions();
|
||||
|
||||
//Adjust some php variables to the execution of this script
|
||||
@ini_set("max_execution_time","3000");
|
||||
raise_memory_limit("128M");
|
||||
ini_set("max_execution_time","3000");
|
||||
ini_set("memory_limit","56M");
|
||||
|
||||
echo "<pre>\n";
|
||||
|
||||
|
||||
+2
-4
@@ -5,8 +5,6 @@
|
||||
// database (backup_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$backup_version = 2004083124; // YYYYMMDD = date of first major branch release 1.4
|
||||
// X = point release version 1,2,3 etc
|
||||
// Y = increments between point releases
|
||||
$backup_version = 2004052400; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
$backup_release = "1.4.2"; // User-friendly version number
|
||||
$backup_release = "1.3"; // User-friendly version number
|
||||
|
||||
@@ -26,7 +26,7 @@ class CourseBlock_activity_modules extends MoodleBlock {
|
||||
if ($modnamesused) {
|
||||
foreach ($modnamesused as $modname => $modfullname) {
|
||||
if ($modname != 'label') {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->course->id.'">'.$modnamesplural[$modname].'</a>';
|
||||
$this->content->items[] = '<a href="../mod/'.$modname.'/index.php?id='.$this->course->id.'">'.$modnamesplural[$modname].'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$modname.'/icon.gif" height="16" width="16" alt="">';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@ class CourseBlock_admin extends MoodleBlock {
|
||||
$this->title = get_string('administration');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081200;
|
||||
$this->version = 2004041000;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG, $THEME;
|
||||
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@@ -19,60 +21,6 @@ class CourseBlock_admin extends MoodleBlock {
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
} else if ($this->course->id == SITEID) {
|
||||
$this->load_content_for_site();
|
||||
} else {
|
||||
$this->load_content_for_course();
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
|
||||
function load_content_for_site() {
|
||||
global $CFG, $USER;
|
||||
|
||||
if (isadmin()) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/configure.php">'.get_string('configuration').'</a>...';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/admin.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/users.php">'.get_string('users').'</a>...';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/backup/backup.php?id='.SITEID.'">'.get_string('backup').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/backup.gif" height="16" width="16" alt="">';
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'&wdir=/backupdata">'.get_string('restore').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/restore.gif" height="16" width="16" alt="">';
|
||||
}
|
||||
|
||||
if (iscreator()) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on&sesskey='.set_user_sesskey().'">'.get_string('courses').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/course.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
|
||||
if (isadmin()) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/log.php?id='.SITEID.'">'.get_string('logs').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/log.gif" height="16" width="16" alt="" />';
|
||||
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'">'.get_string('sitefiles').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/files.gif" height="16" width="16" alt="" />';
|
||||
|
||||
if (file_exists($CFG->dirroot.'/'.$CFG->admin.'/'.$CFG->dbtype)) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/'.$CFG->dbtype.'/frame.php">'.get_string('managedatabase').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/db.gif" height="16" width="16" alt="" />';
|
||||
}
|
||||
$this->content->footer = '<a href="'.$CFG->wwwroot.'/'.$CFG->admin.'/">'.get_string('admin').'</a>...';
|
||||
}
|
||||
}
|
||||
|
||||
function load_content_for_course() {
|
||||
global $CFG, $USER;
|
||||
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
if (isguest()) {
|
||||
return $this->content;
|
||||
}
|
||||
@@ -134,7 +82,6 @@ class CourseBlock_admin extends MoodleBlock {
|
||||
}
|
||||
|
||||
} else if (!isguest()) { // Students menu
|
||||
|
||||
if ($this->course->showgrades) {
|
||||
$this->content->items[]='<a href="grade.php?id='.$this->course->id.'">'.get_string('grades').'...</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/grades.gif" height="16" width="16" alt="">';
|
||||
@@ -155,6 +102,8 @@ class CourseBlock_admin extends MoodleBlock {
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class CourseBlock_calendar_month extends MoodleBlock {
|
||||
$this->title = get_string('calendar', 'calendar');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081200;
|
||||
$this->version = 2004052400;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
@@ -23,24 +23,14 @@ class CourseBlock_calendar_month extends MoodleBlock {
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
if (empty($this->course)) { // Overrides: use no course at all
|
||||
|
||||
if ($this->course === NULL) {
|
||||
// Overrides: use no course at all
|
||||
$courseshown = false;
|
||||
$filtercourse = array();
|
||||
|
||||
} else {
|
||||
|
||||
$courseshown = $this->course->id;
|
||||
|
||||
if($this->course->id == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
// the list of courses it will be grabbing events from.
|
||||
$filtercourse = NULL;
|
||||
}
|
||||
else {
|
||||
// Forcibly filter events to include only those from the particular course we are in.
|
||||
$filtercourse = array($courseshown => 1);
|
||||
}
|
||||
$filtercourse = array($courseshown => 1);
|
||||
}
|
||||
|
||||
// We 'll need this later
|
||||
|
||||
@@ -5,7 +5,7 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
$this->title = get_string('upcomingevents', 'calendar');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
$this->version = 2004052400;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
@@ -15,37 +15,23 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.'/calendar/view.php?view=upcoming&course='.$this->course->id.'">'.get_string('gotocalendar', 'calendar').'</a>...';
|
||||
$this->content->footer .= '<br /><a href="'.$CFG->wwwroot.'/calendar/event.php?action=new">'.get_string('newevent', 'calendar').'</a>...';
|
||||
|
||||
if (empty($this->course)) { // Overrides: use no course at all
|
||||
|
||||
if($this->course === NULL) {
|
||||
// Overrides: use no course at all
|
||||
$courseshown = false;
|
||||
$filtercourse = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
else {
|
||||
$courseshown = $this->course->id;
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.
|
||||
'/calendar/view.php?view=upcoming&course='.$this->course->id.'">'.
|
||||
get_string('gotocalendar', 'calendar').'</a>...';
|
||||
$this->content->footer .= '<br /><a href="'.$CFG->wwwroot.
|
||||
'/calendar/event.php?action=new&course='.$this->course->id.'">'.
|
||||
get_string('newevent', 'calendar').'</a>...';
|
||||
|
||||
if ($this->course->id == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
// the list of courses it will be grabbing events from.
|
||||
$filtercourse = NULL;
|
||||
} else {
|
||||
// Forcibly filter events to include only those from the particular course we are in.
|
||||
$filtercourse = array($courseshown => 1);
|
||||
}
|
||||
$filtercourse = array($courseshown => 1);
|
||||
}
|
||||
|
||||
// We 'll need this later
|
||||
@@ -55,18 +41,11 @@ class CourseBlock_calendar_upcoming extends MoodleBlock {
|
||||
// Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
|
||||
|
||||
calendar_set_filters($courses, $group, $user, $filtercourse, $filtercourse, false);
|
||||
$events = calendar_get_upcoming($courses, $group, $user,
|
||||
get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS),
|
||||
get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
|
||||
|
||||
if (!empty($this->course)) {
|
||||
$this->content->text = calendar_get_sideblock_upcoming($events,
|
||||
'view.php?view=day&course='.$this->course->id.'&');
|
||||
}
|
||||
$this->content->text = calendar_get_sideblock_upcoming($courses, $group, $user, get_user_preferences('calendar_lookahead', CALENDAR_UPCOMING_DAYS), get_user_preferences('calendar_maxevents', CALENDAR_UPCOMING_MAXEVENTS));
|
||||
|
||||
if (empty($this->content->text)) {
|
||||
$this->content->text = '<div style="font-size: 0.8em; text-align: center;">'.
|
||||
get_string('noupcomingevents', 'calendar').'</div>';
|
||||
if(empty($this->content->text)) {
|
||||
$this->content->text = '<div style="font-size: 0.8em; text-align: center;">'.get_string('noupcomingevents', 'calendar').'</div>';
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
|
||||
@@ -2,29 +2,10 @@
|
||||
|
||||
class CourseBlock_course_list extends MoodleBlock {
|
||||
function CourseBlock_course_list ($course) {
|
||||
$this->title = get_string('courses');
|
||||
$this->title = get_string('mycourses');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081200;
|
||||
}
|
||||
|
||||
function has_config() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function print_config() {
|
||||
global $CFG, $USER, $THEME;
|
||||
print_simple_box_start('center', '', $THEME->cellheading);
|
||||
include($CFG->dirroot.'/blocks/'.$this->name().'/config.html');
|
||||
print_simple_box_end();
|
||||
return true;
|
||||
}
|
||||
|
||||
function handle_config($config) {
|
||||
foreach ($config as $name => $value) {
|
||||
set_config($name, $value);
|
||||
}
|
||||
return true;
|
||||
$this->version = 2004041800;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
@@ -46,15 +27,8 @@ class CourseBlock_course_list extends MoodleBlock {
|
||||
$icon = "<img src=\"$CFG->wwwroot/theme/$CFG->theme/pix/i/course.gif\"".
|
||||
" height=\"16\" width=\"16\" alt=\"".get_string("course")."\">";
|
||||
}
|
||||
|
||||
$adminseesall = true;
|
||||
if (isset($CFG->block_course_list_adminview)) {
|
||||
if ( $CFG->block_course_list_adminview == 'own'){
|
||||
$adminseesall = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($USER->id) and !(isadmin() and $adminseesall)) { // Just print My Courses
|
||||
if (isset($USER->id) and !isadmin()) { // Just print My Courses
|
||||
if ($courses = get_my_courses($USER->id)) {
|
||||
foreach ($courses as $course) {
|
||||
if (!$course->category) {
|
||||
@@ -66,10 +40,8 @@ class CourseBlock_course_list extends MoodleBlock {
|
||||
$this->content->icons[]=$icon;
|
||||
}
|
||||
$this->title = get_string('mycourses');
|
||||
$this->content->footer = "<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
|
||||
if ($this->content->items) { // make sure we don't return an empty list
|
||||
return $this->content;
|
||||
}
|
||||
$this->content->footer = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,13 +53,12 @@ class CourseBlock_course_list extends MoodleBlock {
|
||||
$this->content->items[]="<a $linkcss href=\"$CFG->wwwroot/course/category.php?id=$category->id\">$category->name</a>";
|
||||
$this->content->icons[]=$icon;
|
||||
}
|
||||
$this->content->footer = "<a href=\"$CFG->wwwroot/course/\">".get_string("searchcourses")."</a>...<br />".
|
||||
"<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
|
||||
$this->content->footer = "<p><a href=\"$CFG->wwwroot/course/\">".get_string("searchcourses")."</a>...";
|
||||
$this->title = get_string('categories');
|
||||
} else { // Just print course names of single category
|
||||
$category = array_shift($categories);
|
||||
$courses = get_courses($category->id);
|
||||
|
||||
|
||||
if ($courses) {
|
||||
foreach ($courses as $course) {
|
||||
$linkcss = $course->visible ? "" : " class=\"dimmed\" ";
|
||||
@@ -95,7 +66,7 @@ class CourseBlock_course_list extends MoodleBlock {
|
||||
"href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->fullname</a>";
|
||||
$this->content->icons[]=$icon;
|
||||
}
|
||||
$this->content->footer = "<a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
|
||||
$this->content->footer = "<p><a href=\"$CFG->wwwroot/course/index.php\">".get_string("fulllistofcourses")."</a>...";
|
||||
} else {
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<form method="post" action="block.php">
|
||||
<?php echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">"; ?>
|
||||
|
||||
<table cellpadding="9" cellspacing="0">
|
||||
<tr valign="top">
|
||||
<td align="right"><p>block_course_list_adminview:</td>
|
||||
<td>
|
||||
<input name="block" type="hidden" value="<?php echo intval($_REQUEST['block']); ?>" />
|
||||
<select name="block_course_list_adminview">
|
||||
<option value="all" <?php if(isset($CFG->block_course_list_adminview)){
|
||||
if($CFG->block_course_list_adminview == "all"){ p("selected");}
|
||||
}else{
|
||||
p("selected");
|
||||
}?>
|
||||
><?php p(get_string('allcourses', 'block_course_list')) ?></option>
|
||||
<option value="own" <?php if(isset($CFG->block_course_list_adminview)){
|
||||
if($CFG->block_course_list_adminview == "own"){ p("selected"); }
|
||||
}?>
|
||||
><?php p(get_string('owncourses', 'block_course_list')) ?></option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<?php print_string("configadminview", "block_course_list") ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" align="center">
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
@@ -2,51 +2,28 @@
|
||||
|
||||
class CourseBlock_course_summary extends MoodleBlock {
|
||||
function CourseBlock_course_summary ($course) {
|
||||
if(!empty($course) && $course->id == SITEID) { // Site level
|
||||
$this->title = get_string('frontpagedescription');
|
||||
} else {
|
||||
$this->title = get_string('blockname','block_course_summary');
|
||||
}
|
||||
$this->title = get_string('blockname','block_course_summary');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
$this->version = 2004041400;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $THEME;
|
||||
global $USER, $CFG;
|
||||
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->content = New stdClass;
|
||||
$options->noclean = true; // Don't clean Javascripts etc
|
||||
$this->content->text = format_text($this->course->summary, FORMAT_HTML, $options);
|
||||
if(isediting($this->course->id)) {
|
||||
if($this->course->id == SITEID) {
|
||||
$editpage = $CFG->wwwroot.'/'.$CFG->admin.'/site.php';
|
||||
} else {
|
||||
$editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->course->id;
|
||||
}
|
||||
$this->content->text .= '<div style="text-align: right;"><a href="'.$editpage.'"><img src="'.$CFG->pixpath.'/t/edit.gif" /></a></div>';
|
||||
}
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
$this->content->text = format_text($this->course->summary, FORMAT_HTML);
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
function hide_header() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function preferred_width() {
|
||||
return 210;
|
||||
}
|
||||
|
||||
function hide_header() {return true;}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -37,7 +37,6 @@ global $CFG;
|
||||
COMMENT = 'To register and update all the available blocks'");
|
||||
}
|
||||
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ global $CFG;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
<?PHP //$Id$
|
||||
|
||||
class CourseBlock_login extends MoodleBlock {
|
||||
function CourseBlock_login ($course) {
|
||||
$this->title = get_string('login');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004081600;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('site' => true);
|
||||
}
|
||||
|
||||
function get_content () {
|
||||
global $USER, $CFG;
|
||||
$wwwroot = '';
|
||||
$signup = '';
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
// This actually is not so secure ;-), 'cause we're
|
||||
// in unencrypted connection...
|
||||
$wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
|
||||
}
|
||||
|
||||
switch ($CFG->auth) {
|
||||
// I'm not sure if user can create an account
|
||||
// him/her self when using ldap authentication.
|
||||
// If true, then there should be a method for it.
|
||||
case "email":
|
||||
$signup = $wwwroot . '/login/signup.php';
|
||||
break;
|
||||
case "none":
|
||||
// just for the user to see instructions!
|
||||
$signup = $wwwroot . '/login/index.php';
|
||||
break;
|
||||
default:
|
||||
$signup = '';
|
||||
}
|
||||
|
||||
$username = get_moodle_cookie();
|
||||
if (empty($USER->loggedin)) {
|
||||
$this->content->text = "<form name=\"blocklogin\" method=\"post\"";
|
||||
$this->content->text .= " action=\"". $wwwroot ."/login/index.php\">\n";
|
||||
$this->content->text .= "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\"";
|
||||
$this->content->text .= " width=\"100%\" style=\"font-size: small;\">\n";
|
||||
$this->content->text .= "<tr>\n<td>". get_string("username") .":</td>\n</tr>\n";
|
||||
$this->content->text .= "<tr>\n<td><input type=\"text\" name=\"username\" value=\"";
|
||||
$this->content->text .= $username . "\" /></td>\n</tr>\n";
|
||||
$this->content->text .= "<tr>\n<td>". get_string("password") .":</td>\n</tr>\n";
|
||||
$this->content->text .= "<tr>\n<td><input type=\"password\" name=\"password\" /></td>\n</tr>\n";
|
||||
$this->content->text .= "<tr>\n<td align=\"center\"><input type=\"submit\" value=\"";
|
||||
$this->content->text .= get_string("login");
|
||||
$this->content->text .= "\" /></td>\n</tr>\n";
|
||||
if (!empty($signup)) {
|
||||
$this->content->text .= "<tr><td align=\"center\"><a href=\"". $signup ."\">";
|
||||
$this->content->text .= get_string('startsignup');
|
||||
$this->content->text .= "</a></td></tr>\n";
|
||||
}
|
||||
$this->content->text .= "</table>\n";
|
||||
$this->content->text .= "</form>\n";
|
||||
} else {
|
||||
$this->content->text = ''; // It's time to dissapear!
|
||||
// And keep the self test happy by
|
||||
// passing empty string!
|
||||
}
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -66,46 +66,22 @@ class MoodleBlock {
|
||||
case BLOCK_TYPE_NUKE:
|
||||
case BLOCK_TYPE_TEXT:
|
||||
if(empty($this->content->text) && empty($this->content->footer)) {
|
||||
if(empty($this->edit_controls)) {
|
||||
// No content, no edit controls, so just shut up
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// No content but editing, so show something at least
|
||||
$this->print_shadow();
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if($this->hide_header() && empty($this->edit_controls)) {
|
||||
// Header wants to hide, no edit controls to show, so no header it is
|
||||
print_side_block(NULL, $this->content->text, NULL, NULL, $this->content->footer, $this->html_attributes());
|
||||
}
|
||||
else {
|
||||
// The full treatment, please
|
||||
print_side_block($title, $this->content->text, NULL, NULL, $this->content->footer, $this->html_attributes());
|
||||
}
|
||||
if ($this->edit_controls !== NULL || !$this->hide_header()) {
|
||||
print_side_block($title, $this->content->text, NULL, NULL, $this->content->footer);
|
||||
} else {
|
||||
print_side_block(NULL, $this->content->text, NULL, NULL, $this->content->footer);
|
||||
}
|
||||
break;
|
||||
case BLOCK_TYPE_LIST:
|
||||
if(empty($this->content->items) && empty($this->content->footer)) {
|
||||
if(empty($this->edit_controls)) {
|
||||
// No content, no edit controls, so just shut up
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// No content but editing, so show something at least
|
||||
$this->print_shadow();
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if($this->hide_header() && empty($this->edit_controls)) {
|
||||
// Header wants to hide, no edit controls to show, so no header it is
|
||||
print_side_block(NULL, '', $this->content->items, $this->content->icons, $this->content->footer, $this->html_attributes());
|
||||
}
|
||||
else {
|
||||
// The full treatment, please
|
||||
print_side_block($title, '', $this->content->items, $this->content->icons, $this->content->footer, $this->html_attributes());
|
||||
}
|
||||
if ($this->edit_controls !== NULL || !$this->hide_header()) {
|
||||
print_side_block($title, '', $this->content->items, $this->content->icons, $this->content->footer);
|
||||
} else {
|
||||
print_side_block(NULL, '', $this->content->items, $this->content->icons, $this->content->footer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -117,9 +93,8 @@ class MoodleBlock {
|
||||
}
|
||||
print_side_block($title, ' ', NULL, NULL, '');
|
||||
}
|
||||
|
||||
function add_edit_controls($options, $blockid) {
|
||||
global $CFG, $THEME, $USER;
|
||||
global $CFG, $THEME;
|
||||
|
||||
// The block may be disabled
|
||||
$blockid = intval($blockid);
|
||||
@@ -143,8 +118,6 @@ class MoodleBlock {
|
||||
} else {
|
||||
$pixpath = $path.'/../theme/'.$CFG->theme.'/pix';
|
||||
}
|
||||
|
||||
$sesskeystr = '&sesskey='.$USER->sesskey;
|
||||
|
||||
$movebuttons = '<div style="float: right;">';
|
||||
|
||||
@@ -157,26 +130,26 @@ class MoodleBlock {
|
||||
$title = $this->str->show;
|
||||
}
|
||||
|
||||
$movebuttons .= '<a style="margin-right: 6px; margin-left: 3px;" title="'.$title.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=toggle&blockid='.$blockid.$sesskeystr.'">' .
|
||||
$movebuttons .= '<a style="margin-right: 10px;" title="'.$title.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=toggle&blockid='.$blockid.'">' .
|
||||
'<img src="'.$pixpath.$icon.'" /></a>';
|
||||
|
||||
$movebuttons .= '<a title="'.$this->str->delete.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=delete&blockid='.$blockid.$sesskeystr.'">' .
|
||||
'<img src="'.$pixpath.'/t/delete.gif" /></a> ';
|
||||
$movebuttons .= '<a style="margin-right: 10px;" title="'.$this->str->delete.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=delete&blockid='.$blockid.'">' .
|
||||
'<img src="'.$pixpath.'/t/delete.gif" /></a>';
|
||||
|
||||
if ($options & BLOCK_MOVE_LEFT) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveleft.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveside&blockid='.$blockid.$sesskeystr.'">' .
|
||||
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->moveleft.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveside&blockid='.$blockid.'">' .
|
||||
'<img src="'.$pixpath.'/t/left.gif" /></a>';
|
||||
}
|
||||
if ($options & BLOCK_MOVE_UP) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveup.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveup&blockid='.$blockid.$sesskeystr.'">' .
|
||||
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->moveup.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveup&blockid='.$blockid.'">' .
|
||||
'<img src="'.$pixpath.'/t/up.gif" /></a>';
|
||||
}
|
||||
if ($options & BLOCK_MOVE_DOWN) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->movedown.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=movedown&blockid='.$blockid.$sesskeystr.'">' .
|
||||
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->movedown.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=movedown&blockid='.$blockid.'">' .
|
||||
'<img src="'.$pixpath.'/t/down.gif" /></a>';
|
||||
}
|
||||
if ($options & BLOCK_MOVE_RIGHT) {
|
||||
$movebuttons .= '<a style="margin-right: 2px; margin-left: 2px;" title="'.$this->str->moveright.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveside&blockid='.$blockid.$sesskeystr.'">' .
|
||||
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->moveright.'" href="'.$path.'/view.php?id='.$this->course->id.'&blockaction=moveside&blockid='.$blockid.'">' .
|
||||
'<img src="'.$pixpath.'/t/right.gif" /></a>';
|
||||
}
|
||||
|
||||
@@ -206,13 +179,11 @@ class MoodleBlock {
|
||||
$errors[] = 'version_not_set';
|
||||
$correct = false;
|
||||
}
|
||||
|
||||
$formats = $this->applicable_formats();
|
||||
if(empty($formats) || array_sum($formats) === 0) {
|
||||
$allformats = COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL;
|
||||
if(!($this->applicable_formats() & $allformats)) {
|
||||
$errors[] = 'no_course_formats';
|
||||
$correct = false;
|
||||
}
|
||||
|
||||
$width = $this->preferred_width();
|
||||
if(!is_int($width) || $width <= 0) {
|
||||
$errors[] = 'invalid_width';
|
||||
@@ -234,19 +205,19 @@ class MoodleBlock {
|
||||
}
|
||||
function applicable_formats() {
|
||||
// Default case: the block can be used in all course types
|
||||
return array('all' => true);
|
||||
return COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS | COURSE_FORMAT_SOCIAL;
|
||||
}
|
||||
function preferred_width() {
|
||||
// Default case: the block wants to be 180 pixels wide
|
||||
return 180;
|
||||
}
|
||||
function hide_header() {
|
||||
//Default, false--> the header is shown
|
||||
//Default, false--> the header is showed
|
||||
return false;
|
||||
}
|
||||
function html_attributes() {
|
||||
// Default case: just an id for the block, with our name in it
|
||||
return array('id' => 'block_'.$this->name());
|
||||
// Default case: we want no extra attributes
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,23 +5,17 @@ class CourseBlock_news_items extends MoodleBlock {
|
||||
$this->title = get_string('latestnews');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
$this->version = 2004041200;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
|
||||
@@ -5,13 +5,13 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
$this->title = get_string('blockname','block_online_users');
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052700;
|
||||
$this->version = 2004041800;
|
||||
}
|
||||
|
||||
function has_config() {return true;}
|
||||
|
||||
function print_config() {
|
||||
global $CFG, $USER, $THEME;
|
||||
global $CFG, $THEME;
|
||||
print_simple_box_start('center', '', $THEME->cellheading);
|
||||
include($CFG->dirroot.'/blocks/'.$this->name().'/config.html');
|
||||
print_simple_box_end();
|
||||
@@ -27,24 +27,19 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
function get_content() {
|
||||
global $USER, $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
$timetoshowusers = 300; //Seconds default
|
||||
|
||||
if (isset($CFG->block_online_users_timetosee)) {
|
||||
$timetoshowusers = $CFG->block_online_users_timetosee * 60;
|
||||
}
|
||||
$timefrom = time()-$timetoshowusers;
|
||||
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
//Calculate if we are in separate groups
|
||||
$isseparategroups = ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce and
|
||||
@@ -54,61 +49,48 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
$currentgroup = $isseparategroups ? get_current_group($this->course->id) : NULL;
|
||||
|
||||
$groupmembers = "";
|
||||
$groupselect = "";
|
||||
$select = "";
|
||||
|
||||
//Add this to the SQL to show only group users
|
||||
if ($currentgroup !== NULL) {
|
||||
$groupmembers = ", {$CFG->prefix}groups_members gm ";
|
||||
$groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||
$select .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||
}
|
||||
|
||||
if (empty($this->course->category)) { // Site-level
|
||||
$courseselect = '';
|
||||
$timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)";
|
||||
} else {
|
||||
$courseselect = "AND s.course = '".$this->course->id."'";
|
||||
$timeselect = "AND s.timeaccess > $timefrom";
|
||||
}
|
||||
$timefrom = time()-$timetoshowusers;
|
||||
|
||||
$users = array();
|
||||
|
||||
if ($students = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess, s.timeaccess
|
||||
$students = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_students s
|
||||
$groupmembers
|
||||
WHERE u.id = s.userid $courseselect $groupselect $timeselect
|
||||
ORDER BY s.timeaccess DESC")) {
|
||||
foreach ($students as $student) {
|
||||
$student->fullname = fullname($student);
|
||||
$users[$student->id] = $student;
|
||||
}
|
||||
}
|
||||
WHERE u.id = s.userid and
|
||||
s.course = {$this->course->id} and
|
||||
s.timeaccess > $timefrom $select ORDER BY s.timeaccess DESC");
|
||||
|
||||
if (!$this->course->category and $CFG->allusersaresitestudents) {
|
||||
if ($siteusers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess
|
||||
FROM {$CFG->prefix}user u
|
||||
WHERE u.lastaccess > $timefrom AND u.username <> 'guest'
|
||||
ORDER BY u.lastaccess DESC")) {
|
||||
foreach ($siteusers as $siteuser) {
|
||||
$siteuser->fullname = fullname($siteuser);
|
||||
$siteuser->timeaccess = $siteuser->lastaccess;
|
||||
$users[$siteuser->id] = $siteuser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($teachers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, u.lastaccess, s.timeaccess
|
||||
$teachers = get_records_sql("SELECT u.id, u.username, u.firstname, u.lastname, u.picture, s.timeaccess
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_teachers s
|
||||
$groupmembers
|
||||
WHERE u.id = s.userid $courseselect $groupselect $timeselect
|
||||
ORDER BY s.timeaccess DESC")) {
|
||||
foreach ($teachers as $teacher) {
|
||||
$teacher->fullname = '<b>'.fullname($teacher).'</b>';
|
||||
$users[$teacher->id] = $teacher;
|
||||
}
|
||||
}
|
||||
WHERE u.id = s.userid and
|
||||
s.course = {$this->course->id} and
|
||||
s.timeaccess > $timefrom $select ORDER BY s.timeaccess DESC");
|
||||
|
||||
if ($teachers || $students) {
|
||||
if ($students) {
|
||||
foreach ($students as $student) {
|
||||
$student->fullname = fullname($student);
|
||||
$users[$student->id] = $student;
|
||||
}
|
||||
}
|
||||
if ($teachers) {
|
||||
foreach ($teachers as $teacher) {
|
||||
$teacher->fullname = '<b>'.fullname($teacher).'</b>';
|
||||
$users[$teacher->id] = $teacher;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$users = null;
|
||||
}
|
||||
|
||||
//Calculate minutes
|
||||
$minutes = floor($timetoshowusers/60);
|
||||
@@ -117,10 +99,10 @@ class CourseBlock_online_users extends MoodleBlock {
|
||||
|
||||
//Now, we have in users, the list of users to show
|
||||
//Because they are online
|
||||
if (!empty($users)) {
|
||||
if ($users !== null) {
|
||||
foreach ($users as $user) {
|
||||
$this->content->text .= '<div style="text-align: left; font-size: 0.75em; padding-top: 5px;">';
|
||||
$timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage
|
||||
$timeago = format_time(time() - $user->timeaccess);
|
||||
if ($user->picture==0) {
|
||||
$this->content->text .= '<img src="'.$CFG->pixpath.'/i/user.gif" style="height: 16px; width=16px; vertical-align: middle;" alt=""> ';
|
||||
} else {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<form method="post" action="block.php">
|
||||
<?php echo "<input type=\"hidden\" name=\"sesskey\" value=\"".$USER->sesskey."\">"; ?>
|
||||
|
||||
<table cellpadding="9" cellspacing="0">
|
||||
<tr valign="top">
|
||||
|
||||
@@ -5,17 +5,13 @@ class CourseBlock_participants extends MoodleBlock {
|
||||
$this->title = get_string('people');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052600;
|
||||
$this->version = 2004041800;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -27,33 +23,29 @@ class CourseBlock_participants extends MoodleBlock {
|
||||
$strgroups = get_string('groups');
|
||||
$strgroupmy = get_string('groupmy');
|
||||
|
||||
if ($this->course->category or $CFG->showsiteparticipantslist > 1 or ($CFG->showsiteparticipantslist == 1 and isteacherinanycourse()) or isteacher(SITEID)) {
|
||||
$this->content->items[]='<a title="'.get_string('listofallpeople').'" href="'.$CFG->wwwroot.'/user/index.php?id='.$this->course->id.'">'.get_string('participants').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
|
||||
}
|
||||
$this->content->items[]='<a title="'.get_string('listofallpeople').'" href="../user/index.php?id='.$this->course->id.'">'.get_string('participants').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/users.gif" height="16" width="16" alt="">';
|
||||
|
||||
if ($this->course->groupmode or !$this->course->groupmodeforce) {
|
||||
if ($this->course->groupmode == VISIBLEGROUPS or isteacheredit($this->course->id)) {
|
||||
$this->content->items[]='<a title="'.$strgroups.'" href="'.$CFG->wwwroot.'/course/groups.php?id='.$this->course->id.'">'.$strgroups.'</a>';
|
||||
$this->content->items[]='<a title="'.$strgroups.'" href="groups.php?id='.$this->course->id.'">'.$strgroups.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" height="16" width="16" alt="">';
|
||||
} else if ($this->course->groupmode == SEPARATEGROUPS and $this->course->groupmodeforce) {
|
||||
// Show nothing
|
||||
} else if ($currentgroup = get_current_group($this->course->id)) {
|
||||
$this->content->items[]='<a title="'.$strgroupmy.'" href="'.$CFG->wwwroot.'/course/group.php?id='.$this->course->id.'">'.$strgroupmy.'</a>';
|
||||
$this->content->items[]='<a title="'.$strgroupmy.'" href="group.php?id='.$this->course->id.'">'.$strgroupmy.'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/group.gif" height="16" width="16" alt="">';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($USER->id)) {
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.$this->course->id.'">'.get_string('editmyprofile').'</a>';
|
||||
if ($USER->description) {
|
||||
$this->content->items[]= $editmyprofile;
|
||||
} else {
|
||||
$this->content->items[]= $editmyprofile." <blink>*</blink>";
|
||||
}
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="../user/edit.php?id='.$USER->id.'&course='.$this->course->id.'">'.get_string('editmyprofile').'</a>';
|
||||
if ($USER->description) {
|
||||
$this->content->items[]= $editmyprofile;
|
||||
} else {
|
||||
$this->content->items[]= $editmyprofile." <blink>*</blink>";
|
||||
}
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" height="16" width="16" alt="">';
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -10,12 +10,7 @@ class CourseBlock_recent_activity extends MoodleBlock {
|
||||
|
||||
function get_content() {
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,6 @@ class CourseBlock_search_forums extends MoodleBlock {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
@@ -3,24 +3,22 @@
|
||||
class CourseBlock_section_links extends MoodleBlock {
|
||||
|
||||
function CourseBlock_section_links ($course) {
|
||||
if (isset($course->format)) {
|
||||
if ($course->format == 'topics') {
|
||||
$this->title = get_string('topics', 'block_section_links');
|
||||
} else if ($course->format == 'weeks') {
|
||||
$this->title = get_string('weeks', 'block_section_links');
|
||||
} else {
|
||||
$this->title = get_string('blockname', 'block_section_links');
|
||||
}
|
||||
} else {
|
||||
if ($course->format == 'topics') {
|
||||
$this->title = get_string('topics', 'block_section_links');
|
||||
}
|
||||
else if ($course->format == 'weeks') {
|
||||
$this->title = get_string('weeks', 'block_section_links');
|
||||
}
|
||||
else {
|
||||
$this->title = get_string('blockname', 'block_section_links');
|
||||
}
|
||||
$this->content_type = BLOCK_TYPE_TEXT;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052800;
|
||||
$this->version = 2004050500;
|
||||
}
|
||||
|
||||
|
||||
function applicable_formats() {
|
||||
return (array('weeks' => true, 'topics' => true));
|
||||
return (COURSE_FORMAT_WEEKS | COURSE_FORMAT_TOPICS);
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
@@ -28,12 +26,7 @@ class CourseBlock_section_links extends MoodleBlock {
|
||||
|
||||
$highlight = 0;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
$this->content = '';
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
@@ -55,36 +48,25 @@ class CourseBlock_section_links extends MoodleBlock {
|
||||
$inc = 5;
|
||||
}
|
||||
$courseid = $this->course->id;
|
||||
if (!empty($USER->id)) {
|
||||
$display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id);
|
||||
}
|
||||
if (!empty($display)) {
|
||||
if ($display = get_field('course_display', 'display', 'course', $courseid, 'userid', $USER->id)) {
|
||||
$link = "$CFG->wwwroot/course/view.php?id=$courseid&$sectionname=";
|
||||
} else {
|
||||
$link = '#';
|
||||
}
|
||||
$text = '<font size=-1>';
|
||||
for ($i = $inc; $i <= $this->course->numsections; $i += $inc) {
|
||||
$isvisible = get_field('course_sections', 'visible', 'course', $this->course->id, 'section', $i);
|
||||
if (!$isvisible and !isteacher($this->course->id)) {
|
||||
continue;
|
||||
}
|
||||
$style = ($isvisible) ? '' : ' class="dimmed"';
|
||||
if ($i == $highlight) {
|
||||
$text .= "<a href=\"$link$i\"$style><b>$i</b></a> ";
|
||||
$text .= "<a href=\"$link$i\"><b>$i</b></a> ";
|
||||
} else {
|
||||
$text .= "<a href=\"$link$i\"$style>$i</a> ";
|
||||
$text .= "<a href=\"$link$i\">$i</a> ";
|
||||
}
|
||||
}
|
||||
if ($highlight) {
|
||||
$isvisible = get_field('course_sections', 'visible', 'course', $this->course->id, 'section', $highlight);
|
||||
if ($isvisible or isteacher($this->course->id)) {
|
||||
$style = ($isvisible) ? '' : ' class="dimmed"';
|
||||
$text .= "<br><a href=\"$link$highlight\"$style>$linktext</a>";
|
||||
}
|
||||
$text .= "<br><a href=\"$link$highlight\">$linktext</a>";
|
||||
}
|
||||
|
||||
$this->content = New stdClass;
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->header = 'Hello';
|
||||
$this->content->footer = '';
|
||||
$this->content->text = $text;
|
||||
return $this->content;
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
<?php //$Id$
|
||||
|
||||
class CourseBlock_site_main_menu extends MoodleBlock {
|
||||
function CourseBlock_site_main_menu ($course) {
|
||||
$this->title = get_string('mainmenu');
|
||||
$this->content_type = BLOCK_TYPE_LIST;
|
||||
$this->course = $course;
|
||||
$this->version = 2004052700;
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('site' => true);
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if (empty($this->course)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->content = New stdClass;
|
||||
$this->content->items = array();
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
$isteacher = isteacher($this->course->id);
|
||||
$isediting = isediting($this->course->id);
|
||||
$ismoving = ismoving($this->course->id);
|
||||
|
||||
$sections = get_all_sections($this->course->id);
|
||||
$section = $sections[0];
|
||||
|
||||
if($section->sequence || $isediting) {
|
||||
get_all_mods($this->course->id, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
}
|
||||
|
||||
$groupbuttons = $this->course->groupmode;
|
||||
$groupbuttonslink = (!$this->course->groupmodeforce);
|
||||
|
||||
if ($ismoving) {
|
||||
$strmovehere = get_string('movehere');
|
||||
$strmovefull = strip_tags(get_string('movefull', '', "'$USER->activitycopyname'"));
|
||||
$strcancel= get_string('cancel');
|
||||
$stractivityclipboard = $USER->activitycopyname;
|
||||
}
|
||||
|
||||
$modinfo = unserialize($this->course->modinfo);
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
$this->content->icons[] = ' <img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
|
||||
$this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true&sesskey='.$USER->sesskey.'">'.$strcancel.'</a>)';
|
||||
}
|
||||
|
||||
if (!empty($section->sequence)) {
|
||||
$sectionmods = explode(',', $section->sequence);
|
||||
foreach ($sectionmods as $modnumber) {
|
||||
if (empty($mods[$modnumber])) {
|
||||
continue;
|
||||
}
|
||||
$mod = $mods[$modnumber];
|
||||
if ($isediting && !$ismoving) {
|
||||
if ($groupbuttons) {
|
||||
if (! $mod->groupmodelink = $groupbuttonslink) {
|
||||
$mod->groupmode = $this->course->groupmode;
|
||||
}
|
||||
|
||||
} else {
|
||||
$mod->groupmode = false;
|
||||
}
|
||||
$editbuttons = '<br />'.make_editing_buttons($mod, true, true);
|
||||
} else {
|
||||
$editbuttons = '';
|
||||
}
|
||||
if ($mod->visible || $isteacher) {
|
||||
if ($ismoving) {
|
||||
if ($mod->id == $USER->activitycopy) {
|
||||
continue;
|
||||
}
|
||||
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
'<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
|
||||
$this->content->icons[] = '';
|
||||
}
|
||||
$instancename = urldecode($modinfo[$modnumber]->name);
|
||||
if (!empty($CFG->filterall)) {
|
||||
$instancename = filter_text('<nolink>'.$instancename.'</nolink>', $this->course->id);
|
||||
}
|
||||
$linkcss = $mod->visible ? '' : ' class="dimmed" ';
|
||||
if (!empty($modinfo[$modnumber]->extra)) {
|
||||
$extra = urldecode($modinfo[$modnumber]->extra);
|
||||
} else {
|
||||
$extra = '';
|
||||
}
|
||||
if (!empty($modinfo[$modnumber]->icon)) {
|
||||
$icon = $CFG->pixpath.'/'.urldecode($modinfo[$modnumber]->icon);
|
||||
} else {
|
||||
$icon = $CFG->modpixpath.'/'.$mod->modname.'/icon.gif';
|
||||
}
|
||||
|
||||
if ($mod->modname == 'label') {
|
||||
$this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
|
||||
$this->content->icons[] = '';
|
||||
} else {
|
||||
$this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
|
||||
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
|
||||
$this->content->icons[] = '<img src="'.$icon.'" height="16" width="16" alt="'.$mod->modfullname.'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ismoving) {
|
||||
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
'<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
|
||||
$this->content->icons[] = '';
|
||||
}
|
||||
|
||||
if ($isediting && $modnames) {
|
||||
$this->content->footer = '<div style="text-align: right;">'.
|
||||
print_section_add_menus($this->course, 0, $modnames, true, true).'</div>';
|
||||
} else {
|
||||
$this->content->footer = '';
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -9,18 +9,15 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return array('social' => true);
|
||||
return COURSE_FORMAT_SOCIAL;
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
}
|
||||
if (empty($this->course)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$this->content = New object;
|
||||
$this->content->items = array();
|
||||
@@ -49,8 +46,8 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
$editbuttons = '';
|
||||
|
||||
if ($ismoving) {
|
||||
$this->content->icons[] = ' <img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
|
||||
$this->content->items[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
|
||||
$this->content->items[] = ' <img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
|
||||
$this->content->icons[] = $USER->activitycopyname.' (<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
|
||||
}
|
||||
|
||||
if (!empty($section->sequence)) {
|
||||
@@ -78,7 +75,7 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
if ($mod->id == $USER->activitycopy) {
|
||||
continue;
|
||||
}
|
||||
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?moveto='.$mod->id.'">'.
|
||||
'<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
|
||||
$this->content->icons[] = '';
|
||||
}
|
||||
@@ -92,11 +89,6 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
} else {
|
||||
$extra = '';
|
||||
}
|
||||
if (!empty($modinfo[$modnumber]->icon)) {
|
||||
$icon = $CFG->pixpath.'/'.urldecode($modinfo[$modnumber]->icon);
|
||||
} else {
|
||||
$icon = $CFG->modpixpath.'/'.$mod->modname.'/icon.gif';
|
||||
}
|
||||
|
||||
if ($mod->modname == 'label') {
|
||||
$this->content->items[] = format_text($extra, FORMAT_HTML).$editbuttons;
|
||||
@@ -104,21 +96,22 @@ class CourseBlock_social_activities extends MoodleBlock {
|
||||
} else {
|
||||
$this->content->items[] = '<a title="'.$mod->modfullname.'" '.$linkcss.' '.$extra.
|
||||
' href="'.$CFG->wwwroot.'/mod/'.$mod->modname.'/view.php?id='.$mod->id.'">'.$instancename.'</a>'.$editbuttons;
|
||||
$this->content->icons[] = '<img src="'.$icon.'" height="16" width="16" alt="'.$mod->modfullname.'">';
|
||||
$this->content->icons[] = '<img src="'.$CFG->modpixpath.'/'.$mod->modname.'/icon.gif" height="16" width="16" alt="'.$mod->modfullname.'">';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($ismoving) {
|
||||
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
$this->content->items[] = '<a title="'.$strmovefull.'" href="'.$CFG->wwwroot.'/course/mod.php?movetosection='.$section->id.'">'.
|
||||
'<img height="16" width="80" src="'.$CFG->pixpath.'/movehere.gif" alt="'.$strmovehere.'" border="0"></a>';
|
||||
$this->content->icons[] = '';
|
||||
}
|
||||
|
||||
if ($isediting && $modnames) {
|
||||
$this->content->footer = '<div style="text-align: right;">'.
|
||||
print_section_add_menus($this->course, 0, $modnames, true, true).'</div>';
|
||||
popup_form($CFG->wwwroot.'/course/mod.php?id='.$this->course->id.'&section='.$section->section.'&add=',
|
||||
$modnames, 'section0', '', get_string('add').'...', 'mods', get_string('activities'), true) . '</div>';
|
||||
} else {
|
||||
$this->content->footer = '';
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@
|
||||
// database (blocks_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$blocks_version = 2004052700; // The current version is a date (YYYYMMDDXX)
|
||||
$blocks_version = 2004052400; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
+11
-33
@@ -39,9 +39,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php');
|
||||
require_once('lib.php');
|
||||
require_once('../course/lib.php');
|
||||
require_once('../mod/forum/lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -71,22 +71,6 @@
|
||||
$defaultformat = FORMAT_MOODLE;
|
||||
}
|
||||
|
||||
// If a course has been supplied in the URL, change the filters to show that one
|
||||
if(!empty($_GET['course'])) {
|
||||
if(is_numeric($_GET['course']) && $_GET['course'] > 0 && record_exists('course', 'id', $_GET['course'])) {
|
||||
if($_GET['course'] == 1) {
|
||||
// If coming from the home page, show all courses
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
calendar_set_referring_course(0);
|
||||
}
|
||||
else {
|
||||
// Otherwise show just this one
|
||||
$SESSION->cal_courses_shown = intval($_GET['course']);
|
||||
calendar_set_referring_course($SESSION->cal_courses_shown);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch($_REQUEST['action']) {
|
||||
case 'delete':
|
||||
$title = get_string('deleteevent', 'calendar');
|
||||
@@ -112,7 +96,7 @@
|
||||
if($form = data_submitted()) {
|
||||
|
||||
$form->name = strip_tags($form->name); // Strip all tags
|
||||
//$form->description = clean_text($form->description , $form->format); // Clean up any bad tags
|
||||
$form->description = clean_text($form->description , $form->format); // Clean up any bad tags
|
||||
|
||||
$form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin);
|
||||
if($form->duration == 1) {
|
||||
@@ -152,7 +136,7 @@
|
||||
if(!empty($form) && $form->type == 'defined') {
|
||||
|
||||
$form->name = strip_tags($form->name); // Strip all tags
|
||||
//$form->description = clean_text($form->description , $form->format); // Clean up any bad tags
|
||||
$form->description = clean_text($form->description , $form->format); // Clean up any bad tags
|
||||
|
||||
$form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin);
|
||||
if($form->duration == 1) {
|
||||
@@ -221,7 +205,7 @@
|
||||
|
||||
switch($_REQUEST['action']) {
|
||||
case 'delete':
|
||||
if(!empty($_REQUEST['confirm']) && $_REQUEST['confirm'] == 1) {
|
||||
if($_REQUEST['confirm'] == 1) {
|
||||
// Kill it and redirect to day view
|
||||
if(($event = get_record('event', 'id', $_REQUEST['id'])) !== false) {
|
||||
/// Log the event delete.
|
||||
@@ -248,7 +232,7 @@
|
||||
$d = $eventtime['mday'];
|
||||
$y = $eventtime['year'];
|
||||
// Display confirmation form
|
||||
print_side_block_start(get_string('deleteevent', 'calendar').': '.$event->name, array('class' => 'mycalendar'));
|
||||
print_side_block_start(get_string('deleteevent', 'calendar').': '.$event->name, '', 'mycalendar');
|
||||
include('event_delete.html');
|
||||
print_side_block_end();
|
||||
}
|
||||
@@ -279,13 +263,7 @@
|
||||
$form->minutes = '';
|
||||
}
|
||||
}
|
||||
if (!empty($form->courseid)) { // Fixes bug 1488
|
||||
$course = get_record('course', 'id', $form->courseid);
|
||||
} else {
|
||||
$course = $site;
|
||||
}
|
||||
|
||||
print_side_block_start(get_string('editevent', 'calendar'), array('class' => 'mycalendar'));
|
||||
print_side_block_start(get_string('editevent', 'calendar'), '', 'mycalendar');
|
||||
include('event_edit.html');
|
||||
print_side_block_end();
|
||||
if ($usehtmleditor) {
|
||||
@@ -415,7 +393,7 @@
|
||||
$header = ' ('.$header.')';
|
||||
}
|
||||
|
||||
print_side_block_start(get_string('newevent', 'calendar').$header, array('class' => 'mycalendar'));
|
||||
print_side_block_start(get_string('newevent', 'calendar').$header, '', 'mycalendar');
|
||||
if($_REQUEST['type'] == 'select') {
|
||||
$defaultcourse = $SESSION->cal_course_referer;
|
||||
if(isteacheredit($defaultcourse, $USER->id)) {
|
||||
@@ -447,7 +425,7 @@
|
||||
$defaultcourses = calendar_get_default_courses();
|
||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||
|
||||
print_side_block_start(get_string('monthlyview', 'calendar'));
|
||||
print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain');
|
||||
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
|
||||
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
|
||||
|
||||
@@ -530,7 +508,7 @@ function calendar_get_allowed_types(&$allowed) {
|
||||
$allowed->courses = false; // This may change just below
|
||||
$allowed->site = isadmin($USER->id);
|
||||
|
||||
if(!empty($SESSION->cal_course_referer) && $SESSION->cal_course_referer > 1 && isteacheredit($SESSION->cal_course_referer, $USER->id)) {
|
||||
if(!empty($SESSION->cal_course_referer) && isteacheredit($SESSION->cal_course_referer, $USER->id)) {
|
||||
$allowed->courses = array($SESSION->cal_course_referer => 1);
|
||||
$allowed->groups = get_groups($SESSION->cal_course_referer);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
<?php
|
||||
// The following is a hack to fix bug 1488
|
||||
$course = get_record('course', 'id', ($form->courseid) ? $form->courseid : $site->id);
|
||||
?>
|
||||
<form method="post" action="event.php" name="edit">
|
||||
<table cellpadding=5>
|
||||
<tr>
|
||||
|
||||
+37
-37
@@ -1,37 +1,37 @@
|
||||
<table class="formtable">
|
||||
<form method="post" action="event.php">
|
||||
<p>
|
||||
<input type="hidden" name="action" value="new" />
|
||||
<input type="hidden" name="timestart" value="<?php echo $form->timestart; ?>" />
|
||||
</p>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventkind', 'calendar'); ?>:</td>
|
||||
<td>
|
||||
<?php if(!empty($allowed->user)) { ?><p><input type='radio' name='type' value='user' id='type_user' checked='checked' /><label for='type_user'><?php print_string('typeuser', 'calendar') ?></label></p>
|
||||
<?php } ?>
|
||||
<?php if(!empty($allowed->groups)) { ?><p><input type='radio' name='type' value='group' id='type_group' /><label for='type_group'><?php echo get_string('typegroup', 'calendar').' '.get_string('groupfor'); ?></label>
|
||||
<select name='groupid'>
|
||||
<option value=''></option>
|
||||
<?php foreach($allowed->groups as $group) {?>
|
||||
<option value='<?php echo $group->id; ?>' <?php if($group->id == $groupid) echo 'selected="selected"';?>><?php echo $group->name; ?></option>
|
||||
<?php }?>
|
||||
</select>
|
||||
<?php } ?>
|
||||
<?php if(!empty($allowed->courses)) { ?>
|
||||
<p><input type='radio' name='type' value='course' id='type_course' /><input type="hidden" name="courseid" value="<?php echo($courseid) ?>" /><label for='type_course'><?php print_string('typecourse', 'calendar') ?></label></p>
|
||||
<?php } ?>
|
||||
<?php if(!empty($allowed->site)) { ?>
|
||||
<p><input type='radio' name='type' value='site' id='type_site' /><label for='type_site'><?php print_string('typesite', 'calendar') ?></label></p>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<p><input type="submit" value=" <?php print_string('ok') ?> ">
|
||||
<input type="button" onclick="document.location.href='view.php?view=upcoming';" value=" <?php print_string('cancel') ?> ">
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
<table class="formtable">
|
||||
<form method="post" action="event.php">
|
||||
<p>
|
||||
<input type="hidden" name="action" value="new" />
|
||||
<input type="hidden" name="timestart" value="<?php echo $form->timestart; ?>" />
|
||||
</p>
|
||||
<tr>
|
||||
<td style="vertical-align: top; text-align: right;"><?php print_string('eventkind', 'calendar'); ?>:</td>
|
||||
<td>
|
||||
<?php if(!empty($allowed->user)) { ?><p><input type='radio' name='type' value='user' id='type_user' checked='checked' /><label for='type_user'><?php print_string('typeuser', 'calendar') ?></label></p>
|
||||
<?php } ?>
|
||||
<?php if(!empty($allowed->groups)) { ?><p><input type='radio' name='type' value='group' id='type_group' /><label for='type_group'><?php echo get_string('typegroup', 'calendar').' '.get_string('groupfor'); ?></label>
|
||||
<select name='groupid'>
|
||||
<option value=''></option>
|
||||
<?php foreach($allowed->groups as $group) {?>
|
||||
<option value='<?php echo $group->id?>' <?php if($group->id == $groupid) echo 'selected="selected"';?>><?php echo $group->name?></option>
|
||||
<?php }?>
|
||||
</select>
|
||||
<?php } ?>
|
||||
<?php if(!empty($allowed->courses)) { ?>
|
||||
<p><input type='radio' name='type' value='course' id='type_course' /><input type="hidden" name="courseid" value="<?php echo($courseid) ?>" /><label for='type_course'><?php print_string('typecourse', 'calendar') ?></label></p>
|
||||
<?php } ?>
|
||||
<?php if(!empty($allowed->site)) { ?>
|
||||
<p><input type='radio' name='type' value='site' id='type_site' /><label for='type_site'><?php print_string('typesite', 'calendar') ?></label></p>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
<p><input type="submit" value=" <?php print_string('ok') ?> ">
|
||||
<input type="button" onclick="document.location.href='view.php?view=upcoming';" value=" <?php print_string('cancel') ?> ">
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</form>
|
||||
</table>
|
||||
|
||||
+214
-239
@@ -47,7 +47,7 @@ else {
|
||||
}
|
||||
|
||||
define ('SECS_IN_DAY', 86400);
|
||||
define ('CALENDAR_UPCOMING_DAYS', 21);
|
||||
define ('CALENDAR_UPCOMING_DAYS', 14);
|
||||
define ('CALENDAR_UPCOMING_MAXEVENTS', 10);
|
||||
define ('CALENDAR_URL', $CFG->wwwroot.'/calendar/');
|
||||
define ('CALENDAR_TF_24', '%H:%M');
|
||||
@@ -112,17 +112,17 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
$events = array();
|
||||
}
|
||||
else {
|
||||
$events = get_records_select('event', $whereclause, 'timestart');
|
||||
$events = get_records_select('event', $whereclause);
|
||||
}
|
||||
|
||||
// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
|
||||
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
|
||||
// possibly removing courseid 1 from $courses, there is only one course left, then clicking on a day in the month
|
||||
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
|
||||
// arguments to this function.
|
||||
|
||||
$morehref = '';
|
||||
if(!empty($courses)) {
|
||||
$courses = array_diff($courses, array(SITEID));
|
||||
$courses = array_diff($courses, array(1));
|
||||
if(count($courses) == 1) {
|
||||
$morehref = '&course='.reset($courses);
|
||||
}
|
||||
@@ -130,8 +130,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
|
||||
// We want to have easy access by day, since the display is on a per-day basis.
|
||||
// Arguments passed by reference.
|
||||
//calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday);
|
||||
calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
|
||||
|
||||
$content .= '<table class="calendarmini">'; // Begin table
|
||||
$content .= '<thead><tr>'; // Header row: day names
|
||||
@@ -190,12 +189,12 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
$popupicon = $CFG->modpixpath.'/'.$event->modulename.'/icon.gif';
|
||||
$popupalt = $event->modulename;
|
||||
|
||||
} else if ($event->courseid == SITEID) { // Site event
|
||||
} else if ($event->courseid == 1) { // Site event
|
||||
$popupicon = $CFG->pixpath.'/c/site.gif';
|
||||
$popupalt = '';
|
||||
} else if ($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) { // Course event
|
||||
} else if ($event->courseid > 1 and empty($event->groupid)) { // Course event
|
||||
$popupicon = $CFG->pixpath.'/c/course.gif';
|
||||
$popupalt = '';
|
||||
$popupalt = '';
|
||||
} else if ($event->groupid) { // Group event
|
||||
$popupicon = $CFG->pixpath.'/c/group.gif';
|
||||
$popupalt = '';
|
||||
@@ -203,11 +202,10 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
$popupicon = $CFG->pixpath.'/c/user.gif';
|
||||
$popupalt = '';
|
||||
}
|
||||
$popupcontent .= '<div><img height="16" width="16" src="'.$popupicon.'" style="vertical-align: middle; margin-right: 4px;" alt="'.$popupalt.'" /><a href="'.$dayhref.'">'.$event->name.'</a></div>';
|
||||
$popupcontent .= '<div><img height=16 width=16 src=\\\''.$popupicon.'\\\' style=\\\'vertical-align: middle; margin-right: 4px;\\\' alt=\\\''.$popupalt.'\\\' /><a href=\\\''.$dayhref.'\\\'>'.addslashes(htmlspecialchars($event->name)).'</a></div>';
|
||||
}
|
||||
|
||||
$popupcaption = get_string('eventsfor', 'calendar', userdate($events[$eventid]->timestart, $strftimetimedayshort));
|
||||
$popupcontent = str_replace("'", "\'", htmlspecialchars($popupcontent));
|
||||
$popup = 'onmouseover="return overlib(\''.$popupcontent.'\', CAPTION, \''.$popupcaption.'\');" onmouseout="return nd();"';
|
||||
|
||||
// Class and cell content
|
||||
@@ -279,20 +277,18 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
|
||||
|
||||
$processed = 0;
|
||||
$now = time(); // We 'll need this later
|
||||
$usermidnighttoday = usergetmidnight($now);
|
||||
$nowsecs = $now % SECS_IN_DAY; // this too
|
||||
$nowdays = $now - $nowsecs; // and this
|
||||
|
||||
if ($fromtime) {
|
||||
$display->tstart = $fromtime;
|
||||
} else {
|
||||
$display->tstart = $usermidnighttoday;
|
||||
$display->tstart = usergetmidnight(time());
|
||||
}
|
||||
|
||||
// This effectively adds as many days as needed, and the final SECS_IN_DAY - 1
|
||||
// serves to cover the duration until the end of the final day. We could
|
||||
// just do another gmmktime() and an addition, but this is "faster" :)
|
||||
|
||||
// WARNING: IT IS ALSO BUGGY WITH REGARDS TO DST CHANGES! THIS HAS TO BE FIXED SOMEDAY!
|
||||
// IF YOU DO SECS ARITHMETIC, THE CODE WILL ALWAYS BE BUGGY WITH REGARD TO DST!
|
||||
$display->tend = $display->tstart + (SECS_IN_DAY * $display->range) - 1;
|
||||
|
||||
// Get the events matching our criteria
|
||||
@@ -300,17 +296,18 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
|
||||
if ($whereclause === false) {
|
||||
$events = false;
|
||||
} else {
|
||||
$events = get_records_select('event', $whereclause, 'timestart');
|
||||
$whereclause .= ' ORDER BY timestart'; // We want them this way
|
||||
$events = get_records_select('event', $whereclause);
|
||||
}
|
||||
|
||||
// This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
|
||||
// possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
|
||||
// possibly removing courseid 1 from $courses, there is only one course left, then clicking on a day in the month
|
||||
// will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
|
||||
// arguments to this function.
|
||||
|
||||
$morehref = '';
|
||||
if(!empty($courses)) {
|
||||
$courses = array_diff($courses, array(SITEID));
|
||||
$courses = array_diff($courses, array(1));
|
||||
if(count($courses) == 1) {
|
||||
$morehref = '&course='.reset($courses);
|
||||
}
|
||||
@@ -318,12 +315,70 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
|
||||
|
||||
if($events !== false) {
|
||||
foreach($events as $event) {
|
||||
if($processed >= $display->maxevents) break;
|
||||
|
||||
if($processed >= $display->maxevents) {
|
||||
break;
|
||||
$startdate = usergetdate($event->timestart);
|
||||
$enddate = usergetdate($event->timestart + $event->timeduration);
|
||||
|
||||
$starttimesecs = $event->timestart % SECS_IN_DAY; // Seconds after that day's midnight
|
||||
$starttimedays = $event->timestart - $starttimesecs; // Timestamp of midnight of that day
|
||||
|
||||
if($event->timeduration) {
|
||||
// To avoid doing the math if one IF is enough :)
|
||||
$endtimesecs = ($event->timestart + $event->timeduration) % SECS_IN_DAY; // Seconds after that day's midnight
|
||||
$endtimedays = ($event->timestart + $event->timeduration) - $endtimesecs; // Timestamp of midnight of that day
|
||||
}
|
||||
else {
|
||||
$endtimesecs = $starttimesecs;
|
||||
$endtimedays = $starttimedays;
|
||||
}
|
||||
|
||||
$eventtime = calendar_format_event_time($event, $now, $morehref);
|
||||
// Keep in mind: $starttimeXXX, $endtimeXXX and $nowXXX are all in GMT-based
|
||||
// OK, now to get a meaningful display...
|
||||
|
||||
// First of all we have to construct a human-readable date/time representation
|
||||
if($endtimedays < $nowdays || $endtimedays == $nowdays && $endtimesecs <= $nowsecs) {
|
||||
// It has expired, so we don't care about duration
|
||||
$day = calendar_day_representation($event->timestart + $event->timeduration, $now);
|
||||
$time = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
|
||||
// This var always has the printable time representation
|
||||
$eventtime = '<span class="dimmed_text"><a class="dimmed" href="'.calendar_get_link_href(CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).'">'.$day.'</a> ('.$time.')</span>';
|
||||
|
||||
}
|
||||
else if($event->timeduration) {
|
||||
// It has a duration
|
||||
if($starttimedays == $endtimedays) {
|
||||
// But it's all on one day
|
||||
$day = calendar_day_representation($event->timestart, $now);
|
||||
$timestart = calendar_time_representation($event->timestart);
|
||||
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
|
||||
// Set printable representation
|
||||
$eventtime = calendar_get_link_tag($day, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).
|
||||
' ('.$timestart.' -> '.$timeend.')';
|
||||
}
|
||||
else {
|
||||
// It spans two or more days
|
||||
$daystart = calendar_day_representation($event->timestart, $now);
|
||||
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now);
|
||||
$timestart = calendar_time_representation($event->timestart);
|
||||
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
|
||||
// Set printable representation
|
||||
$eventtime = calendar_get_link_tag($daystart, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $startdate['mday'], $startdate['mon'], $startdate['year']).
|
||||
' ('.$timestart.') -> '.calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).
|
||||
' ('.$timeend.')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It's an "instantaneous" event
|
||||
$day = calendar_day_representation($event->timestart, $now);
|
||||
$time = calendar_time_representation($event->timestart);
|
||||
|
||||
// Set printable representation
|
||||
$eventtime = calendar_get_link_tag($day, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $startdate['mday'], $startdate['mon'], $startdate['year']).' ('.$time.')';
|
||||
}
|
||||
|
||||
$outkey = count($output);
|
||||
|
||||
@@ -357,12 +412,14 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
|
||||
$output[$outkey]->cmid = $module->id;
|
||||
|
||||
|
||||
} else if($event->courseid == SITEID) { // Site event
|
||||
|
||||
} else if($event->courseid == 1) { // Site event
|
||||
$output[$outkey]->icon = '<img height=16 width=16 src="'.$CFG->pixpath.'/c/site.gif" alt="" style="vertical-align: middle;" />';
|
||||
$output[$outkey]->time = $eventtime;
|
||||
|
||||
|
||||
} else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) { // Course event
|
||||
|
||||
} else if($event->courseid > 1 and !$event->groupid) { // Course event
|
||||
calendar_get_course_cached($coursecache, $event->courseid);
|
||||
|
||||
$output[$outkey]->icon = '<img height=16 width=16 src="'.$CFG->pixpath.'/c/course.gif" alt="" style="vertical-align: middle;" />';
|
||||
@@ -409,11 +466,6 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
|
||||
if(!empty($whereclause)) $whereclause .= ' OR';
|
||||
$whereclause .= ' userid != 0 AND courseid = 0 AND groupid = 0';
|
||||
}
|
||||
else if($users === false) {
|
||||
// No user at all
|
||||
// No need to do anything
|
||||
}
|
||||
|
||||
if(is_array($groups) && !empty($groups)) {
|
||||
// Events from a number of groups
|
||||
if(!empty($whereclause)) $whereclause .= ' OR';
|
||||
@@ -429,20 +481,10 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
|
||||
if(!empty($whereclause)) $whereclause .= ' OR ';
|
||||
$whereclause .= ' groupid != 0';
|
||||
}
|
||||
// boolean false (no groups at all): we don't need to do anything
|
||||
|
||||
if(is_array($courses)) {
|
||||
// A number of courses (maybe none at all!)
|
||||
if(!empty($courses)) {
|
||||
if(!empty($whereclause)) {
|
||||
$whereclause .= ' OR';
|
||||
}
|
||||
$whereclause .= ' groupid = 0 AND courseid IN ('.implode(',', $courses).')';
|
||||
}
|
||||
else {
|
||||
// This means NO courses, not that we don't care!
|
||||
// No need to do anything
|
||||
}
|
||||
if(is_array($courses) && !empty($courses)) {
|
||||
// A number of courses
|
||||
if(!empty($whereclause)) $whereclause .= ' OR';
|
||||
$whereclause .= ' groupid = 0 AND courseid IN ('.implode(',', $courses).')';
|
||||
}
|
||||
else if(is_numeric($courses)) {
|
||||
// One course
|
||||
@@ -455,14 +497,6 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
|
||||
$whereclause .= ' groupid = 0 AND courseid != 0';
|
||||
}
|
||||
|
||||
// Security check: if, by now, we have NOTHING in $whereclause, then it means
|
||||
// that NO event-selecting clauses were defined. Thus, we won't be returning ANY
|
||||
// events no matter what. Allowing the code to proceed might return a completely
|
||||
// valid query with only time constraints, thus selecting ALL events in that time frame!
|
||||
if(empty($whereclause)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($ignorehidden) {
|
||||
if (!empty($whereclause)) $whereclause .= ' AND';
|
||||
$whereclause .= ' visible = 1';
|
||||
@@ -482,8 +516,7 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
|
||||
// Just basic time filtering
|
||||
$whereclause = $timeclause;
|
||||
}
|
||||
|
||||
return empty($whereclause) ? false : $whereclause;
|
||||
return $whereclause;
|
||||
}
|
||||
|
||||
function calendar_top_controls($type, $data) {
|
||||
@@ -540,8 +573,8 @@ function calendar_top_controls($type, $data) {
|
||||
case 'day':
|
||||
$data['d'] = $date['mday']; // Just for convenience
|
||||
$dayname = calendar_wday_name($date['weekday']);
|
||||
$prevdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] - 1));
|
||||
$nextdate = usergetdate(make_timestamp($data['y'], $data['m'], $data['d'] + 1));
|
||||
$prevdate = getdate($time - SECS_IN_DAY);
|
||||
$nextdate = getdate($time + SECS_IN_DAY);
|
||||
$prevname = calendar_wday_name($prevdate['weekday']);
|
||||
$nextname = calendar_wday_name($nextdate['weekday']);
|
||||
$content .= "<table style='width: 100%;'><tr>\n";
|
||||
@@ -578,11 +611,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) {
|
||||
$getvars = '&from='.$type;
|
||||
break;
|
||||
case 'course':
|
||||
if (isset($_GET['id'])) {
|
||||
$getvars = '&from=course&id='.$_GET['id'];
|
||||
} else {
|
||||
$getvars = '&from=course';
|
||||
}
|
||||
$getvars = '&from=course&id='.$_GET['id'];
|
||||
if (isset($course->groupmode) and !$course->groupmode and $course->groupmodeforce) {
|
||||
$groupevents = false;
|
||||
}
|
||||
@@ -609,7 +638,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) {
|
||||
$content .= '<td style="width: 8px;"></td><td><a href="'.CALENDAR_URL.'set.php?var=showcourses'.$getvars.'" title="'.get_string('tt_showcourse', 'calendar').'">'.get_string('courseevents', 'calendar').'</a></td>'."\n";
|
||||
}
|
||||
|
||||
if(!empty($USER->id) && !isguest()) {
|
||||
if(!isguest($USER->id)) {
|
||||
$content .= "</tr>\n<tr>";
|
||||
|
||||
if($groupevents) {
|
||||
@@ -655,28 +684,27 @@ function calendar_day_representation($tstamp, $now = false, $usecommonwords = tr
|
||||
// To have it in one place, if a change is needed
|
||||
$formal = userdate($tstamp, $shortformat);
|
||||
|
||||
$datestamp = usergetdate($tstamp);
|
||||
$datenow = usergetdate($now);
|
||||
// Reverse TZ compensation: make GMT stamps correspond to user's TZ
|
||||
$tzfix = calendar_get_tz_offset();
|
||||
$tstamp += $tzfix;
|
||||
$now += $tzfix;
|
||||
|
||||
$eventdays = intval($tstamp / SECS_IN_DAY);
|
||||
$nowdays = intval($now / SECS_IN_DAY);
|
||||
|
||||
if($usecommonwords == false) {
|
||||
// We don't want words, just a date
|
||||
return $formal;
|
||||
}
|
||||
else if($datestamp['year'] == $datenow['year'] && $datestamp['yday'] == $datenow['yday']) {
|
||||
else if($eventdays == $nowdays) {
|
||||
// Today
|
||||
return get_string('today', 'calendar');
|
||||
}
|
||||
else if(
|
||||
($datestamp['year'] == $datenow['year'] && $datestamp['yday'] == $datenow['yday'] - 1 ) ||
|
||||
($datestamp['year'] == $datenow['year'] - 1 && $datestamp['mday'] == 31 && $datestamp['mon'] == 12 && $datenow['yday'] == 1)
|
||||
) {
|
||||
else if($eventdays == $nowdays - 1) {
|
||||
// Yesterday
|
||||
return get_string('yesterday', 'calendar');
|
||||
}
|
||||
else if(
|
||||
($datestamp['year'] == $datenow['year'] && $datestamp['yday'] == $datenow['yday'] + 1 ) ||
|
||||
($datestamp['year'] == $datenow['year'] + 1 && $datenow['mday'] == 31 && $datenow['mon'] == 12 && $datestamp['yday'] == 1)
|
||||
) {
|
||||
else if($eventdays == $nowdays + 1) {
|
||||
// Tomorrow
|
||||
return get_string('tomorrow', 'calendar');
|
||||
}
|
||||
@@ -731,15 +759,28 @@ function calendar_mktime_check($m, $d, $y, $default = false) {
|
||||
}
|
||||
}
|
||||
|
||||
function calendar_month_name($month) {
|
||||
if(is_int($month)) {
|
||||
// 1 ... 12 integer converted to month name
|
||||
$months = array('january', 'february', 'march', 'april', 'may', 'june', 'july', 'august', 'september', 'october', 'november', 'december');
|
||||
return get_string($months[$month - 1], 'calendar');
|
||||
}
|
||||
else {
|
||||
return get_string(strtolower($month), 'calendar');
|
||||
}
|
||||
}
|
||||
|
||||
function calendar_wday_name($englishname) {
|
||||
return get_string(strtolower($englishname), 'calendar');
|
||||
}
|
||||
|
||||
function calendar_days_in_month($month, $year) {
|
||||
return intval(date('t', mktime(0, 0, 0, $month, 1, $year)));
|
||||
return date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
}
|
||||
|
||||
function calendar_get_sideblock_upcoming($events, $linkhref = NULL) {
|
||||
function calendar_get_sideblock_upcoming($courses, $groups, $users, $daysinfuture, $maxevents) {
|
||||
$events = calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents);
|
||||
|
||||
$content = '';
|
||||
$lines = count($events);
|
||||
if (!$lines) {
|
||||
@@ -747,22 +788,12 @@ function calendar_get_sideblock_upcoming($events, $linkhref = NULL) {
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $lines; ++$i) {
|
||||
if (!isset($events[$i]->time)) { // Just for robustness
|
||||
continue;
|
||||
}
|
||||
$content .= '<div class="cal_event">'.$events[$i]->icon.' ';
|
||||
if (!empty($events[$i]->referer)) {
|
||||
// That's an activity event, so let's provide the hyperlink
|
||||
$content .= $events[$i]->referer;
|
||||
} else {
|
||||
if(!empty($linkhref)) {
|
||||
$ed = usergetdate($events[$i]->timestart);
|
||||
$href = calendar_get_link_href(CALENDAR_URL.$linkhref, $ed['mday'], $ed['mon'], $ed['year']);
|
||||
$content .= '<a href="'.$href.'">'.$events[$i]->name.'</a>';
|
||||
}
|
||||
else {
|
||||
$content .= $events[$i]->name;
|
||||
}
|
||||
$content .= $events[$i]->name;
|
||||
}
|
||||
$events[$i]->time = str_replace('->', '<br />->', $events[$i]->time);
|
||||
$content .= '</div><div class="cal_event_date" style="text-align:right;">'.$events[$i]->time.'</div>';
|
||||
@@ -790,7 +821,7 @@ function calendar_sub_month($month, $year) {
|
||||
}
|
||||
}
|
||||
|
||||
function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$durationbyday, &$typesbyday) {
|
||||
function calendar_events_by_day($events, $starttime, &$eventsbyday, &$durationbyday, &$typesbyday) {
|
||||
$eventsbyday = array();
|
||||
$typesbyday = array();
|
||||
$durationbyday = array();
|
||||
@@ -799,66 +830,61 @@ function calendar_events_by_day($events, $month, $year, &$eventsbyday, &$duratio
|
||||
return;
|
||||
}
|
||||
|
||||
// Reverse TZ compensation: make GMT stamps (from event table) correspond to user's TZ
|
||||
$tzfix = calendar_get_tz_offset();
|
||||
|
||||
foreach($events as $event) {
|
||||
$eventdaystart = 1 + floor(($event->timestart + $tzfix - $starttime) / SECS_IN_DAY);
|
||||
$eventdayend = 1 + floor(($event->timestart + $event->timeduration + $tzfix - $starttime) / SECS_IN_DAY);
|
||||
|
||||
$startdate = usergetdate($event->timestart);
|
||||
$enddate = usergetdate($event->timestart + $event->timeduration);
|
||||
// Give the event to its day
|
||||
$eventsbyday[$eventdaystart][] = $event->id;
|
||||
|
||||
// Simple arithmetic: $year * 13 + $month is a distinct integer for each distinct ($year, $month) pair
|
||||
if(!($startdate['year'] * 13 + $startdate['mon'] <= $year * 13 + $month) && ($enddate['year'] * 13 + $enddate['mon'] >= $year * 13 + $month)) {
|
||||
// Out of bounds
|
||||
continue;
|
||||
// Mark the day as having such an event
|
||||
if($event->courseid == 1 && $event->groupid == 0) {
|
||||
$typesbyday[$eventdaystart]['startglobal'] = true;
|
||||
}
|
||||
else if($event->courseid > 1 && $event->groupid == 0) {
|
||||
$typesbyday[$eventdaystart]['startcourse'] = true;
|
||||
}
|
||||
else if($event->groupid) {
|
||||
$typesbyday[$eventdaystart]['startgroup'] = true;
|
||||
}
|
||||
else if($event->userid) {
|
||||
$typesbyday[$eventdaystart]['startuser'] = true;
|
||||
}
|
||||
|
||||
$eventdaystart = intval($startdate['mday']);
|
||||
// Mark all days up to and including ending day as duration
|
||||
if($eventdaystart < $eventdayend) {
|
||||
|
||||
if($startdate['mon'] == $month && $startdate['year'] == $year) {
|
||||
// Give the event to its day
|
||||
$eventsbyday[$eventdaystart][] = $event->id;
|
||||
// Normally this should be
|
||||
|
||||
// Mark the day as having such an event
|
||||
if($event->courseid == SITEID && $event->groupid == 0) {
|
||||
$typesbyday[$eventdaystart]['startglobal'] = true;
|
||||
}
|
||||
else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
|
||||
$typesbyday[$eventdaystart]['startcourse'] = true;
|
||||
}
|
||||
else if($event->groupid) {
|
||||
$typesbyday[$eventdaystart]['startgroup'] = true;
|
||||
}
|
||||
else if($event->userid) {
|
||||
$typesbyday[$eventdaystart]['startuser'] = true;
|
||||
// $bound = min($eventdayend, $display->maxdays);
|
||||
// for($i = $eventdaystart + 1; $i <= $bound; ++$i) {
|
||||
|
||||
// So that we don't go on marking days after the end of
|
||||
// the month if the event continues. However, this code
|
||||
// has moved and now we don't have access to $display->maxdays.
|
||||
// In order to save the overhead of recomputing it, we just
|
||||
// use this "dumb" approach. Anyway, the function that called
|
||||
// us already knows up to what day it should display.
|
||||
|
||||
for($i = $eventdaystart + 1; $i <= $eventdayend; ++$i) {
|
||||
$durationbyday[$i][] = $event->id;
|
||||
if($event->courseid == 1 && $event->groupid == 0) {
|
||||
$typesbyday[$i]['durationglobal'] = true;
|
||||
}
|
||||
else if($event->courseid > 1 && $event->groupid == 0) {
|
||||
$typesbyday[$i]['durationcourse'] = true;
|
||||
}
|
||||
else if($event->groupid) {
|
||||
$typesbyday[$i]['durationgroup'] = true;
|
||||
}
|
||||
else if($event->userid) {
|
||||
$typesbyday[$i]['durationuser'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($event->timeduration == 0) {
|
||||
// Proceed with the next
|
||||
continue;
|
||||
}
|
||||
|
||||
// The event starts on $month $year or before. So...
|
||||
$lowerbound = $startdate['mon'] == $month && $startdate['year'] == $year ? intval($startdate['mday']) : 0;
|
||||
|
||||
// Also, it ends on $month $year or later...
|
||||
$upperbound = $enddate['mon'] == $month && $enddate['year'] == $year ? intval($enddate['mday']) : calendar_days_in_month($month, $year);
|
||||
|
||||
// Mark all days between $lowerbound and $upperbound (inclusive) as duration
|
||||
for($i = $lowerbound + 1; $i <= $upperbound; ++$i) {
|
||||
$durationbyday[$i][] = $event->id;
|
||||
if($event->courseid == SITEID && $event->groupid == 0) {
|
||||
$typesbyday[$i]['durationglobal'] = true;
|
||||
}
|
||||
else if($event->courseid != 0 && $event->courseid != SITEID && $event->groupid == 0) {
|
||||
$typesbyday[$i]['durationcourse'] = true;
|
||||
}
|
||||
else if($event->groupid) {
|
||||
$typesbyday[$i]['durationgroup'] = true;
|
||||
}
|
||||
else if($event->userid) {
|
||||
$typesbyday[$i]['durationuser'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -883,19 +909,6 @@ function calendar_get_course_cached(&$coursecache, $courseid) {
|
||||
function calendar_session_vars() {
|
||||
global $SESSION, $USER;
|
||||
|
||||
if(!empty($USER->id) && isset($USER->realuser) && !isset($SESSION->cal_loggedinas)) {
|
||||
// We just logged in as someone else, update the filtering
|
||||
unset($SESSION->cal_users_shown);
|
||||
unset($SESSION->cal_courses_shown);
|
||||
$SESSION->cal_loggedinas = true;
|
||||
}
|
||||
else if(!empty($USER->id) && !isset($USER->realuser) && isset($SESSION->cal_loggedinas)) {
|
||||
// We just logged back to our real self, update again
|
||||
unset($SESSION->cal_users_shown);
|
||||
unset($SESSION->cal_courses_shown);
|
||||
unset($SESSION->cal_loggedinas);
|
||||
}
|
||||
|
||||
if(!isset($SESSION->cal_course_referer)) {
|
||||
$SESSION->cal_course_referer = 0;
|
||||
}
|
||||
@@ -909,21 +922,11 @@ function calendar_session_vars() {
|
||||
$SESSION->cal_show_course = true;
|
||||
}
|
||||
if(!isset($SESSION->cal_show_user)) {
|
||||
$SESSION->cal_show_user = true;
|
||||
$SESSION->cal_show_user = isset($USER->id) ? $USER->id : false;
|
||||
}
|
||||
if(empty($SESSION->cal_courses_shown)) {
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
}
|
||||
if(empty($SESSION->cal_users_shown)) {
|
||||
// The empty() instead of !isset() here makes a whole world of difference,
|
||||
// as it will automatically change to the user's id when the user first logs
|
||||
// in. With !isset(), it would never do that.
|
||||
$SESSION->cal_users_shown = isset($USER->id) ? $USER->id : false;
|
||||
}
|
||||
else if(is_numeric($SESSION->cal_users_shown) && !empty($USER->id) && $SESSION->cal_users_shown != $USER->id) {
|
||||
// Follow the white rabbit, for example if a teacher logs in as a student
|
||||
$SESSION->cal_users_shown = $USER->id;
|
||||
}
|
||||
}
|
||||
|
||||
function calendar_overlib_html() {
|
||||
@@ -960,11 +963,11 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
|
||||
|
||||
if(($SESSION->cal_show_course && $SESSION->cal_show_global) || $ignorefilters) {
|
||||
if(is_int($courseeventsfrom)) {
|
||||
$courses = array(SITEID, $courseeventsfrom);
|
||||
$courses = array(1, $courseeventsfrom);
|
||||
}
|
||||
else if(is_array($courseeventsfrom)) {
|
||||
$courses = array_keys($courseeventsfrom);
|
||||
$courses[] = SITEID;
|
||||
$courses[] = 1;
|
||||
}
|
||||
}
|
||||
else if($SESSION->cal_show_course) {
|
||||
@@ -974,18 +977,22 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
|
||||
else if(is_array($courseeventsfrom)) {
|
||||
$courses = array_keys($courseeventsfrom);
|
||||
}
|
||||
$courses = array_diff($courses, array(SITEID));
|
||||
$courses = array_diff($courses, array(1));
|
||||
}
|
||||
else if($SESSION->cal_show_global) {
|
||||
$courses = array(SITEID);
|
||||
$courses = array(1);
|
||||
}
|
||||
else {
|
||||
$courses = false;
|
||||
}
|
||||
|
||||
if($SESSION->cal_show_user || $ignorefilters) {
|
||||
// This doesn't work for arrays yet (maybe someday it will)
|
||||
$user = $SESSION->cal_users_shown;
|
||||
// This ignores the "which user to see" setting
|
||||
// The functionality to do that does exist, but this was
|
||||
// the most painless way to solve bug 1323. And anyway,
|
||||
// it wasn't being used anywhere.
|
||||
$user = $USER->id;
|
||||
//$user = $SESSION->cal_show_user;
|
||||
}
|
||||
else {
|
||||
$user = false;
|
||||
@@ -1003,7 +1010,7 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
|
||||
// For each course...
|
||||
foreach($groupcourses as $courseid) {
|
||||
// If the user is an editing teacher in there,
|
||||
if(!empty($USER->id) && isteacheredit($courseid, $USER->id)) {
|
||||
if(isteacheredit($courseid, $USER->id)) {
|
||||
// Show events from all groups
|
||||
if(($grouprecords = get_groups($courseid)) !== false) {
|
||||
$grouparray = array_merge($grouparray, array_keys($grouprecords));
|
||||
@@ -1029,13 +1036,9 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
|
||||
function calendar_edit_event_allowed($event) {
|
||||
global $USER;
|
||||
|
||||
if(empty($USER->id) || isguest($USER->id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isadmin($USER->id)) return true; // Admins are allowed anything
|
||||
|
||||
if ($event->courseid != 0 && $event->courseid != SITEID) {
|
||||
if ($event->courseid > 1) {
|
||||
// Course event, only editing teachers may... edit :P
|
||||
if(isteacheredit($event->courseid)) {
|
||||
return true;
|
||||
@@ -1061,15 +1064,15 @@ function calendar_get_default_courses($ignoreref = false) {
|
||||
global $USER, $CFG, $SESSION;
|
||||
|
||||
if(!empty($SESSION->cal_course_referer) && !$ignoreref) {
|
||||
return array($SESSION->cal_course_referer => SITEID);
|
||||
return array($SESSION->cal_course_referer => 1);
|
||||
}
|
||||
|
||||
if(empty($USER->id)) {
|
||||
if(empty($USER)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$courses = array();
|
||||
if(!empty($USER->id) && isadmin($USER->id)) {
|
||||
if(isadmin($USER->id)) {
|
||||
$courses = get_records_sql('SELECT id, 1 FROM '.$CFG->prefix.'course');
|
||||
return $courses;
|
||||
}
|
||||
@@ -1082,6 +1085,40 @@ function calendar_get_default_courses($ignoreref = false) {
|
||||
return $courses;
|
||||
}
|
||||
|
||||
function calendar_get_tz_offset() {
|
||||
global $USER, $CFG;
|
||||
static $tzfix;
|
||||
|
||||
// Caching
|
||||
if(isset($tzfix)) {
|
||||
return $tzfix;
|
||||
}
|
||||
|
||||
if(empty($USER)) {
|
||||
// Don't forget that there are users which have NOT logged in, even as guests
|
||||
$timezone = $CFG->timezone;
|
||||
}
|
||||
else {
|
||||
// If, on the other hand, we do have a user...
|
||||
$timezone = $USER->timezone;
|
||||
if(abs($timezone > 13)) {
|
||||
// But if the user has specified 'server default' time,
|
||||
// don't get the server's; get the Moodle $CFG setting
|
||||
// (Martin's help text on site cfg implies this)
|
||||
$timezone = $CFG->timezone;
|
||||
}
|
||||
}
|
||||
|
||||
if(abs($timezone) <= 13) {
|
||||
$tzfix = $timezone * 3600;
|
||||
}
|
||||
else {
|
||||
$tzfix = date('Z');
|
||||
}
|
||||
|
||||
return $tzfix;
|
||||
}
|
||||
|
||||
function calendar_preferences_array() {
|
||||
return array(
|
||||
'startwday' => get_string('pref_startwday', 'calendar'),
|
||||
@@ -1095,7 +1132,7 @@ function calendar_preferences_button() {
|
||||
global $CFG, $USER;
|
||||
|
||||
// Guests have no preferences
|
||||
if (empty($USER->id) || isguest()) {
|
||||
if (empty($USER->id) or isguest()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -1104,68 +1141,6 @@ function calendar_preferences_button() {
|
||||
"<input type=\"submit\" value=\"".get_string("preferences", "calendar")." ...\" /></form>";
|
||||
}
|
||||
|
||||
function calendar_format_event_time($event, $now, $morehref, $usecommonwords = true) {
|
||||
$startdate = usergetdate($event->timestart);
|
||||
$enddate = usergetdate($event->timestart + $event->timeduration);
|
||||
$usermidnightstart = usergetmidnight($event->timestart);
|
||||
|
||||
if($event->timeduration) {
|
||||
// To avoid doing the math if one IF is enough :)
|
||||
$usermidnightend = usergetmidnight($event->timestart + $event->timeduration);
|
||||
}
|
||||
else {
|
||||
$usermidnightend = $usermidnightstart;
|
||||
}
|
||||
|
||||
// OK, now to get a meaningful display...
|
||||
// First of all we have to construct a human-readable date/time representation
|
||||
|
||||
if($event->timestart + $event->timeduration < $now) {
|
||||
// It has expired, so we don't care about duration
|
||||
$day = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords);
|
||||
$time = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
|
||||
// This var always has the printable time representation
|
||||
$eventtime = '<span class="dimmed_text"><a class="dimmed" href="'.calendar_get_link_href(CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).'">'.$day.'</a> ('.$time.')</span>';
|
||||
|
||||
}
|
||||
else if($event->timeduration) {
|
||||
// It has a duration
|
||||
if($usermidnightstart == $usermidnightend) {
|
||||
// But it's all on the same day
|
||||
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
|
||||
$timestart = calendar_time_representation($event->timestart);
|
||||
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
|
||||
// Set printable representation
|
||||
$eventtime = calendar_get_link_tag($day, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).
|
||||
' ('.$timestart.' -> '.$timeend.')';
|
||||
}
|
||||
else {
|
||||
// It spans two or more days
|
||||
$daystart = calendar_day_representation($event->timestart, $now, $usecommonwords);
|
||||
$dayend = calendar_day_representation($event->timestart + $event->timeduration, $now, $usecommonwords);
|
||||
$timestart = calendar_time_representation($event->timestart);
|
||||
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
|
||||
// Set printable representation
|
||||
$eventtime = calendar_get_link_tag($daystart, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $startdate['mday'], $startdate['mon'], $startdate['year']).
|
||||
' ('.$timestart.') -> '.calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).
|
||||
' ('.$timeend.')';
|
||||
}
|
||||
}
|
||||
else {
|
||||
// It's an "instantaneous" event
|
||||
$day = calendar_day_representation($event->timestart, $now, $usecommonwords);
|
||||
$time = calendar_time_representation($event->timestart);
|
||||
|
||||
// Set printable representation
|
||||
$eventtime = calendar_get_link_tag($day, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $startdate['mday'], $startdate['mon'], $startdate['year']).' ('.$time.')';
|
||||
}
|
||||
|
||||
return $eventtime;
|
||||
}
|
||||
|
||||
if(!function_exists('array_diff_assoc')) {
|
||||
// PHP < 4.3.0
|
||||
function array_diff_assoc($source, $diff) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?PHP // $Id$
|
||||
// preferences.php - user prefs for calendar
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
require("../config.php");
|
||||
require_once('lib.php');
|
||||
|
||||
|
||||
if (isset($SESSION->cal_course_referer)) {
|
||||
if (! $course = get_record("course", "id", $SESSION->cal_course_referer)) {
|
||||
@@ -16,7 +17,7 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
if ($form = data_submitted()) {
|
||||
print_header();
|
||||
foreach ($form as $preference => $value) {
|
||||
switch ($preference) {
|
||||
@@ -78,6 +79,6 @@
|
||||
include("preferences.html");
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer($course);
|
||||
print_footer($course->id);
|
||||
|
||||
?>
|
||||
|
||||
+9
-5
@@ -39,7 +39,9 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
require_once('lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
require_variable($_GET['from']);
|
||||
require_variable($_GET['var']);
|
||||
@@ -50,9 +52,6 @@
|
||||
optional_variable($_GET['cal_y']);
|
||||
|
||||
switch($_GET['var']) {
|
||||
case 'setuser':
|
||||
// Not implemented yet (or possibly at all)
|
||||
break;
|
||||
case 'setcourse':
|
||||
$id = intval($_GET['id']);
|
||||
if($id == 0) {
|
||||
@@ -86,7 +85,12 @@
|
||||
$SESSION->cal_show_global = !$SESSION->cal_show_global;
|
||||
break;
|
||||
case 'showuser':
|
||||
$SESSION->cal_show_user = !$SESSION->cal_show_user;
|
||||
if($SESSION->cal_show_user) {
|
||||
$SESSION->cal_show_user = false;
|
||||
}
|
||||
else {
|
||||
$SESSION->cal_show_user = $USER->id;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+48
-61
@@ -41,10 +41,17 @@
|
||||
// Display the calendar page.
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_once($CFG->dirroot.'/calendar/lib.php');
|
||||
require_once('../course/lib.php');
|
||||
|
||||
require_login();
|
||||
|
||||
require_once('lib.php');
|
||||
|
||||
optional_variable($_GET['view'], 'upcoming');
|
||||
optional_variable($_GET['course'], 0);
|
||||
optional_variable($_GET['cal_d']);
|
||||
optional_variable($_GET['cal_m']);
|
||||
optional_variable($_GET['cal_y']);
|
||||
|
||||
if(!$site = get_site()) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/index.php');
|
||||
@@ -56,11 +63,10 @@
|
||||
|
||||
$nav = calendar_get_link_tag(get_string('calendar', 'calendar'), CALENDAR_URL.'view.php?view=upcoming&', $now['mday'], $now['mon'], $now['year']);
|
||||
|
||||
$view = optional_param('view', 'upcoming');
|
||||
$day = optional_param('cal_d', 0, PARAM_INT);
|
||||
$mon = optional_param('cal_m', 0, PARAM_INT);
|
||||
$yr = optional_param('cal_y', 0, PARAM_INT);
|
||||
|
||||
// Make sure that the GET variables are correct
|
||||
$day = intval($_GET['cal_d']);
|
||||
$mon = intval($_GET['cal_m']);
|
||||
$yr = intval($_GET['cal_y']);
|
||||
if(!checkdate($mon, $day, $yr)) {
|
||||
$day = intval($now['mday']);
|
||||
$mon = intval($now['mon']);
|
||||
@@ -68,7 +74,7 @@
|
||||
}
|
||||
$time = mktime(0, 0, 0, $mon, $day, $yr);
|
||||
|
||||
switch($view) {
|
||||
switch($_GET['view']) {
|
||||
case 'day':
|
||||
$text = strftime(get_string('strftimedate'), $time);
|
||||
if($text[0] == '0') {
|
||||
@@ -87,35 +93,26 @@
|
||||
}
|
||||
|
||||
// If a course has been supplied in the URL, change the filters to show that one
|
||||
if (!empty($_GET['course'])) {
|
||||
if (is_numeric($_GET['course']) && $_GET['course'] > 0 && record_exists('course', 'id', $_GET['course'])) {
|
||||
if ($_GET['course'] == 1) {
|
||||
// If coming from the home page, show all courses
|
||||
$SESSION->cal_courses_shown = calendar_get_default_courses(true);
|
||||
calendar_set_referring_course(0);
|
||||
|
||||
} else {
|
||||
// Otherwise show just this one
|
||||
$SESSION->cal_courses_shown = intval($_GET['course']);
|
||||
calendar_set_referring_course($SESSION->cal_courses_shown);
|
||||
}
|
||||
if(!empty($_GET['course'])) {
|
||||
if(is_numeric($_GET['course']) && $_GET['course'] > 0 && record_exists('course', 'id', $_GET['course'])) {
|
||||
$SESSION->cal_courses_shown = intval($_GET['course']);
|
||||
calendar_set_referring_course($SESSION->cal_courses_shown);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($USER->id) or isguest()) {
|
||||
if(isguest($USER->id)) {
|
||||
$defaultcourses = calendar_get_default_courses();
|
||||
calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses);
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
calendar_set_filters($courses, $groups, $users);
|
||||
}
|
||||
|
||||
// Let's see if we are supposed to provide a referring course link
|
||||
// but NOT for the "main page" course
|
||||
if ($SESSION->cal_course_referer > 1 &&
|
||||
($shortname = get_field('course', 'shortname', 'id', $SESSION->cal_course_referer)) !== false) {
|
||||
// If we know about the referring course, show a return link and ALSO require login!
|
||||
require_login();
|
||||
if($SESSION->cal_course_referer > 1 &&
|
||||
($shortname = get_field('course', 'shortname', 'id', $SESSION->cal_course_referer)) !== false) {
|
||||
// If we know about the referring course, show a return link
|
||||
$nav = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$SESSION->cal_course_referer.'">'.$shortname.'</a> -> '.$nav;
|
||||
}
|
||||
|
||||
@@ -136,7 +133,7 @@
|
||||
|
||||
echo '<td style="vertical-align: top; width: 100%;">';
|
||||
|
||||
switch($view) {
|
||||
switch($_GET['view']) {
|
||||
case 'day':
|
||||
calendar_show_day($day, $mon, $yr, $courses, $groups, $users);
|
||||
break;
|
||||
@@ -154,11 +151,11 @@
|
||||
|
||||
// START: Last column (3-month display)
|
||||
echo '<td style="vertical-align: top; width: 180px;">';
|
||||
print_side_block_start(get_string('monthlyview', 'calendar'));
|
||||
print_side_block_start(get_string('monthlyview', 'calendar'), '', 'sideblockmain');
|
||||
list($prevmon, $prevyr) = calendar_sub_month($mon, $yr);
|
||||
list($nextmon, $nextyr) = calendar_add_month($mon, $yr);
|
||||
$getvars = 'cal_d='.$day.'&cal_m='.$mon.'&cal_y='.$yr; // For filtering
|
||||
echo calendar_filter_controls($view, $getvars);
|
||||
echo calendar_filter_controls($_GET['view'], $getvars);
|
||||
echo '<p>';
|
||||
echo calendar_top_controls('display', array('m' => $prevmon, 'y' => $prevyr));
|
||||
echo calendar_get_mini($courses, $groups, $users, $prevmon, $prevyr);
|
||||
@@ -180,7 +177,7 @@
|
||||
|
||||
|
||||
function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
global $CFG, $THEME, $USER;
|
||||
global $CFG, $THEME, $db;
|
||||
|
||||
if (!checkdate($m, $d, $y)) {
|
||||
$now = usergetdate(time());
|
||||
@@ -190,13 +187,14 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
$getvars = 'from=day&cal_d='.$d.'&cal_m='.$m.'&cal_y='.$y; // For filtering
|
||||
|
||||
$starttime = make_timestamp($y, $m, $d);
|
||||
$endtime = make_timestamp($y, $m, $d + 1) - 1;
|
||||
$endtime = $starttime + SECS_IN_DAY - 1;
|
||||
|
||||
$events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime);
|
||||
|
||||
// New event button
|
||||
if (empty($USER->id) || isguest()) {
|
||||
if (isguest()) {
|
||||
$text = get_string('dayview', 'calendar').': '.calendar_course_filter_selector($getvars);
|
||||
|
||||
} else {
|
||||
$text = '<div style="float: left;">'.get_string('dayview', 'calendar').': '.
|
||||
calendar_course_filter_selector($getvars).'</div><div style="float: right;">';
|
||||
@@ -209,7 +207,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
$text.= '</form></div>';
|
||||
}
|
||||
|
||||
print_side_block_start($text, array('class' => 'mycalendar'));
|
||||
print_side_block_start($text, '', 'mycalendar');
|
||||
echo '<p>'.calendar_top_controls('day', array('d' => $d, 'm' => $m, 'y' => $y)).'</p>';
|
||||
|
||||
if (empty($events)) {
|
||||
@@ -223,17 +221,7 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
// First, print details about events that start today
|
||||
foreach ($events as $event) {
|
||||
if ($event->timestart >= $starttime && $event->timestart <= $endtime) { // Print it now
|
||||
|
||||
|
||||
/*
|
||||
$dayend = calendar_day_representation($event->timestart + $event->timeduration);
|
||||
$timeend = calendar_time_representation($event->timestart + $event->timeduration);
|
||||
$enddate = usergetdate($event->timestart + $event->timeduration);
|
||||
// Set printable representation
|
||||
echo calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&', $enddate['mday'], $enddate['mon'], $enddate['year']).' ('.$timeend.')';
|
||||
*/
|
||||
//unset($event->time);
|
||||
$event->time = calendar_format_event_time($event, time(), '', false);
|
||||
unset($event->time);
|
||||
calendar_print_event($event);
|
||||
|
||||
} else { // Save this for later
|
||||
@@ -245,7 +233,6 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
|
||||
if (!empty($underway)) {
|
||||
echo '<p style="text-align: center;"><strong>'.get_string('spanningevents', 'calendar').':</strong></p>';
|
||||
foreach ($underway as $event) {
|
||||
$event->time = calendar_format_event_time($event, time(), '', false);
|
||||
calendar_print_event($event);
|
||||
}
|
||||
}
|
||||
@@ -309,14 +296,14 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||
$events = array();
|
||||
}
|
||||
else {
|
||||
$events = get_records_select('event', $whereclause, 'timestart');
|
||||
$events = get_records_select('event', $whereclause);
|
||||
}
|
||||
|
||||
// Extract information: events vs. time
|
||||
calendar_events_by_day($events, $m, $y, $eventsbyday, $durationbyday, $typesbyday);
|
||||
calendar_events_by_day($events, $display->tstart, $eventsbyday, $durationbyday, $typesbyday);
|
||||
|
||||
// New event button
|
||||
if(empty($USER->id) || isguest()) {
|
||||
if(isguest()) {
|
||||
$text = get_string('detailedmonthview', 'calendar').': '.calendar_course_filter_selector($getvars);
|
||||
}
|
||||
else {
|
||||
@@ -329,7 +316,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||
$text.= '</form></div>';
|
||||
}
|
||||
|
||||
print_side_block_start($text, array('class' => 'mycalendar'));
|
||||
print_side_block_start($text, '', 'mycalendar');
|
||||
|
||||
echo calendar_top_controls('month', array('m' => $m, 'y' => $y));
|
||||
|
||||
@@ -479,7 +466,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||
|
||||
echo "</tr>\n";
|
||||
|
||||
if(!empty($USER->id) && !isguest()) {
|
||||
if(!isguest($USER->id)) {
|
||||
echo '<tr>';
|
||||
// Group events
|
||||
if($SESSION->cal_show_groups) {
|
||||
@@ -507,12 +494,11 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
|
||||
}
|
||||
|
||||
function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $maxevents) {
|
||||
global $USER;
|
||||
|
||||
$events = calendar_get_upcoming($courses, $groups, $users, $futuredays, $maxevents);
|
||||
|
||||
// New event button
|
||||
if(empty($USER->id) || isguest()) {
|
||||
if(isguest()) {
|
||||
$text = get_string('upcomingevents', 'calendar').': '.calendar_course_filter_selector('from=upcoming');
|
||||
|
||||
} else {
|
||||
@@ -527,7 +513,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||
$text.= '</form></div>';
|
||||
}
|
||||
|
||||
print_side_block_start($text, array('class' => 'mycalendar'));
|
||||
print_side_block_start($text, '', 'mycalendar');
|
||||
if ($events) {
|
||||
foreach ($events as $event) {
|
||||
calendar_print_event($event);
|
||||
@@ -541,7 +527,7 @@ function calendar_show_upcoming_events($courses, $groups, $users, $futuredays, $
|
||||
|
||||
|
||||
function calendar_print_event($event) {
|
||||
global $CFG, $THEME, $USER;
|
||||
global $CFG, $THEME;
|
||||
|
||||
static $strftimetime;
|
||||
|
||||
@@ -576,11 +562,11 @@ function calendar_print_event($event) {
|
||||
if (calendar_edit_event_allowed($event)) {
|
||||
echo '<div align="right">';
|
||||
if (empty($event->cmid)) {
|
||||
$editlink = CALENDAR_URL.'event.php?action=edit&id='.$event->id;
|
||||
$editlink = CALENDAR_URL.'event.php?action=edit&id='.$event->id;
|
||||
$deletelink = CALENDAR_URL.'event.php?action=delete&id='.$event->id;
|
||||
} else {
|
||||
$editlink = $CFG->wwwroot.'/course/mod.php?update='.$event->cmid.'&return=true&sesskey='.$USER->sesskey;
|
||||
$deletelink = $CFG->wwwroot.'/course/mod.php?delete='.$event->cmid.'&sesskey='.$USER->sesskey;;
|
||||
$editlink = "$CFG->wwwroot/mod/$event->modulename/view.php?id=$event->cmid";
|
||||
$deletelink = "$CFG->wwwroot/course/mod.php?delete=$event->cmid";
|
||||
}
|
||||
echo ' <a href="'.$editlink.'"><img
|
||||
src="'.$CFG->pixpath.'/t/edit.gif" alt="'.get_string('tt_editevent', 'calendar').'"
|
||||
@@ -598,12 +584,13 @@ function calendar_print_event($event) {
|
||||
function calendar_course_filter_selector($getvars = '') {
|
||||
global $USER, $SESSION;
|
||||
|
||||
if (empty($USER->id) or isguest()) {
|
||||
if (isguest($USER->id)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (isadmin()) {
|
||||
$courses = get_courses('all', 'c.shortname','c.id,c.shortname');
|
||||
if (isadmin($USER->id)) {
|
||||
$courses = get_courses('all', 'c.shortname');
|
||||
|
||||
} else {
|
||||
$courses = get_my_courses($USER->id, 'shortname');
|
||||
}
|
||||
|
||||
+21
-49
@@ -45,26 +45,26 @@ unset($CFG); // Ignore this line
|
||||
// A special case exists when using PostgreSQL databases via sockets. //
|
||||
// Define dbhost as follows, leaving dbname, dbuser, dbpass BLANK!: //
|
||||
// $CFG->dbhost = " user='muser' password='mpass' dbname='mdata'"; //
|
||||
//
|
||||
//
|
||||
|
||||
$CFG->dbtype = 'mysql'; // mysql or postgres7 (for now)
|
||||
$CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
|
||||
$CFG->dbhost = 'localhost'; // eg localhost or db.isp.com
|
||||
$CFG->dbname = 'moodle'; // database name, eg moodle
|
||||
$CFG->dbuser = 'username'; // your database username
|
||||
$CFG->dbpass = 'password'; // your database password
|
||||
$CFG->prefix = 'mdl_'; // Prefix to use for all table names
|
||||
|
||||
$CFG->dbpersist = false; // Should database connections be reused?
|
||||
// "false" is the most stable setting
|
||||
// "true" can improve performance sometimes
|
||||
// "false" is the most stable setting
|
||||
// "true" can improve performance sometimes
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// 2. WEB SITE LOCATION
|
||||
//=========================================================================
|
||||
// Now you need to tell Moodle where it is located. Specify the full
|
||||
// web address to where moodle has been installed. If your web site
|
||||
// is accessible via multiple URLs then choose the most natural one
|
||||
// web address to where moodle has been installed. If your web site
|
||||
// is accessible via multiple URLs then choose the most natural one
|
||||
// that your students would use. Do not include a trailing slash
|
||||
|
||||
$CFG->wwwroot = 'http://example.com/moodle';
|
||||
@@ -87,8 +87,8 @@ $CFG->dirroot = '/home/example/public_html/moodle';
|
||||
// 4. DATA FILES LOCATION
|
||||
//=========================================================================
|
||||
// Now you need a place where Moodle can save uploaded files. This
|
||||
// directory should be readable AND WRITEABLE by the web server user
|
||||
// (usually 'nobody' or 'apache'), but it should not be accessible
|
||||
// directory should be readable AND WRITEABLE by the web server user
|
||||
// (usually 'nobody' or 'apache'), but it should not be accessible
|
||||
// directly via the web.
|
||||
//
|
||||
// - On hosting systems you might need to make sure that your "group" has
|
||||
@@ -103,9 +103,9 @@ $CFG->dataroot = '/home/example/moodledata';
|
||||
// 5. DATA FILES PERMISSIONS
|
||||
//=========================================================================
|
||||
// The following parameter sets the permissions of new directories
|
||||
// created by Moodle within the data directory. The format is in
|
||||
// created by Moodle within the data directory. The format is in
|
||||
// octal format (as used by the Unix utility chmod, for example).
|
||||
// The default is usually OK, but you may want to change it to 0750
|
||||
// The default is usually OK, but you may want to change it to 0750
|
||||
// if you are concerned about world-access to the files (you will need
|
||||
// to make sure the web server process (eg Apache) can access the files.
|
||||
// NOTE: the prefixed 0 is important, and don't use quotes.
|
||||
@@ -116,10 +116,10 @@ $CFG->directorypermissions = 0777;
|
||||
//=========================================================================
|
||||
// 6. DIRECTORY LOCATION (most people can just ignore this setting)
|
||||
//=========================================================================
|
||||
// A very few webhosts use /admin as a special URL for you to access a
|
||||
// control panel or something. Unfortunately this conflicts with the
|
||||
// standard location for the Moodle admin pages. You can fix this by
|
||||
// renaming the admin directory in your installation, and putting that
|
||||
// A very few webhosts use /admin as a special URL for you to access a
|
||||
// control panel or something. Unfortunately this conflicts with the
|
||||
// standard location for the Moodle admin pages. You can fix this by
|
||||
// renaming the admin directory in your installation, and putting that
|
||||
// new name here. eg "moodleadmin". This will fix admin links in Moodle.
|
||||
|
||||
$CFG->admin = 'admin';
|
||||
@@ -133,7 +133,7 @@ $CFG->admin = 'admin';
|
||||
//
|
||||
//
|
||||
// Prevent users from updating their profile images
|
||||
// $CFG->disableuserimages = true;
|
||||
// $CFG->disableuserimages = true;
|
||||
//
|
||||
// Prevent scheduled backups from operating (and hide the GUI for them)
|
||||
// Useful for webhost operators who have alternate methods of backups
|
||||
@@ -144,8 +144,8 @@ $CFG->admin = 'admin';
|
||||
// $CFG->restrictusers = 'teacher,fred,jim';
|
||||
//
|
||||
// Turning this on will make Moodle filter more than usual, including
|
||||
// forum subjects, activity names and so on (in ADDITION to the normal
|
||||
// texts like forum postings, journals etc). This is mostly only useful
|
||||
// forum subjects, activity names and so on (in ADDITION to the normal
|
||||
// texts like forum postings, journals etc). This is mostly only useful
|
||||
// when using the multilang filter. This feature may not be complete.
|
||||
// $CFG->filterall = true;
|
||||
//
|
||||
@@ -157,40 +157,12 @@ $CFG->admin = 'admin';
|
||||
// The names here should all be existing blocks in the "blocks" directory.
|
||||
// $CFG->defaultblocks = "participants,activity_modules,search_forums,admin,course_list:news_items,calendar_upcoming,recent_activity";
|
||||
//
|
||||
// This setting will put Moodle in Unicode mode. It's very new and
|
||||
// This setting will put Moodle in Unicode mode. It's very new and
|
||||
// most likely doesn't work yet. THIS IS FOR DEVELOPERS ONLY, IT IS
|
||||
// NOT RECOMMENDED FOR PRODUCTION SITES
|
||||
// $CFG->unicode = true;
|
||||
//
|
||||
// To use spell-checking (experimental) define a path below to your
|
||||
// locally-installed copy of Aspell (0.50.1 or newer)
|
||||
// $CFG->aspellpath = '/usr/bin/aspell'; // *nix
|
||||
// $CFG->aspellpath = '"c:\path\to\aspell\aspell.exe"'; // Windows
|
||||
//
|
||||
// Seconds for files to remain in caches. Decrease this if you are worried
|
||||
// about students being served outdated versions of uploaded files.
|
||||
// $CFG->filelifetime = 86400;
|
||||
//
|
||||
// The following two settings allow you to specify allowed domains for
|
||||
// email addresses. If the first one is set, then Moodle will DISALLOW
|
||||
// all domains EXCEPT those listed. Otherwise, if the second one is set
|
||||
// then all addresses are ALLOWED EXCEPT those listed.
|
||||
// $CFG->allowemailaddresses = "myschool.edu.au hotmail.com";
|
||||
// $CFG->denyemailaddresses = "hotmail.com yahoo.com";
|
||||
//
|
||||
// The following setting will tell Moodle to respect your PHP session
|
||||
// settings. Use this if you want to control session configuration
|
||||
// from php.ini, httpd.conf or .htaccess files.
|
||||
// $CFG->respectsessionsettings = true;
|
||||
//
|
||||
// Generating the language menu consumes a *lot* of memory and queries a
|
||||
// lot of files. if you are looking for performance, and not adding/removing
|
||||
// languages often, enable the language menu cache. With the cache enabled,
|
||||
// Moodle only refreshes the list of languages every few invocations of the
|
||||
// cron script. For maximum efficiency, make sure your cron is called from the
|
||||
// commandline, not via HTTP.
|
||||
// $CFG->langcache = true;
|
||||
//
|
||||
|
||||
|
||||
|
||||
//=========================================================================
|
||||
// ALL DONE! To continue installation, visit your main page with a browser
|
||||
@@ -208,6 +180,6 @@ if (file_exists("$CFG->dirroot/lib/setup.php")) { // Do not edit
|
||||
}
|
||||
die;
|
||||
}
|
||||
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
|
||||
// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
|
||||
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
|
||||
?>
|
||||
|
||||
+63
-90
@@ -23,7 +23,7 @@
|
||||
}
|
||||
|
||||
if (iscreator()) {
|
||||
if (isset($_GET['edit']) and confirm_sesskey()) {
|
||||
if (isset($_GET['edit'])) {
|
||||
if ($edit == "on") {
|
||||
$USER->categoryediting = true;
|
||||
} else if ($edit == "off") {
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
if (isadmin()) {
|
||||
/// Rename the category if requested
|
||||
if (!empty($_POST['rename']) and confirm_sesskey()) {
|
||||
if (!empty($_POST['rename'])) {
|
||||
$category->name = $_POST['rename'];
|
||||
if (! set_field("course_categories", "name", $category->name, "id", $category->id)) {
|
||||
notify("An error occurred while renaming the category");
|
||||
@@ -56,20 +56,8 @@
|
||||
|
||||
/// Resort the category if requested
|
||||
|
||||
if (!empty($_GET['resort']) and confirm_sesskey()) {
|
||||
if ($courses = get_courses($category->id, "fullname ASC", 'c.id,c.fullname,c.sortorder')) {
|
||||
// move it off the range
|
||||
$count = get_record_sql('SELECT MAX(sortorder) AS max, 1
|
||||
FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id);
|
||||
$count = $count->max + 100;
|
||||
begin_sql();
|
||||
foreach ($courses as $course) {
|
||||
set_field('course', 'sortorder', $count, 'id', $course->id);
|
||||
$count++;
|
||||
}
|
||||
commit_sql();
|
||||
fix_course_sortorder($category->id);
|
||||
}
|
||||
if (!empty($_GET['resort'])) {
|
||||
fix_course_sortorder($category->id, "fullname ASC");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,16 +73,16 @@
|
||||
|
||||
if ($creatorediting) {
|
||||
if ($adminediting) {
|
||||
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
|
||||
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
|
||||
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> ".
|
||||
"<a href=\"index.php\">$strcategories</a> -> $category->name",
|
||||
"", "", true, $navbaritem);
|
||||
} else {
|
||||
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
|
||||
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
|
||||
"<a href=\"index.php\">$strcategories</a> -> $category->name", "", "", true, $navbaritem);
|
||||
}
|
||||
} else {
|
||||
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
|
||||
print_header("$site->shortname: $category->name", "$site->fullname: $strcourses",
|
||||
"<a href=\"index.php\">$strcategories</a> -> $category->name", "", "", true, $navbaritem);
|
||||
}
|
||||
|
||||
@@ -119,7 +107,7 @@
|
||||
|
||||
/// Move a specified course to a new category
|
||||
|
||||
if (isset($moveto) and $data = data_submitted() and confirm_sesskey()) { // Some courses are being moved
|
||||
if (isset($moveto) and $data = data_submitted()) { // Some courses are being moved
|
||||
|
||||
if (! $destcategory = get_record("course_categories", "id", $data->moveto)) {
|
||||
error("Error finding the category");
|
||||
@@ -127,32 +115,19 @@
|
||||
|
||||
unset($data->moveto);
|
||||
unset($data->id);
|
||||
unset($data->sesskey);
|
||||
|
||||
if ($data) {
|
||||
foreach ($data as $code => $junk) {
|
||||
|
||||
$courseid = substr($code, 1);
|
||||
|
||||
if (! $course = get_record("course", "id", $courseid)) {
|
||||
notify("Error finding course $courseid");
|
||||
} else {
|
||||
// figure out a sortorder that we can use in the destination category
|
||||
$sortorder = get_field_sql('SELECT MIN(sortorder)-1 AS min
|
||||
FROM ' . $CFG->prefix . 'course WHERE category=' . $destcategory->id);
|
||||
if ($sortorder < 1) {
|
||||
// rather than let the db default to 0
|
||||
// set it to > 100 and avoid extra work in fix_coursesortorder()
|
||||
$sortorder = 200;
|
||||
}
|
||||
|
||||
$course->category = $destcategory->id;
|
||||
$course->sortorder = $sortorder;
|
||||
|
||||
if (!update_record('course', $course)) {
|
||||
if (!set_field("course", "category", $destcategory->id, "id", $course->id)) {
|
||||
notify("An error occurred - course not moved!");
|
||||
}
|
||||
fix_course_sortorder();
|
||||
fix_course_sortorder($destcategory->id);
|
||||
fix_course_sortorder($category->id);
|
||||
$category = get_record("course_categories", "id", $category->id);
|
||||
}
|
||||
}
|
||||
@@ -162,7 +137,7 @@
|
||||
|
||||
/// Hide or show a course
|
||||
|
||||
if ((isset($hide) or isset($show)) and confirm_sesskey()) {
|
||||
if (isset($hide) or isset($show)) {
|
||||
if (isset($hide)) {
|
||||
$course = get_record("course", "id", $hide);
|
||||
$visible = 0;
|
||||
@@ -180,45 +155,55 @@
|
||||
|
||||
/// Move a course up or down
|
||||
|
||||
if ((isset($moveup) or isset($movedown)) and confirm_sesskey()) {
|
||||
if (isset($moveup) or isset($movedown)) {
|
||||
|
||||
$movecourse = NULL;
|
||||
$swapcourse = NULL;
|
||||
|
||||
// ensure the course order has no gaps
|
||||
// and isn't at 0
|
||||
fix_course_sortorder($category->id);
|
||||
|
||||
// we are going to need to know the range
|
||||
$max = get_record_sql('SELECT MAX(sortorder) AS max, 1
|
||||
FROM ' . $CFG->prefix . 'course WHERE category=' . $category->id);
|
||||
$max = $max->max + 100;
|
||||
|
||||
if (isset($moveup)) {
|
||||
$movecourse = get_record('course', 'id', $moveup);
|
||||
$swapcourse = get_record('course',
|
||||
'category', $category->id,
|
||||
'sortorder', $movecourse->sortorder - 1);
|
||||
} else {
|
||||
$movecourse = get_record('course', 'id', $movedown);
|
||||
$swapcourse = get_record('course',
|
||||
'category', $category->id,
|
||||
'sortorder', $movecourse->sortorder + 1);
|
||||
}
|
||||
|
||||
if ($swapcourse and $movecourse) { // Renumber everything for robustness
|
||||
begin_sql();
|
||||
if (!( set_field("course", "sortorder", $max, "id", $swapcourse->id)
|
||||
&& set_field("course", "sortorder", $swapcourse->sortorder, "id", $movecourse->id)
|
||||
&& set_field("course", "sortorder", $movecourse->sortorder, "id", $swapcourse->id)
|
||||
)) {
|
||||
notify("Could not update that course!");
|
||||
}
|
||||
commit_sql();
|
||||
}
|
||||
$courses = get_courses($category->id);
|
||||
|
||||
if (isset($moveup)) {
|
||||
if ($movecourse = get_record("course", "id", $moveup)) {
|
||||
foreach ($courses as $course) {
|
||||
if ($course->id == $movecourse->id) {
|
||||
break;
|
||||
}
|
||||
$swapcourse = $course;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($movedown)) {
|
||||
if ($movecourse = get_record("course", "id", $movedown)) {
|
||||
$choosenext = false;
|
||||
foreach ($courses as $course) {
|
||||
if ($choosenext) {
|
||||
$swapcourse = $course;
|
||||
break;
|
||||
}
|
||||
if ($course->id == $movecourse->id) {
|
||||
$choosenext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($swapcourse and $movecourse) { // Renumber everything for robustness
|
||||
$count=0;
|
||||
foreach ($courses as $course) {
|
||||
$count++;
|
||||
if ($course->id == $swapcourse->id) {
|
||||
$course = $movecourse;
|
||||
} else if ($course->id == $movecourse->id) {
|
||||
$course = $swapcourse;
|
||||
}
|
||||
if (! set_field("course", "sortorder", $count, "id", $course->id)) {
|
||||
notify("Could not update that course!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fix_course_sortorder($category->id);
|
||||
|
||||
} // End of editing stuff
|
||||
|
||||
/// Print out all the sub-categories
|
||||
@@ -245,11 +230,7 @@
|
||||
|
||||
|
||||
/// Print out all the courses
|
||||
unset($course); // To avoid unwanted language effects later
|
||||
|
||||
$courses = get_courses_page($category->id, 'c.sortorder ASC',
|
||||
'c.id,c.sortorder,c.shortname,c.fullname,c.summary,c.visible,c.teacher,c.guest,c.password',
|
||||
$totalcount, $page*$perpage, $perpage);
|
||||
$courses = get_courses_page($category->id, "c.sortorder ASC", "c.*", $totalcount, $page*$perpage, $perpage);
|
||||
$numcourses = count($courses);
|
||||
|
||||
if (!$courses) {
|
||||
@@ -273,8 +254,7 @@
|
||||
$strhide = get_string("hide");
|
||||
$strshow = get_string("show");
|
||||
$strsummary = get_string("summary");
|
||||
$strsettings = get_string("settings");
|
||||
$strassignteachers = get_string("assignteachers");
|
||||
$strassignteachers = get_string("assignteachers");
|
||||
$strallowguests = get_string("allowguests");
|
||||
$strrequireskey = get_string("requireskey");
|
||||
|
||||
@@ -285,7 +265,6 @@
|
||||
}
|
||||
|
||||
echo "<form name=\"movecourses\" action=\"category.php\" method=\"post\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
|
||||
echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=4 class=\"generalbox\"><tr>";
|
||||
echo "<th>$strcourses</th>";
|
||||
if ($creatorediting) {
|
||||
@@ -313,17 +292,15 @@
|
||||
if ($creatorediting) {
|
||||
if ($adminediting) {
|
||||
echo "<td>";
|
||||
echo "<a title=\"$strsettings\" href=\"$CFG->wwwroot/course/edit.php?id=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a> ";
|
||||
echo "<a title=\"$strassignteachers\" href=\"$CFG->wwwroot/course/teacher.php?id=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/user.gif\" height=11 width=11 border=0></a> ";
|
||||
echo "<a title=\"$strdelete\" href=\"delete.php?id=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/delete.gif\" height=11 width=11 border=0></a> ";
|
||||
if (!empty($acourse->visible)) {
|
||||
echo "<a title=\"$strhide\" href=\"category.php?id=$category->id&page=$page&hide=$acourse->id&sesskey=$USER->sesskey\"><img".
|
||||
echo "<a title=\"$strhide\" href=\"category.php?id=$category->id&hide=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/hide.gif\" height=11 width=11 border=0></a> ";
|
||||
} else {
|
||||
echo "<a title=\"$strshow\" href=\"category.php?id=$category->id&page=$page&show=$acourse->id&sesskey=$USER->sesskey\"><img".
|
||||
echo "<a title=\"$strshow\" href=\"category.php?id=$category->id&show=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/show.gif\" height=11 width=11 border=0></a> ";
|
||||
}
|
||||
|
||||
@@ -334,14 +311,14 @@
|
||||
" src=\"$pixpath/t/restore.gif\" height=11 width=11 border=0></a> ";
|
||||
|
||||
if ($up) {
|
||||
echo "<a title=\"$strmoveup\" href=\"category.php?id=$category->id&page=$page&moveup=$acourse->id&sesskey=$USER->sesskey\"><img".
|
||||
echo "<a title=\"$strmoveup\" href=\"category.php?id=$category->id&moveup=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/up.gif\" height=11 width=11 border=0></a> ";
|
||||
} else {
|
||||
echo "<img src=\"$CFG->wwwroot/pix/spacer.gif\" height=11 width=11 border=0></a> ";
|
||||
}
|
||||
|
||||
if ($down) {
|
||||
echo "<a title=\"$strmovedown\" href=\"category.php?id=$category->id&page=$page&movedown=$acourse->id&sesskey=$USER->sesskey\"><img".
|
||||
echo "<a title=\"$strmovedown\" href=\"category.php?id=$category->id&movedown=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/down.gif\" height=11 width=11 border=0></a> ";
|
||||
} else {
|
||||
echo "<img src=\"$CFG->wwwroot/pix/spacer.gif\" height=11 width=11 border=0></a> ";
|
||||
@@ -354,21 +331,19 @@
|
||||
|
||||
} else if (isteacheredit($acourse->id)) {
|
||||
echo "<td>";
|
||||
echo "<a title=\"$strsettings\" href=\"$CFG->wwwroot/course/edit.php?id=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/edit.gif\" height=11 width=11 border=0></a> ";
|
||||
echo "<a title=\"$strassignteachers\" href=\"$CFG->wwwroot/course/teacher.php?id=$acourse->id\"><img".
|
||||
" src=\"$pixpath/t/user.gif\" height=11 width=11 border=0></a> ";
|
||||
}
|
||||
echo "</td>";
|
||||
} else {
|
||||
echo "<td align=\"right\">";
|
||||
if (!empty($acourse->guest)) {
|
||||
if ($acourse->guest ) {
|
||||
echo "<a href=\"view.php?id=$acourse->id\"><img hspace=2 title=\"$strallowguests\" alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/user.gif\"></a>";
|
||||
}
|
||||
if (!empty($acourse->password)) {
|
||||
if ($acourse->password) {
|
||||
echo "<a href=\"view.php?id=$acourse->id\"><img hspace=2 title=\"$strrequireskey\" alt=\"\" height=16 width=16 border=0 src=\"$pixpath/i/key.gif\"></a>";
|
||||
}
|
||||
if (!empty($acourse->summary)) {
|
||||
if ($acourse->summary) {
|
||||
link_to_popup_window ("/course/info.php?id=$acourse->id", "courseinfo",
|
||||
"<img hspace=2 alt=\"info\" height=16 width=16 border=0 src=\"$pixpath/i/info.gif\">",
|
||||
400, 500, $strsummary);
|
||||
@@ -398,7 +373,6 @@
|
||||
unset($options);
|
||||
$options["id"] = $category->id;
|
||||
$options["resort"] = "name";
|
||||
$options["sesskey"] = $USER->sesskey;
|
||||
print_single_button("category.php", $options, get_string("resortcoursesbyname"), "get");
|
||||
}
|
||||
|
||||
@@ -413,7 +387,6 @@
|
||||
$strrename= get_string("rename");
|
||||
echo "<form name=\"renameform\" action=\"category.php\" method=\"post\">";
|
||||
echo "<input type=\"hidden\" name=\"id\" value=\"$category->id\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
|
||||
echo "<input type=\"text\" size=30 name=\"rename\" value=\"".s($category->name)."\">";
|
||||
echo "<input type=\"submit\" value=\"$strrename\">";
|
||||
echo "</form>";
|
||||
|
||||
+1
-5
@@ -38,7 +38,7 @@
|
||||
"$strdeletecheck");
|
||||
|
||||
notice_yesno("$strdeletecoursecheck<BR><BR>$course->fullname ($course->shortname)",
|
||||
"delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=$USER->sesskey",
|
||||
"delete.php?id=$course->id&delete=".md5($course->timemodified),
|
||||
"category.php?id=$course->category");
|
||||
exit;
|
||||
}
|
||||
@@ -47,10 +47,6 @@
|
||||
error("The check variable was wrong - try again");
|
||||
}
|
||||
|
||||
if (!confirm_sesskey()) {
|
||||
error(get_string('confirmsesskeybad', 'error'));
|
||||
}
|
||||
|
||||
// OK checks done, delete the course now.
|
||||
$strdeletingcourse = get_string("deletingcourse", "", $course->shortname);
|
||||
|
||||
|
||||
@@ -12,9 +12,6 @@
|
||||
if (!isset($form->lang)) {
|
||||
$form->lang = '';
|
||||
}
|
||||
if (!isset($form->enrolperiod)) {
|
||||
$form->enrolperiod = 0;
|
||||
}
|
||||
?>
|
||||
<FORM METHOD="post" action="edit.php" NAME="form">
|
||||
<table cellpadding=9 cellspacing=0 >
|
||||
@@ -43,13 +40,6 @@
|
||||
<?php if (isset($err["shortname"])) formerr($err["shortname"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("idnumber") ?>:</td>
|
||||
<td><input type="text" name="idnumber" maxlength="100" size="10" value="<?php p($form->idnumber) ?>">
|
||||
<?php helpbutton("courseidnumber", get_string("idnumber")) ?>
|
||||
<?php if (isset($err["idnumber"])) formerr($err["idnumber"]); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("summary") ?>:</td>
|
||||
<td><?php
|
||||
@@ -74,20 +64,6 @@
|
||||
helpbutton("coursestartdate", get_string("startdate"));
|
||||
?></td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("enrolperiod") ?>:</td>
|
||||
<td>
|
||||
<?php
|
||||
$periodmenu[0] = get_string('unlimited');
|
||||
for ($i=1; $i<=365; $i++) {
|
||||
$seconds = $i * 86400;
|
||||
$periodmenu[$seconds] = get_string('numdays', '', $i);
|
||||
}
|
||||
choose_from_menu ($periodmenu, "enrolperiod", "$form->enrolperiod", "");
|
||||
helpbutton("enrolperiod", get_string("enrolperiod"));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("numberweeks") ?>:</td>
|
||||
<td><?php
|
||||
@@ -146,17 +122,6 @@
|
||||
helpbutton("guestaccess", get_string("opentoguests")); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
if ($CFG->enrol != 'internal') {
|
||||
?>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("cost") ?>:</td>
|
||||
<td><input type="text" name="cost" maxlength="6" size=6 value="<?php p($form->cost) ?>">
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<tr valign=top>
|
||||
<td align="right"><P><?php print_string("hiddensections") ?>:</td>
|
||||
<td><?php
|
||||
@@ -260,5 +225,4 @@
|
||||
<td><input type="submit" value="<?php print_string("savechanges") ?>"></td>
|
||||
</table>
|
||||
<input type="hidden" name="id" value="<?php echo $form->id ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php echo $form->sesskey ?>">
|
||||
</form>
|
||||
|
||||
+14
-38
@@ -1,12 +1,12 @@
|
||||
<?PHP // $Id$
|
||||
// Edit course settings
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->libdir/blocklib.php");
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->libdir/blocklib.php");
|
||||
|
||||
$id = (int)optional_param('id', 0); // course id
|
||||
$category = (int)optional_param('category', 0); // possible default category
|
||||
optional_variable($id, 0); // course id
|
||||
optional_variable($category, 0); // category id
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -36,18 +36,12 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if (empty($course)) {
|
||||
check_for_restricted_user($USER->username, "$CFG->wwwroot");
|
||||
} else {
|
||||
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
|
||||
}
|
||||
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
|
||||
|
||||
$form->startdate = make_timestamp($form->startyear, $form->startmonth, $form->startday);
|
||||
|
||||
$form->format = optional_param('format', 'social', PARAM_ALPHA);
|
||||
|
||||
validate_form($course, $form, $err);
|
||||
|
||||
if (count($err) == 0) {
|
||||
@@ -55,15 +49,10 @@
|
||||
$form->timemodified = time();
|
||||
|
||||
if (!empty($course)) {
|
||||
// Test for and remove blocks which aren't appropriate anymore
|
||||
$form->blockinfo = $course->blockinfo;
|
||||
block_remove_inappropriate_from_course($form);
|
||||
|
||||
// Update with the new data
|
||||
if (update_record("course", $form)) {
|
||||
add_to_log($course->id, "course", "update", "edit.php?id=$id", "");
|
||||
fix_course_sortorder();
|
||||
redirect("view.php?id=$course->id", get_string("changessaved"));
|
||||
fix_course_sortorder($form->category);
|
||||
redirect("view.php?id=$course->id", get_string("changessaved"));
|
||||
} else {
|
||||
error("Serious Error! Could not update the course record! (id = $form->id)");
|
||||
}
|
||||
@@ -77,13 +66,6 @@
|
||||
//For topics and weeks formats (default built in the function)
|
||||
$form->blockinfo = blocks_get_default_blocks();
|
||||
}
|
||||
|
||||
// place at beginning of category
|
||||
fix_course_sortorder();
|
||||
$form->sortorder = get_field_sql("SELECT min(sortorder)-1 FROM {$CFG->prefix}course WHERE category=$form->category");
|
||||
if (empty($form->sortorder)) {
|
||||
$form->sortorder = 100;
|
||||
}
|
||||
|
||||
if ($newcourseid = insert_record("course", $form)) { // Set up new course
|
||||
$section = NULL;
|
||||
@@ -91,7 +73,7 @@
|
||||
$section->section = 0;
|
||||
$section->id = insert_record("course_sections", $section);
|
||||
|
||||
fix_course_sortorder();
|
||||
fix_course_sortorder($form->category);
|
||||
add_to_log($newcourseid, "course", "new", "view.php?id=$newcourseid", "");
|
||||
|
||||
if (isadmin()) { // Redirect admin to add teachers
|
||||
@@ -112,8 +94,6 @@
|
||||
$USER->teacher[$newcourseid] = true;
|
||||
$USER->teacheredit[$newcourseid] = true;
|
||||
|
||||
fix_course_sortorder();
|
||||
|
||||
redirect("view.php?id=$newcourseid", get_string("changessaved"));
|
||||
}
|
||||
|
||||
@@ -121,14 +101,14 @@
|
||||
error("Serious Error! Could not create the new course!");
|
||||
}
|
||||
}
|
||||
die;
|
||||
die;
|
||||
} else {
|
||||
foreach ($err as $key => $value) {
|
||||
$focus = "form.$key";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Otherwise fill and print the form.
|
||||
|
||||
@@ -144,8 +124,6 @@
|
||||
$form->password = "";
|
||||
$form->guest = 0;
|
||||
$form->numsections = 10;
|
||||
$form->idnumber = '';
|
||||
$form->cost = '';
|
||||
$form->newsitems = 5;
|
||||
$form->showgrades = 1;
|
||||
$form->groupmode = 0;
|
||||
@@ -189,7 +167,7 @@
|
||||
$strcategories = get_string("categories");
|
||||
|
||||
if (!empty($course)) {
|
||||
print_header($streditcoursesettings, "$course->fullname",
|
||||
print_header($streditcoursesettings, "$course->fullname",
|
||||
"<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a>
|
||||
-> $streditcoursesettings", $focus);
|
||||
} else {
|
||||
@@ -198,11 +176,9 @@
|
||||
"<a href=\"index.php\">$strcategories</a> -> $straddnewcourse", $focus);
|
||||
}
|
||||
|
||||
$form->sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
print_heading($streditcoursesettings);
|
||||
print_simple_box_start("center", "", "$THEME->cellheading");
|
||||
include("edit.html");
|
||||
include("edit.html");
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer($course);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
</tr>
|
||||
</table>
|
||||
<input type="hidden" name=id value="<?php echo $form->id ?>">
|
||||
<input type="hidden" name=sesskey value="<?php echo $form->sesskey ?>">
|
||||
<input type="submit" value="<?php print_string("savechanges") ?>">
|
||||
</form>
|
||||
</center>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
$timenow = time();
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
$form = $section;
|
||||
}
|
||||
|
||||
$form->sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
$usehtmleditor = can_use_html_editor();
|
||||
|
||||
$sectionname = get_string("name$course->format");
|
||||
|
||||
+96
-31
@@ -1,16 +1,16 @@
|
||||
<?PHP // $Id$
|
||||
// Depending on the current enrolment method, this page
|
||||
// presents the user with whatever they need to know when
|
||||
// they try to enrol in a course.
|
||||
// Asks for a course pass key, once only, and enrols that user
|
||||
|
||||
require_once("../config.php");
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->dirroot/enrol/$CFG->enrol/enrol.php");
|
||||
|
||||
require_variable($id);
|
||||
|
||||
require_login();
|
||||
|
||||
$strloginto = get_string("loginto", "", $course->shortname);
|
||||
$strcourses = get_string("courses");
|
||||
|
||||
if (! $course = get_record("course", "id", $id) ) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
@@ -21,17 +21,57 @@
|
||||
|
||||
check_for_restricted_user($USER->username);
|
||||
|
||||
$enrol = new enrolment_plugin();
|
||||
/// Check the submitted enrollment key if there is one
|
||||
|
||||
/// Refreshing enrolment data in the USER session
|
||||
$enrol->get_student_courses($USER);
|
||||
$enrol->get_teacher_courses($USER);
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if ($form->password == $course->password) {
|
||||
|
||||
if (isguest()) {
|
||||
add_to_log($course->id, "course", "guest", "view.php?id=$course->id", $_SERVER['REMOTE_ADDR']);
|
||||
|
||||
} else if (!record_exists("user_students", "userid", $USER->id, "course", $course->id)) {
|
||||
|
||||
if (! enrol_student($USER->id, $course->id)) {
|
||||
error("An error occurred while trying to enrol you.");
|
||||
}
|
||||
|
||||
$subject = get_string("welcometocourse", "", $course->fullname);
|
||||
|
||||
$a->coursename = $course->fullname;
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id";
|
||||
$message = get_string("welcometocoursetext", "", $a);
|
||||
|
||||
if (! $teacher = get_teacher($course->id)) {
|
||||
$teacher = get_admin();
|
||||
}
|
||||
email_to_user($USER, $teacher, $subject, $message);
|
||||
|
||||
add_to_log($course->id, "course", "enrol", "view.php?id=$course->id", "$USER->id");
|
||||
}
|
||||
|
||||
$USER->student[$course->id] = true;
|
||||
|
||||
if ($SESSION->wantsurl) {
|
||||
$destination = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
} else {
|
||||
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
}
|
||||
|
||||
redirect($destination);
|
||||
|
||||
} else {
|
||||
$errormsg = get_string("enrolmentkeyhint", "", substr($course->password,0,1));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Double check just in case they are actually enrolled already
|
||||
/// This might occur if they were enrolled during this session
|
||||
|
||||
if ( !empty($USER->student[$course->id]) or !empty($USER->teacher[$course->id]) ) {
|
||||
/// This might occur if they were manually enrolled during this session
|
||||
|
||||
if (record_exists("user_students", "userid", $USER->id, "course", $course->id)) {
|
||||
$USER->student[$course->id] = true;
|
||||
|
||||
if ($SESSION->wantsurl) {
|
||||
$destination = $SESSION->wantsurl;
|
||||
@@ -39,34 +79,59 @@
|
||||
} else {
|
||||
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
}
|
||||
|
||||
|
||||
redirect($destination);
|
||||
}
|
||||
|
||||
|
||||
/// Automatically enrol into courses without password
|
||||
|
||||
if ($course->password == "") { // no password, so enrol
|
||||
|
||||
if (isguest()) {
|
||||
add_to_log($course->id, "course", "guest", "view.php?id=$course->id", "$USER->id");
|
||||
|
||||
} else if (empty($confirm)) {
|
||||
|
||||
print_header($strloginto, $course->fullname, "<a href=\".\">$strcourses</a> -> $strloginto");
|
||||
echo "<br />";
|
||||
notice_yesno(get_string("enrolmentconfirmation"), "enrol.php?id=$course->id&confirm=1", $CFG->wwwroot);
|
||||
print_footer();
|
||||
exit;
|
||||
|
||||
} else {
|
||||
|
||||
if (! enrol_student($USER->id, $course->id)) {
|
||||
error("An error occurred while trying to enrol you.");
|
||||
}
|
||||
add_to_log($course->id, "course", "enrol", "view.php?id=$course->id", "$USER->id");
|
||||
|
||||
$USER->student[$course->id] = true;
|
||||
|
||||
if ($SESSION->wantsurl) {
|
||||
$destination = $SESSION->wantsurl;
|
||||
unset($SESSION->wantsurl);
|
||||
} else {
|
||||
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
|
||||
}
|
||||
|
||||
/// Users can't enroll to site course
|
||||
if (!$course->category) {
|
||||
print_header_simple();
|
||||
notice(get_string('enrollfirst'), $CFG->wwwroot);
|
||||
}
|
||||
|
||||
/// Double check just in case they are enrolled to start in the future
|
||||
|
||||
if ($student = get_record('user_students', 'userid', $USER->id, 'course', $course->id)) {
|
||||
if ($course->enrolperiod and $student->timestart and ($student->timestart >= time())) {
|
||||
$message = get_string('enrolmentnotyet', '', userdate($student->timestart));
|
||||
print_header();
|
||||
notice($message, $CFG->wwwroot);
|
||||
redirect($destination);
|
||||
}
|
||||
}
|
||||
|
||||
/// Check the submitted enrollment key if there is one
|
||||
|
||||
if ($form = data_submitted()) {
|
||||
$enrol->check_entry($form, $course);
|
||||
$teacher = get_teacher($course->id);
|
||||
if (!isset($password)) {
|
||||
$password = "";
|
||||
}
|
||||
|
||||
$enrol->print_entry($course);
|
||||
|
||||
/// Easy!
|
||||
print_header($strloginto, $course->fullname, "<A HREF=\".\">$strcourses</A> -> $strloginto", "form.password");
|
||||
|
||||
print_course($course);
|
||||
|
||||
include("enrol.html");
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
?>
|
||||
|
||||
@@ -33,16 +33,16 @@
|
||||
|
||||
echo "<td width=\"*\" valign=\"top\">";
|
||||
if ($social = forum_get_course_forum($course->id, "social")) {
|
||||
if (forum_is_forcesubscribed($social->id)) {
|
||||
$subtext = get_string('everyoneissubscribed', 'forum');
|
||||
} else if (forum_is_subscribed($USER->id, $social->id)) {
|
||||
$subtext = '<a href="../mod/forum/subscribe.php?id='.$social->id.'">'.get_string('unsubscribe', 'forum').'</a>';
|
||||
if (forum_is_subscribed($USER->id, $social->id)) {
|
||||
$subtext = get_string("unsubscribe", "forum");
|
||||
} else {
|
||||
$subtext = '<a href="../mod/forum/subscribe.php?id='.$social->id.'">'.get_string('subscribe', 'forum').'</a>';
|
||||
$subtext = get_string("subscribe", "forum");
|
||||
}
|
||||
$headertext = "<table border=0 width=100% cellpadding=0 cellspacing=0 class=headingblockcontent><tr><td>".
|
||||
get_string("socialheadline").
|
||||
"</td><td align=right><font size='1'>$subtext</font></td></tr></table>";
|
||||
"</td><td align=right><font size=1>".
|
||||
"<a href=\"../mod/forum/subscribe.php?id=$social->id\">$subtext</a></td>".
|
||||
"</tr></table>";
|
||||
print_heading_block($headertext);
|
||||
echo "<img alt=\"\" height=7 src=\"../pix/spacer.gif\"><br>";
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
print_course_blocks($course, $rightblocks, BLOCK_RIGHT);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($course, $missingblocks);
|
||||
block_print_blocks_admin($course->id, $missingblocks);
|
||||
}
|
||||
print_spacer(1, 120, true);
|
||||
echo '</td>';
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (isteacher($course->id) and isset($marker) and confirm_sesskey()) {
|
||||
if (isteacher($course->id) and isset($marker)) {
|
||||
$course->marker = $marker;
|
||||
if (! set_field("course", "marker", $marker, "id", $course->id)) {
|
||||
error("Could not mark that topic for this course");
|
||||
@@ -84,7 +84,7 @@
|
||||
echo "<tr>";
|
||||
echo "<td colspan=3 valign=top bgcolor=\"$THEME->cellcontent\" class=\"topicoutlineclip\" width=\"100%\">";
|
||||
echo "<p><font size=2>";
|
||||
echo "$stractivityclipboard (<a href=\"mod.php?cancelcopy=true&sesskey=$USER->sesskey\">$strcancel</a>)";
|
||||
echo "$stractivityclipboard (<a href=\"mod.php?cancelcopy=true\">$strcancel</a>)";
|
||||
echo "</font></p>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
@@ -98,12 +98,11 @@
|
||||
$thissection = $sections[$section];
|
||||
|
||||
if ($thissection->summary or $thissection->sequence or isediting($course->id)) {
|
||||
echo '<tr id="section_0">';
|
||||
echo "<tr>";
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"topicsoutlineside\" valign=top width=20> </td>";
|
||||
echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"topicsoutlinecontent\" width=\"100%\">";
|
||||
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
echo format_text($thissection->summary, FORMAT_HTML);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo "<a title=\"$streditsummary\" ".
|
||||
@@ -116,7 +115,10 @@
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
@@ -188,14 +190,13 @@
|
||||
echo "</td>";
|
||||
|
||||
if (!isteacher($course->id) and !$thissection->visible) { // Hidden for students
|
||||
echo '<td id="section_'.($section).'" style="vertical-align:top; text-align: center; width: 100%;" '.$colormain.'>';
|
||||
echo "<td valign=top align=center $colormain width=\"100%\">";
|
||||
echo get_string("notavailable");
|
||||
echo "</td>";
|
||||
} else {
|
||||
echo '<td id="section_'.($section).'" style="vertical-align:top; width: 100%;" '.$colormain.'>';
|
||||
echo "<td valign=top $colormain width=\"100%\">";
|
||||
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
echo format_text($thissection->summary, FORMAT_HTML);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo " <a title=\"$streditsummary\" href=editsection.php?id=$thissection->id>".
|
||||
@@ -207,7 +208,10 @@
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...");
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
@@ -226,28 +230,28 @@
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if ($course->marker == $section) { // Show the "light globe" on/off
|
||||
echo "<a href=\"view.php?id=$course->id&marker=0&sesskey=$USER->sesskey\" title=\"$strmarkedthistopic\">".
|
||||
echo "<a href=\"view.php?id=$course->id&marker=0\" title=\"$strmarkedthistopic\">".
|
||||
"<img src=\"$CFG->pixpath/i/marked.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
} else {
|
||||
echo "<a href=\"view.php?id=$course->id&marker=$section&sesskey=$USER->sesskey\" title=\"$strmarkthistopic\">".
|
||||
echo "<a href=\"view.php?id=$course->id&marker=$section\" title=\"$strmarkthistopic\">".
|
||||
"<img src=\"$CFG->pixpath/i/marker.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo "<a href=\"view.php?id=$course->id&hide=$section&sesskey=$USER->sesskey\" title=\"$strtopichide\">".
|
||||
echo "<a href=\"view.php?id=$course->id&hide=$section\" title=\"$strtopichide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
} else {
|
||||
echo "<a href=\"view.php?id=$course->id&show=$section&sesskey=$USER->sesskey\" title=\"$strtopicshow\">".
|
||||
echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strtopicshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=-1&sesskey=$USER->sesskey\" title=\"$strmoveup\">".
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=-1\" title=\"$strmoveup\">".
|
||||
"<img src=\"$CFG->pixpath/t/up.gif\" vspace=3 height=11 width=11 border=0></a><br />";
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=1&sesskey=$USER->sesskey\" title=\"$strmovedown\">".
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=1\" title=\"$strmovedown\">".
|
||||
"<img src=\"$CFG->pixpath/t/down.gif\" vspace=3 height=11 width=11 border=0></a><br />";
|
||||
}
|
||||
|
||||
@@ -277,7 +281,7 @@
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
print_course_blocks($course, $rightblocks, BLOCK_RIGHT);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($course, $missingblocks);
|
||||
block_print_blocks_admin($course->id, $missingblocks);
|
||||
}
|
||||
print_spacer(1, 120, true);
|
||||
echo '</td>';
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
}
|
||||
|
||||
/// Start main column
|
||||
echo "<td width=\"*\">";
|
||||
echo "</td><td width=\"*\">";
|
||||
print_heading_block(get_string("weeklyoutline"), "100%", "outlineheadingblock");
|
||||
print_spacer(8, 1, true);
|
||||
|
||||
@@ -74,7 +74,7 @@
|
||||
echo "<tr>";
|
||||
echo "<td colspan=3 valign=top bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlineclip\" width=\"100%\">";
|
||||
echo "<p><font size=2>";
|
||||
echo "$stractivityclipboard (<a href=\"mod.php?cancelcopy=true&sesskey=$USER->sesskey\">$strcancel</a>)";
|
||||
echo "$stractivityclipboard (<a href=\"mod.php?cancelcopy=true\">$strcancel</a>)";
|
||||
echo "</font></p>";
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
@@ -91,8 +91,7 @@
|
||||
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top width=20> </td>";
|
||||
echo "<td valign=top bgcolor=\"$THEME->cellcontent\" class=\"weeklyoutlinecontent\" width=\"100%\">";
|
||||
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
echo format_text($thissection->summary, FORMAT_HTML);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo " <a title=\"$streditsummary\" ".
|
||||
@@ -105,7 +104,10 @@
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...", "mods", $stractivities);
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
@@ -187,8 +189,7 @@
|
||||
|
||||
echo "<p class=\"weeklydatetext\">$weekday - $endweekday</p>";
|
||||
|
||||
$summaryformatoptions->noclean = true;
|
||||
echo format_text($thissection->summary, FORMAT_HTML, $summaryformatoptions);
|
||||
echo format_text($thissection->summary, FORMAT_HTML);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
echo " <a title=\"$streditsummary\" href=\"editsection.php?id=$thissection->id\">".
|
||||
@@ -200,7 +201,10 @@
|
||||
print_section($course, $thissection, $mods, $modnamesused);
|
||||
|
||||
if (isediting($course->id)) {
|
||||
print_section_add_menus($course, $section, $modnames);
|
||||
echo "<div align=right>";
|
||||
popup_form("$CFG->wwwroot/course/mod.php?id=$course->id&section=$section&add=",
|
||||
$modnames, "section$section", "", "$stradd...");
|
||||
echo "</div>";
|
||||
}
|
||||
|
||||
echo "</td>";
|
||||
@@ -219,20 +223,20 @@
|
||||
|
||||
if (isediting($course->id)) {
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo "<a href=\"view.php?id=$course->id&hide=$section&sesskey=$USER->sesskey\" title=\"$strweekhide\">".
|
||||
echo "<a href=\"view.php?id=$course->id&hide=$section\" title=\"$strweekhide\">".
|
||||
"<img src=\"$CFG->pixpath/i/hide.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
} else {
|
||||
echo "<a href=\"view.php?id=$course->id&show=$section&sesskey=$USER->sesskey\" title=\"$strweekshow\">".
|
||||
echo "<a href=\"view.php?id=$course->id&show=$section\" title=\"$strweekshow\">".
|
||||
"<img src=\"$CFG->pixpath/i/show.gif\" vspace=3 height=16 width=16 border=0></a><br />";
|
||||
}
|
||||
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=-1&sesskey=$USER->sesskey\" title=\"$strmoveup\">".
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=-1\" title=\"$strmoveup\">".
|
||||
"<img src=\"$CFG->pixpath/t/up.gif\" vspace=3 height=11 width=11 border=0></a><br />";
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=1&sesskey=$USER->sesskey\" title=\"$strmovedown\">".
|
||||
echo "<a href=\"view.php?id=$course->id§ion=$section&move=1\" title=\"$strmovedown\">".
|
||||
"<img src=\"$CFG->pixpath/t/down.gif\" vspace=3 height=11 width=11 border=0></a><br />";
|
||||
}
|
||||
|
||||
@@ -263,7 +267,7 @@
|
||||
echo '<td style="vertical-align: top; width: '.$preferred_width_right.'px;">';
|
||||
print_course_blocks($course, $rightblocks, BLOCK_RIGHT);
|
||||
if ($editing && !empty($missingblocks)) {
|
||||
block_print_blocks_admin($course, $missingblocks);
|
||||
block_print_blocks_admin($course->id, $missingblocks);
|
||||
}
|
||||
print_spacer(1, 120, true);
|
||||
echo '</td>';
|
||||
|
||||
+3
-5
@@ -141,7 +141,7 @@
|
||||
|
||||
|
||||
/// OK, we have all the data, now present it to the user
|
||||
if ($download == "xls" and confirm_sesskey()) {
|
||||
if ($download == "xls") {
|
||||
require_once("../lib/excel/Worksheet.php");
|
||||
require_once("../lib/excel/Workbook.php");
|
||||
|
||||
@@ -199,7 +199,7 @@
|
||||
|
||||
exit;
|
||||
|
||||
} else if ($download == "txt" and confirm_sesskey()) {
|
||||
} else if ($download == "txt") {
|
||||
|
||||
/// Print header to force download
|
||||
|
||||
@@ -254,16 +254,14 @@
|
||||
echo "<TD>";
|
||||
$options["id"] = "$course->id";
|
||||
$options["download"] = "xls";
|
||||
$options["sesskey"] = $USER->sesskey;
|
||||
print_single_button("grades.php", $options, get_string("downloadexcel"));
|
||||
echo "<TD>";
|
||||
$options["download"] = "txt";
|
||||
$options["sesskey"] = $USER->sesskey;
|
||||
print_single_button("grades.php", $options, get_string("downloadtext"));
|
||||
echo "</TABLE>";
|
||||
|
||||
|
||||
$table->head = array_merge(array ("", get_string("firstname"), get_string("lastname")), $columnhtml, array(get_string("total")));
|
||||
$table->head = array_merge(array ("", get_string("firstname"), get_string("lastname")), $columnhtml, get_string("total"));
|
||||
$table->width = array(35, "");
|
||||
$table->align = array("LEFT", "RIGHT", "LEFT");
|
||||
foreach ($columns as $column) {
|
||||
|
||||
@@ -50,5 +50,4 @@
|
||||
|
||||
<input type="hidden" name="group" value="<?php p($group->id) ?>">
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>">
|
||||
<input type="hidden" name="sesskey" value="<?php p($sesskey) ?>">
|
||||
</form>
|
||||
|
||||
+1
-3
@@ -58,7 +58,7 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($form = data_submitted() and confirm_sesskey()) {
|
||||
if ($form = data_submitted()) {
|
||||
|
||||
if (empty($form->name)) {
|
||||
$edit = true;
|
||||
@@ -92,8 +92,6 @@
|
||||
$defaultformat = FORMAT_MOODLE;
|
||||
}
|
||||
|
||||
$sesskey = !empty($USER->id) ? $USER->sesskey : '';
|
||||
|
||||
include('group-edit.html');
|
||||
|
||||
if ($usehtmleditor) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user