This repository has been archived by the owner on Aug 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.php
executable file
·57 lines (49 loc) · 1.92 KB
/
init.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
<?php
/*
* Made by SirHyperNova
* NamelessMC version 2.0.0-pr3
*
* License: MIT
*
* File Manager Module
*/
// Ensure module has been installed
$cache->setCache('modulescache');
$module_installed = $cache->retrieve('FileManager');
if(!$module_installed){
// Update main admin group permissions
$group = $queries->getWhere('groups', array('id', '=', 2));
$group = $group[0];
$group_permissions = json_decode($group->permissions, TRUE);
$group_permissions['admincp.files'] = 1;
$group_permissions['files.view'] = 1;
$group_permissions['files.write'] = 1;
$group_permissions = json_encode($group_permissions);
$queries->update('groups', 2, array('permissions' => $group_permissions));
$cache->store('FileManager', 1);
} else {
// Installed
}
// Initialise FileManager languages
$fm_lang = new Language(ROOT_PATH.'/modules/FileManager/languages', LANGUAGE);
PermissionHandler::registerPermissions('Files', array(
'admincp.files' => $language->get('admin', 'admin_cp') . ' » ' . $fm_lang->get('files', 'name'),
'files.view' => $fm_lang->get('files','name') . ' » ' . $fm_lang->get('files','view'),
'files.write' => $fm_lang->get('files','name') . ' » ' . $fm_lang->get('files','write')
));
if($user->isLoggedIn()){
if($user->hasPermission('files.view') || $user->data()->id == 1) {
// Add link to navbar
$navigation->add('FileManager', $fm_lang->get('files', 'name'), URL::build('/files'));
// Define URLs which belong to this module
$pages->add('FileManager', '/files','pages/main/index.php');
$pages->add('FileManager', '/admin/files','pages/admin/index.php');
}
if($user->hasPermission('admincp.files') || $user->data()->id == 1){
if(!isset($admin_sidebar)) $admin_sidebar = array();
$admin_sidebar['files'] = array(
'title' => $fm_lang->get('files', 'name'),
'url' => URL::build('/admin/files')
);
}
}