Code Duplication    Length = 19-22 lines in 2 locations

mod/etherpad/start.php 1 location

@@ 276-294 (lines=19) @@
273
 * @param unknown_type $returnvalue
274
 * @param unknown_type $params
275
 */
276
function etherpad_container_permission_check($hook, $entity_type, $returnvalue, $params) {
277
278
	if (elgg_get_context() == "etherpad") {
279
		if( elgg_get_page_owner_guid() ){
280
			if( can_write_to_container(elgg_get_logged_in_user_guid(), elgg_get_page_owner_guid()) ) return true;
281
		}
282
		if( $page_guid = get_input('page_guid',0) ){
283
			$entity = get_entity($page_guid);
284
		} else if ($parent_guid = get_input('parent_guid',0)) {
285
			$entity = get_entity($parent_guid);
286
		}
287
		if ($entity instanceof ElggObject) {
288
			if( can_write_to_container(elgg_get_logged_in_user_guid(), $entity->container_guid) || in_array($entity->write_access_id, get_access_list()) ){
289
				return true;
290
			}
291
		}
292
	}
293
294
}
295

mod/tasks/start.php 1 location

@@ 434-455 (lines=22) @@
431
 * @param unknown_type $returnvalue
432
 * @param unknown_type $params
433
 */
434
function tasks_container_permission_check($hook, $entity_type, $returnvalue, $params) {
435
436
	if (elgg_get_context() == "tasks") {
437
		if (elgg_get_page_owner_guid()) {
438
			if (can_write_to_container(elgg_get_logged_in_user_guid(), elgg_get_page_owner_guid())) return true;
439
		}
440
		if ($task_guid = get_input('task_guid',0)) {
441
			$entity = get_entity($task_guid);
442
		} else if ($parent_guid = get_input('parent_guid',0)) {
443
			$entity = get_entity($parent_guid);
444
		}
445
		if ($entity instanceof ElggObject) {
446
			if (
447
					can_write_to_container(elgg_get_logged_in_user_guid(), $entity->container_guid)
448
					|| in_array($entity->write_access_id,get_access_list())
449
				) {
450
					return true;
451
			}
452
		}
453
	}
454
455
}
456
457
/**
458
 * Return views to parse for tasks.