Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-36060: Remove anonymous functions in mod/lti

This was breaking eaccelerator because it doesn't
support anonymous functions.
  • Loading branch information...
commit 7281117d6e7486ac42d0fdc4cb77e48973b62531 1 parent 5e00b9a
Mark Nielsen mrmark authored danpoltawski committed

Showing 2 changed files with 20 additions and 9 deletions. Show diff stats Hide diff stats

  1. +17 0 mod/lti/locallib.php
  2. +3 9 mod/lti/settings.php
17 mod/lti/locallib.php
@@ -563,6 +563,23 @@ function lti_filter_get_types($course) {
563 563 return $DB->get_records('lti_types', $filter);
564 564 }
565 565
  566 +/**
  567 + * Given an array of tools, filter them based on their state
  568 + *
  569 + * @param array $tools An array of lti_types records
  570 + * @param int $state One of the LTI_TOOL_STATE_* constants
  571 + * @return array
  572 + */
  573 +function lti_filter_tool_types(array $tools, $state) {
  574 + $return = array();
  575 + foreach ($tools as $key => $tool) {
  576 + if ($tool->state == $state) {
  577 + $return[$key] = $tool;
  578 + }
  579 + }
  580 + return $return;
  581 +}
  582 +
566 583 function lti_get_types_for_add_instance() {
567 584 global $DB, $SITE, $COURSE;
568 585
12 mod/lti/settings.php
@@ -66,21 +66,15 @@
66 66
67 67 $types = lti_filter_get_types(get_site()->id);
68 68
69   - $configuredtools = array_filter($types, function($value) {
70   - return $value->state == LTI_TOOL_STATE_CONFIGURED;
71   - });
  69 + $configuredtools = lti_filter_tool_types($types, LTI_TOOL_STATE_CONFIGURED);
72 70
73 71 $configuredtoolshtml = lti_get_tool_table($configuredtools, 'lti_configured');
74 72
75   - $pendingtools = array_filter($types, function($value) {
76   - return $value->state == LTI_TOOL_STATE_PENDING;
77   - });
  73 + $pendingtools = lti_filter_tool_types($types, LTI_TOOL_STATE_PENDING);
78 74
79 75 $pendingtoolshtml = lti_get_tool_table($pendingtools, 'lti_pending');
80 76
81   - $rejectedtools = array_filter($types, function($value) {
82   - return $value->state == LTI_TOOL_STATE_REJECTED;
83   - });
  77 + $rejectedtools = lti_filter_tool_types($types, LTI_TOOL_STATE_REJECTED);
84 78
85 79 $rejectedtoolshtml = lti_get_tool_table($rejectedtools, 'lti_rejected');
86 80

0 comments on commit 7281117

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