~ubuntu-branches/ubuntu/trusty/moodle/trusty

« back to all changes in this revision

Viewing changes to lib/moodlelib.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-01-21 13:40:52 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20140121134052-ym2qvsp2cd9vq0p6
Tags: 2.5.4-1
* New upstream release, fixing security issues:
  - MSA-14-0001 Config passwords visibility issue [CVE-2014-0008]
  - MSA-14-0002 Group constraints lacking in "login as" [CVE-2014-0009]
  - MSA-14-0003 CSRF vulnerability in profile fields [CVE-2014-0010]
* Move /var/lib/moodle directory into package.
* Revert back to bundled yui3. Unfortunately, version in Debian and
  of upstream are not compatible (closes: #735312).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1184
1184
        // No null bytes expected in our data, so let's remove it.
1185
1185
        $value = str_replace("\0", '', $value);
1186
1186
 
1187
 
        // Lower error reporting because glibc throws bogus notices.
1188
 
        $olderror = error_reporting();
1189
 
        if ($olderror & E_NOTICE) {
1190
 
            error_reporting($olderror ^ E_NOTICE);
1191
 
        }
1192
 
 
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€');
1197
1191
        }
1198
1192
 
1199
1193
        if ($buggyiconv) {
1209
1203
            }
1210
1204
 
1211
1205
        } else {
1212
 
            $result = iconv('UTF-8', 'UTF-8//IGNORE', $value);
1213
 
        }
1214
 
 
1215
 
        if ($olderror & E_NOTICE) {
1216
 
            error_reporting($olderror);
 
1206
            $result = @iconv('UTF-8', 'UTF-8//IGNORE', $value);
1217
1207
        }
1218
1208
 
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');
4784
4775
 
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);
4945
4936
 
 
4937
    // Notes, you shall not pass!
 
4938
    note_delete_all($course->id);
 
4939
 
4946
4940
    // die comments!
4947
4941
    comment::delete_comments($coursecontext->id);
4948
4942
 
8233
8227
    $cache = cache::make('core', 'plugintypes');
8234
8228
 
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);
8240
 
        } else {
8241
 
            // Oops they didn't match. The moodle directory has been moved on us.
8242
 
            $cached = false;
8243
 
        }
 
8230
        // Cache each dirroot separately in case cluster nodes happen to be deployed to
 
8231
        // different locations.
 
8232
        $cached = $cache->get(sha1($CFG->dirroot));
8244
8233
    } else {
8245
8234
        $cached = $cache->get(0);
8246
8235
    }
8299
8288
        }
8300
8289
 
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);
8306
8292
 
8307
8293
        return ($fullpaths ? $fullinfo : $info);
8308
8294
    }
9399
9385
    $pool .= 'abcdefghijklmnopqrstuvwxyz';
9400
9386
    $pool .= '0123456789';
9401
9387
    $poollen = strlen($pool);
9402
 
    mt_srand ((double) microtime() * 1000000);
9403
9388
    $string = '';
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));
9426
9410
    }
9728
9712
 */
9729
9713
function swapshuffle($array) {
9730
9714
 
9731
 
    srand ((double) microtime() * 10000000);
9732
9715
    $last = count($array) - 1;
9733
9716
    for ($i=0;$i<=$last;$i++) {
9734
9717
        $from = rand(0,$last);
9768
9751
 * @return array
9769
9752
 */
9770
9753
function draw_rand_array($array, $draws) {
9771
 
    srand ((double) microtime() * 10000000);
9772
9754
 
9773
9755
    $return = array();
9774
9756
 
10544
10526
        $strgomessage = get_string('gotomessages', 'message');
10545
10527
        $strstaymessage = get_string('ignore','admin');
10546
10528
 
 
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'));
 
10537
 
 
10538
            $notificationsound = html_writer::tag('audio', $sourcetags, array('preload' => 'auto', 'autoplay' => 'autoplay'));
 
10539
        }
 
10540
 
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').
10552
10546
 
10553
 
                        html_writer::start_tag('div', array('id'=>'newmessagelinks')).
10554
 
                            html_writer::link($url, $strgomessage, array('id'=>'notificationyes')).'&nbsp;&nbsp;&nbsp;'.
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')).'&nbsp;&nbsp;&nbsp;'.
 
10550
                            html_writer::link('', $strstaymessage, array('id' => 'notificationno')).
10556
10551
                        html_writer::end_tag('div');
10557
10552
                    html_writer::end_tag('div');
10558
10553