start.php ➔ gcconnex_theme_init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * start.php
5
 *
6
 * GCconnex theme - includes all GCTools branding, links and language.
7
 *
8
 * @author Government of Canada
9
 */
10
11
elgg_register_event_handler('init', 'system', 'gcconnex_theme_init');
12
13
function gcconnex_theme_init()
14
{
15
	elgg_register_page_handler('hello', 'gcconnex_theme_page_handler');
16
	elgg_register_plugin_hook_handler('register', 'menu:site', 'career_menu_hander');
17
18
	//jobs.gc.ca menu link
19
	elgg_register_menu_item('subSite', array(
20
		'name' => 'jobs',
21
		'text' => elgg_echo('wet:jobs:link'),
22
		'href' => elgg_echo('wet:jobs:href'),
23
		'target' => '_blank',
24
	));
25
26
	//menu item for career dropdown
27
	elgg_register_menu_item('site', array(
28
			'name' => 'career',
29
			'href' => '#career_menu',
30
			'text' => elgg_echo('career') . '<span class="expicon glyphicon glyphicon-chevron-down"></span>'
31
	));
32
33
	// this will take care of the redirect only for groups
34
	elgg_register_plugin_hook_handler('route', 'all', 'group_content_routing_handler', 10);
35
}
36
37
// function that handles moving jobs marketplace and micro missions into drop down menu
38
function career_menu_hander($hook, $type, $menu, $params)
0 ignored issues
show
Best Practice introduced by
The function career_menu_hander() has been defined more than once; this definition is ignored, only the first definition in mod/gccollab_theme/start.php (L173-192) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
39
{
40
	if (!is_array($menu)) {
41
		return;
42
	}
43
44 View Code Duplication
	foreach ($menu as $key => $item) {
45
		if ($item->getName() === 'career') {
46
			if (elgg_is_active_plugin('missions')) {
47
				$item->addChild(elgg_get_menu_item('site', 'mission_main'));
48
			}
49
50
			//if (elgg_is_active_plugin('gcforums')) {
51
				//$item->addChild(elgg_get_menu_item('subSite', 'Forum'));
52
			//}
53
54
			$item->addChild(elgg_get_menu_item('subSite', 'jobs'));
55
			$item->setLinkClass('item');
56
		}
57
	}
58
}
59
60
/**
61
 * handler that takes care of the page routes (#1195)
62
 * redirects user (who do not have access to group content) to the group profile
63
 * @param string $hook
64
 * @param string $type
65
 * @param array $info
66
 */
67
function group_content_routing_handler($hook, $type, $info)
68
{
69
	global $CONFIG;
70
	$dbprefix = elgg_get_config('dbprefix');
71
	$entity_guid = (int)$info['segments'][1];
72
73
	$query = "SELECT guid, container_guid FROM {$dbprefix}entities WHERE guid = {$entity_guid} LIMIT 1";
74
	$entity_information = get_data($query);
75
76
	$group_guid = $entity_information[0]->container_guid;
77
	$group_entity = get_entity($group_guid);
78
79
	if ($group_entity instanceof ElggGroup && !(get_entity($entity_guid))) {
80
		register_error(elgg_echo('limited_access'));
81
		forward("groups/profile/{$group_guid}");
82
	}
83
}
84