Permalink
Browse files

MDL-35637 group: Fix form submission error that occurs when GD versio…

…n is not set.
  • Loading branch information...
1 parent a3ab18c commit 5a45b936bf58f3bfe9b97a19ea9794ef8ddfabba @markn86 markn86 committed Sep 27, 2012
Showing with 11 additions and 10 deletions.
  1. +11 −10 group/lib.php
View
@@ -311,17 +311,18 @@ function groups_update_group_icon($group, $data, $editform) {
$context = context_course::instance($group->courseid, MUST_EXIST);
//TODO: it would make sense to allow picture deleting too (skodak)
-
- if ($iconfile = $editform->save_temp_file('imagefile')) {
- if (process_new_icon($context, 'group', 'icon', $group->id, $iconfile)) {
- $DB->set_field('groups', 'picture', 1, array('id'=>$group->id));
- $group->picture = 1;
- } else {
- $fs->delete_area_files($context->id, 'group', 'icon', $group->id);
- $DB->set_field('groups', 'picture', 0, array('id'=>$group->id));
- $group->picture = 0;
+ if (!empty($CFG->gdversion)) {
+ if ($iconfile = $editform->save_temp_file('imagefile')) {
+ if (process_new_icon($context, 'group', 'icon', $group->id, $iconfile)) {
+ $DB->set_field('groups', 'picture', 1, array('id'=>$group->id));
+ $group->picture = 1;
+ } else {
+ $fs->delete_area_files($context->id, 'group', 'icon', $group->id);
+ $DB->set_field('groups', 'picture', 0, array('id'=>$group->id));
+ $group->picture = 0;
+ }
+ @unlink($iconfile);
}
- @unlink($iconfile);
}
}

0 comments on commit 5a45b93

Please sign in to comment.