This lets people who are not using sql_auth plugin still be able to do things and not worry about setting permissions.
Warning: Not using sql_auth will NOT let you configure user permissions. In other words, anyone you give access will have permission to do everything.
define('HOOKTYPE_USER_PERMISSION_LIST', 116);
define('HOOKTYPE_EDIT_USER', 117);
+
+
+
+define('HOOKTYPE_AUTH_MOD', 200);
/**
* Class for "Hook"
* This is the main function which gets called whenever you want to use a Hook.
*/
function current_user_can($permission) : bool
{
+ if (!is_auth_provided()) // if there is no auth plugin, assume the user handles logins themselves
+ return true;
$user = unreal_get_current_user();
if (!$user)
return false;
"IP WHOIS" => "tools/ip-whois.php",
],
"Settings" => [
- "Panel Access" => "settings",
"Plugins" => "settings/plugins.php",
],
- "News" => "news.php",
+ "News" => "news.php",
];
-$user = unreal_get_current_user();
-if ($user)
+
+if (is_auth_provided())
{
- /* Add logout page, if logged in */
- $pages["Logout"] = "login/?logout=true";
-}
+ $pages["Settings"]["Panel Access"] = "settings";
+ $user = unreal_get_current_user();
+ if ($user)
+ {
+ /* Add logout page, if logged in */
+ $pages["Logout"] = "login/?logout=true";
+ }
+}
Hook::run(HOOKTYPE_NAVBAR, $pages);
/* Example to add new menu item:
{
if (!Plugins::plugin_exists($name,$version))
die("Missing plugin: $name v$version");
+}
+
+
+
+/* I'm not a fan of globals */
+class AuthModLoaded
+{
+ public static $status = 0;
+}
+
+function is_auth_provided()
+{
+ return AuthModLoaded::$status;
}
\ No newline at end of file
Hook::func(HOOKTYPE_USER_DELETE, 'sql_auth::user_delete');
Hook::func(HOOKTYPE_EDIT_USER, 'sql_auth::edit_core');
Hook::func(HOOKTYPE_PRE_OVERVIEW_CARD, 'sql_auth::add_pre_overview_card');
+ AuthModLoaded::$status = 1;
if (defined('SQL_DEFAULT_USER')) // we've got a default account
{