From 3565ff92e48f4c8dd28743a466501be122604882 Mon Sep 17 00:00:00 2001
From: nicolasconnault <nicolasconnault>
Date: Fri, 24 Aug 2007 06:01:15 +0000
Subject: [PATCH] MDL-10970 Someone was using $locations = array('location1');
 $locations += array('location2', 'location3', 'location4');

to save the hassle of doing one $locations[] = 'location1'; for each location.

But += doesn't add any entry if the key of the new array already exists in the original array. So, using my example, the resulting array would be:

$locations: array('location1', 'location3', 'location4');
---
 grade/lib.php     | 6 +++---
 lib/moodlelib.php | 9 ++++++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/grade/lib.php b/grade/lib.php
index 627ca0772f..31898c9783 100644
--- a/grade/lib.php
+++ b/grade/lib.php
@@ -35,7 +35,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
             if ($active_type == 'report' and $active_plugin == $plugin ) {
                 $active = $url;
             }
-            $reportnames[$url] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'lang/');
+            $reportnames[$url] = get_string('modulename', 'gradereport_'.$plugin, NULL, $CFG->dirroot.'/grade/report/'.$plugin.'/lang/');
         }
         asort($reportnames);
     }
@@ -59,7 +59,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
             if ($active_type == 'import' and $active_plugin == $plugin ) {
                 $active = $url;
             }
-            $importnames[$url] = get_string('modulename', 'gradeimport_'.$plugin, NULL, $CFG->dirroot.'/grade/import/'.$plugin.'lang/');
+            $importnames[$url] = get_string('modulename', 'gradeimport_'.$plugin, NULL, $CFG->dirroot.'/grade/import/'.$plugin.'/lang/');
         }
         asort($importnames);
     }
@@ -83,7 +83,7 @@ function print_grade_plugin_selector($courseid, $active_type, $active_plugin, $r
             if ($active_type == 'export' and $active_plugin == $plugin ) {
                 $active = $url;
             }
-            $exportnames[$url] = get_string('modulename', 'gradeexport_'.$plugin, NULL, $CFG->dirroot.'/grade/export/'.$plugin.'lang/');
+            $exportnames[$url] = get_string('modulename', 'gradeexport_'.$plugin, NULL, $CFG->dirroot.'/grade/export/'.$plugin.'/lang/');
         }
         asort($exportnames);
     }
diff --git a/lib/moodlelib.php b/lib/moodlelib.php
index 443e375a37..03eb239596 100644
--- a/lib/moodlelib.php
+++ b/lib/moodlelib.php
@@ -4481,10 +4481,13 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
     if (isset($CFG->running_installer)) {
         $module = 'installer';
         $filetocheck = 'installer.php';
-        $locations += array( $CFG->dirroot.'/install/lang/', $CFG->dataroot.'/lang/',  $CFG->dirroot.'/lang/' );
+        $locations[] = $CFG->dirroot.'/install/lang/';
+        $locations[] = $CFG->dataroot.'/lang/';
+        $locations[] = $CFG->dirroot.'/lang/';
         $defaultlang = 'en_utf8';
     } else {
-        $locations += array( $CFG->dataroot.'/lang/',  $CFG->dirroot.'/lang/' );
+        $locations[] = $CFG->dataroot.'/lang/';
+        $locations[] = $CFG->dirroot.'/lang/';
     }
 
 /// Add extra places to look for strings for particular plugin types.
@@ -4525,7 +4528,7 @@ function get_string($identifier, $module='', $a=NULL, $extralocations=NULL) {
                 eval($result);
                 return $resultstring;
             }
-        }
+       }
     }
 
 /// If the preferred language was English (utf8) we can abort now
-- 
2.39.5