require_once("../config.php");
require_once("lib.php");
+ require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->libdir.'/completionlib.php');
require_once($CFG->libdir.'/conditionlib.php');
* @param string $module name of module
* @param object $activity instance of activity
* @param int $cmid course module id
+ * @param bool $filter filter resulting html text
* @return text
*/
-function format_module_intro($module, $activity, $cmid) {
+function format_module_intro($module, $activity, $cmid, $filter=true) {
global $CFG;
require_once("$CFG->libdir/filelib.php");
- $options = (object)array('noclean'=>true, 'para'=>false);
+ $options = (object)array('noclean'=>true, 'para'=>false, 'filter'=>false);
$context = get_context_instance(CONTEXT_MODULE, $cmid);
$intro = file_rewrite_pluginfile_urls($activity->intro, 'pluginfile.php', $context->id, $module.'_intro', 0);
return trim(format_text($intro, $activity->introformat, $options));
fwrite ($bf,full_tag("ID",4,false,$label->id));
fwrite ($bf,full_tag("MODTYPE",4,false,"label"));
fwrite ($bf,full_tag("NAME",4,false,$label->name));
- fwrite ($bf,full_tag("CONTENT",4,false,$label->content));
+ fwrite ($bf,full_tag("CONTENT",4,false,$label->intro));
fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$label->timemodified));
//End mod
$status = fwrite ($bf,end_tag("MOD",3,true));
<?xml version="1.0" encoding="UTF-8" ?>
-<XMLDB PATH="mod/label/db" VERSION="20060905" COMMENT="XMLDB file for Moodle mod/label"
+<XMLDB PATH="mod/label/db" VERSION="20090422" COMMENT="XMLDB file for Moodle mod/label"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../lib/xmldb/xmldb.xsd"
>
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" SEQUENCE="true" ENUM="false" NEXT="course"/>
<FIELD NAME="course" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="id" NEXT="name"/>
- <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="content"/>
- <FIELD NAME="content" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="timemodified"/>
- <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="content"/>
+ <FIELD NAME="name" TYPE="char" LENGTH="255" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="course" NEXT="intro"/>
+ <FIELD NAME="intro" TYPE="text" LENGTH="small" NOTNULL="true" SEQUENCE="false" ENUM="false" PREVIOUS="name" NEXT="introformat"/>
+ <FIELD NAME="introformat" TYPE="int" LENGTH="4" NOTNULL="false" UNSIGNED="true" DEFAULT="4" SEQUENCE="false" ENUM="false" PREVIOUS="intro" NEXT="timemodified"/>
+ <FIELD NAME="timemodified" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="introformat"/>
</FIELDS>
<KEYS>
- <KEY NAME="primary" TYPE="primary" FIELDS="id" />
+ <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
<INDEXES>
<INDEX NAME="course" UNIQUE="false" FIELDS="course"/>
</INDEXES>
</TABLE>
</TABLES>
-</XMLDB>
+</XMLDB>
\ No newline at end of file
upgrade_mod_savepoint($result, 2007101510, 'label');
}
+ if ($result && $oldversion < 2009042200) {
+
+ /// Rename field content on table label to intro
+ $table = new xmldb_table('label');
+ $field = new xmldb_field('content', XMLDB_TYPE_TEXT, 'small', null, XMLDB_NOTNULL, null, null, null, null, 'name');
+
+ /// Launch rename field content
+ $dbman->rename_field($table, $field, 'intro');
+
+ /// label savepoint reached
+ upgrade_mod_savepoint($result, 2009042200, 'label');
+ }
+
+ if ($result && $oldversion < 2009042201) {
+
+ /// Define field introformat to be added to label
+ $table = new xmldb_table('label');
+ $field = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', XMLDB_UNSIGNED, null, null, null, null, '4', 'intro');
+
+ /// Launch add field introformat
+ $dbman->add_field($table, $field);
+
+ /// label savepoint reached
+ upgrade_mod_savepoint($result, 2009042201, 'label');
+ }
+
return $result;
}
function get_label_name($label) {
$textlib = textlib_get_instance();
- $name = strip_tags(format_string($label->content,true));
+ $name = strip_tags(format_string($label->intro,true));
if ($textlib->strlen($name) > LABEL_MAX_NAME_LENGTH) {
$name = $textlib->substr($name, 0, LABEL_MAX_NAME_LENGTH)."...";
}
function label_get_coursemodule_info($coursemodule) {
global $DB;
- if ($label = $DB->get_record('label', array('id'=>$coursemodule->instance), 'id, content, name')) {
+ if ($label = $DB->get_record('label', array('id'=>$coursemodule->instance), 'id, name, intro, introformat')) {
if (empty($label->name)) {
// label name missing, fix it
$label->name = "label{$label->id}";
$DB->set_field('label', 'name', $label->name, array('id'=>$label->id));
}
$info = new object();
- $info->extra = urlencode($label->content);
- $info->name = urlencode($label->name);
+ // no filtering hre because this info is cached and filtered later
+ $info->extra = urlencode(format_module_intro('label', $label, $coursemodule->id, false));
+ $info->name = urlencode($label->name);
return $info;
} else {
return null;
case FEATURE_GROUPS: return false;
case FEATURE_GROUPINGS: return false;
case FEATURE_GROUPMEMBERSONLY: return true;
- case FEATURE_MOD_INTRO: return false;
+ case FEATURE_MOD_INTRO: return true;
case FEATURE_COMPLETION_TRACKS_VIEWS: return false;
case FEATURE_GRADE_HAS_GRADE: return false;
case FEATURE_GRADE_OUTCOMES: return false;
$mform =& $this->_form;
- $mform->addElement('htmleditor', 'content', get_string('labeltext', 'label'), array('size'=>'64'));
- $mform->setType('content', PARAM_RAW);
- $mform->addRule('content', get_string('required'), 'required', null, 'client');
- $mform->setHelpButton('content', array('questions', 'richtext2'), false, 'editorhelpbutton');
+ $this->add_intro_editor(true, get_string('labeltext', 'label'));
$this->standard_coursemodule_elements();
}
}
-?>
//Now, build the LABEL record structure
$label->course = $restore->course_id;
$label->name = backup_todb($info['MOD']['#']['NAME']['0']['#']);
- $label->content = backup_todb($info['MOD']['#']['CONTENT']['0']['#']);
+ $label->intro = backup_todb($info['MOD']['#']['CONTENT']['0']['#']);
$label->timemodified = $info['MOD']['#']['TIMEMODIFIED']['0']['#'];
//The structure is equal to the db, so insert the label
foreach ($labels as $label) {
//Increment counter
$i++;
- $content = $label->content;
+ $content = $label->intro;
$result = restore_decode_content_links_worker($content,$restore);
if ($result != $content) {
//Update record
- $label->content = $result;
+ $label->intro = $result;
$status = $DB->update_record("label", $label);
if (debugging()) {
if (!defined('RESTORE_SILENTLY')) {
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2007101510; // The current module version (Date: YYYYMMDDXX)
-$module->requires = 2007101509; // Requires this Moodle version
+$module->version = 2009042201; // The current module version (Date: YYYYMMDDXX)
+$module->requires = 2009041700; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
?>
}
}
- require_login($course->id);
+ require_login($course, true, $cm);
redirect("$CFG->wwwroot/course/view.php?id=$course->id");