Skip to content
Browse files

Merge branch 'MDL-36060-23' of git://github.com/danpoltawski/moodle i…

…nto MOODLE_23_STABLE
  • Loading branch information...
2 parents cfbf324 + 7281117 commit c1163a13feca1631e121998cef1750f6c93503ca Sam Hemelryk committed May 1, 2013
Showing with 20 additions and 9 deletions.
  1. +17 −0 mod/lti/locallib.php
  2. +3 −9 mod/lti/settings.php
View
17 mod/lti/locallib.php
@@ -563,6 +563,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;
View
12 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');

0 comments on commit c1163a1

Please sign in to comment.
Something went wrong with that request. Please try again.