Skip to content

Commit

Permalink
rename $mod_nav to $staffcp_nav, move groups to be near users
Browse files Browse the repository at this point in the history
because groups are closely related to users
  • Loading branch information
Derkades committed Oct 8, 2021
1 parent b2e6304 commit 36d4994
Show file tree
Hide file tree
Showing 84 changed files with 212 additions and 208 deletions.
2 changes: 1 addition & 1 deletion 403.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
require_once(ROOT_PATH . '/core/templates/frontend_init.php');

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets);

$page_load = microtime(true) - $start;
define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
Expand Down
2 changes: 1 addition & 1 deletion 404.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
require_once(ROOT_PATH . '/core/templates/frontend_init.php');

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets);

$page_load = microtime(true) - $start;
define(
Expand Down
2 changes: 1 addition & 1 deletion core/includes/tfa_signin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
);

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets);

$page_load = microtime(true) - $start;
define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
Expand Down
11 changes: 5 additions & 6 deletions core/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,16 @@
define('MINECRAFT', false);

// Navbar links
$navigation = new Navigation();
$cc_nav = new Navigation();
$mod_nav = new Navigation(true); // $mod_nav = panel nav
$navigation = new Navigation();
$cc_nav = new Navigation();
$staffcp_nav = new Navigation(true); // $staffcp_nav = panel nav

// Add links to cc_nav
$cc_nav->add('cc_overview', $language->get('user', 'overview'), URL::build('/user'));
$cc_nav->add('cc_alerts', $language->get('user', 'alerts'), URL::build('/user/alerts'));
$cc_nav->add('cc_messaging', $language->get('user', 'messaging'), URL::build('/user/messaging'));
$cc_nav->add('cc_settings', $language->get('user', 'profile_settings'), URL::build('/user/settings'));

// Placeholders enabled?
$placeholders_enabled = $configuration->get('Core', 'placeholders');
if($placeholders_enabled == 1) {
Expand Down Expand Up @@ -458,7 +458,7 @@

// Endpoints
$endpoints = new Endpoints();

// Announcements
$announcements = new Announcements($cache);

Expand Down Expand Up @@ -633,4 +633,3 @@
unset($_SESSION['password']);
}
}

6 changes: 3 additions & 3 deletions core/integration/run_mcassoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
'lastip' => htmlspecialchars($ip),
'last_online' => date('U')
));

$new_user = new User(DB::getInstance()->lastId());
// TODO: which group should they be set to?
// TODO: which group should they be set to?
// VALIDATED_DEFAULT
// PRE_VALIDATED_DEFAULT
$new_user->setGroup(1);
Expand All @@ -123,7 +123,7 @@
}

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets);

$page_load = microtime(true) - $start;
define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
Expand Down
4 changes: 2 additions & 2 deletions core/templates/panel_navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
$smarty->assign(array(
'SITE_NAME' => SITE_NAME,
'PANEL_INDEX' => URL::build('/panel'),
'NAV_LINKS' => $mod_nav->returnNav('top'),
'NAV_LINKS' => $staffcp_nav->returnNav('top'),
'VIEW_SITE' => $language->get('admin', 'view_site'),
'PAGE_LOAD_TIME' => PAGE_LOAD_TIME,
'SUPPORT' => $language->get('admin', 'support'),
'SOURCE' => $language->get('admin', 'source'),
'NOTICES' => Core_Module::getNotices(),
'NO_NOTICES' => $language->get('admin', 'no_notices'),
'MODE_TOGGLE' => $language->get('admin', 'mode_toggle')
));
));
2 changes: 1 addition & 1 deletion maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets);

$page_load = microtime(true) - $start;
define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
Expand Down
129 changes: 67 additions & 62 deletions modules/Core/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Core_Module extends Module {

/** @var Configuration */
private $_configuration;

private static $_dashboard_graph = array(), $_notices = array(), $_user_actions = array();

public function __construct($language, $pages, $user, $queries, $navigation, $cache, $endpoints){
Expand Down Expand Up @@ -321,7 +321,7 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart
PermissionHandler::registerPermissions($language->get('admin', 'administrator'), array(
'administrator' => $language->get('admin', 'administrator') . ' » ' . $language->get('admin', 'administrator_permission_info'),
));

// AdminCP
PermissionHandler::registerPermissions($language->get('moderator', 'staff_cp'), array(
'admincp.core' => $language->get('admin', 'core'),
Expand Down Expand Up @@ -880,23 +880,6 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart
}
}

if($user->hasPermission('admincp.groups')){
if(!$cache->isCached('groups_order')){
$order = 3;
$cache->store('groups_order', 3);
} else {
$order = $cache->retrieve('groups_order');
}

if(!$cache->isCached('groups_icon')){
$icon = '<i class="nav-icon fas fa-address-book"></i>';
$cache->store('group_icon', $icon);
} else
$icon = $cache->retrieve('group_icon');

$navs[2]->add('groups', $language->get('admin', 'groups'), URL::build('/panel/core/groups'), 'top', null, $order, $icon);
}

if ($user->hasPermission('admincp.core.announcements')) {
if (!$cache->isCached('announcements_order')) {
$order = 4;
Expand Down Expand Up @@ -1022,7 +1005,7 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart
} else {
$order = $cache->retrieve('pages_order');
}

if(!$cache->isCached('pages_icon')){
$icon = '<i class="nav-icon fas fa-file"></i>';
$cache->store('pages_icon', $icon);
Expand All @@ -1032,95 +1015,117 @@ public function onPageLoad(User $user, Pages $pages, Cache $cache, Smarty $smart
$navs[2]->add('custom_pages', $language->get('admin', 'custom_pages'), URL::build('/panel/core/pages'), 'top', null, $order, $icon);
}

if($user->hasPermission('admincp.security')){
if(!$cache->isCached('security_order')){
$order = 9;
$cache->store('security_order', 9);
} else {
$order = $cache->retrieve('security_order');
}

if(!$cache->isCached('security_icon')){
$icon = '<i class="nav-icon fas fa-lock"></i>';
$cache->store('security_icon', $icon);
} else
$icon = $cache->retrieve('security_icon');

$navs[2]->add('security', $language->get('admin', 'security'), URL::build('/panel/security'), 'top', null, $order, $icon);
}

if($user->hasPermission('admincp.update')){
if(!$cache->isCached('update_order')){
$order = 10;
$cache->store('update_order', 10);
if ($user->hasPermission('admincp.groups')){
if(!$cache->isCached('groups_order')){
$order = 3;
$cache->store('groups_order', 3);
} else {
$order = $cache->retrieve('update_order');
$order = $cache->retrieve('groups_order');
}

if(!$cache->isCached('update_icon')){
$icon = '<i class="nav-icon fas fa-download"></i>';
$cache->store('update_icon', $icon);
if(!$cache->isCached('groups_icon')){
$icon = '<i class="nav-icon fas fa-address-book"></i>';
$cache->store('group_icon', $icon);
} else
$icon = $cache->retrieve('update_icon');
$icon = $cache->retrieve('group_icon');

$navs[2]->add('update', $language->get('admin', 'update'), URL::build('/panel/update'), 'top', null, $order, $icon);
$navs[2]->add('groups', $language->get('admin', 'groups'), URL::build('/panel/core/groups'), 'top', null, $order, $icon);
}

if($user->hasPermission('admincp.users')){
if(!$cache->isCached('users_order')){
if ($user->hasPermission('admincp.users')) {
if (!$cache->isCached('users_order')) {
$order = 11;
$cache->store('users_order', 11);
} else {
$order = $cache->retrieve('users_order');
}

if(!$cache->isCached('users_icon')){
if (!$cache->isCached('users_icon')) {
$icon = '<i class="nav-icon fas fa-user-circle"></i>';
$cache->store('users_icon', $icon);
} else
} else {
$icon = $cache->retrieve('users_icon');
}

$navs[2]->addDropdown('users', $language->get('admin', 'user_management'), 'top', $order, $icon);

if(!$cache->isCached('user_icon')){
if (!$cache->isCached('user_icon')) {
$icon = '<i class="nav-icon fas fa-users"></i>';
$cache->store('user_icon', $icon);
} else
} else {
$icon = $cache->retrieve('user_icon');
}

$navs[2]->addItemToDropdown('users', 'users', $language->get('admin', 'users'), URL::build('/panel/users'), 'top', null, $icon, $order);

if($user->hasPermission('modcp.ip_lookup')){
if(!$cache->isCached('ip_lookup_icon')){
if ($user->hasPermission('modcp.ip_lookup')) {
if (!$cache->isCached('ip_lookup_icon')) {
$icon = '<i class="nav-icon fas fa-binoculars"></i>';
$cache->store('ip_lookup_icon', $icon);
} else
} else {
$icon = $cache->retrieve('ip_lookup_icon');
}

$navs[2]->addItemToDropdown('users', 'ip_lookup', $language->get('moderator', 'ip_lookup'), URL::build('/panel/users/ip_lookup'), 'top', null, $icon, $order);
}

if($user->hasPermission('modcp.punishments')){
if(!$cache->isCached('punishments_icon')){
if ($user->hasPermission('modcp.punishments')) {
if (!$cache->isCached('punishments_icon')) {
$icon = '<i class="nav-icon fas fa-gavel"></i>';
$cache->store('punishments_icon', $icon);
} else
} else {
$icon = $cache->retrieve('punishments_icon');
}

$navs[2]->addItemToDropdown('users', 'punishments', $language->get('moderator', 'punishments'), URL::build('/panel/users/punishments'), 'top', null, $icon, $order);
}

if($user->hasPermission('modcp.reports')){
if(!$cache->isCached('reports_icon')){
if ($user->hasPermission('modcp.reports')) {
if (!$cache->isCached('reports_icon')) {
$icon = '<i class="nav-icon fas fa-exclamation-triangle"></i>';
$cache->store('reports_icon', $icon);
} else
} else {
$icon = $cache->retrieve('reports_icon');
}

$navs[2]->addItemToDropdown('users', 'reports', $language->get('moderator', 'reports'), URL::build('/panel/users/reports'), 'top', null, $icon, $order);
}
}

if ($user->hasPermission('admincp.security')) {
if(!$cache->isCached('security_order')){
$order = 9;
$cache->store('security_order', 9);
} else {
$order = $cache->retrieve('security_order');
}

if(!$cache->isCached('security_icon')){
$icon = '<i class="nav-icon fas fa-lock"></i>';
$cache->store('security_icon', $icon);
} else
$icon = $cache->retrieve('security_icon');

$navs[2]->add('security', $language->get('admin', 'security'), URL::build('/panel/security'), 'top', null, $order, $icon);
}

if ($user->hasPermission('admincp.update')) {
if(!$cache->isCached('update_order')){
$order = 10;
$cache->store('update_order', 10);
} else {
$order = $cache->retrieve('update_order');
}

if(!$cache->isCached('update_icon')){
$icon = '<i class="nav-icon fas fa-download"></i>';
$cache->store('update_icon', $icon);
} else
$icon = $cache->retrieve('update_icon');

$navs[2]->add('update', $language->get('admin', 'update'), URL::build('/panel/update'), 'top', null, $order, $icon);
}

// Notices
$cache->setCache('notices_cache');

Expand Down
6 changes: 3 additions & 3 deletions modules/Core/pages/api/v2/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
require_once(ROOT_PATH . '/core/templates/frontend_init.php');

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets);

// Ensure API is actually enabled
if (!Util::getSetting(DB::getInstance(), 'use_api')) {
Expand Down Expand Up @@ -83,9 +83,9 @@ public function __construct(string $route, Language $api_language, Endpoints $en

/**
* Validate provided API key to make sure it matches.
*
*
* @param string $api_key API key to check.
*
*
* @return bool Whether it matches or not.
*/
private function validateKey(string $api_key = null): bool {
Expand Down
4 changes: 2 additions & 2 deletions modules/Core/pages/authme_connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
}

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets, $template);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets, $template);

$page_load = microtime(true) - $start;
define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
Expand All @@ -409,4 +409,4 @@
require(ROOT_PATH . '/core/templates/navbar.php');
require(ROOT_PATH . '/core/templates/footer.php');

$template->displayTemplate($template_file, $smarty);
$template->displayTemplate($template_file, $smarty);
2 changes: 1 addition & 1 deletion modules/Core/pages/complete_signup.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
require_once(ROOT_PATH . '/core/templates/frontend_init.php');

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets, $template);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets, $template);

// Validate code
if(!isset($_GET['c'])){
Expand Down
4 changes: 2 additions & 2 deletions modules/Core/pages/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
$headers = 'From: ' . $siteemail . "\r\n" .
'Reply-To: ' . $fromemail . "\r\n" .
'X-Mailer: PHP/' . phpversion() . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=UTF-8' . "\r\n";

$email = array(
Expand Down Expand Up @@ -177,7 +177,7 @@
));

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets, $template);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets, $template);

$page_load = microtime(true) - $start;
define('PAGE_LOAD_TIME', str_replace('{x}', round($page_load, 3), $language->get('general', 'page_loaded_in')));
Expand Down
2 changes: 1 addition & 1 deletion modules/Core/pages/custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
require_once(ROOT_PATH . '/core/templates/frontend_init.php');

// Load modules + template
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $mod_nav), $widgets, $template);
Module::loadPage($user, $pages, $cache, $smarty, array($navigation, $cc_nav, $staffcp_nav), $widgets, $template);

$smarty->assign(array(
'WIDGETS_LEFT' => $widgets->getWidgets('left'),
Expand Down
Loading

0 comments on commit 36d4994

Please sign in to comment.