Navigation Menu

Skip to content

Commit

Permalink
MDL-36060: Remove anonymous functions in mod/lti
Browse files Browse the repository at this point in the history
This was breaking eaccelerator because it doesn't
support anonymous functions.
  • Loading branch information
polothy authored and danpoltawski committed Apr 30, 2013
1 parent c6be138 commit 7515658
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
17 changes: 17 additions & 0 deletions mod/lti/locallib.php
Expand Up @@ -573,6 +573,23 @@ function lti_filter_get_types($course) {
return $DB->get_records('lti_types', $filter); return $DB->get_records('lti_types', $filter);
} }


/**
* Given an array of tools, filter them based on their state
*
* @param array $tools An array of lti_types records
* @param int $state One of the LTI_TOOL_STATE_* constants
* @return array
*/
function lti_filter_tool_types(array $tools, $state) {
$return = array();
foreach ($tools as $key => $tool) {
if ($tool->state == $state) {
$return[$key] = $tool;
}
}
return $return;
}

function lti_get_types_for_add_instance() { function lti_get_types_for_add_instance() {
global $DB, $SITE, $COURSE; global $DB, $SITE, $COURSE;


Expand Down
12 changes: 3 additions & 9 deletions mod/lti/settings.php
Expand Up @@ -66,21 +66,15 @@


$types = lti_filter_get_types(get_site()->id); $types = lti_filter_get_types(get_site()->id);


$configuredtools = array_filter($types, function($value) { $configuredtools = lti_filter_tool_types($types, LTI_TOOL_STATE_CONFIGURED);
return $value->state == LTI_TOOL_STATE_CONFIGURED;
});


$configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured'); $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');


$pendingtools = array_filter($types, function($value) { $pendingtools = lti_filter_tool_types($types, LTI_TOOL_STATE_PENDING);
return $value->state == LTI_TOOL_STATE_PENDING;
});


$pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending'); $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');


$rejectedtools = array_filter($types, function($value) { $rejectedtools = lti_filter_tool_types($types, LTI_TOOL_STATE_REJECTED);
return $value->state == LTI_TOOL_STATE_REJECTED;
});


$rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected'); $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');


Expand Down

0 comments on commit 7515658

Please sign in to comment.