Merge branch 'MDL-37114_23' of git://github.com/timhunt/moodle into MOODLE_23_STABLE
authorDan Poltawski <dan@moodle.com>
Mon, 17 Dec 2012 07:25:30 +0000 (15:25 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 17 Dec 2012 07:25:30 +0000 (15:25 +0800)
13 files changed:
backup/moodle2/restore_stepslib.php
comment/comment.js
course/lib.php
course/renderer.php
course/yui/toolboxes/toolboxes.js
lib/blocklib.php
lib/conditionlib.php
lib/db/upgrade.php
lib/navigationlib.php
mod/assign/locallib.php
mod/data/db/upgrade.php
mod/data/version.php
version.php

index 3abea43..3247a82 100644 (file)
@@ -1160,11 +1160,11 @@ class restore_section_structure_step extends restore_structure_step {
         $sectionid = $this->get_task()->get_sectionid();
 
         // Get data object for current section availability (if any).
-        $data = $DB->get_record('course_sections_availability',
-                array('coursesectionid' => $sectionid), 'id, sourcecmid, gradeitemid', IGNORE_MISSING);
+        $records = $DB->get_records('course_sections_availability',
+                array('coursesectionid' => $sectionid), 'id, sourcecmid, gradeitemid');
 
         // If it exists, update mappings.
-        if ($data) {
+        foreach ($records as $data) {
             // Only update mappings for entries which are created by this restore.
             // Otherwise, when you restore to an existing course, it will mess up
             // existing section availability entries.
index 37c44d4..76efcf3 100644 (file)
@@ -184,7 +184,7 @@ bodyContent: '<div class="comment-delete-confirm"><a href="#" id="confirmdelete-
                         val = val.replace('___name___', list[i].fullname);
                     }
                     if (list[i]['delete']||newcmt) {
-                        list[i].content = '<div class="comment-delete"><a href="#" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+M.str.moodle.deletecomment+'"><img src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
+                        list[i].content = '<div class="comment-delete"><a href="#" id ="comment-delete-'+this.client_id+'-'+list[i].id+'" title="'+M.str.moodle.deletecomment+'"><img alt="" src="'+M.util.image_url('t/delete', 'core')+'" /></a></div>' + list[i].content;
                     }
                     val = val.replace('___time___', list[i].time);
                     val = val.replace('___picture___', list[i].avatar);
index b9f93bc..c2d0f78 100644 (file)
@@ -1748,17 +1748,20 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
             if (!$mod->uservisible) {
                 echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
             } else if ($canviewhidden && !empty($CFG->enableavailability)) {
-                $visibilityclass = '';
-                if (!$mod->visible) {
-                    $visibilityclass = 'accesshide';
-                }
-                $ci = new condition_info($mod);
-                $fullinfo = $ci->get_full_information();
-                if($fullinfo) {
-                    echo '<div class="availabilityinfo '.$visibilityclass.'">'.get_string($mod->showavailability
-                        ? 'userrestriction_visible'
-                        : 'userrestriction_hidden','condition',
-                        $fullinfo).'</div>';
+                // Don't add availability information if user is not editing and activity is hidden.
+                if ($mod->visible || $PAGE->user_is_editing()) {
+                    $hidinfoclass = '';
+                    if (!$mod->visible) {
+                        $hidinfoclass = 'hide';
+                    }
+                    $ci = new condition_info($mod);
+                    $fullinfo = $ci->get_full_information();
+                    if($fullinfo) {
+                        echo '<div class="availabilityinfo '.$hidinfoclass.'">'.get_string($mod->showavailability
+                            ? 'userrestriction_visible'
+                            : 'userrestriction_hidden','condition',
+                            $fullinfo).'</div>';
+                    }
                 }
             }
 
index a980841..e6ed2b5 100644 (file)
@@ -123,6 +123,7 @@ class core_course_renderer extends plugin_renderer_base {
         if ($hascourses) {
             $content .= html_writer::start_tag('div', array('class'=>'courses'));
             $coursecount = 0;
+            $strinfo = new lang_string('info');
             foreach ($category->courses as $course) {
                 $classes = array('course');
                 $linkclass = 'course_link';
@@ -143,8 +144,9 @@ class core_course_renderer extends plugin_renderer_base {
                 }
 
                 if ($course->summary) {
+                    $url = new moodle_url('/course/info.php', array('id' => $course->id));
                     $image = html_writer::empty_tag('img', array('src'=>$this->output->pix_url('i/info'), 'alt'=>$this->strings->summary));
-                    $content .= html_writer::link(new moodle_url('/course/info.php', array('id'=>$course->id)), $image, array('title'=>$this->strings->summary));
+                    $content .= $this->action_link($url, $image, new popup_action('click', $url, 'courseinfo'), array('title' => $this->strings->summary));
                 }
                 $content .= html_writer::end_tag('div');
                 $content .= html_writer::end_tag('div');
index d7d031b..2486fba 100644 (file)
@@ -37,7 +37,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
         CONDITIONALHIDDEN : 'conditionalhidden',
         AVAILABILITYINFODIV : 'div.availabilityinfo',
         SHOWCLASS : 'editing_show',
-        ACCESSHIDECLASS : 'accesshide'
+        HIDECLASS : 'hide'
     };
 
     /**
@@ -99,7 +99,7 @@ YUI.add('moodle-course-toolboxes', function(Y) {
             var availabilityinfo = element.one(CSS.AVAILABILITYINFODIV);
 
             if (availabilityinfo) {
-                availabilityinfo.toggleClass(CSS.ACCESSHIDECLASS);
+                availabilityinfo.toggleClass(CSS.HIDECLASS);
             }
             return value;
         },
index 9413201..841a000 100644 (file)
@@ -1834,6 +1834,7 @@ function block_add_block_ui($page, $output) {
 
     $actionurl = new moodle_url($page->url, array('sesskey'=>sesskey()));
     $select = new single_select($actionurl, 'bui_addblock', $menu, null, array(''=>get_string('adddots')), 'add_block');
+    $select->set_label(get_string('addblock'), array('class'=>'accesshide'));
     $bc->content = $OUTPUT->render($select);
     return $bc;
 }
index 550d49a..c1a0851 100644 (file)
@@ -760,7 +760,7 @@ abstract class condition_info_base {
                 if (empty($modinfo->cms[$cmid])) {
                     global $PAGE, $UNITTEST;
                     if (!empty($UNITTEST) || (isset($PAGE) && strpos($PAGE->pagetype, 'course-view-')===0)) {
-                        debugging("Warning: activity {$this->cm->id} '{$this->cm->name}' has condition " .
+                        debugging("Warning: activity {$this->item->id} '{$this->item->name}' has condition " .
                                 "on deleted activity $cmid (to get rid of this message, edit the named activity)");
                     }
                     continue;
index 91263db..92f7837 100644 (file)
@@ -985,5 +985,19 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2012062502.07);
     }
 
+    if ($oldversion < 2012062503.07) {
+        // Remove "_utf8" suffix from all langs in course table.
+        $langs = $DB->get_records_sql("SELECT DISTINCT lang FROM {course} WHERE lang LIKE ?", array('%_utf8'));
+
+        foreach ($langs as $lang=>$unused) {
+            $newlang = str_replace('_utf8', '', $lang);
+            $sql = "UPDATE {course} SET lang = :newlang WHERE lang = :lang";
+            $DB->execute($sql, array('newlang'=>$newlang, 'lang'=>$lang));
+        }
+
+        // Main savepoint reached.
+        upgrade_main_savepoint(true, 2012062503.07);
+    }
+
     return true;
 }
index f092010..d0b2d5f 100644 (file)
@@ -4254,7 +4254,7 @@ class settings_navigation extends navigation_node {
     protected function load_category_settings() {
         global $CFG;
 
-        $categorynode = $this->add(print_context_name($this->context));
+        $categorynode = $this->add(print_context_name($this->context), null, null, null, 'categorysettings');
         $categorynode->force_open();
 
         if (has_any_capability(array('moodle/category:manage', 'moodle/course:create'), $this->context)) {
index e0bfc1d..2564d0e 100644 (file)
@@ -1074,7 +1074,7 @@ class assign {
                    LEFT JOIN {assign_grades} g ON
                         s.assignment = g.assignment AND
                         s.userid = g.userid
-                   JOIN(' . $esql . ') AS e ON e.id = s.userid
+                   JOIN(' . $esql . ') e ON e.id = s.userid
                    WHERE
                         s.assignment = :assignid AND
                         s.timemodified IS NOT NULL AND
@@ -1104,7 +1104,7 @@ class assign {
                    LEFT JOIN {assign_grades} g ON
                         s.assignment = g.assignment AND
                         s.userid = g.userid
-                   JOIN(' . $esql . ') AS e ON e.id = s.userid
+                   JOIN(' . $esql . ') e ON e.id = s.userid
                    WHERE
                         s.assignment = :assignid AND
                         s.timemodified IS NOT NULL AND
@@ -1173,7 +1173,7 @@ class assign {
         $sql = 'SELECT s.*, u.lastname, u.firstname, u.username
                    FROM {assign_submission} s
                    JOIN {user} u ON s.userid = u.id
-                   JOIN(' . $esql . ') AS e ON e.id = s.userid
+                   JOIN(' . $esql . ') e ON e.id = s.userid
                    WHERE
                         s.assignment = :assignid AND
                         s.timemodified IS NOT NULL';
index 745d0cb..e58dbbe 100644 (file)
@@ -32,6 +32,93 @@ function xmldb_data_upgrade($oldversion) {
     // Moodle v2.3.0 release upgrade line
     // Put any upgrade step following this
 
+    if ($oldversion < 2012061701) {
+        // Check if there is a directory containing any old presets.
+        $olddatadir = $CFG->dataroot . '/data';
+        $oldpresetdir = "$olddatadir/preset";
+        if (file_exists($oldpresetdir)) {
+            // Get directory contents.
+            $userfolders = new DirectoryIterator($oldpresetdir);
+            // Store the system context, these are site wide presets.
+            $context = get_system_context();
+            // Create file storage object.
+            $fs = get_file_storage();
+            // Create array of accepted files.
+            $arracceptedfilenames = array('singletemplate.html', 'listtemplateheader.html', 'listtemplate.html',
+                                          'listtemplatefooter.html', 'addtemplate.html', 'rsstemplate.html',
+                                          'rsstitletemplate.html', 'csstemplate.css', 'jstemplate.js',
+                                          'asearchtemplate.html', 'preset.xml');
+            // Loop through all the folders, they should represent userids.
+            foreach ($userfolders as $userfolder) {
+                // If it is a file, skip it.
+                if ($userfolder->isFile()) {
+                    continue;
+                }
+                // The folder name should represent the user id.
+                $userid = $userfolder->getFilename();
+                // Skip if it is not numeric.
+                if (!is_numeric($userid)) {
+                    continue;
+                }
+                // Skip if the number does not correspond to a user (does not matter if user was deleted).
+                if (!$DB->record_exists('user', array('id' => $userid))) {
+                    continue;
+                }
+                // Open this folder.
+                $presetfolders = new DirectoryIterator("$oldpresetdir/$userid");
+                foreach ($presetfolders as $presetfolder) {
+                    // If it is a file, skip it.
+                    if ($presetfolder->isFile()) {
+                        continue;
+                    }
+                    // Save the name of the preset.
+                    $presetname = $presetfolder->getFilename();
+                    // Get the files in this preset folder.
+                    $presetfiles = new DirectoryIterator("$oldpresetdir/$userid/$presetname");
+                    // Now we want to get the contents of the presets.
+                    foreach ($presetfiles as $file) {
+                        // If it is not a file, skip it.
+                        if (!$file->isFile()) {
+                            continue;
+                        }
+                        // Set the filename.
+                        $filename = $file->getFilename();
+                        // If it is not in the array of accepted file names skip it.
+                        if (!in_array($filename, $arracceptedfilenames)) {
+                            continue;
+                        }
+                        // Store the full file path.
+                        $fullfilepath = "$oldpresetdir/$userid/$presetname/$filename";
+                        // Create file record.
+                        $filerecord = array('contextid' => $context->id,
+                                            'component' => 'mod_data',
+                                            'filearea' => 'site_presets',
+                                            'itemid' => 0,
+                                            'filename' => $filename,
+                                            'userid' => $userid);
+                        // Check to ensure it does not already exists in the file directory.
+                        if (!$fs->file_exists($context->id, 'mod_data', 'site_presets', 0, '/' . $presetfolder . '/', $filename)) {
+                            $filerecord['filepath'] = '/' . $presetfolder . '/';
+                        } else {
+                            $filerecord['filepath'] = '/' . $presetfolder . '_' . $userid . '_old/';
+                        }
+                        $fs->create_file_from_pathname($filerecord, $fullfilepath);
+                        // Remove the file.
+                        @unlink($fullfilepath);
+                    }
+                    // Remove the preset directory.
+                    @rmdir("$oldpresetdir/$userid/$presetname");
+                }
+                // Remove the user directory.
+                @rmdir("$oldpresetdir/$userid");
+            }
+            // Remove the final directories.
+            @rmdir("$oldpresetdir");
+            @rmdir("$olddatadir");
+        }
+
+        upgrade_mod_savepoint(true, 2012061701, 'data');
+    }
 
     return true;
 }
index e8a1c92..ab159f8 100644 (file)
@@ -25,7 +25,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$module->version   = 2012061700;       // The current module version (Date: YYYYMMDDXX)
-$module->requires  = 2012061700;    // Requires this Moodle version
+$module->version   = 2012061701;       // The current module version (Date: YYYYMMDDXX)
+$module->requires  = 2012061700;       // Requires this Moodle version
 $module->component = 'mod_data';       // Full name of the plugin (used for diagnostics)
 $module->cron      = 0;
index 148b30c..95ae746 100644 (file)
@@ -30,7 +30,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 
-$version  = 2012062503.06;              // YYYYMMDD      = weekly release date of this DEV branch
+$version  = 2012062503.07;              // YYYYMMDD      = weekly release date of this DEV branch
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes