Merge branch 'MDL-37114' of git://github.com/timhunt/moodle
authorDan Poltawski <dan@moodle.com>
Mon, 17 Dec 2012 07:25:22 +0000 (15:25 +0800)
committerDan Poltawski <dan@moodle.com>
Mon, 17 Dec 2012 07:25:22 +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 1a5604e..babbcd0 100644 (file)
@@ -1268,11 +1268,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 65dcae8..f0f4ddf 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 1e81de9..f145c33 100644 (file)
@@ -1694,17 +1694,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 bbb761e..33c15b4 100644 (file)
@@ -168,6 +168,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';
@@ -188,8 +189,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 5c8c896..1b37f40 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 e566933..cbea8ad 100644 (file)
@@ -1848,6 +1848,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 96b9580..71d36c7 100644 (file)
@@ -942,7 +942,7 @@ abstract class condition_info_base {
                 if (empty($modinfo->cms[$cmid])) {
                     global $PAGE;
                     if (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 7dee7a7..f3f3329 100644 (file)
@@ -1517,5 +1517,19 @@ function xmldb_main_upgrade($oldversion) {
         upgrade_main_savepoint(true, 2012120300.01);
     }
 
+    if ($oldversion < 2012120300.04) {
+        // 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, 2012120300.04);
+    }
+
     return true;
 }
index b4e69c6..450f266 100644 (file)
@@ -4038,7 +4038,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 39deae3..3701d08 100644 (file)
@@ -1154,7 +1154,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
@@ -1183,7 +1183,7 @@ class assign {
 
         $sql = 'SELECT COUNT(g.userid)
                    FROM {assign_grades} g
-                   JOIN(' . $esql . ') AS e ON e.id = g.userid
+                   JOIN(' . $esql . ') e ON e.id = g.userid
                    WHERE g.assignment = :assignid';
 
         return $DB->count_records_sql($sql, $params);
@@ -1222,7 +1222,7 @@ class assign {
 
             $sql = 'SELECT COUNT(s.userid)
                        FROM {assign_submission} s
-                       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';
@@ -1258,7 +1258,7 @@ class assign {
         } else {
             $sql = 'SELECT COUNT(s.userid)
                         FROM {assign_submission} s
-                        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
index ed06ae4..f35ff77 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 < 2012112901) {
+        // 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, 2012112901, 'data');
+    }
 
     // Moodle v2.4.0 release upgrade line
     // Put any upgrade step following this
index 783b782..5914db8 100644 (file)
@@ -25,7 +25,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
-$module->version   = 2012112900;       // The current module version (Date: YYYYMMDDXX)
-$module->requires  = 2012112900;    // Requires this Moodle version
+$module->version   = 2012112901;       // The current module version (Date: YYYYMMDDXX)
+$module->requires  = 2012112900;       // Requires this Moodle version
 $module->component = 'mod_data';       // Full name of the plugin (used for diagnostics)
 $module->cron      = 0;
index 4d34c36..f5a52b6 100644 (file)
@@ -30,7 +30,7 @@
 defined('MOODLE_INTERNAL') || die();
 
 
-$version  = 2012120300.03;              // YYYYMMDD      = weekly release date of this DEV branch
+$version  = 2012120300.04;              // YYYYMMDD      = weekly release date of this DEV branch
                                         //         RR    = release increments - 00 in DEV branches
                                         //           .XX = incremental changes