Skip to content

Commit

Permalink
MDL-52454 tool_lp: Fix all PARAM_TEXT on persistent, and exporters
Browse files Browse the repository at this point in the history
  • Loading branch information
gauts authored and Frederic Massart committed Apr 18, 2016
1 parent 357d386 commit e54f8c4
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/competency.php
Expand Up @@ -68,7 +68,7 @@ protected static function define_properties() {
),
'description' => array(
'default' => '',
'type' => PARAM_TEXT
'type' => PARAM_RAW
),
'descriptionformat' => array(
'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/competency_framework.php
Expand Up @@ -90,7 +90,7 @@ protected static function define_properties() {
'type' => PARAM_TEXT
),
'description' => array(
'type' => PARAM_TEXT,
'type' => PARAM_RAW,
'default' => ''
),
'descriptionformat' => array(
Expand Down
5 changes: 2 additions & 3 deletions admin/tool/lp/classes/external/exporter.php
Expand Up @@ -144,7 +144,7 @@ final public function export(renderer_base $output) {

$data->$property = $record->$property;

// If the field is PARAM_TEXT and has a format field.
// If the field is PARAM_RAW and has a format field.
if ($propertyformat = self::get_format_field($properties, $property)) {
if (!property_exists($record, $propertyformat)) {
// Whoops, we got something that wasn't defined.
Expand All @@ -155,7 +155,6 @@ final public function export(renderer_base $output) {
$data->$property = $text;
$data->$propertyformat = $format;

// If it's a PARAM_TEXT without format field.
} else if ($definition['type'] === PARAM_TEXT) {
if (!empty($definition['multiple'])) {
foreach ($data->$property as $key => $value) {
Expand Down Expand Up @@ -334,7 +333,7 @@ final protected static function get_context_structure() {
*/
final protected static function get_format_field($definitions, $property) {
$formatproperty = $property . 'format';
if ($definitions[$property]['type'] == PARAM_TEXT && isset($definitions[$formatproperty])
if ($definitions[$property]['type'] == PARAM_RAW && isset($definitions[$formatproperty])
&& $definitions[$formatproperty]['type'] == PARAM_INT) {
return $formatproperty;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/form/competency.php
Expand Up @@ -76,7 +76,7 @@ public function definition() {
$mform->addRule('shortname', null, 'required', null, 'client');
$mform->addElement('editor', 'description',
get_string('description', 'tool_lp'), array('rows' => 4));
$mform->setType('description', PARAM_TEXT);
$mform->setType('description', PARAM_RAW);
$mform->addElement('text', 'idnumber',
get_string('idnumber', 'tool_lp'));
$mform->setType('idnumber', PARAM_TEXT);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/form/competency_framework.php
Expand Up @@ -60,7 +60,7 @@ public function definition() {
$mform->addRule('shortname', null, 'required', null, 'client');
$mform->addElement('editor', 'description',
get_string('description', 'tool_lp'), array('rows' => 4));
$mform->setType('description', PARAM_TEXT);
$mform->setType('description', PARAM_RAW);
$mform->addElement('text', 'idnumber',
get_string('idnumber', 'tool_lp'));
$mform->setType('idnumber', PARAM_TEXT);
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/form/plan.php
Expand Up @@ -54,7 +54,7 @@ public function definition() {
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addElement('editor', 'description', get_string('plandescription', 'tool_lp'), array('rows' => 4));
$mform->setType('description', PARAM_TEXT);
$mform->setType('description', PARAM_RAW);

$mform->addElement('date_time_selector', 'duedate', get_string('duedate', 'tool_lp'), array('optional' => true));
$mform->addHelpButton('duedate', 'duedate', 'tool_lp');
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/form/template.php
Expand Up @@ -56,7 +56,7 @@ public function definition() {
$mform->addRule('shortname', null, 'required', null, 'client');
$mform->addElement('editor', 'description',
get_string('description', 'tool_lp'), array('rows' => 4));
$mform->setType('description', PARAM_TEXT);
$mform->setType('description', PARAM_RAW);
$mform->addElement('selectyesno', 'visible',
get_string('visible', 'tool_lp'));
$mform->addElement('date_time_selector',
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/form/user_evidence.php
Expand Up @@ -53,7 +53,7 @@ public function definition() {

$mform->addElement('editor', 'description', get_string('userevidencedescription', 'tool_lp'), array('rows' => 10));
// TODO MDL-52454 Make PARAM_RAW.
$mform->setType('description', PARAM_TEXT);
$mform->setType('description', PARAM_RAW);

$mform->addElement('url', 'url', get_string('userevidenceurl', 'tool_lp'), array(), array('usefilepicker' => false));
$mform->setType('url', PARAM_RAW_TRIMMED); // Can not use PARAM_URL, it silently converts bad URLs to ''.
Expand Down
3 changes: 1 addition & 2 deletions admin/tool/lp/classes/persistent.php
Expand Up @@ -232,8 +232,7 @@ final public static function get_formatted_properties() {
$formatted = array();
foreach ($properties as $property => $definition) {
$propertyformat = $property . 'format';
// TODO MDL-52454 Check PARAM_RAW.
if ($definition['type'] == PARAM_TEXT && array_key_exists($propertyformat, $properties)
if ($definition['type'] == PARAM_RAW && array_key_exists($propertyformat, $properties)
&& $properties[$propertyformat]['type'] == PARAM_INT) {
$formatted[$property] = $propertyformat;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/plan.php
Expand Up @@ -58,7 +58,7 @@ protected static function define_properties() {
'type' => PARAM_TEXT,
),
'description' => array(
'type' => PARAM_TEXT,
'type' => PARAM_RAW,
'default' => ''
),
'descriptionformat' => array(
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/template.php
Expand Up @@ -53,7 +53,7 @@ protected static function define_properties() {
),
'description' => array(
'default' => '',
'type' => PARAM_TEXT,
'type' => PARAM_RAW,
),
'descriptionformat' => array(
'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/classes/user_evidence.php
Expand Up @@ -53,7 +53,7 @@ protected static function define_properties() {
'type' => PARAM_TEXT
),
'description' => array(
'type' => PARAM_TEXT, // TODO MDL-52454 Make PARAM_RAW.
'type' => PARAM_RAW,
'default' => '',
),
'descriptionformat' => array(
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/lp/templates/competency_summary.mustache
@@ -1,9 +1,9 @@
<p><strong>{{competency.shortname}} <em>{{competency.idnumber}}</em></strong></p>
<p>{{competency.description}}</p>
<p>{{{competency.description}}}</p>

{{#framework}}
<p><strong>{{framework.shortname}}</strong></p>
<p>{{framework.description}}</p>
<p>{{{framework.description}}}</p>
{{/framework}}

{{#showrelatedcompetencies}}
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/templates/plan_page.mustache
Expand Up @@ -52,7 +52,7 @@
{{/plan.template}}
{{#description}}
<dt>{{#str}}description{{/str}}</dt>
<dd>{{plan.description}}</dd>
<dd>{{{plan.description}}}</dd>
{{/description}}
</dl>
</div>
Expand Down
2 changes: 1 addition & 1 deletion admin/tool/lp/templates/user_evidence_page.mustache
Expand Up @@ -40,7 +40,7 @@
<div data-region="user-evidence-summary">
{{#description}}
<div>
{{description}}
{{{description}}}
</div>
{{/description}}
<ul class="user-evidence-documents">
Expand Down

0 comments on commit e54f8c4

Please sign in to comment.