Merge branch 'w46_MDL-30308_m22_reqstrict' of git://github.com/skodak/moodle
authorSam Hemelryk <sam@moodle.com>
Sun, 20 Nov 2011 23:39:42 +0000 (12:39 +1300)
committerSam Hemelryk <sam@moodle.com>
Sun, 20 Nov 2011 23:39:42 +0000 (12:39 +1300)
17 files changed:
admin/blocks.php
backup/moodle2/restore_stepslib.php
lib/adminlib.php
lib/plagiarismlib.php
mod/lti/backup/moodle2/backup_lti_stepslib.php
mod/lti/db/install.xml
mod/lti/db/upgrade.php
mod/lti/lib.php
mod/lti/mod_form.php
mod/lti/version.php
mod/lti/view.php
mod/wiki/pagelib.php
plagiarism/lib.php
theme/anomaly/style/general.css
theme/base/style/core.css
theme/base/style/course.css
theme/mymobile/lang/en/theme_mymobile.php

index 8f4fdc9..ca9633d 100644 (file)
             exit;
 
         } else {
-            // Inform block it's about to be deleted
-            if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
-                $blockobject = block_instance($block->name);
-                if ($blockobject) {
-                    $blockobject->before_delete();  //only if we can create instance, block might have been already removed
-                }
-            }
-
-            // First delete instances and then block
-            $instances = $DB->get_records('block_instances', array('blockname' => $block->name));
-            if(!empty($instances)) {
-                foreach($instances as $instance) {
-                    blocks_delete_instance($instance);
-                }
-            }
-
-            // Delete block
-            $DB->delete_records('block', array('id'=>$block->id));
-
-            drop_plugin_tables($block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false); // old obsoleted table names
-            drop_plugin_tables('block_'.$block->name, "$CFG->dirroot/blocks/$block->name/db/install.xml", false);
-
-            // Delete the capabilities that were defined by this block
-            capabilities_cleanup('block/'.$block->name);
-
-            // Remove event handlers and dequeue pending events
-            events_uninstall('block/'.$block->name);
+            uninstall_plugin('block', $block->name);
 
             $a->block = $strblockname;
             $a->directory = $CFG->dirroot.'/blocks/'.$block->name;
index c9705a9..6486489 100644 (file)
@@ -1109,7 +1109,6 @@ class restore_course_structure_step extends restore_structure_step {
         global $CFG, $DB;
 
         $data = (object)$data;
-        $oldid = $data->id; // We'll need this later
 
         $fullname  = $this->get_setting_value('course_fullname');
         $shortname = $this->get_setting_value('course_shortname');
@@ -1122,7 +1121,13 @@ class restore_course_structure_step extends restore_structure_step {
         $data->id = $this->get_courseid();
         $data->fullname = $fullname;
         $data->shortname= $shortname;
-        $data->idnumber = '';
+
+        $context = get_context_instance_by_id($this->task->get_contextid());
+        if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
+            $data->idnumber = '';
+        } else {
+            unset($data->idnumber);
+        }
 
         // Only restrict modules if original course was and target site too for new courses
         $data->restrictmodules = $data->restrictmodules && !empty($CFG->restrictmodulesfor) && $CFG->restrictmodulesfor == 'all';
index 68c1761..4eaaecb 100644 (file)
@@ -245,6 +245,26 @@ function uninstall_plugin($type, $name) {
                 set_config('enrol_plugins_enabled', implode(',', $enabledenrols));
             }
         }
+
+    } else if ($type === 'block') {
+        if ($block = $DB->get_record('block', array('name'=>$name))) {
+            // Inform block it's about to be deleted
+            if (file_exists("$CFG->dirroot/blocks/$block->name/block_$block->name.php")) {
+                $blockobject = block_instance($block->name);
+                if ($blockobject) {
+                    $blockobject->before_delete();  //only if we can create instance, block might have been already removed
+                }
+            }
+
+            // First delete instances and related contexts
+            $instances = $DB->get_records('block_instances', array('blockname' => $block->name));
+            foreach($instances as $instance) {
+                blocks_delete_instance($instance);
+            }
+
+            // Delete block
+            $DB->delete_records('block', array('id'=>$block->id));
+        }
     }
 
     // perform clean-up task common for all the plugin/subplugin types
@@ -271,7 +291,11 @@ function uninstall_plugin($type, $name) {
 
     // delete the plugin tables
     $xmldbfilepath = $plugindirectory . '/db/install.xml';
-    drop_plugin_tables($pluginname, $xmldbfilepath, false);
+    drop_plugin_tables($component, $xmldbfilepath, false);
+    if ($type === 'mod' or $type === 'block') {
+        // non-frankenstyle table prefixes
+        drop_plugin_tables($name, $xmldbfilepath, false);
+    }
 
     // delete the capabilities that were defined by this module
     capabilities_cleanup($component);
index b8c8546..2ff95ab 100644 (file)
@@ -53,6 +53,31 @@ function plagiarism_get_links($linkarray) {
     return $output;
 }
 
+/**
+ * returns array of plagiarism details about specified file
+ *
+ * @param int $cmid
+ * @param int $userid
+ * @param object $file moodle file object
+ * @return array - sets of details about specified file, one array of details per plagiarism plugin
+ *  - each set contains at least 'analyzed', 'score', 'reporturl'
+ */
+function plagiarism_get_file_results($cmid, $userid, $file) {
+    global $CFG;
+    $allresults = array();
+    if (empty($CFG->enableplagiarism)) {
+        return $allresults;
+    }
+    $plagiarismplugins = plagiarism_load_available_plugins();
+    foreach($plagiarismplugins as $plugin => $dir) {
+        require_once($dir.'/lib.php');
+        $plagiarismclass = "plagiarism_plugin_$plugin";
+        $plagiarismplugin = new $plagiarismclass;
+        $allresults[] = $plagiarismplugin->get_file_results($cmid, $userid, $file);
+    }
+    return $allresults;
+}
+
 /**
  * saves/updates plagiarism settings from a modules config page - called by course/modedit.php
  *
index 3be2514..c9c2a24 100644 (file)
@@ -77,8 +77,8 @@ class backup_lti_activity_structure_step extends backup_activity_structure_step
             'instructorchoiceallowsetting',
             'grade',
             'instructorcustomparameters',
-            'showtitle',
-            'showdescription'
+            'showtitlelaunch',
+            'showdescriptionlaunch'
             )
         );
 
index 4d62cb0..2df3df5 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/lti/db" VERSION="20111018" COMMENT="XMLDB file for Moodle mod/lti"
+<XMLDB PATH="mod/lti/db" VERSION="20111116" COMMENT="XMLDB file for Moodle mod/lti"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
 >
         <FIELD NAME="launchcontainer" TYPE="int" LENGTH="2" NOTNULL="true" UNSIGNED="true" DEFAULT="1" SEQUENCE="false" COMMENT="Launch external tool in a pop-up" PREVIOUS="grade" NEXT="resourcekey"/>
         <FIELD NAME="resourcekey" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="launchcontainer" NEXT="password"/>
         <FIELD NAME="password" TYPE="char" LENGTH="255" NOTNULL="false" SEQUENCE="false" PREVIOUS="resourcekey" NEXT="debuglaunch"/>
-        <FIELD NAME="debuglaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Enable the debug-style launch which pauses before auto-submit" PREVIOUS="password" NEXT="showtitle"/>
-        <FIELD NAME="showtitle" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="debuglaunch" NEXT="showdescription"/>
-        <FIELD NAME="showdescription" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showtitle" NEXT="servicesalt"/>
-        <FIELD NAME="servicesalt" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false" PREVIOUS="showdescription" NEXT="icon"/>
+        <FIELD NAME="debuglaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" COMMENT="Enable the debug-style launch which pauses before auto-submit" PREVIOUS="password" NEXT="showtitlelaunch"/>
+        <FIELD NAME="showtitlelaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="debuglaunch" NEXT="showdescriptionlaunch"/>
+        <FIELD NAME="showdescriptionlaunch" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" PREVIOUS="showtitlelaunch" NEXT="servicesalt"/>
+        <FIELD NAME="servicesalt" TYPE="char" LENGTH="40" NOTNULL="false" SEQUENCE="false" PREVIOUS="showdescriptionlaunch" NEXT="icon"/>
         <FIELD NAME="icon" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="servicesalt" NEXT="secureicon"/>
         <FIELD NAME="secureicon" TYPE="text" LENGTH="small" NOTNULL="false" SEQUENCE="false" PREVIOUS="icon"/>
       </FIELDS>
@@ -95,4 +95,4 @@
       </INDEXES>
     </TABLE>
   </TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
index 99f9deb..33aa23c 100644 (file)
@@ -64,6 +64,20 @@ function xmldb_lti_upgrade($oldversion) {
 
     $dbman = $DB->get_manager();
 
+    if ($oldversion < 2011111600){
+        // Rename showdescription to showdescriptionlaunch to not conflict with setting from core Moodle
+        // Rename showtitle as well to be consistent
+        $table = new xmldb_table('lti');
+        $field = new xmldb_field('showtitle', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'debuglaunch');
+
+        $dbman->rename_field($table, $field, 'showtitlelaunch');
+
+        $field = new xmldb_field('showdescription', XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'showtitlelaunch');
+        $dbman->rename_field($table, $field, 'showdescriptionlaunch');
+
+        upgrade_mod_savepoint(true, 2011111600, 'lti');
+    }
+
     return true;
 }
 
index 5853162..0ca9153 100644 (file)
@@ -63,6 +63,7 @@ function lti_supports($feature) {
         case FEATURE_GRADE_HAS_GRADE:         return true;
         case FEATURE_GRADE_OUTCOMES:          return true;
         case FEATURE_BACKUP_MOODLE2:          return true;
+        case FEATURE_SHOW_DESCRIPTION:        return true;
 
         default: return null;
     }
@@ -117,12 +118,12 @@ function lti_update_instance($lti, $mform) {
     $lti->timemodified = time();
     $lti->id = $lti->instance;
 
-    if (!isset($lti->showtitle)) {
-        $lti->showtitle = 0;
+    if (!isset($lti->showtitlelaunch)) {
+        $lti->showtitlelaunch = 0;
     }
 
-    if (!isset($lti->showdescription)) {
-        $lti->showdescription = 0;
+    if (!isset($lti->showdescriptionlaunch)) {
+        $lti->showdescriptionlaunch = 0;
     }
 
     if (!isset($lti->grade)) {
@@ -175,7 +176,7 @@ function lti_get_coursemodule_info($coursemodule) {
     require_once($CFG->dirroot.'/mod/lti/locallib.php');
 
     if (!$lti = $DB->get_record('lti', array('id' => $coursemodule->instance),
-            'icon, secureicon')) {
+            'icon, secureicon, intro, introformat, name')) {
         return null;
     }
 
@@ -189,6 +190,13 @@ function lti_get_coursemodule_info($coursemodule) {
         $info->iconurl = new moodle_url($lti->icon);
     }
 
+    if ($coursemodule->showdescription) {
+        // Convert intro to html. Do not filter cached version, filters run at display time.
+        $info->content = format_module_intro('lti', $lti, $coursemodule->id, false);
+    }
+
+    $info->name = $lti->name;
+
     return $info;
 }
 
index c588e39..353110f 100644 (file)
@@ -70,13 +70,22 @@ class mod_lti_mod_form extends moodleform_mod {
         $this->add_intro_editor(false, get_string('basicltiintro', 'lti'));
         $mform->setAdvanced('introeditor');
 
-        $mform->addElement('checkbox', 'showtitle', '&nbsp;', ' ' . get_string('display_name', 'lti'));
-        $mform->setAdvanced('showtitle');
-        $mform->addHelpButton('showtitle', 'display_name', 'lti');
+        // Display the label to the right of the checkbox so it looks better & matches rest of the form
+        $coursedesc = $mform->getElement('showdescription');
+        if(!empty($coursedesc)){
+            $coursedesc->setText(' ' . $coursedesc->getLabel());
+            $coursedesc->setLabel('&nbsp');
+        }
 
-        $mform->addElement('checkbox', 'showdescription', '&nbsp;', ' ' . get_string('display_description', 'lti'));
         $mform->setAdvanced('showdescription');
-        $mform->addHelpButton('showdescription', 'display_description', 'lti');
+
+        $mform->addElement('checkbox', 'showtitlelaunch', '&nbsp;', ' ' . get_string('display_name', 'lti'));
+        $mform->setAdvanced('showtitlelaunch');
+        $mform->addHelpButton('showtitlelaunch', 'display_name', 'lti');
+
+        $mform->addElement('checkbox', 'showdescriptionlaunch', '&nbsp;', ' ' . get_string('display_description', 'lti'));
+        $mform->setAdvanced('showdescriptionlaunch');
+        $mform->addHelpButton('showdescriptionlaunch', 'display_description', 'lti');
 
         // Tool settings
         $tooltypes = $mform->addElement('select', 'typeid', get_string('external_tool_type', 'lti'), array());
index 9eb1e6d..499854d 100644 (file)
@@ -48,7 +48,7 @@
 
 defined('MOODLE_INTERNAL') || die;
 
-$module->version   = 2011111400;;
+$module->version   = 2011111600;;
 $module->requires  = 2011110200;  // Requires this Moodle version
 $module->cron      = 0;
 $module->component = 'mod_lti';
index 0697df6..350c68e 100644 (file)
@@ -100,12 +100,12 @@ $PAGE->set_heading($course->fullname);
 // Print the page header
 echo $OUTPUT->header();
 
-if ($lti->showtitle) {
+if ($lti->showtitlelaunch) {
     // Print the main part of the page
     echo $OUTPUT->heading(format_string($lti->name));
 }
 
-if ($lti->showdescription && $lti->intro) {
+if ($lti->showdescriptionlaunch && $lti->intro) {
     echo $OUTPUT->box($lti->intro, 'generalbox description', 'intro');
 }
 
index aa36d43..ac21684 100644 (file)
@@ -1260,20 +1260,13 @@ class page_wiki_history extends page_wiki {
             } else {
 
                 $checked = $vcount - $offset;
-                $lastdate = '';
                 $rowclass = array();
 
                 foreach ($versions as $version) {
                     $user = wiki_get_user_info($version->userid);
                     $picture = $OUTPUT->user_picture($user, array('popup' => true));
                     $date = userdate($version->timecreated, get_string('strftimedate'));
-                    if ($date == $lastdate) {
-                        $date = '';
-                        $rowclass[] = '';
-                    } else {
-                        $lastdate = $date;
-                        $rowclass[] = 'wiki_histnewdate';
-                    }
+                    $rowclass[] = 'wiki_histnewdate';
                     $time = userdate($version->timecreated, get_string('strftimetime', 'langconfig'));
                     $versionid = wiki_get_version($version->id);
                     if ($versionid) {
index ea58f52..6f47313 100644 (file)
@@ -40,6 +40,19 @@ class plagiarism_plugin {
     public function get_links($linkarray) {
         return '';
     }
+    /**
+     * hook to allow plagiarism specific information to be returned unformatted
+     * @param int $cmid
+     * @param int $userid
+     * @param object $file moodle file object
+     * @return array containing at least:
+     *   - 'analyzed' - whether the file has been successfully analyzed
+     *   - 'score' - similarity score - ('' if not known)
+     *   - 'reporturl' - url of originality report - '' if unavailable
+     */
+    public function get_file_results($cmid, $userid, $file) {
+        return array('analyzed' => '', 'score' => '', 'reporturl' => '');
+    }
     /**
      * hook to add plagiarism specific settings to a module settings page
      * @param object $mform  - Moodle form
index 188bce1..df2b251 100644 (file)
@@ -125,7 +125,7 @@ html, body {
 }
 
 #page-report-outline-user .section {
-    border:i 1px solid #DDD;
+    border: 1px solid #DDD;
     margin: 0 5% 1.5em 5%;
 }
 
index 3abeb99..999a630 100644 (file)
@@ -652,6 +652,7 @@ body.tag .managelink {padding: 5px;}
 #page-enrol-users .enrol_user_buttons .enrolusersbutton div,
 #page-enrol-users .enrol_user_buttons .enrolusersbutton form {display:inline;}
 #page-enrol-users .enrol_user_buttons .enrolusersbutton input {padding-left:6px;padding-right:6px;}
+#page-enrol-users.dir-rtl .col_userdetails .subfield_picture {float: right;}
 
 /**
 * Overide for RTL layout
@@ -664,6 +665,9 @@ body.tag .managelink {padding: 5px;}
 .dir-rtl .mform .fitem .fitemtitle {float:right;}
 .dir-rtl .loginbox .loginform .form-label {float:right;text-align:left;}
 .dir-rtl .loginbox .loginform .form-input {text-align: right;}
+.dir-rtl .yui3-menu-hidden {left: 0px;}
+#page-admin-roles-define.dir-rtl #rolesform .felement {margin-right: 180px;}
+#page-message-edit.dir-rtl table.generaltable th.c0 {text-align: right;}
 
 /**
  * Backup
index 37f9792..3062ac6 100644 (file)
@@ -27,7 +27,7 @@
 .path-course-view li.activity form.togglecompletion .ajaxworking {position:absolute;top:0; left:20px;width: 20px; height: 20px;background: url([[pix:i/ajaxloader]]) no-repeat;}
 .dir-rtl.path-course-view li.activity {margin-right:0px;margin-left:20px;}
 .dir-rtl.path-course-view li.activity form.togglecompletion,
-.dir-rtl.path-course-view li.activity span.autocompletion {right:auto;right:-20px;}
+.dir-rtl.path-course-view li.activity span.autocompletion {right:auto;left:-20px;}
 
 .section img.movetarget {height:16px;width:80px;}
 
index 9b3d0cd..77465ef 100644 (file)
@@ -27,7 +27,7 @@ $string['choosereadme'] = '<div class="clearfix"><div class="theme_screenshot"><
 $string['colourswatch'] = 'Mobile theme color swatch';
 $string['colourswatch_desc'] = 'Toggle the color swatch of the theme between grey and light/blue.';
 $string['grey'] = 'Grey';
-$string['light'] = 'Light';
+$string['light'] = 'Light/Blue';
 $string['mtoggle'] = 'Toggle 2nd Column';
 $string['no'] = 'No';
 $string['pluginname'] = 'MyMobile';