Skip to content

Commit

Permalink
Optimize array size
Browse files Browse the repository at this point in the history
  • Loading branch information
dasistwas committed May 19, 2024
1 parent 3e5112d commit 74d7c2e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions field/field_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ public function get_datalynx_instances_menu(): array {
$dl = new mod_datalynx\datalynx($dlid);
// Only add if user can manage dl templates.
if (has_capability('mod/datalynx:managetemplates', $dl->context)) {
$datalynxs[$dlid] = $dl;
$dlinfo = new stdClass();
$dlinfo->courseshortname = $dl->course->shortname;
$dlinfo->name = $dl->name();
$datalynxs[$dlid] = $dlinfo;
}
}
}
Expand All @@ -128,11 +131,11 @@ public function get_datalynx_instances_menu(): array {
$dfmenu[''][$this->_df->id()] = get_string('thisdatalynx', 'datalynx') .
" (" . strip_tags(format_string($this->_df->name(), true)) . ")";
foreach ($datalynxs as $dlid => $dl) {
if (!isset($dfmenu[$dl->course->shortname])) {
$dfmenu[$dl->course->shortname] = array();
if (!isset($dfmenu[$dl->courseshortname])) {
$dfmenu[$dl->courseshortname] = array();
}
$dfmenu[$dl->course->shortname][$dlid] = strip_tags(
format_string($dl->name(), true));
$dfmenu[$dl->courseshortname][$dlid] = strip_tags(
format_string($dl->name, true));
}
} else {
$dfmenu = array('' => array(0 => get_string('nodatalynxs', 'datalynx')));
Expand Down

0 comments on commit 74d7c2e

Please sign in to comment.