Compare commits

..

64 Commits

Author SHA1 Message Date
moodler 575eba292a Preparing for release in a couple of hours 2004-07-16 13:15:26 +00:00
moodler 0a2294525c Fixing up last merge problem 2004-07-16 13:13:35 +00:00
moodler 4b685ab2a3 Fixed typo for globalglossary 2004-07-16 13:07:14 +00:00
moodler 00231a7498 Adding latest ADOdb to stable 2004-07-16 12:15:46 +00:00
stronk7 ad6c367583 Ooops!! I thought I had sent this to CVS some days ago.
Now both type of links (slasharguments on and off) are
detected in the backup process. And the restore process
take care of the slasharguments seting in destination
and translate all the links to the correct format.
I think it's really a nice addition, ;-)
Ready to 1.3.3 bump!!!
Bug 1634
(http://moodle.org/bugs/bug.php?op=show&bugid=1634)
2004-07-15 22:59:20 +00:00
moodler 7ffa4254e2 Fix for bug 1514 2004-07-15 05:59:59 +00:00
moodler 86fb51fe69 Added $bodytags variable in themes 2004-07-14 06:47:06 +00:00
moodler bc05b1544d Added bodytags parameter for print_header, to help SCORM module insert onload() to pages 2004-07-14 06:41:56 +00:00
moodler e2d3d77173 Fixes from Deen Foxx BUg 1638 2004-07-13 13:53:41 +00:00
moodler 6b63e94a29 Fixed XSS bug #1637 2004-07-13 03:49:20 +00:00
stronk7 350e44bf21 Now, for glossaries using the 'Entry List' format, their
entry->description is viewable with the standard popup window.

Bug 1636
(http://moodle.org/bugs/bug.php?op=show&bugid=1636)
2004-07-12 17:08:45 +00:00
stronk7 f97355847a In 'categories view' (all and only one), now attachements, edit, comment
and delete are working properly. Thanks to frank@nomios.de!!
See bug 1632
(http://moodle.org/bugs/bug.php?op=show&bugid=1632)
2004-07-12 16:33:04 +00:00
stronk7 ee84cd6c76 Updated to 1.3.2 (from trunk) 2004-07-11 23:08:04 +00:00
moodler 14824286cb Small fix to detect_munged_arguments to make Thiagi game shells work.
They have a '..' in the arguments, so we are allowing one of these only.

I wonder if this is Ger's problem too.
2004-07-11 16:01:09 +00:00
stronk7 3f4e0d9d6a Now, course->summary
section->summary
     user->description
are properly transformed if, in their contents, there was some
file.php call.
See bug 1631
(http://moodle.org/bugs/bug.php?op=show&bugid=1631)
2004-07-10 22:37:45 +00:00
stronk7 2b8fb55a4d Latest changes from Antonio Vergara in HEAD rev. 2004-07-09 15:20:45 +00:00
moodler aa55bb6666 And moving on ... 2004-07-09 09:47:04 +00:00
moodler 90c644a587 Latest release notes for 1.3.2 (in STable) 2004-07-09 08:30:26 +00:00
moodler 30772a2aaf Latest SCORM from development now merged into stable 2004-07-09 05:53:46 +00:00
stronk7 4287e72159 Updated because they are very old (Moodle 1.1.1).
Changes apllied from 1.4 TRUNK.
2004-07-08 21:22:57 +00:00
moodler 79b71ea0cd All current language files have been merged from the main development branch 2004-07-08 15:35:28 +00:00
stronk7 5180efaa90 Now only restored wikis (posts and resources) are re-encoded when
restoring to a existing course. Bug 1571.
(http://moodle.org/bugs/bug.php?op=show&bugid=1571)
2004-07-08 05:59:50 +00:00
moodler 1a55aa43a2 Preparing for release today 2004-07-08 01:21:20 +00:00
moodler eb34e77f15 Add require login to be safe (more checks than just isadmin) 2004-07-08 01:16:29 +00:00
stronk7 935ba6ed19 Force to destroy the php session. Without this, some buggy PHP versions
can have problems under certain situations. :-)
2004-07-07 19:28:26 +00:00
moodler ea944efe7f A fix to prevent breaking of lines in multibyte languages 2004-07-07 15:04:52 +00:00
moodler 4f8442c56d Preparing for 1.3.2 release 2004-07-06 01:57:58 +00:00
moodler fe544ceab4 Made forum search form slightly smaller 2004-07-05 05:45:09 +00:00
moodler b65fdd3b54 Allow students to always see editing teachers in their course 2004-07-04 11:08:47 +00:00
moodler 6478428784 FIxes for showing user discussions from groups 2004-07-04 07:38:51 +00:00
moodler 660381d2b0 Fixes for recent activity 2004-07-03 12:56:14 +00:00
moodler 65aede08b6 This fixes some rather serious bugs with how groups are used in group-oriented
forums.

The zero group was used to define both the

   - ungrouped people
   - the posts that all groups should see

The groupid field in the forums is now a signed field and a new value -1 has
been introduced.

   0  --> ungrouped people
   -1 --> the posts that all groups should see

Things are now a lot more intuitive.  Teachers can post to individual
groups or to ALL groups at once.   Recent news display now makes sense etc.
2004-07-03 12:09:34 +00:00
moodler cc1ec30e2d Made assignment submission counting more robust 2004-07-03 10:25:50 +00:00
moodler 5f90f9fad6 Updated to English 2004-07-03 09:16:19 +00:00
moodler 60d17e47a0 FIxed bug 1607 - user sorting 2004-07-02 02:44:34 +00:00
stronk7 94826e8e57 Minor copy/paste bug solved... :-) 2004-07-01 18:56:22 +00:00
stronk7 ae39746289 Some polishing of "TAB" chars in source code done.
Minor changes in glossary export/import to include the displayformat field.
Added a new feature (it was hidden and uncompleted in source code):
Import a glossary file, creating automatically a new glossary activity.
Bug 1606.
http://moodle.org/bugs/bug.php?op=show&bugid=1606
2004-07-01 18:52:44 +00:00
gustav_delius 49fe4f99e1 using fullname() on info page, fixing bug 1596 2004-06-29 21:46:32 +00:00
stronk7 4997042474 Take care of empty aliases in glossary xml files when importing them.
See bug 1599. Thanks to skodak. :-)
http://moodle.org/bugs/bug.php?op=show&bugid=1599
2004-06-28 23:54:00 +00:00
stronk7 1194026729 Modified to delete temp files older than 4 hours (previously it was
configured to 48 hours). Force to execute the clean before doing the
backup itself. This should avoid the disk full of temp backup files
issue. See bug 1520.
http://moodle.org/bugs/bug.php?op=show&bugid=1520
2004-06-27 22:28:19 +00:00
moodler 20761eb71d Some fixes for locales in a very multilibgual site (eg moodle.org) 2004-06-21 12:39:31 +00:00
gustav_delius 734bdb63bf Site option forcelogin is now respected by /mod/forum/search.php, fixing bug 1566 2004-06-14 20:06:15 +00:00
stronk7 e0dd8f3260 Added a new check in selectItemInMenuByName() javascript to apply the
select only to menus by checking element.type == select-one. Thanks to
Antonio Vicent.
2004-06-13 01:07:16 +00:00
gustav_delius 578ba7762e fixed bug 1553 which gave error with empty jump menu 2004-06-09 08:35:47 +00:00
moodler e044b5a536 A glossary marked global can now be unmarked again later 2004-06-07 08:40:39 +00:00
moodler 63f6422df2 Updating release name 2004-06-07 08:37:51 +00:00
moodler 8097f8d7c7 Fixed a bug reported here: http://moodle.org/mod/forum/discuss.php?d=8737
Students now will not see a forum rating menu if "teachers only" has been selected.
2004-06-07 06:12:55 +00:00
moodler ac90c4a264 Fixed problem with mediaplugins filter being too greedy when there
were multiple links in the same line of HTML code.
2004-06-06 14:25:23 +00:00
gustav_delius 345692a64d Fixed bug 1531, section links to invisible sections now greyed out or hidden 2004-06-05 12:03:22 +00:00
gustav_delius 86a8e9070b Fixed bug 1531, section links to invisible sections now greyed out or hidden 2004-06-05 11:56:51 +00:00
moodler 6555eabb0c Latest release notes for 1.3.1 2004-06-04 16:14:20 +00:00
moodler dcc6326eb9 Slip those popular » characters into the navigation bar 2004-06-04 13:15:45 +00:00
moodler e8fb94a3cd Label this as Moodle 1.3.1 2004-06-04 07:55:19 +00:00
moodler 79dd6106dd Removed PHP_SELF ... bug 1522 2004-06-03 14:22:20 +00:00
moodler 031dd5f017 OK, for bug fixes this is a pretty big checkin!! :-/
I finally was able to see the HTML Editor bug in IE/XP that everyone
was talking about, and it's a very serious bug as it makes Moodle 1.3
almost unusable for these people.  :-(  :-(

So, I eventually found out that the problem is that the Javascript that
attaches the editor has troubles when it is embedded within the table                                                   that course/mod.php puts around the mod.html forms in each module.
(Only in IE and only sometimes, mind you).

While testing I also had a good look at a long standing issue which is the
inconsistency of the mod.html forms when using the editor.

So, to fix both I decided to put the HTML editor calls OUTSIDE the mod.html
in the mod.php file.  This means that all modules get the HTML editor by default
on all text areas during activity module setup by default.

I've been running through this for the past few hours and it seems
pretty stable now and a lot more consistent, so I'm checking it in
as big fix towards the Moodle 1.3.1 we have to have.

Unfortunately it also means the API has changed a bit  ... I had to
update all the module dependencies to this exact version (or later).

Please test this "stable" version hard using the standard modules only
and I'll merge these changes over to the trunk in a day or so and update
all known third-party modules.
2004-06-03 13:07:49 +00:00
moodler 507ee65e59 Fix for bug 1070 where HTML editor body was not always being shown. 2004-06-03 08:14:07 +00:00
defacer 56b19c309e Fix for an (apparently old but only recently discovered by me) issue from the
forums where require_once() would fail to do the "once" part unless you use
absolute pathnames.
2004-06-02 08:03:05 +00:00
stronk7 99dac04aeb Solved bug 1491 in all the "linking" filters.
(http://moodle.org/bugs/bug.php?op=show&bugid=1491)
Bugfix 001
2004-05-30 00:28:52 +00:00
gustav_delius 12f18ea1ab A hack to fix bug 1488. html editor needs $course object defined. Should perhaps be solved differently in the long run. 2004-05-29 16:19:32 +00:00
stronk7 1626376373 One simple change to test cvs branching... 2004-05-29 15:19:15 +00:00
moodler 7729acff90 On second thoughts, we must not touch the version date,
so that people can upgrade properly to Moodle 1.4 later.
2004-05-29 14:27:33 +00:00
moodler b35cd9c592 Update version number for stable. No need to merge this obviously 2004-05-29 14:25:39 +00:00
gustav_delius a69a278684 previous fix now also works in weekly format 2004-05-29 09:12:33 +00:00
gustav_delius 61cc70ae45 section links now preserve focused view, see http://moodle.org/mod/forum/discuss.php?d=7648#37555 2004-05-29 08:40:41 +00:00
3622 changed files with 50963 additions and 191127 deletions
-88
View File
@@ -1,88 +0,0 @@
<form name="adminform" id="adminform" method="post" action="admin.php">
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
<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="&larr;" />
<br />
<input name="remove" type="<?php echo $removebuttontype ?>" id="remove" value="&rarr;" />
<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 -52
View File
@@ -32,11 +32,16 @@
"assignadmins",
"administration",
"existingadmins",
"noexistingadmins",
"potentialadmins",
"nopotentialadmins",
"addadmin",
"removeadmin",
"search",
"searchagain",
"toomanytoshow",
"users",
"searchresults",
"showall"
"searchresults"
);
foreach ($stringstoload as $stringtoload){
@@ -44,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 &nbsp;&nbsp; ";
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>&nbsp;&nbsp;".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();
+1 -6
View File
@@ -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
+102 -224
View File
@@ -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,37 +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="submit" value="<?php print_string("savechanges") ?>"></td>
<input type="submit" value="<?php print_string("savechanges") ?>"></td>
</tr>
</table>
-14
View File
@@ -86,20 +86,6 @@
include("config.html");
print_simple_box_end();
/// Lock some options
$httpsurl = str_replace('http://', 'https://', $CFG->wwwroot);
if ($httpsurl != $CFG->wwwroot) {
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();
}
-3
View File
@@ -41,9 +41,6 @@
get_string("adminhelpbackup"));
}
$table->data[]= array("<b><a href=\"editor.php\">". get_string("editorsettings") ."</a></b>",
get_string("adminhelpeditorsettings"));
print_table($table);
print_footer($site);
-82
View File
@@ -1,82 +0,0 @@
<form name="creatorsform" id="creatorsform" method="post" action="creators.php">
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
<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="&larr;" />
<br />
<input name="remove" type="submit" id="remove" value="&rarr;" />
<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 -50
View File
@@ -26,11 +26,16 @@
"assigncreators",
"administration",
"existingcreators",
"noexistingcreators",
"potentialcreators",
"nopotentialcreators",
"addcreator",
"removecreator",
"search",
"searchagain",
"users",
"searchresults",
"showall"
"toomanytoshow",
"searchresults"
);
foreach ($stringstoload as $stringtoload){
@@ -38,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 &nbsp;&nbsp; ";
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>&nbsp;&nbsp;$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();
+18 -41
View File
@@ -33,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";
@@ -50,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
@@ -71,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
@@ -80,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";
}
}
}
@@ -93,11 +87,10 @@
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?)
@@ -109,7 +102,6 @@
"AND course = '$user->course' AND id <> '$user->id'");
}
}
flush();
/// Delete old logs to save space (this might need a timer to slow it down...)
@@ -118,7 +110,6 @@
$loglifetime = $timenow - ($CFG->loglifetime * 3600 * 24);
delete_records_select("log", "time < '$loglifetime'");
}
flush();
/// Delete old cached texts
@@ -126,17 +117,9 @@
$cachelifetime = time() - $CFG->cachetext;
delete_records_select("cache_text", "timemodified < '$cachelifetime'");
}
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");
}
@@ -144,7 +127,7 @@
//Execute backup's cron
//Perhaps a long time and memory could help in large sites
@set_time_limit(0);
@ini_set("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
@@ -153,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";
}
}
}
@@ -166,31 +150,24 @@
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";
?>
-83
View File
@@ -1,83 +0,0 @@
<form method="post" action="<?php print($GLOBALS['ME']);?>">
<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>&nbsp;</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>&nbsp;</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']);?>">
<center>
<input type="submit" name="resettodefaults" value="<?php print_string('editorresettodefaults') ?>" />
</center>
</form>
-136
View File
@@ -1,136 +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 ($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", 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;
}
?>
-81
View File
@@ -1,81 +0,0 @@
<?PHP // $Id$
// enrol.php - allows admin to edit all enrollment variables
// Yes, enrol is correct English spelling.
include("../config.php");
require_login();
optional_variable($enrol, $CFG->enrol);
if (!$site = get_site()) {
redirect("index.php");
}
if (!isadmin()) {
error("Only the admin can use this page");
}
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", 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 "<div align=\"center\"><p><b>";
/// Choose an enrolment method
echo get_string('chooseenrolmethod').': ';
choose_from_menu ($options, "enrol", $enrol, "",
"document.location='enrol.php?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;
?>
+144 -46
View File
@@ -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, "&nbsp;", "&nbsp;");
}
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, "&nbsp;", "&nbsp;");
}
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()) {
@@ -288,8 +387,6 @@
$configdata .= "<font size=+1>&nbsp;</font><a href=\"backup.php\">".get_string("backup")."</a> - <font size=1>".
get_string("adminhelpbackup")."</font><br />";
}
$configdata .= "<font size=+1>&nbsp;</font><a href=\"editor.php\">". 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);
@@ -297,27 +394,26 @@
$userdata = "<font size=+1>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</font><a href=\"user.php\">".get_string("edituser")."</a> - <font size=1>".
get_string("adminhelpedituser")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</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>&nbsp;</font><a href=\"$CFG->wwwroot/$CFG->admin/uploaduser.php\">".
get_string("uploadusers")."</a> - <font size=1>".
get_string("adminhelpuploadusers")."</font><br />";
$userdata .= "<hr><font size=+1>&nbsp;</font><a href=\"enrol.php\">".get_string("enrolments")."</a> - <font size=1>".
get_string("adminhelpenrolments")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"../course/index.php?edit=off\">".get_string("assignstudents")."</a> - <font size=1>".
get_string("adminhelpassignstudents")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"admin.php\">".get_string("assignadmins")."</a> - <font size=1>".
get_string("adminhelpassignadmins")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"creators.php\">".get_string("assigncreators")."</a> - <font size=1>".
get_string("adminhelpassigncreators")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</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>&nbsp;</font><a href=\"creators.php\">".get_string("assigncreators")."</a> - <font size=1>".
get_string("adminhelpassigncreators")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</font><a href=\"admin.php\">".get_string("assignadmins")."</a> - <font size=1>".
get_string("adminhelpassignadmins")."</font><br />";
$userdata .= "<font size=+1>&nbsp;</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);
@@ -363,3 +459,5 @@
print_footer($site);
?>
+4 -21
View File
@@ -27,21 +27,14 @@
case "missing":
$navigation = "<A HREF=\"lang.php\">$strlanguage</A> -> $strmissingstrings";
$title = $strmissingstrings;
$button = '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/admin/lang.php">'.
'<input type="hidden" name="mode" value="compare" />'.
'<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.'/admin/lang.php">'.
'<input type="hidden" name="mode" value="missing" />'.
'<input type="submit" value="'.$strmissingstrings.'" /></form>';
break;
default:
$title = $strlanguage;
$navigation = $strlanguage;
$button = '';
break;
}
@@ -49,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();
@@ -110,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!");
}
@@ -201,12 +190,6 @@
unset($string);
include("$enlangdir/$currentfile");
$enstring = $string;
if ($currentlang != 'en') {
$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);
+18 -28
View File
@@ -2,13 +2,13 @@
<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>
-6
View File
@@ -29,11 +29,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)) {
@@ -65,7 +60,6 @@
$form->shortname = "";
$form->summary = "";
$form->newsitems = 3;
$form->numsections = 0;
$form->id = "";
$form->category = 0;
$form->format = "social";
+3 -4
View File
@@ -33,17 +33,16 @@
$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)";
}
}
-1
View File
@@ -151,7 +151,6 @@
$user->{$name} = addslashes($value);
}
}
$user->auth = 'manual';
$user->confirmed = 1;
$user->timemodified = time();
$linenum++;
+1 -5
View File
@@ -78,7 +78,6 @@
}
if ($newuser) { // Create a new user
$user->auth = "manual";
$user->firstname = "";
$user->lastname = "";
$user->username = "changeme";
@@ -332,9 +331,6 @@
}
echo "</form>";
echo "</td></tr></table>";
if (is_internal_auth()){
print_heading("<a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a>");
}
print_table($table);
@@ -344,7 +340,7 @@
}
if (is_internal_auth()){
if ($CFG->auth == "email" || $CFG->auth == "none" || $CFG->auth == "manual"){
print_heading("<a href=\"user.php?newuser=true\">".get_string("addnewuser")."</a>");
}
+8 -11
View File
@@ -25,25 +25,22 @@
$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\">".get_string("addnewuser")."</a></b>",
get_string("adminhelpaddnewuser"));
$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\">".get_string("enrolments")."</a></b>",
get_string("adminhelpenrolments"));
$table->data[] = array("<b><a href=\"../course/index.php?edit=off\">".get_string("assignstudents")."</a></b>",
get_string("adminhelpassignstudents"));
$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=\"creators.php\">".get_string("assigncreators")."</a></b>",
get_string("adminhelpassigncreators"));
$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);
-71
View File
@@ -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 "?>"
-84
View File
@@ -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>
-218
View File
@@ -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
View File
@@ -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
View File
@@ -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>
+33 -247
View File
@@ -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=*";
}
@@ -135,11 +99,10 @@ function auth_get_userinfo($username){
$result[$key]=$user_entry[0][strtolower($value)][0];
}
}
$result['guid']='ldap';
}
@ldap_close($ldap_connection);
return $result;
}
@@ -186,149 +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) {
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;
@@ -362,49 +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 false;
}
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){
$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;
@@ -502,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) {
@@ -510,7 +319,6 @@ function auth_ldap_attributes (){
$moodleattributes[$field] = $config["auth_user_$field"];
}
}
$moodleattributes['username']=$config["ldap_user_attribute"];
return $moodleattributes;
}
@@ -562,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 -15
View File
@@ -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
View File
@@ -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) {
+2 -2
View File
@@ -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");
@ini_set("memory_limit","128M");
ini_set("max_execution_time","3000");
ini_set("memory_limit","80M");
//Call the form, depending the step we are
if (!$launch) {
+21 -21
View File
@@ -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,19 +36,19 @@ 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;
@@ -56,13 +56,13 @@ function schedule_backup_cron() {
//Now we get a list of courses in the server
if ($status) {
mtrace(" Checking 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
@@ -74,7 +74,7 @@ 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
@@ -105,21 +105,21 @@ 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 ($emailpending) {
mtrace(" Sending email to admin");
echo " Sending email to admin\n";
$message = "";
//Build the message text (future versions should handle html messages too!!)
$logs = get_records_select ("backup_log","laststarttime >= '$now'","id");
@@ -152,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);
@@ -169,10 +169,10 @@ function schedule_backup_launch_backup($course,$starttime = 0) {
}
}
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!!");
}
@@ -650,7 +650,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);
@@ -669,16 +669,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++;
+8 -9
View File
@@ -534,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));
@@ -551,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));
@@ -563,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));
@@ -571,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));
@@ -714,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));
@@ -744,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));
@@ -793,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
+1 -1
View File
@@ -196,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>
+2 -2
View File
@@ -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");
@ini_set("memory_limit","128M");
ini_set("max_execution_time","3000");
ini_set("memory_limit","80M");
//Call the form, depending the step we are
if (!$launch) {
+1 -1
View File
@@ -296,7 +296,7 @@
rebuild_course_cache($restore->course_id);
//categories table
$course = get_record("course","id",$restore->course_id);
fix_course_sortorder();
fix_course_sortorder($course->category);
}
//Cleanup temps (files and db)
-10
View File
@@ -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
+3 -45
View File
@@ -125,6 +125,7 @@
}
$formatwiki = FORMAT_WIKI;
$typewiki = WIKITEXT;
//FORUM: Decode every POST (message) in the course
//Check we are restoring forums
@@ -175,13 +176,12 @@
//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 being restored
if ($resources = get_records_sql ("SELECT r.id, r.alltext
FROM {$CFG->prefix}resource r,
{$CFG->prefix}backup_ids b
WHERE r.course = $restore->course_id AND
r.type = 'text' AND
r.options = $formatwiki AND
r.type = $typewiki AND
b.backup_code = $restore->backup_unique_code AND
b.table_name = 'resource' AND
b.new_id = r.id")) {
@@ -536,7 +536,6 @@
$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->summary = restore_decode_absolute_links(addslashes($course_header->course_summary));
$course->format = addslashes($course_header->course_format);
$course->showgrades = addslashes($course_header->course_showgrades);
@@ -548,7 +547,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);
@@ -556,7 +554,6 @@
$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);
@@ -808,19 +805,6 @@
$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;
}
//We are going to create the user
//The structure is exactly as we need
$newid = insert_record ("user",$user);
@@ -1681,11 +1665,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;
@@ -2198,9 +2177,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;
@@ -2234,9 +2210,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;
@@ -2258,9 +2231,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;
@@ -2440,9 +2410,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;
@@ -2530,9 +2497,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;
@@ -2575,12 +2539,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;
+3 -4
View File
@@ -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");
@ini_set("memory_limit","128M");
ini_set("max_execution_time","3000");
ini_set("memory_limit","56M");
echo "<pre>\n";
+2 -2
View File
@@ -5,6 +5,6 @@
// database (backup_version) to determine whether upgrades should
// be performed (see db/backup_*.php)
$backup_version = 2004083100; // The current version is a date (YYYYMMDDXX)
$backup_version = 2004052403; // The current version is a date (YYYYMMDDXX)
$backup_release = "1.4"; // User-friendly version number
$backup_release = "1.3.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="">';
}
}
+6 -51
View File
@@ -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,54 +21,6 @@ class CourseBlock_admin extends MoodleBlock {
$this->content->icons = array();
$this->content->footer = '';
if (empty($this->course)) {
$this->content = '';
} else if ($this->course->category == 0) {
$this->load_content_for_site();
} else {
$this->load_content_for_course();
}
return $this->content;
}
function load_content_for_site() {
global $CFG;
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="" />';
}
if (iscreator()) {
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/index.php?edit=on">'.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=1">'.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=1">'.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;
}
@@ -128,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="">';
@@ -149,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;
}
}
+4 -14
View File
@@ -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,38 +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&amp;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&amp;course='.$this->course->id.'">'.
get_string('gotocalendar', 'calendar').'</a>...';
$this->content->footer .= '<br /><a href="'.$CFG->wwwroot.
'/calendar/event.php?action=new&amp;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
@@ -56,9 +41,8 @@ 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));
$this->content->text = calendar_get_sideblock_upcoming($events, 'view.php?view=day&amp;course='.$this->course->id.'&amp;');
$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>';
+8 -37
View File
@@ -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, $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();
-31
View File
@@ -1,31 +0,0 @@
<form method="post" action="block.php">
<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>
+7 -30
View File
@@ -2,51 +2,28 @@
class CourseBlock_course_summary extends MoodleBlock {
function CourseBlock_course_summary ($course) {
if (empty($course->category)) { // 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 (empty($this->course->category)) {
$editpage = $CFG->wwwroot.'/admin/site.php';
} else {
$editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->course->id;
}
$this->content->text .= "<div 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;}
}
?>
-1
View File
@@ -37,7 +37,6 @@ global $CFG;
COMMENT = 'To register and update all the available blocks'");
}
//Finally, return result
return $result;
}
-1
View File
@@ -39,7 +39,6 @@ global $CFG;
}
//Finally, return result
return $result;
}
-77
View File
@@ -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;
}
}
?>
+23 -50
View File
@@ -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,7 +93,6 @@ class MoodleBlock {
}
print_side_block($title, '&nbsp;', NULL, NULL, '');
}
function add_edit_controls($options, $blockid) {
global $CFG, $THEME;
@@ -155,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.'&amp;blockaction=toggle&amp;blockid='.$blockid.'">' .
$movebuttons .= '<a style="margin-right: 10px;" title="'.$title.'" href="'.$path.'/view.php?id='.$this->course->id.'&amp;blockaction=toggle&amp;blockid='.$blockid.'">' .
'<img src="'.$pixpath.$icon.'" /></a>';
$movebuttons .= '<a title="'.$this->str->delete.'" href="'.$path.'/view.php?id='.$this->course->id.'&amp;blockaction=delete&amp;blockid='.$blockid.'">' .
'<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.'&amp;blockaction=delete&amp;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.'&amp;blockaction=moveside&amp;blockid='.$blockid.'">' .
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->moveleft.'" href="'.$path.'/view.php?id='.$this->course->id.'&amp;blockaction=moveside&amp;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.'&amp;blockaction=moveup&amp;blockid='.$blockid.'">' .
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->moveup.'" href="'.$path.'/view.php?id='.$this->course->id.'&amp;blockaction=moveup&amp;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.'&amp;blockaction=movedown&amp;blockid='.$blockid.'">' .
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->movedown.'" href="'.$path.'/view.php?id='.$this->course->id.'&amp;blockaction=movedown&amp;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.'&amp;blockaction=moveside&amp;blockid='.$blockid.'">' .
$movebuttons .= '<a style="margin-right: 3px;" title="'.$this->str->moveright.'" href="'.$path.'/view.php?id='.$this->course->id.'&amp;blockaction=moveside&amp;blockid='.$blockid.'">' .
'<img src="'.$pixpath.'/t/right.gif" /></a>';
}
@@ -204,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';
@@ -232,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;
}
}
+2 -8
View File
@@ -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 = '';
+39 -57
View File
@@ -5,7 +5,7 @@ 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;}
@@ -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 {
+13 -21
View File
@@ -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 isteacher()) 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.'&amp;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.'&amp;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 = '';
+10 -20
View File
@@ -3,15 +3,13 @@
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;
@@ -20,7 +18,7 @@ class CourseBlock_section_links extends MoodleBlock {
}
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,10 +48,7 @@ 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&amp;$sectionname=";
} else {
$link = '#';
@@ -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[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
$this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$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.'">'.
'<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.'">'.
'<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[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
$this->content->items[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
$this->content->items[] = '&nbsp;<img align="bottom" src="'.$CFG->pixpath.'/t/move.gif" height="11" width="11">';
$this->content->icons[] = $USER->activitycopyname.'&nbsp;(<a href="'.$CFG->wwwroot.'/course/mod.php?cancelcopy=true">'.$strcancel.'</a>)';
}
if (!empty($section->sequence)) {
@@ -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,7 +96,7 @@ 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.'">';
}
}
}
@@ -118,7 +110,8 @@ class CourseBlock_social_activities extends MoodleBlock {
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.'&amp;section='.$section->section.'&amp;add=',
$modnames, 'section0', '', get_string('add').'...', 'mods', get_string('activities'), true) . '</div>';
} else {
$this->content->footer = '';
}
+1 -1
View File
@@ -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
View File
@@ -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);
}
+4
View File
@@ -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
View File
@@ -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>&nbsp;</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>&nbsp;</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>
+163 -194
View File
@@ -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');
@@ -122,7 +122,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
$morehref = '';
if(!empty($courses)) {
$courses = array_diff($courses, array(SITEID));
$courses = array_diff($courses, array(1));
if(count($courses) == 1) {
$morehref = '&amp;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
@@ -195,7 +194,7 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
$popupalt = '';
} 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,12 +277,13 @@ 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
@@ -308,7 +307,7 @@ function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxeve
$morehref = '';
if(!empty($courses)) {
$courses = array_diff($courses, array(SITEID));
$courses = array_diff($courses, array(1));
if(count($courses) == 1) {
$morehref = '&amp;course='.reset($courses);
}
@@ -316,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.'&amp;', $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.'&amp;', $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.'&amp;', $startdate['mday'], $startdate['mon'], $startdate['year']).
' ('.$timestart.') -> '.calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&amp;', $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.'&amp;', $startdate['mday'], $startdate['mon'], $startdate['year']).' ('.$time.')';
}
$outkey = count($output);
@@ -393,6 +450,7 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
if(is_bool($users) && is_bool($groups) && is_bool($courses)) {
return false;
}
if(is_array($users) && !empty($users)) {
// Events from a number of users
if(!empty($whereclause)) $whereclause .= ' OR';
@@ -408,10 +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';
@@ -427,18 +481,10 @@ function calendar_sql_where($tstart, $tend, $users, $groups, $courses, $withdura
if(!empty($whereclause)) $whereclause .= ' OR ';
$whereclause .= ' groupid != 0';
}
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
@@ -470,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) {
@@ -566,11 +611,7 @@ function calendar_filter_controls($type, $vars = NULL, $course = NULL) {
$getvars = '&amp;from='.$type;
break;
case 'course':
if (isset($_GET['id'])) {
$getvars = '&amp;from=course&amp;id='.$_GET['id'];
} else {
$getvars = '&amp;from=course';
}
$getvars = '&amp;from=course&amp;id='.$_GET['id'];
if (isset($course->groupmode) and !$course->groupmode and $course->groupmodeforce) {
$groupevents = false;
}
@@ -597,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) && !isguest()) {
if(!isguest($USER->id)) {
$content .= "</tr>\n<tr>";
if($groupevents) {
@@ -643,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');
}
@@ -719,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) {
@@ -740,14 +793,7 @@ function calendar_get_sideblock_upcoming($events, $linkhref = NULL) {
// 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>';
@@ -775,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();
@@ -784,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 == 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;
// $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 == 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;
}
}
}
return;
}
@@ -881,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() {
@@ -946,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;
@@ -975,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));
@@ -1001,10 +1036,6 @@ function calendar_set_filters(&$courses, &$group, &$user, $courseeventsfrom = NU
function calendar_edit_event_allowed($event) {
global $USER;
if(empty($USER) || isguest($USER->id)) {
return false;
}
if (isadmin($USER->id)) return true; // Admins are allowed anything
if ($event->courseid > 1) {
@@ -1041,7 +1072,7 @@ function calendar_get_default_courses($ignoreref = false) {
}
$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;
}
@@ -1101,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 '';
}
@@ -1110,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.'&amp;', $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.'&amp;', $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.'&amp;', $startdate['mday'], $startdate['mon'], $startdate['year']).
' ('.$timestart.') -> '.calendar_get_link_tag($dayend, CALENDAR_URL.'view.php?view=day'.$morehref.'&amp;', $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.'&amp;', $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) {
+5 -4
View File
@@ -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
View File
@@ -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;
}
+33 -49
View File
@@ -41,8 +41,11 @@
// 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);
@@ -90,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) 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;
}
@@ -157,7 +151,7 @@
// 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.'&amp;cal_m='.$mon.'&amp;cal_y='.$yr; // For filtering
@@ -183,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());
@@ -198,8 +192,9 @@ function calendar_show_day($d, $m, $y, $courses, $groups, $users) {
$events = calendar_get_upcoming($courses, $groups, $users, 1, 100, $starttime);
// New event button
if (empty($USER) || 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;">';
@@ -212,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)) {
@@ -226,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.'&amp;', $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
@@ -248,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);
}
}
@@ -316,10 +300,10 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
}
// 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) || isguest()) {
if(isguest()) {
$text = get_string('detailedmonthview', 'calendar').': '.calendar_course_filter_selector($getvars);
}
else {
@@ -332,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));
@@ -482,7 +466,7 @@ function calendar_show_month_detailed($m, $y, $courses, $groups, $users) {
echo "</tr>\n";
if(!empty($USER) && !isguest()) {
if(!isguest($USER->id)) {
echo '<tr>';
// Group events
if($SESSION->cal_show_groups) {
@@ -510,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) || isguest()) {
if(isguest()) {
$text = get_string('upcomingevents', 'calendar').': '.calendar_course_filter_selector('from=upcoming');
} else {
@@ -530,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);
@@ -579,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&amp;id='.$event->id;
$editlink = CALENDAR_URL.'event.php?action=edit&amp;id='.$event->id;
$deletelink = CALENDAR_URL.'event.php?action=delete&amp;id='.$event->id;
} else {
$editlink = $CFG->wwwroot.'/course/mod.php?update='.$event->cmid.'&amp;return=true';
$deletelink = $CFG->wwwroot.'/course/mod.php?delete='.$event->cmid;
$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').'"
@@ -601,12 +584,13 @@ function calendar_print_event($event) {
function calendar_course_filter_selector($getvars = '') {
global $USER, $SESSION;
if (empty($USER) or isguest()) {
if (isguest($USER->id)) {
return '';
}
if (isadmin()) {
if (isadmin($USER->id)) {
$courses = get_courses('all', 'c.shortname');
} else {
$courses = get_my_courses($USER->id, 'shortname');
}
+21 -35
View File
@@ -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,26 +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";
//=========================================================================
// ALL DONE! To continue installation, visit your main page with a browser
@@ -194,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.
?>
+8 -21
View File
@@ -57,14 +57,7 @@
/// Resort the category if requested
if (!empty($_GET['resort'])) {
if ($courses = get_courses($category->id, "fullname ASC")) {
$count = 0;
foreach ($courses as $course) {
set_field('course', 'sortorder', $count, 'id', $course->id);
$count++;
}
fix_course_sortorder();
}
fix_course_sortorder($category->id, "fullname ASC");
}
}
@@ -80,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);
}
@@ -133,7 +126,8 @@
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);
}
}
@@ -208,7 +202,7 @@
}
}
fix_course_sortorder();
fix_course_sortorder($category->id);
} // End of editing stuff
@@ -236,8 +230,6 @@
/// Print out all the courses
unset($course); // To avoid unwanted language effects later
$courses = get_courses_page($category->id, "c.sortorder ASC", "c.*", $totalcount, $page*$perpage, $perpage);
$numcourses = count($courses);
@@ -262,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");
@@ -301,8 +292,6 @@
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".
@@ -342,8 +331,6 @@
} 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> ";
}
-35
View File
@@ -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
+12 -23
View File
@@ -1,9 +1,9 @@
<?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");
optional_variable($id, 0); // course id
optional_variable($category, 0); // category id
@@ -36,13 +36,9 @@
/// If data submitted, then process and store.
if ($form = data_submitted()) {
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);
@@ -53,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)");
}
@@ -82,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
@@ -110,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.
@@ -133,8 +124,6 @@
$form->password = "";
$form->guest = 0;
$form->numsections = 10;
$form->idnumber = '';
$form->cost = '';
$form->newsitems = 5;
$form->showgrades = 1;
$form->groupmode = 0;
@@ -178,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 {
@@ -189,7 +178,7 @@
print_heading($streditcoursesettings);
print_simple_box_start("center", "", "$THEME->cellheading");
include("edit.html");
include("edit.html");
print_simple_box_end();
print_footer($course);
+96 -31
View File
@@ -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();
?>
+1 -1
View File
@@ -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>';
+14 -10
View File
@@ -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>&nbsp;</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&amp;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&amp;section=$section&add=",
$modnames, "section$section", "", "$stradd...");
echo "</div>";
}
echo "</td>";
@@ -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>';
+11 -7
View File
@@ -91,8 +91,7 @@
echo "<td nowrap bgcolor=\"$THEME->cellheading\" class=\"weeklyoutlineside\" valign=top width=20>&nbsp;</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&amp;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&amp;section=$section&add=",
$modnames, "section$section", "", "$stradd...");
echo "</div>";
}
echo "</td>";
@@ -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>';
+1 -1
View File
@@ -261,7 +261,7 @@
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) {
+1 -1
View File
@@ -49,7 +49,7 @@
$groups = get_groups($course->id);
if (empty($USER->groupsediting)) { /// Display an overview of all groups
if (!$USER->groupsediting) { /// Display an overview of all groups
if (!$groups) {
print_heading(get_string('groupsnone'));
+9 -5
View File
@@ -2,8 +2,8 @@
// For most people, just lists the course categories
// Allows the admin to create, delete and rename course categories
require_once("../config.php");
require_once("lib.php");
require_once("../config.php");
require_once("lib.php");
if (!$site = get_site()) {
error("Site isn't defined!");
@@ -76,7 +76,7 @@
$straction = get_string("action");
$straddnewcategory = get_string("addnewcategory");
print_header("$site->shortname: $strcategories", "$site->fullname",
print_header("$site->shortname: $strcategories", "$site->fullname",
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strcategories",
"addform.addcategory", "", true, update_categories_button());
@@ -231,6 +231,7 @@
$categories = get_categories();
$default = 99999;
foreach ($categories as $category) {
fix_course_sortorder($category->id);
if ($category->id < $default) {
$default = $category->id;
}
@@ -238,14 +239,17 @@
/// Find any orphan courses that don't yet have a valid category and set to default
if ($courses = get_courses()) {
$foundorphans = false;
foreach ($courses as $course) {
if ($course->category and !isset($categories[$course->category])) {
set_field("course", "category", $default, "id", $course->id);
$foundorphans = true;
}
}
if ($foundorphans) {
fix_course_sortorder($default);
}
}
fix_course_sortorder();
/// Print form for creating new categories
+466 -253
View File
File diff suppressed because it is too large Load Diff
+4 -5
View File
@@ -5,7 +5,6 @@
require_once("lib.php");
require_variable($id); // Course ID
optional_variable($group, -1); // Group to display
optional_variable($user, 0); // User to display
optional_variable($date, 0); // Date to display
optional_variable($modname, ""); // course_module->id
@@ -42,7 +41,7 @@
if (!$u = get_record("user", "id", $user) ) {
error("That's an invalid user!");
}
$userinfo = fullname($u, isteacher($course->id));
$userinfo = "$u->firstname $u->lastname";
}
if ($date) {
$dateinfo = userdate($date, get_string("strftimedaydate"));
@@ -60,11 +59,11 @@
print_heading("$course->fullname: $userinfo, $dateinfo (".usertimezone().")");
print_log_selector_form($course, $user, $date, $modname, $modid, $modaction, $group);
print_log_selector_form($course, $user, $date, $modname, $modid, $modaction);
print_log($course, $user, $date, "l.time DESC", $page, $perpage,
"log.php?id=$course->id&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction&group=$group",
$modname, $modid, $modaction, $group);
"log.php?id=$course->id&chooselog=1&user=$user&date=$date&modid=$modid&modaction=$modaction",
$modname, $modid, $modaction);
} else {
if ($course->category) {
-2
View File
@@ -40,8 +40,6 @@
error("Only teachers can use this page!");
}
check_for_restricted_user($USER->username, "$CFG->wwwroot/user/view.php?id=$user&course=$course->id");
if ($course->category and !isstudent($course->id, $user) and !isadmin()) {
error("This student is not in this course!");
}
+5 -79
View File
@@ -1,6 +1,6 @@
<?PHP // $Id$
// Moves, adds, updates, duplicates or deletes modules in a course
// Moves, adds, updates or deletes modules in a course
require("../config.php");
require("lib.php");
@@ -48,11 +48,6 @@
switch ($mod->mode) {
case "update":
if (trim($mod->name) == '') {
unset($mod->name);
}
$return = $updateinstancefunction($mod);
if (!$return) {
if (file_exists($moderr)) {
@@ -65,9 +60,6 @@
if (is_string($return)) {
error($return, "view.php?id=$course->id");
}
$SESSION->returnpage = "$CFG->wwwroot/mod/$mod->modulename/view.php?id=$mod->coursemodule";
add_to_log($course->id, "course", "update mod",
"../mod/$mod->modulename/view.php?id=$mod->coursemodule",
"$mod->modulename $mod->instance");
@@ -77,11 +69,6 @@
break;
case "add":
if (trim($mod->name) == '') {
$mod->name = get_string("modulename", $mod->modulename);
}
$return = $addinstancefunction($mod);
if (!$return) {
if (file_exists($moderr)) {
@@ -117,9 +104,6 @@
if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
error("Could not update the course module with the correct section");
}
$SESSION->returnpage = "$CFG->wwwroot/mod/$mod->modulename/view.php?id=$mod->coursemodule";
add_to_log($course->id, "course", "add mod",
"../mod/$mod->modulename/view.php?id=$mod->coursemodule",
"$mod->modulename $mod->instance");
@@ -127,7 +111,6 @@
"view.php?id=$mod->coursemodule",
"$mod->instance", $mod->coursemodule);
break;
case "delete":
if (! $deleteinstancefunction($mod->instance)) {
notify("Could not delete the $mod->modulename (instance)");
@@ -138,9 +121,6 @@
if (! delete_mod_from_section($mod->coursemodule, "$mod->section")) {
notify("Could not delete the $mod->modulename from that section");
}
unset($SESSION->returnpage);
add_to_log($course->id, "course", "delete mod",
"view.php?id=$mod->course",
"$mod->modulename $mod->instance", $mod->coursemodule);
@@ -414,8 +394,9 @@
$strdeletecheck = get_string("deletecheck", "", "$form->fullmodulename");
$strdeletecheckfull = get_string("deletecheckfull", "", "$form->fullmodulename '$form->instancename'");
print_header_simple("$strdeletecheck", "$",
"$strdeletecheck");
print_header("$course->shortname: $strdeletecheck", "$course->fullname",
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A> ->
$strdeletecheck");
print_simple_box_start("center", "60%", "#FFAAAA", 20, "noticebox");
print_heading($strdeletecheckfull);
@@ -475,57 +456,6 @@
$pageheading = get_string("updatinga", "moodle", $fullmodulename);
}
} else if (isset($_GET['duplicate'])) { // value = course module
if (! $cm = get_record("course_modules", "id", $_GET['duplicate'])) {
error("This course module doesn't exist");
}
if (! $course = get_record("course", "id", $cm->course)) {
error("This course doesn't exist");
}
if (!isteacheredit($course->id)) {
error("You can't modify this course!");
}
if (! $module = get_record("modules", "id", $cm->module)) {
error("This module doesn't exist");
}
if (! $form = get_record($module->name, "id", $cm->instance)) {
error("The required instance of this module doesn't exist");
}
if (! $cw = get_record("course_sections", "id", $cm->section)) {
error("This course section doesn't exist");
}
if (isset($return)) {
$SESSION->returnpage = "$CFG->wwwroot/mod/$module->name/view.php?id=$cm->id";
}
$section = get_field('course_sections', 'section', 'id', $cm->section);
$form->coursemodule = $cm->id;
$form->section = $section; // The section ID
$form->course = $course->id;
$form->module = $module->id;
$form->modulename = $module->name;
$form->instance = $cm->instance;
$form->mode = "add";
$sectionname = get_string("name$course->format");
$fullmodulename = strtolower(get_string("modulename", $module->name));
if ($form->section) {
$heading->what = $fullmodulename;
$heading->in = "$sectionname $cw->section";
$pageheading = get_string("duplicatingain", "moodle", $heading);
} else {
$pageheading = get_string("duplicatinga", "moodle", $fullmodulename);
}
} else if (isset($_GET['add'])) {
@@ -552,9 +482,6 @@
$form->instance = "";
$form->coursemodule = "";
$form->mode = "add";
if (isset($_GET['type'])) {
$form->type = $_GET['type'];
}
$sectionname = get_string("name$course->format");
$fullmodulename = get_string("modulename", $module->name);
@@ -602,7 +529,6 @@
if ($usehtmleditor = can_use_html_editor()) {
$defaultformat = FORMAT_HTML;
$editorfields = '';
} else {
$defaultformat = FORMAT_MOODLE;
}
@@ -615,7 +541,7 @@
print_simple_box_end();
if ($usehtmleditor and empty($nohtmleditorneeded)) {
use_html_editor($editorfields);
use_html_editor();
}
} else {
-365
View File
@@ -1,365 +0,0 @@
<?PHP // $Id$
// Displays all activity for non-quiz modules for a course
///This version allows students to see their own activity, but not that of others.
///For teachers only, clicking on a student's name brings up the Moodle user activity summary.
require_once("../config.php");
require_once("lib.php");
require_once("../lib/datalib.php");
//module, location of user data,pointer
$quick_dataloc["assignment"] = array("assignment_submissions","assignment");
$quick_dataloc["choice"] = array("choice_answers","choice");
$quick_dataloc["dialogue"] = array("dialogue_entries","dialogue");
$quick_dataloc["discussion"] = array("forum_posts","discussion");
$quick_dataloc["journal"] = array("journal_entries","journal");
$quick_dataloc["quiz"] = array("quiz_attempts","quiz");
$quick_dataloc["survey"] = array("survey_analysis","survey");
$quick_dataloc["workshop"] = array("workshop_submissions","workshopid");
$usemods = ",assignment,choice,dialogue,forum,journal,quiz,survey,workshop";
$modlist = get_records("modules","visible",1);
foreach ($modlist as $nowmod){
if (strpos($usemods,$nowmod->name)){
$modnames[$nowmod->id] = $nowmod->name;
}
}
//needed for cases when a particular module type needs special treatment (assignment,forum)
$modname_value = array_flip($modnames);
require_variable($id); // course id
optional_variable($download, ""); // to download data
require_login();
if (! $course = get_record("course", "id", $id)) {
error("Course ID was incorrect");
}
//take each event and create an array type/event/user hierarchy
//we need to get the entire list of enrolled students for the course so that we can list by student
if (isteacher($course->id)) {
$isstudent = 0;
} elseif (isstudent($course->id)) {
$isstudent = 1;
} else {
error("You are not registered for this course");
}
$courseid = $course->id;
//Get the ids of all course users
$allusers = quick_findusers($course->id);
//Get all postings from this course's users
$allposts = quick_findposts($course->id);
//count posts per user by looping thru $allposts and put counts in $post_counts
foreach ($allposts as $thispost){
$post_counts[$thispost->forumid][$thispost->userid]++;
}
$allmods = quick_moduleorder($course->id);
//Now take all mods and build an object $mod_info for only those modules that will be reported
//Concurrently build a $mods_week array that says how many columns will be in the header per week
$modcount = -1;
foreach($allmods as $thismod){
$modcount++;
//get the info on this module from course_modules
$nowmod = get_record("course_modules","id",$thismod[mod]);
$noworder = get_record("course_sections","id",$nowmod->section);
//only add to array the module is contained in the $modnames array
if ($modnames[$nowmod->module]){
//section is the entry in course_sections which says which instances
///reside in the section and which week/section they are in
$mod_info[$modcount][section] = $nowmod->section;
//module is the type of module (assignment, forum, etc.)
$mod_info[$modcount][module] = $nowmod->module;
//modid is the id of the module in "course_modules" table
$mod_info[$modcount][modid] = $nowmod->id;
//week is the current week/section that the module resides in
$mod_info[$modcount][week] = $noworder->section;
//instance in the relevant module table will yield the name
$mod_info[$modcount][instance] = $nowmod->instance;
//Count how many instances in each week for colspan purposes
if ($mods_week[$noworder->section]){
$mods_week[$noworder->section]++;
} else {
$mods_week[$noworder->section] = 1;
}
//Now add the name of the module to $mods_info
$mod_info[$modcount][name] = get_field($modnames[$nowmod->module],"name","id",$nowmod->instance);
} else {
$modcount--;
}
}
//Catalog by user all activity for every module
//This will include modules to be ignored later, but it is easier this way
//Data for each user can be retrieved by matching$rec->name with $mod_info name(created above)
//Create a comma-delimited string in $user_data with the IDs of each user in an array of mod type(module) + modid
foreach ($modnames as $nowtype => $nowname){
$now_module = $nowname;
$now_user_table = $quick_dataloc[$now_module][0]; //name of table containing individual user records
$now_pointer = $quick_dataloc[$now_module][1]; // the field in above with pointer to table with name of activity
// Now set up a table for each separate instance of the module with a listing of the users
$allrecs = quick_findrecs($now_module,$now_user_table,$now_pointer,$course->id);
if ($allrecs) {
foreach ($allrecs as $rec){
$np = $rec->instance;
if ($nowname == "assignment"){
// For assignments, a record is created for all students when the assmt is created
//the timemodified is 0 until the student submits an assignment
if ($rec->timemodified != 0) {
$user_data[$nowtype][$np] = $user_data[$nowtype][$np] . ",$rec->userid,";
}
} else {
$user_data[$nowtype][$np] = $user_data[$nowtype][$np] . ",$rec->userid,";
}
}
}
}
if ($allposts) {
foreach ($allposts as $rec){
$forumval = $modname_value["forum"];
$user_data[$forumval][$rec->forumid] = $user_data[$forumval][$rec->forumid] . ",$rec->userid,";
// echo "<br>" . $rec->forumid . $rec->name . "<br>";
}
}
//now go through the $mod_info array in order of the users, and find whether each user contributed, put in $user_contribs
foreach($allusers as $user){
$uid = $user->id;
foreach ($mod_info as $thismod){
if(strlen($user_data[$thismod[module]][$thismod[instance]]) < 2){
$user_contribs[$uid][] = "-";
continue;
}
//For forums count the number of contributions. For others, just "x" or "-";
if ($thismod[module] == $modname_value["forum"]) {
$puid = $post_counts[$uid];
if ($post_counts[$thismod[instance]][$uid] > 0){
$user_contribs[$uid][] = $post_counts[$thismod[instance]][$uid];
} else {
$user_contribs[$uid][] = "-";
}
} else {
//see if "comma+userid+comma " exists
$sstring = ",$user->id,";
if(strpos($user_data[$thismod[module]][$thismod[instance]],$sstring)> -1){
$user_contribs[$uid][] = "X";
}else {
$user_contribs[$uid][] = "-";
}
}
}
}
//if Excel spreadsheet requested
if ($download == "xls") {
require_once("$CFG->libdir/excel/Worksheet.php");
require_once("$CFG->libdir/excel/Workbook.php");
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$course->shortname"."_quickreport.xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
$workbook = new Workbook("-");
// Creating the first worksheet
$myxls = &$workbook->add_worksheet('Quick Report');
$myxls->write_string(0,0,$quiz->name);
$myxls->set_column(0,0,25);
$formaty =& $workbook->add_format();
$formaty->set_bg_color('yellow');
$formatyc =& $workbook->add_format();
$formatyc->set_bg_color('yellow');
$formatyc->set_bold(1);
$formatyc->set_align('center');
$formatc =& $workbook->add_format();
$formatc->set_align('center');
$formatb =& $workbook->add_format();
$formatb->set_bold(1);
$row = 1;
$col = 2;
/// Print names of all the fields
///First labels to show week/section
if ($course->format == "weeks") {$formatname = "Week";} else {$formatname = "Section";}
foreach($mods_week as $week=>$wkcount){
for ($i = 0; $i < $wkcount;$i++) {
$col++;
$col_label = "$formatname $week";
$myxls->write_string($row,$col,$col_label,$formatb);
}
}
//now labels for module names
$row++;
$col=0;
$myxls->write_string($row,$col,"Student",$formatb);
$col++;
$myxls->write_string($row,$col,"Picture",$formatb);
$col++;
$myxls->write_string($row,$col,"Profile",$formatb);
//get the names of each module instance and put in header
foreach($mod_info as $thiscat=>$thismod){
$modname = ucwords($modnames[$thismod[module]]);
$col++;
$col_label = "$modname $thismod[name]";
$myxls->write_string($row,$col,$col_label,$formatb);
}
/// Print all the user data
$row++;
foreach ($user_contribs as $userid=>$thisuser){
$row++;
$col=0;
$fullname = ucwords($allusers[$userid]->lastname) . ", " . ucwords($allusers[$userid]->firstname);
$myxls->write_string($row,$col,$fullname,$formatb);
$col++;
if($allusers[$userid]->picture){
$myxls->write_string($row,$col,"X",$formatc);
} else {
$myxls->write_string($row,$col,"-",$formatc);
}
$col++;
if (strlen($allusers[$userid]->description) > 10) {
$myxls->write_string($row,$col,"X",$formatc);
} else {
$myxls->write_string($row,$col,"-",$formatc);
}
foreach ($thisuser as $thismod) {
$col++;
$myxls->write_string($row,$col,$thismod,$formatc);
}
}
$workbook->close();
exit;
}
quick_headers($course);
$quick_bgcount = 0;
echo "<table>";
//printer header line with weeks
$options["id"] = $course->id;
$options["download"] = "xls";
print ( "<tr valign=top><td colspan=3>");
print_single_button("quickreport.php", $options, get_string("downloadexcel"));
print ("</td>");
if ($course->format == "weeks") {$formatname = "Week";} else {$formatname = "Section";}
foreach($mods_week as $week=>$wkcount){
print "<td colspan=$wkcount>$formatname $week</td>";
}
echo "<tr valign=top><td width='150'>Student</td><td>Picture</td><td>Profile</td>";
//get the names of each module instance and put in header
foreach($mod_info as $thiscat=>$thismod){
$modname = ucwords($modnames[$thismod[module]]);
print ("<td> $modname <br><font size=-1>$thismod[name]</font></td>");
}
echo "</tr>\n";
foreach ($user_contribs as $userid=>$thisuser){
$quick_bgcount++;
if ($quick_bgcount%3 == 0) {
echo "<tr align=center bgcolor='#ffffff'>";
} else {
echo "<tr align=center>";
}
$fullname = ucwords($allusers[$userid]->lastname) . ", " . ucwords($allusers[$userid]->firstname);
if (!$isstudent){
$fullname = "<a href=user.php?id=$course->id&user=$userid>$fullname</a>";
}
echo "<td align=left><b>$fullname</b></td>";
$picture = print_user_picture($userid, $course->id, $allusers[$userid]->picture, false, true);
echo "<td>" . $picture . "</td>";
if (strlen($allusers[$userid]->description) > 10) {quick_show("X");} else {quick_show("-");}
foreach ($thisuser as $thismod) {
quick_show($thismod);
}
echo "</tr>\n";
}
echo "</table>\n";
print_footer($course);
function quick_findusers($courseid){
global $CFG,$USER,$isstudent;
if ($isstudent){
$studcondition = "AND a.id = $USER->id";
} else {
$studcondition = "";
}
$allusers = get_records_sql("SELECT a.id,a.lastname, a.firstname,a.picture,a.description,b.course
FROM {$CFG->prefix}user a,
{$CFG->prefix}user_students b
WHERE b.course = $courseid AND
b.userid = a.id $studcondition
ORDER BY a.lastname ASC, a.firstname ASC");
return $allusers;
}
function quick_findrecs($tbl1,$tbl2,$pointer,$courseid){
global $CFG;
$allrecs = get_records_sql("SELECT b.id,a.id, c.id,c.lastname, c.firstname,a.course,a.name ,b.userid,b.timemodified, b.$pointer as instance
FROM {$CFG->prefix}$tbl1 a,
{$CFG->prefix}$tbl2 b,
{$CFG->prefix}user c,
{$CFG->prefix}course_modules d
WHERE a.course = $courseid AND
a.id = b.$pointer AND
c.id = b.userid AND
d.instance = b.$pointer");
/// ORDER BY e.section ASC
// print("<h3>All records: $tbl1</h3>");
// print_object($allrecs);
return $allrecs;
}
function quick_findposts($courseid){
global $CFG;
//this will allow records to be identified by Forum but not by thread (no b.id)
$allposts = get_records_sql("SELECT
c.id, c.userid,a.id as forumid,a.name
FROM {$CFG->prefix}forum a,
{$CFG->prefix}forum_discussions b,
{$CFG->prefix}forum_posts c
WHERE b.course = $courseid AND
a.id = b.forum AND
c.discussion = b.id
ORDER BY forumid ASC");
return $allposts;
}
function quick_moduleorder($courseid){
//using course_sections which gives the sections & sequence, build an array with each section + item pair
// echo "<br>Course= " . $courseid . "<br>";
$allmods = get_records("course_sections","course",$courseid,"section","id,section,sequence");
// print_object($allmods);
// $modsequence
foreach ($allmods as $thisweek){
// print_object($thisweek);
if ($thisweek->sequence){
// print ("$thisweek->sequence");
$weeklist = explode(",",$thisweek->sequence);
foreach($weeklist as $activity){
$all_list[] =array("mod"=>$activity,"sec"=>$thisweek->section);
}
// print_object($weeklist);
} else {
// print ("<br>No modules this week<br>");
}
}
return $all_list;
}
function quick_headers($course){
global $CFG;
print_header("$course->shortname: 'Quick Report'", "$course->fullname",
"<A HREF=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</A>
-> 'Quick Report'");
}
function quick_show($x){
echo "<td align=center>";
print ("$x");
echo "</td>";
}
?>
+19 -25
View File
@@ -8,7 +8,6 @@
require_variable($id);
optional_variable($user);
optional_variable($sortby, 'default');
if (! $course = get_record("course", "id", $id) ) {
error("That's an invalid course id");
@@ -34,7 +33,7 @@
}
$userinfo = fullname($u);
}
if ($date)
if ($date)
$dateinfo = userdate($date, get_string("strftimedaydate"));
if ($course->category) {
@@ -43,7 +42,8 @@
<a href=\"recent.php?id=$course->id\">$strrecentactivity</a> -> $userinfo, $dateinfo", "");
} else {
print_header("$course->shortname: $strrecentactivity", "$course->fullname",
"<a href=\"recent.php?id=$course->id\">$strrecentactivity</a> -> $userinfo, $dateinfo", "");
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> ->
<a href=\"recent.php?id=$course->id\">$strrecentactivity</a> -> $userinfo, $dateinfo", "");
}
print_heading("$course->fullname: $userinfo, $dateinfo (".usertimezone().")");
@@ -67,21 +67,15 @@
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strrecentactivity", "");
} else {
print_header("$course->shortname: $strrecentactivity", "$course->fullname",
"$strrecentactivity", "");
"<a href=\"../$CFG->admin/index.php\">$stradministration</a> -> $strrecentactivity", "");
}
print_heading(get_string("activitysince", "", userdate($date)));
if (!isset($advancedfilter)) {
$advancedfilter = 0;
}
print_recent_selector_form($course, $advancedfilter);
}
if (!isset($modid)) {
$modid="activity/All";
}
$tmpmodid = $modid;
switch ($tmpmodid) {
@@ -173,22 +167,22 @@
AND m.id = cm.module $activityfilter
AND cm.id = '$sectionmod'");
$groupmode = groupmode($course, $coursemod);
$groupmode = groupmode($course, $coursemod);
switch ($groupmode) {
case SEPARATEGROUPS : $groupid = mygroupid($course->id); break;
case VISIBLEGROUPS :
case VISIBLEGROUPS :
if ($selectedgroup == "allgroups") {
$groupid = "";
} else {
$groupid = $selectedgroup;
}
}
break;
case NOGROUPS :
default : $groupid = "";
}
}
$libfile = "$CFG->dirroot/mod/$coursemod->name/lib.php";
if (file_exists($libfile)) {
require_once($libfile);
$get_recent_mod_activity = $coursemod->name."_get_recent_mod_activity";
@@ -197,7 +191,7 @@
$activity->type = "activity";
$activity->name = $instance->name;
$activity->visible = $coursemod->visible;
$activity->content->modfullname = $mod->modfullname;
$activity->content->fullname = $mod->modfullname;
$activity->content->modname = $mod->modname;
$activity->content->modid =$mod->id;
$activities[$index] = $activity;
@@ -214,9 +208,9 @@
switch ($sortby) {
case "datedesc" : usort($activities, "compare_activities_by_time_desc"); break;
case "dateasc" : usort($activities, "compare_activities_by_time_asc"); break;
case "default" :
case "default" :
default : $detail = false; $sortby = "default";
}
if (!empty($activities)) {
@@ -240,8 +234,8 @@
// peak at next activity. If it's another section, don't print this one!
// this means there are no activities in the current section
if (($activity->type == "section") &&
(($activity_count == ($key + 1)) ||
if (($activity->type == "section") &&
(($activity_count == ($key + 1)) ||
($activities[$key+1]->type == "section"))) {
continue;
@@ -267,21 +261,21 @@
}
$image = "<img src=\"$CFG->modpixpath/" . $activity->content->modname . "/icon.gif\"" .
"height=16 width=16 alt=\"" . $activity->content->modfullname . "\">";
echo "<ul><h4>$image " . $activity->content->modfullname .
" <a href=\"$CFG->wwwroot/mod/" . $activity->content->modname . "/view.php?" .
echo "<ul><h4>$image " . $activity->content->modfullname .
"<a href=\"$CFG->wwwroot/mod/" . $activity->content->modname . "/view.php?" .
"id=" . $activity->content->modid . "\" $linkformat>" .
$activity->name . "</a></h4></ul>";
}
} else {
if (!$inbox) {
print_simple_box_start("center", "90%");
$inbox = true;
}
$print_recent_mod_activity = $activity->type."_print_recent_mod_activity";
if (function_exists($print_recent_mod_activity)) {
echo '<ul><ul>';
$print_recent_mod_activity($activity, $course->id, $detail);
-80
View File
@@ -1,80 +0,0 @@
<form name="studentform" id="studentform" method="post" action="student.php">
<input type="hidden" name="previoussearch" value="<?php echo $previoussearch ?>">
<input type="hidden" name="id" value="<?php echo $id?>">
<table align="center" border="0" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">
<?php echo count($students) . " ". $strexistingstudents ?>
</td>
<td></td>
<td valign="top">
<?php echo $usercount . " " . $strpotentialstudents ?>
</td>
</tr>
<tr>
<td valign="top">
<select name="removeselect[]" size="20" id="removeselect" multiple
onFocus="document.studentform.add.disabled=true;
document.studentform.remove.disabled=false;
document.studentform.addselect.selectedIndex=-1;">
<?php
foreach ($students as $student) {
$fullname = fullname($student, true);
echo "<option value=\"$student->id\">".$fullname.", ".$student->email."</option>\n";
}
?>
</select></td>
<td valign="top">
<br />
<input name="add" type="submit" id="add" value="&larr;" />
<br />
<input name="remove" type="submit" id="remove" value="&rarr;" />
<br />
</td>
<td valign="top">
<select name="addselect[]" size="20" id="addselect" multiple
onFocus="document.studentform.add.disabled=false;
document.studentform.remove.disabled=true;
document.studentform.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.studentform.add.disabled=true;
document.studentform.remove.disabled=true;
document.studentform.removeselect.selectedIndex=-1;
document.studentform.addselect.selectedIndex=-1;"
onkeydown = "var keyCode = event.which ? event.which : event.keyCode;
if (keyCode == 13) {
document.studentform.previoussearch.value=1;
document.studentform.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>
+115 -84
View File
@@ -1,7 +1,7 @@
<?PHP // $Id$
// Script to assign students to courses
require_once("../config.php");
require_once("../config.php");
define("MAX_USERS_PER_PAGE", 50);
@@ -33,111 +33,142 @@
$strremovestudent = get_string("removestudent");
$strsearch = get_string("search");
$strsearchresults = get_string("searchresults");
$strsearchagain = get_string("searchagain");
$strtoomanytoshow = get_string("toomanytoshow");
$strstudents = get_string("students");
$strshowall = get_string("showall");
$strunenrolallstudents = get_string("unenrolallstudents");
$strunenrolallstudentssure = get_string("unenrolallstudentssure");
if ($course->students != $strstudents) {
$strassignstudents .= " ($course->students)";
$strpotentialstudents .= " ($course->students)";
$strexistingstudents .= " ($course->students)";
if ($search) {
$searchstring = $strsearchagain;
} else {
$searchstring = $strsearch;
}
print_header("$course->shortname: $strassignstudents",
if ($course->students != $strstudents) {
$parastudents = " ($course->students)";
} else {
$parastudents = "";
}
print_header("$course->shortname: $strassignstudents",
"$site->fullname",
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strassignstudents",
"studentform.searchtext");
"<a href=\"view.php?id=$course->id\">$course->shortname</a> -> $strassignstudents", "");
/// Don't allow restricted teachers to even see this page (because it contains
/// a lot of email addresses and access to all student on the server
/// Add a student if one is specified
check_for_restricted_user($USER->username, "$CFG->wwwroot/course/view.php?id=$course->id");
if (!empty($add)) {
if (! enrol_student($add, $course->id)) {
error("Could not add that student to this course!");
}
}
/// Remove a student if one is specified.
if (!empty($remove)) {
if (! unenrol_student($remove, $course->id)) {
error("Could not remove that student from this course!");
}
}
/// Remove all students from specified course
if (!empty($removeall)) {
$students = get_course_students($course->id, "u.lastname ASC, u.firstname ASC");
foreach ($students as $student) {
if (! unenrol_student($student->id, $course->id)) {
$fullname = fullname($student, true);
notify("Could not remove $fullname from this course!");
}
}
}
/// Print a help notice about the need to use this page
if (!$frm = data_submitted()) {
$note = get_string("assignstudentsnote");
if (empty($add) and empty($remove) and empty($search)) {
$note = get_string("assignstudentsnote");
if ($course->password) {
$note .= "<p>".get_string("assignstudentspass", "",
"<a href=\"edit.php?id=$course->id\">$course->password</a>");
$note .= "<p>".get_string("assignstudentspass", "", "<a href=\"edit.php?id=$course->id\">$course->password</a>");
}
print_simple_box($note, "center", "50%");
}
/// A form was submitted so process the input
/// Get all existing students for this course.
$students = get_course_students($course->id, "u.lastname ASC, u.firstname ASC");
/// Print the lists of existing and potential students
echo "<table cellpadding=1 cellspacing=5 align=center>";
echo "<tr><th width=50%>$strexistingstudents$parastudents</th><td>&nbsp;</td><th width=50%>$strpotentialstudents</th></tr>";
echo "<tr><td width=50% nowrap valign=top>";
/// First, show existing students for this course
if (empty($students)) {
echo "<p align=center>$strnoexistingstudents</a>";
$studentlist = "";
} else {
if (!empty($frm->add) and !empty($frm->addselect)) {
if ($course->enrolperiod) {
$timestart = time();
$timeend = $timestart + $course->enrolperiod;
} else {
$timestart = $timeend = 0;
}
foreach ($frm->addselect as $addstudent) {
if (! enrol_student($addstudent, $course->id, $timestart, $timeend)) {
error("Could not add student with id $addstudent to this course!");
}
}
} else if (!empty($frm->remove) and !empty($frm->removeselect)) {
foreach ($frm->removeselect as $removestudent) {
if (! unenrol_student($removestudent, $course->id)) {
error("Could not remove student with id $removestudent from this course!");
}
}
} else if (!empty($frm->showall)) {
unset($frm->searchtext);
$frm->previoussearch = 0;
$studentarray = array();
foreach ($students as $student) {
$studentarray[] = $student->id;
$fullname = fullname($student, true);
echo "<p align=right>$fullname, $student->email &nbsp;&nbsp; <a href=\"student.php?id=$course->id&remove=$student->id\" title=\"$strremovestudent\"><img src=\"../pix/t/right.gif\" border=0></a></p>";
}
$studentlist = implode(",",$studentarray);
unset($studentarray);
// button to unenrol all students from course
echo "<p>&nbsp;</p>\n";
echo "<p align=\"center\">\n";
echo "<input type=\"button\" value=\"$strunenrolallstudents\" ".
" OnClick=\"ctemp = window.confirm('".addslashes($strunenrolallstudentssure)."'); ".
" if(ctemp) window.location.href='student.php?id=$course->id&removeall=1';\"/>\n";
echo "</p>\n";
}
echo "<td>&nbsp;</td>";
echo "<td width=50% nowrap valign=top>";
/// Print list of potential students
$usercount = get_users(false, $search, true, $studentlist, "lastname ASC, firstname ASC");
if ($usercount == 0) {
echo "<p align=center>$strnopotentialstudents</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, $studentlist)) {
error("Could not get users!");
}
foreach ($users as $user) {
$fullname = fullname($user, true);
echo "<p align=left><a href=\"student.php?id=$course->id&add=$user->id\"".
"title=\"$straddstudent\"><img src=\"../pix/t/left.gif\"".
"border=0></a>&nbsp;&nbsp;$fullname, $user->email";
}
}
$previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ;
/// Get all existing students and teachers for this course.
if (!$students = get_course_students($course->id, "u.firstname ASC, u.lastname ASC", "", 0, 99999,
'', '', NULL, '', 'u.id,u.firstname,u.lastname,u.email')) {
$students = array();
}
if (!$teachers = get_course_teachers($course->id)) {
$teachers = array();
}
$existinguserarray = array();
foreach ($students as $student) {
$existinguserarray[] = $student->id;
}
foreach ($teachers as $teacher) {
$existinguserarray[] = $teacher->id;
}
$existinguserlist = implode(',', $existinguserarray);
unset($existinguserarray);
/// Get search results excluding any users already in this course
if (!empty($frm->searchtext) and $previoussearch) {
$searchusers = get_users(true, $frm->searchtext, true, $existinguserlist, 'firstname ASC, lastname ASC',
'', '', 0, 99999, 'id, firstname, lastname, email');
$usercount = get_users(false, '', true, $studentlist);
}
/// If no search results then get potential students for this course excluding users already in course
if (empty($searchusers)) {
if (!$users = get_users(true, '', true, $existinguserlist, 'firstname ASC, lastname ASC', '', '',
0, 99999, 'id, firstname, lastname, email') ) {
$users = array();
}
$usercount = count($users);
if ($search or $usercount > MAX_USERS_PER_PAGE) {
echo "<form action=student.php method=post>";
echo "<input type=hidden name=id value=\"$course->id\">";
echo "<input type=text name=search size=20>";
echo "<input type=submit value=\"$searchstring\">";
echo "</form>";
}
$searchtext = (isset($frm->searchtext)) ? $frm->searchtext : "";
$previoussearch = ($previoussearch) ? '1' : '0';
print_simple_box_start("center", "", "$THEME->cellheading");
include('student.html');
print_simple_box_end();
echo "</tr></table>";
print_footer();
+2 -2
View File
@@ -20,8 +20,8 @@
require_login($course->id);
if ($user->id != $USER->id and !isteacheredit($course->id)) {
error("You must be a teacher with editing rights to do this");
if ($user->id != $USER->id and !isteacher($course->id)) {
error("You must be a teacher to do this");
}
if ($user->id == $USER->id and !$CFG->allowunenroll) {
+20 -11
View File
@@ -2,9 +2,9 @@
// Display the course home page.
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");
optional_variable($id);
optional_variable($name);
@@ -33,6 +33,21 @@
$course->format = 'weeks'; // Default format is weeks
}
// Can't avoid this... :(
switch($course->format) {
case 'weeks':
$courseformat = COURSE_FORMAT_WEEKS;
break;
case 'topics':
$courseformat = COURSE_FORMAT_TOPICS;
break;
case 'social':
$courseformat = COURSE_FORMAT_SOCIAL;
break;
default:
$courseformat = 0;
}
// Doing this now so we can pass the results to block_action()
// and dodge the overhead of doing the same work twice.
@@ -103,13 +118,7 @@
// If it's not hidden or displayed right now...
if(!in_array($recblock->id, $allblocks) && !in_array(-($recblock->id), $allblocks)) {
// And if it's applicable for display in this format...
$formats = block_method_result($recblock->name, 'applicable_formats');
if( isset($formats[$course->format]) ? $formats[$course->format] : !empty($formats['all'])) {
// Translation: if the course format is explicitly accepted/rejected, use
// that setting. Otherwise, fallback to the 'all' format. The empty() test
// uses the trick that empty() fails if 'all' is either !isset() or false.
if(block_method_result($recblock->name, 'applicable_formats') & $courseformat) {
// Add it to the missing blocks
$missingblocks[] = $recblock->id;
}
@@ -190,6 +199,6 @@
require("$CFG->dirroot/course/format/$course->format/format.php"); // Include the actual course format
print_footer(NULL, $course);
print_footer();
?>
+1 -13
View File
@@ -1,3 +1,4 @@
body, td, th, li {
font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
}
@@ -116,16 +117,3 @@ ul {
margin-top: 10px;
}
.commandline {
font-family: "Courier New", Courier, mono;
font-size: x-small;
background-color: #FBFBFB;
margin: auto auto 20px 30px;
padding: 5px;
width: compact;
font-weight: bold;
border: 1px solid #999999;
white-space: nowrap;
clear: both;
float: none;
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

-15
View File
@@ -1,15 +0,0 @@
ENROLMENT MODULES
-----------------
(Yes, that's the correct English spelling ;-) )
enrol.class.php contains the base class and explains
all the possible functions that an enrolment module
can have.
Each plugin is in a subfolder here and extends the
base class as necessary.
Martin Dougiamas and Shane Elliott, Moodle.com
-118
View File
@@ -1,118 +0,0 @@
<table cellspacing="0" cellpadding="5" border="0" align="center">
<tr valign="top">
<td align="right"><p>enrol_dbtype:</p></td>
<td>
<?php $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
foreach ($dbtypes as $dbtype) {
$dboptions[$dbtype] = $dbtype;
}
choose_from_menu($dboptions, "enrol_dbtype", $frm->enrol_dbtype, '', '', '');
?>
</td>
<td>
<?php print_string("dbtype","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_dbhost:</p></td>
<td>
<input size="15" type="text" name="enrol_dbhost" value="<?php echo $frm->enrol_dbhost ?>" />
</td>
<td>
<?php print_string("dbhost","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_dbuser:</p></td>
<td>
<input size="15" type="text" name="enrol_dbuser" value="<?php echo $frm->enrol_dbuser ?>" />
</td>
<td>
<?php print_string("dbuser","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_dbpass:</p></td>
<td>
<input size="15" type="text" name="enrol_dbpass" value="<?php echo $frm->enrol_dbpass ?>" />
</td>
<td>
<?php print_string("dbpass","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_dbname:</p></td>
<td>
<input size="15" type="text" name="enrol_dbname" value="<?php echo $frm->enrol_dbname ?>" />
</td>
<td>
<?php print_string("dbname","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_dbtable:</p></td>
<td>
<input size="15" type="text" name="enrol_dbtable" value="<?php echo $frm->enrol_dbtable ?>" />
</td>
<td>
<?php print_string("dbtable","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_localcoursefield:</p></td>
<td>
<input size="15" type="text" name="enrol_localcoursefield" value="<?php echo $frm->enrol_localcoursefield ?>" />
</td>
<td>
<?php print_string("localcoursefield","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_localuserfield:</p></td>
<td>
<input size="15" type="text" name="enrol_localuserfield" value="<?php echo $frm->enrol_localuserfield ?>" />
</td>
<td>
<?php print_string("localuserfield","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_remotecoursefield:</p></td>
<td>
<input size="15" type="text" name="enrol_remotecoursefield" value="<?php echo $frm->enrol_remotecoursefield ?>" />
</td>
<td>
<?php print_string("remotecoursefield","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_remoteuserfield:</p></td>
<td>
<input size="15" type="text" name="enrol_remoteuserfield" value="<?php echo $frm->enrol_remoteuserfield ?>" />
</td>
<td>
<?php print_string("remoteuserfield","enrol_database") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_allowinternal:</p></td>
<td>
<input type="checkbox" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string('allowinternal') ?>
</td>
</tr>
</table>
-161
View File
@@ -1,161 +0,0 @@
<?php // $Id$
require_once("$CFG->dirroot/enrol/enrol.class.php");
class enrolment_plugin extends enrolment_base {
var $log;
/// Leave get_teacher_courses() function unchanged for the time being
/// Leave cron() function unchanged
/// Overide the base get_student_courses() function
function get_student_courses(&$user) {
global $CFG;
parent::get_student_courses($user);
// This is a hack to workaround what seems to be a bug in ADOdb with accessing
// 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 (strpos($CFG->prefix, $CFG->dbname) === false) {
$CFG->prefix = "$CFG->dbname.$CFG->prefix";
}
// Connect to the external database
$enroldb = &ADONewConnection($CFG->enrol_dbtype);
if ($enroldb->PConnect($CFG->enrol_dbhost,$CFG->enrol_dbuser,$CFG->enrol_dbpass,$CFG->enrol_dbname)) {
foreach ($user->student as $courseid=>$value) {
/// Get the value of the local course field
$localcoursevalue = get_field("course", $CFG->enrol_localcoursefield, "id", $courseid);
/// Find a record in the external database that matches the local course field and local user field
/// to the respective remote fields
$rs = $enroldb->Execute("SELECT * FROM $CFG->enrol_dbtable
WHERE $CFG->enrol_remotecoursefield = '$localcoursevalue'
AND $CFG->enrol_remoteuserfield = '{$user->$CFG->enrol_localuserfield}' ");
/// If no records existed then student has been unenrolled externally.
/// Unenrol locally and remove entry from the $user->student array
if (! ($rs->RecordCount()) ) {
unenrol_student($user->id, $courseid);
unset ($user->student[$courseid]);
}
}
$enroldb->Close();
}
}
/// Override the base print_entry() function
function print_entry($course) {
global $CFG;
if (! empty($CFG->enrol_allowinternal) ) {
parent::print_entry($course);
} else {
print_header();
notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
}
}
/// Override the base check_entry() function
function check_entry($form, $course) {
global $CFG;
if (! empty($CFG->enrol_allowinternal) ) {
parent::check_entry($form, $course);
}
}
/// Overide the get_access_icons() function
function get_access_icons($course) {
}
/// Overrise the base config_form() function
function config_form($frm) {
global $CFG;
include("$CFG->dirroot/enrol/database/config.html");
}
/// Override the base process_config() function
function process_config($config) {
if (!isset($config->enrol_dbtype)) {
$config->enrol_dbtype = 'mysql';
}
set_config('enrol_dbtype', $config->enrol_dbtype);
if (!isset($config->enrol_dbhost)) {
$config->enrol_dbhost = '';
}
set_config('enrol_dbhost', $config->enrol_dbhost);
if (!isset($config->enrol_dbuser)) {
$config->enrol_dbuser = '';
}
set_config('enrol_dbuser', $config->enrol_dbuser);
if (!isset($config->enrol_dbpass)) {
$config->enrol_dbpass = '';
}
set_config('enrol_dbpass', $config->enrol_dbpass);
if (!isset($config->enrol_dbname)) {
$config->enrol_dbname = '';
}
set_config('enrol_dbname', $config->enrol_dbname);
if (!isset($config->enrol_dbtable)) {
$config->enrol_dbtable = '';
}
set_config('enrol_dbtable', $config->enrol_dbtable);
if (!isset($config->enrol_localcoursefield)) {
$config->enrol_localcoursefield = '';
}
set_config('enrol_localcoursefield', $config->enrol_localcoursefield);
if (!isset($config->enrol_localuserfield)) {
$config->enrol_localuserfield = '';
}
set_config('enrol_localuserfield', $config->enrol_localuserfield);
if (!isset($config->enrol_remotecoursefield)) {
$config->enrol_remotecoursefield = '';
}
set_config('enrol_remotecoursefield', $config->enrol_remotecoursefield);
if (!isset($config->enrol_remoteuserfield)) {
$config->enrol_remoteuserfield = '';
}
set_config('enrol_remoteuserfield', $config->enrol_remoteuserfield);
if (!isset($config->enrol_allowinternal)) {
$config->enrol_allowinternal = '';
}
set_config('enrol_allowinternal', $config->enrol_allowinternal);
return true;
}
} // end of class
?>
-335
View File
@@ -1,335 +0,0 @@
<?php /// $Id$
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
// //
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.org //
// //
// Copyright (C) 2004 Martin Dougiamas http://moodle.com //
// //
// 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, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details: //
// //
// http://www.gnu.org/copyleft/gpl.html //
// //
///////////////////////////////////////////////////////////////////////////
/**
* enrolment_base is the base class for enrolment plugins
*
* This class provides all the functionality for an enrolment plugin
* In fact it includes all the code for the default, "internal" method
* so that other plugins can override these as necessary.
*/
class enrolment_base {
var $errormsg;
/**
* Returns information about the courses a student has access to
*
* Set the $user->student course array
* Set the $user->timeaccess course array
*
* @param user referenced object, must contain $user->id already set
*/
function get_student_courses(&$user) {
if ($students = get_records("user_students", "userid", $user->id)) {
$currenttime = time();
foreach ($students as $student) {
/// Is course visible?
if (get_field("course", "visible", "id", $student->course)) {
/// Is the student enrolment active right now?
if ( ( $student->timestart == 0 or ( $currenttime > $student->timestart )) and
( $student->timeend == 0 or ( $currenttime < $student->timeend )) ) {
$user->student[$student->course] = true;
$user->timeaccess[$student->course] = $student->timeaccess;
}
}
}
}
}
/**
* Returns information about the courses a student has access to
*
* Set the $user->teacher course array
* Set the $user->teacheredit course array
* Set the $user->timeaccess course array
*
* @param user referenced object, must contain $user->id already set
*/
function get_teacher_courses(&$user) {
if ($teachers = get_records("user_teachers", "userid", $user->id)) {
$currenttime = time();
foreach ($teachers as $teacher) {
/// Is teacher only teaching this course for a specific time period?
if ( ( $teacher->timestart == 0 or ( $currenttime > $teacher->timestart )) and
( $teacher->timeend == 0 or ( $currenttime < $teacher->timeend )) ) {
$user->teacher[$teacher->course] = true;
if ($teacher->editall) {
$user->teacheredit[$teacher->course] = true;
}
$user->timeaccess[$teacher->course] = $teacher->timeaccess;
}
}
}
}
/**
* Prints the entry form/page for this enrolment
*
* This is only called from course/enrol.php
* Most plugins will probably override this to print payment
* forms etc, or even just a notice to say that manual enrolment
* is disabled
*
* @param course current course object
*/
function print_entry($course) {
global $CFG, $USER, $SESSION, $THEME;
$strloginto = get_string("loginto", "", $course->shortname);
$strcourses = get_string("courses");
/// 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($_GET['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 ($course->enrolperiod) {
$timestart = time();
$timeend = time() + $course->enrolperiod;
} else {
$timestart = $timeend = 0;
}
if (! enrol_student($USER->id, $course->id, $timestart, $timeend)) {
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";
}
redirect($destination);
}
}
$teacher = get_teacher($course->id);
if (!isset($password)) {
$password = "";
}
print_header($strloginto, $course->fullname, "<A HREF=\".\">$strcourses</A> -> $strloginto", "form.password");
print_course($course);
include("$CFG->dirroot/enrol/internal/enrol.html");
print_footer();
}
/**
* The other half to print_entry, this checks the form data
*
* This function checks that the user has completed the task on the
* enrolment entry page and then enrolls them.
*
* @param form the form data submitted, as an object
* @param course the current course, as an object
*/
function check_entry($form, $course) {
global $CFG, $USER, $SESSION, $THEME;
if ($form->password == $course->password) {
if (isguest()) {
add_to_log($course->id, "course", "guest", "view.php?id=$course->id", $_SERVER['REMOTE_ADDR']);
} else { /// Update or add new enrolment
if ($course->enrolperiod) {
$timestart = time();
$timeend = $timestart + $course->enrolperiod;
} else {
$timestart = $timeend = 0;
}
if (! enrol_student($USER->id, $course->id, $timestart, $timeend)) {
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 {
$this->errormsg = get_string("enrolmentkeyhint", "", substr($course->password,0,1));
}
}
/**
* Prints a form for configuring the current enrolment plugin
*
* This function is called from admin/enrol.php, and outputs a
* full page with a form for defining the current enrolment plugin.
*
* @param page an object containing all the data for this page
*/
function config_form($page) {
}
/**
* Processes and stored configuration data for the enrolment plugin
*
* Processes and stored configuration data for the enrolment plugin
*
* @param config all the configuration data as entered by the admin
*/
function process_config($config) {
$return = true;
foreach ($config as $name => $value) {
if (!set_config($name, $value)) {
$return = false;
}
}
return $return;
}
/**
* This function is run by admin/cron.php every time
*
* The cron function can perform regular checks for the current
* enrollment plugin. For example it can check a foreign database,
* all look for a file to pull data in from
*
*/
function cron() {
// Delete students from all courses where their enrolment period has expired
$select = "timeend > '0' AND timeend < '" . time() . "'";
if ($students = get_records_select('user_students', $select)) {
foreach ($students as $student) {
unenrol_student($student->userid, $student->course);
}
}
if ($teachers = get_records_select('user_teachers', $select)) {
foreach ($teachers as $teacher) {
remove_teacher($teacher->userid, $teacher->course);
}
}
}
/**
* Returns the relevant icons for a course
*
* Returns the relevant icons for a course
*
* @param course the current course, as an object
*/
function get_access_icons($course) {
global $CFG;
$str = '';
if ($course->guest) {
$strallowguests = get_string("allowguests");
$str .= "<a title=\"$strallowguests\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
$str .= "<img vspace=4 alt=\"$strallowguests\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/guest.gif\"></a>&nbsp;&nbsp;";
}
if ($course->password) {
$strrequireskey = get_string("requireskey");
$str .= "<a title=\"$strrequireskey\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">";
$str .= "<img vspace=4 alt=\"$strrequireskey\" height=16 width=16 border=0 src=\"$CFG->pixpath/i/key.gif\"></a>";
}
return $str;
}
} /// end of class
?>
-53
View File
@@ -1,53 +0,0 @@
<table cellspacing="0" cellpadding="5" border="0" align="center">
<tr valign="top">
<td align="right"><p>enrol_flatfilelocation:</p></td>
<td>
<input type="text" size="20" name="enrol_flatfilelocation" value="<?php echo $frm->enrol_flatfilelocation ?>" />
</td>
<td>
<?php print_string("location", "enrol_flatfile") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_mailstudents:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailstudents") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_mailteachers:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailteachers") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_mailadmins:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailadmins") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_allowinternal:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string('allowinternal') ?>
</td>
</tr>
</table>
-273
View File
@@ -1,273 +0,0 @@
<?php
require_once("$CFG->dirroot/enrol/enrol.class.php");
// The following flags are set in the configuration
// $CFG->enrol_flatfilelocation: where is the file we are looking for?
// $CFG->enrol_allowinternal: allow internal enrolment in courses
// $CFG->enrol_emailstudents: send email to students when they are enrolled in a course
// $CFG->enrol_emailteachers: send email to teachers when they are enrolled in a course
// $CFG->enrol_emailadmins: email the log from the cron job to the admin
class enrolment_plugin extends enrolment_base {
var $log;
/// Override the base print_entry() function
function print_entry($course) {
global $CFG;
if (! empty($CFG->enrol_allowinternal) ) {
parent::print_entry($course);
} else {
print_header();
notice(get_string("enrolmentnointernal"), $CFG->wwwroot);
}
}
/// Override the base check_entry() function
function check_entry($form, $course) {
global $CFG;
if (! empty($CFG->enrol_allowinternal) ) {
parent::check_entry($form, $course);
}
}
/// Override the base config_form() function
function config_form($frm) {
global $CFG;
include ("$CFG->dirroot/enrol/flatfile/config.html");
}
/// Override the base process_config() function
function process_config($config) {
if (!isset($config->enrol_flatfilelocation)) {
$config->enrol_flatfilelocation = '';
}
set_config('enrol_flatfilelocation', $config->enrol_flatfilelocation);
if (!isset($config->enrol_mailstudents)) {
$config->enrol_mailstudents = '';
}
set_config('enrol_mailstudents', $config->enrol_mailstudents);
if (!isset($config->enrol_mailteachers)) {
$config->enrol_mailteachers = '';
}
set_config('enrol_mailteachers', $config->enrol_mailteachers);
if (!isset($config->enrol_mailadmins)) {
$config->enrol_mailadmins = '';
}
set_config('enrol_mailadmins', $config->enrol_mailadmins);
if (!isset($config->enrol_allowinternal)) {
$config->enrol_allowinternal = '';
}
set_config('enrol_allowinternal', $config->enrol_allowinternal);
return true;
}
/**
* Override the base cron() function to read in a file
*
* Comma separated file assumed to have four or six fields per line:
* operation, role, idnumber(user), idnumber(course) [, starttime, endtime]
* where:
* operation = add | del
* role = student | teacher | teacheredit
* idnumber(user) = idnumber in the user table NB not id
* idnumber(course) = idnumber in the course table NB not id
* starttime = start time (in seconds since epoch) - optional
* endtime = end time (in seconds since epoch) - optional
*/
function cron() {
global $CFG;
/// call the base class
parent::cron();
if (empty($CFG->enrol_flatfilelocation)) {
$filename = "$CFG->dataroot/1/enrolments.txt"; // Default location
} else {
$filename = $CFG->enrol_flatfilelocation;
}
if ( file_exists($filename) ) {
$this->log = userdate(time()) . "\n";
$this->log .= "Flatfile enrol cron found file: $filename\n\n";
if (($fh = fopen($filename, "r")) != false) {
$line = 0;
while (!feof($fh)) {
$line++;
$fields = explode( ",", str_replace( "\r", "", fgets($fh) ) );
/// If a line is incorrectly formatted ie does not have 4 comma separated fields then ignore it
if (count($fields) != 4 and count($fields) !=6) {
if ( count($fields) > 1 or strlen($fields[0]) > 1) { // no error for blank lines
$this->log .= "$line: Line incorrectly formatted - ignoring\n";
}
continue;
}
$fields[0] = trim(strtolower($fields[0]));
$fields[1] = trim(strtolower($fields[1]));
$fields[2] = trim($fields[2]);
$fields[3] = trim($fields[3]);
$this->log .= "$line: $fields[0] $fields[1] $fields[2] $fields[3] ";
if (!empty($fields[5])) {
$fields[4] = (int)trim($fields[4]);
$fields[5] = (int)trim($fields[5]);
$this->log .= "$fields[4] $fields[5]";
} else {
$fields[4] = 0;
$fields[5] = 0;
}
$this->log .= ":";
/// check correct formatting of operation field
if ($fields[0] != "add" and $fields[0] != "del") {
$this->log .= "Unknown operation in field 1 - ignoring line\n";
continue;
}
/// check correct formatting of role field
if ($fields[1] != "student" and $fields[1] != "teacher" and $fields[1] != "teacheredit") {
$this->log .= "Unknown role in field2 - ignoring line\n";
continue;
}
if (! $user = get_record("user", "idnumber", $fields[2]) ) {
$this->log .= "Unknown user idnumber in field 3 - ignoring line\n";
continue;
}
if (! $course = get_record("course", "idnumber", $fields[3]) ) {
$this->log .= "Unknown course idnumber in field 4 - ignoring line\n";
continue;
}
if ($fields[4] > $fields[5]) {
$this->log .= "Start time was later than end time - ignoring line\n";
continue;
}
unset($elog);
switch ($fields[1]) {
case "student":
if ($fields[0] == "add") {
if (! enrol_student($user->id, $course->id, $fields[4], $fields[5])) {
$elog = "Error enrolling in course\n";
}
} else {
if (! unenrol_student($user->id, $course->id)) {
$elog = "Error unenrolling from course\n";
}
}
break;
case "teacher":
if ($fields[0] == "add") {
if (! add_teacher($user->id, $course->id, 0, '', $fields[4], $fields[5])) {
$elog = "Error adding teacher to course\n";
}
} else {
if (! remove_teacher($user->id, $course->id)) {
$elog = "Error removing teacher from course\n";
}
}
break;
case "teacheredit":
if ($fields[0] == "add") {
if (! add_teacher($user->id, $course->id, 1, '', $fields[4], $fields[5])) {
$elog = "Error adding teacher to course\n";
}
} else {
if (! remove_teacher($user->id, $course->id)) {
$elog = "Error removing teacher from course\n";
}
}
break;
default: // should never get here as checks made above for correct values of $fields[1]
} // end of switch
if ( empty($elog) and ($fields[0] == "add") ) {
if ($fields[1] == "student") {
if (! $teacher = get_teacher($course->id)) {
$teacher = get_admin();
}
} else {
$teacher = get_admin();
}
if (!empty($CFG->enrol_mailstudents)) {
$a->coursename = "$course->fullname";
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id";
email_to_user($user, $teacher, get_string("enrolmentnew", '', $course->shortname),
get_string('welcometocoursetext', '', $a));
}
if (!empty($CFG->enrol_mailteachers)) {
$a->course = "$course->fullname";
$a->user = fullname($user);
email_to_user($teacher, $user, get_string("enrolmentnew", '', $course->shortname),
get_string('enrolmentnewuser', '', $a));
}
}
if (empty($elog)) {
$elog = "OK\n";
}
$this->log .= $elog;
} // end of while loop
fclose($fh);
} // end of if(file_open)
if(! @unlink($filename)) {
email_to_user(get_admin(), get_admin(), get_string("filelockedmailsubject", "enrol_flatfile"), get_string("filelockedmail", "enrol_flatfile", $filename));
$this->log .= "Error unlinking file $filename\n";
}
if (!empty($CFG->enrol_mailadmins)) {
email_to_user(get_admin(), get_admin(), "Flatfile Enrolment Log", $this->log);
}
} // end of if(file_exists)
} // end of function
} // end of class
?>
-6
View File
@@ -1,6 +0,0 @@
add, student, 5, CF101
add, teacher, 6, CF101
add, teacheredit, 7, CF101
del, student, 8, CF101
del, student, 17, CF101
add, student, 21, CF101, 1091115000, 1091215000
-1
View File
@@ -1 +0,0 @@
<table cellpadding="20" align="center"> <tr valign="top"> <td> <p align="center"> <?php if ($teacher) { $site = get_site(); $teachername = "<a href=\"../user/view.php?id=$teacher->id&course=$site->id\">". "$teacher->firstname $teacher->lastname</a>."; } else { $teachername = get_string("yourteacher", "", strtolower($course->teacher)); } print_string("enrolmentkeyfrom", "", $teachername); ?> </p> </td> </tr> <tr valign=top> <td class="generalbox" bgcolor="<?php p($THEME->cellcontent) ?>"> <center><?php if (! empty($this->errormsg)) {formerr($this->errormsg);} ?></center> <form name="form" method="post" action="enrol.php"> <table> <tr> <td width="50%" align="right"><p><?php print_string("enrolmentkey") ?>:</p></td> <td width="50%"> <input type="password" name="password" size="20" value="<?php p($password) ?>" > <input type="hidden" name="id" value="<?php p($course->id) ?>" > </td> <tr> <td width="50%">&nbsp;</td> <td width="50%"> <table cellpadding="1" cellspacing="0" align="center"> <tr> <td><input type="submit" value="<?php print_string("login") ?>">&nbsp;&nbsp;</form></td> <td><form action="<?php p($CFG->wwwroot)?>/index.php" method=post> <input type="submit" value="<?php print_string("cancel") ?>"></form></td> </tr> </table> </td> </table> </td> </tr> </table>
-8
View File
@@ -1,8 +0,0 @@
<?php
require_once("$CFG->dirroot/enrol/enrol.class.php");
class enrolment_plugin extends enrolment_base {
/// nothing to do - it's already perfect!
}
?>
-63
View File
@@ -1,63 +0,0 @@
<table cellspacing="0" cellpadding="5" border="0" align="center">
<tr valign="top">
<td align="right"><p>enrol_cost:</p></td>
<td>
<input type="text" size="5" name="enrol_cost" value="<?php echo $frm->enrol_cost ?>" />
</td>
<td>
<?php print_string("costdefault") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_currency:</p></td>
<td>
<?php choose_from_menu ($paypalcurrencies, "enrol_currency", $frm->enrol_currency, "","", "") ?>
</td>
<td>
<?php print_string("currency") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_paypalbusiness:</p></td>
<td>
<input type="text" name="enrol_paypalbusiness" value="<?php echo $frm->enrol_paypalbusiness ?>" />
</td>
<td>
<?php print_string("business", "enrol_paypal") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_mailstudents:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailstudents") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_mailteachers:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailteachers") ?>
</td>
</tr>
<tr valign="top">
<td align="right"><p>enrol_mailadmins:</p></td>
<td>
<input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
</td>
<td>
<?php print_string("mailadmins") ?>
</td>
</tr>
</table>
-19
View File
@@ -1,19 +0,0 @@
<?PHP //$Id$
// MySQL commands for upgrading this enrolment module
function paypal_upgrade($oldversion=0) {
global $CFG, $THEME, $db;
$result = true;
if ($oldversion == 0) {
modify_database("$CFG->dirroot/enrol/paypal/db/mysql.sql");
}
return $result;
}
?>
-23
View File
@@ -1,23 +0,0 @@
CREATE TABLE `prefix_enrol_paypal` (
`id` int(10) unsigned NOT NULL auto_increment,
`business` varchar(255) NOT NULL default '',
`receiver_email` varchar(255) NOT NULL default '',
`receiver_id` varchar(255) NOT NULL default '',
`item_name` varchar(255) NOT NULL default '',
`courseid` int(10) unsigned NOT NULL default '0',
`userid` int(10) unsigned NOT NULL default '0',
`memo` varchar(255) NOT NULL default '',
`tax` varchar(255) NOT NULL default '',
`option_name1` varchar(255) NOT NULL default '',
`option_selection1_x` varchar(255) NOT NULL default '',
`option_name2` varchar(255) NOT NULL default '',
`option_selection2_x` varchar(255) NOT NULL default '',
`payment_status` varchar(255) NOT NULL default '',
`pending_reason` varchar(255) NOT NULL default '',
`reason_code` varchar(30) NOT NULL default '',
`txn_id` varchar(255) NOT NULL default '',
`parent_txn_id` varchar(255) NOT NULL default '',
`payment_type` varchar(30) NOT NULL default '',
`timeupdated` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`id`)
) TYPE=MyISAM COMMENT='Holds all known information about Paypal transactions' ;

Some files were not shown because too many files have changed in this diff Show More