Passed
Push — 1.10.x ( b1a5c9...95d0a1 )
by
unknown
197:44 queued 146:40
created
main/group/group_creation.php 2 patches
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
             exit;
58 58
             break;
59 59
         case 'create_subgroups':
60
-			GroupManager::create_subgroups(
61
-				$_POST['base_group'],
62
-				$_POST['number_of_groups']
63
-			);
60
+            GroupManager::create_subgroups(
61
+                $_POST['base_group'],
62
+                $_POST['number_of_groups']
63
+            );
64 64
             Display::addFlash(Display::return_message(get_lang('GroupsAdded')));
65 65
             header("Location: ".$currentUrl);
66 66
             exit;
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
 if (isset($_POST['number_of_groups'])) {
85 85
     if (!is_numeric($_POST['number_of_groups']) || intval($_POST['number_of_groups']) < 1) {
86 86
         Display :: display_error_message(
87
-			get_lang('PleaseEnterValidNumber').'<br /><br />
87
+            get_lang('PleaseEnterValidNumber').'<br /><br />
88 88
 			<a href="group_creation.php?'.api_get_cidreq().'">&laquo; '.get_lang('Back').'</a>',
89
-			false
90
-		);
89
+            false
90
+        );
91 91
     } else {
92 92
         $number_of_groups = intval($_POST['number_of_groups']);
93 93
         if ($number_of_groups > 1) {
@@ -125,20 +125,20 @@  discard block
 block discarded – undo
125 125
     }
126 126
     </script>
127 127
     <?php
128
-		}
129
-		$group_categories = GroupManager::get_categories();
130
-		$group_id = GroupManager :: get_number_of_groups() + 1;
131
-		$cat_options = [];
132
-		foreach ($group_categories as $index => $category) {
133
-			$cat_options[$category['id']] = $category['title'];
134
-		}
128
+        }
129
+        $group_categories = GroupManager::get_categories();
130
+        $group_id = GroupManager :: get_number_of_groups() + 1;
131
+        $cat_options = [];
132
+        foreach ($group_categories as $index => $category) {
133
+            $cat_options[$category['id']] = $category['title'];
134
+        }
135 135
         $form = new FormValidator('create_groups_step2', 'POST', api_get_self().'?'.api_get_cidreq());
136 136
 
137
-		// Modify the default templates
138
-		$renderer = $form->defaultRenderer();
139
-		$form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>";
140
-		$renderer->setFormTemplate($form_template);
141
-		$element_template = <<<EOT
137
+        // Modify the default templates
138
+        $renderer = $form->defaultRenderer();
139
+        $form_template = "<form {attributes}>\n<div class='create-groups'>\n<table>\n{content}\n</table>\n</div>\n</form>";
140
+        $renderer->setFormTemplate($form_template);
141
+        $element_template = <<<EOT
142 142
         <tr class="separate">
143 143
 		<td>
144 144
 			<!-- BEGIN required -->
@@ -151,35 +151,35 @@  discard block
 block discarded – undo
151 151
 	</tr>
152 152
 
153 153
 EOT;
154
-		$renderer->setCustomElementTemplate($element_template);
154
+        $renderer->setCustomElementTemplate($element_template);
155 155
         $form->addElement('header', $nameTools);
156
-		$form->addElement('hidden', 'action');
157
-		$form->addElement('hidden', 'number_of_groups');
158
-		$defaults = array();
159
-		// Table heading
160
-		$group_el = array();
161
-		$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
156
+        $form->addElement('hidden', 'action');
157
+        $form->addElement('hidden', 'number_of_groups');
158
+        $defaults = array();
159
+        // Table heading
160
+        $group_el = array();
161
+        $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupName').'</b>');
162 162
 
163
-		if (api_get_setting('allow_group_categories') == 'true') {
164
-			$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
165
-		}
166
-		$group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
167
-		$form->addGroup($group_el, 'groups', null, "</td><td>", false);
168
-		// Checkboxes
169
-		if ($_POST['number_of_groups'] > 1) {
170
-			$group_el = array ();
171
-			$group_el[] = $form->createElement('static', null, null, ' ');
172
-			if (api_get_setting('allow_group_categories') == 'true') {
173
-				$group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');"));
174
-			}
175
-			$group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');"));
176
-			$form->addGroup($group_el, 'groups', null, '</td><td>', false);
177
-		}
178
-		// Properties for all groups
179
-		for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
180
-			$group_el = array();
181
-			$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
182
-			if (api_get_setting('allow_group_categories') == 'true') {
163
+        if (api_get_setting('allow_group_categories') == 'true') {
164
+            $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupCategory').'</b>');
165
+        }
166
+        $group_el[] = $form->createElement('static', null, null, '<b>'.get_lang('GroupPlacesThis').'</b>');
167
+        $form->addGroup($group_el, 'groups', null, "</td><td>", false);
168
+        // Checkboxes
169
+        if ($_POST['number_of_groups'] > 1) {
170
+            $group_el = array ();
171
+            $group_el[] = $form->createElement('static', null, null, ' ');
172
+            if (api_get_setting('allow_group_categories') == 'true') {
173
+                $group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');"));
174
+            }
175
+            $group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');"));
176
+            $form->addGroup($group_el, 'groups', null, '</td><td>', false);
177
+        }
178
+        // Properties for all groups
179
+        for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
180
+            $group_el = array();
181
+            $group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
182
+            if (api_get_setting('allow_group_categories') == 'true') {
183 183
                 $group_el[] = $form->createElement(
184 184
                     'select',
185 185
                     'group_'.$group_number.'_category',
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
                     $cat_options,
188 188
                     array('id' => 'category_'.$group_number)
189 189
                 );
190
-			}
190
+            }
191 191
             $group_el[] = $form->createElement(
192 192
                 'text',
193 193
                 'group_'.$group_number.'_places',
@@ -195,111 +195,111 @@  discard block
 block discarded – undo
195 195
                 array('class' => 'span1', 'id' => 'places_'.$group_number)
196 196
             );
197 197
 
198
-			if ($_POST['number_of_groups'] < 10000) {
199
-				if ($group_id < 10) {
200
-					$prev = '000';
201
-				} elseif ($group_id < 100) {
202
-					$prev = '00';
203
-				} elseif ($group_id<1000) {
204
-					$prev = '0';
205
-				} else {
206
-					$prev = '';
207
-				}
208
-			}
198
+            if ($_POST['number_of_groups'] < 10000) {
199
+                if ($group_id < 10) {
200
+                    $prev = '000';
201
+                } elseif ($group_id < 100) {
202
+                    $prev = '00';
203
+                } elseif ($group_id<1000) {
204
+                    $prev = '0';
205
+                } else {
206
+                    $prev = '';
207
+                }
208
+            }
209 209
 
210
-			$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
211
-			$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
212
-		}
213
-		$defaults['action'] = 'create_groups';
214
-		$defaults['number_of_groups'] = intval($_POST['number_of_groups']);
215
-		$form->setDefaults($defaults);
216
-		$form->addButtonCreate(get_lang('CreateGroup'), 'submit');
210
+            $defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
211
+            $form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
212
+        }
213
+        $defaults['action'] = 'create_groups';
214
+        $defaults['number_of_groups'] = intval($_POST['number_of_groups']);
215
+        $form->setDefaults($defaults);
216
+        $form->addButtonCreate(get_lang('CreateGroup'), 'submit');
217 217
         $form->display();
218
-	}
218
+    }
219 219
 } else {
220
-	/*
220
+    /*
221 221
 	 * Show form to generate new groups
222 222
 	 */
223 223
 
224
-	$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
225
-	$create_groups_form->addElement('header', $nameTools);
224
+    $create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
225
+    $create_groups_form->addElement('header', $nameTools);
226 226
     $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1'));
227 227
     $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary');
228
-	$defaults = array();
229
-	$defaults['number_of_groups'] = 1;
230
-	$create_groups_form->setDefaults($defaults);
231
-	$create_groups_form->display();
228
+    $defaults = array();
229
+    $defaults['number_of_groups'] = 1;
230
+    $create_groups_form->setDefaults($defaults);
231
+    $create_groups_form->display();
232 232
 
233
-	/*
233
+    /*
234 234
 	 * Show form to generate subgroups
235 235
 	 */
236
-	if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) {
237
-		$base_group_options = array ();
238
-		$groups = GroupManager :: get_group_list();
239
-		foreach ($groups as $index => $group) {
240
-			$number_of_students = GroupManager :: number_of_students($group['id']);
241
-			if ($number_of_students > 0) {
242
-				$base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
243
-			}
244
-		}
245
-		if (count($base_group_options) > 0) {
246
-			$create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
236
+    if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) {
237
+        $base_group_options = array ();
238
+        $groups = GroupManager :: get_group_list();
239
+        foreach ($groups as $index => $group) {
240
+            $number_of_students = GroupManager :: number_of_students($group['id']);
241
+            if ($number_of_students > 0) {
242
+                $base_group_options[$group['id']] = $group['name'].' ('.$number_of_students.' '.get_lang('Users').')';
243
+            }
244
+        }
245
+        if (count($base_group_options) > 0) {
246
+            $create_subgroups_form = new FormValidator('create_subgroups', 'post', api_get_self().'?'.api_get_cidreq());
247 247
             $create_subgroups_form->addElement('header', get_lang('CreateSubgroups'));
248 248
             $create_subgroups_form->addElement('html', get_lang('CreateSubgroupsInfo'));
249
-			$create_subgroups_form->addElement('hidden', 'action');
250
-			$group_el = array();
251
-			$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
252
-			$group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
253
-			$group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
254
-			$group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
255
-			$group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
256
-			$create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false);
257
-			$defaults = array();
258
-			$defaults['action'] = 'create_subgroups';
259
-			$create_subgroups_form->setDefaults($defaults);
260
-			$create_subgroups_form->display();
261
-		}
262
-	}
249
+            $create_subgroups_form->addElement('hidden', 'action');
250
+            $group_el = array();
251
+            $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('CreateNumberOfGroups'));
252
+            $group_el[] = $create_subgroups_form->createElement('text', 'number_of_groups', null, array('size' => 3));
253
+            $group_el[] = $create_subgroups_form->createElement('static', null, null, get_lang('WithUsersFrom'));
254
+            $group_el[] = $create_subgroups_form->createElement('select', 'base_group', null, $base_group_options);
255
+            $group_el[] = $create_subgroups_form->createElement('button', 'submit', get_lang('Ok'));
256
+            $create_subgroups_form->addGroup($group_el, 'create_groups', null, ' ', false);
257
+            $defaults = array();
258
+            $defaults['action'] = 'create_subgroups';
259
+            $create_subgroups_form->setDefaults($defaults);
260
+            $create_subgroups_form->display();
261
+        }
262
+    }
263 263
 
264
-	/*
264
+    /*
265 265
 	 * Show form to generate groups from classes subscribed to the course
266 266
 	 */
267 267
     $options['where'] = array(" usergroup.course_id = ? " =>  api_get_real_course_id());
268 268
     $obj = new UserGroup();
269 269
     $classes = $obj->getUserGroupInCourse($options);
270
-	if (count($classes) > 0) {
271
-		echo '<b>'.get_lang('GroupsFromClasses').'</b>';
272
-		echo '<blockquote>';
273
-		echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
274
-		echo '<ul>';
275
-		foreach ($classes as $index => $class) {
276
-			$number_of_users = count($obj->get_users_by_usergroup($class['id']));
277
-			echo '<li>';
278
-			echo $class['name'];
279
-			echo ' ('.$number_of_users.' '.get_lang('Users').')';
280
-			echo '</li>';
281
-		}
282
-		echo '</ul>';
270
+    if (count($classes) > 0) {
271
+        echo '<b>'.get_lang('GroupsFromClasses').'</b>';
272
+        echo '<blockquote>';
273
+        echo '<p>'.get_lang('GroupsFromClassesInfo').'</p>';
274
+        echo '<ul>';
275
+        foreach ($classes as $index => $class) {
276
+            $number_of_users = count($obj->get_users_by_usergroup($class['id']));
277
+            echo '<li>';
278
+            echo $class['name'];
279
+            echo ' ('.$number_of_users.' '.get_lang('Users').')';
280
+            echo '</li>';
281
+        }
282
+        echo '</ul>';
283 283
 
284
-		$create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
285
-		$create_class_groups_form->addElement('hidden', 'action');
286
-		if (api_get_setting('allow_group_categories') == 'true') {
287
-			$group_categories = GroupManager :: get_categories();
288
-			$cat_options = array();
289
-			foreach ($group_categories as $index => $category) {
290
-				$cat_options[$category['id']] = $category['title'];
291
-			}
292
-			$create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
293
-		} else {
294
-			$create_class_groups_form->addElement('hidden', 'group_category');
295
-		}
296
-		$create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
297
-		$defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
298
-		$defaults['action'] = 'create_class_groups';
299
-		$create_class_groups_form->setDefaults($defaults);
300
-		$create_class_groups_form->display();
301
-		echo '</blockquote>';
302
-	}
284
+        $create_class_groups_form = new FormValidator('create_class_groups_form', 'post', api_get_self().'?'.api_get_cidreq());
285
+        $create_class_groups_form->addElement('hidden', 'action');
286
+        if (api_get_setting('allow_group_categories') == 'true') {
287
+            $group_categories = GroupManager :: get_categories();
288
+            $cat_options = array();
289
+            foreach ($group_categories as $index => $category) {
290
+                $cat_options[$category['id']] = $category['title'];
291
+            }
292
+            $create_class_groups_form->addElement('select', 'group_category', null, $cat_options);
293
+        } else {
294
+            $create_class_groups_form->addElement('hidden', 'group_category');
295
+        }
296
+        $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok'));
297
+        $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY;
298
+        $defaults['action'] = 'create_class_groups';
299
+        $create_class_groups_form->setDefaults($defaults);
300
+        $create_class_groups_form->display();
301
+        echo '</blockquote>';
302
+    }
303 303
 }
304 304
 
305 305
 Display :: display_footer();
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
         case 'create_groups':
25 25
             $groups = array();
26 26
 
27
-            for ($i = 0; $i < $_POST['number_of_groups']; $i ++) {
27
+            for ($i = 0; $i < $_POST['number_of_groups']; $i++) {
28 28
                 $group1['name'] = empty($_POST['group_'.$i.'_name']) ? get_lang('Group').' '.$i : $_POST['group_'.$i.'_name'];
29 29
                 $group1['category'] = isset($_POST['group_'.$i.'_category']) ? $_POST['group_'.$i.'_category'] : null;
30 30
                 $group1['tutor'] = isset($_POST['group_'.$i.'_tutor']) ? $_POST['group_'.$i.'_tutor'] : null;
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
 		$form->addGroup($group_el, 'groups', null, "</td><td>", false);
168 168
 		// Checkboxes
169 169
 		if ($_POST['number_of_groups'] > 1) {
170
-			$group_el = array ();
170
+			$group_el = array();
171 171
 			$group_el[] = $form->createElement('static', null, null, ' ');
172 172
 			if (api_get_setting('allow_group_categories') == 'true') {
173 173
 				$group_el[] = $form->createElement('checkbox', 'same_category', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('category');"));
174 174
 			}
175
-			$group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array ('onclick' => "javascript: switch_state('places');"));
175
+			$group_el[] = $form->createElement('checkbox', 'same_places', null, get_lang('SameForAll'), array('onclick' => "javascript: switch_state('places');"));
176 176
 			$form->addGroup($group_el, 'groups', null, '</td><td>', false);
177 177
 		}
178 178
 		// Properties for all groups
179
-		for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number ++) {
179
+		for ($group_number = 0; $group_number < $_POST['number_of_groups']; $group_number++) {
180 180
 			$group_el = array();
181 181
 			$group_el[] = $form->createElement('text', 'group_'.$group_number.'_name');
182 182
 			if (api_get_setting('allow_group_categories') == 'true') {
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 					$prev = '000';
201 201
 				} elseif ($group_id < 100) {
202 202
 					$prev = '00';
203
-				} elseif ($group_id<1000) {
203
+				} elseif ($group_id < 1000) {
204 204
 					$prev = '0';
205 205
 				} else {
206 206
 					$prev = '';
207 207
 				}
208 208
 			}
209 209
 
210
-			$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id ++;
210
+			$defaults['group_'.$group_number.'_name'] = get_lang('GroupSingle').' '.$prev.$group_id++;
211 211
 			$form->addGroup($group_el, 'group_'.$group_number, null, '</td><td>', false);
212 212
 		}
213 213
 		$defaults['action'] = 'create_groups';
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 
224 224
 	$create_groups_form = new FormValidator('create_groups', 'post', api_get_self().'?'.api_get_cidreq());
225 225
 	$create_groups_form->addElement('header', $nameTools);
226
-    $create_groups_form->addText('number_of_groups',get_lang('NumberOfGroupsToCreate'),null,array('value'=>'1'));
227
-    $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'),'plus','primary');
226
+    $create_groups_form->addText('number_of_groups', get_lang('NumberOfGroupsToCreate'), null, array('value'=>'1'));
227
+    $create_groups_form->addButton('submit', get_lang('ProceedToCreateGroup'), 'plus', 'primary');
228 228
 	$defaults = array();
229 229
 	$defaults['number_of_groups'] = 1;
230 230
 	$create_groups_form->setDefaults($defaults);
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	 * Show form to generate subgroups
235 235
 	 */
236 236
 	if (api_get_setting('allow_group_categories') == 'true' && count(GroupManager :: get_group_list()) > 0) {
237
-		$base_group_options = array ();
237
+		$base_group_options = array();
238 238
 		$groups = GroupManager :: get_group_list();
239 239
 		foreach ($groups as $index => $group) {
240 240
 			$number_of_students = GroupManager :: number_of_students($group['id']);
Please login to merge, or discard this patch.