Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
440 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
/*************************************************************************** | ||
* | ||
* OUGC Hide Administrator Location (/inc/plugins/ougcHideAdminLoc/admin.php) | ||
* Author: Omar Gonzalez | ||
* Copyright: © 2016 - 2023 Omar Gonzalez | ||
* | ||
* Website: https://ougc.network | ||
* | ||
* Hide administrator's location from the Who Is Online (WOL) list. | ||
* | ||
*************************************************************************** | ||
**************************************************************************** | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
****************************************************************************/ | ||
|
||
namespace OUGCHideAdminLoc\Admin; | ||
|
||
function pluginInfo() : array { | ||
global $lang; | ||
|
||
\OUGCHideAdminLoc\Core\loadLanguage(); | ||
|
||
return [ | ||
'name' => 'OUGC Hide Administrator Location', | ||
'description' => $lang->setting_group_ougc_hal_desc, | ||
'website' => 'https://ougc.network', | ||
'author' => 'Omar G.', | ||
'authorsite' => 'https://ougc.network', | ||
'version' => '1.8.33', | ||
'versioncode' => 1833, | ||
'compatibility' => '183*', | ||
'codename' => 'ougc_hal', | ||
'pl' => [ | ||
'version' => 13, | ||
'url' => 'http://community.mybb.com/mods.php?action=view&pid=573' | ||
] | ||
]; | ||
} | ||
|
||
function pluginActivate() : true { | ||
global $PL, $lang, $cache; | ||
|
||
\OUGCHideAdminLoc\Core\loadPluginLibrary(); | ||
|
||
// Add settings group | ||
$PL->settings('ougc_hal', $lang->setting_group_ougc_hal, $lang->setting_group_ougc_hal_desc, [ | ||
'uids' => [ | ||
'title' => $lang->setting_ougc_hal_uids, | ||
'description' => $lang->setting_ougc_hal_uids_descs, | ||
'optionscode' => 'text', | ||
'value' => '', | ||
], | ||
'gids' => [ | ||
'title' => $lang->setting_ougc_hal_gids, | ||
'description' => $lang->setting_ougc_hal_gids_desc, | ||
'optionscode' => 'groupselect', | ||
'value' => 4, | ||
] | ||
]); | ||
|
||
// Insert/update version into cache | ||
$plugins = (array) $cache->read('ougc_plugins'); | ||
|
||
if(!$plugins) { | ||
$plugins = []; | ||
} | ||
|
||
if(!isset($plugins['ougc_hal'])) { | ||
$plugins['ougc_hal'] = pluginInfo()['versioncode']; | ||
} | ||
|
||
/*~*~* RUN UPDATES START *~*~*/ | ||
|
||
/*~*~* RUN UPDATES END *~*~*/ | ||
|
||
$plugins['ougc_hal'] = pluginInfo()['versioncode']; | ||
|
||
$cache->update('ougc_plugins', $plugins); | ||
|
||
return true; | ||
} | ||
|
||
function pluginIsInstalled() : bool { | ||
global $cache; | ||
|
||
$plugins = $cache->read('ougc_plugins'); | ||
|
||
return isset($plugins['ougc_hal']); | ||
} | ||
|
||
function pluginUninstall() : true { | ||
global $db, $PL, $cache; | ||
|
||
\OUGCCoinbasePoints\Core\loadPluginLibrary(); | ||
|
||
$PL->settings_delete('ougc_hal'); | ||
|
||
// Delete version from cache | ||
$plugins = (array) $cache->read('ougc_plugins'); | ||
|
||
if(isset($plugins['ougc_hal'])) { | ||
unset($plugins['ougc_hal']); | ||
} | ||
|
||
if(!empty($plugins)) { | ||
$cache->update('ougc_plugins', $plugins); | ||
} | ||
else { | ||
$PL->cache_delete('ougc_plugins'); | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
<?php | ||
|
||
/*************************************************************************** | ||
* | ||
* OUGC Hide Administrator Location (/inc/plugins/ougcHideAdminLoc/core.php) | ||
* Author: Omar Gonzalez | ||
* Copyright: © 2016 - 2023 Omar Gonzalez | ||
* | ||
* Website: https://ougc.network | ||
* | ||
* Hide administrator's location from the Who Is Online (WOL) list. | ||
* | ||
*************************************************************************** | ||
**************************************************************************** | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
****************************************************************************/ | ||
|
||
namespace OUGCHideAdminLoc\Core; | ||
|
||
function loadLanguage() : true { | ||
global $lang; | ||
|
||
if(!isset($lang->setting_group_ougc_hal)) { | ||
$lang->load('ougc_hal'); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function pluginLibraryRequirements() : object { | ||
return (object) \OUGCHideAdminLoc\Admin\pluginInfo()['pl']; | ||
} | ||
|
||
function loadPluginLibrary(bool $doCheck = true) : bool { | ||
global $PL, $lang; | ||
|
||
loadLanguage(); | ||
|
||
if($fileExists = file_exists(PLUGINLIBRARY)) { | ||
($PL instanceof PluginLibrary) or require_once PLUGINLIBRARY; | ||
} | ||
|
||
if(!$doCheck) { | ||
return false; | ||
} | ||
|
||
if(!$fileExists || $PL->version < pluginLibraryRequirements()->version) { | ||
flash_message( | ||
$lang->sprintf( | ||
$lang->ougc_hal_pluginlibrary, | ||
pluginLibraryRequirements()->url, | ||
pluginLibraryRequirements()->version | ||
), | ||
'error' | ||
); | ||
|
||
admin_redirect('index.php?module=config-plugins'); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function addHooks(string $namespace) : true { | ||
global $plugins; | ||
|
||
$namespaceLowercase = strtolower($namespace); | ||
$definedUserFunctions = get_defined_functions()['user']; | ||
|
||
foreach($definedUserFunctions as $callable) { | ||
$namespaceWithPrefixLength = strlen($namespaceLowercase) + 1; | ||
|
||
if(substr($callable, 0, $namespaceWithPrefixLength) == $namespaceLowercase.'\\') { | ||
$hookName = substr_replace($callable, '', 0, $namespaceWithPrefixLength); | ||
|
||
$priority = substr($callable, -2); | ||
|
||
if(is_numeric(substr($hookName, -2))) { | ||
$hookName = substr($hookName, 0, -2); | ||
} | ||
else { | ||
$priority = 10; | ||
} | ||
|
||
$plugins->add_hook($hookName, $callable, $priority); | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function getSetting( string $settingKey = '') : string { | ||
global $mybb; | ||
|
||
$string = 'OUGC_HAL_'.strtoupper($settingKey); | ||
|
||
return defined($string) ? constant($string) : (string) $mybb->settings['ougc_hal_'.$settingKey]; | ||
} |
Oops, something went wrong.