Commit ba16996a authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1438894: Moving the profile introduction text to description column"

parents ca00f969 e305c12a
......@@ -243,6 +243,16 @@ class PluginBlocktypeProfileinfo extends MaharaCoreBlocktype {
'template' => 'artefact:internal:artefactchooser-element.tpl',
);
}
/**
* Allow the introduction option to be displayed correctly
*/
public static function artefactchooser_get_element_data($artefact) {
if ($artefact->artefacttype == 'introduction') {
unset($artefact->description);
}
return $artefact;
}
/**
* Deliberately enforce _no_ sort order. The database will return them in
......
......@@ -49,7 +49,7 @@ class LeapExportElementInternal extends LeapExportElement {
if (!$data = $this->data_mapping($a)) {
if ($a->get('artefacttype') == 'introduction') {
$this->smarty->assign('contenttype', 'html');
$this->smarty->assign('content', clean_html($a->get('title')));
$this->smarty->assign('content', clean_html($a->get('description')));
}
continue;
}
......
......@@ -393,7 +393,8 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
switch ($entrydata['type']) {
case 'introduction':
$introduction = new ArtefactTypeIntroduction(0, array('owner' => $importer->get('usr')));
$introduction->set('title', $entrydata['content']['title']);
$introduction->set('title', 'introduction');
$introduction->set('description', $entrydata['content']['title']);
$introduction->commit();
$artefactmapping[(string)$entry->id] = array($introduction->get('id'));
break;
......
......@@ -31,7 +31,12 @@ $profile_data = get_records_select_array('artefact', "owner=? AND artefacttype I
if ($profile_data) {
foreach ($profile_data as $field) {
$profilefields[$field->artefacttype] = $field->title;
if ($field->artefacttype == 'introduction') {
$profilefields[$field->artefacttype] = $field->description;
}
else {
$profilefields[$field->artefacttype] = $field->title;
}
}
}
......
......@@ -789,8 +789,14 @@ class ArtefactTypeEmail extends ArtefactTypeProfileField {
class ArtefactTypeStudentid extends ArtefactTypeCachedProfileField {}
class ArtefactTypeIntroduction extends ArtefactTypeProfileField {
public function commit() {
$this->set('description', $this->title);
$this->set('title', 'introduction');
parent::commit();
}
public function render_self($options) {
return array('html' => clean_html($this->title), 'javascript' => null);
return array('html' => clean_html($this->description), 'javascript' => null);
}
}
class ArtefactTypeWebAddress extends ArtefactTypeProfileField {
......
......@@ -4556,5 +4556,24 @@ function xmldb_core_upgrade($oldversion=0) {
clear_menu_cache();
}
if ($oldversion < 2016070801) {
log_debug('Adjusting the profile "introduction" field to store the tinymce data in description field rather than title field for consistency');
if ($results = get_records_array('artefact', 'artefacttype', 'introduction', 'id', 'id')) {
safe_require('artefact', 'internal');
$count = 0;
$limit = 1000;
$total = count($results);
foreach ($results as $result) {
$introduction = new ArtefactTypeIntroduction($result->id);
$introduction->commit();
$count++;
if (($count % $limit) == 0 || $count == $total) {
log_debug("$count/$total");
set_time_limit(30);
}
}
}
}
return $status;
}
......@@ -663,6 +663,9 @@ function get_profile_field($userid, $field) {
$value = ArtefactTypeSocialprofile::get_social_profiles();
}
}
else if ($field == 'introduction') {
$value = get_field('artefact', 'description', 'owner', $userid, 'artefacttype', $field);
}
else {
$value = get_field('artefact', 'title', 'owner', $userid, 'artefacttype', $field);
}
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/wiki/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2016070800;
$config->version = 2016070801;
$config->series = '16.10';
$config->release = '16.10dev';
$config->minupgradefrom = 2012080604;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment