Code Duplication    Length = 25-25 lines in 2 locations

engine/lib/deprecated-1.9.php 2 locations

@@ 298-322 (lines=25) @@
295
 * @throws InvalidClassException
296
 * @deprecated 1.9 Use \ElggGroup::addObjectToGroup()
297
 */
298
function add_object_to_group($group_guid, $object_guid) {
299
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup::addObjectToGroup()', 1.9);
300
	$group_guid = (int)$group_guid;
301
	$object_guid = (int)$object_guid;
302
303
	$group = get_entity($group_guid);
304
	$object = get_entity($object_guid);
305
306
	if ((!$group) || (!$object)) {
307
		return false;
308
	}
309
310
	if (!($group instanceof \ElggGroup)) {
311
		$msg = "GUID:" . $group_guid . " is not a valid " . '\ElggGroup';
312
		throw new \InvalidClassException($msg);
313
	}
314
315
	if (!($object instanceof \ElggObject)) {
316
		$msg = "GUID:" . $object_guid . " is not a valid " . '\ElggObject';
317
		throw new \InvalidClassException($msg);
318
	}
319
320
	$object->container_guid = $group_guid;
321
	return $object->save();
322
}
323
324
/**
325
 * Remove an object from the given group.
@@ 334-358 (lines=25) @@
331
 * @throws InvalidClassException
332
 * @deprecated 1.9 Use \ElggGroup::removeObjectFromGroup()
333
 */
334
function remove_object_from_group($group_guid, $object_guid) {
335
	elgg_deprecated_notice(__FUNCTION__ . ' is deprecated. Use \ElggGroup::removeObjectFromGroup()', 1.9);
336
	$group_guid = (int)$group_guid;
337
	$object_guid = (int)$object_guid;
338
339
	$group = get_entity($group_guid);
340
	$object = get_entity($object_guid);
341
342
	if ((!$group) || (!$object)) {
343
		return false;
344
	}
345
346
	if (!($group instanceof \ElggGroup)) {
347
		$msg = "GUID:" . $group_guid . " is not a valid " . '\ElggGroup';
348
		throw new \InvalidClassException($msg);
349
	}
350
351
	if (!($object instanceof \ElggObject)) {
352
		$msg = "GUID:" . $object_guid . " is not a valid " . '\ElggObject';
353
		throw new \InvalidClassException($msg);
354
	}
355
356
	$object->container_guid = $object->owner_guid;
357
	return $object->save();
358
}
359
360
/**
361
 * Return whether a given user is a member of the group or not.