Skip to content

Commit

Permalink
Rewrite for MyBB 1.8.33
Browse files Browse the repository at this point in the history
  • Loading branch information
Sama34 committed May 21, 2023
1 parent 36f9494 commit 255151c
Show file tree
Hide file tree
Showing 6 changed files with 440 additions and 236 deletions.
54 changes: 28 additions & 26 deletions Upload/inc/languages/english/admin/ougc_hal.lang.php
Expand Up @@ -2,40 +2,42 @@

/***************************************************************************
*
* OUGC Pages plugin (/inc/languages/english/admin/ougc_hal.lang.php)
* OUGC Hide Administrator Location plugin (/inc/languages/english/admin/ougc_hal.lang.php)
* Author: Omar Gonzalez
* Copyright: © 2016 - 2020 Omar Gonzalez
* Copyright: © 2016 - 2023 Omar Gonzalez
*
* Website: https://ougc.network
*
* Hide administrator's location at WOL list.
* 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.
****************************************************************************
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
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.
// Plugin API
$l['setting_group_ougc_hal'] = 'OUGC Hide Administrator Location';
$l['setting_group_ougc_hal_desc'] = 'Hide administrator\'s location at WOL list.';
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

// Settings
$l['setting_ougc_hal_uids'] = 'Hide Specific Users';
$l['setting_ougc_hal_uids_descs'] = 'Insert the UID of the users that you want to hide from the WOL list.';
$l['setting_ougc_hal_gids'] = 'Hide Specific Groups';
$l['setting_ougc_hal_gids_desc'] = 'Select the groups that you want to hide from the WOL list.';
$l = [
// Plugin API
'setting_group_ougc_hal' => 'OUGC Hide Administrator Location',
'setting_group_ougc_hal_desc' => 'Hide administrator\'s location from the Who Is Online (WOL) list.',

// PluginLibrary
$l['ougc_hal_pluginlibrary'] = 'This plugin requires <a href="{1}">PluginLibrary</a> version {2} or later to be uploaded to your forum. Please uplaod the required files.';
// Settings
'setting_ougc_hal_uids' => 'Hide Specific Users',
'setting_ougc_hal_uids_descs' => 'Insert the UID of the users that you want to hide from the Who Is Online (WOL) list.',
'setting_ougc_hal_gids' => 'Hide Specific Groups',
'setting_ougc_hal_gids_desc' => 'Select the groups that you want to hide from the Who Is Online (WOL) list.',

// PluginLibrary
'ougc_hal_pluginlibrary' => 'This plugin requires <a href="{1}">PluginLibrary</a> version {2} or later to be uploaded to your forum. Please upload the required files.',
];
54 changes: 28 additions & 26 deletions Upload/inc/languages/espanol/admin/ougc_hal.lang.php
Expand Up @@ -2,40 +2,42 @@

/***************************************************************************
*
* OUGC Pages plugin (/inc/languages/spanol/admin/ougc_hal.lang.php)
* OUGC Hide Administrator Location plugin (/inc/languages/spanol/admin/ougc_hal.lang.php)
* Author: Omar Gonzalez
* Copyright: © 2016 - 2020 Omar Gonzalez
* Copyright: © 2016 - 2023 Omar Gonzalez
*
* Website: https://ougc.network
*
* Hide administrator's location at WOL list.
* 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.
****************************************************************************
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.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
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.
// Plugin API
$l['setting_group_ougc_hal'] = 'OUGC Hide Administrator Location';
$l['setting_group_ougc_hal_desc'] = 'Oculta la ubicacion de los administradores de la lista WOL.';
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/

// Settings
$l['setting_ougc_hal_uids'] = 'Ocultar Usuarios Especificos';
$l['setting_ougc_hal_uids_descs'] = 'Escribe el UID de los usuarios que quieres ocultar del listado WOL.';
$l['setting_ougc_hal_gids'] = 'Ocultar Grupos Especificos';
$l['setting_ougc_hal_gids_desc'] = 'Selecciona a los grupos que quieres ocultar del listado WOL.';
$l = [
// Plugin API
'setting_group_ougc_hal' => 'OUGC Hide Administrator Location',
'setting_group_ougc_hal_desc' => 'Oculta la ubicacion de los administradores de la lista de Quien Esta en Linea.',

// PluginLibrary
$l['ougc_hal_pluginlibrary'] = 'Este plugin requiere <a href="{1}">PluginLibrary</a> version {2} para funcionar. Por favor sube los archivos necesarios.';
// Settings
'setting_ougc_hal_uids' => 'Ocultar Usuarios Especificos',
'setting_ougc_hal_uids_descs' => 'Escribe el UID de los usuarios que quieres ocultar del listado de Quien Esta en Linea.',
'setting_ougc_hal_gids' => 'Ocultar Grupos Especificos',
'setting_ougc_hal_gids_desc' => 'Selecciona a los grupos que quieres ocultar del listado de Quien Esta en Linea.',

// PluginLibrary
'ougc_hal_pluginlibrary' => 'Este plugin requiere <a href="{1}">PluginLibrary</a> version {2} para funcionar. Por favor sube los archivos necesarios.',
];
127 changes: 127 additions & 0 deletions Upload/inc/plugins/ougcHideAdminLoc/admin.php
@@ -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;
}
109 changes: 109 additions & 0 deletions Upload/inc/plugins/ougcHideAdminLoc/core.php
@@ -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];
}

0 comments on commit 255151c

Please sign in to comment.