Compare commits
377 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d9a81c347 | |||
| 262ec64be3 | |||
| 4541181369 | |||
| 4d0036e8be | |||
| 0e83e4f5ca | |||
| d40b3e1034 | |||
| 72343793f6 | |||
| d4e8a03c53 | |||
| 6c979e8a24 | |||
| 794e4a05a3 | |||
| d067b2005b | |||
| c6d79e46d9 | |||
| 2b8a5e83ac | |||
| 2a1e7c302c | |||
| 59b4825741 | |||
| 38d0c10e3c | |||
| 50d2685d0e | |||
| f187b7f98b | |||
| 0726456942 | |||
| 1bf6b1cc18 | |||
| efbd1fc514 | |||
| 9900b2f103 | |||
| 2716e73e9e | |||
| abe51bbed9 | |||
| cd09750495 | |||
| 3377c60427 | |||
| 5242595975 | |||
| 2605a5ba8f | |||
| 1aa43ea576 | |||
| f12b2a7d5d | |||
| 834d5863b9 | |||
| c8825cfd2d | |||
| 380b3b305c | |||
| 2ae294c9d6 | |||
| cb82934b8d | |||
| c1c70a909a | |||
| 541ba098e7 | |||
| c298a8b8e0 | |||
| 94863d1946 | |||
| 6b8155d4a8 | |||
| d9e4f9eb2a | |||
| d864c083c2 | |||
| 80970e2938 | |||
| c196e0f3cb | |||
| 5a6dba91bb | |||
| 4600286cd2 | |||
| 4bbd7130f1 | |||
| b862c77e93 | |||
| 1a149c0d33 | |||
| 84f3391271 | |||
| 1f66b55e6e | |||
| 4339f32452 | |||
| 00b8db5f4f | |||
| b0bba0e704 | |||
| d501331e75 | |||
| ac9ed861a4 | |||
| effa8cd5d1 | |||
| 3dbdb64c89 | |||
| 660e6d5f9d | |||
| 277ea82b49 | |||
| dce99d41f4 | |||
| 44c4e47a1c | |||
| ba4f9b230f | |||
| 2ba777cd5a | |||
| 03b40486ca | |||
| ea257a167e | |||
| a666b9dbcf | |||
| 986a50e26d | |||
| 625c8a70aa | |||
| 66a14b7292 | |||
| 0a265f0fcd | |||
| be8137a81b | |||
| 8bdb6d99a8 | |||
| 07c8c52cbf | |||
| b588ef46f4 | |||
| cdb048acd7 | |||
| dd9a68560e | |||
| c731399ff1 | |||
| c8d483b80c | |||
| 75775efcf7 | |||
| de8c6852d3 | |||
| 36d7c02847 | |||
| 64375cb146 | |||
| 1f7569c38a | |||
| d636096334 | |||
| 1f1a9a809c | |||
| fe19f91525 | |||
| aea38264b5 | |||
| 44e2500992 | |||
| ecf140979f | |||
| 9531202c10 | |||
| a5436ee747 | |||
| 826067335c | |||
| d5306794ec | |||
| 89905101b7 | |||
| f6849778a7 | |||
| c0f904046c | |||
| 23da79eff2 | |||
| 176d1229af | |||
| 6aef11722c | |||
| 5218d67aca | |||
| 9b037d3842 | |||
| 6481349eb3 | |||
| 9abb0f813a | |||
| 914d8f5801 | |||
| 7a553f06a3 | |||
| a9fd047eea | |||
| b225c41b53 | |||
| 2d0ee29b15 | |||
| 0bfac2fe7a | |||
| c7d9b99dae | |||
| f87c87b9ba | |||
| 88c0c27c83 | |||
| 395c75becd | |||
| b02e4ee384 | |||
| fae3f45758 | |||
| 5d46f73a3c | |||
| 1ac7d05730 | |||
| 27f60090f6 | |||
| 28dc928f43 | |||
| 7fe8550e18 | |||
| c9aecec6be | |||
| 69b693dbc9 | |||
| 0803379406 | |||
| 4eb4b874ba | |||
| aff589d128 | |||
| c4c9a5d860 | |||
| 805720ebd3 | |||
| af70ea6a96 | |||
| ae8df5acdf | |||
| 1e900c139d | |||
| ef93a24f23 | |||
| 47737013d3 | |||
| 476b3195fa | |||
| ed7ce12186 | |||
| de78b7e81b | |||
| bf48c7abcd | |||
| 26e6e8c048 | |||
| d0bdb4d3c9 | |||
| 7af4d79611 | |||
| 49f020ec0c | |||
| a4bb593422 | |||
| d799a9aef2 | |||
| 6b611eb82d | |||
| 1e04f3179a | |||
| ec7418d3ce | |||
| 6d895ae5e9 | |||
| b194dfbf15 | |||
| 278bd07a17 | |||
| 2aa86d2d33 | |||
| 74e97cf096 | |||
| d86503c7cf | |||
| ee16e98eb1 | |||
| 800085d9ae | |||
| c8937fb8ea | |||
| 08d1ef9d83 | |||
| 2fd3511227 | |||
| 3abe15dd14 | |||
| 213b568441 | |||
| 91a036b599 | |||
| 5484222182 | |||
| 321a23004b | |||
| 272fecfce4 | |||
| ffccc532c6 | |||
| ad6ae2c4e5 | |||
| 76816913ed | |||
| 4c74601224 | |||
| b4c8301258 | |||
| c446109283 | |||
| b4ab174902 | |||
| 2deb9e2501 | |||
| be02c7520a | |||
| 364f1151a6 | |||
| fb3a583b2b | |||
| 83bf9af99e | |||
| a00095da48 | |||
| 3ed4068ee1 | |||
| 949f570992 | |||
| 2bef2c7dca | |||
| 36e32ba459 | |||
| baa1209e37 | |||
| 4878c5a6d2 | |||
| 5d4353a158 | |||
| 446088fa5d | |||
| 33f519119b | |||
| 7acc6626c5 | |||
| e616f403eb | |||
| b51b3dd05c | |||
| e4fd3f4f06 | |||
| bce3627ed9 | |||
| 567596e8c2 | |||
| f703afe925 | |||
| 6483738028 | |||
| 086018ae01 | |||
| ae04fba0cd | |||
| db9529f65f | |||
| 97ae5efdf0 | |||
| a636a125da | |||
| b3ed98f7ba | |||
| 46941b6043 | |||
| 670cced63a | |||
| f6c74641dd | |||
| 3141843a1a | |||
| 4da8b58b36 | |||
| 7c8304a6c9 | |||
| fee588e503 | |||
| 42e2fba317 | |||
| 48c54e90ce | |||
| dad92a063d | |||
| 9033ed3212 | |||
| 146132bffc | |||
| 331c6f4620 | |||
| ed501d3e98 | |||
| d2780b2594 | |||
| 3054f2faf2 | |||
| 3c0fd35102 | |||
| 67e55d7e0b | |||
| 5b0d565bcd | |||
| ade83600e1 | |||
| b87862b89a | |||
| 30faf003ba | |||
| c9a53bb206 | |||
| 6fb6c9d960 | |||
| 5d502dc3e4 | |||
| 30d36e2f3e | |||
| 989e230b3d | |||
| f45b5a05c0 | |||
| 48cd99809d | |||
| 6ebca3c77e | |||
| 2e311d898c | |||
| a87bbde1a1 | |||
| 71777355b1 | |||
| 01d50616ee | |||
| d44136dee7 | |||
| 5c9fe50894 | |||
| e620c033cb | |||
| d3b5c5f081 | |||
| 6936ef91df | |||
| 3f94709321 | |||
| 6428434a5f | |||
| 9bb14972af | |||
| 01f3128264 | |||
| 3e55705455 | |||
| 889209d1fa | |||
| efc346b5ca | |||
| 5eb64d447e | |||
| 9446d15749 | |||
| dc28278d18 | |||
| d04f1621e8 | |||
| ef38765d91 | |||
| 7c3c8b7249 | |||
| eb676fdf9a | |||
| bf55369e5d | |||
| 56a6a9ff49 | |||
| 91e4976c08 | |||
| 299560a9fc | |||
| 23cb8a304c | |||
| 9c71eb42b8 | |||
| f642809590 | |||
| 3edb646260 | |||
| 7828580904 | |||
| 2711fbb039 | |||
| d226adef8b | |||
| 88aba6189b | |||
| e371190c10 | |||
| dd3b147a87 | |||
| 653c70a063 | |||
| bb75ef114c | |||
| f220d982f2 | |||
| 1db555e84d | |||
| 2c97ca5d59 | |||
| 4a1f1588f0 | |||
| 2b5c23c82b | |||
| e1b8eb512c | |||
| fca3ef18aa | |||
| d2c77a0dc0 | |||
| f76e87652c | |||
| 108145970d | |||
| d4d1873933 | |||
| 52a85b5475 | |||
| 6f1c69ec02 | |||
| f184d1610b | |||
| 7832d94156 | |||
| 289b648803 | |||
| c86c9b30c5 | |||
| a722923c62 | |||
| ae3f15fac1 | |||
| d5b0187a32 | |||
| 100aa1d7be | |||
| 4ff35d69bc | |||
| ec29c403be | |||
| a576feacb8 | |||
| 9c44a6972c | |||
| 1ce5928d35 | |||
| 35c30e915e | |||
| f59139d640 | |||
| b4bdcbe535 | |||
| b6d175eeb7 | |||
| a7084ab10b | |||
| 6a4c28904a | |||
| d0e1fd06c5 | |||
| 287a93580b | |||
| 53fedccb0b | |||
| a08ccf0a61 | |||
| df8baa04c3 | |||
| 3b0e0d4df4 | |||
| 250ea6271e | |||
| f356fbe45e | |||
| 37f401637b | |||
| 13f944bc55 | |||
| 3e21f15895 | |||
| fc410020b8 | |||
| 200460b0c8 | |||
| d1014faf32 | |||
| b692cb65b7 | |||
| 3f566d8f2e | |||
| 46beca01b3 | |||
| 0257c6d6b0 | |||
| b10192c1e4 | |||
| 0772879f24 | |||
| 5563b4e151 | |||
| ffcce04152 | |||
| b374d60430 | |||
| 848e124eab | |||
| a53b09c16b | |||
| 8374432bdb | |||
| 18ab64ef11 | |||
| e1b6fbf2eb | |||
| a37df0735f | |||
| 8b0c3b6551 | |||
| 5ee7e12e26 | |||
| f4aaf2f7b5 | |||
| c385f70296 | |||
| 00fe4b8045 | |||
| 0472d056f6 | |||
| 07f8831194 | |||
| a7f53e74f6 | |||
| 8a6733ead1 | |||
| e5bafac7d2 | |||
| f101e4f736 | |||
| 53b824ef1f | |||
| 672007443c | |||
| 1180c98509 | |||
| 337f36b459 | |||
| be1ed90464 | |||
| 55c0d5b8a4 | |||
| aa912c49e2 | |||
| 8abfee6962 | |||
| f1068df6c6 | |||
| 3b438e0db9 | |||
| 6d699a924d | |||
| f6de1e03d7 | |||
| 0416a3be25 | |||
| 1e4f7f125b | |||
| 1b2472e584 | |||
| 51aca6a92f | |||
| 04803a039d | |||
| 8d101bc522 | |||
| 474c8d3f00 | |||
| e48f4e502d | |||
| 00b9ff724b | |||
| d5be1194cb | |||
| d3176779c8 | |||
| 8e4485c69b | |||
| e565767d24 | |||
| aca29171b4 | |||
| 1710f639ae | |||
| 711d6de23f | |||
| fdee3caacb | |||
| 0c19b8fd99 | |||
| 1bad990a14 | |||
| 155a4e17a2 | |||
| 11a5d6c147 | |||
| ca5b6b6506 | |||
| d0fcd925f9 | |||
| b985f62858 | |||
| e793cddc22 |
+1
-1
@@ -60,7 +60,7 @@
|
||||
|
||||
// $CFG->pagepath is used to generate the body and id attributes for the body tag
|
||||
// of the page. It is also used to generate the link to the Moodle Docs for this view.
|
||||
$CFG->pagepath = 'block/' . $strblockname . '/config';
|
||||
$CFG->pagepath = 'block/' . $block->name() . '/config';
|
||||
|
||||
print_header($site->shortname.': '.$strblockname.": $strconfiguration", $site->fullname,
|
||||
"<a href=\"index.php\">$stradmin</a> -> ".
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
if (count($err) == 0) {
|
||||
foreach ($config as $name => $value) {
|
||||
if ($name == "sessioncookie") {
|
||||
$value = eregi_replace("[^a-zA-Z]", "", $value);
|
||||
$value = eregi_replace("[^a-zA-Z0-9_]", "", $value);
|
||||
}
|
||||
if ($name == "defaultallowedmodules") {
|
||||
$value = implode(',',$value);
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@
|
||||
chdir(dirname($_SERVER['argv'][0]));
|
||||
}
|
||||
|
||||
require_once("../config.php");
|
||||
require_once(dirname(__FILE__) . '/../config.php');
|
||||
require_once($CFG->dirroot.'/lib/adminlib.php');
|
||||
|
||||
if (!$alreadyadmin = isadmin()) {
|
||||
|
||||
@@ -34,4 +34,30 @@
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
<MOODLE version="1.7">
|
||||
<DATABASE level="required">
|
||||
<VENDOR name="mysql" version="4.1.16">
|
||||
<FEEDBACK>
|
||||
<ON_ERROR message="mysql416required" />
|
||||
</FEEDBACK>
|
||||
<BYPASS function="bypass_mysql416_reqs" message="mysql416bypassed" />
|
||||
</VENDOR>
|
||||
<VENDOR name="postgres" version="7.4" />
|
||||
<VENDOR name="mssql" version="8.0" />
|
||||
<VENDOR name="oracle" version="9.0" />
|
||||
</DATABASE>
|
||||
<PHP version="4.3.0" level="required" />
|
||||
<PHP_EXTENSIONS>
|
||||
<PHP_EXTENSION name="iconv" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="iconvrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
<PHP_EXTENSION name="mbstring" level="optional">
|
||||
<FEEDBACK>
|
||||
<ON_CHECK message="mbstringrecommended" />
|
||||
</FEEDBACK>
|
||||
</PHP_EXTENSION>
|
||||
</PHP_EXTENSIONS>
|
||||
</MOODLE>
|
||||
</COMPATIBILITY_MATRIX>
|
||||
|
||||
+7
-2
@@ -188,10 +188,15 @@
|
||||
// construct the flexible table ready to display
|
||||
$table = new flexible_table(FILTER_TABLE);
|
||||
$table->define_columns(array('name', 'hideshow', 'order', 'settings'));
|
||||
$table->column_style('hideshow', 'text-align', 'center');
|
||||
$table->column_style('order', 'text-align', 'center');
|
||||
$table->column_style('settings', 'text-align', 'center');
|
||||
$table->define_headers(array($txt->name, $txt->hideshow, $txt->updown, $txt->settings));
|
||||
$table->define_baseurl("$CFG->wwwroot/admin/filters.php");
|
||||
$table->set_attribute('id', 'blocks');
|
||||
$table->set_attribute('class', 'flexible generaltable generalbox');
|
||||
$table->set_attribute('style', 'margin:auto;');
|
||||
$table->set_attribute('cellpadding', '5');
|
||||
$table->setup();
|
||||
|
||||
// iterate through filters adding to display table
|
||||
@@ -202,13 +207,13 @@
|
||||
// get hide/show link
|
||||
if (in_array($path, $activefilters)) {
|
||||
$hideshow = "<a href=\"$myurl&action=hide&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"$img/hide.gif\" alt=\"hide\" /></a>";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/hide.gif\" height=\"16\" width=\"16\" alt=\"hide\" /></a>";
|
||||
$hidden = false;
|
||||
$displayname = "<span>$name</span>";
|
||||
}
|
||||
else {
|
||||
$hideshow = "<a href=\"$myurl&action=show&filterpath=$upath\">";
|
||||
$hideshow .= "<img src=\"$img/show.gif\" alt=\"show\" /></a>";
|
||||
$hideshow .= "<img src=\"{$CFG->pixpath}/i/show.gif\" height=\"16\" width=\"16\" alt=\"show\" /></a>";
|
||||
$hidden = true;
|
||||
$displayname = "<span class=\"dimmed_text\">$name</span>";
|
||||
}
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ $langdir/$currentfile")."</font></p>";
|
||||
|
||||
echo "<textarea rows=\"$fileeditorrows\" cols=\"$fileeditorcols\" name=\"filedata\">\n";
|
||||
if (file_exists("$langdir/$currentfile")) {
|
||||
echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
|
||||
echo htmlspecialchars(file_get_contents("$langdir/$currentfile"));
|
||||
} else {
|
||||
echo ($filetemplate);
|
||||
}
|
||||
|
||||
+5
-5
@@ -39,7 +39,7 @@
|
||||
|
||||
print_heading($strmanagemodules);
|
||||
|
||||
$courseaffected = false;
|
||||
$coursesaffected = false;
|
||||
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
@@ -149,10 +149,10 @@
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$strmodulename = get_string("modulename", "$module->name");
|
||||
// Deal with modules which are lacking the language string
|
||||
if ($strmodulename == '[[modulename]]') {
|
||||
$strmodulename = $module->name;
|
||||
}
|
||||
// Deal with modules which are lacking the language string
|
||||
if ($strmodulename == '[[modulename]]') {
|
||||
$strmodulename = $module->name;
|
||||
}
|
||||
$modulebyname[$strmodulename] = $module;
|
||||
}
|
||||
ksort($modulebyname);
|
||||
|
||||
@@ -93,12 +93,13 @@
|
||||
foreach ($courses as $c) {
|
||||
$a = array();
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$c->courseid.'">'.get_field('course','shortname','id',$c->courseid).'</a>';
|
||||
$a[] = print_numeric_value($c->line1);
|
||||
|
||||
$a[] = $c->line1;
|
||||
if (isset($c->line2)) {
|
||||
$a[] = print_numeric_value($c->line2);
|
||||
$a[] = $c->line2;
|
||||
}
|
||||
if (isset($c->line3)) {
|
||||
$a[] = print_numeric_value($c->line3);
|
||||
$a[] = $c->line3;
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
@@ -107,12 +108,4 @@
|
||||
|
||||
print_footer();
|
||||
|
||||
function print_numeric_value($value) {
|
||||
list($whole, $decimals) = split ('[.,]', $value, 2);
|
||||
if (intval($decimals) > 0)
|
||||
return number_format($value,2,".",",");
|
||||
else
|
||||
return $value;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -5,7 +5,50 @@
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<a href="'.$CFG->wwwroot.'/admin/report/courseoverview/index.php">'.get_string('courseoverview').'</a>';
|
||||
|
||||
$strreports = get_string('reports');
|
||||
$strcourseoverview = get_string('courseoverview');
|
||||
|
||||
print_heading("$strcourseoverview:");
|
||||
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
$report = optional_param('report', STATS_REPORT_ACTIVE_COURSES, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$numcourses = optional_param('numcourses', 20, PARAM_INT);
|
||||
|
||||
$course = get_site();
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
$table->width = '*';
|
||||
$table->align = array('left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="text" name="numcourses" size="3" maxlength="2" value="'.$numcourses.'" />',
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
|
||||
echo '<form action="report/courseoverview/index.php" method="post">'."\n";
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
error("Stats is not enabled.");
|
||||
}
|
||||
|
||||
$courseid = required_param('course', PARAM_INT);
|
||||
$report = optional_param('report', 0, PARAM_INT);
|
||||
$time = optional_param('time', 0, PARAM_INT);
|
||||
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
|
||||
$userid = optional_param('userid', 0, PARAM_INT);
|
||||
|
||||
if ($report == STATS_REPORT_USER_LOGINS) {
|
||||
$courseid = SITEID; //override
|
||||
}
|
||||
|
||||
if ($mode == STATS_MODE_RANKED) {
|
||||
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report.php?time='.$time);
|
||||
}
|
||||
|
||||
if (!$course = get_record("course","id",$courseid)) {
|
||||
error("That's an invalid course id");
|
||||
}
|
||||
|
||||
if (!empty($userid)) {
|
||||
if (!$user = get_record('user','id',$userid)) {
|
||||
error("That's an invalid user id");
|
||||
}
|
||||
}
|
||||
|
||||
require_login();
|
||||
if (!isteacher($course->id)) {
|
||||
error("You need to be a teacher to use this page");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$menu = report_stats_mode_menu($course, $mode, $time);
|
||||
|
||||
|
||||
$crumb = "<a href=\"{$CFG->wwwroot}/admin\">".get_string('administration')."</a> ->
|
||||
<a href=\"{$CFG->wwwroot}/admin/report.php\">$strreports</a> ->
|
||||
$strstats";
|
||||
|
||||
print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
$crumb, '', '', true, ' ', $menu);
|
||||
|
||||
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
print_footer();
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php //$Id$
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<p style="text-align:center;">';
|
||||
echo '<a href="'.$CFG->wwwroot.'/admin/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
|
||||
echo '</p>';
|
||||
}
|
||||
?>
|
||||
+357
-321
@@ -4,7 +4,7 @@
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/environmentlib.php');
|
||||
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
require_login();
|
||||
|
||||
if (!isadmin()) {
|
||||
@@ -178,8 +178,12 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
//mtrace() and return 0. (showing the current
|
||||
//table/field/recordid)
|
||||
|
||||
global $db, $CFG, $dbtablename, $fieldname, $record;
|
||||
global $db, $CFG, $dbtablename, $fieldname, $record, $processedrecords;
|
||||
$debug = ($CFG->debug > 7);
|
||||
|
||||
//echo date("H:i:s");
|
||||
|
||||
ignore_user_abort(false); // see bug report 5352. This should kill this thread as soon as user aborts.
|
||||
|
||||
@set_time_limit(0);
|
||||
@ob_implicit_flush(true);
|
||||
@@ -191,8 +195,22 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
|
||||
$ignoretables = array(); //list of tables to ignore, optional
|
||||
|
||||
//one gigantic array to hold all db table information read from all the migrate2utf8.xml file.
|
||||
require_once($CFG->dirroot.'/lib/xmlize.php');
|
||||
$xmls = utf_get_xml(1);
|
||||
$tablestoconvert = 0; // total number of tables to convert
|
||||
foreach ($xmls as $xml) { ///foreach xml file, we must get a list of tables
|
||||
$dbtables = $xml['DBMIGRATION']['#']['TABLES'][0]['#']['TABLE']; //real db tables
|
||||
foreach ($dbtables as $dbtable) {
|
||||
$tablestoconvert++;
|
||||
}
|
||||
}
|
||||
// progress bar handling
|
||||
// first let's find out how many tables there are
|
||||
|
||||
$done = 0;
|
||||
print_progress($done, 158, 5, 1);
|
||||
print_progress($done, $tablestoconvert, 5, 1);
|
||||
|
||||
|
||||
$textlib = textlib_get_instance(); //only 1 reference
|
||||
|
||||
@@ -280,17 +298,9 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
$crash->field = $crashdata[1];
|
||||
$crash->record = $crashdata[2];
|
||||
|
||||
print_heading('Resume information :');
|
||||
echo '<br>Resuming from @ table : '.$crash->table;
|
||||
echo '<br>Resuming from @ field : '.$crash->field;
|
||||
echo '<br>Resuming from @ record : '.$crash->record;
|
||||
notify("Resuming migration from: $crash->table / .$crash->field, Record: $crash->record");
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot.'/lib/xmlize.php');
|
||||
|
||||
//one gigantic array to hold all db table information read from all the migrate2utf8.xml file.
|
||||
$xmls = utf_get_xml(1);
|
||||
|
||||
/************************************************************************
|
||||
* Now we got all our tables in order *
|
||||
************************************************************************/
|
||||
@@ -302,7 +312,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
foreach ($dbtables as $dbtable) {
|
||||
|
||||
$done++;
|
||||
print_progress($done, 158, 5, 1);
|
||||
print_progress($done, $tablestoconvert, 5, 1);
|
||||
|
||||
$dbtablename = $dbtable['@']['name'];
|
||||
|
||||
@@ -315,6 +325,7 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
}
|
||||
|
||||
if ($crash && ($dbtablename != $crash->table)) { //resuming from crash
|
||||
$done++; // need to update progress bar
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -322,348 +333,372 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
print_heading("<br><b>Processsing db table ".$dbtablename.'...</b>');
|
||||
}
|
||||
|
||||
if (!empty($dbtable['#']) && ($fields = $dbtable['#']['FIELDS'][0]['#']['FIELD']) and (!in_array($dbtablename, $ignoretables))) {
|
||||
/**********************************************************
|
||||
* This is the by pass structure. It allows us to process *
|
||||
* tables on row basis instead of column/field basis *
|
||||
* It relies on a single function in migrate2utf8.php *
|
||||
**********************************************************/
|
||||
|
||||
$colnames = array();
|
||||
$coltypes = array(); //array to hold all column types for the table
|
||||
$collengths = array(); //array to hold all column lengths for the table
|
||||
$defaults = array(); //array to hold defaults, if any
|
||||
//reset holders
|
||||
$addindexarray = array();
|
||||
$adduniqueindexarray = array();
|
||||
$addprimaryarray = array();
|
||||
/// first, check to see if there's a function for the whole table. By pass point (1)
|
||||
if (file_exists($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php')) {
|
||||
require_once($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php');
|
||||
// this is a function to process table on role basis, e.g. user table in moodorg
|
||||
$tablefunction = 'migrate2utf8_'.$dbtablename;
|
||||
}
|
||||
if ($CFG->dbtype=='mysql' && function_exists($tablefunction)) {
|
||||
$tablefunction($dbtable['#']['FIELDS'][0]['#']['FIELD'], $crash, $debug, $maxrecords); // execute it.
|
||||
} else {
|
||||
|
||||
foreach ($fields as $field){
|
||||
/******************************************************
|
||||
* No function for converting whole table, we proceed *
|
||||
******************************************************/
|
||||
|
||||
if (!empty($dbtable['#']) && ($fields = $dbtable['#']['FIELDS'][0]['#']['FIELD']) and (!in_array($dbtablename, $ignoretables))) {
|
||||
|
||||
//if in crash state, and field name is not the same as crash field name
|
||||
$colnames = array();
|
||||
$coltypes = array(); //array to hold all column types for the table
|
||||
$collengths = array(); //array to hold all column lengths for the table
|
||||
$defaults = array(); //array to hold defaults, if any
|
||||
//reset holders
|
||||
$addindexarray = array();
|
||||
$adduniqueindexarray = array();
|
||||
$addprimaryarray = array();
|
||||
|
||||
$fieldname = isset($field['@']['name'])?$field['@']['name']:"";
|
||||
$method = isset($field['@']['method'])?$field['@']['method']:"";
|
||||
$type = isset($field['@']['type'])?$field['@']['type']:"";
|
||||
$length = isset($field['@']['length'])?$field['@']['length']:"";
|
||||
foreach ($fields as $field){
|
||||
|
||||
if ($crash && ($crash->field != $fieldname)) {
|
||||
continue;
|
||||
}
|
||||
//if in crash state, and field name is not the same as crash field name
|
||||
|
||||
$dropindex = isset($field['@']['dropindex'])?$field['@']['dropindex']:"";
|
||||
$addindex = isset($field['@']['addindex'])?$field['@']['addindex']:"";
|
||||
$adduniqueindex = isset($field['@']['adduniqueindex'])?$field['@']['adduniqueindex']:"";
|
||||
$fieldname = isset($field['@']['name'])?$field['@']['name']:"";
|
||||
$method = isset($field['@']['method'])?$field['@']['method']:"";
|
||||
$type = isset($field['@']['type'])?$field['@']['type']:"";
|
||||
$length = isset($field['@']['length'])?$field['@']['length']:"";
|
||||
|
||||
$dropprimary = isset($field['@']['dropprimary'])?$field['@']['dropprimary']:"";
|
||||
$addprimary = isset($field['@']['addprimary'])?$field['@']['addprimary']:"";
|
||||
$default = isset($field['@']['default'])?"'".$field['@']['default']."'":"''";
|
||||
|
||||
if ($fieldname != 'dummy') {
|
||||
$colnames[] = $fieldname;
|
||||
$coltypes[] = $type;
|
||||
$collengths[]= $length;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
echo "<br>--><b>processing db field ".$fieldname.'</b>';
|
||||
echo "<br>---><b>method ".$method.'</b>';
|
||||
}
|
||||
|
||||
|
||||
if ($CFG->dbtype == 'mysql') {
|
||||
|
||||
/* Drop the index, because with index on, you can't change it to longblob */
|
||||
|
||||
if ($dropindex){ //drop index if index is varchar, text etc type
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$dropindex.';';
|
||||
$SQL1 = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$CFG->prefix.$dropindex.';'; // see bug 5205
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
execute_sql($SQL, false); // see bug 5205
|
||||
execute_sql($SQL1, false); // see bug 5205
|
||||
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
} else if ($dropprimary) { // drop primary key
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename.' DROP PRIMARY KEY;';
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
execute_sql($SQL, $debug);
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
if ($crash && ($crash->field != $fieldname)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Change to longblob, serves 2 purposes:
|
||||
1. column loses encoding, so when we finally change it to unicode,
|
||||
mysql does not do a double convertion
|
||||
2. longblobs puts no limit (ok, not really but it's large enough)
|
||||
to handle most of the problems such as in bug 5194
|
||||
*/
|
||||
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename;
|
||||
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGBLOB';
|
||||
$dropindex = isset($field['@']['dropindex'])?$field['@']['dropindex']:"";
|
||||
$addindex = isset($field['@']['addindex'])?$field['@']['addindex']:"";
|
||||
$adduniqueindex = isset($field['@']['adduniqueindex'])?$field['@']['adduniqueindex']:"";
|
||||
|
||||
$dropprimary = isset($field['@']['dropprimary'])?$field['@']['dropprimary']:"";
|
||||
$addprimary = isset($field['@']['addprimary'])?$field['@']['addprimary']:"";
|
||||
$default = isset($field['@']['default'])?"'".$field['@']['default']."'":"''";
|
||||
|
||||
/*
|
||||
if ($length > 0) {
|
||||
$SQL.='('.$length.') ';
|
||||
}
|
||||
$SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
|
||||
*/
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
if ($fieldname != 'dummy') {
|
||||
execute_sql($SQL, $debug);
|
||||
$colnames[] = $fieldname;
|
||||
$coltypes[] = $type;
|
||||
$collengths[]= $length;
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
echo "<br>--><b>processing db field ".$fieldname.'</b>';
|
||||
echo "<br>---><b>method ".$method.'</b>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$patterns[]='/RECORDID/'; //for preg_replace
|
||||
$patterns[]='/\{\$CFG\-\>prefix\}/i'; //same here
|
||||
|
||||
if ($method == 'PLAIN_SQL_UPDATE') {
|
||||
$sqldetectuser = $field['#']['SQL_DETECT_USER'][0]['#'];
|
||||
$sqldetectcourse = $field['#']['SQL_DETECT_COURSE'][0]['#'];
|
||||
}
|
||||
else if ($method == 'PHP_FUNCTION') {
|
||||
$phpfunction = 'migrate2utf8_'.$dbtablename.'_'.$fieldname;
|
||||
}
|
||||
|
||||
///get the total number of records for this field
|
||||
|
||||
// could not use count_records because it addes prefix to adodb_logsql
|
||||
$totalrecords = count_records_sql("select count(*) from {$prefix}$dbtablename");
|
||||
$counter = 0;
|
||||
$recordsetsize = 4;
|
||||
if ($CFG->dbtype == 'mysql') {
|
||||
|
||||
if ($crash) { //if resuming from crash
|
||||
//find the number of records with id smaller than the crash id
|
||||
$indexSQL = 'SELECT COUNT(*) FROM '.$prefix.$dbtablename.' WHERE id < '.$crash->record;
|
||||
$counter = count_records_sql($indexSQL);
|
||||
}
|
||||
/* Drop the index, because with index on, you can't change it to longblob */
|
||||
|
||||
if ($debug) {
|
||||
echo "<br>Total number of records is ..".$totalrecords;
|
||||
echo "<br/>Counter is $counter";
|
||||
}
|
||||
|
||||
if ($dropindex){ //drop index if index is varchar, text etc type
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$dropindex.';';
|
||||
$SQL1 = 'ALTER TABLE '.$prefix.$dbtablename.' DROP INDEX '.$CFG->prefix.$dropindex.';'; // see bug 5205
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
execute_sql($SQL, false); // see bug 5205
|
||||
execute_sql($SQL1, false); // see bug 5205
|
||||
|
||||
/**************************
|
||||
* converting each record *
|
||||
**************************/
|
||||
while(($counter < $totalrecords) and ($fieldname !='dummy') and ($method!='NO_CONV')) { //while there is still something
|
||||
$SQL = 'SELECT * FROM '.$prefix.$dbtablename.' ORDER BY id ASC '.sql_paging_limit($counter, $recordsetsize);
|
||||
if ($records = get_records_sql($SQL)) {
|
||||
foreach ($records as $record) {
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
} else if ($dropprimary) { // drop primary key
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename.' DROP PRIMARY KEY;';
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
execute_sql($SQL, $debug);
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
}
|
||||
|
||||
//if we are up this far, either no crash, or crash with same table, field name.
|
||||
if ($crash){
|
||||
if ($crash->record != $record->id) { //might set to < just in case record is deleted
|
||||
continue;
|
||||
} else {
|
||||
$crash = 0;
|
||||
print_heading('recovering from '.$dbtablename.'--'.$fieldname.'--'.$record->id);
|
||||
/* Change to longblob, serves 2 purposes:
|
||||
1. column loses encoding, so when we finally change it to unicode,
|
||||
mysql does not do a double convertion
|
||||
2. longblobs puts no limit (ok, not really but it's large enough)
|
||||
to handle most of the problems such as in bug 5194
|
||||
*/
|
||||
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename;
|
||||
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGBLOB';
|
||||
|
||||
/*
|
||||
if ($length > 0) {
|
||||
$SQL.='('.$length.') ';
|
||||
}
|
||||
$SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
|
||||
*/
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
if ($fieldname != 'dummy') {
|
||||
execute_sql($SQL, $debug);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$patterns[]='/RECORDID/'; //for preg_replace
|
||||
$patterns[]='/\{\$CFG\-\>prefix\}/i'; //same here
|
||||
|
||||
if ($method == 'PLAIN_SQL_UPDATE') {
|
||||
$sqldetectuser = $field['#']['SQL_DETECT_USER'][0]['#'];
|
||||
$sqldetectcourse = $field['#']['SQL_DETECT_COURSE'][0]['#'];
|
||||
}
|
||||
else if ($method == 'PHP_FUNCTION') {
|
||||
$phpfunction = 'migrate2utf8_'.$dbtablename.'_'.$fieldname;
|
||||
}
|
||||
|
||||
///get the total number of records for this field
|
||||
|
||||
// could not use count_records because it addes prefix to adodb_logsql
|
||||
$totalrecords = count_records_sql("select count(*) from {$prefix}$dbtablename");
|
||||
$counter = 0;
|
||||
$recordsetsize = 50;
|
||||
|
||||
if ($crash) { //if resuming from crash
|
||||
//find the number of records with id smaller than the crash id
|
||||
$indexSQL = 'SELECT COUNT(*) FROM '.$prefix.$dbtablename.' WHERE id < '.$crash->record;
|
||||
$counter = count_records_sql($indexSQL);
|
||||
}
|
||||
|
||||
if ($debug) {
|
||||
echo "<br>Total number of records is ..".$totalrecords;
|
||||
echo "<br/>Counter is $counter";
|
||||
}
|
||||
|
||||
|
||||
/**************************
|
||||
* converting each record *
|
||||
**************************/
|
||||
while(($counter < $totalrecords) and ($fieldname !='dummy') and ($method!='NO_CONV')) { //while there is still something
|
||||
$SQL = 'SELECT * FROM '.$prefix.$dbtablename.' ORDER BY id ASC '.sql_paging_limit($counter, $recordsetsize);
|
||||
if ($records = get_records_sql($SQL)) {
|
||||
foreach ($records as $record) {
|
||||
|
||||
//if we are up this far, either no crash, or crash with same table, field name.
|
||||
if ($crash){
|
||||
if ($crash->record != $record->id) { //might set to < just in case record is deleted
|
||||
continue;
|
||||
} else {
|
||||
$crash = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$migrationconfig = get_record('config','name','dbmigration');
|
||||
$migrationconfig->name = 'dbmigration';
|
||||
$migrationconfig->value = $dbtablename.'##'.$fieldname.'##'.$record->id;
|
||||
update_record('config',$migrationconfig);
|
||||
|
||||
$replacements = array(); //manual refresh
|
||||
$replacements[] = $record->id;
|
||||
$replacements[] = $prefix;
|
||||
|
||||
if (!empty($record->{$fieldname})) { //only update if not empty
|
||||
switch ($method){
|
||||
case 'PLAIN_SQL_UPDATE': //use the 2 statements to update
|
||||
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
|
||||
//if global lang is set, we just use that
|
||||
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$userid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectuser));
|
||||
$courseid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectcourse));
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang(isset($courseid->course)?$courseid->course:1);
|
||||
$userlang = get_user_lang(isset($userid->userid)?$userid->userid:1);
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
//only update if non utf8
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($record->{$fieldname}, $fromenc);
|
||||
$newrecord = new object;
|
||||
$newrecord->id = $record->id;
|
||||
$newrecord->{$fieldname} = $result;
|
||||
migrate2utf8_update_record($dbtablename,$newrecord);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PHP_FUNCTION': //use the default php function to execute
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
require_once($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php');
|
||||
$phpfunction($record->id);
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
break;
|
||||
|
||||
default: //no_conv, don't do anything ;-)
|
||||
break;
|
||||
}
|
||||
}
|
||||
$counter++;
|
||||
if ($maxrecords) {
|
||||
if ($processedrecords == $maxrecords) {
|
||||
notify($maxrecords.' records processed. Migration Process halted');
|
||||
print_continue('utfdbmigrate.php?confirm=1&maxrecords='.$maxrecords.'&sesskey='.sesskey());
|
||||
print_footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$processedrecords++;
|
||||
//print some output once in a while
|
||||
if (($processedrecords) % 5000 == 0) {
|
||||
print_progress($done, $tablestoconvert, 5, 1,
|
||||
'Processing: '.$dbtablename.'/'.$fieldname.' ');
|
||||
}
|
||||
}
|
||||
|
||||
$migrationconfig = get_record('config','name','dbmigration');
|
||||
$migrationconfig->name = 'dbmigration';
|
||||
$migrationconfig->value = $dbtablename.'##'.$fieldname.'##'.$record->id;
|
||||
update_record('config',$migrationconfig);
|
||||
|
||||
$replacements = array(); //manual refresh
|
||||
$replacements[] = $record->id;
|
||||
$replacements[] = $prefix;
|
||||
|
||||
switch ($method){
|
||||
case 'PLAIN_SQL_UPDATE': //use the 2 statements to update
|
||||
|
||||
if (!empty($record->{$fieldname})) { //only update if not empty
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
|
||||
//if global lang is set, we just use that
|
||||
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$userid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectuser));
|
||||
$courseid = get_record_sql(preg_replace($patterns, $replacements, $sqldetectcourse));
|
||||
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang(isset($courseid->course)?$courseid->course:1);
|
||||
$userlang = get_user_lang(isset($userid->userid)?$userid->userid:1);
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
//only update if non utf8
|
||||
if (($fromenc != 'utf-8') && ($fromenc != 'UTF-8')) {
|
||||
$result = utfconvert($record->{$fieldname}, $fromenc);
|
||||
$newrecord = new object;
|
||||
$newrecord->id = $record->id;
|
||||
$newrecord->{$fieldname} = $result;
|
||||
migrate2utf8_update_record($dbtablename,$newrecord);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'PHP_FUNCTION': //use the default php function to execute
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
require_once($CFG->dirroot.'/'.$dir.'/db/migrate2utf8.php');
|
||||
$phpfunction($record->id);
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
break;
|
||||
|
||||
default: //no_conv, don't do anything ;-)
|
||||
break;
|
||||
}
|
||||
$counter++;
|
||||
if ($maxrecords) {
|
||||
if ($processedrecords == $maxrecords) {
|
||||
notify($maxrecords.' records processed. Migration Process halted');
|
||||
print_continue('utfdbmigrate.php?confirm=1&maxrecords='.$maxrecords.'&sesskey='.sesskey());
|
||||
print_footer();
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$processedrecords++;
|
||||
//print some output once in a while
|
||||
if (($processedrecords) % 5000 == 0) {
|
||||
echo 'Processing...'.$dbtablename.'...'.$fieldname.'...'.$record->id;
|
||||
}else {
|
||||
if ($debug) {
|
||||
notify('no records found!');
|
||||
}
|
||||
}
|
||||
}else {
|
||||
} //close the while loop
|
||||
|
||||
/********************
|
||||
* Drop index here **
|
||||
********************/
|
||||
|
||||
if ($CFG->dbtype == 'mysql') {
|
||||
|
||||
/*********************************
|
||||
* Change column encoding 2 phase*
|
||||
*********************************/
|
||||
|
||||
/*
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
|
||||
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGTEXT';
|
||||
// if ($length > 0) {
|
||||
// $SQL.='('.$length.') ';
|
||||
// }
|
||||
$SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
|
||||
if ($debug) {
|
||||
notify('no records found!');
|
||||
$db->debug=999;
|
||||
}
|
||||
if ($fieldname != 'dummy') {
|
||||
execute_sql($SQL, $debug);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}*/
|
||||
//phase 2
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename;
|
||||
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' '.$type;
|
||||
if ($length > 0) {
|
||||
$SQL.='('.$length.') ';
|
||||
}
|
||||
$SQL.=' CHARACTER SET utf8 NOT NULL DEFAULT '.$default.';';
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
if ($fieldname != 'dummy') {
|
||||
execute_sql($SQL, $debug);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
/********************************************
|
||||
* build an array to add index back together*
|
||||
********************************************/
|
||||
if ($addindex){
|
||||
$addindexarray[] = $addindex;
|
||||
} else if ($adduniqueindex) {
|
||||
$adduniqueindexarray[] = $adduniqueindex;
|
||||
} else if ($addprimary) {
|
||||
$addprimaryarray[] = $addprimary;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
//posgresql code here
|
||||
//No we don't need to do anything here
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Adding the index back *
|
||||
********************************/
|
||||
$alter = 0;
|
||||
|
||||
if ($CFG->dbtype=='mysql'){
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename;
|
||||
|
||||
if (!empty($addindexarray)) {
|
||||
foreach ($addindexarray as $aidx){
|
||||
$SQL .= ' ADD INDEX '.$aidx.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
} //close the while loop
|
||||
|
||||
/********************
|
||||
* Drop index here **
|
||||
********************/
|
||||
if (!empty($adduniqueindexarray)) {
|
||||
foreach ($adduniqueindexarray as $auidx){
|
||||
$SQL .= ' ADD UNIQUE INDEX '.$auidx.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($CFG->dbtype == 'mysql') {
|
||||
if (!empty($addprimaryarray)) {
|
||||
foreach ($addprimaryarray as $apm){
|
||||
$SQL .= ' ADD PRIMARY KEY '.$apm.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************
|
||||
* Change column encoding 2 phase*
|
||||
*********************************/
|
||||
|
||||
/*
|
||||
$SQL = 'ALTER TABLE '.$CFG->prefix.$dbtablename;
|
||||
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' LONGTEXT';
|
||||
// if ($length > 0) {
|
||||
// $SQL.='('.$length.') ';
|
||||
// }
|
||||
$SQL .= ' CHARACTER SET binary NOT NULL DEFAULT '.$default.';';
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
if ($fieldname != 'dummy') {
|
||||
execute_sql($SQL, $debug);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}*/
|
||||
//phase 2
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename;
|
||||
$SQL.= ' CHANGE '.$fieldname.' '.$fieldname.' '.$type;
|
||||
if ($length > 0) {
|
||||
$SQL.='('.$length.') ';
|
||||
}
|
||||
$SQL.=' CHARACTER SET utf8 NOT NULL DEFAULT '.$default.';';
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
if ($fieldname != 'dummy') {
|
||||
execute_sql($SQL, $debug);
|
||||
}
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
/********************************************
|
||||
* build an array to add index back together*
|
||||
********************************************/
|
||||
if ($addindex){
|
||||
$addindexarray[] = $addindex;
|
||||
} else if ($adduniqueindex) {
|
||||
$adduniqueindexarray[] = $adduniqueindex;
|
||||
} else if ($addprimary) {
|
||||
$addprimaryarray[] = $addprimary;
|
||||
}
|
||||
$SQL = rtrim($SQL, ', ');
|
||||
$SQL.=';';
|
||||
|
||||
} else {
|
||||
///posgresql code here
|
||||
///No we don't need to do anything here
|
||||
|
||||
//posgresql code here
|
||||
//No we don't need to do anything here
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/********************************
|
||||
* Adding the index back *
|
||||
********************************/
|
||||
$alter = 0;
|
||||
|
||||
if ($CFG->dbtype=='mysql'){
|
||||
$SQL = 'ALTER TABLE '.$prefix.$dbtablename;
|
||||
|
||||
if (!empty($addindexarray)) {
|
||||
foreach ($addindexarray as $aidx){
|
||||
$SQL .= ' ADD INDEX '.$aidx.',';
|
||||
$alter++;
|
||||
if ($alter) {
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
execute_sql($SQL, $debug);
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($adduniqueindexarray)) {
|
||||
foreach ($adduniqueindexarray as $auidx){
|
||||
$SQL .= ' ADD UNIQUE INDEX '.$auidx.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($addprimaryarray)) {
|
||||
foreach ($addprimaryarray as $apm){
|
||||
$SQL .= ' ADD PRIMARY KEY '.$apm.',';
|
||||
$alter++;
|
||||
}
|
||||
}
|
||||
|
||||
$SQL = rtrim($SQL, ', ');
|
||||
$SQL.=';';
|
||||
|
||||
} else {
|
||||
///posgresql code here
|
||||
///No we don't need to do anything here
|
||||
|
||||
}
|
||||
|
||||
if ($alter) {
|
||||
if ($debug) {
|
||||
$db->debug=999;
|
||||
}
|
||||
execute_sql($SQL, $debug);
|
||||
if ($debug) {
|
||||
$db->debug=0;
|
||||
}
|
||||
}
|
||||
|
||||
} //if there are fields
|
||||
} //if there are fields
|
||||
|
||||
|
||||
} /// Point 1 - bypass should end here.
|
||||
|
||||
|
||||
/************************************
|
||||
* now we modify the table encoding *
|
||||
************************************/
|
||||
@@ -723,8 +758,8 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
}
|
||||
|
||||
//finish the javascript bar
|
||||
$done=159;
|
||||
print_progress($done, 158, 5, 1);
|
||||
$done = $tablestoconvert;
|
||||
print_progress($done, $tablestoconvert, 5, 1);
|
||||
|
||||
//prints the list of langs used in this site
|
||||
print_simple_box_start('center','50%');
|
||||
@@ -756,7 +791,8 @@ function db_migrate2utf8(){ //Eloy: Perhaps some type of limit parameter here
|
||||
|
||||
//set the final flag
|
||||
migrate2utf8_set_config('unicodedb','true'); //this is the main flag for unicode db
|
||||
|
||||
|
||||
//echo date("H:i:s");
|
||||
}
|
||||
|
||||
|
||||
@@ -1020,7 +1056,7 @@ function utf_get_xml ($mode=0) { // if mode is 1, do not perform check for scrip
|
||||
|
||||
foreach ($enrols as $enrol){
|
||||
if (file_exists($CFG->dirroot.'/enrol/'.$enrol.'/db/migrate2utf8.xml')) {
|
||||
$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/enrol/'.$enrol.'/db/migrate2utf8.xml'));
|
||||
$xmls[] = xmlize(file_get_contents($CFG->dirroot.'/enrol/'.$enrol.'/db/migrate2utf8.xml'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,14 +36,9 @@
|
||||
</form>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($CFG->changepassword or is_internal_auth() ) {
|
||||
if (is_internal_auth()) {
|
||||
$changepassword = "forgot_password.php";
|
||||
$changebuttonname = get_string("senddetails");
|
||||
} else {
|
||||
$changepassword = $CFG->changepassword;
|
||||
$changebuttonname = get_string("passwordrecovery");
|
||||
}
|
||||
<?php if (is_internal_auth() ) {
|
||||
$changepassword = "forgot_password.php";
|
||||
$changebuttonname = get_string("senddetails");
|
||||
?>
|
||||
<hr width="80%" />
|
||||
<p><?php print_string("forgotten") ?></p>
|
||||
|
||||
+3
-9
@@ -18,7 +18,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
$wwwroot = str_replace('http:','https:',$CFG->wwwroot);
|
||||
}
|
||||
$langmenu = popup_form ("$wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
@@ -109,10 +109,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
//Select password change url
|
||||
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
} elseif($CFG->changepassword) {
|
||||
$passwordchangeurl=$CFG->changepassword;
|
||||
}
|
||||
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)){
|
||||
@@ -219,10 +216,7 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
//Select password change url
|
||||
if (is_internal_auth() || $CFG->{'auth_'.$USER->auth.'_stdchangepassword'}){
|
||||
$passwordchangeurl=$CFG->wwwroot.'/login/change_password.php';
|
||||
} elseif($CFG->changepassword) {
|
||||
$passwordchangeurl=$CFG->changepassword;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check whether the user should be changing password
|
||||
if (get_user_preferences('auth_forcepasswordchange', false)){
|
||||
@@ -319,4 +313,4 @@ defined('MOODLE_INTERNAL') or die('Direct access to this script is forbidden.');
|
||||
|
||||
// No footer on this page
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
+4
-2
@@ -144,7 +144,9 @@ function auth_get_userinfo($username){
|
||||
$ldapval = $newval;
|
||||
}
|
||||
}
|
||||
$result[$key] = $ldapval;
|
||||
if (!is_null($ldapval)) {
|
||||
$result[$key] = $ldapval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -838,7 +840,7 @@ function auth_user_update($olduser, $newuser) {
|
||||
if ($user_info_result){
|
||||
|
||||
$user_entry = auth_ldap_get_entries($ldapconnection, $user_info_result);
|
||||
if (count($user_entry)) {
|
||||
if (count($user_entry) > 1) {
|
||||
trigger_error("ldap: Strange! More than one user record found in ldap. Only using the first one.");
|
||||
}
|
||||
$user_entry = $user_entry[0];
|
||||
|
||||
@@ -19,8 +19,8 @@ Changes:
|
||||
|
||||
Moodle Configuration with Dual login
|
||||
-------------------------------------------------------------------------------
|
||||
1. Protect the file moodle/auth/shibboleth/ directory with Shibboleth.
|
||||
The page index.php actually logs in a Shibboleth user.
|
||||
1. Protect the directory moodle/auth/shibboleth/ with Shibboleth.
|
||||
The page index.php in that directory actually logs in a Shibboleth user.
|
||||
For Apache you have to define a rule like the following in the Apache config:
|
||||
|
||||
--
|
||||
@@ -63,7 +63,7 @@ Moodle Configuration with Dual login
|
||||
4. The large text field 'Instructions' must contain a link to the
|
||||
moodle/auth/shibboleth/index.php file which is protected by
|
||||
Shibboleth (see step 1) and causes the Shibboleth login procedure to start.
|
||||
You also could use HTML code in that field, e.g. to create your own
|
||||
You could also use HTML code in that field, e.g. to create your own
|
||||
Shibboleth login button.
|
||||
|
||||
5. Save the changes for the Shibboleth authentication method.
|
||||
@@ -79,11 +79,11 @@ described in the dual login section above and do the following steps:
|
||||
|
||||
How the Shibboleth authentication works
|
||||
--------------------------------------------------------------------------------
|
||||
For a user to get Shibboleth authenticated in Moodle he basically must go to the
|
||||
To get Shibboleth authenticated in Moodle a user basically must access the
|
||||
Shibboleth-protected page /auth/shibboleth/index.php. If Shibboleth is the only
|
||||
authentication method (see 4.a), this happens automatically when a user wants to
|
||||
login. Otherwise the user has to click on the link on the login page you
|
||||
provided in step 4.
|
||||
login in Moodle. Otherwise, the user has to click on the link on the login page
|
||||
you provided in step 4.
|
||||
|
||||
Moodle basically checks whether the Shibboleth attribute that you mapped
|
||||
as the username is present. This attribute should only be present if a user is
|
||||
@@ -98,19 +98,16 @@ these are checked by Shibboleth itself. Only users who met these rules
|
||||
actually can access /auth/shibboleth/index.php and get logged in.
|
||||
|
||||
You can use Shibboleth AND another authentication method (it was tested with
|
||||
manual login). So if there are a few users that don't have a Shibboleth
|
||||
manual login). So, if there are a few users that don't have a Shibboleth
|
||||
login, you could create manual accounts for them and they could use the manual
|
||||
login. For other authentication methods you first have to configure them and
|
||||
then set Shibboleth as your authentication method. Users can log in only via one
|
||||
authentication method unless they have two accounts in Moodle.
|
||||
Users that provide a non-existing login name for non-Shibboleth authentication
|
||||
methods are automatically redirected to auth/shibboleth/index.php and it is
|
||||
tried to authenticate them via Shibboleth.
|
||||
|
||||
Shibboleth dual login with custom login page
|
||||
--------------------------------------------------------------------------------
|
||||
Of course you can create a dual login page that better fits your needs. For this
|
||||
to work you have to set up the two authentication methods (e.g. 'Manual' and
|
||||
to work, you have to set up the two authentication methods (e.g. 'Manual' and
|
||||
'Shibboleth') and specify an alternate login link to your own dual login page.
|
||||
On that page you basically need a link to the Shibboleth-protected page
|
||||
('/auth/shibboleth/index.php') for the Shibboleth login and a
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
if (!isset($config->auth_instructions) or empty($pluginconfig->shib_user_attribute)) {
|
||||
$config->auth_instructions = get_string('auth_shib_instructions', 'auth', $CFG->wwwroot.'/auth/shibboleth/shib-protected.php');
|
||||
$config->auth_instructions = get_string('auth_shib_instructions', 'auth', $CFG->wwwroot.'/auth/shibboleth/index.php');
|
||||
}
|
||||
|
||||
if (!isset ($pluginconfig->user_attribute)) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
redirect($urltogo);
|
||||
}
|
||||
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
|
||||
// Check whether Shibboleth is configured properly
|
||||
|
||||
@@ -65,7 +65,7 @@ function auth_get_userinfo($username) {
|
||||
|
||||
function auth_shib_attributes(){
|
||||
//returns array containg attribute mappings between Moodle and shibboleth
|
||||
global $CFG;
|
||||
global $CFG;
|
||||
|
||||
$pluginconfig = get_config('auth/shibboleth');
|
||||
$pluginconfig = (array) $pluginconfig;
|
||||
@@ -82,6 +82,6 @@ function auth_shib_attributes(){
|
||||
}
|
||||
$moodleattributes['username']=$pluginconfig["shib_user_attribute"];
|
||||
|
||||
return $moodleattributes;
|
||||
return $moodleattributes;
|
||||
}
|
||||
?>
|
||||
|
||||
+3
-1
@@ -117,7 +117,9 @@
|
||||
//Call the form, depending the step we are
|
||||
if (!$launch) {
|
||||
// if we're at the start, clear the cache of prefs
|
||||
unset($SESSION->backupprefs[$course->id]);
|
||||
if (isset($SESSION->backupprefs[$course->id])) {
|
||||
unset($SESSION->backupprefs[$course->id]);
|
||||
}
|
||||
include_once("backup_form.html");
|
||||
} else if ($launch == "check") {
|
||||
include_once("backup_check.html");
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
if (isset($backupprefs->$var) && $backupprefs->$var) {
|
||||
$var = "backup_".$modname;
|
||||
//Only if selected
|
||||
if ($backupprefs->$var == 1) {
|
||||
if (!empty($backupprefs->$var) and ($backupprefs->$var == 1)) {
|
||||
//Print the full tr
|
||||
echo "<tr>";
|
||||
echo "<td colspan=\"2\">";
|
||||
|
||||
@@ -145,7 +145,7 @@
|
||||
|
||||
//If we have selected to backup quizzes, backup categories and
|
||||
//questions structure (step 1). See notes on mod/quiz/backuplib.php
|
||||
if ($status and $preferences->mods['quiz']->backup) {
|
||||
if ($status and !empty($preferences->mods['quiz']->backup)) {
|
||||
echo "<li>".get_string("writingcategoriesandquestions").'</li>';
|
||||
require_once($CFG->dirroot.'/mod/quiz/backuplib.php');
|
||||
if (!$status = backup_question_categories($backup_file,$preferences)) {
|
||||
|
||||
+18
-11
@@ -98,18 +98,19 @@ function schedule_backup_cron() {
|
||||
if (!$backup_course) {
|
||||
mtrace(" ERROR (in backup_courses detection)");
|
||||
$status = false;
|
||||
continue;
|
||||
}
|
||||
//Now we backup every course with nextstarttime < now
|
||||
if ($backup_course->nextstarttime > 0 && $backup_course->nextstarttime < $now) {
|
||||
// Skip backup of unavailable courses that have remained unmodified in a month
|
||||
$skipped = false;
|
||||
if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
|
||||
mtrace(" SKIPPING - hidden+unmodified");
|
||||
set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
|
||||
$skipped = true;
|
||||
}
|
||||
//Now we backup every non skipped course with nextstarttime < now
|
||||
if (!$skipped && $backup_course->nextstarttime > 0 && $backup_course->nextstarttime < $now) {
|
||||
//We have to send a email because we have included at least one backup
|
||||
$emailpending = true;
|
||||
// Skip backup of unavailable courses that have remained unmodified in a month
|
||||
if (!$course->visible && ($now - $course->timemodified) > 31) { //Hidden + unmodified last month
|
||||
//if (!$course->visible && ($now - $course->timemodified) > 31*24*60*60) { //Hidden + unmodified last month
|
||||
mtrace(" SKIPPING - hidden+unmodified");
|
||||
set_field("backup_courses","laststatus","3","courseid",$backup_course->courseid);
|
||||
continue;
|
||||
}
|
||||
//Only make the backup if laststatus isn't 2-UNFINISHED (uncontrolled error)
|
||||
if ($backup_course->laststatus != 2) {
|
||||
//Set laststarttime
|
||||
@@ -334,7 +335,7 @@ function schedule_backup_course_configure($course,$starttime = 0) {
|
||||
$backup_config->backup_sche_coursefiles = 1;
|
||||
}
|
||||
if (!isset($backup_config->backup_sche_messages)) {
|
||||
$backup_config->backup_sche_messages = 1;
|
||||
$backup_config->backup_sche_messages = 0;
|
||||
}
|
||||
if (!isset($backup_config->backup_sche_active)) {
|
||||
$backup_config->backup_sche_active = 0;
|
||||
@@ -513,7 +514,13 @@ function schedule_backup_course_configure($course,$starttime = 0) {
|
||||
//Now calculate the users
|
||||
if ($status) {
|
||||
schedule_backup_log($starttime,$course->id," calculating users");
|
||||
user_check_backup($course->id,$backup_unique_code,$preferences->backup_users,$preferences->backup_messages);
|
||||
//Decide about include users with messages, based on SITEID
|
||||
if ($preferences->backup_messages && $preferences->backup_course == SITEID) {
|
||||
$include_message_users = true;
|
||||
} else {
|
||||
$include_message_users = false;
|
||||
}
|
||||
user_check_backup($course->id,$backup_unique_code,$preferences->backup_users,$include_message_users);
|
||||
}
|
||||
|
||||
//Now calculate the logs
|
||||
|
||||
@@ -460,10 +460,11 @@
|
||||
|
||||
function xml_tag_safe_content($content) {
|
||||
global $CFG;
|
||||
//If enabled, we strip all the control chars from the text but tabs, newlines and returns
|
||||
//If enabled, we strip all the control chars (\x0-\x1f) from the text but tabs (\x9),
|
||||
//newlines (\xa) and returns (\xd). The delete control char (\x7f) is also included.
|
||||
//because they are forbiden in XML 1.0 specs. The expression below seems to be
|
||||
//UTF-8 safe too because it simply ignores the rest of characters.
|
||||
$content = preg_replace("/(?(?=[[:cntrl:]])[^\n\r\t])/is","",$content);
|
||||
$content = preg_replace("/[\x-\x8\xb-\xc\xe-\x1f\x7f]/is","",$content);
|
||||
if (!empty($CFG->unicodedb)) {
|
||||
// Don't perform the conversion. Contents are Unicode.
|
||||
$content = preg_replace("/\r\n|\r/", "\n", htmlspecialchars($content));
|
||||
@@ -1001,7 +1002,6 @@
|
||||
fwrite ($bf,full_tag("TYPE",6,false,$moduletype));
|
||||
fwrite ($bf,full_tag("INSTANCE",6,false,$course_module[$tok]->instance));
|
||||
fwrite ($bf,full_tag("ADDED",6,false,$course_module[$tok]->added));
|
||||
fwrite ($bf,full_tag("DELETED",6,false,$course_module[$tok]->deleted));
|
||||
fwrite ($bf,full_tag("SCORE",6,false,$course_module[$tok]->score));
|
||||
fwrite ($bf,full_tag("INDENT",6,false,$course_module[$tok]->indent));
|
||||
fwrite ($bf,full_tag("VISIBLE",6,false,$course_module[$tok]->visible));
|
||||
@@ -1048,7 +1048,6 @@
|
||||
//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("GUID",4,false,$user_data->guid));
|
||||
fwrite ($bf,full_tag("CONFIRMED",4,false,$user_data->confirmed));
|
||||
fwrite ($bf,full_tag("POLICYAGREED",4,false,$user_data->policyagreed));
|
||||
fwrite ($bf,full_tag("DELETED",4,false,$user_data->deleted));
|
||||
@@ -1078,7 +1077,7 @@
|
||||
fwrite ($bf,full_tag("LASTACCESS",4,false,$user_data->lastaccess));
|
||||
fwrite ($bf,full_tag("LASTLOGIN",4,false,$user_data->lastlogin));
|
||||
fwrite ($bf,full_tag("CURRENTLOGIN",4,false,$user_data->currentlogin));
|
||||
fwrite ($bf,full_tag("LASTIP",4,false,$user_data->lastIP));
|
||||
fwrite ($bf,full_tag("LASTIP",4,false,$user_data->lastip));
|
||||
fwrite ($bf,full_tag("SECRET",4,false,$user_data->secret));
|
||||
fwrite ($bf,full_tag("PICTURE",4,false,$user_data->picture));
|
||||
fwrite ($bf,full_tag("URL",4,false,$user_data->url));
|
||||
|
||||
@@ -50,6 +50,27 @@ function backup_upgrade($oldversion=0) {
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006042801) {
|
||||
modify_database('', 'ALTER TABLE prefix_backup_log
|
||||
ALTER COLUMN "time" TYPE integer,
|
||||
ALTER COLUMN "time" SET DEFAULT 0,
|
||||
ALTER COLUMN laststarttime TYPE integer,
|
||||
ALTER COLUMN laststarttime SET DEFAULT 0,
|
||||
ALTER COLUMN courseid TYPE integer,
|
||||
ALTER COLUMN courseid SET DEFAULT 0');
|
||||
|
||||
modify_database('', 'ALTER TABLE mdl_backup_courses
|
||||
ALTER COLUMN lastendtime TYPE integer,
|
||||
ALTER COLUMN lastendtime SET DEFAULT 0,
|
||||
ALTER COLUMN laststarttime TYPE integer,
|
||||
ALTER COLUMN laststarttime SET DEFAULT 0,
|
||||
ALTER COLUMN courseid TYPE integer,
|
||||
ALTER COLUMN courseid SET DEFAULT 0,
|
||||
ALTER COLUMN nextstarttime TYPE integer,
|
||||
ALTER COLUMN nextstarttime SET DEFAULT 0');
|
||||
|
||||
}
|
||||
|
||||
//Finally, return result
|
||||
return $result;
|
||||
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@
|
||||
if (!$launch) {
|
||||
include_once("restore_precheck.html");
|
||||
} else if ($launch == "form") {
|
||||
if ($SESSION->restore->importing) {
|
||||
if (!empty($SESSION->restore->importing)) {
|
||||
// set up all the config stuff and skip asking the user about it.
|
||||
restore_setup_for_check($SESSION->restore,$backup_unique_code);
|
||||
include_once("restore_execute.html");
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
$$var = optional_param( $var,0);
|
||||
$var = "restore_user_info_".$modname;
|
||||
$$var = optional_param( $var,0);
|
||||
$instances = $info->mods[$mod->name]->instances;
|
||||
$instances = !empty($info->mods[$mod->name]->instances) ? $info->mods[$mod->name]->instances : NULL;
|
||||
if ($instances === NULL) {
|
||||
continue;
|
||||
}
|
||||
@@ -86,7 +86,7 @@
|
||||
$restore->mods[$modname]->restore=$$var;
|
||||
$var = "restore_user_info_".$modname;
|
||||
$restore->mods[$modname]->userinfo=$$var;
|
||||
$instances = $info->mods[$mod->name]->instances;
|
||||
$instances = !empty($info->mods[$mod->name]->instances) ? $info->mods[$mod->name]->instances : NULL;
|
||||
if ($instances === NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@
|
||||
error ("An error has occurred and the restore could not be completed!");
|
||||
}
|
||||
|
||||
if (!$restore->importing) {
|
||||
echo $output;
|
||||
if (empty($restore->importing)) {
|
||||
//Print final message
|
||||
print_simple_box(get_string("restorefinished"),"center");
|
||||
} else {
|
||||
|
||||
+33
-12
@@ -889,7 +889,6 @@
|
||||
$course_module->module = $module->id;
|
||||
$course_module->section = $newid;
|
||||
$course_module->added = $mod->added;
|
||||
$course_module->deleted = $mod->deleted;
|
||||
$course_module->score = $mod->score;
|
||||
$course_module->indent = $mod->indent;
|
||||
$course_module->visible = $mod->visible;
|
||||
@@ -962,7 +961,7 @@
|
||||
//Process info about metacourse
|
||||
if ($status and $info) {
|
||||
//Process child records
|
||||
if ($info->childs) {
|
||||
if (!empty($info->childs)) {
|
||||
foreach ($info->childs as $child) {
|
||||
$dbcourse = false;
|
||||
$dbmetacourse = false;
|
||||
@@ -994,7 +993,7 @@
|
||||
sync_metacourse($restore->course_id);
|
||||
}
|
||||
//Process parent records
|
||||
if ($info->parents) {
|
||||
if (!empty($info->parents)) {
|
||||
foreach ($info->parents as $parent) {
|
||||
$dbcourse = false;
|
||||
$dbmetacourse = false;
|
||||
@@ -1268,7 +1267,11 @@
|
||||
$itemid = insert_record('grade_item',$item);
|
||||
|
||||
//Now process grade_exceptions
|
||||
$exceptions = $ite_info['#']['GRADE_EXCEPTIONS']['0']['#']['GRADE_EXCEPTION'];
|
||||
if (!empty($ite_info['#']['GRADE_EXCEPTIONS'])) {
|
||||
$exceptions = $ite_info['#']['GRADE_EXCEPTIONS']['0']['#']['GRADE_EXCEPTION'];
|
||||
} else {
|
||||
$exceptions = array();
|
||||
}
|
||||
|
||||
//Iterate over exceptions
|
||||
for($j = 0; $j < sizeof($exceptions); $j++) {
|
||||
@@ -2732,6 +2735,31 @@
|
||||
$log->info = "";
|
||||
$toinsert = true;
|
||||
break;
|
||||
case "report log":
|
||||
$log->url = "report/log/index.php?id=".$log->course;
|
||||
$log->info = $log->course;
|
||||
$toinsert = true;
|
||||
break;
|
||||
case "report live":
|
||||
$log->url = "report/log/live.php?id=".$log->course;
|
||||
$log->info = $log->course;
|
||||
$toinsert = true;
|
||||
break;
|
||||
case "report outline":
|
||||
$log->url = "report/outline/index.php?id=".$log->course;
|
||||
$log->info = $log->course;
|
||||
$toinsert = true;
|
||||
break;
|
||||
case "report participation":
|
||||
$log->url = "report/participation/index.php?id=".$log->course;
|
||||
$log->info = $log->course;
|
||||
$toinsert = true;
|
||||
break;
|
||||
case "report stats":
|
||||
$log->url = "report/stats/index.php?id=".$log->course;
|
||||
$log->info = $log->course;
|
||||
$toinsert = true;
|
||||
break;
|
||||
default:
|
||||
echo "action (".$log->module."-".$log->action.") unknown. Not restored<br />"; //Debug
|
||||
break;
|
||||
@@ -3591,8 +3619,6 @@
|
||||
$this->info->tempmod->instance;
|
||||
$this->info->tempsection->mods[$this->info->tempmod->id]->added =
|
||||
$this->info->tempmod->added;
|
||||
$this->info->tempsection->mods[$this->info->tempmod->id]->deleted =
|
||||
$this->info->tempmod->deleted;
|
||||
$this->info->tempsection->mods[$this->info->tempmod->id]->score =
|
||||
$this->info->tempmod->score;
|
||||
$this->info->tempsection->mods[$this->info->tempmod->id]->indent =
|
||||
@@ -3618,9 +3644,6 @@
|
||||
case "ADDED":
|
||||
$this->info->tempmod->added = $this->getContents();
|
||||
break;
|
||||
case "DELETED":
|
||||
$this->info->tempmod->deleted = $this->getContents();
|
||||
break;
|
||||
case "SCORE":
|
||||
$this->info->tempmod->score = $this->getContents();
|
||||
break;
|
||||
@@ -3847,9 +3870,6 @@
|
||||
case "AUTH":
|
||||
$this->info->tempuser->auth = $this->getContents();
|
||||
break;
|
||||
case "GUID":
|
||||
$this->info->tempuser->guid = $this->getContents();
|
||||
break;
|
||||
case "CONFIRMED":
|
||||
$this->info->tempuser->confirmed = $this->getContents();
|
||||
break;
|
||||
@@ -5218,6 +5238,7 @@
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
echo '<li>'.get_string('creatingblocks').'</li>';
|
||||
}
|
||||
$course_header->blockinfo = !empty($course_header->blockinfo) ? $course_header->blockinfo : NULL;
|
||||
if (!$status = restore_create_blocks($restore, $info->backup_block_format, $course_header->blockinfo, $xml_file)) {
|
||||
if (!defined('RESTORE_SILENTLY')) {
|
||||
notify('Error while creating the course blocks');
|
||||
|
||||
+2
-2
@@ -5,6 +5,6 @@
|
||||
// database (backup_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$backup_version = 2006042800; // The current version is a date (YYYYMMDDXX)
|
||||
$backup_version = 2006053000; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
$backup_release = "1.6beta4"; // User-friendly version number
|
||||
$backup_release = "1.6"; // User-friendly version number
|
||||
|
||||
@@ -14,7 +14,9 @@ class block_activity_modules extends block_list {
|
||||
// data from db if the course format has already fetched them
|
||||
if(!isset($GLOBALS['modnamesplural']) || !isset($GLOBALS['modnamesused'])) {
|
||||
require_once($CFG->dirroot.'/course/lib.php');
|
||||
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
if (!empty($this->instance)) {
|
||||
get_all_mods($this->instance->pageid, $mods, $modnames, $modnamesplural, $modnamesused);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$modnamesplural = $GLOBALS['modnamesplural'];
|
||||
@@ -30,7 +32,7 @@ class block_activity_modules extends block_list {
|
||||
$this->content->icons = array();
|
||||
$this->content->footer = '';
|
||||
|
||||
if ($modnamesused) {
|
||||
if (isset($modnamesused) && $modnamesused) {
|
||||
foreach ($modnamesused as $modname => $modfullname) {
|
||||
if ($modname != 'label') {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/mod/'.$modname.'/index.php?id='.$this->instance->pageid.'">'.$modnamesplural[$modname].'</a>';
|
||||
|
||||
@@ -56,10 +56,8 @@ class block_admin extends block_list {
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/log.gif" alt="" />';
|
||||
|
||||
|
||||
if (!empty($CFG->enablestats)) {
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/course/report/stats/index.php?course='.SITEID.'">'.get_string('stats').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/stats.gif" alt="" />';
|
||||
}
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/admin/report.php">'.get_string('reports').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/stats.gif" alt="" />';
|
||||
|
||||
$this->content->items[] = '<a href="'.$CFG->wwwroot.'/files/index.php?id='.SITEID.'">'.get_string('sitefiles').'</a>';
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/files.gif" alt="" />';
|
||||
@@ -92,6 +90,12 @@ class block_admin extends block_list {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
if(empty($CFG->loginhttps)) {
|
||||
$securewwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$securewwwroot = str_replace('http:','https:',$CFG->wwwroot);
|
||||
}
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
if (isteacher($this->instance->pageid)) {
|
||||
@@ -111,9 +115,9 @@ class block_admin extends block_list {
|
||||
|
||||
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.$USER->id.'&course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$securewwwroot.'/user/edit.php?id='.$USER->id.'&course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
|
||||
if (empty($USER->description)) {
|
||||
//Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
|
||||
//Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
|
||||
$text = get_string('profile').' '.get_string('missingdescription');
|
||||
$this->content->items[]= $editmyprofile.' <a title="'.$text.'" class="useredit blink">*<span class="accesshide">'.$text.'</span></a>';
|
||||
} else {
|
||||
@@ -186,7 +190,9 @@ class block_admin extends block_list {
|
||||
$this->content->icons[] = '<img src="'.$CFG->pixpath.'/i/payment.gif" alt="" />';
|
||||
}
|
||||
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/doc/view.php?id='.$this->instance->pageid.'&file=teacher.html">'.get_string('help').'</a>';
|
||||
$lang = str_replace('_utf8', '', current_language());
|
||||
|
||||
$this->content->items[]='<a href="http://docs.moodle.org/'.$lang.'/Teacher_documentation">'.get_string('help').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->modpixpath.'/resource/icon.gif" alt="" />';
|
||||
|
||||
if ($teacherforum = forum_get_course_forum($this->instance->pageid, 'teacher')) {
|
||||
@@ -206,10 +212,10 @@ class block_admin extends block_list {
|
||||
}
|
||||
|
||||
$fullname = fullname($USER, true);
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$CFG->wwwroot.'/user/edit.php?id='.
|
||||
$editmyprofile = '<a title="'.$fullname.'" href="'.$securewwwroot.'/user/edit.php?id='.
|
||||
$USER->id.'&course='.$this->instance->pageid.'">'.get_string('editmyprofile').'</a>';
|
||||
if (empty($USER->description)) {
|
||||
//Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
|
||||
//Accessibility: replace non-standard <blink> with CSS (<a> makes title visible in IE).
|
||||
$text = get_string('profile').' '.get_string('missingdescription');
|
||||
$this->content->items[]= $editmyprofile.' <a title="'.$text.'" class="useredit blink">*<span class="accesshide">'.$text.'</span></a>';
|
||||
} else {
|
||||
@@ -218,12 +224,10 @@ class block_admin extends block_list {
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
|
||||
|
||||
if (is_internal_auth() && !is_restricted_user($USER->username)) {
|
||||
$this->content->items[]='<a href="'.$CFG->wwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'</a>';
|
||||
$this->content->items[]='<a href="'.$securewwwroot.'/login/change_password.php?id='.$this->instance->pageid.'">'.get_string('changepassword').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
|
||||
} else if ($CFG->changepassword && !is_restricted_user($USER->username)) {
|
||||
$this->content->items[]='<a href="'.$CFG->changepassword.'">'.get_string('changepassword').'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
|
||||
}
|
||||
}
|
||||
|
||||
if ($CFG->allowunenroll && !$course->metacourse) {
|
||||
$this->content->items[]='<a href="unenrol.php?id='.$this->instance->pageid.'">'.get_string('unenrolme', '', $course->shortname).'</a>';
|
||||
$this->content->icons[]='<img src="'.$CFG->pixpath.'/i/user.gif" alt="" />';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<?php //$Id$
|
||||
|
||||
require_once($CFG->dirroot .'/blog/lib.php');
|
||||
|
||||
class block_blog_menu extends block_base {
|
||||
|
||||
function init() {
|
||||
@@ -15,13 +17,13 @@ class block_blog_menu extends block_base {
|
||||
$course = SITEID;
|
||||
}
|
||||
|
||||
if ($CFG->bloglevel < 1) {
|
||||
if ($CFG->bloglevel < BLOG_USER_LEVEL) {
|
||||
$this->content->text = '';
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
// don't display menu block if block is set at site level, and user is not logged in
|
||||
if ($CFG->bloglevel < 5 && !(isloggedin() && !isguest())) {
|
||||
if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL && !(isloggedin() && !isguest())) {
|
||||
$this->content->text = '';
|
||||
return $this->content;
|
||||
}
|
||||
@@ -48,15 +50,13 @@ class block_blog_menu extends block_base {
|
||||
$this->content->text = $output;
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
require_once($CFG->dirroot .'/blog/lib.php');
|
||||
|
||||
//if ( blog_isLoggedIn() && !isguest() ) {
|
||||
$courseviewlink = '';
|
||||
$addentrylink = '';
|
||||
|
||||
$coursearg = '';
|
||||
if((isloggedin() && !isguest()) && isset($course) && isset($course->id) && $course->id !=0 && $course->id!=SITEID && $CFG->bloglevel >=3 ) {
|
||||
if((isloggedin() && !isguest()) && isset($course) && isset($course->id) && $course->id !=0 && $course->id!=SITEID && $CFG->bloglevel >= BLOG_COURSE_LEVEL) {
|
||||
$coursearg = '&courseid='. $course->id;
|
||||
// a course is specified
|
||||
|
||||
@@ -66,10 +66,10 @@ class block_blog_menu extends block_base {
|
||||
|
||||
$blogmodon = false;
|
||||
|
||||
if ((isloggedin() && !isguest()) && (isadmin() || !$blogmodon || ($blogmodon && $coursearg != '')) && $CFG->bloglevel >= 1) {
|
||||
if ((isloggedin() && !isguest()) && (isadmin() || !$blogmodon || ($blogmodon && $coursearg != '')) && $CFG->bloglevel >= BLOG_USER_LEVEL) {
|
||||
|
||||
// show Add entry link - user is not admin, moderation is off, or moderation is on and the user is viewing the block within the context of a course
|
||||
$addentrylink = '<a href="'. $CFG->wwwroot. '/blog/edit.php?userid='. $userBlog->userid . $coursearg .'">'. get_string('addnewentry', 'blog') .'</a><br />';
|
||||
$addentrylink = '<a href="'. $CFG->wwwroot. '/blog/edit.php?userid='. $userBlog->userid . $coursearg .'">'. get_string('addnewentry', 'blog') .'</a><br />';
|
||||
|
||||
// show View my entries link
|
||||
$addentrylink .= '<a href="'. $CFG->wwwroot .'/blog/index.php?userid='. $userBlog->userid.'">';
|
||||
@@ -83,7 +83,7 @@ class block_blog_menu extends block_base {
|
||||
}
|
||||
|
||||
// show View site entries link
|
||||
if ($CFG->bloglevel >= 4) {
|
||||
if ($CFG->bloglevel >= BLOG_SITE_LEVEL) {
|
||||
$output .= '<a href="'. $CFG->wwwroot .'/blog/index.php?filtertype=site&">';
|
||||
$output .= get_string('viewsiteentries', 'blog') .'</a><br />';
|
||||
}
|
||||
|
||||
@@ -4,13 +4,7 @@ define('BLOGDEFAULTTIMEWITHIN', 90);
|
||||
define('BLOGDEFAULTNUMBEROFTAGS', 20);
|
||||
define('BLOGDEFAULTSORT', 'text');
|
||||
|
||||
if (!defined('BLOG_USER_LEVEL')) {
|
||||
define ('BLOG_USER_LEVEL', 1);
|
||||
define ('BLOG_GROUP_LEVEL', 2);
|
||||
define ('BLOG_COURSE_LEVEL', 3);
|
||||
define ('BLOG_SITE_LEVEL', 4);
|
||||
define ('BLOG_GLOBAL_LEVEL', 5);
|
||||
}
|
||||
require_once($CFG->dirroot .'/blog/lib.php');
|
||||
|
||||
class block_blog_tags extends block_base {
|
||||
function init() {
|
||||
@@ -47,7 +41,7 @@ class block_blog_tags extends block_base {
|
||||
|
||||
function get_content() {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $SITE, $COURSE;
|
||||
|
||||
if (empty($this->config->timewithin)) {
|
||||
$this->config->timewithin = BLOGDEFAULTTIMEWITHIN;
|
||||
@@ -137,17 +131,21 @@ class block_blog_tags extends block_base {
|
||||
|
||||
case BLOG_COURSE_LEVEL:
|
||||
$filtertype = 'course';
|
||||
global $course; // Need to do this unfortunately for pages like blog pages
|
||||
if (isset($course->id)) {
|
||||
$filterselect = $course->id;
|
||||
if (isset($COURSE->id)) {
|
||||
$filterselect = $COURSE->id;
|
||||
} else {
|
||||
$filterselect = $this->instance->pageid;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$filtertype = 'site';
|
||||
$filterselect = SITEID;
|
||||
if (isset($COURSE->id) && $COURSE->id != SITEID) {
|
||||
$filtertype = 'course';
|
||||
$filterselect = $COURSE->id;
|
||||
} else {
|
||||
$filtertype = 'site';
|
||||
$filterselect = SITEID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class block_calendar_month extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG, $SESSION;
|
||||
global $USER, $CFG, $SESSION, $COURSE;
|
||||
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
|
||||
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
|
||||
|
||||
@@ -28,12 +28,7 @@ class block_calendar_month extends block_base {
|
||||
// [pj] To me it looks like this if would never be needed, but Penny added it
|
||||
// when committing the /my/ stuff. Reminder to discuss and learn what it's about.
|
||||
// It definitely needs SOME comment here!
|
||||
if (!empty($this->instance->pageid)) {
|
||||
$courseshown = $this->instance->pageid;
|
||||
}
|
||||
else {
|
||||
$courseshown = SITEID;
|
||||
}
|
||||
$courseshown = $COURSE->id;
|
||||
|
||||
if($courseshown == SITEID) {
|
||||
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
|
||||
@@ -58,13 +53,12 @@ class block_calendar_month extends block_base {
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
|
||||
// No filters for now
|
||||
|
||||
} elseif (!empty($courseshown)) {
|
||||
} else {
|
||||
// For any other course
|
||||
$this->content->text .= calendar_overlib_html();
|
||||
$this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
|
||||
$this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
$this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $course).'</div>';
|
||||
$this->content->text .= '<div class="filters">'.calendar_filter_controls('course', '', $COURSE).'</div>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class block_calendar_upcoming extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG, $SESSION;
|
||||
global $USER, $CFG, $SESSION, $COURSE;
|
||||
$cal_m = optional_param( 'cal_m', 0, PARAM_INT );
|
||||
$cal_y = optional_param( 'cal_y', 0, PARAM_INT );
|
||||
|
||||
@@ -27,12 +27,7 @@ class block_calendar_upcoming extends block_base {
|
||||
$this->content->footer = '';
|
||||
|
||||
} else {
|
||||
if (!empty($this->instance->pageid)) {
|
||||
$courseshown = $this->instance->pageid;
|
||||
}
|
||||
else {
|
||||
$courseshown = SITEID;
|
||||
}
|
||||
$courseshown = $COURSE->id;
|
||||
$this->content->footer = '<br /><a href="'.$CFG->wwwroot.
|
||||
'/calendar/view.php?view=upcoming&course='.$courseshown.'">'.
|
||||
get_string('gotocalendar', 'calendar').'</a>...';
|
||||
|
||||
@@ -34,7 +34,7 @@ class block_course_list extends block_list {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($USER->id) and !(isadmin() and $adminseesall)) { // Just print My Courses
|
||||
if (empty($CFG->disablemycourses) and isset($USER->id) and !(isadmin() and $adminseesall)) { // Just print My Courses
|
||||
if ($courses = get_my_courses($USER->id)) {
|
||||
foreach ($courses as $course) {
|
||||
if ($course->id == SITEID) {
|
||||
|
||||
@@ -7,13 +7,14 @@ class block_course_summary extends block_base {
|
||||
}
|
||||
|
||||
function specialization() {
|
||||
if($this->instance->pagetype == PAGE_COURSE_VIEW && $this->instance->pageid != SITEID) {
|
||||
global $COURSE;
|
||||
if($this->instance->pagetype == PAGE_COURSE_VIEW && $COURSE->id != SITEID) {
|
||||
$this->title = get_string('coursesummary', 'block_course_summary');
|
||||
}
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $THEME;
|
||||
global $CFG, $COURSE;
|
||||
|
||||
if($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@@ -23,19 +24,14 @@ class block_course_summary extends block_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (empty($this->instance->pageid)) {
|
||||
$this->instance->pageid = SITEID;
|
||||
}
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$this->content = New stdClass;
|
||||
$options->noclean = true; // Don't clean Javascripts etc
|
||||
$this->content->text = format_text($course->summary, FORMAT_HTML, $options);
|
||||
if(isediting($this->instance->pageid)) {
|
||||
if($this->instance->pageid == SITEID) {
|
||||
$this->content->text = format_text($COURSE->summary, FORMAT_HTML, $options);
|
||||
if(isediting($COURSE->id)) {
|
||||
if($COURSE->id == SITEID) {
|
||||
$editpage = $CFG->wwwroot.'/'.$CFG->admin.'/site.php';
|
||||
} else {
|
||||
$editpage = $CFG->wwwroot.'/course/edit.php?id='.$this->instance->pageid;
|
||||
$editpage = $CFG->wwwroot.'/course/edit.php?id='.$COURSE->id;
|
||||
}
|
||||
$this->content->text .= "<div align=\"right\"><a href=\"$editpage\"><img src=\"$CFG->pixpath/t/edit.gif\" alt=\"\" /></a></div>";
|
||||
}
|
||||
|
||||
@@ -61,6 +61,35 @@ function migrate2utf8_block_instance_configdata($recordid){
|
||||
|
||||
return $blah;
|
||||
|
||||
} else if ($blocktype -> name == 'glossary_random'){
|
||||
|
||||
///find course
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($blockinstance->pageid); //Non existing!
|
||||
$userlang = get_main_teacher_lang($blockinstance->pageid); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
$blah = unserialize(base64_decode($blockinstance->configdata));
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
|
||||
/// Convert the text
|
||||
$blah->title = utfconvert($blah->title, $fromenc, false);
|
||||
$blah->addentry = utfconvert($blah->addentry, $fromenc, false);
|
||||
$blah->viewglossary = utfconvert($blah->viewglossary, $fromenc, false);
|
||||
$blah->invisible = utfconvert($blah->invisible, $fromenc, false);
|
||||
|
||||
$blockinstance->configdata = base64_encode(serialize($blah));
|
||||
|
||||
migrate2utf8_update_record('block_instance',$blockinstance);
|
||||
|
||||
return $blah;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,6 +156,35 @@ global $CFG, $globallang;
|
||||
|
||||
return $blah;
|
||||
|
||||
} else if ($blocktype -> name == 'glossary_random'){
|
||||
|
||||
///find course
|
||||
if ($globallang) {
|
||||
$fromenc = $globallang;
|
||||
} else {
|
||||
$sitelang = $CFG->lang;
|
||||
$courselang = get_course_lang($blockpinned->pageid); //Non existing!
|
||||
$userlang = get_main_teacher_lang($blockpinned->pageid); //N.E.!!
|
||||
|
||||
$fromenc = get_original_encoding($sitelang, $courselang, $userlang);
|
||||
}
|
||||
|
||||
$blah = unserialize(base64_decode($blockpinned->configdata));
|
||||
|
||||
/// We are going to use textlib facilities
|
||||
|
||||
/// Convert the text
|
||||
$blah->title = utfconvert($blah->title, $fromenc, false);
|
||||
$blah->addentry = utfconvert($blah->addentry, $fromenc, false);
|
||||
$blah->viewglossary = utfconvert($blah->viewglossary, $fromenc, false);
|
||||
$blah->invisible = utfconvert($blah->invisible, $fromenc, false);
|
||||
|
||||
$blockinstance->configdata = base64_encode(serialize($blah));
|
||||
|
||||
migrate2utf8_update_record('block_instance',$blockinstance);
|
||||
|
||||
return $blah;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -13,8 +13,8 @@ class block_glossary_random extends block_base {
|
||||
}
|
||||
|
||||
function specialization() {
|
||||
global $CFG;
|
||||
$this->course = get_record('course', 'id', $this->instance->pageid);
|
||||
global $CFG, $COURSE;
|
||||
$this->course = $COURSE;
|
||||
|
||||
// load userdefined title and make sure it's never empty
|
||||
if (empty($this->config->title)) {
|
||||
|
||||
@@ -12,26 +12,26 @@
|
||||
<td><input type="text" name="title" size="50" value="<?php p($this->config->title) ?>" /></td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<tr valign=top>
|
||||
<td align=right><?php print_string("select_glossary","block_glossary_random") ?>:</td>
|
||||
<td><?php choose_from_menu($glossaries,"glossary",$this->config->glossary) ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<tr valign=top>
|
||||
<td align=right><?php print_string("refresh","block_glossary_random") ?>:</td>
|
||||
<td><input type="text" name="refresh" size="5" value="<?php p($this->config->refresh) ?>" /></td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><?php print_string("type","block_glossary_random") ?>:</td>
|
||||
<tr valign=top>
|
||||
<td align=right><?php print_string("type","block_glossary_random") ?>:</td>
|
||||
<td><?php
|
||||
choose_from_menu($type, "type", $this->config->type, "");
|
||||
helpbutton("",get_string("type","block_glossary_random"),"moodle",true,false,get_string("typehelp","block_glossary_random"));
|
||||
?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign=top>
|
||||
<td align=right><?php print_string("showconcept","block_glossary_random") ?>:</td>
|
||||
<tr valign=top>
|
||||
<td align=right><?php print_string("showconcept","block_glossary_random") ?>:</td>
|
||||
<td>
|
||||
<input type="hidden" name="showconcept" value="0" />
|
||||
<input type="checkbox" name="showconcept" value="1" <?php if(!empty($this->config->showconcept)) echo 'checked="checked"'; ?> /></td>
|
||||
|
||||
@@ -32,13 +32,12 @@ class block_login extends block_base {
|
||||
$forgot = $wwwroot . '/login/forgot_password.php';
|
||||
} else {
|
||||
if (!empty($CFG->{'auth_'.$CFG->auth.'_stdchangepassword'})
|
||||
|| $CFG->changepassword
|
||||
|| is_internal_auth() ) {
|
||||
if (is_internal_auth() || !empty($CFG->{'auth_'.$CFG->auth.'_stdchangepassword'})) {
|
||||
$forgot = $wwwroot . '/login/forgot_password.php';
|
||||
}
|
||||
else {
|
||||
$forgot = $CFG->changepassword;
|
||||
$forgot = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ class block_news_items extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $COURSE;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@@ -22,44 +22,39 @@ class block_news_items extends block_base {
|
||||
}
|
||||
|
||||
|
||||
if ($this->instance->pageid == 0) {
|
||||
$this->instance->pageid = SITEID;
|
||||
}
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
if ($course->newsitems) { // Create a nice listing of recent postings
|
||||
if ($COURSE->newsitems) { // Create a nice listing of recent postings
|
||||
|
||||
require_once($CFG->dirroot.'/mod/forum/lib.php'); // We'll need this
|
||||
|
||||
$text = '';
|
||||
|
||||
if (!$forum = forum_get_course_forum($course->id, 'news')) {
|
||||
if (!$forum = forum_get_course_forum($COURSE->id, 'news')) {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
|
||||
/// First work out whether we can post to this group and if so, include a link
|
||||
|
||||
if (isteacheredit($course->id)) { /// Teachers can always post
|
||||
if (isteacheredit($COURSE->id)) { /// Teachers can always post
|
||||
$visiblegroups = -1;
|
||||
|
||||
$text .= '<div align="center" class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
|
||||
get_string('addanewtopic', 'forum').'</a>...</div>';
|
||||
|
||||
} else { /// Check the group situation
|
||||
$currentgroup = get_current_group($course->id);
|
||||
$currentgroup = get_current_group($COURSE->id);
|
||||
|
||||
if (forum_user_can_post_discussion($forum, $currentgroup)) {
|
||||
$text .= '<div align="center" class="newlink"><a href="'.$CFG->wwwroot.'/mod/forum/post.php?forum='.$forum->id.'">'.
|
||||
get_string('addanewtopic', 'forum').'</a>...</div>';
|
||||
}
|
||||
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
|
||||
if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $COURSE->id)) {
|
||||
$this->content->text = $text;
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$groupmode = groupmode($course, $cm);
|
||||
$groupmode = groupmode($COURSE, $cm);
|
||||
|
||||
/// Decides if current user is allowed to see ALL the current discussions or not
|
||||
|
||||
@@ -73,7 +68,7 @@ class block_news_items extends block_base {
|
||||
/// Get all the recent discussions we're allowed to see
|
||||
|
||||
if (! $discussions = forum_get_discussions($forum->id, 'p.modified DESC', 0, false,
|
||||
$visiblegroups, $course->newsitems) ) {
|
||||
$visiblegroups, $COURSE->newsitems) ) {
|
||||
$text .= '('.get_string('nonews', 'forum').')';
|
||||
$this->content->text = $text;
|
||||
return $this->content;
|
||||
@@ -119,7 +114,7 @@ class block_news_items extends block_base {
|
||||
} else {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
$this->content->footer .= '<br />'.rss_get_link($course->id, $userid, 'forum', $forum->id, $tooltiptext);
|
||||
$this->content->footer .= '<br />'.rss_get_link($COURSE->id, $userid, 'forum', $forum->id, $tooltiptext);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ class block_online_users extends block_base {
|
||||
function has_config() {return true;}
|
||||
|
||||
function get_content() {
|
||||
global $USER, $CFG;
|
||||
global $USER, $CFG, $COURSE;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@@ -23,8 +23,6 @@ class block_online_users extends block_base {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
$timetoshowusers = 300; //Seconds default
|
||||
if (isset($CFG->block_online_users_timetosee)) {
|
||||
$timetoshowusers = $CFG->block_online_users_timetosee * 60;
|
||||
@@ -32,10 +30,10 @@ class block_online_users extends block_base {
|
||||
$timefrom = time()-$timetoshowusers;
|
||||
|
||||
//Calculate if we are in separate groups
|
||||
$isseparategroups = ($course->groupmode == SEPARATEGROUPS && $course->groupmodeforce && !isteacheredit($this->instance->pageid));
|
||||
$isseparategroups = ($COURSE->groupmode == SEPARATEGROUPS && $COURSE->groupmodeforce && !isteacheredit($COURSE->id));
|
||||
|
||||
//Get the user current group
|
||||
$currentgroup = $isseparategroups ? get_current_group($this->instance->pageid) : NULL;
|
||||
$currentgroup = $isseparategroups ? get_current_group($COURSE->id) : NULL;
|
||||
|
||||
$groupmembers = "";
|
||||
$groupselect = "";
|
||||
@@ -46,11 +44,11 @@ class block_online_users extends block_base {
|
||||
$groupselect .= " AND u.id = gm.userid AND gm.groupid = '$currentgroup'";
|
||||
}
|
||||
|
||||
if ($this->instance->pageid == SITEID) { // Site-level
|
||||
if ($COURSE->id == SITEID) { // Site-level
|
||||
$courseselect = '';
|
||||
$timeselect = "AND (s.timeaccess > $timefrom OR u.lastaccess > $timefrom)";
|
||||
} else {
|
||||
$courseselect = "AND s.course = '".$this->instance->pageid."'";
|
||||
$courseselect = "AND s.course = '".$COURSE->id."'";
|
||||
$timeselect = "AND s.timeaccess > $timefrom";
|
||||
}
|
||||
|
||||
@@ -69,7 +67,7 @@ class block_online_users extends block_base {
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->instance->pageid == SITEID && $CFG->allusersaresitestudents) {
|
||||
if ($COURSE->id == SITEID && $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'
|
||||
@@ -88,7 +86,7 @@ class block_online_users extends block_base {
|
||||
$groupmembers
|
||||
WHERE u.id = s.userid $courseselect $groupselect $timeselect ";
|
||||
|
||||
if (!isteacher($course->id)) {
|
||||
if (!isteacher($COURSE->id)) {
|
||||
// Hide hidden teachers from students.
|
||||
$findteacherssql .= 'AND s.authority > 0 ';
|
||||
}
|
||||
@@ -110,14 +108,14 @@ class block_online_users extends block_base {
|
||||
//Now, we have in users, the list of users to show
|
||||
//Because they are online
|
||||
if (!empty($users)) {
|
||||
//Accessibility: Don't want 'Alt' text for the user picture; DO want it for the envelope/message link (existing lang string).
|
||||
//Accessibility: Converted <div> to <ul>, inherit existing classes & styles.
|
||||
$this->content->text .= "<ul class='list'>\n";
|
||||
//Accessibility: Don't want 'Alt' text for the user picture; DO want it for the envelope/message link (existing lang string).
|
||||
//Accessibility: Converted <div> to <ul>, inherit existing classes & styles.
|
||||
$this->content->text .= "<ul class='list'>\n";
|
||||
foreach ($users as $user) {
|
||||
$this->content->text .= '<li class="listentry">';
|
||||
$this->content->text .= '<li class="listentry">';
|
||||
$timeago = format_time(time() - max($user->timeaccess, $user->lastaccess)); //bruno to calculate correctly on frontpage
|
||||
$this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 16, true).' ';
|
||||
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$this->instance->pageid.'" title="'.$timeago.'">'.$user->fullname.'</a>';
|
||||
$this->content->text .= print_user_picture($user->id, $COURSE->id, $user->picture, 16, true).' ';
|
||||
$this->content->text .= '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$COURSE->id.'" title="'.$timeago.'">'.$user->fullname.'</a>';
|
||||
if (!empty($USER->id) and ($USER->id != $user->id) and !empty($CFG->messaging) and !isguest()) { // Only when logged in
|
||||
$this->content->text .= "\n".' <a title="'.get_string('messageselectadd').'" target="message_'.$user->id.'" href="'.$CFG->wwwroot.'/message/discussion.php?id='.$user->id.'" onclick="return openpopup(\'/message/discussion.php?id='.$user->id.'\', \'message_'.$user->id.'\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">'
|
||||
.'<img class="icon message" src="'.$CFG->pixpath.'/t/message.gif" alt="'. get_string('messageselectadd') .'" /></a>';
|
||||
|
||||
@@ -7,6 +7,7 @@ class block_recent_activity extends block_base {
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $COURSE;
|
||||
|
||||
if ($this->content !== NULL) {
|
||||
return $this->content;
|
||||
@@ -21,11 +22,9 @@ class block_recent_activity extends block_base {
|
||||
$this->content->text = '';
|
||||
$this->content->footer = '';
|
||||
|
||||
$course = get_record('course', 'id', $this->instance->pageid);
|
||||
|
||||
// Slightly hacky way to do it but...
|
||||
ob_start();
|
||||
print_recent_activity($course);
|
||||
print_recent_activity($COURSE);
|
||||
$this->content->text = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
global $CFG, $editing;
|
||||
global $CFG, $editing, $COURSE;
|
||||
|
||||
require_once($CFG->libdir .'/rsslib.php');
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
$isteacher = false;
|
||||
$this->courseid = SITEID;
|
||||
if ($this->instance->pagetype == PAGE_COURSE_VIEW) {
|
||||
$this->courseid = $this->instance->pageid;
|
||||
$this->courseid = $COURSE->id;
|
||||
$isteacher = isteacher($this->courseid);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ if (isguest()) {
|
||||
error(get_string('noguestpost', 'forum'), $referrer);
|
||||
}
|
||||
|
||||
$url = optional_param('url','',PARAM_URL);
|
||||
|
||||
if (!empty($url)) {
|
||||
// attempting to replace feed and rss url types with http
|
||||
@@ -41,7 +42,7 @@ if (!empty($url)) {
|
||||
$act = optional_param('act', NULL, PARAM_ALPHA);
|
||||
$rssid = optional_param('rssid', NULL, PARAM_INT);
|
||||
$id = optional_param('id', SITEID, PARAM_INT);
|
||||
$url = clean_param($url, PARAM_URL);
|
||||
//$url = clean_param($url, PARAM_URL);
|
||||
$preferredtitle = optional_param('preferredtitle', '', PARAM_ALPHA);
|
||||
|
||||
if (!defined('MAGPIE_OUTPUT_ENCODING')) {
|
||||
|
||||
@@ -12,6 +12,12 @@ function rss_client_upgrade($oldversion) {
|
||||
table_column('block_rss_client','description','description','text');
|
||||
}
|
||||
|
||||
if ($oldversion < 2005090201) {
|
||||
modify_database('', 'ALTER TABLE prefix_block_rss_client
|
||||
ALTER COLUMN title SET DEFAULT \'\',
|
||||
ALTER COLUMN description SET DEFAULT \'\'');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class block_section_links extends block_base {
|
||||
}
|
||||
|
||||
function applicable_formats() {
|
||||
return (array('course-view-weeks' => true, 'course-view-topics' => true));
|
||||
return (array('course-view-weeks' => true, 'course-view-topics' => true, 'course-edit-weeks' => true, 'course-edit-topics' => true));
|
||||
}
|
||||
|
||||
function get_content() {
|
||||
|
||||
+1
-1
@@ -5,4 +5,4 @@
|
||||
// database (blocks_version) to determine whether upgrades should
|
||||
// be performed (see db/backup_*.php)
|
||||
|
||||
$blocks_version = 2005090200; // The current version is a date (YYYYMMDDXX)
|
||||
$blocks_version = 2005090201; // The current version is a date (YYYYMMDDXX)
|
||||
|
||||
@@ -137,16 +137,6 @@ print_simple_box_start("center");
|
||||
require('edit.html');
|
||||
print_simple_box_end();
|
||||
|
||||
// Janne comment: Let's move this in here
|
||||
// so IE gets more time to load the
|
||||
// Page.
|
||||
if ($usehtmleditor) {
|
||||
// Janne comment: there are two text fields in form
|
||||
// so lets try to replace them both with
|
||||
// HTMLArea editors
|
||||
use_html_editor();
|
||||
}
|
||||
|
||||
include($CFG->dirroot .'/blog/footer.php');
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,17 @@ if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
|
||||
<?php
|
||||
|
||||
// Janne comment: Let's move this in here
|
||||
// so IE gets more time to load the
|
||||
// Page.
|
||||
|
||||
if (isset($usehtmleditor) && $usehtmleditor) {
|
||||
// Janne comment: there are two text fields in form
|
||||
// so lets try to replace them both with
|
||||
// HTMLArea editors
|
||||
use_html_editor();
|
||||
}
|
||||
|
||||
if (isset($course) && ($course->id)) {
|
||||
print_footer($course);
|
||||
} else {
|
||||
|
||||
+25
-22
@@ -15,9 +15,6 @@ $blockid = optional_param('blockid', 0, PARAM_INT);
|
||||
/// If user has never visited this page before, install 2 blocks for him
|
||||
blog_check_and_install_blocks();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect($CFG->wwwroot.'/index.php');
|
||||
}
|
||||
|
||||
// now check that they are logged in and allowed into the course (if specified)
|
||||
if ($courseid != SITEID) {
|
||||
@@ -26,7 +23,7 @@ if ($courseid != SITEID) {
|
||||
}
|
||||
require_login($course->id);
|
||||
} else {
|
||||
$course = get_site();
|
||||
$course = $SITE;
|
||||
}
|
||||
|
||||
// Bounds for block widths within this page
|
||||
@@ -92,7 +89,7 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
$formHeading = get_string('addnewentry', 'blog');
|
||||
}
|
||||
|
||||
print_header("$site->shortname: $blogstring", "$site->fullname",
|
||||
print_header("$SITE->shortname: $blogstring", "$SITE->fullname",
|
||||
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
|
||||
<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.$blogstring.'</a> -> '. $formHeading,'','',true);
|
||||
|
||||
@@ -103,20 +100,20 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
switch ($filtertype) {
|
||||
case 'site':
|
||||
if ($tagid || !empty($tag)) {
|
||||
print_header("$site->shortname: $blogstring", "",
|
||||
print_header("$SITE->shortname: $blogstring", $SITE->fullname,
|
||||
'<a href="index.php?filtertype=site">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
|
||||
} else {
|
||||
print_header("$site->shortname: $blogstring", "",
|
||||
print_header("$SITE->shortname: $blogstring", $SITE->fullname,
|
||||
$blogstring,'','',true,$PAGE->get_extra_header_string());
|
||||
}
|
||||
break;
|
||||
|
||||
case 'course':
|
||||
if ($tagid || !empty($tag)) {
|
||||
print_header_simple("$course->shortname: $blogstring", "",
|
||||
print_header_simple("$course->shortname: $blogstring", $course->fullname,
|
||||
'<a href="index.php?filtertype=course&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
|
||||
} else {
|
||||
print_header_simple("$course->shortname: $blogstring", "",
|
||||
print_header_simple("$course->shortname: $blogstring", $course->fullname,
|
||||
$blogstring,'','',true,$PAGE->get_extra_header_string());
|
||||
}
|
||||
break;
|
||||
@@ -126,11 +123,11 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
$thisgroup = get_record('groups', 'id', $filterselect);
|
||||
|
||||
if ($tagid || !empty($tag)) {
|
||||
print_header_simple("$course->shortname: $blogstring", "$course->fullname",
|
||||
print_header_simple("$course->shortname: $blogstring", $course->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&group='.$filterselect.'">'.$thisgroup->name.'</a> ->
|
||||
<a href="index.php?filtertype=group&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
|
||||
} else {
|
||||
print_header_simple("$course->shortname: $blogstring", "$course->fullname",
|
||||
print_header_simple("$course->shortname: $blogstring", $course->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'&group='.$filterselect.'">'.$thisgroup->name."</a> ->
|
||||
$blogstring",'','',true,$PAGE->get_extra_header_string());
|
||||
|
||||
@@ -144,14 +141,14 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
|
||||
if (isset($course->id) && $course->id && $course->id != SITEID) {
|
||||
if ($tagid || !empty($tag)) {
|
||||
print_header("$course->shortname: $blogstring", "$course->fullname",
|
||||
print_header("$course->shortname: $blogstring", $course->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
|
||||
<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
|
||||
<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&course='.$course->id.'">'.fullname($user).'</a> ->
|
||||
<a href="index.php?courseid='.optional_param('courseid', 0, PARAM_INT).'&filtertype=user&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
|
||||
|
||||
} else {
|
||||
print_header("$course->shortname: $blogstring", "$course->fullname",
|
||||
print_header("$course->shortname: $blogstring", $course->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'.$course->shortname.'</a> ->
|
||||
<a href="'.$CFG->wwwroot.'/user/index.php?id='.$course->id.'">'.$participants.'</a> ->
|
||||
<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'&course='.$course->id.'">'.fullname($user).'</a> ->
|
||||
@@ -163,12 +160,12 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
else {
|
||||
|
||||
if ($tagid || !empty($tag)) {
|
||||
print_header("$site->shortname: $blogstring", "$site->fullname",
|
||||
print_header("$SITE->shortname: $blogstring", $SITE->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
|
||||
<a href="index.php?filtertype=user&filterselect='.$filterselect.'">'. "$blogstring</a> -> $tagstring: $taginstance->text",'','',true,$PAGE->get_extra_header_string());
|
||||
|
||||
} else {
|
||||
print_header("$site->shortname: $blogstring", "$site->fullname",
|
||||
print_header("$SITE->shortname: $blogstring", $SITE->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
|
||||
'.$blogstring,'','',true,$PAGE->get_extra_header_string());
|
||||
|
||||
@@ -178,7 +175,7 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
break;
|
||||
|
||||
default: //user click on add from block
|
||||
print_header("$site->shortname: $blogstring", "$site->fullname",
|
||||
print_header("$SITE->shortname: $blogstring", $SITE->fullname,
|
||||
'<a href="'.$CFG->wwwroot.'/user/view.php?id='.$filterselect.'">'.fullname($user).'</a> ->
|
||||
<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.$blogstring.'</a> -> '.get_string('addentry','blog'),'','',true,$PAGE->get_extra_header_string());
|
||||
break;
|
||||
@@ -186,18 +183,24 @@ if ($ME == $CFG->wwwroot.'/blog/edit.php') { /// We are in edit mode, print the
|
||||
|
||||
} /// close switch
|
||||
|
||||
// prints the tabs
|
||||
$currenttab = 'blogs';
|
||||
$user = $USER;
|
||||
if (!$course) {
|
||||
$course = get_record('course','id',optional_param('courseid', SITEID, PARAM_INT));
|
||||
}
|
||||
require_once($CFG->dirroot .'/user/tabs.php');
|
||||
|
||||
$editing = false;
|
||||
if ($PAGE->user_allowed_editing()) {
|
||||
$editing = $PAGE->user_is_editing();
|
||||
}
|
||||
|
||||
// Calculate the preferred width for left, right and center (both center positions will use the same)
|
||||
$preferred_width_left = optional_param('preferred_width_left', blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]), PARAM_INT);
|
||||
$preferred_width_right = optional_param('preferred_width_right', blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]), PARAM_INT);
|
||||
$preferred_width_left = min($preferred_width_left, BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_left = max($preferred_width_left, BLOCK_L_MIN_WIDTH);
|
||||
$preferred_width_right = min($preferred_width_right, BLOCK_R_MAX_WIDTH);
|
||||
$preferred_width_right = max($preferred_width_right, BLOCK_R_MIN_WIDTH);
|
||||
$preferred_width_left = bounded_number(BLOCK_L_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_LEFT]),
|
||||
BLOCK_L_MAX_WIDTH);
|
||||
$preferred_width_right = bounded_number(BLOCK_R_MIN_WIDTH, blocks_preferred_width($pageblocks[BLOCK_POS_RIGHT]),
|
||||
BLOCK_R_MAX_WIDTH);
|
||||
|
||||
// Display the blocks and allow blocklib to handle any block action requested
|
||||
$pageblocks = blocks_get_by_page($PAGE);
|
||||
|
||||
@@ -139,14 +139,6 @@ if ($limit == 'none') {
|
||||
|
||||
include($CFG->dirroot .'/blog/header.php');
|
||||
|
||||
// prints the tabs
|
||||
$currenttab = 'blogs';
|
||||
$user = $USER;
|
||||
if (!$course) {
|
||||
$course = get_record('course','id',optional_param('courseid', SITEID, PARAM_INT));
|
||||
}
|
||||
require_once($CFG->dirroot .'/user/tabs.php');
|
||||
|
||||
$blogpage = optional_param('blogpage',0,PARAM_INT);
|
||||
|
||||
blog_print_html_formatted_entries($userid, $postid, $limit, ($blogpage * $limit) ,$filtertype, $filterselect, $tagid, $tag, $filtertype, $filterselect);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" align="center">
|
||||
<input type="submit" value="<?php print_string("savechanges"); ?>" />
|
||||
<input type="submit" value="<?php print_string("savechanges"); ?>" />
|
||||
<input type="button" value="<?php print_string('cancel'); ?>" onclick="javascript:history.go(-1)" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
/// If data submitted, then process and store.
|
||||
|
||||
if ($post = data_submitted()) {
|
||||
if ($post = data_submitted()) {
|
||||
|
||||
$pagesize = optional_param('pagesize', 10, PARAM_INT);
|
||||
if ($pagesize < 1 ) {
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
print_simple_box_start('center', '', '');
|
||||
|
||||
include('./preferences.html');
|
||||
include('./preferences.html');
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@
|
||||
|
||||
if($form = data_submitted()) {
|
||||
|
||||
$form->name = clean_text(strip_tags($form->name,'<lang><span>'));
|
||||
$form->name = clean_param(strip_tags($form->name,'<lang><span>'), PARAM_CLEAN);
|
||||
|
||||
$form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin);
|
||||
if($form->duration == 1) {
|
||||
|
||||
+8
-8
@@ -241,9 +241,9 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
|
||||
//Accessibility: functionality moved to calendar_get_popup.
|
||||
if($display->thismonth && $day == $d) {
|
||||
$popup = calendar_get_popup(true, $events[$eventid]->timestart, $popupcontent);
|
||||
$popup = calendar_get_popup(true, $events[$eventid]->timestart, $popupcontent);
|
||||
} else {
|
||||
$popup = calendar_get_popup(false, $events[$eventid]->timestart, $popupcontent);
|
||||
$popup = calendar_get_popup(false, $events[$eventid]->timestart, $popupcontent);
|
||||
}
|
||||
|
||||
// Class and cell content
|
||||
@@ -279,15 +279,15 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
|
||||
}
|
||||
|
||||
// Special visual fx for today
|
||||
//Accessibility: hidden text for today, and popup.
|
||||
//Accessibility: hidden text for today, and popup.
|
||||
if($display->thismonth && $day == $d) {
|
||||
$class .= ' today';
|
||||
$today = get_string('today', 'calendar').' '.userdate(time(), get_string('strftimedayshort'));
|
||||
|
||||
if(! isset($eventsbyday[$day])) {
|
||||
$class .= ' eventnone';
|
||||
$popup = calendar_get_popup(true, false);
|
||||
$cell = '<a href="#" '.$popup.'>'.$day.'</a>';
|
||||
$class .= ' eventnone';
|
||||
$popup = calendar_get_popup(true, false);
|
||||
$cell = '<a href="#" '.$popup.'>'.$day.'</a>';
|
||||
}
|
||||
$cell = '<span class="accesshide">'.$today.' </span>'.$cell;
|
||||
}
|
||||
@@ -327,13 +327,13 @@ function calendar_get_popup($is_today, $event_timestart, $popupcontent='') {
|
||||
if (false === $event_timestart) {
|
||||
$popupcaption .= userdate(time(), get_string('strftimedayshort'));
|
||||
$popupcontent = get_string('eventnone', 'calendar');
|
||||
|
||||
|
||||
} else {
|
||||
$popupcaption .= get_string('eventsfor', 'calendar', userdate($event_timestart, get_string('strftimedayshort')));
|
||||
}
|
||||
$popupcontent = str_replace("'", "\'", htmlspecialchars($popupcontent));
|
||||
$popup = 'onmouseover="return overlib(\''.$popupcontent.'\', CAPTION, \''.$popupcaption.'\');" onmouseout="return nd();"';
|
||||
return $popup;
|
||||
return $popup;
|
||||
}
|
||||
|
||||
function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
|
||||
|
||||
+11
-11
@@ -301,33 +301,33 @@
|
||||
echo "<td>";
|
||||
echo '<a title="'.$strsettings.'" href="'.$CFG->wwwroot.'/course/edit.php?id='.
|
||||
$acourse->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" alt="'.$stredit.'" /></a> ';
|
||||
echo '<a title="'.$strassignteachers.'" href="'.$CFG->wwwroot.'/course/teacher.php?id='.
|
||||
$acourse->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/user.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/user.gif" height="11" width="11" border="0" alt="'.$strassignteachers.'" /></a> ';
|
||||
echo '<a title="'.$strdelete.'" href="delete.php?id='.$acourse->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/delete.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/delete.gif" height="11" width="11" border="0" alt="'.$strdelete.'" /></a> ';
|
||||
if (!empty($acourse->visible)) {
|
||||
echo '<a title="'.$strhide.'" href="category.php?id='.$category->id.'&page='.$page.
|
||||
'&perpage='.$perpage.'&hide='.$acourse->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/hide.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/hide.gif" height="11" width="11" border="0" alt="'.$strhide.'" /></a> ';
|
||||
} else {
|
||||
echo '<a title="'.$strshow.'" href="category.php?id='.$category->id.'&page='.$page.
|
||||
'&perpage='.$perpage.'&show='.$acourse->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/show.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/show.gif" height="11" width="11" border="0" alt="'.$strshow.'" /></a> ';
|
||||
}
|
||||
|
||||
echo '<a title="'.$strbackup.'" href="../backup/backup.php?id='.$acourse->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/backup.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/backup.gif" height="11" width="11" border="0" alt="'.$strbackup.'" /></a> ';
|
||||
|
||||
echo '<a title="'.$strrestore.'" href="../files/index.php?id='.$acourse->id.
|
||||
'&wdir=/backupdata">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/restore.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/restore.gif" height="11" width="11" border="0" alt="'.$strrestore.'" /></a> ';
|
||||
|
||||
if ($up) {
|
||||
echo '<a title="'.$strmoveup.'" href="category.php?id='.$category->id.'&page='.$page.
|
||||
'&perpage='.$perpage.'&moveup='.$acourse->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" height="11" width="11" border="0" alt="'.$strmoveup.'" /></a> ';
|
||||
} else {
|
||||
echo '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" height="11" width="11" border="0" alt="" /> ';
|
||||
}
|
||||
@@ -335,7 +335,7 @@
|
||||
if ($down) {
|
||||
echo '<a title="'.$strmovedown.'" href="category.php?id='.$category->id.'&page='.$page.
|
||||
'&perpage='.$perpage.'&movedown='.$acourse->id.'&sesskey='.$USER->sesskey.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" height="11" width="11" border="0" alt="'.$strmovedown.'" /></a> ';
|
||||
} else {
|
||||
echo '<img src="'.$CFG->wwwroot.'/pix/spacer.gif" height="11" width="11" border="0" alt="" /> ';
|
||||
}
|
||||
@@ -348,9 +348,9 @@
|
||||
} else if (isteacheredit($acourse->id)) {
|
||||
echo '<td>';
|
||||
echo '<a title="'.$strsettings.'" href="'.$CFG->wwwroot.'/course/edit.php?id='.$acourse->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/edit.gif" height="11" width="11" border="0" alt="'.$strsettings.'" /></a> ';
|
||||
echo '<a title="'.$strassignteachers.'" href="'.$CFG->wwwroot.'/course/teacher.php?id='.$acourse->id.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/user.gif" height="11" width="11" border="0" alt="" /></a> ';
|
||||
'<img src="'.$CFG->pixpath.'/t/user.gif" height="11" width="11" border="0" alt="'.$strassignteachers.'" /></a> ';
|
||||
}
|
||||
echo '</td>';
|
||||
} else {
|
||||
|
||||
@@ -68,6 +68,7 @@
|
||||
print_heading($strdeletingcourse);
|
||||
|
||||
delete_course($course->id);
|
||||
fix_course_sortorder(); //update course count in catagories
|
||||
|
||||
print_heading( get_string("deletedcourse", "", $course->shortname) );
|
||||
|
||||
|
||||
+11
-8
@@ -7,7 +7,8 @@
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->dirroot/enrol/enrol.class.php");
|
||||
|
||||
$id = required_param('id',PARAM_INT);
|
||||
$id = required_param('id', PARAM_INT);
|
||||
$loginasguest = optional_param('loginasguest', 0, PARAM_BOOL);
|
||||
|
||||
require_login();
|
||||
|
||||
@@ -19,12 +20,6 @@
|
||||
error("Could not find a site!");
|
||||
}
|
||||
|
||||
/// Check if the course is a meta course
|
||||
if ($course->metacourse) {
|
||||
print_header_simple();
|
||||
notice(get_string('coursenotaccessible'), $CFG->wwwroot);
|
||||
}
|
||||
|
||||
check_for_restricted_user($USER->username);
|
||||
|
||||
/// Refreshing enrolment data in the USER session
|
||||
@@ -47,6 +42,7 @@
|
||||
|
||||
/// Double check just in case they are actually enrolled already
|
||||
/// This might occur if they were enrolled during this session
|
||||
/// also happens when course is unhidden after student logs in
|
||||
|
||||
if ( !empty($USER->student[$course->id]) or !empty($USER->teacher[$course->id]) ) {
|
||||
|
||||
@@ -59,6 +55,13 @@
|
||||
|
||||
redirect($destination);
|
||||
}
|
||||
|
||||
/// Check if the course is a meta course
|
||||
/// moved here to fix bug 5734
|
||||
if ($course->metacourse) {
|
||||
print_header_simple();
|
||||
notice(get_string('coursenotaccessible'), $CFG->wwwroot);
|
||||
}
|
||||
|
||||
/// Users can't enroll to site course
|
||||
if (!$course->category) {
|
||||
@@ -96,7 +99,7 @@
|
||||
//User is not enrolled in the course, wants to access course content
|
||||
//as a guest, and course setting allow unlimited guest access
|
||||
//Code cribbed from course/loginas.php
|
||||
if (isset($loginasguest) && ($course->guest==1)) {
|
||||
if ($loginasguest and ($course->guest==1)) {
|
||||
$realuser = $USER->id;
|
||||
$realname = fullname($USER, true);
|
||||
$USER = guest_user();
|
||||
|
||||
@@ -30,7 +30,7 @@ if ($topic != -1) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isteacher($course->id) and !empty($marker) and confirm_sesskey()) {
|
||||
if (($marker >=0) and isteacher($course->id) and confirm_sesskey()) {
|
||||
$course->marker = $marker;
|
||||
if (! set_field("course", "marker", $marker, "id", $course->id)) {
|
||||
error("Could not mark that topic for this course");
|
||||
@@ -63,7 +63,7 @@ echo '<table id="layout-table" cellspacing="0"><tr>';
|
||||
/// The left column ...
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
echo '<td width="'.$preferred_width_left.'" id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</td>';
|
||||
}
|
||||
@@ -283,28 +283,28 @@ while ($section <= $course->numsections) {
|
||||
if (isediting($course->id)) {
|
||||
if ($course->marker == $section) { // Show the "light globe" on/off
|
||||
echo '<a href="view.php?id='.$course->id.'&marker=0&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkedthistopic.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/marked.gif" vspace="3" height="16" width="16" border="0" alt="" /></a><br />';
|
||||
'<img src="'.$CFG->pixpath.'/i/marked.gif" vspace="3" height="16" width="16" border="0" alt="'.$strmarkedthistopic.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&marker='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strmarkthistopic.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/marker.gif" vspace="3" height="16" width="16" border="0" alt="" /></a><br />';
|
||||
'<img src="'.$CFG->pixpath.'/i/marker.gif" vspace="3" height="16" width="16" border="0" alt="'.$strmarkthistopic.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($thissection->visible) { // Show the hide/show eye
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" vspace="3" height="16" width="16" border="0" alt="" /></a><br />';
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" vspace="3" height="16" width="16" border="0" alt="'.$strtopichide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" vspace="3" height="16" width="16" border="0" alt="" /></a><br />';
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopicshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" vspace="3" height="16" width="16" border="0" alt="'.$strtopicshow.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&section='.$section.'&move=-1&sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" vspace="3" height="11" width="11" border="0" alt="" /></a><br />';
|
||||
'<img src="'.$CFG->pixpath.'/t/up.gif" vspace="3" height="11" width="11" border="0" alt="'.$strmoveup.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section < $course->numsections) { // Add a arrow to move section down
|
||||
echo '<a href="view.php?id='.$course->id.'&section='.$section.'&move=1&sesskey='.$USER->sesskey.'#section-'.($section+1).'" title="'.$strmovedown.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" vspace="3" height="11" width="11" border="0" alt="" /></a><br />';
|
||||
'<img src="'.$CFG->pixpath.'/t/down.gif" vspace="3" height="11" width="11" border="0" alt="'.$strmovedown.'" /></a><br />';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -329,7 +329,7 @@ echo '</td>';
|
||||
|
||||
// The right column
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
echo '<td width="'.$preferred_width_right.'" id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
echo '<tr>';
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
echo '<td width="'.$preferred_width_left.'" id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</td>';
|
||||
}
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
// The right column
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
echo '<td width="'.$preferred_width_right.'" id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
echo '<tr>';
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
echo '<td width="'.$preferred_width_left.'" id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</td>';
|
||||
}
|
||||
@@ -51,7 +51,7 @@
|
||||
|
||||
// The right column
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
echo '<td width="'.$preferred_width_right.'" id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
if ($marker && isteacher($course->id) && confirm_sesskey()) {
|
||||
if (($marker >=0) && isteacher($course->id) && confirm_sesskey()) {
|
||||
$course->marker = $marker;
|
||||
if (! set_field("course", "marker", $marker, "id", $course->id)) {
|
||||
error("Could not mark that topic for this course");
|
||||
@@ -64,7 +64,7 @@
|
||||
/// The left column ...
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
echo '<td width="'.$preferred_width_left.'" id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</td>';
|
||||
}
|
||||
@@ -221,8 +221,8 @@
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" vspace="3" height="16" width="16" border="0" alt="'.$strtopichide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopichide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" vspace="3" height="16" width="16" border="0" alt="'.$strtopichide.'" /></a><br />';
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strtopicshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" vspace="3" height="16" width="16" border="0" alt="'.$strtopicshow.'" /></a><br />';
|
||||
}
|
||||
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
@@ -257,7 +257,7 @@
|
||||
|
||||
// The right column
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
echo '<td width="'.$preferred_width_right.'" id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
/// The left column ...
|
||||
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_LEFT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_left.'px;" id="left-column">';
|
||||
echo '<td width="'.$preferred_width_left.'" id="left-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_LEFT);
|
||||
echo '</td>';
|
||||
}
|
||||
@@ -213,8 +213,8 @@
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" vspace="3" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" vspace="3" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" vspace="3" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
|
||||
}
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&section='.$section.'&move=-1&sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
@@ -247,7 +247,7 @@
|
||||
|
||||
// The right column
|
||||
if (blocks_have_content($pageblocks, BLOCK_POS_RIGHT) || $editing) {
|
||||
echo '<td style="width: '.$preferred_width_right.'px;" id="right-column">';
|
||||
echo '<td width="'.$preferred_width_right.'" id="right-column">';
|
||||
blocks_print_group($PAGE, $pageblocks, BLOCK_POS_RIGHT);
|
||||
echo '</td>';
|
||||
}
|
||||
|
||||
@@ -217,8 +217,8 @@
|
||||
echo '<a href="view.php?id='.$course->id.'&hide='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/hide.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
} else {
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekhide.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strweekhide.'" /></a><br />';
|
||||
echo '<a href="view.php?id='.$course->id.'&show='.$section.'&sesskey='.$USER->sesskey.'#section-'.$section.'" title="'.$strweekshow.'">'.
|
||||
'<img src="'.$CFG->pixpath.'/i/show.gif" class="icon hide" alt="'.$strweekshow.'" /></a><br />';
|
||||
}
|
||||
if ($section > 1) { // Add a arrow to move section up
|
||||
echo '<a href="view.php?id='.$course->id.'&section='.$section.'&move=-1&sesskey='.$USER->sesskey.'#section-'.($section-1).'" title="'.$strmoveup.'">'.
|
||||
|
||||
@@ -57,5 +57,5 @@
|
||||
|
||||
<input type="hidden" name="group" value="<?php p($group->id) ?>" />
|
||||
<input type="hidden" name="id" value="<?php p($course->id) ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php sesskey() ?>" />
|
||||
<input type="hidden" name="sesskey" value="<?php p(sesskey()) ?>" />
|
||||
</form>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
$strimport = get_string("importdata");
|
||||
|
||||
$tcourseids = '';
|
||||
|
||||
|
||||
if ($teachers = get_records_select('user_teachers', "userid = $USER->id AND editall = 1",'','id,course')) {
|
||||
foreach ($teachers as $teacher) {
|
||||
if ($teacher->course != $course->id && $teacher->course != SITEID){
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
$taught_courses = array();
|
||||
if (!empty($tcourseids)) {
|
||||
if (!empty($tcourseids)) {
|
||||
$tcourseids = substr($tcourseids,0,-1);
|
||||
$taught_courses = get_records_list('course', 'id', $tcourseids);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
}
|
||||
else {
|
||||
foreach ($courses as $course) {
|
||||
echo "<option value=\"$course->id\">".course_format_name($course,60)."</option>\n";
|
||||
echo "<option value=\"$course->id\">".course_format_name($course,60)."</option>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -59,7 +59,7 @@
|
||||
if (iscreator()) { // Print link to create a new course
|
||||
print_single_button("edit.php", NULL, get_string("addnewcourse"), "get");
|
||||
}
|
||||
if (!empty($CFG->enablecourserequests)) {
|
||||
if (isadmin() and !empty($CFG->enablecourserequests)) {
|
||||
print_single_button('pending.php',NULL, get_string('coursespending'),"get");
|
||||
}
|
||||
echo "</center>";
|
||||
@@ -346,23 +346,23 @@ function print_category_edit($category, $displaylist, $parentslist, $depth=-1, $
|
||||
echo "<td nowrap=\"nowrap\">"; /// Print little icons
|
||||
|
||||
echo "<a title=\"$str->delete\" href=\"index.php?delete=$category->id&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/delete.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
|
||||
" src=\"$CFG->pixpath/t/delete.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"$str->delete\" /></a> ";
|
||||
|
||||
if (!empty($category->visible)) {
|
||||
echo "<a title=\"$str->hide\" href=\"index.php?hide=$category->id&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/hide.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
|
||||
" src=\"$CFG->pixpath/t/hide.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"$str->hide\" /></a> ";
|
||||
} else {
|
||||
echo "<a title=\"$str->show\" href=\"index.php?show=$category->id&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/show.gif\" height=\"11\" width=\"11\" border=\"0\"alt=\"\" /></a> ";
|
||||
" src=\"$CFG->pixpath/t/show.gif\" height=\"11\" width=\"11\" border=\"0\"alt=\"$str->show\" /></a> ";
|
||||
}
|
||||
|
||||
if ($up) {
|
||||
echo "<a title=\"$str->moveup\" href=\"index.php?moveup=$category->id&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/up.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"\" /></a> ";
|
||||
" src=\"$CFG->pixpath/t/up.gif\" height=\"11\" width=\"11\" border=\"0\" alt=\"$str->moveup\" /></a> ";
|
||||
}
|
||||
if ($down) {
|
||||
echo "<a title=\"$str->movedown\" href=\"index.php?movedown=$category->id&sesskey=$USER->sesskey\"><img".
|
||||
" src=\"$CFG->pixpath/t/down.gif\" height=\"11\" width=\"11\" border=\"0\"alt=\"\" /></a> ";
|
||||
" src=\"$CFG->pixpath/t/down.gif\" height=\"11\" width=\"11\" border=\"0\"alt=\"$str->movedown\" /></a> ";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
|
||||
+16
-13
@@ -505,7 +505,7 @@ function print_recent_activity($course) {
|
||||
|
||||
echo '<a href="'.$CFG->wwwroot.'/course/recent.php?id='.$course->id.'">'.get_string('recentactivityreport').'</a>';
|
||||
|
||||
echo '</div>';
|
||||
echo "</div>\n";
|
||||
|
||||
|
||||
// Firstly, have there been any new enrolments?
|
||||
@@ -515,18 +515,21 @@ function print_recent_activity($course) {
|
||||
|
||||
$users = get_recent_enrolments($course->id, $timestart);
|
||||
|
||||
//Accessibility: new users now appear in an <OL> list.
|
||||
if ($users) {
|
||||
echo '<div class="newusers">';
|
||||
foreach ($users as $user) {
|
||||
if (! $heading) {
|
||||
print_headline(get_string("newusers").':', 3);
|
||||
$heading = true;
|
||||
$content = true;
|
||||
}
|
||||
$fullname = fullname($user, $isteacher);
|
||||
echo '<span class="name"><a href="'.$CFG->wwwroot."/user/view.php?id=$user->id&course=$course->id\">$fullname</a></span><br />";
|
||||
if (! $heading) {
|
||||
print_headline(get_string("newusers").':', 3);
|
||||
$heading = true;
|
||||
$content = true;
|
||||
}
|
||||
echo '</div>';
|
||||
echo "<ol class=\"list\">\n";
|
||||
foreach ($users as $user) {
|
||||
|
||||
$fullname = fullname($user, $isteacher);
|
||||
echo '<li class="name"><a href="'.$CFG->wwwroot."/user/view.php?id=$user->id&course=$course->id\">$fullname</a></li>\n";
|
||||
}
|
||||
echo "</ol>\n</div>\n";
|
||||
}
|
||||
|
||||
// Next, have there been any modifications to the course structure?
|
||||
@@ -944,9 +947,9 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
|
||||
}
|
||||
|
||||
// we need to loop through the forms and check to see if we can add them.
|
||||
foreach ($modnames as $key) {
|
||||
foreach ($modnames as $key=>$value) {
|
||||
if (!course_allowed_module($course,$key))
|
||||
unset($modnames[strtolower($key)]);
|
||||
unset($modnames[$key]);
|
||||
}
|
||||
|
||||
// this is stupid but labels get put into resource, so if resource is hidden and label is not, we're in trouble.
|
||||
@@ -1813,7 +1816,7 @@ function course_allowed_module($course,$mod) {
|
||||
if (is_numeric($mod)) {
|
||||
$modid = $mod;
|
||||
} else if (is_string($mod)) {
|
||||
if ($mod = get_field("modules","id","name",strtolower($mod)))
|
||||
if ($mod = get_field("modules","id","name",$mod))
|
||||
$modid = $mod;
|
||||
}
|
||||
if (empty($modid)) {
|
||||
|
||||
+1
-1
@@ -609,7 +609,7 @@
|
||||
$sectionname = get_string("name$course->format");
|
||||
$fullmodulename = get_string("modulename", $module->name);
|
||||
|
||||
if ($form->section) {
|
||||
if ($form->section && $course->format != 'site') {
|
||||
$heading->what = $fullmodulename;
|
||||
$heading->to = "$sectionname $form->section";
|
||||
$pageheading = get_string("addinganewto", "moodle", $heading);
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->fullname);
|
||||
add_to_log($course->id, "course", "report log", "report/log/index.php?id=$course->id", $course->id);
|
||||
|
||||
$strlogs = get_string('logs');
|
||||
$stradministration = get_string('administration');
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
error("Only teachers can view logs");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->fullname);
|
||||
add_to_log($course->id, "course", "report live", "report/log/live.php?id=$course->id", $course->id);
|
||||
|
||||
session_write_close();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
error("You are not allowed to look at this page");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report outline", "report/outline/index.php?id=$course->id", $course->fullname);
|
||||
add_to_log($course->id, "course", "report outline", "report/outline/index.php?id=$course->id", $course->id);
|
||||
|
||||
$stractivityreport = get_string("activityreport");
|
||||
$strparticipants = get_string("participants");
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
print_error('mustbeteacher', '', $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->fullname);
|
||||
add_to_log($course->id, "course", "report participation", "report/participation/index.php?id=$course->id", $course->id);
|
||||
|
||||
$strparticipation = get_string('participationreport');
|
||||
$strviews = get_string('views');
|
||||
|
||||
+15
-182
@@ -2,6 +2,7 @@
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
require_once($CFG->dirroot.'/course/report/stats/lib.php');
|
||||
|
||||
if (empty($CFG->enablestats)) {
|
||||
error("Stats is not enabled.");
|
||||
@@ -36,193 +37,25 @@
|
||||
error("You need to be a teacher to use this page");
|
||||
}
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->fullname);
|
||||
|
||||
add_to_log($course->id, "course", "report stats", "report/stats/index.php?course=$course->id", $course->id);
|
||||
stats_check_uptodate($course->id);
|
||||
|
||||
|
||||
|
||||
$strreports = get_string("reports");
|
||||
$strstats = get_string('stats');
|
||||
|
||||
$menu = report_stats_mode_menu($course, $mode, $time);
|
||||
|
||||
$crumb = "<a href=\"../../view.php?id=$course->id\">$course->shortname</a> ->
|
||||
<a href=\"../../report.php?id=$course->id\">$strreports</a> ->
|
||||
$strstats";
|
||||
|
||||
print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
$crumb, '', '', true, ' ', $menu);
|
||||
|
||||
$reportoptions = stats_get_report_options($courseid,$mode);
|
||||
|
||||
$courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname');
|
||||
$courseoptions = array();
|
||||
|
||||
foreach ($courses as $c) {
|
||||
if (isteacher($c->id)) {
|
||||
$courseoptions[$c->id] = $c->shortname;
|
||||
}
|
||||
}
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$tableprefix = $CFG->prefix.'stats_user_';
|
||||
}
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
$timeoptions = stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
|
||||
if (empty($timeoptions)) {
|
||||
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
$options = array();
|
||||
$options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
|
||||
$options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
|
||||
if (isadmin()) {
|
||||
$options[STATS_MODE_RANKED] = get_string('reports');
|
||||
}
|
||||
|
||||
$menu = choose_from_menu($options,'mode',$mode,'','this.form.submit();',0,true);
|
||||
|
||||
$menu = '<form action="index.php" method="post">'."\n"
|
||||
.'<input type="hidden" name="course" value="'.$course->id.'" />'."\n"
|
||||
.'<input type="hidden" name="time" value="'.$time.'" />'."\n"
|
||||
.$menu."\n".'</form>';
|
||||
|
||||
print_header("$course->shortname: $strstats", "$course->fullname",
|
||||
"<a href=\"../../view.php?id=$course->id\">$course->shortname</a> ->
|
||||
<a href=\"../../report.php?id=$course->id\">$strreports</a> ->
|
||||
$strstats", '','',true,' ',$menu);
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n"
|
||||
.'<input type="hidden" name="mode" value="'.$mode.'" />'."\n";
|
||||
|
||||
$table->width = '*';
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
if (!empty($time)) {
|
||||
$param = stats_get_parameters($time,null,$course->id,$mode); // we only care about the table and the time string.
|
||||
$sql = 'SELECT DISTINCT s.userid,s.roleid,u.firstname,u.lastname,u.idnumber FROM '.$CFG->prefix.'stats_user_'.$param->table.' s JOIN '.$CFG->prefix.'user u ON u.id = s.userid '
|
||||
.'WHERE courseid = '.$course->id.' AND timeend >= '.$param->timeafter . ((!empty($param->stattype)) ? ' AND stattype = \''.$param->stattype.'\'' : '');
|
||||
if (!isadmin()) {
|
||||
$sql .= ' AND (s.roleid = 1 OR s.userid = '.$USER->id .")";
|
||||
}
|
||||
$sql .= " ORDER BY s.roleid ";
|
||||
} else {
|
||||
$sql = 'SELECT s.userid,u.firstname,u.lastname,u.idnumber,1 AS roleid FROM '.$CFG->prefix.'user_students s JOIN '.$CFG->prefix.'user u ON u.id = s.userid WHERE course = '.$course->id;
|
||||
}
|
||||
|
||||
$us = get_records_sql($sql);
|
||||
$admins = get_admins();
|
||||
foreach ($us as $u) {
|
||||
$role = $course->student;
|
||||
if ($u->roleid == 2) {
|
||||
$role = $course->teacher;
|
||||
}
|
||||
if (array_key_exists($u->userid,$admins)) {
|
||||
$role = get_string('admin');
|
||||
}
|
||||
$users[$u->userid] = $role.' - '.fullname($u,true);
|
||||
}
|
||||
if (empty($time)) {
|
||||
if (isadmin()) {
|
||||
$sql = 'SELECT t.userid,u.firstname,u.lastname,u.idnumber,1 AS roleid FROM '.$CFG->prefix.'user_teachers t JOIN '.$CFG->prefix.'user u ON u.id = t.userid WHERE course = '.$course->id;
|
||||
$moreusers = get_records_sql($sql);
|
||||
foreach ($moreusers as $u) {
|
||||
$users[$u->userid] = $course->teacher .' - '.fullname($u,true);
|
||||
}
|
||||
} else {
|
||||
$users[$USER->id] = $course->teacher.' - '.fullname($USER,true);
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we sort so teachers are at the top.
|
||||
if (strcmp($course->student,$course->teacher) < 0) {
|
||||
arsort($users);
|
||||
} else {
|
||||
asort($users);
|
||||
}
|
||||
|
||||
$table->align = array('left','left','left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('course'),choose_from_menu($courseoptions,'course',$course->id,'','','',true),
|
||||
get_string('users'),choose_from_menu($users,'userid',$userid,'','','',true),
|
||||
get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
} else {
|
||||
$table->align = array('left','left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('course'),choose_from_menu($courseoptions,'course',$course->id,'','','',true),
|
||||
get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
}
|
||||
|
||||
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($report) && !empty($time)) {
|
||||
if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) {
|
||||
error("This type of report is only available for the site course");
|
||||
}
|
||||
$param = stats_get_parameters($time,$report,$course->id,$mode);
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$param->table = 'user_'.$param->table;
|
||||
}
|
||||
$sql = 'SELECT timeend,'.$param->fields.' FROM '.$CFG->prefix.'stats_'.$param->table.' WHERE '
|
||||
.(($course->id == SITEID) ? '' : ' courseid = '.$course->id.' AND ')
|
||||
.((!empty($userid)) ? ' userid = '.$userid.' AND ' : '')
|
||||
. ((!empty($param->stattype)) ? ' stattype = \''.$param->stattype.'\' AND ' : '')
|
||||
.' timeend >= '.$param->timeafter
|
||||
.$param->extras
|
||||
.' ORDER BY timeend DESC';
|
||||
|
||||
$stats = get_records_sql($sql);
|
||||
|
||||
if (empty($stats)) {
|
||||
error(get_string('statsnodata'.((!empty($user)) ? 'user' : '')),$CFG->wwwroot.'/stats/index.php?course='.$course->id.'&mode='.$mode.'&time='.$time);
|
||||
}
|
||||
|
||||
$stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2)));
|
||||
|
||||
print_heading($course->shortname.' - '.get_string('statsreport'.$report).((!empty($user)) ? ' '.get_string('statsreportforuser').' ' .fullname($user,true) : ''));
|
||||
|
||||
if (empty($CFG->gdversion)) {
|
||||
echo "(".get_string("gdneed").")";
|
||||
} else {
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'&userid='.$userid.'" /></center>';
|
||||
} else {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'" /></center>';
|
||||
}
|
||||
}
|
||||
|
||||
$table = new object();
|
||||
$table->align = array('left','center','center','center');
|
||||
$param->table = str_replace('user_','',$param->table);
|
||||
$table->head = array(get_string('periodending','moodle',$param->table),$param->line1);
|
||||
if (!empty($param->line2)) {
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
$table->head[] = get_string('logs');
|
||||
|
||||
foreach ($stats as $stat) {
|
||||
$a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1);
|
||||
if (isset($stat->line2)) {
|
||||
$a[] = $stat->line2;
|
||||
}
|
||||
if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) {
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/report/log/index.php?id='.$course->id.'&chooselog=1&showusers=1&showcourses=1&user='.$userid.'&date='.usergetmidnight($stat->timeend-(60*60*24)).'">'.get_string('course').' ' .get_string('logs').'</a> ';
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
require_once($CFG->dirroot.'/course/report/stats/report.php');
|
||||
|
||||
print_footer();
|
||||
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is also required by /admin/reports/stats/index.php.
|
||||
*/
|
||||
|
||||
|
||||
require_once('../../../config.php');
|
||||
require_once($CFG->dirroot.'/lib/statslib.php');
|
||||
|
||||
|
||||
function report_stats_mode_menu($course, $mode, $time) {
|
||||
global $CFG;
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id, $mode);
|
||||
$timeoptions = report_stats_timeoptions($mode);
|
||||
|
||||
if (empty($timeoptions)) {
|
||||
error(get_string('nostatstodisplay'), $CFG->wwwroot.'/course/view.php?id='.$course->id);
|
||||
}
|
||||
|
||||
$options = array();
|
||||
$options[STATS_MODE_GENERAL] = get_string('statsmodegeneral');
|
||||
$options[STATS_MODE_DETAILED] = get_string('statsmodedetailed');
|
||||
if (isadmin()) {
|
||||
$options[STATS_MODE_RANKED] = get_string('reports');
|
||||
}
|
||||
|
||||
$menu = choose_from_menu($options,'mode',$mode,'','this.form.submit();',0,true);
|
||||
|
||||
$menu = '<form action="index.php" method="post">'."\n"
|
||||
.'<input type="hidden" name="course" value="'.$course->id.'" />'."\n"
|
||||
.'<input type="hidden" name="time" value="'.$time.'" />'."\n"
|
||||
.$menu."\n".'</form>';
|
||||
|
||||
return $menu;
|
||||
}
|
||||
|
||||
|
||||
function report_stats_timeoptions($mode) {
|
||||
global $CFG;
|
||||
|
||||
$tableprefix = $CFG->prefix.'stats_';
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$tableprefix = $CFG->prefix.'stats_user_';
|
||||
}
|
||||
|
||||
$earliestday = get_field_sql('SELECT timeend FROM '.$tableprefix.'daily ORDER BY timeend LIMIT 1');
|
||||
$earliestweek = get_field_sql('SELECT timeend FROM '.$tableprefix.'weekly ORDER BY timeend LIMIT 1');
|
||||
$earliestmonth = get_field_sql('SELECT timeend FROM '.$tableprefix.'monthly ORDER BY timeend LIMIT 1');
|
||||
|
||||
if (empty($earliestday)) $earliestday = time();
|
||||
if (empty($earliestweek)) $earliestweek = time();
|
||||
if (empty($earliestmonth)) $earliestmonth = time();
|
||||
|
||||
$now = stats_get_base_daily();
|
||||
$lastweekend = stats_get_base_weekly();
|
||||
$lastmonthend = stats_get_base_monthly();
|
||||
|
||||
return stats_get_time_options($now,$lastweekend,$lastmonthend,$earliestday,$earliestweek,$earliestmonth);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -4,11 +4,9 @@
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
echo '<p style="text-align:center;">';
|
||||
if (!empty($CFG->enablestats)) {
|
||||
echo '<p style="text-align:center;">';
|
||||
echo '<a href="'.$CFG->wwwroot.'/course/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
|
||||
} else {
|
||||
echo '<a href="'.$CFG->wwwroot.'/admin/config.php#configsectionstats">'.get_string('statsoff').'</a>';
|
||||
echo '</p>';
|
||||
}
|
||||
echo '</p>';
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
$courses = get_courses('all','c.shortname','c.id,c.shortname,c.fullname');
|
||||
$courseoptions = array();
|
||||
|
||||
foreach ($courses as $c) {
|
||||
if (isteacher($c->id)) {
|
||||
$courseoptions[$c->id] = $c->shortname;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo '<form action="index.php" method="post">'."\n"
|
||||
.'<input type="hidden" name="mode" value="'.$mode.'" />'."\n";
|
||||
|
||||
$reportoptions = stats_get_report_options($course->id, $mode);
|
||||
$timeoptions = report_stats_timeoptions($mode);
|
||||
$table->width = '*';
|
||||
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
if (!empty($time)) {
|
||||
$param = stats_get_parameters($time,null,$course->id,$mode); // we only care about the table and the time string.
|
||||
$sql = 'SELECT DISTINCT s.userid,s.roleid,u.firstname,u.lastname,u.idnumber FROM '.$CFG->prefix.'stats_user_'.$param->table.' s JOIN '.$CFG->prefix.'user u ON u.id = s.userid '
|
||||
.'WHERE courseid = '.$course->id.' AND timeend >= '.$param->timeafter . ((!empty($param->stattype)) ? ' AND stattype = \''.$param->stattype.'\'' : '');
|
||||
if (!isadmin()) {
|
||||
$sql .= ' AND (s.roleid = 1 OR s.userid = '.$USER->id .")";
|
||||
}
|
||||
$sql .= " ORDER BY s.roleid ";
|
||||
} else {
|
||||
$sql = 'SELECT s.userid,u.firstname,u.lastname,u.idnumber,1 AS roleid FROM '.$CFG->prefix.'user_students s JOIN '.$CFG->prefix.'user u ON u.id = s.userid WHERE course = '.$course->id;
|
||||
}
|
||||
|
||||
if (!$us = get_records_sql($sql)) {
|
||||
error('Cannot enter detailed view: No users found for this course.');
|
||||
}
|
||||
$admins = get_admins();
|
||||
foreach ($us as $u) {
|
||||
$role = $course->student;
|
||||
if ($u->roleid == 2) {
|
||||
$role = $course->teacher;
|
||||
}
|
||||
if (array_key_exists($u->userid,$admins)) {
|
||||
$role = get_string('admin');
|
||||
}
|
||||
$users[$u->userid] = $role.' - '.fullname($u,true);
|
||||
}
|
||||
if (empty($time)) {
|
||||
if (isadmin()) {
|
||||
$sql = 'SELECT t.userid,u.firstname,u.lastname,u.idnumber,1 AS roleid FROM '.$CFG->prefix.'user_teachers t JOIN '.$CFG->prefix.'user u ON u.id = t.userid WHERE course = '.$course->id;
|
||||
$moreusers = get_records_sql($sql);
|
||||
foreach ($moreusers as $u) {
|
||||
$users[$u->userid] = $course->teacher .' - '.fullname($u,true);
|
||||
}
|
||||
} else {
|
||||
$users[$USER->id] = $course->teacher.' - '.fullname($USER,true);
|
||||
}
|
||||
}
|
||||
|
||||
// make sure we sort so teachers are at the top.
|
||||
if (strcmp($course->student,$course->teacher) < 0) {
|
||||
arsort($users);
|
||||
} else {
|
||||
asort($users);
|
||||
}
|
||||
|
||||
$table->align = array('left','left','left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('course'),choose_from_menu($courseoptions,'course',$course->id,'','','',true),
|
||||
get_string('users'),choose_from_menu($users,'userid',$userid,'','','',true),
|
||||
get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
} else {
|
||||
$table->align = array('left','left','left','left','left','left','left');
|
||||
$table->data[] = array(get_string('course'),choose_from_menu($courseoptions,'course',$course->id,'','','',true),
|
||||
get_string('statsreporttype'),choose_from_menu($reportoptions,'report',$report,'','','',true),
|
||||
get_string('statstimeperiod'),choose_from_menu($timeoptions,'time',$time,'','','',true),
|
||||
'<input type="submit" value="'.get_string('view').'" />') ;
|
||||
}
|
||||
|
||||
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
|
||||
if (!empty($report) && !empty($time)) {
|
||||
if ($report == STATS_REPORT_LOGINS && $course->id != SITEID) {
|
||||
error("This type of report is only available for the site course");
|
||||
}
|
||||
$param = stats_get_parameters($time,$report,$course->id,$mode);
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
$param->table = 'user_'.$param->table;
|
||||
}
|
||||
$sql = 'SELECT timeend,'.$param->fields.' FROM '.$CFG->prefix.'stats_'.$param->table.' WHERE '
|
||||
.(($course->id == SITEID) ? '' : ' courseid = '.$course->id.' AND ')
|
||||
.((!empty($userid)) ? ' userid = '.$userid.' AND ' : '')
|
||||
. ((!empty($param->stattype)) ? ' stattype = \''.$param->stattype.'\' AND ' : '')
|
||||
.' timeend >= '.$param->timeafter
|
||||
.$param->extras
|
||||
.' ORDER BY timeend DESC';
|
||||
|
||||
$stats = get_records_sql($sql);
|
||||
|
||||
if (empty($stats)) {
|
||||
error(get_string('statsnodata'.((!empty($user)) ? 'user' : '')),$CFG->wwwroot.'/stats/index.php?course='.$course->id.'&mode='.$mode.'&time='.$time);
|
||||
}
|
||||
|
||||
$stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2)));
|
||||
|
||||
print_heading($course->shortname.' - '.get_string('statsreport'.$report).((!empty($user)) ? ' '.get_string('statsreportforuser').' ' .fullname($user,true) : ''));
|
||||
|
||||
if (empty($CFG->gdversion)) {
|
||||
echo "(".get_string("gdneed").")";
|
||||
} else {
|
||||
if ($mode == STATS_MODE_DETAILED) {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'&userid='.$userid.'" /></center>';
|
||||
} else {
|
||||
echo '<center><img src="'.$CFG->wwwroot.'/course/report/stats/graph.php?mode='.$mode.'&course='.$course->id.'&time='.$time.'&report='.$report.'" /></center>';
|
||||
}
|
||||
}
|
||||
|
||||
$table = new object();
|
||||
$table->align = array('left','center','center','center');
|
||||
$param->table = str_replace('user_','',$param->table);
|
||||
$table->head = array(get_string('periodending','moodle',$param->table),$param->line1);
|
||||
if (!empty($param->line2)) {
|
||||
$table->head[] = $param->line2;
|
||||
}
|
||||
$table->head[] = get_string('logs');
|
||||
|
||||
foreach ($stats as $stat) {
|
||||
$a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1);
|
||||
if (isset($stat->line2)) {
|
||||
$a[] = $stat->line2;
|
||||
}
|
||||
if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) {
|
||||
$a[] = '<a href="'.$CFG->wwwroot.'/course/report/log/index.php?id='.$course->id.'&chooselog=1&showusers=1&showcourses=1&user='.$userid.'&date='.usergetmidnight($stat->timeend-(60*60*24)).'">'.get_string('course').' ' .get_string('logs').'</a> ';
|
||||
}
|
||||
$table->data[] = $a;
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
|
||||
?>
|
||||
+1
-1
@@ -36,7 +36,7 @@
|
||||
$form = stripslashes_safe($form);
|
||||
}
|
||||
|
||||
// !! no db access using data from $form beyond this point !!
|
||||
// !! no db access using data from $form beyond this point !!
|
||||
}
|
||||
|
||||
// print_simple_box(get_string('courserequestintro'),'center');
|
||||
|
||||
+1
-4
@@ -43,7 +43,7 @@
|
||||
$courses = array();
|
||||
|
||||
/// If scale data is being submitted, then save it and continue
|
||||
|
||||
$focus = "";
|
||||
$errors = NULL;
|
||||
|
||||
if ($action == 'sendform' and confirm_sesskey()) {
|
||||
@@ -166,9 +166,6 @@
|
||||
}
|
||||
|
||||
//Print out the headers
|
||||
if (!isset($focus)) {
|
||||
$focus = "";
|
||||
}
|
||||
print_header("$course->shortname: $strscales", "$course->fullname",
|
||||
"<a href=\"view.php?id=$course->id\">$course->shortname</a>".
|
||||
" -> <a href=\"scales.php?id=$course->id\">$strscales</a>".
|
||||
|
||||
+12
-13
@@ -9,6 +9,9 @@
|
||||
$page = optional_param('page', 0, PARAM_INT); // which page to show
|
||||
$perpage = optional_param('perpage', 10, PARAM_INT); // how many per page
|
||||
$moveto = optional_param('moveto', 0, PARAM_INT); // move to category
|
||||
$edit = optional_param('edit', -1, PARAM_BOOL);
|
||||
$hide = optional_param('hide', 0, PARAM_INT);
|
||||
$show = optional_param('show', 0, PARAM_INT);
|
||||
|
||||
$search = trim(strip_tags($search)); // trim & clean raw searched string
|
||||
|
||||
@@ -29,23 +32,19 @@
|
||||
}
|
||||
|
||||
if (iscreator()) {
|
||||
if (isset($_GET['edit']) and confirm_sesskey()) {
|
||||
if ($edit == "on") {
|
||||
$USER->categoriessearchediting = true;
|
||||
} else if ($edit == "off") {
|
||||
$USER->categoriessearchediting = false;
|
||||
}
|
||||
if ($edit !== -1) {
|
||||
$USER->categoryediting = $edit;
|
||||
// If the edit mode we are leaving has higher per page than the one we are entering,
|
||||
// with pages, chances are you will get a no courses found error. So when we are switching
|
||||
// modes, set page to 0.
|
||||
$page = 0;
|
||||
}
|
||||
|
||||
$creatorediting = !empty($USER->categoriessearchediting);
|
||||
$creatorediting = !empty($USER->categoryediting);
|
||||
$adminediting = (isadmin() and $creatorediting);
|
||||
|
||||
} else {
|
||||
$creatorediting = false;
|
||||
$adminediting = false;
|
||||
$creatorediting = false;
|
||||
}
|
||||
|
||||
/// Editing functions
|
||||
@@ -54,8 +53,8 @@
|
||||
|
||||
/// Hide or show a course
|
||||
|
||||
if ((isset($hide) or isset($show)) and confirm_sesskey()) {
|
||||
if (isset($hide)) {
|
||||
if ($hide or $show and confirm_sesskey()) {
|
||||
if ($hide) {
|
||||
$course = get_record("course", "id", $hide);
|
||||
$visible = 0;
|
||||
} else {
|
||||
@@ -162,7 +161,7 @@
|
||||
|
||||
echo "<form name=\"movecourses\" action=\"search.php\" method=\"post\">";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\">";
|
||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search)."\">";
|
||||
echo "<input type=\"hidden\" name=\"search\" value=\"".s($search, true)."\">";
|
||||
echo "<input type=\"hidden\" name=\"page\" value=\"$page\">";
|
||||
echo "<input type=\"hidden\" name=\"perpage\" value=\"$perpage\">";
|
||||
echo "<table align=\"center\" border=0 cellspacing=2 cellpadding=4 class=\"generalbox\"><tr>";
|
||||
@@ -225,7 +224,7 @@
|
||||
}
|
||||
|
||||
} else {
|
||||
print_heading(get_string("nocoursesfound", "", s($search)));
|
||||
print_heading(get_string("nocoursesfound", "", s($search, true)));
|
||||
}
|
||||
|
||||
echo "<br /><br />";
|
||||
|
||||
+1
-1
@@ -211,8 +211,8 @@
|
||||
$user_complete($course, $user, $mod, $instance);
|
||||
echo "</ul>";
|
||||
|
||||
ob_end_clean();
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if (str_replace(' ', '', $output) != '<ul></ul>') {
|
||||
echo $output;
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
$studentview = optional_param('studentview', -1, PARAM_BOOL);
|
||||
$section = optional_param('section', 0, PARAM_INT);
|
||||
$move = optional_param('move', 0, PARAM_INT);
|
||||
$marker = optional_param('marker',0 , PARAM_INT);
|
||||
$marker = optional_param('marker',-1 , PARAM_INT);
|
||||
|
||||
|
||||
if (empty($id) && empty($name) && empty($idnumber)) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php // $Id$
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
define('AN_APPROVED', '1');
|
||||
@@ -156,6 +156,7 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||
return false;
|
||||
}
|
||||
$total = floatval($extra->sum) + floatval($extra->amount);
|
||||
unset($extra->sum); // this is not used in refunds table.
|
||||
if (($extra->amount == 0) || ($total > $order->amount)) {
|
||||
$message = "Can be credited up to original amount.";
|
||||
return false;
|
||||
@@ -294,7 +295,7 @@ function authorizenet_action(&$order, &$message, &$extra, $action=AN_ACTION_NONE
|
||||
if (!empty($CFG->an_avs)) {
|
||||
$avs = "avs" . strtolower($response[5]);
|
||||
$stravs = get_string($avs, "enrol_authorize");
|
||||
$message .= "<br />" . get_string("avsresult", "enrol_authorize") . $stravs;
|
||||
$message .= "<br />" . get_string("avsresult", "enrol_authorize", $stravs);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
+77
-31
@@ -15,19 +15,34 @@ if (!isset($frm->an_test)) $frm->an_test = '';
|
||||
if (!isset($frm->an_review)) $frm->an_review = '';
|
||||
if (!isset($frm->an_capture_day)) $frm->an_capture_day = '5';
|
||||
if (!isset($frm->an_emailexpired)) $frm->an_emailexpired = '2';
|
||||
if (!isset($frm->an_emailexpiredteacher)) $frm->an_emailexpiredteacher = '';
|
||||
if (!isset($frm->an_sorttype)) $frm->an_sorttype = 'ttl';
|
||||
if (!isset($frm->an_teachermanagepay)) $frm->an_teachermanagepay = '';
|
||||
|
||||
if (isset($CFG->an_cutoff)) {
|
||||
$frm->an_cutoff_hour = intval($CFG->an_cutoff) / 60;
|
||||
$frm->an_cutoff_min = intval($CFG->an_cutoff) % 60;
|
||||
$cutoff = intval($CFG->an_cutoff);
|
||||
$mins = $cutoff % 60; $hrs = ($cutoff - $mins) / 60;
|
||||
$frm->an_cutoff_hour = $hrs; $frm->an_cutoff_min = $mins;
|
||||
}
|
||||
if (!isset($frm->an_cutoff_hour)) {
|
||||
$timezone = format_float(get_user_timezone_offset(), 1);
|
||||
$frm->an_cutoff_hour = intval($timezone);
|
||||
$frm->an_cutoff_min = (intval(round($timezone)) != intval($timezone)) ? 35 : 5;
|
||||
}
|
||||
|
||||
if (!isset($frm->acceptccs)) {
|
||||
$frm->acceptccs = array_keys(get_list_of_creditcards());
|
||||
$CFG->an_acceptccs = implode(',', $frm->acceptccs);
|
||||
}
|
||||
if (!isset($frm->an_cutoff_hour)) $frm->an_cutoff_hour = '0';
|
||||
if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
|
||||
?>
|
||||
|
||||
<table cellspacing="0" cellpadding="5" border="0" align="center">
|
||||
|
||||
<tr valign="top">
|
||||
<td colspan="3" align="right"><a href="../enrol/authorize/index.php"><?php print_string("paymentmanagement", "enrol_authorize") ?></a></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizewide", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
@@ -43,6 +58,13 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_teachermanagepay:</td>
|
||||
<td><?php print_checkbox('an_teachermanagepay', '1', !empty($frm->an_teachermanagepay)) ?></td>
|
||||
<td><?php print_string("adminteachermanagepay", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<?php if (substr($CFG->wwwroot, 0, 5) !== 'https') { /* https && loginhttps */ ?>
|
||||
<tr valign="top">
|
||||
<td align="right">loginhttps:</td>
|
||||
<td><?php echo (empty($CFG->loginhttps) ? "<font color=\"red\"><b>off</b></font>" : "<font color=\"green\">on</font>") ?></td>
|
||||
@@ -51,6 +73,7 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
print_string("logindesc", "enrol_authorize", $a)
|
||||
?></td>
|
||||
</tr>
|
||||
<?php } /* end: https && loginhttps */ ?>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizesettings", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
@@ -83,20 +106,6 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
<td><?php print_string("anreferer", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_avs:</td>
|
||||
<td><input type="checkbox" value="1" name="an_avs" <?php if (!empty($frm->an_avs)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><?php print_string("adminavs", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_test:</td>
|
||||
<td><input type="checkbox" value="1" name="an_test" <?php if (!empty($frm->an_test)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><?php print_string("antestmode", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_cutoff:</td>
|
||||
<td><?php print_time_selector("an_cutoff_hour","an_cutoff_min",make_timestamp(2000,1,1,$frm->an_cutoff_hour,$frm->an_cutoff_min),5); ?></td>
|
||||
@@ -104,14 +113,35 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_teachermanagepay:</td>
|
||||
<td><input type="checkbox" value="1" name="an_teachermanagepay" <?php if (!empty($frm->an_teachermanagepay)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><?php print_string("adminteachermanagepay", "enrol_authorize") ?></td>
|
||||
<td align="right">an_avs:</td>
|
||||
<td><?php print_checkbox('an_avs', '1', !empty($frm->an_avs)) ?></td>
|
||||
<td><?php print_string("adminavs", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_test:</td>
|
||||
<td><?php print_checkbox('an_test', '1', !empty($frm->an_test)) ?></td>
|
||||
<td><?php print_string("antestmode", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_acceptccs:</td>
|
||||
<td><?php
|
||||
$allccs = get_list_of_creditcards(true);
|
||||
foreach ($allccs as $key => $val) {
|
||||
print_checkbox('acceptccs[]', $key, stristr($CFG->an_acceptccs, $key) !== false, $val); echo "<br />\n";
|
||||
}
|
||||
?></td>
|
||||
<td><?php print_string("adminacceptccs", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeccapture", "enrol_authorize") ?>
|
||||
<?php helpbutton('orderreview', '', 'enrol/authorize'); ?>
|
||||
</h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_review:</td>
|
||||
<td><input type="checkbox" value="1" name="an_review" <?php if (!empty($frm->an_review)) echo "checked=\"true\"" ?> />
|
||||
<td><?php print_checkbox('an_review', '1', !empty($frm->an_review)) ?>
|
||||
<?php helpbutton('review', get_string('adminhelpreviewtitle', 'enrol_authorize'), 'enrol/authorize'); ?></td>
|
||||
<td><?php print_string("adminreview", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
@@ -123,29 +153,45 @@ if (!isset($frm->an_cutoff_min)) $frm->an_cutoff_min = '5';
|
||||
<td><?php print_string("reviewday", "enrol_authorize", $frm->an_capture_day) ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_emailexpired:</td>
|
||||
<td><input type="text" name="an_emailexpired" size="1" maxlength="1" value="<?php p($frm->an_emailexpired) ?>" /></td>
|
||||
<td><?php print_string("adminemailexpired", "enrol_authorize", $frm->an_emailexpired) ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top"><td colspan="3"><h4><?php print_string("adminauthorizeemail", "enrol_authorize") ?></h4></td></tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_emailexpired:</td>
|
||||
<td><input type="text" name="an_emailexpired" size="1" maxlength="1" value="<?php p($frm->an_emailexpired) ?>" /></td>
|
||||
<td><?php print_string("adminemailexpired", "enrol_authorize", $frm->an_emailexpired) ?><br />
|
||||
<?php print_string("adminemailexpsetting", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_emailexpiredteacher:</td>
|
||||
<td><?php print_checkbox('an_emailexpiredteacher', '1', !empty($frm->an_emailexpiredteacher)) ?></td>
|
||||
<td><?php print_string("adminemailexpiredteacher", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">an_sorttype:</td>
|
||||
<td><?php
|
||||
$sorts = array('ttl' => get_string('adminemailexpiredsortsum', 'enrol_authorize'),
|
||||
'cnt' => get_string('adminemailexpiredsortcount', 'enrol_authorize'));
|
||||
choose_from_menu($sorts, "an_sorttype", $frm->an_sorttype, "","", "") ?></td>
|
||||
<td><?php print_string("adminemailexpiredsort", "enrol_authorize") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailstudents:</td>
|
||||
<td><input type="checkbox" value=1 name="enrol_mailstudents" <?php if (!empty($frm->enrol_mailstudents)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><?php print_checkbox('enrol_mailstudents', '1', !empty($frm->enrol_mailstudents)) ?></td>
|
||||
<td><?php print_string("mailstudents") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailteachers:</td>
|
||||
<td><input type="checkbox" value=1 name="enrol_mailteachers" <?php if (!empty($frm->enrol_mailteachers)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><?php print_checkbox('enrol_mailteachers', '1', !empty($frm->enrol_mailteachers)) ?></td>
|
||||
<td><?php print_string("mailteachers") ?></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td align="right">enrol_mailadmins:</td>
|
||||
<td><input type="checkbox" value=1 name="enrol_mailadmins" <?php if (!empty($frm->enrol_mailadmins)) echo "checked=\"true\"" ?> /></td>
|
||||
<td><?php print_checkbox('enrol_mailadmins', '1', !empty($frm->enrol_mailadmins)) ?></td>
|
||||
<td><?php print_string("mailadmins") ?></td>
|
||||
</tr>
|
||||
|
||||
|
||||
+47
-73
@@ -1,83 +1,57 @@
|
||||
<?php // $Id$
|
||||
|
||||
/**
|
||||
* New order. No transaction was made.
|
||||
*/
|
||||
define('AN_STATUS_NONE', 0x00);
|
||||
|
||||
/**
|
||||
* Authorized.
|
||||
*/
|
||||
define('AN_STATUS_AUTH', 0x01);
|
||||
|
||||
/**
|
||||
* Captured.
|
||||
*/
|
||||
define('AN_STATUS_CAPTURE', 0x02);
|
||||
|
||||
/**
|
||||
* AN_STATUS_AUTH|AN_STATUS_CAPTURE.
|
||||
/**#@+
|
||||
* Order status used in enrol_authorize table.
|
||||
*
|
||||
* NONE: New order or order is in progress. TransactionID hasn't received yet.
|
||||
* AUTH: Authorized/Pending Capture.
|
||||
* CAPTURE: Captured.
|
||||
* AUTHCAPTURE: Authorized/Captured
|
||||
* CREDIT: Refunded.
|
||||
* VOID: Cancelled.
|
||||
* EXPIRE: Expired. Orders be expired unless be accepted within 30 days.
|
||||
* TEST: Tested. It means created in TEST mode and TransactionID is 0.
|
||||
*/
|
||||
define('AN_STATUS_NONE', 0x00);
|
||||
define('AN_STATUS_AUTH', 0x01);
|
||||
define('AN_STATUS_CAPTURE', 0x02);
|
||||
define('AN_STATUS_AUTHCAPTURE', 0x03);
|
||||
define('AN_STATUS_CREDIT', 0x04);
|
||||
define('AN_STATUS_VOID', 0x08);
|
||||
define('AN_STATUS_EXPIRE', 0x10);
|
||||
define('AN_STATUS_TEST', 0x80);
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* Refunded.
|
||||
*/
|
||||
define('AN_STATUS_CREDIT', 0x04);
|
||||
|
||||
/**
|
||||
* Voided.
|
||||
*/
|
||||
define('AN_STATUS_VOID', 0x08);
|
||||
|
||||
/**
|
||||
* Expired.
|
||||
*/
|
||||
define('AN_STATUS_EXPIRE', 0x10);
|
||||
|
||||
/**
|
||||
* No action.
|
||||
*/
|
||||
define('AN_ACTION_NONE', 0x00);
|
||||
|
||||
/**
|
||||
* Used to authorize only, don't capture.
|
||||
*/
|
||||
define('AN_ACTION_AUTH_ONLY', 0x01);
|
||||
|
||||
/**
|
||||
* Used to capture, it was authorized before.
|
||||
*/
|
||||
define('AN_ACTION_PRIOR_AUTH_CAPTURE', 0x02);
|
||||
|
||||
/**
|
||||
* Used to authorize and capture.
|
||||
*/
|
||||
define('AN_ACTION_AUTH_CAPTURE', 0x03);
|
||||
|
||||
/**
|
||||
* Used to return funds to a customer's credit card.
|
||||
/**#@+
|
||||
* Actions used in authorizenet_action function.
|
||||
*
|
||||
* - Can be credited within 120 days after the original authorization was obtained.
|
||||
* - Amount can be any amount up to the original amount charged.
|
||||
* - Captured/pending settlement transactions cannot be credited,
|
||||
* instead a void must be issued to cancel the settlement.
|
||||
* NOTE: Assigns a new transactionID to the original transaction.
|
||||
* SAVE IT, so we can cancel new refund if it is a fault return.
|
||||
*/
|
||||
define('AN_ACTION_CREDIT', 0x04);
|
||||
|
||||
/**
|
||||
* Used to cancel an exiting transaction with a status of
|
||||
* authorized/pending capture, captured/pending settlement or
|
||||
* settled/refunded.
|
||||
* NONE: No action. Function always returns false.
|
||||
* AUTH_ONLY: Used to authorize only, don't capture.
|
||||
* PRIOR_AUTH_CAPTURE: Used to capture, it was authorized before.
|
||||
* AUTH_CAPTURE: Used to authorize and capture.
|
||||
* CREDIT: Used to return funds to a customer's credit card.
|
||||
* VOID: Used to cancel an exiting pending transaction.
|
||||
*
|
||||
* - Void requests effectively cancel the Capture request
|
||||
* that would start the funds transfer process.
|
||||
* - Also used to cancel existing transaction with a status of
|
||||
* settled/refunded. Credited mistakenly, so cancel it
|
||||
* and return funds to our account.
|
||||
* Credit rules:
|
||||
* 1. It can be credited within 120 days after the original authorization was obtained.
|
||||
* 2. Amount can be any amount up to the original amount charged.
|
||||
* 3. Captured/pending settlement transactions cannot be credited,
|
||||
* instead a void must be issued to cancel the settlement.
|
||||
* NOTE: It assigns a new transactionID to the original transaction.
|
||||
* We should save it, so admin can cancel new transaction if it is a mistake return.
|
||||
*
|
||||
* Void rules:
|
||||
* 1. These requests effectively cancel the Capture request that would start the funds transfer process.
|
||||
* 2. It mustn't be settled. Please set up settlement date correctly.
|
||||
* 3. These transactions can be voided:
|
||||
* authorized/pending capture, captured/pending settlement, credited/pending settlement
|
||||
*/
|
||||
define('AN_ACTION_VOID', 0x08);
|
||||
define('AN_ACTION_NONE', 0x00);
|
||||
define('AN_ACTION_AUTH_ONLY', 0x01);
|
||||
define('AN_ACTION_PRIOR_AUTH_CAPTURE', 0x02);
|
||||
define('AN_ACTION_AUTH_CAPTURE', 0x03);
|
||||
define('AN_ACTION_CREDIT', 0x04);
|
||||
define('AN_ACTION_VOID', 0x08);
|
||||
/**#@-*/
|
||||
|
||||
?>
|
||||
|
||||
@@ -19,7 +19,7 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
}
|
||||
|
||||
if ($oldversion && $oldversion < 2005071602) {
|
||||
notify("If you are using the authorize.net enrolment plugin for credit card
|
||||
notify("If you are using the authorize.net enrolment plugin for credit card
|
||||
handling, please ensure that you have turned loginhttps ON in Admin >> Variables >> Security.");
|
||||
}
|
||||
|
||||
@@ -29,11 +29,12 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
table_column('enrol_authorize', '', 'timecreated', 'integer', '10', 'unsigned', '0', 'not null', 'status');
|
||||
table_column('enrol_authorize', '', 'timeupdated', 'integer', '10', 'unsigned', '0', 'not null', 'timecreated');
|
||||
// status index for speed.
|
||||
execute_sql(" ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX status(status) ");
|
||||
execute_sql("ALTER TABLE `{$CFG->prefix}enrol_authorize` ADD INDEX status(status)");
|
||||
// defaults.
|
||||
$timenow = time();
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
execute_sql(" UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow', status='$status' ", false);
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
|
||||
$timenow = time();
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2005121200) {
|
||||
@@ -65,7 +66,7 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
if ($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime')) {
|
||||
include_once("$CFG->dirroot/enrol/authorize/action.php");
|
||||
include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
|
||||
foreach ($settlements as $settlement) {
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
|
||||
getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
|
||||
@@ -103,6 +104,10 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
|
||||
delete_records('config_plugins', 'name', 'an_nextmail');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,10 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
// status index for speed.
|
||||
modify_database('',"CREATE INDEX prefix_enrol_authorize_status_idx ON prefix_enrol_authorize (status);");
|
||||
// defaults.
|
||||
$timenow = time();
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow', status='$status'", false);
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='$status' WHERE transid<>'0'", false);
|
||||
$timenow = time();
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET timecreated='$timenow', timeupdated='$timenow'", false);
|
||||
}
|
||||
|
||||
if ($oldversion < 2005121200) {
|
||||
@@ -76,7 +77,7 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
table_column('enrol_authorize', 'timeupdated', 'settletime', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
$status = AN_STATUS_AUTH | AN_STATUS_CAPTURE;
|
||||
if ($settlements = get_records_select('enrol_authorize', "status='$status'", '', 'id, settletime')) {
|
||||
include_once("$CFG->dirroot/enrol/authorize/action.php");
|
||||
include_once("$CFG->dirroot/enrol/authorize/authorizenetlib.php");
|
||||
foreach ($settlements as $settlement) {
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET settletime = '" .
|
||||
getsettletime($settlement->settletime) . "' WHERE id = '$settlement->id'", false);
|
||||
@@ -92,10 +93,10 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
}
|
||||
|
||||
if ($oldversion < 2006010200) { // rename an_review_day
|
||||
if (isset($CFG->an_review_day)) {
|
||||
set_config('an_capture_day', $CFG->an_review_day);
|
||||
delete_records('config', 'name', 'an_review_day');
|
||||
}
|
||||
if (isset($CFG->an_review_day)) {
|
||||
set_config('an_capture_day', $CFG->an_review_day);
|
||||
delete_records('config', 'name', 'an_review_day');
|
||||
}
|
||||
}
|
||||
|
||||
if ($oldversion < 2006020100) { // rename an_cutoff_hour and an_cutoff_min to an_cutoff
|
||||
@@ -114,6 +115,10 @@ function enrol_authorize_upgrade($oldversion=0) {
|
||||
table_column('enrol_authorize', 'transid', 'transid', 'integer', '10', 'unsigned', '0', 'not null');
|
||||
}
|
||||
|
||||
if ($oldversion < 2006021501) { // delete an_nextmail record from config_plugins table
|
||||
delete_records('config_plugins', 'name', 'an_nextmail');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ CREATE TABLE prefix_enrol_authorize (
|
||||
status integer DEFAULT 0 NOT NULL,
|
||||
timecreated integer DEFAULT 0 NOT NULL,
|
||||
settletime integer DEFAULT 0 NOT NULL,
|
||||
amount varchar(10) DEFAULT '0',
|
||||
amount varchar(10) DEFAULT '0' NOT NULL,
|
||||
currency varchar(3) DEFAULT 'USD' NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -59,12 +59,7 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
|
||||
<tr>
|
||||
<td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
|
||||
<td align="left"><?php
|
||||
$CCTYPES = array(
|
||||
'mcd' => 'Master Card', 'vis' => 'Visa', 'amx' => 'American Express',
|
||||
'dsc' => 'Discover', 'dnc' => 'Diners Club', 'jcb' => 'JCB',
|
||||
'swi' => 'Switch', 'dlt' => 'Delta', 'enr' => 'EnRoute'
|
||||
);
|
||||
choose_from_menu($CCTYPES, 'cctype', $form->cctype);
|
||||
choose_from_menu(get_list_of_creditcards(), 'cctype', $form->cctype);
|
||||
if (!empty($this->ccerrors['cctype'])) { formerr($this->ccerrors['cctype']); }
|
||||
?>
|
||||
</td>
|
||||
|
||||
+164
-71
@@ -1,7 +1,43 @@
|
||||
<?php // $Id$
|
||||
|
||||
require_once $CFG->dirroot.'/enrol/enrol.class.php';
|
||||
require_once $CFG->dirroot.'/enrol/authorize/const.php';
|
||||
require_once($CFG->dirroot.'/enrol/enrol.class.php');
|
||||
require_once($CFG->dirroot.'/enrol/authorize/const.php');
|
||||
|
||||
/**
|
||||
* get_list_of_creditcards
|
||||
*
|
||||
* @param bool $getall
|
||||
* @return array
|
||||
*/
|
||||
function get_list_of_creditcards($getall = false)
|
||||
{
|
||||
global $CFG;
|
||||
|
||||
$alltypes = array(
|
||||
'mcd' => 'Master Card',
|
||||
'vis' => 'Visa',
|
||||
'amx' => 'American Express',
|
||||
'dsc' => 'Discover',
|
||||
'dnc' => 'Diners Club',
|
||||
'jcb' => 'JCB',
|
||||
'swi' => 'Switch',
|
||||
'dlt' => 'Delta',
|
||||
'enr' => 'EnRoute'
|
||||
);
|
||||
|
||||
if ($getall || empty($CFG->an_acceptccs)) {
|
||||
return $alltypes;
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
$ccs = explode(',', $CFG->an_acceptccs);
|
||||
|
||||
foreach ($ccs as $key) {
|
||||
$ret[$key] = $alltypes[$key];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* enrolment_plugin_authorize
|
||||
@@ -36,7 +72,7 @@ class enrolment_plugin_authorize
|
||||
{
|
||||
global $CFG, $USER, $form;
|
||||
|
||||
if ($this->zero_cost($course) || isguest()) {
|
||||
if ($this->zero_cost($course) or isguest()) {
|
||||
$manual = enrolment_factory::factory('manual');
|
||||
$manual->print_entry($course);
|
||||
return; // No money for guests ;)
|
||||
@@ -64,11 +100,11 @@ class enrolment_plugin_authorize
|
||||
if ($course->password) {
|
||||
print_simple_box(get_string('choosemethod', 'enrol_authorize'), 'center');
|
||||
$password = '';
|
||||
include $CFG->dirroot.'/enrol/manual/enrol.html';
|
||||
include($CFG->dirroot.'/enrol/manual/enrol.html');
|
||||
}
|
||||
|
||||
print_simple_box_start('center');
|
||||
include $CFG->dirroot.'/enrol/authorize/enrol.html';
|
||||
include($CFG->dirroot.'/enrol/authorize/enrol.html');
|
||||
print_simple_box_end();
|
||||
|
||||
print_footer();
|
||||
@@ -83,10 +119,10 @@ class enrolment_plugin_authorize
|
||||
* @access public
|
||||
*/
|
||||
function check_entry($form, $course) {
|
||||
if ((!empty($form->password)) || isguest() || $this->zero_cost($course)) {
|
||||
if ((!empty($form->password)) or isguest() or $this->zero_cost($course)) {
|
||||
$manual = enrolment_factory::factory('manual');
|
||||
$manual->check_entry($form, $course);
|
||||
} elseif ((!empty($form->ccsubmit)) && $this->validate_enrol_form($form)) {
|
||||
} elseif ((!empty($form->ccsubmit)) and $this->validate_enrol_form($form)) {
|
||||
$this->cc_submit($form, $course);
|
||||
}
|
||||
}
|
||||
@@ -103,7 +139,7 @@ class enrolment_plugin_authorize
|
||||
function cc_submit($form, $course)
|
||||
{
|
||||
global $CFG, $USER, $SESSION;
|
||||
require_once $CFG->dirroot.'/enrol/authorize/action.php';
|
||||
require_once('authorizenetlib.php');
|
||||
|
||||
$this->prevent_double_paid($course);
|
||||
|
||||
@@ -181,6 +217,7 @@ class enrolment_plugin_authorize
|
||||
|
||||
if ($an_review) { // review enabled, inform admin and redirect to main page.
|
||||
if (update_record("enrol_authorize", $order)) {
|
||||
$a = new stdClass;
|
||||
$a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$order->id";
|
||||
$a->orderid = $order->id;
|
||||
$a->transid = $order->transid;
|
||||
@@ -191,6 +228,7 @@ class enrolment_plugin_authorize
|
||||
$a->user = fullname($USER);
|
||||
$a->acstatus = ($CFG->an_capture_day > 0) ? get_string('yes') : get_string('no');
|
||||
$emailmessage = get_string('adminneworder', 'enrol_authorize', $a);
|
||||
$a = new stdClass;
|
||||
$a->course = $course->shortname;
|
||||
$a->orderid = $order->id;
|
||||
$emailsubject = get_string('adminnewordersubject', 'enrol_authorize', $a);
|
||||
@@ -224,6 +262,7 @@ class enrolment_plugin_authorize
|
||||
if (enrol_student($USER->id, $course->id, $timestart, $timeend, 'authorize')) {
|
||||
$teacher = get_teacher($course->id);
|
||||
if (!empty($CFG->enrol_mailstudents)) {
|
||||
$a = new stdClass;
|
||||
$a->coursename = "$course->fullname";
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$USER->id";
|
||||
email_to_user($USER,
|
||||
@@ -232,6 +271,7 @@ class enrolment_plugin_authorize
|
||||
get_string('welcometocoursetext', '', $a));
|
||||
}
|
||||
if (!empty($CFG->enrol_mailteachers)) {
|
||||
$a = new stdClass;
|
||||
$a->course = "$course->fullname";
|
||||
$a->user = fullname($USER);
|
||||
email_to_user($teacher,
|
||||
@@ -240,6 +280,7 @@ class enrolment_plugin_authorize
|
||||
get_string('enrolmentnewuser', '', $a));
|
||||
}
|
||||
if (!empty($CFG->enrol_mailadmins)) {
|
||||
$a = new stdClass;
|
||||
$a->course = "$course->fullname";
|
||||
$a->user = fullname($USER);
|
||||
$admins = get_admins();
|
||||
@@ -271,36 +312,39 @@ class enrolment_plugin_authorize
|
||||
function validate_enrol_form($form)
|
||||
{
|
||||
global $CFG;
|
||||
require_once $CFG->dirroot.'/enrol/authorize/ccval.php';
|
||||
require_once('ccval.php');
|
||||
|
||||
$ccexpiremm = intval($form->ccexpiremm);
|
||||
$ccexpireyyyy = intval($form->ccexpireyyyy);
|
||||
|
||||
if (empty($ccexpiremm) || empty($ccexpireyyyy)) {
|
||||
$this->ccerrors['ccexpire'] = get_string('missingccexpire', 'enrol_authorize');
|
||||
}
|
||||
$expdate = sprintf("%02d", $ccexpiremm) . strval($ccexpireyyyy);
|
||||
$validcc = CCVal($form->cc, $form->cctype, $expdate);
|
||||
if (!$validcc) {
|
||||
if ($validcc === 0) {
|
||||
$this->ccerrors['ccexpire'] = get_string('ccexpired', 'enrol_authorize');
|
||||
}
|
||||
else {
|
||||
$this->ccerrors['cc'] = get_string('ccinvalid', 'enrol_authorize');
|
||||
}
|
||||
}
|
||||
if (empty($form->ccfirstname) || empty($form->cclastname)) {
|
||||
$this->ccerrors['ccfirstlast'] = get_string('missingfullname');
|
||||
}
|
||||
if (empty($form->cc)) {
|
||||
$this->ccerrors['cc'] = get_string('missingcc', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->ccexpiremm) || empty($form->ccexpireyyyy)) {
|
||||
$this->ccerrors['ccexpire'] = get_string('missingccexpire', 'enrol_authorize');
|
||||
}
|
||||
else {
|
||||
$expdate = sprintf("%02d", intval($form->ccexpiremm)) . $form->ccexpireyyyy;
|
||||
$validcc = CCVal($form->cc, $form->cctype, $expdate);
|
||||
if (!$validcc) {
|
||||
if ($validcc === 0) {
|
||||
$this->ccerrors['ccexpire'] = get_string('ccexpired', 'enrol_authorize');
|
||||
}
|
||||
else {
|
||||
$this->ccerrors['cc'] = get_string('ccinvalid', 'enrol_authorize');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($form->ccfirstname) || empty($form->cclastname)) {
|
||||
$this->ccerrors['ccfirstlast'] = get_string('missingfullname');
|
||||
}
|
||||
|
||||
if (empty($form->cvv) || !is_numeric($form->cvv)) {
|
||||
$this->ccerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
|
||||
}
|
||||
if (empty($form->cctype)) {
|
||||
|
||||
if (empty($form->cctype) || !in_array($form->cctype, array_keys(get_list_of_creditcards()))) {
|
||||
$this->ccerrors['cctype'] = get_string('missingcctype', 'enrol_authorize');
|
||||
}
|
||||
|
||||
if (!empty($CFG->an_avs)) {
|
||||
if (empty($form->ccaddress)) {
|
||||
$this->ccerrors['ccaddress'] = get_string('missingaddress', 'enrol_authorize');
|
||||
@@ -412,7 +456,7 @@ class enrolment_plugin_authorize
|
||||
notify('PHP must be compiled with SSL support (--with-openssl)');
|
||||
}
|
||||
|
||||
if (empty($CFG->loginhttps)) {
|
||||
if (empty($CFG->loginhttps) and substr($CFG->wwwroot, 0, 5) !== 'https') {
|
||||
notify('loginhttps must be ON');
|
||||
}
|
||||
|
||||
@@ -428,6 +472,7 @@ class enrolment_plugin_authorize
|
||||
}
|
||||
|
||||
if ($count = count_records('enrol_authorize', 'status', AN_STATUS_AUTH)) {
|
||||
$a = new stdClass;
|
||||
$a->count = $count;
|
||||
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=".AN_STATUS_AUTH;
|
||||
notify(get_string('adminpendingorders', 'enrol_authorize', $a));
|
||||
@@ -442,7 +487,7 @@ class enrolment_plugin_authorize
|
||||
}
|
||||
}
|
||||
|
||||
include $CFG->dirroot.'/enrol/authorize/config.html';
|
||||
include($CFG->dirroot.'/enrol/authorize/config.html');
|
||||
}
|
||||
|
||||
|
||||
@@ -460,24 +505,29 @@ class enrolment_plugin_authorize
|
||||
// site settings
|
||||
set_config('enrol_cost', optional_param('enrol_cost', 5, PARAM_INT));
|
||||
set_config('enrol_currency', optional_param('enrol_currency', 'USD', PARAM_ALPHA));
|
||||
set_config('enrol_mailstudents', optional_param('enrol_mailstudents', ''));
|
||||
set_config('enrol_mailteachers', optional_param('enrol_mailteachers', ''));
|
||||
set_config('enrol_mailadmins', optional_param('enrol_mailadmins', ''));
|
||||
set_config('enrol_mailstudents', optional_param('enrol_mailstudents', 0, PARAM_BOOL));
|
||||
set_config('enrol_mailteachers', optional_param('enrol_mailteachers', 0, PARAM_BOOL));
|
||||
set_config('enrol_mailadmins', optional_param('enrol_mailadmins', 0, PARAM_BOOL));
|
||||
|
||||
// optional authorize.net settings
|
||||
set_config('an_avs', optional_param('an_avs', ''));
|
||||
set_config('an_test', optional_param('an_test', ''));
|
||||
set_config('an_teachermanagepay', optional_param('an_teachermanagepay', ''));
|
||||
set_config('an_avs', optional_param('an_avs', 0, PARAM_BOOL));
|
||||
set_config('an_test', optional_param('an_test', 0, PARAM_BOOL));
|
||||
set_config('an_teachermanagepay', optional_param('an_teachermanagepay', 0, PARAM_BOOL));
|
||||
set_config('an_referer', optional_param('an_referer', 'http://', PARAM_URL));
|
||||
|
||||
$acceptccs = optional_param('acceptccs', array_keys(get_list_of_creditcards()), PARAM_ALPHA);
|
||||
set_config('an_acceptccs', implode(',', $acceptccs));
|
||||
|
||||
$cutoff_hour = optional_param('an_cutoff_hour', 0, PARAM_INT);
|
||||
$cutoff_min = optional_param('an_cutoff_min', 5, PARAM_INT);
|
||||
set_config('an_cutoff', $cutoff_hour * 60 + $cutoff_min);
|
||||
|
||||
// cron depencies
|
||||
$reviewval = optional_param('an_review', '');
|
||||
$reviewval = optional_param('an_review', 0, PARAM_BOOL);
|
||||
$captureday = optional_param('an_capture_day', 5, PARAM_INT);
|
||||
$emailexpired = optional_param('an_emailexpired', 2, PARAM_INT);
|
||||
$emailexpiredteacher = optional_param('an_emailexpiredteacher', 0, PARAM_BOOL);
|
||||
$sorttype = optional_param('an_sorttype', 'ttl', PARAM_ALPHA);
|
||||
|
||||
$captureday = ($captureday > 29) ? 29 : (($captureday < 0) ? 0 : $captureday);
|
||||
$emailexpired = ($emailexpired > 5) ? 5 : (($emailexpired < 0) ? 0 : $emailexpired);
|
||||
@@ -492,14 +542,18 @@ class enrolment_plugin_authorize
|
||||
set_config('an_review', $reviewval);
|
||||
set_config('an_capture_day', $captureday);
|
||||
set_config('an_emailexpired', $emailexpired);
|
||||
set_config('an_emailexpiredteacher', $emailexpiredteacher);
|
||||
set_config('an_sorttype', $sorttype);
|
||||
|
||||
// required fields
|
||||
$loginval = optional_param('an_login', '');
|
||||
$tranval = optional_param('an_tran_key', '');
|
||||
$passwordval = optional_param('an_password', '');
|
||||
|
||||
if (empty($CFG->loginhttps) || (!$this->check_openssl_loaded()) ||
|
||||
empty($loginval) || (empty($tranval) && empty($passwordval))) {
|
||||
if ((empty($CFG->loginhttps) and substr($CFG->wwwroot, 0, 5) !== 'https') ||
|
||||
!$this->check_openssl_loaded() ||
|
||||
empty($loginval) ||
|
||||
(empty($tranval) and empty($passwordval))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -518,16 +572,17 @@ class enrolment_plugin_authorize
|
||||
* @param mixed $data
|
||||
* @access private
|
||||
*/
|
||||
function email_to_admin($subject, $data) {
|
||||
$admin = get_admin();
|
||||
function email_to_admin($subject, $data)
|
||||
{
|
||||
$site = get_site();
|
||||
$admin = get_admin();
|
||||
$data = (array)$data;
|
||||
|
||||
$message = "$site->fullname: Transaction failed.\n\n$subject\n\n";
|
||||
foreach ($data as $key => $value) {
|
||||
$message .= "$key => $value\n";
|
||||
}
|
||||
email_to_user($admin, $admin, "CC ERROR: ".$subject, $message);
|
||||
email_to_user($admin, $admin, "Authorize.net ERROR: ".$subject, $message);
|
||||
}
|
||||
|
||||
|
||||
@@ -544,9 +599,10 @@ class enrolment_plugin_authorize
|
||||
$status = empty($CFG->an_test) ? AN_STATUS_AUTH : AN_STATUS_NONE;
|
||||
|
||||
if ($rec=get_record('enrol_authorize','userid',$USER->id,'courseid',$course->id,'status',$status,'id')) {
|
||||
$a = new stdClass;
|
||||
$a->orderid = $rec->id;
|
||||
$a->url = "$CFG->wwwroot/enrol/authorize/index.php?order=$a->orderid";
|
||||
redirect($CFG->wwwroot, get_string("paymentpending", "enrol_authorize", $a), '20');
|
||||
redirect($a->url, get_string("paymentpending", "enrol_authorize", $a), '10');
|
||||
return;
|
||||
}
|
||||
if (isset($SESSION->ccpaid)) {
|
||||
@@ -574,44 +630,80 @@ class enrolment_plugin_authorize
|
||||
*/
|
||||
function cron()
|
||||
{
|
||||
global $CFG;
|
||||
require_once $CFG->dirroot.'/enrol/authorize/action.php';
|
||||
global $CFG, $SITE;
|
||||
require_once($CFG->dirroot.'/enrol/authorize/authorizenetlib.php');
|
||||
|
||||
$oneday = 86400;
|
||||
$timenow = time();
|
||||
$random100 = mt_rand(0, 100);
|
||||
$timenowsettle = getsettletime($timenow);
|
||||
$timediff30 = $timenowsettle - (30 * $oneday);
|
||||
$mconfig = get_config('enrol/authorize');
|
||||
set_config('an_lastcron', $timenow, 'enrol/authorize');
|
||||
|
||||
if ($random100 < 33) {
|
||||
$select = "(status = '" .AN_STATUS_NONE. "') AND (timecreated < '$timediff30')";
|
||||
if (intval($mconfig->an_dailysettlement) <= $timenowsettle) {
|
||||
set_config('an_dailysettlement', $timenowsettle + $oneday, 'enrol/authorize');
|
||||
// Some clean-up and update
|
||||
$select = "(status='".AN_STATUS_NONE."') AND (timecreated<'$timediff30')";
|
||||
delete_records_select('enrol_authorize', $select);
|
||||
}
|
||||
elseif ($random100 > 66) {
|
||||
$select = "(status = '" .AN_STATUS_AUTH. "') AND (timecreated < '$timediff30')";
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status = '" .AN_STATUS_EXPIRE. "' WHERE $select", false);
|
||||
}
|
||||
else {
|
||||
$select = "(status='".AN_STATUS_AUTH."') AND (timecreated<'$timediff30')";
|
||||
execute_sql("UPDATE {$CFG->prefix}enrol_authorize SET status='".AN_STATUS_EXPIRE."' WHERE $select", false);
|
||||
$timediff60 = $timenowsettle - (60 * $oneday);
|
||||
$select = "(status = '" .AN_STATUS_EXPIRE. "') AND (timecreated < '$timediff60')";
|
||||
$select = "(status='".AN_STATUS_EXPIRE."') AND (timecreated<'$timediff60')";
|
||||
delete_records_select('enrol_authorize', $select);
|
||||
}
|
||||
|
||||
if (!empty($CFG->an_emailexpired) && intval($mconfig->an_nextmail) < $timenowsettle) {
|
||||
set_config('an_nextmail', $timenowsettle + $oneday + 1, 'enrol/authorize');
|
||||
$timediffem = $timenowsettle - ((30 - intval($CFG->an_emailexpired)) * $oneday);
|
||||
$select = "(status = '" . AN_STATUS_AUTH . "') AND " .
|
||||
"(timecreated < '$timediffem') AND (timecreated > '$timediff30')";
|
||||
if ($count = count_records_select('enrol_authorize', $select)) {
|
||||
$a->pending = $count;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$a->enrolurl = "$CFG->wwwroot/$CFG->admin/users.php";
|
||||
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=".AN_STATUS_AUTH;
|
||||
$message = get_string('pendingordersemail', 'enrol_authorize', $a);
|
||||
$adminuser = get_admin();
|
||||
email_to_user($adminuser, $adminuser, "WARNING: PENDING PAYMENTS", $a);
|
||||
// Daily warning email for expiring pending orders.
|
||||
if (!empty($CFG->an_emailexpired)) {
|
||||
$timediffem = $timenowsettle - ((30 - intval($CFG->an_emailexpired)) * $oneday);
|
||||
$select = "(status='". AN_STATUS_AUTH ."') AND (timecreated<'$timediffem') AND (timecreated>'$timediff30')";
|
||||
if ($count = count_records_select('enrol_authorize', $select)) {
|
||||
$a = new stdClass;
|
||||
$a->pending = $count;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$a->course = $SITE->shortname;
|
||||
$subject = get_string('pendingorderssubject', 'enrol_authorize', $a);
|
||||
$a = new stdClass;
|
||||
$a->pending = $count;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$a->course = $SITE->fullname;
|
||||
$a->enrolurl = "$CFG->wwwroot/$CFG->admin/users.php";
|
||||
$a->url = $CFG->wwwroot."/enrol/authorize/index.php?status=".AN_STATUS_AUTH;
|
||||
$message = get_string('pendingordersemail', 'enrol_authorize', $a);
|
||||
$adminuser = get_admin();
|
||||
email_to_user($adminuser, $adminuser, $subject, $message);
|
||||
if (!empty($CFG->an_teachermanagepay) and !empty($CFG->an_emailexpiredteacher)) {
|
||||
$sorttype = empty($CFG->an_sorttype) ? 'ttl' : $CFG->an_sorttype;
|
||||
$sql = "SELECT E.courseid, E.currency, C.fullname, C.shortname, " .
|
||||
"COUNT(E.courseid) AS cnt, SUM(E.amount) as ttl " .
|
||||
"FROM {$CFG->prefix}enrol_authorize E " .
|
||||
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
|
||||
"WHERE $select GROUP BY E.courseid ORDER BY $sorttype DESC";
|
||||
$message = ''; $subject = ''; $lastcourse = 0;
|
||||
$courseidandcounts = get_records_sql($sql);
|
||||
foreach($courseidandcounts as $courseidandcount) {
|
||||
if ($lastcourse != $courseidandcount->courseid) {
|
||||
$lastcourse = $courseidandcount->courseid;
|
||||
$a = new stdClass;
|
||||
$a->course = $courseidandcount->shortname;
|
||||
$a->pending = $courseidandcount->cnt;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$subject = get_string('pendingorderssubject', 'enrol_authorize', $a);
|
||||
$a = new stdClass;
|
||||
$a->course = $courseidandcount->fullname;
|
||||
$a->pending = $courseidandcount->cnt;
|
||||
$a->currency = $courseidandcount->currency;
|
||||
$a->sumcost = $courseidandcount->ttl;
|
||||
$a->days = $CFG->an_emailexpired;
|
||||
$a->url = $CFG->wwwroot.'/enrol/authorize/index.php?course='.
|
||||
$lastcourse.'&status='.AN_STATUS_AUTH;
|
||||
$message = get_string('pendingordersemailteacher', 'enrol_authorize', $a);
|
||||
}
|
||||
if ($teachers = get_course_teachers($lastcourse)) {
|
||||
foreach ($teachers as $teacher) {
|
||||
email_to_user($teacher, $adminuser, $subject, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -715,6 +807,7 @@ class enrolment_plugin_authorize
|
||||
$teacher = get_teacher($lastcourse);
|
||||
}
|
||||
$user = get_record('user', 'id', $order->userid);
|
||||
$a = new stdClass;
|
||||
$a->coursename = $order->fullname;
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
|
||||
email_to_user($user, $teacher,
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
}
|
||||
|
||||
/// Load strings. All strings should be defined here. locallib.php uses these strings.
|
||||
$strs = get_strings(array('user','status','action','delete','time','course','confirm','yes','no','all','none','error'));
|
||||
$authstrs = get_strings(array('paymentmanagement','orderid','void','capture','refund','delete',
|
||||
$strs = get_strings(array('status','action','time','course','confirm','yes','no','all','none','error'));
|
||||
$authstrs = get_strings(array('orderid','nameoncard','void','capture','refund','delete',
|
||||
'authcaptured','authorizedpendingcapture','capturedpendingsettle','capturedsettled',
|
||||
'settled','refunded','cancelled','expired','tested',
|
||||
'transid','settlementdate','notsettled','amount',
|
||||
'howmuch','captureyes','unenrolstudent'), 'enrol_authorize');
|
||||
'settled','refunded','cancelled','expired','tested','new',
|
||||
'transid','settlementdate','notsettled','amount','unenrolstudent'), 'enrol_authorize');
|
||||
|
||||
/// Print header
|
||||
$strpaymentmanagement = get_string('paymentmanagement', 'enrol_authorize');
|
||||
if (!$course = get_record('course', 'id', $courseid)) {
|
||||
error('Could not find that course');
|
||||
}
|
||||
print_header_simple("$authstrs->paymentmanagement", "", "<a href=\"index.php\">$authstrs->paymentmanagement</a>");
|
||||
print_header_simple("$strpaymentmanagement", "", "<a href=\"index.php\">$strpaymentmanagement</a>");
|
||||
|
||||
|
||||
/// If orderid is empty, user wants to see all orders
|
||||
|
||||
+116
-82
@@ -1,11 +1,11 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
die('Direct access to this script is forbidden.');
|
||||
}
|
||||
|
||||
require_once('const.php');
|
||||
require_once('action.php');
|
||||
require_once('authorizenetlib.php');
|
||||
|
||||
define('ORDER_CAPTURE', 'capture');
|
||||
define('ORDER_DELETE', 'delete');
|
||||
@@ -21,12 +21,12 @@ function authorize_print_orders()
|
||||
global $CFG, $USER;
|
||||
global $strs, $authstrs;
|
||||
global $courseid, $userid;
|
||||
require_once $CFG->libdir.'/tablelib.php';
|
||||
require_once($CFG->libdir.'/tablelib.php');
|
||||
|
||||
$perpage = 10;
|
||||
$status = optional_param('status', AN_STATUS_NONE, PARAM_INT);
|
||||
|
||||
if (!isteacher($courseid)) {
|
||||
if (! isteacher($courseid)) {
|
||||
$userid = $USER->id;
|
||||
}
|
||||
|
||||
@@ -36,23 +36,26 @@ function authorize_print_orders()
|
||||
AN_STATUS_AUTHCAPTURE => $authstrs->authcaptured,
|
||||
AN_STATUS_CREDIT => $authstrs->refunded,
|
||||
AN_STATUS_VOID => $authstrs->cancelled,
|
||||
AN_STATUS_EXPIRE => $authstrs->expired
|
||||
AN_STATUS_EXPIRE => $authstrs->expired,
|
||||
AN_STATUS_TEST => $authstrs->tested
|
||||
);
|
||||
|
||||
print_simple_box_start('center', '80%');
|
||||
echo "$strs->status: ";
|
||||
echo popup_form($baseurl.'&course='.$courseid.'&status=', $statusmenu, 'statusmenu', $status, '', '', '', true);
|
||||
if ($courses = get_courses('all', 'c.sortorder ASC', 'c.id,c.fullname,c.enrol')) {
|
||||
$popupcrs = array();
|
||||
foreach ($courses as $crs) {
|
||||
if ($crs->enrol == 'authorize' || (empty($crs->enrol) && $CFG->enrol == 'authorize')) {
|
||||
$popupcrs[(int)$crs->id] = $crs->fullname;
|
||||
$popupcrs[intval($crs->id)] = $crs->fullname;
|
||||
}
|
||||
}
|
||||
echo " $strs->course: ";
|
||||
echo popup_form($baseurl.'&status='.$status.'&course=', $popupcrs, 'coursesmenu', $courseid, '', '', '', true);
|
||||
if (!empty($popupcrs)) {
|
||||
print_simple_box_start('center', '100%');
|
||||
echo "$strs->status: ";
|
||||
echo popup_form($baseurl.'&course='.$courseid.'&status=',$statusmenu,'statusmenu',$status,'','','',true);
|
||||
echo " $strs->course: ";
|
||||
echo popup_form($baseurl.'&status='.$status.'&course=',$popupcrs,'coursesmenu',$courseid,'','','',true);
|
||||
print_simple_box_end();
|
||||
}
|
||||
}
|
||||
print_simple_box_end();
|
||||
|
||||
$table = new flexible_table('enrol-authorize');
|
||||
$table->set_attribute('width', '100%');
|
||||
@@ -62,31 +65,38 @@ function authorize_print_orders()
|
||||
$table->set_attribute('class', 'generaltable generalbox');
|
||||
|
||||
$table->define_columns(array('id', 'timecreated', 'userid', 'status', ''));
|
||||
$table->define_headers(array($authstrs->orderid, $strs->time, $strs->user, $strs->status, $strs->action));
|
||||
$table->define_headers(array($authstrs->orderid, $strs->time, $authstrs->nameoncard, $strs->status, $strs->action));
|
||||
$table->define_baseurl($baseurl."&status=$status");
|
||||
|
||||
$table->sortable(true);
|
||||
$table->sortable(true, 'id', SORT_DESC);
|
||||
$table->pageable(true);
|
||||
$table->setup();
|
||||
|
||||
$select = "SELECT E.id, E.transid, E.courseid, E.userid, E.status, E.ccname, E.timecreated, E.settletime";
|
||||
$from = " FROM {$CFG->prefix}enrol_authorize E ";
|
||||
$select = "SELECT E.id, E.transid, E.courseid, E.userid, E.status, E.ccname, E.timecreated, E.settletime ";
|
||||
$from = "FROM {$CFG->prefix}enrol_authorize E ";
|
||||
$where = "WHERE (1=1) ";
|
||||
|
||||
if ($status > AN_STATUS_NONE) {
|
||||
if ($status == AN_STATUS_CREDIT) {
|
||||
$from .= "INNER JOIN {$CFG->prefix}enrol_authorize_refunds R ON E.id = R.orderid ";
|
||||
$where = "WHERE (E.status = '" . AN_STATUS_AUTHCAPTURE . "') ";
|
||||
}
|
||||
else {
|
||||
$where = "WHERE (E.status = '$status') ";
|
||||
switch ($status)
|
||||
{
|
||||
case AN_STATUS_CREDIT:
|
||||
$from .= "INNER JOIN {$CFG->prefix}enrol_authorize_refunds R ON E.id = R.orderid ";
|
||||
$where .= "AND (E.status = '" . AN_STATUS_AUTHCAPTURE . "') ";
|
||||
break;
|
||||
|
||||
case AN_STATUS_TEST:
|
||||
$newordertime = time() - 120; // -2 minutes. Order may be still in process.
|
||||
$where .= "AND (E.status = '" . AN_STATUS_NONE . "') AND (E.transid = '0') AND (E.timecreated < $newordertime) ";
|
||||
break;
|
||||
|
||||
default:
|
||||
$where .= "AND (E.status = '$status') ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (empty($CFG->an_test)) {
|
||||
$where = "WHERE (E.status != '" . AN_STATUS_NONE . "') ";
|
||||
}
|
||||
else {
|
||||
$where = "WHERE (1=1) ";
|
||||
$where .= "AND (E.status != '" . AN_STATUS_NONE . "') ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +110,6 @@ function authorize_print_orders()
|
||||
if ($sort = $table->get_sql_sort()) {
|
||||
$sort = ' ORDER BY ' . $sort;
|
||||
}
|
||||
else {
|
||||
$sort = ' ORDER BY id DESC ';
|
||||
}
|
||||
|
||||
$totalcount = count_records_sql('SELECT COUNT(*) ' . $from . $where);
|
||||
$table->initialbars($totalcount > $perpage);
|
||||
@@ -124,7 +131,7 @@ function authorize_print_orders()
|
||||
}
|
||||
else {
|
||||
foreach ($actionstatus->actions as $value) {
|
||||
$actions .= " <a href='index.php?$value=y&order=$record->id'>{$authstrs->$value}</a> ";
|
||||
$actions .= " <a href='index.php?$value=y&sesskey=$USER->sesskey&order=$record->id'>{$authstrs->$value}</a> ";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,9 +163,10 @@ function authorize_print_order_details($orderno)
|
||||
$cmdrefund = optional_param(ORDER_REFUND, '', PARAM_ALPHA);
|
||||
$cmdvoid = optional_param(ORDER_VOID, '', PARAM_ALPHA);
|
||||
|
||||
$unenrol = optional_param('unenrol', '', PARAM_ALPHA);
|
||||
$confirm = optional_param('confirm', '', PARAM_ALPHA);
|
||||
$unenrol = optional_param('unenrol', 0, PARAM_BOOL);
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL);
|
||||
|
||||
$table = new stdClass;
|
||||
$table->width = '100%';
|
||||
$table->size = array('30%', '70%');
|
||||
$table->align = array('right', 'left');
|
||||
@@ -174,13 +182,14 @@ function authorize_print_order_details($orderno)
|
||||
}
|
||||
|
||||
if ($USER->id != $order->userid) { // Current user viewing someone else's order
|
||||
if (!isteacher($order->courseid)) {
|
||||
if (! isteacher($order->courseid)) {
|
||||
error("Students can view their order.");
|
||||
}
|
||||
}
|
||||
|
||||
echo "<form action='index.php' method='post'>\n";
|
||||
echo "<input type='hidden' name='order' value='$orderno'>\n";
|
||||
echo "<form action=\"index.php\" method=\"post\">\n";
|
||||
echo "<input type=\"hidden\" name=\"order\" value=\"$orderno\">\n";
|
||||
echo "<input type=\"hidden\" name=\"sesskey\" value=\"" . sesskey() . "\" />";
|
||||
|
||||
$settled = settled($order);
|
||||
$status = authorize_get_status_action($order);
|
||||
@@ -191,22 +200,24 @@ function authorize_print_order_details($orderno)
|
||||
if (empty($cmdcapture) and empty($cmdrefund) and empty($cmdvoid) and empty($cmddelete)) {
|
||||
$table->data[] = array("<b>$strs->course:</b>", $order->shortname);
|
||||
$table->data[] = array("<b>$strs->status:</b>", $authstrs->{$status->status});
|
||||
$table->data[] = array("<b>$strs->user:</b>", $order->ccname);
|
||||
$table->data[] = array("<b>$authstrs->nameoncard:</b>", $order->ccname);
|
||||
$table->data[] = array("<b>$strs->time:</b>", userdate($order->timecreated));
|
||||
$table->data[] = array("<b>$authstrs->settlementdate:</b>", $settled ?
|
||||
userdate($order->settletime) : $authstrs->notsettled);
|
||||
}
|
||||
$table->data[] = array(" ", "<hr size='1' noshade>\n");
|
||||
|
||||
if (!empty($cmdcapture)) { // CAPTURE
|
||||
if (!empty($cmdcapture) and confirm_sesskey()) { // CAPTURE
|
||||
if (!in_array(ORDER_CAPTURE, $status->actions)) {
|
||||
$a = new stdClass;
|
||||
$a->action = $authstrs->capture;
|
||||
error(get_string('youcantdo', 'enrol_authorize', $a));
|
||||
}
|
||||
|
||||
if (empty($confirm)) {
|
||||
$strcaptureyes = get_string('captureyes', 'enrol_authorize');
|
||||
$table->data[] = array("<b>$strs->confirm:</b>",
|
||||
"$authstrs->captureyes<br /><a href='index.php?order=$orderno&".ORDER_CAPTURE."=y&confirm=y'>$strs->yes</a>
|
||||
"$strcaptureyes<br /><a href='index.php?order=$orderno&sesskey=$USER->sesskey&".ORDER_CAPTURE."=y&confirm=1'>$strs->yes</a>
|
||||
<a href='index.php?order=$orderno'>$strs->no</a>");
|
||||
}
|
||||
else {
|
||||
@@ -227,9 +238,11 @@ function authorize_print_order_details($orderno)
|
||||
if (enrol_student($order->userid, $order->courseid, $timestart, $timeend, 'authorize')) {
|
||||
$user = get_record('user', 'id', $order->userid);
|
||||
$teacher = get_teacher($order->courseid);
|
||||
$a = new stdClass;
|
||||
$a->coursename = $order->shortname;
|
||||
$a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
|
||||
email_to_user($user, $teacher,
|
||||
email_to_user($user,
|
||||
$teacher,
|
||||
get_string("enrolmentnew", '', $order->shortname),
|
||||
get_string('welcometocoursetext', '', $a));
|
||||
redirect("index.php?order=$orderno");
|
||||
@@ -247,13 +260,14 @@ function authorize_print_order_details($orderno)
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
elseif (!empty($cmdrefund)) { // REFUND
|
||||
elseif (!empty($cmdrefund) and confirm_sesskey()) { // REFUND
|
||||
if (!in_array(ORDER_REFUND, $status->actions)) {
|
||||
$a = new stdClass;
|
||||
$a->action = $authstrs->refund;
|
||||
error(get_string('youcantdo', 'enrol_authorize', $a));
|
||||
}
|
||||
|
||||
$extra = new stdClass();
|
||||
$extra = new stdClass;
|
||||
$extra->sum = 0.0;
|
||||
$extra->orderid = $orderno;
|
||||
|
||||
@@ -269,13 +283,15 @@ function authorize_print_order_details($orderno)
|
||||
}
|
||||
else {
|
||||
$amount = format_float(optional_param('amount', $upto), 2);
|
||||
if (($amount > $upto) || empty($confirm)) {
|
||||
if (($amount > $upto) or empty($confirm)) {
|
||||
$a = new stdClass;
|
||||
$a->upto = $upto;
|
||||
$strcanbecredit = get_string('canbecredit', 'enrol_authorize', $a);
|
||||
$table->data[] = array("<b>$authstrs->unenrolstudent</b>",
|
||||
"<input type='checkbox' name='unenrol' value='y'" . (!empty($unenrol) ? " checked" : "") . ">");
|
||||
$table->data[] = array("<b>$authstrs->howmuch</b>",
|
||||
"<input type='hidden' name='confirm' value='y'>
|
||||
$strhowmuch = get_string('howmuch', 'enrol_authorize');
|
||||
$cbunenrol = print_checkbox('unenrol', '1', !empty($unenrol), '', '', '', true);
|
||||
$table->data[] = array("<b>$authstrs->unenrolstudent</b>", $cbunenrol);
|
||||
$table->data[] = array("<b>$strhowmuch</b>",
|
||||
"<input type='hidden' name='confirm' value='1'>
|
||||
<input type='text' size='5' name='amount' value='$amount'>
|
||||
$strcanbecredit<br /><input type='submit' name='".ORDER_REFUND."' value='$authstrs->refund'>");
|
||||
}
|
||||
@@ -286,13 +302,23 @@ function authorize_print_order_details($orderno)
|
||||
if ($success) {
|
||||
if (empty($CFG->an_test)) {
|
||||
$extra->id = insert_record("enrol_authorize_refunds", $extra);
|
||||
if (!$extra->id) {
|
||||
// to do: email admin
|
||||
if (empty($extra->id)) {
|
||||
$emailsubject = "Authorize.net: insert record error";
|
||||
$emailmessage = "Error while trying to insert new data to enrol_authorize_refunds table:\n";
|
||||
$data = (array)$extra;
|
||||
foreach ($data as $key => $value) {
|
||||
$emailmessage .= "$key => $value\n";
|
||||
}
|
||||
$adminuser = get_admin();
|
||||
email_to_user($adminuser, $adminuser, $emailsubject, $emailmessage);
|
||||
$table->data[] = array("<b><font color=red>$strs->error:</font></b>", $emailmessage);
|
||||
}
|
||||
if (!empty($unenrol)) {
|
||||
unenrol_student($order->userid, $order->courseid);
|
||||
else {
|
||||
if (!empty($unenrol)) {
|
||||
unenrol_student($order->userid, $order->courseid);
|
||||
}
|
||||
redirect("index.php?order=$orderno");
|
||||
}
|
||||
redirect("index.php?order=$orderno");
|
||||
}
|
||||
else {
|
||||
$table->data[] = array(get_string('testmode', 'enrol_authorize'),
|
||||
@@ -306,8 +332,9 @@ function authorize_print_order_details($orderno)
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
elseif (!empty($cmdvoid)) { // VOID
|
||||
elseif (!empty($cmdvoid) and confirm_sesskey()) { // VOID
|
||||
if (!in_array(ORDER_VOID, $status->actions)) {
|
||||
$a = new stdClass;
|
||||
$a->action = $authstrs->void;
|
||||
error(get_string('youcantdo', 'enrol_authorize', $a));
|
||||
}
|
||||
@@ -318,7 +345,7 @@ function authorize_print_order_details($orderno)
|
||||
$strvoidyes = get_string('voidyes', 'enrol_authorize');
|
||||
$table->data[] = array("<b>$strs->confirm:</b>",
|
||||
"$strvoidyes<br /><input type='hidden' name='".ORDER_VOID."' value='y'>
|
||||
<input type='hidden' name='confirm' value='y'>
|
||||
<input type='hidden' name='confirm' value='1'>
|
||||
<input type='submit' value='$strs->yes'>
|
||||
<a href='index.php?order=$orderno'>$strs->no</a>");
|
||||
}
|
||||
@@ -351,16 +378,15 @@ function authorize_print_order_details($orderno)
|
||||
}
|
||||
else {
|
||||
if (empty($confirm)) {
|
||||
$a = new stdClass;
|
||||
$a->transid = $suborder->transid;
|
||||
$a->amount = $suborder->amount;
|
||||
$strsubvoidyes = get_string('subvoidyes', 'enrol_authorize', $a);
|
||||
|
||||
$table->data[] = array("<b>$authstrs->unenrolstudent</b>",
|
||||
"<input type='checkbox' name='unenrol' value='y'" . (!empty($unenrol) ? " checked" : "") . ">");
|
||||
|
||||
$cbunenrol = print_checkbox('unenrol', '1', !empty($unenrol), '', '', '', true);
|
||||
$table->data[] = array("<b>$authstrs->unenrolstudent</b>", $cbunenrol);
|
||||
$table->data[] = array("<b>$strs->confirm:</b>",
|
||||
"$strsubvoidyes<br /><input type='hidden' name='".ORDER_VOID."' value='y'>
|
||||
<input type='hidden' name='confirm' value='y'>
|
||||
<input type='hidden' name='confirm' value='1'>
|
||||
<input type='hidden' name='suborder' value='$suborderno'>
|
||||
<input type='submit' value='$strs->yes'>
|
||||
<a href='index.php?order=$orderno'>$strs->no</a>");
|
||||
@@ -390,18 +416,18 @@ function authorize_print_order_details($orderno)
|
||||
}
|
||||
print_table($table);
|
||||
}
|
||||
elseif (!empty($cmddelete)) { // DELETE
|
||||
elseif (!empty($cmddelete) and confirm_sesskey()) { // DELETE
|
||||
if (!in_array(ORDER_DELETE, $status->actions)) {
|
||||
$a = new stdClass;
|
||||
$a->action = $authstrs->delete;
|
||||
error(get_string('youcantdo', 'enrol_authorize', $a));
|
||||
}
|
||||
if (empty($confirm)) {
|
||||
$table->data[] = array("<b>$authstrs->unenrolstudent</b>",
|
||||
"<input type='checkbox' name='unenrol' value='y'" . (!empty($unenrol) ? " checked" : "") . ">");
|
||||
|
||||
$cbunenrol = print_checkbox('unenrol', '1', !empty($unenrol), '', '', '', true);
|
||||
$table->data[] = array("<b>$authstrs->unenrolstudent</b>", $cbunenrol);
|
||||
$table->data[] = array("<b>$strs->confirm:</b>",
|
||||
"<input type='hidden' name='".ORDER_DELETE."' value='y'>
|
||||
<input type='hidden' name='confirm' value='y'>
|
||||
<input type='hidden' name='confirm' value='1'>
|
||||
<input type='submit' value='$strs->yes'>
|
||||
<a href='index.php?order=$orderno'>$strs->no</a>");
|
||||
}
|
||||
@@ -427,14 +453,14 @@ function authorize_print_order_details($orderno)
|
||||
$table->data[] = array("<b>$strs->action</b>", $actions);
|
||||
print_table($table);
|
||||
if ($settled) { // show refunds.
|
||||
echo "<h4>" . get_string('returns', 'enrol_authorize') . "</h4>\n";
|
||||
$t2 = new stdClass;
|
||||
$t2->size = array('15%', '15%', '20%', '35%', '15%');
|
||||
$t2->align = array('right', 'right', 'right', 'left', 'right');
|
||||
$t2->align = array('right', 'right', 'right', 'right', 'right');
|
||||
$t2->head = array($authstrs->transid,
|
||||
$authstrs->amount,
|
||||
$strs->status,
|
||||
$authstrs->settlementdate,
|
||||
$strs->action);
|
||||
$authstrs->amount,
|
||||
$strs->status,
|
||||
$authstrs->settlementdate,
|
||||
$strs->action);
|
||||
$refunds = get_records('enrol_authorize_refunds', 'orderid', $orderno);
|
||||
if ($refunds) {
|
||||
foreach ($refunds as $rf) {
|
||||
@@ -446,19 +472,20 @@ function authorize_print_order_details($orderno)
|
||||
else {
|
||||
foreach ($substatus->actions as $vl) {
|
||||
$subactions .=
|
||||
"<a href='index.php?$vl=y&order=$orderno&suborder=$rf->id'>{$authstrs->$vl}</a> ";
|
||||
"<a href='index.php?$vl=y&sesskey=$USER->sesskey&order=$orderno&suborder=$rf->id'>{$authstrs->$vl}</a> ";
|
||||
}
|
||||
}
|
||||
$t2->data[] = array($rf->transid,
|
||||
$rf->amount,
|
||||
$authstrs->{$substatus->status},
|
||||
userdate($rf->settletime),
|
||||
$subactions);
|
||||
$rf->amount,
|
||||
$authstrs->{$substatus->status},
|
||||
userdate($rf->settletime),
|
||||
$subactions);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$t2->data[] = array(get_string('noreturns', 'enrol_authorize'));
|
||||
$t2->data[] = array('','',get_string('noreturns', 'enrol_authorize'),'','');
|
||||
}
|
||||
echo "<h4>" . get_string('returns', 'enrol_authorize') . "</h4>\n";
|
||||
print_table($t2);
|
||||
}
|
||||
}
|
||||
@@ -473,21 +500,28 @@ function authorize_print_order_details($orderno)
|
||||
*/
|
||||
function authorize_get_status_action($order)
|
||||
{
|
||||
global $CFG, $USER;
|
||||
static $timediff30;
|
||||
global $CFG;
|
||||
static $timediff30, $newordertime;
|
||||
|
||||
if (empty($timediff30)) {
|
||||
$timediff30 = getsettletime(time()) - (30 * 3600 * 24);
|
||||
$timenow = time();
|
||||
$timediff30 = getsettletime($timenow) - (30 * 3600 * 24);
|
||||
$newordertime = $timenow - 120; // -2 minutes. Order may be still in process.
|
||||
}
|
||||
|
||||
$ret = new stdClass();
|
||||
$ret->actions = array();
|
||||
|
||||
if (intval($order->transid) == 0) { // test transaction
|
||||
if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
|
||||
$ret->actions = array(ORDER_DELETE);
|
||||
if (intval($order->transid) == 0) { // test transaction or new order
|
||||
if ($order->timecreated < $newordertime) {
|
||||
if (isadmin() || (!empty($CFG->an_teachermanagepay) && isteacher($order->courseid))) {
|
||||
$ret->actions = array(ORDER_DELETE);
|
||||
}
|
||||
$ret->status = 'tested';
|
||||
}
|
||||
else {
|
||||
$ret->status = 'new';
|
||||
}
|
||||
$ret->status = 'tested';
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?PHP // $Id$
|
||||
|
||||
$plugin->version = 2006021500;
|
||||
$plugin->version = 2006021501;
|
||||
$plugin->requires = 2005072200;
|
||||
|
||||
?>
|
||||
|
||||
@@ -529,7 +529,7 @@ function process_person_tag($tagcontents){
|
||||
}
|
||||
if($CFG->enrol_imssourcedidfallback && trim($person->username)==''){
|
||||
// This is the point where we can fall back to useing the "sourcedid" if "userid" is not supplied
|
||||
// NB We don't use an "elseif" because the tag may be supplied-but-empty
|
||||
// NB We don't use an "elseif" because the tag may be supplied-but-empty
|
||||
$person->username = $person->idnumber;
|
||||
}
|
||||
if(preg_match('{<email>(.*?)</email>}is', $tagcontents, $matches)){
|
||||
|
||||
@@ -3,20 +3,20 @@ require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
|
||||
require_login();
|
||||
|
||||
if (!$site = get_site()) {
|
||||
redirect("index.php");
|
||||
redirect("index.php");
|
||||
}
|
||||
|
||||
if (!isadmin()) {
|
||||
error("Only the admin can use this page");
|
||||
error("Only the admin can use this page");
|
||||
}
|
||||
|
||||
/// get language strings
|
||||
$str = get_strings(array('enrolments', 'users', 'administration', 'settings'));
|
||||
|
||||
print_header("$site->shortname: $str->enrolments", "$site->fullname",
|
||||
"<a href=\"../../admin/index.php\">$str->administration</a> ->
|
||||
<a href=\"../../admin/users.php\">$str->users</a> ->
|
||||
$str->enrolments -> IMS import");
|
||||
"<a href=\"../../admin/index.php\">$str->administration</a> ->
|
||||
<a href=\"../../admin/users.php\">$str->users</a> ->
|
||||
$str->enrolments -> IMS import");
|
||||
|
||||
require_once('enrol.php');
|
||||
|
||||
|
||||
@@ -353,6 +353,10 @@ function cron() {
|
||||
|
||||
// Notify teachers/students about students who's enrolment are going to expire
|
||||
global $CFG;
|
||||
if (empty($CFG->lastexpirynotify)) {
|
||||
$CFG->lastexpirynotify = 0;
|
||||
}
|
||||
|
||||
if ($CFG->lastexpirynotify < date('Ymd') && ($courses = get_records_select('course', 'enrolperiod > 0 AND expirynotify > 0 AND expirythreshold > 0'))) {
|
||||
$site = get_site();
|
||||
$admin = get_admin();
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user