forked from brandonkelly/module_nav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acc.module_nav.php
88 lines (73 loc) · 2.45 KB
/
acc.module_nav.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Module Tab Accessory Class for EE2
*
* @package Module Tab
* @author Brandon Kelly <[email protected]>
* @copyright Copyright (c) 2010 Pixel & Tonic, LLC
*/
class Module_nav_acc {
var $name = 'Module Tab';
var $id = 'module_tab';
var $version = '1.0';
var $description = 'Replaces the “Add-Ons” navigation menu with a “Modules” menu.';
var $sections = array();
/**
* Constructor
*/
function Module_nav_acc()
{
$this->EE =& get_instance();
}
// --------------------------------------------------------------------
/**
* Set Sections
*/
function set_sections()
{
if ($this->EE->session->userdata['can_access_modules'] == 'y')
{
$this->EE->cp->load_package_js('module_nav');
$this->EE->lang->loadfile('module_nav');
$lang = array(
'addons' => $this->EE->lang->line('nav_addons'),
'admin' => $this->EE->lang->line('nav_admin'),
'addon_administration' => $this->EE->lang->line('nav_addon_administration'),
'modules' => $this->EE->lang->line('nav_modules')
);
$group_id = $this->EE->session->userdata['group_id'];
if ($group_id == 1)
{
$query = $this->EE->db->query('SELECT module_name
FROM exp_modules
WHERE has_cp_backend = "y"
ORDER BY module_name');
}
else
{
$query = $this->EE->db->query('SELECT m.module_name
FROM exp_modules m, exp_module_member_groups mmg
WHERE m.module_id = mmg.module_id
AND mmg.group_id = '.$group_id.'
AND m.has_cp_backend = "y"
ORDER BY m.module_name');
}
$modules = array();
if ($query->num_rows())
{
foreach ($query->result_array() as $row)
{
$class = strtolower($row['module_name']);
$this->EE->lang->loadfile($class);
$name = $this->EE->lang->line($class.'_module_name');
$url = BASE.AMP.'C=addons_modules'.AMP.'M=show_module_cp'.AMP.'module='.$class;
$modules[] = array($name, $url);
}
}
$this->EE->cp->add_to_foot('<script type="text/javascript">initModuleNav('
. $this->EE->javascript->generate_json($lang, TRUE) . ', '
. $this->EE->javascript->generate_json($modules, TRUE)
. ');</script>');
}
}
}