]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-10311 - further groups import fixes - merged from MOODLE_18_STABLE
authorpoltawski <poltawski>
Fri, 6 Jul 2007 16:34:30 +0000 (16:34 +0000)
committerpoltawski <poltawski>
Fri, 6 Jul 2007 16:34:30 +0000 (16:34 +0000)
course/import/groups/index.php
lang/en_utf8/group.php

index 5498608ec2ee42aa45e34d8286335131d05b5775..341a59f425b703af2038819039b9fe5d621ce495 100755 (executable)
@@ -6,14 +6,14 @@
     require_once('../../lib.php');
     require_once($CFG->dirroot . '/group/lib/basicgrouplib.php');
     
-    $mycourseid = required_param('id', PARAM_INT);    // Course id
+    $id = required_param('id', PARAM_INT);    // Course id
     
-    if (! $course = get_record('course', 'id', $mycourseid) ) {
+    if (! $course = get_record('course', 'id', $id) ) {
         error("That's an invalid course id");
     }
     
     require_login($course->id);
-    $context = get_context_instance(CONTEXT_COURSE, $mycourseid);
+    $context = get_context_instance(CONTEXT_COURSE, $id);
     
     
     if (!has_capability('moodle/course:managegroups', $context)) {
         // check for valid field names
         foreach ($header as $i => $h) {
             $h = trim($h); $header[$i] = $h; // remove whitespace
-            if (!($required[$h] or $optionalDefaults[$h] or $optional[$h])) {
+            if ( !(isset($required[$h]) or 
+                isset($optionalDefaults[$h]) or 
+                isset($optional[$h])) ) {
                 error(get_string('invalidfieldname', 'error', $h), 'index.php?id='.$id.'&amp;sesskey='.$USER->sesskey);
             }
-            if ($required[$h]) {
+            if ( isset($required[$h]) ) {
                 $required[$h] = 2;
             }
         }
                 // add fields to object $user
                 foreach ($record as $name => $value) {
                     // check for required values
-                    if ($required[$name] and !$value) {
+                    if (isset($required[$name]) and !$value) {
                         error(get_string('missingfield', 'error', $name). " ".
                               get_string('erroronline', 'error', $linenum) .". ".
                               get_string('processingstops', 'error'), 
                 }
                 //else juse use current id
                 else{
-                    $newgroup->courseid = $mycourseid;
+                    $newgroup->courseid = $id;
                 }
                 
                 //if courseid is set
                     
                     ///Users cannot upload groups in courses they cannot update.
                     if (!has_capability('moodle/course:managegroups', $newgrpcoursecontext)){
-                        notify("$newgroup->name ".get_string('notaddedto').$newgroup->coursename.get_string('notinyourcapacity'));
+                        notify( get_string('nopermissionforcreation','group',$newgroup->name) );
                     } else {
                         if ( $group = groups_group_name_exists($newgroup->courseid, $groupname) || !($newgroup->id = groups_create_group($newgroup->courseid, $newgroup)) ) {
     
                             //Record not added - probably because group is already registered
                             //In this case, output groupname from previous registration
                             if ($group) {
-                                notify("$newgroup->name ".get_string('groupexistforcourse', 'error', $groupname));
+                                notify("$newgroup->name :".get_string('groupexistforcourse', 'error', $groupname));
                             } else {
                                 notify(get_string('groupnotaddederror', 'error', $groupname));
                             } 
                         }  
                         else {
-                            notify(get_string('group')." $newgroup->name ".get_string('addedsuccessfully'));
+                            notify( get_string('groupaddedsuccesfully', 'group', $newgroup->name) );
                         }
                     }
                 } //close courseid validity check
index a887b71db9cf172c9d851f49af30b20f5436e0b7..0ada7d7561fcc1564398a394bbbf52062a3b786b 100644 (file)
@@ -114,4 +114,6 @@ $string['groupsnone'] = 'No groups';
 $string['groupsseparate'] = 'Separate groups';
 $string['groupsvisible'] = 'Visible groups';
 
-?>
\ No newline at end of file
+$string['groupaddedsuccesfully'] = 'Group $a added succesfully';
+$string['nopermissionforcreation'] = 'Can\'t create group \"$a\" as you dont have the required permissions';
+?>