From 75156589fd82e4a88721fff8b3e7ff2ea74bdc8f Mon Sep 17 00:00:00 2001 From: Mark Nielsen Date: Tue, 12 Mar 2013 15:28:23 -0700 Subject: [PATCH] MDL-36060: Remove anonymous functions in mod/lti This was breaking eaccelerator because it doesn't support anonymous functions. --- mod/lti/locallib.php | 17 +++++++++++++++++ mod/lti/settings.php | 12 +++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index 368ac6c5bb0bc..37f2e32e82ee1 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -573,6 +573,23 @@ function lti_filter_get_types($course) { 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() { global $DB, $SITE, $COURSE; diff --git a/mod/lti/settings.php b/mod/lti/settings.php index 36efa95d45962..46e5bb08596b2 100644 --- a/mod/lti/settings.php +++ b/mod/lti/settings.php @@ -66,21 +66,15 @@ $types = lti_filter_get_types(get_site()->id); - $configuredtools = array_filter($types, function($value) { - return $value->state == LTI_TOOL_STATE_CONFIGURED; - }); + $configuredtools = lti_filter_tool_types($types, LTI_TOOL_STATE_CONFIGURED); $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured'); - $pendingtools = array_filter($types, function($value) { - return $value->state == LTI_TOOL_STATE_PENDING; - }); + $pendingtools = lti_filter_tool_types($types, LTI_TOOL_STATE_PENDING); $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending'); - $rejectedtools = array_filter($types, function($value) { - return $value->state == LTI_TOOL_STATE_REJECTED; - }); + $rejectedtools = lti_filter_tool_types($types, LTI_TOOL_STATE_REJECTED); $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');