Projet

Général

Profil

« Précédent | Suivant » 

Révision 4c291f4c

Ajouté par Renato Botelho il y a plus de 9 ans

Fix indent and whitespaces

Voir les différences:

usr/local/www/system_groupmanager.php
1
<?php 
1
<?php
2 2
/*
3
	$Id: system_groupmanager.php 
3
	$Id: system_groupmanager.php
4 4
	part of m0n0wall (http://m0n0.ch/wall)
5 5

  
6 6
	Copyright (C) 2008 Shrew Soft Inc.
7
	All rights reserved. 
7
	All rights reserved.
8 8

  
9 9
	Copyright (C) 2005 Paul Taylor <paultaylor@winn-dixie.com>.
10
	All rights reserved. 
10
	All rights reserved.
11 11

  
12 12
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
13 13
	All rights reserved.
14
	
14

  
15 15
	Redistribution and use in source and binary forms, with or without
16 16
	modification, are permitted provided that the following conditions are met:
17
	
17

  
18 18
	1. Redistributions of source code must retain the above copyright notice,
19 19
	   this list of conditions and the following disclaimer.
20
	
20

  
21 21
	2. Redistributions in binary form must reproduce the above copyright
22 22
	   notice, this list of conditions and the following disclaimer in the
23 23
	   documentation and/or other materials provided with the distribution.
24
	
24

  
25 25
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
26 26
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
27 27
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
......
117 117
	/* input validation */
118 118
	$reqdfields = explode(" ", "groupname");
119 119
	$reqdfieldsn = array(gettext("Group Name"));
120
	
120

  
121 121
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
122
	
122

  
123 123
	if (preg_match("/[^a-zA-Z0-9\.\-_ ]/", $_POST['groupname']))
124 124
		$input_errors[] = gettext("The group name contains invalid characters.");
125
	
125

  
126 126
	if (strlen($_POST['groupname']) > 16)
127 127
		$input_errors[] = gettext("The group name is longer than 16 characters.");
128
	
128

  
129 129
	if (!$input_errors && !(isset($id) && $a_group[$id])) {
130 130
		/* make sure there are no dupes */
131 131
		foreach ($a_group as $group) {
......
135 135
			}
136 136
		}
137 137
	}
138
	
138

  
139 139
	if (!$input_errors) {
140 140
		$group = array();
141 141
		if (isset($id) && $a_group[$id])
142 142
			$group = $a_group[$id];
143
		
143

  
144 144
		$group['name'] = $_POST['groupname'];
145 145
		$group['description'] = $_POST['description'];
146 146

  
......
170 170
		}
171 171

  
172 172
		write_config();
173
		
173

  
174 174
		header("Location: system_groupmanager.php");
175 175
		exit;
176 176
	}
......
248 248
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="group manager">
249 249
	<tr>
250 250
		<td>
251
			<?php 
252
				$tab_array = array();
253
				$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
254
				$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
255
				$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
256
				$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
257
				display_top_tabs($tab_array);
258
			?>
251
<?php
252
			$tab_array = array();
253
			$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
254
			$tab_array[] = array(gettext("Groups"), true, "system_groupmanager.php");
255
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
256
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
257
			display_top_tabs($tab_array);
258
?>
259 259
		</td>
260
	</tr>    
260
	</tr>
261 261
	<tr>
262 262
		<td id="mainarea">
263 263
			<div class="tabcont">
264 264

  
265
				<?php if($_GET['act']=="new" || $_GET['act']=="edit"): ?>
266

  
265
<?php
266
			if($_GET['act']=="new" || $_GET['act']=="edit"):
267
?>
267 268
				<form action="system_groupmanager.php" method="post" name="iform" id="iform" onsubmit="presubmit()">
268 269
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
269
	                    <?php
270
	                        $ro = "";
271
	                        if ($pconfig['gtype'] == "system")
272
	                            $ro = "readonly=\"readonly\"";
273
	                    ?>
270
<?php
271
						$ro = "";
272
						if ($pconfig['gtype'] == "system")
273
							$ro = "readonly=\"readonly\"";
274
?>
274 275
						<tr>
275 276
							<td width="22%" valign="top" class="vncell"><?=gettext("Defined by");?></td>
276 277
							<td width="78%" class="vtable">
......
278 279
								<input name="gtype" type="hidden" value="<?=htmlspecialchars($pconfig['gtype'])?>"/>
279 280
							</td>
280 281
						</tr>
281
						<tr> 
282
						<tr>
282 283
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Group name");?></td>
283
							<td width="78%" class="vtable"> 
284
							<td width="78%" class="vtable">
284 285
								<input name="groupname" type="text" class="formfld group" id="groupname" size="20" maxlength="16" value="<?=htmlspecialchars($pconfig['name']);?>" <?=$ro;?> />
285 286
							</td>
286 287
						</tr>
287
						<tr> 
288
						<tr>
288 289
							<td width="22%" valign="top" class="vncell"><?=gettext("Description");?></td>
289
							<td width="78%" class="vtable"> 
290
							<td width="78%" class="vtable">
290 291
								<input name="description" type="text" class="formfld unknown" id="description" size="20" value="<?=htmlspecialchars($pconfig['description']);?>" />
291 292
								<br />
292 293
								<?=gettext("Group description, for your own information only");?>
293 294
							</td>
294 295
						</tr>
295

  
296
						<?php if ($pconfig['gid'] != 1998): // all users group ?>
297

  
296
<?php
297
					if ($pconfig['gid'] != 1998): // all users group
298
?>
298 299
						<tr>
299 300
							<td width="22%" valign="top" class="vncell"><?=gettext("Group Memberships");?></td>
300 301
							<td width="78%" class="vtable" align="center">
......
304 305
											<strong><?=gettext("Not Members");?></strong><br />
305 306
											<br />
306 307
												<select size="10" style="width: 75%" name="notmembers[]" class="formselect" id="notmembers" onchange="clear_selected('members')" multiple="multiple">
307
												<?php
308
													$rowIndex = 0;
309
													foreach ($config['system']['user'] as $user):
310
														if (is_array($pconfig['members']) && in_array($user['uid'],$pconfig['members']))
311
															continue;
312
														$rowIndex++;
313
												?>
308
<?php
309
											$rowIndex = 0;
310
											foreach ($config['system']['user'] as $user):
311
												if (is_array($pconfig['members']) && in_array($user['uid'],$pconfig['members']))
312
													continue;
313
												$rowIndex++;
314
?>
314 315
												<option value="<?=$user['uid'];?>" <?=$selected;?>>
315 316
													<?=htmlspecialchars($user['name']);?>
316 317
												</option>
317
												<?php endforeach;
318
												if ($rowIndex == 0)
319
													echo "<option></option>";
320
												?>
318
<?php
319
											endforeach;
320
											if ($rowIndex == 0)
321
												echo "<option></option>";
322
?>
321 323
											</select>
322 324
											<br />
323 325
										</td>
......
335 337
											<strong><?=gettext("Members");?></strong><br />
336 338
											<br />
337 339
											<select size="10" style="width: 75%" name="members[]" class="formselect" id="members" onchange="clear_selected('notmembers')" multiple="multiple">
338
												<?php
339
													$rowIndex = 0;
340
													foreach ($config['system']['user'] as $user):
341
														if (!(is_array($pconfig['members']) && in_array($user['uid'],$pconfig['members'])))
342
															continue;
343
														$rowIndex++;
344
												?>
340
<?php
341
											$rowIndex = 0;
342
											foreach ($config['system']['user'] as $user):
343
												if (!(is_array($pconfig['members']) && in_array($user['uid'],$pconfig['members'])))
344
													continue;
345
												$rowIndex++;
346
?>
345 347
												<option value="<?=$user['uid'];?>">
346 348
													<?=htmlspecialchars($user['name']);?>
347 349
												</option>
348
												<?php endforeach;
349
												if ($rowIndex == 0)
350
													echo "<option></option>";
351
												?>
350
<?php
351
											endforeach;
352
											if ($rowIndex == 0)
353
												echo "<option></option>";
354
?>
352 355
											</select>
353 356
											<br />
354 357
										</td>
......
357 360
								<?=gettext("Hold down CTRL (pc)/COMMAND (mac) key to select multiple items");?>
358 361
							</td>
359 362
						</tr>
360

  
361
						<?php endif; ?>
362
						<?php if($_GET['act'] != "new"): ?>
363
						
363
<?php
364
					endif;
365
					if($_GET['act'] != "new"):
366
?>
364 367
						<tr>
365 368
							<td width="22%" valign="top" class="vncell"><?=gettext("Assigned Privileges");?></td>
366 369
							<td width="78%" class="vtable">
......
370 373
										<td width="60%" class="listhdrr"><?=gettext("Description");?></td>
371 374
										<td class="list"></td>
372 375
									</tr>
373
									<?php
374
										if(is_array($pconfig['priv'])):
375
											$i = 0;
376
											foreach ($pconfig['priv'] as $priv):
377
									?>
376
<?php
377
							if(is_array($pconfig['priv'])):
378
								$i = 0;
379
								foreach ($pconfig['priv'] as $priv):
380
?>
378 381
									<tr>
379 382
										<td class="listr">
380 383
											<?=htmlspecialchars($priv_list[$priv]['name']);?>
......
388 391
											</a>
389 392
										</td>
390 393
									</tr>
391
									<?php
392
											$i++;
393
	                      					endforeach;
394
										endif;
395
									?>
394
<?php
395
									$i++;
396
								endforeach;
397
							endif;
398
?>
396 399
									<tr>
397 400
										<td class="list" colspan="2"></td>
398 401
										<td class="list">
......
406 409
								</table>
407 410
							</td>
408 411
						</tr>
409
						<?php endif; ?>
410
						<tr> 
412
<?php
413
					endif;
414
?>
415
						<tr>
411 416
							<td width="22%" valign="top">&nbsp;</td>
412
							<td width="78%"> 
417
							<td width="78%">
413 418
								<input name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
414 419
								<?php if (isset($id) && $a_group[$id]): ?>
415 420
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
......
419 424
						</tr>
420 425
					</table>
421 426
				</form>
422

  
423
				<?php else: ?>
424

  
427
<?php
428
			else:
429
?>
425 430
				<table class="sortable" width="100%" border="0" cellpadding="0" cellspacing="0" summary="">
426 431
					<thead>
427 432
						<tr>
......
432 437
						</tr>
433 438
					</thead>
434 439
					<tfoot>
435
						<tr> 
440
						<tr>
436 441
							<td class="list" colspan="3"></td>
437 442
							<td class="list">
438 443
								<a href="system_groupmanager.php?act=new"><img src="./themes/<?=$g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add group");?>" width="17" height="17" border="0" alt="add" />
......
442 447
						<tr>
443 448
							<td colspan="3">
444 449
								<p>
445
									<?=gettext("Additional webConfigurator groups can be added here. 
450
									<?=gettext("Additional webConfigurator groups can be added here.
446 451
									Group permissions can be assigned which are inherited by users who are members of the group.
447 452
									An icon that appears grey indicates that it is a system defined object.
448 453
									Some system object properties can be modified but they cannot be deleted.");?>
......
451 456
						</tr>
452 457
					</tfoot>
453 458
					<tbody>
454
						<?php
455
							$i = 0;
456
							foreach($a_group as $group):
457

  
458
								if($group['scope'] == "system")
459
									$grpimg = "/themes/{$g['theme']}/images/icons/icon_system-group-grey.png";
460
								else
461
									$grpimg = "/themes/{$g['theme']}/images/icons/icon_system-group.png";
462
								$groupcount = count($group['member']);
463
								if ($group["name"] == "all")
464
									$groupcount = count($config['system']['user']);
465
						?>
459
<?php
460
					$i = 0;
461
					foreach($a_group as $group):
462
						if($group['scope'] == "system")
463
							$grpimg = "/themes/{$g['theme']}/images/icons/icon_system-group-grey.png";
464
						else
465
							$grpimg = "/themes/{$g['theme']}/images/icons/icon_system-group.png";
466
						$groupcount = count($group['member']);
467
						if ($group["name"] == "all")
468
							$groupcount = count($config['system']['user']);
469
?>
466 470
						<tr ondblclick="document.location='system_groupmanager.php?act=edit&amp;id=<?=$i;?>'">
467 471
							<td class="listlr">
468 472
								<table border="0" cellpadding="0" cellspacing="0" summary="">
......
487 491
									<img src="./themes/<?=$g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit group");?>" width="17" height="17" border="0" alt="edit" />
488 492
								</a>
489 493
								&nbsp;
490
								<?php if($group['scope'] != "system"): ?>
494
<?php
495
							if($group['scope'] != "system"):
496
?>
491 497
								<a href="system_groupmanager.php?act=delgroup&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this group?"); ?>')">
492 498
									<img src="/themes/<?=$g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete group"); ?>" width="17" height="17" border="0" alt="delete" />
493 499
								</a>
494
								<?php endif; ?>
500
<?php
501
							endif;
502
?>
495 503
							</td>
496 504
						</tr>
497
						<?php
498
							$i++;
499
							endforeach;
500
						?>
505
<?php
506
						$i++;
507
					endforeach;
508
?>
501 509
					</tbody>
502 510
				</table>
503
			
504
				<?php endif; ?>
505

  
506
			</div>     
511
<?php
512
			endif;
513
?>
514
			</div>
507 515
		</td>
508 516
	</tr>
509 517
</table>

Formats disponibles : Unified diff