Code Duplication    Length = 24-24 lines in 2 locations

security/Permission.php 2 locations

@@ 366-389 (lines=24) @@
363
	 * @param string Optional: The permission argument (e.g. a page ID).
364
	 * @returns Permission Returns the new permission object.
365
	 */
366
	public static function grant($groupID, $code, $arg = "any") {
367
		$perm = new Permission();
368
		$perm->GroupID = $groupID;
369
		$perm->Code = $code;
370
		$perm->Type = self::GRANT_PERMISSION;
371
372
		// Arg component
373
		switch($arg) {
374
			case "any":
375
				break;
376
			case "all":
377
				$perm->Arg = -1;
378
			default:
379
				if(is_numeric($arg)) {
380
					$perm->Arg = $arg;
381
				} else {
382
					user_error("Permission::checkMember: bad arg '$arg'",
383
										E_USER_ERROR);
384
				}
385
		}
386
387
		$perm->write();
388
		return $perm;
389
	}
390
391
392
	/**
@@ 400-423 (lines=24) @@
397
	 * @param string Optional: The permission argument (e.g. a page ID).
398
	 * @returns Permission Returns the new permission object.
399
	 */
400
	public static function deny($groupID, $code, $arg = "any") {
401
		$perm = new Permission();
402
		$perm->GroupID = $groupID;
403
		$perm->Code = $code;
404
		$perm->Type = self::DENY_PERMISSION;
405
406
		// Arg component
407
		switch($arg) {
408
			case "any":
409
				break;
410
			case "all":
411
				$perm->Arg = -1;
412
			default:
413
				if(is_numeric($arg)) {
414
					$perm->Arg = $arg;
415
				} else {
416
					user_error("Permission::checkMember: bad arg '$arg'",
417
										E_USER_ERROR);
418
				}
419
		}
420
421
		$perm->write();
422
		return $perm;
423
	}
424
425
	/**
426
	 * Returns all members for a specific permission.