1184
1184
// No null bytes expected in our data, so let's remove it.
1185
1185
$value = str_replace("\0", '', $value);
1187
// Lower error reporting because glibc throws bogus notices.
1188
$olderror = error_reporting();
1189
if ($olderror & E_NOTICE) {
1190
error_reporting($olderror ^ E_NOTICE);
1193
1187
// Note: this duplicates min_fix_utf8() intentionally.
1194
1188
static $buggyiconv = null;
1195
1189
if ($buggyiconv === null) {
1196
$buggyiconv = (!function_exists('iconv') or iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
1190
$buggyiconv = (!function_exists('iconv') or @iconv('UTF-8', 'UTF-8//IGNORE', '100'.chr(130).'€') !== '100€');
1199
1193
if ($buggyiconv) {
1212
$result = iconv('UTF-8', 'UTF-8//IGNORE', $value);
1215
if ($olderror & E_NOTICE) {
1216
error_reporting($olderror);
1206
$result = @iconv('UTF-8', 'UTF-8//IGNORE', $value);
1219
1209
return $result;
4781
4771
require_once($CFG->dirroot.'/tag/coursetagslib.php');
4782
4772
require_once($CFG->dirroot.'/comment/lib.php');
4783
4773
require_once($CFG->dirroot.'/rating/lib.php');
4774
require_once($CFG->dirroot.'/notes/lib.php');
4785
4776
// Handle course badges.
4786
4777
badges_handle_course_deletion($courseid);
4943
4934
// filters be gone!
4944
4935
filter_delete_all_for_context($coursecontext->id);
4937
// Notes, you shall not pass!
4938
note_delete_all($course->id);
4946
4940
// die comments!
4947
4941
comment::delete_comments($coursecontext->id);
8233
8227
$cache = cache::make('core', 'plugintypes');
8235
8229
if ($fullpaths) {
8236
// First confirm that dirroot and the stored dirroot match.
8237
if ($CFG->dirroot === $cache->get('dirroot')) {
8238
// They match we can use it.
8239
$cached = $cache->get(1);
8241
// Oops they didn't match. The moodle directory has been moved on us.
8230
// Cache each dirroot separately in case cluster nodes happen to be deployed to
8231
// different locations.
8232
$cached = $cache->get(sha1($CFG->dirroot));
8245
8234
$cached = $cache->get(0);
8301
8290
$cache->set(0, $info);
8302
$cache->set(1, $fullinfo);
8303
// We cache the dirroot as well so that we can compare it when we
8304
// retrieve full info from the cache.
8305
$cache->set('dirroot', $CFG->dirroot);
8291
$cache->set(sha1($CFG->dirroot), $fullinfo);
8307
8293
return ($fullpaths ? $fullinfo : $info);
9399
9385
$pool .= 'abcdefghijklmnopqrstuvwxyz';
9400
9386
$pool .= '0123456789';
9401
9387
$poollen = strlen($pool);
9402
mt_srand ((double) microtime() * 1000000);
9404
9389
for ($i = 0; $i < $length; $i++) {
9405
9390
$string .= substr($pool, (mt_rand()%($poollen)), 1);
9420
9405
$pool = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
9421
9406
$pool .= '`~!@#%^&*()_+-=[];,./<>?:{} ';
9422
9407
$poollen = strlen($pool);
9423
mt_srand ((double) microtime() * 1000000);
9424
9408
if ($length===null) {
9425
9409
$length = floor(rand(24,32));
10544
10526
$strgomessage = get_string('gotomessages', 'message');
10545
10527
$strstaymessage = get_string('ignore','admin');
10529
$notificationsound = null;
10530
$beep = get_user_preferences('message_beepnewmessage', '');
10531
if (!empty($beep)) {
10532
// Browsers will work down this list until they find something they support.
10533
$sourcetags = html_writer::empty_tag('source', array('src' => $CFG->wwwroot.'/message/bell.wav', 'type' => 'audio/wav'));
10534
$sourcetags .= html_writer::empty_tag('source', array('src' => $CFG->wwwroot.'/message/bell.ogg', 'type' => 'audio/ogg'));
10535
$sourcetags .= html_writer::empty_tag('source', array('src' => $CFG->wwwroot.'/message/bell.mp3', 'type' => 'audio/mpeg'));
10536
$sourcetags .= html_writer::empty_tag('embed', array('src' => $CFG->wwwroot.'/message/bell.wav', 'autostart' => 'true', 'hidden' => 'true'));
10538
$notificationsound = html_writer::tag('audio', $sourcetags, array('preload' => 'auto', 'autoplay' => 'autoplay'));
10547
10541
$url = $CFG->wwwroot.'/message/index.php';
10548
10542
$content = html_writer::start_tag('div', array('id'=>'newmessageoverlay','class'=>'mdl-align')).
10549
10543
html_writer::start_tag('div', array('id'=>'newmessagetext')).
10550
10544
$strmessages.
10551
10545
html_writer::end_tag('div').
10553
html_writer::start_tag('div', array('id'=>'newmessagelinks')).
10554
html_writer::link($url, $strgomessage, array('id'=>'notificationyes')).' '.
10555
html_writer::link('', $strstaymessage, array('id'=>'notificationno')).
10547
$notificationsound.
10548
html_writer::start_tag('div', array('id' => 'newmessagelinks')).
10549
html_writer::link($url, $strgomessage, array('id' => 'notificationyes')).' '.
10550
html_writer::link('', $strstaymessage, array('id' => 'notificationno')).
10556
10551
html_writer::end_tag('div');
10557
10552
html_writer::end_tag('div');