Commit 1ffd82ce authored by Robert Lyon's avatar Robert Lyon Committed by Kristina Hoeppner
Browse files

Bug 1690221: Add sort order to the profile types chooser



This was originally relying on the order data was placed into db -
which is brittle

Now we order this data based on the get_profile_artefact_types() array
that is hardcoded in the artefact/internal/lib.php file

behatnotneeded

Sponsored by SWITCH

Change-Id: I22307e6f84dd2561088a68c1bcaf8fd5aafb8f11
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 62fd8dc1
......@@ -260,7 +260,18 @@ class PluginBlocktypeProfileinfo extends MaharaCoreBlocktype {
* are listed in the profile screen
*/
public static function artefactchooser_get_sort_order() {
return '';
safe_require('artefact', 'internal');
$artefacttypes = array_diff(PluginArtefactInternal::get_profile_artefact_types(), array('email'));
if (!get_record('blocktype_installed', 'active', 1, 'name', 'socialprofile')) {
$artefacttypes = array_diff($artefacttypes, array('socialprofile'));
}
$sortorder = array();
foreach ($artefacttypes as $type) {
$sortorder[] = array('fieldname' => 'artefacttype',
'fieldvalue' => $type,
'order' => 'DESC');
}
return $sortorder;
}
public static function rewrite_blockinstance_config(View $view, $configdata) {
......
......@@ -3353,8 +3353,11 @@ class View {
else {
$sortorder .= ', ';
}
$sortorder .= $field['fieldname'] . ' ' . $order;
$fieldname = $field['fieldname'];
if (!empty($field['fieldvalue'])) {
$fieldname .= " = '" . $field['fieldvalue'] . "'";
}
$sortorder .= $fieldname . ' ' . $order;
}
}
......
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