From d284cdb982a05857ea62e5cde6ba85aa0a928e7b Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Thu, 27 Aug 2026 14:58:47 -0500 Subject: [PATCH] Qualify every reference to a FOG core class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plugins are global-namespace by design (fogproject ADR 0009) and have always named core classes bare -- `extends Hook`, `Route::listem()`, `new Image()`. That works only because every file under fogproject's packages/web/src/ ends in a class_alias() re-exporting itself into the global namespace, and that alias set is being retired (fogproject ADR 0013 §2, docs/composer-psr4-plan.md). A bare name resolves to nothing once it goes. 574 references across 163 files now carry their namespace. The plugins stay global -- only the names they reach into core with have changed. ADR 0009 requires this to ship BEFORE the core change that deletes the aliases: downloadplugins() runs before configureHttpd(), so a server is never serving a core without aliases against plugins that still need them. bin/qualify-core-references.php does the rewrite. It reads the map from a fogproject checkout rather than carrying a copy, because which bucket a class lives in is fogproject's to decide and a stale list here would rewrite names to somewhere they are not. Tokenised, never regex, so a name in a docblock or a string is left alone and `$obj->Route` is not mistaken for a class. Three sources feed that map, and the first cut used only the first: src/ PSR-4, so the path is the name lib/ the 46 discovery-named classes, flat FOG namespace -- eight plugin reports extend FOG\ReportManagement commons/ Initiator, genuinely global and staying that way; qualifying it is just a leading backslash Two rounds of the sweep were wrong before this was right, and the gates caught both rather than review doing it: - The tool built its "classes this tree declares" set from the whole tree, including tests/stubs, which declares doubles NAMED FOGController, FOGManagerController and Schema. Every reference to those three therefore looked like a plugin's own class and was skipped -- 313 rewritten, ~90 silently left. The strict stubs failed the suite immediately. - Initiator and ReportManagement are not under src/ at all, so the src-only map could not see them. The self-contained test found all 18. tests/stubs/fog-stubs.php now declares its doubles in the namespaces core declares them in, and deliberately NOT also under their bare global names. That is what makes the plugin tests a gate for this: a file still saying `extends FOGController` fails to load exactly as it would on a real server. The stub's own `Schema::createTable()` needed qualifying too -- it sits in FOG\Base and Schema is in FOG\Items. tests/core-references-are-qualified.test.php is the standing gate, and it carries no copy of core's class list: the invariant is that a name this tree does not declare and PHP does not have must be qualified. That needs no fogproject checkout, which matters because CI has none. Mutation-confirmed -- reverting one `extends \FOG\Base\Hook` names that file and line. It handles both tokenizer shapes, since PHP 8 folds a qualified name into one T_NAME_FULLY_QUALIFIED token and 7.4 does not, and CI runs both. Suite: 10 passed, 0 failed. Co-Authored-By: Claude --- bin/qualify-core-references.php | 204 +++++++++++++++++ capone/class/capone.class.php | 2 +- capone/class/caponemanager.class.php | 8 +- capone/hooks/addbootmenuitem.hook.php | 2 +- capone/hooks/addcaponeapi.hook.php | 2 +- capone/hooks/addcaponejs.hook.php | 2 +- capone/hooks/addcaponemenuitem.hook.php | 2 +- capone/pages/caponemanagement.page.php | 14 +- capone/reg-task/caponetasking.class.php | 6 +- helloworld/class/helloworld.class.php | 2 +- helloworld/class/helloworldmanager.class.php | 4 +- helloworld/hooks/addhelloworldapi.hook.php | 2 +- helloworld/hooks/addhelloworldjs.hook.php | 2 +- .../hooks/addhelloworldmenuitem.hook.php | 2 +- .../pages/helloworldmanagement.page.php | 2 +- helloworld/tasks/helloworldheartbeat.task.php | 4 +- ldap/class/ldap.class.php | 8 +- ldap/class/ldapgroup.class.php | 14 +- ldap/class/ldapgroupmanager.class.php | 2 +- ldap/class/ldapgrouproleassociation.class.php | 2 +- .../ldapgrouproleassociationmanager.class.php | 2 +- .../ldapgroupusergroupassociation.class.php | 2 +- ...groupusergroupassociationmanager.class.php | 2 +- ldap/class/ldapmanager.class.php | 16 +- ldap/class/ldapusergrant.class.php | 2 +- ldap/class/ldapusergrantmanager.class.php | 2 +- ldap/hooks/addldapapi.hook.php | 2 +- ldap/hooks/addldapgrouptabs.hook.php | 24 +- ldap/hooks/addldapjs.hook.php | 2 +- ldap/hooks/addldapmenuitem.hook.php | 2 +- ldap/hooks/addldaptype.hook.php | 2 +- ldap/hooks/ldapdeletemassitems.hook.php | 2 +- ldap/hooks/ldappluginhook.hook.php | 6 +- ldap/pages/ldapgroupmanagement.page.php | 8 +- ldap/pages/ldapmanagement.page.php | 32 +-- ldap/reports/ldap_report.report.php | 8 +- location/class/location.class.php | 4 +- location/class/locationassociation.class.php | 2 +- .../locationassociationmanager.class.php | 2 +- location/class/locationmanager.class.php | 12 +- location/hooks/addlocationapi.hook.php | 36 +-- location/hooks/addlocationgroup.hook.php | 26 +-- location/hooks/addlocationhost.hook.php | 26 +-- location/hooks/addlocationimport.hook.php | 12 +- location/hooks/addlocationjs.hook.php | 2 +- location/hooks/addlocationmenuitem.hook.php | 2 +- location/hooks/addlocationtype.hook.php | 2 +- .../hooks/addserviceconfiguration.hook.php | 6 +- location/hooks/locationchangeitems.hook.php | 18 +- .../hooks/locationdeletemassitems.hook.php | 2 +- location/pages/locationmanagement.page.php | 10 +- location/reports/location_report.report.php | 8 +- ntfy/class/ntfy.class.php | 2 +- ntfy/class/ntfyextends.class.php | 4 +- ntfy/class/ntfymanager.class.php | 4 +- ntfy/hooks/addntfyapi.hook.php | 2 +- ntfy/hooks/addntfyjs.hook.php | 2 +- ntfy/hooks/addntfymenuitem.hook.php | 2 +- ntfy/pages/ntfymanagement.page.php | 2 +- oidc/class/oidc.class.php | 2 +- oidc/class/oidcflow.class.php | 14 +- oidc/class/oidcgroup.class.php | 14 +- oidc/class/oidcgroupmanager.class.php | 2 +- oidc/class/oidcgrouproleassociation.class.php | 2 +- .../oidcgrouproleassociationmanager.class.php | 2 +- .../oidcgroupusergroupassociation.class.php | 2 +- ...groupusergroupassociationmanager.class.php | 2 +- oidc/class/oidcidentity.class.php | 2 +- oidc/class/oidcidentitymanager.class.php | 4 +- oidc/class/oidcmanager.class.php | 6 +- oidc/class/oidcusergrant.class.php | 2 +- oidc/class/oidcusergrantmanager.class.php | 2 +- oidc/hooks/addoidcapi.hook.php | 2 +- oidc/hooks/addoidcgrouptabs.hook.php | 24 +- oidc/hooks/addoidcjs.hook.php | 2 +- oidc/hooks/addoidcmenuitem.hook.php | 2 +- oidc/hooks/addoidcroutes.hook.php | 4 +- oidc/hooks/oidcdeletemassitems.hook.php | 2 +- oidc/hooks/oidcloginredirect.hook.php | 2 +- oidc/hooks/oidclogout.hook.php | 2 +- oidc/pages/oidcgroupmanagement.page.php | 8 +- oidc/pages/oidcmanagement.page.php | 4 +- ou/class/ou.class.php | 4 +- ou/class/ouassociation.class.php | 2 +- ou/class/ouassociationmanager.class.php | 2 +- ou/class/oumanager.class.php | 4 +- ou/hooks/addouapi.hook.php | 2 +- ou/hooks/addougroup.hook.php | 24 +- ou/hooks/addouhost.hook.php | 26 +-- ou/hooks/addoujs.hook.php | 2 +- ou/hooks/addoumenuitem.hook.php | 2 +- ou/hooks/addoutype.hook.php | 2 +- ou/hooks/ouchangeitems.hook.php | 4 +- ou/hooks/oudeletemassitems.hook.php | 2 +- ou/pages/oumanagement.page.php | 2 +- ou/reports/ou_report.report.php | 8 +- .../class/persistentgroups.class.php | 2 +- .../class/persistentgroupsmanager.class.php | 4 +- pushbullet/class/pushbullet.class.php | 2 +- pushbullet/class/pushbulletextends.class.php | 4 +- pushbullet/class/pushbulletmanager.class.php | 4 +- pushbullet/hooks/addpushbulletapi.hook.php | 2 +- pushbullet/hooks/addpushbulletjs.hook.php | 2 +- .../hooks/addpushbulletmenuitem.hook.php | 2 +- .../pages/pushbulletmanagement.page.php | 2 +- slack/class/slack.class.php | 2 +- slack/class/slackmanager.class.php | 4 +- slack/events/imagecomplete_slack.event.php | 4 +- slack/events/imagefail_slack.event.php | 4 +- slack/events/loginfailure_slack.event.php | 4 +- slack/events/snapincomplete_slack.event.php | 4 +- .../events/snapintaskcomplete_slack.event.php | 4 +- slack/hooks/addslackapi.hook.php | 2 +- slack/hooks/addslackjs.hook.php | 2 +- slack/hooks/addslackmenuitem.hook.php | 2 +- slack/pages/slackmanagement.page.php | 2 +- subnetgroup/class/subnetgroup.class.php | 2 +- .../class/subnetgroupmanager.class.php | 4 +- subnetgroup/hooks/addsubnetgroupapi.hook.php | 2 +- subnetgroup/hooks/addsubnetgrouphost.hook.php | 4 +- subnetgroup/hooks/addsubnetgroupjs.hook.php | 2 +- .../hooks/addsubnetgroupmenuitem.hook.php | 2 +- subnetgroup/hooks/addsubnetgrouptype.hook.php | 2 +- .../hooks/removesubnetgroupgroup.hook.php | 4 +- .../pages/subnetgroupmanagement.page.php | 2 +- .../reports/subnetgroup_report.report.php | 8 +- taskstateedit/class/taskstateedit.class.php | 2 +- .../class/taskstateeditmanager.class.php | 2 +- .../hooks/addtaskstateeditjs.hook.php | 2 +- .../hooks/addtaskstateeditmenuitem.hook.php | 2 +- taskstateedit/hooks/addtaskstatetype.hook.php | 2 +- .../pages/taskstateeditmanagement.page.php | 2 +- .../reports/taskstateedit_report.report.php | 8 +- tasktypeedit/class/tasktypeedit.class.php | 2 +- .../class/tasktypeeditmanager.class.php | 2 +- tasktypeedit/hooks/addtasktypeeditjs.hook.php | 2 +- .../hooks/addtasktypeeditmenuitem.hook.php | 2 +- tasktypeedit/hooks/addtasktypetype.hook.php | 2 +- .../pages/tasktypeeditmanagement.page.php | 2 +- .../reports/tasktypeedit_report.report.php | 8 +- tests/core-references-are-qualified.test.php | 177 +++++++++++++++ tests/oidc-flow-safety.test.php | 8 +- tests/oidc-provider-safety.test.php | 2 +- tests/stubs/fog-stubs.php | 205 ++++++++++-------- windowskey/class/windowskey.class.php | 6 +- .../class/windowskeyassociation.class.php | 2 +- .../windowskeyassociationmanager.class.php | 2 +- windowskey/class/windowskeymanager.class.php | 4 +- windowskey/hooks/addwindowskeyapi.hook.php | 2 +- windowskey/hooks/addwindowskeyimage.hook.php | 24 +- windowskey/hooks/addwindowskeyjs.hook.php | 2 +- .../hooks/addwindowskeymenuitem.hook.php | 2 +- windowskey/hooks/changehostkey.hook.php | 6 +- .../hooks/windowskeydeletemassitems.hook.php | 2 +- .../pages/windowskeymanagement.page.php | 2 +- .../reports/windowskey_report.report.php | 8 +- wolbroadcast/class/wolbroadcast.class.php | 2 +- .../class/wolbroadcastmanager.class.php | 4 +- .../hooks/addbroadcastaddresses.hook.php | 4 +- .../hooks/addwolbroadcastapi.hook.php | 2 +- wolbroadcast/hooks/addwolbroadcastjs.hook.php | 2 +- .../hooks/addwolbroadcastmenuitem.hook.php | 2 +- .../hooks/addwolbroadcasttype.hook.php | 2 +- .../pages/wolbroadcastmanagement.page.php | 2 +- .../reports/wolbroadcast_report.report.php | 8 +- 165 files changed, 898 insertions(+), 496 deletions(-) create mode 100644 bin/qualify-core-references.php create mode 100644 tests/core-references-are-qualified.test.php diff --git a/bin/qualify-core-references.php b/bin/qualify-core-references.php new file mode 100644 index 00000000..9e2c08f9 --- /dev/null +++ b/bin/qualify-core-references.php @@ -0,0 +1,204 @@ +Route` is not a class reference. + * + * Names the plugin tree itself declares are skipped even when core has one of + * the same name -- a plugin's own class always wins for its own references. + * + * Usage: + * php bin/qualify-core-references.php --core=/path/to/fogproject [--fix] + * + * Without --fix it reports and changes nothing. Exit 1 if anything is left to + * do (so it doubles as a check), 0 when the tree is clean. + */ + +$opts = getopt('', ['core:', 'fix']); +$core = $opts['core'] ?? '/home/telliott/fogproject'; +$fix = isset($opts['fix']); +$srcRoot = rtrim($core, '/') . '/packages/web/src'; +if (!is_dir($srcRoot)) { + fwrite(STDERR, "no fogproject src/ at $srcRoot -- pass --core=/path/to/fogproject\n"); + exit(2); +} + +/** + * Core: lowercased short name => the name to write, WITHOUT a leading + * backslash (the rewrite adds one). + * + * Three sources, because core does not keep all its classes in one place and + * the src/ map alone silently misses two kinds of reference: + * + * - packages/web/src/ PSR-4, so the path IS the name. + * - packages/web/lib/ the 46 discovery-named classes, whose filenames + * are a contract with FOGPageManager and cannot be + * PSR-4. They sit in the flat FOG namespace, so a + * plugin report extends FOG\ReportManagement. + * - packages/web/commons/ Initiator, which is genuinely global-namespace + * and stays that way; qualifying it is just a + * leading backslash. + * + * Only the first group's aliases are being retired, but the other two are + * bare names resolving by luck of the global namespace, and the test that + * gates this cannot tell the three apart -- nor should it have to. + */ +$core = []; +$walk = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($srcRoot)); +foreach ($walk as $file) { + if ($file->isFile() && 'php' === $file->getExtension()) { + $short = $file->getBasename('.php'); + $core[strtolower($short)] = 'FOG\\' . basename(dirname($file->getPathname())) . '\\' . $short; + } +} +$webRoot = dirname($srcRoot); +foreach (['pages', 'hooks', 'reports', 'events'] as $dir) { + foreach (glob($webRoot . '/lib/' . $dir . '/*.php') as $path) { + $short = preg_replace('/\\.(page|hook|report|event)$/', '', basename($path, '.php')); + $src = file_get_contents($path); + if (preg_match('/^\\s*(?:final\\s+|abstract\\s+)*class\\s+(\\w+)/mi', $src, $m)) { + $core[strtolower($m[1])] = 'FOG\\' . $m[1]; + } + } +} +foreach (glob($webRoot . '/commons/*.php') as $path) { + if (preg_match_all( + '/^\\s*(?:final\\s+|abstract\\s+)*class\\s+(\\w+)/mi', + file_get_contents($path), + $m + )) { + foreach ($m[1] as $name) { + // Global namespace, and staying there -- the leading backslash + // the rewrite adds is the whole change. + $core[strtolower($name)] = $name; + } + } +} + +$root = dirname(__DIR__); + +/** Every class this tree declares. A plugin's own name always wins. */ +$own = []; +$walk = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)); +foreach ($walk as $file) { + // tests/stubs is excluded here as well as from the rewrite. It declares + // test doubles NAMED for core classes -- FOGController, Schema -- and + // counting those as the tree's own would make every reference to them + // look like a plugin's own class and skip it. That is not hypothetical: + // the first run of this tool rewrote 313 references and silently left + // ~90 behind for exactly that reason. The strict stubs caught it. + if (!$file->isFile() || 'php' !== $file->getExtension() + || false !== strpos($file->getPathname(), '/.git/') + || false !== strpos($file->getPathname(), '/tests/stubs/') + ) { + continue; + } + if (preg_match_all( + '/^\s*(?:final\s+|abstract\s+)*(?:class|interface|trait)\s+(\w+)/mi', + file_get_contents($file->getPathname()), + $m + )) { + foreach ($m[1] as $name) { + $own[strtolower($name)] = true; + } + } +} + +$skip = [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT]; +$changedFiles = 0; +$changedRefs = 0; +$report = []; + +$walk = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($root)); +foreach ($walk as $file) { + $path = $file->getPathname(); + if (!$file->isFile() || 'php' !== $file->getExtension() + || false !== strpos($path, '/.git/') + || false !== strpos($path, '/tests/stubs/') + ) { + continue; + } + $src = file_get_contents($path); + $tokens = token_get_all($src); + $count = count($tokens); + $out = ''; + $hits = 0; + for ($i = 0; $i < $count; $i++) { + $token = $tokens[$i]; + if (!is_array($token) || T_STRING !== $token[0]) { + $out .= is_array($token) ? $token[1] : $token; + continue; + } + $name = $token[1]; + $key = strtolower($name); + if (!isset($core[$key]) || isset($own[$key])) { + $out .= $name; + continue; + } + // Neighbours, whitespace and comments skipped. + $prev = null; + for ($j = $i - 1; $j >= 0; $j--) { + if (is_array($tokens[$j]) && in_array($tokens[$j][0], $skip, true)) { + continue; + } + $prev = $tokens[$j]; + break; + } + $next = null; + for ($j = $i + 1; $j < $count; $j++) { + if (is_array($tokens[$j]) && in_array($tokens[$j][0], $skip, true)) { + continue; + } + $next = $tokens[$j]; + break; + } + // Already qualified, or a member/function/const name rather than a + // class reference. + $isQualified = is_array($prev) + && in_array($prev[0], [T_NS_SEPARATOR, T_OBJECT_OPERATOR, T_DOUBLE_COLON, T_FUNCTION, T_CONST], true); + $followsSeparator = is_array($next) && T_NS_SEPARATOR === $next[0]; + $isClassRef = (is_array($next) && T_DOUBLE_COLON === $next[0]) + || (is_array($prev) && in_array($prev[0], [T_NEW, T_EXTENDS, T_IMPLEMENTS, T_INSTANCEOF], true)); + if ($isQualified || $followsSeparator || !$isClassRef) { + $out .= $name; + continue; + } + $out .= '\\' . $core[$key]; + $hits++; + } + if (!$hits) { + continue; + } + $rel = str_replace($root . '/', '', $path); + $report[] = sprintf('%-58s %d', $rel, $hits); + $changedFiles++; + $changedRefs += $hits; + if ($fix) { + file_put_contents($path, $out); + } +} + +sort($report); +echo implode("\n", $report) . "\n"; +printf( + "%s: %d reference(s) in %d file(s)\n", + $fix ? 'rewrote' : 'would rewrite', + $changedRefs, + $changedFiles +); +exit($changedRefs && !$fix ? 1 : 0); diff --git a/capone/class/capone.class.php b/capone/class/capone.class.php index b83b2b20..b8c95563 100644 --- a/capone/class/capone.class.php +++ b/capone/class/capone.class.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class Capone extends FOGController +class Capone extends \FOG\Base\FOGController { /** * The capone table diff --git a/capone/class/caponemanager.class.php b/capone/class/caponemanager.class.php index 17d76d32..923964f9 100644 --- a/capone/class/caponemanager.class.php +++ b/capone/class/caponemanager.class.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class CaponeManager extends FOGManagerController +class CaponeManager extends \FOG\Base\FOGManagerController { /** * The base table name. @@ -149,7 +149,7 @@ function () { */ public function install() { - $res = Schema::applyUpdates($this->schema(), 0); + $res = \FOG\Items\Schema::applyUpdates($this->schema(), 0); return $res['error'] === null; } /** @@ -159,11 +159,11 @@ public function install() */ public function uninstall() { - Route::deletemass( + \FOG\Router\Route::deletemass( 'setting', ['name' => 'FOG_PLUGIN_CAPONE_%'] ); - Route::deletemass( + \FOG\Router\Route::deletemass( 'pxemenuoptions', ['name' => 'fog.capone'] ); diff --git a/capone/hooks/addbootmenuitem.hook.php b/capone/hooks/addbootmenuitem.hook.php index 2edaa4c0..6210fca8 100644 --- a/capone/hooks/addbootmenuitem.hook.php +++ b/capone/hooks/addbootmenuitem.hook.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddBootMenuItem extends Hook +class AddBootMenuItem extends \FOG\Base\Hook { /** * The name of this hook. diff --git a/capone/hooks/addcaponeapi.hook.php b/capone/hooks/addcaponeapi.hook.php index 2c0edbb1..02e90453 100644 --- a/capone/hooks/addcaponeapi.hook.php +++ b/capone/hooks/addcaponeapi.hook.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddCaponeAPI extends Hook +class AddCaponeAPI extends \FOG\Base\Hook { /** * Name of the hook. diff --git a/capone/hooks/addcaponejs.hook.php b/capone/hooks/addcaponejs.hook.php index c0469099..ede2efc7 100644 --- a/capone/hooks/addcaponejs.hook.php +++ b/capone/hooks/addcaponejs.hook.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddCaponeJS extends Hook +class AddCaponeJS extends \FOG\Base\Hook { /** * The name of this hook. diff --git a/capone/hooks/addcaponemenuitem.hook.php b/capone/hooks/addcaponemenuitem.hook.php index 3cf2a1f3..c9cb7541 100644 --- a/capone/hooks/addcaponemenuitem.hook.php +++ b/capone/hooks/addcaponemenuitem.hook.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddCaponeMenuItem extends Hook +class AddCaponeMenuItem extends \FOG\Base\Hook { /** * The name of this hook. diff --git a/capone/pages/caponemanagement.page.php b/capone/pages/caponemanagement.page.php index f4a561de..6f1c12f2 100644 --- a/capone/pages/caponemanagement.page.php +++ b/capone/pages/caponemanagement.page.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class CaponeManagement extends FOGPage +class CaponeManagement extends \FOG\Base\FOGPage { /** * The node this page displays with. @@ -133,7 +133,7 @@ function (&$serverFault) { $key = trim( filter_input(INPUT_POST, 'key') ); - $image = new Image($imageID); + $image = new \FOG\Items\Image($imageID); $os = $image->getOS(); $osID = $os->get('id'); if (!$image->isValid()) { @@ -261,7 +261,7 @@ public function caponeGeneralPost() $key = trim( filter_input(INPUT_POST, 'key') ); - $image = new Image($imageID); + $image = new \FOG\Items\Image($imageID); $os = $image->getOS(); $osID = $os->get('id'); @@ -321,7 +321,7 @@ public function globalsettings() 'FOG_PLUGIN_CAPONE_SHUTDOWN' ] ]; - $settings = Route::getIds( + $settings = \FOG\Router\Route::getIds( 'setting', $find, 'value' @@ -443,7 +443,7 @@ public function globalsettingsPost() throw new \Exception(_('Unable to set action field')); } $hook = 'CAPONE_GLOBAL_EDIT_SUCCESS'; - $code = HTTPResponseCodes::HTTP_ACCEPTED; + $code = \FOG\Router\HTTPResponseCodes::HTTP_ACCEPTED; $msg = json_encode( [ 'msg' => _('Global settings updated!'), @@ -454,8 +454,8 @@ public function globalsettingsPost() $hook = 'CAPONE_GLOBAL_EDIT_FAIL'; $code = ( $serverFault ? - HTTPResponseCodes::HTTP_INTERNAL_SERVER_ERROR : - HTTPResponseCodes::HTTP_BAD_REQUEST + \FOG\Router\HTTPResponseCodes::HTTP_INTERNAL_SERVER_ERROR : + \FOG\Router\HTTPResponseCodes::HTTP_BAD_REQUEST ); $msg = json_encode( [ diff --git a/capone/reg-task/caponetasking.class.php b/capone/reg-task/caponetasking.class.php index b2a3ae46..dc193851 100644 --- a/capone/reg-task/caponetasking.class.php +++ b/capone/reg-task/caponetasking.class.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class CaponeTasking extends FOGBase +class CaponeTasking extends \FOG\Base\FOGBase { /** * The actions supported fog capone. @@ -62,12 +62,12 @@ public function __construct() try { $strSetup = "%s|%s|%s|%s|%s|%s|%s"; ob_start(); - $capones = Route::getList( + $capones = \FOG\Router\Route::getList( 'capone', ['key' => $key] ); foreach ($capones as &$Capone) { - $Image = new Image($Capone->imageID); + $Image = new \FOG\Items\Image($Capone->imageID); $OS = $Image->getOS(); $StorageNode = $Image ->getStorageGroup() diff --git a/helloworld/class/helloworld.class.php b/helloworld/class/helloworld.class.php index fc2ab8c2..6c35f581 100644 --- a/helloworld/class/helloworld.class.php +++ b/helloworld/class/helloworld.class.php @@ -28,7 +28,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class HelloWorld extends FOGController +class HelloWorld extends \FOG\Base\FOGController { /** * The database table this model maps to. diff --git a/helloworld/class/helloworldmanager.class.php b/helloworld/class/helloworldmanager.class.php index 0b81ddb8..a41c0bcd 100644 --- a/helloworld/class/helloworldmanager.class.php +++ b/helloworld/class/helloworldmanager.class.php @@ -28,7 +28,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class HelloWorldManager extends FOGManagerController +class HelloWorldManager extends \FOG\Base\FOGManagerController { /** * The table name. @@ -107,7 +107,7 @@ public function schema() */ public function install() { - $res = Schema::applyUpdates($this->schema(), 0); + $res = \FOG\Items\Schema::applyUpdates($this->schema(), 0); return $res['error'] === null; } } diff --git a/helloworld/hooks/addhelloworldapi.hook.php b/helloworld/hooks/addhelloworldapi.hook.php index 7dbd9d80..fe099497 100644 --- a/helloworld/hooks/addhelloworldapi.hook.php +++ b/helloworld/hooks/addhelloworldapi.hook.php @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddHelloWorldAPI extends Hook +class AddHelloWorldAPI extends \FOG\Base\Hook { /** * The name of this hook. diff --git a/helloworld/hooks/addhelloworldjs.hook.php b/helloworld/hooks/addhelloworldjs.hook.php index cc20380f..5aa0c95a 100644 --- a/helloworld/hooks/addhelloworldjs.hook.php +++ b/helloworld/hooks/addhelloworldjs.hook.php @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddHelloWorldJS extends Hook +class AddHelloWorldJS extends \FOG\Base\Hook { /** * The name of this hook. diff --git a/helloworld/hooks/addhelloworldmenuitem.hook.php b/helloworld/hooks/addhelloworldmenuitem.hook.php index ec7ec07c..e63a65c1 100644 --- a/helloworld/hooks/addhelloworldmenuitem.hook.php +++ b/helloworld/hooks/addhelloworldmenuitem.hook.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddHelloWorldMenuItem extends Hook +class AddHelloWorldMenuItem extends \FOG\Base\Hook { /** * The name of this hook. diff --git a/helloworld/pages/helloworldmanagement.page.php b/helloworld/pages/helloworldmanagement.page.php index bfc916b0..be6c9a94 100644 --- a/helloworld/pages/helloworldmanagement.page.php +++ b/helloworld/pages/helloworldmanagement.page.php @@ -30,7 +30,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class HelloWorldManagement extends FOGPage +class HelloWorldManagement extends \FOG\Base\FOGPage { /** * The node this page operates on (matches the plugin machine name). diff --git a/helloworld/tasks/helloworldheartbeat.task.php b/helloworld/tasks/helloworldheartbeat.task.php index bdb7209d..6736e0fc 100644 --- a/helloworld/tasks/helloworldheartbeat.task.php +++ b/helloworld/tasks/helloworldheartbeat.task.php @@ -43,7 +43,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class HelloWorldHeartbeat extends PluginTask +class HelloWorldHeartbeat extends \FOG\Base\PluginTask { /** * Shown in the service log instead of the class name. @@ -98,7 +98,7 @@ public function run() // getCount(), not count(): count() returns void and stashes the // result for getData() to encode. getCount() is the wrapper that // hands back an int. - $total = Route::getCount('helloworld'); + $total = \FOG\Router\Route::getCount('helloworld'); $this->logLine( sprintf( '%s: %d', diff --git a/ldap/class/ldap.class.php b/ldap/class/ldap.class.php index 2a2414fc..540ed4c8 100644 --- a/ldap/class/ldap.class.php +++ b/ldap/class/ldap.class.php @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAP extends FOGController +class LDAP extends \FOG\Base\FOGController { /** * The matching rule that makes a member= test transitive. @@ -819,7 +819,7 @@ public function getDisplayName($user, $pass) * immediately if found. */ $test = preg_match( - User::PATTERN, + \FOG\Items\User::PATTERN, $user ); if (!$test) { @@ -1115,7 +1115,7 @@ public function destroy($key = 'id') * each group also takes its role and user group associations * with it -- LDAPGroup::destroy() is what knows about those. */ - $groupIds = (array)Route::getIds( + $groupIds = (array)\FOG\Router\Route::getIds( 'ldapgroup', ['serverID' => $id], 'id' @@ -1172,7 +1172,7 @@ public function authLDAP($user, $pass) * immediately if found. */ $test = preg_match( - User::PATTERN, + \FOG\Items\User::PATTERN, $user ); if (!$test) { diff --git a/ldap/class/ldapgroup.class.php b/ldap/class/ldapgroup.class.php index 84fcd3b0..e65c220e 100644 --- a/ldap/class/ldapgroup.class.php +++ b/ldap/class/ldapgroup.class.php @@ -36,7 +36,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPGroup extends FOGController +class LDAPGroup extends \FOG\Base\FOGController { /** * The table name. @@ -101,12 +101,12 @@ class LDAPGroup extends FOGController public static function serverLinkCell($serverID) { if (!$serverID) { - return Route::EMPTY_CELL; + return \FOG\Router\Route::EMPTY_CELL; } $name = self::getClass('LDAP', $serverID)->get('name'); // A group outliving its server should still list, not fatal. if (!$name) { - return Route::EMPTY_CELL; + return \FOG\Router\Route::EMPTY_CELL; } return self::entityLink('ldap', $serverID, $name); } @@ -195,7 +195,7 @@ protected function loadRoles() { $this->set( 'roles', - (array)Route::getIds( + (array)\FOG\Router\Route::getIds( 'ldapgrouproleassociation', ['ldapgroupID' => $this->get('id')], 'roleID' @@ -211,7 +211,7 @@ protected function loadUsergroups() { $this->set( 'usergroups', - (array)Route::getIds( + (array)\FOG\Router\Route::getIds( 'ldapgroupusergroupassociation', ['ldapgroupID' => $this->get('id')], 'usergroupID' @@ -232,11 +232,11 @@ public function destroy($key = 'id') { $id = (int)$this->get('id'); if ($id > 0) { - Route::deletemass( + \FOG\Router\Route::deletemass( 'ldapgrouproleassociation', ['ldapgroupID' => $id] ); - Route::deletemass( + \FOG\Router\Route::deletemass( 'ldapgroupusergroupassociation', ['ldapgroupID' => $id] ); diff --git a/ldap/class/ldapgroupmanager.class.php b/ldap/class/ldapgroupmanager.class.php index 765e7bd2..0d739390 100644 --- a/ldap/class/ldapgroupmanager.class.php +++ b/ldap/class/ldapgroupmanager.class.php @@ -21,7 +21,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPGroupManager extends FOGManagerController +class LDAPGroupManager extends \FOG\Base\FOGManagerController { /** * The base table name. diff --git a/ldap/class/ldapgrouproleassociation.class.php b/ldap/class/ldapgrouproleassociation.class.php index d7470350..c67d75e1 100644 --- a/ldap/class/ldapgrouproleassociation.class.php +++ b/ldap/class/ldapgrouproleassociation.class.php @@ -24,7 +24,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPGroupRoleAssociation extends FOGController +class LDAPGroupRoleAssociation extends \FOG\Base\FOGController { /** * The table name. diff --git a/ldap/class/ldapgrouproleassociationmanager.class.php b/ldap/class/ldapgrouproleassociationmanager.class.php index 90232d24..86ace0db 100644 --- a/ldap/class/ldapgrouproleassociationmanager.class.php +++ b/ldap/class/ldapgrouproleassociationmanager.class.php @@ -21,7 +21,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPGroupRoleAssociationManager extends FOGManagerController +class LDAPGroupRoleAssociationManager extends \FOG\Base\FOGManagerController { /** * The base table name. diff --git a/ldap/class/ldapgroupusergroupassociation.class.php b/ldap/class/ldapgroupusergroupassociation.class.php index 4356ee73..47398c17 100644 --- a/ldap/class/ldapgroupusergroupassociation.class.php +++ b/ldap/class/ldapgroupusergroupassociation.class.php @@ -25,7 +25,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPGroupUserGroupAssociation extends FOGController +class LDAPGroupUserGroupAssociation extends \FOG\Base\FOGController { /** * The table name. diff --git a/ldap/class/ldapgroupusergroupassociationmanager.class.php b/ldap/class/ldapgroupusergroupassociationmanager.class.php index 89cf481c..2e555e04 100644 --- a/ldap/class/ldapgroupusergroupassociationmanager.class.php +++ b/ldap/class/ldapgroupusergroupassociationmanager.class.php @@ -21,7 +21,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPGroupUserGroupAssociationManager extends FOGManagerController +class LDAPGroupUserGroupAssociationManager extends \FOG\Base\FOGManagerController { /** * The base table name. diff --git a/ldap/class/ldapmanager.class.php b/ldap/class/ldapmanager.class.php index 4d5d048e..596effe8 100644 --- a/ldap/class/ldapmanager.class.php +++ b/ldap/class/ldapmanager.class.php @@ -23,7 +23,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPManager extends FOGManagerController +class LDAPManager extends \FOG\Base\FOGManagerController { /** * The base table name. @@ -296,7 +296,7 @@ public function seedSettings() */ private static function _defaultRoleId($name) { - $ids = Route::getIds('role', ['name' => $name], 'id'); + $ids = \FOG\Router\Route::getIds('role', ['name' => $name], 'id'); return (string)(array_shift($ids) ?: ''); } /** @@ -328,7 +328,7 @@ public function backfillIdentities() // throw on query errors, so stamping a column that is not there yet // would fail silently and leave these rows unprotected. $column = array_filter( - (array)DatabaseManager::getColumns('users', 'uAuthSource') + (array)\FOG\Db\DatabaseManager::getColumns('users', 'uAuthSource') ); if (count($column) < 1) { return _( @@ -899,7 +899,7 @@ function () { // through VARCHAR(1) so the conversion is by label, and carries // this table's nullability and defaults across (lsAllowAPI is nullable and lsUseGroupMatch has no default at all). function () { - return Schema::enumToTinyint( + return \FOG\Items\Schema::enumToTinyint( [ 'LDAPServers' => [ 'lsAllowAPI', @@ -920,7 +920,7 @@ function () { */ public function install() { - $res = Schema::applyUpdates($this->schema(), 0); + $res = \FOG\Items\Schema::applyUpdates($this->schema(), 0); return $res['error'] === null; } /** @@ -937,16 +937,16 @@ public function uninstall() // -- uType is a shared column anyone can write, including over the // API and CSV import. $find = ['authsource' => LDAPPluginHook::AUTH_SOURCE]; - $userIDs = Route::getIds( + $userIDs = \FOG\Router\Route::getIds( 'user', $find ); - Route::deletemass( + \FOG\Router\Route::deletemass( 'setting', ['category' => 'Plugin: LDAP'] ); if (count($userIDs ?: [])) { - Route::deletemass( + \FOG\Router\Route::deletemass( 'user', ['id' => $userIDs] ); diff --git a/ldap/class/ldapusergrant.class.php b/ldap/class/ldapusergrant.class.php index f06fad17..fca783cf 100644 --- a/ldap/class/ldapusergrant.class.php +++ b/ldap/class/ldapusergrant.class.php @@ -37,7 +37,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPUserGrant extends FOGController +class LDAPUserGrant extends \FOG\Base\FOGController { /** * Target kinds, matching the association tables they mirror. diff --git a/ldap/class/ldapusergrantmanager.class.php b/ldap/class/ldapusergrantmanager.class.php index 81fc942e..fc66fecf 100644 --- a/ldap/class/ldapusergrantmanager.class.php +++ b/ldap/class/ldapusergrantmanager.class.php @@ -21,7 +21,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class LDAPUserGrantManager extends FOGManagerController +class LDAPUserGrantManager extends \FOG\Base\FOGManagerController { /** * The base table name. diff --git a/ldap/hooks/addldapapi.hook.php b/ldap/hooks/addldapapi.hook.php index 27b711ff..c0deacbb 100644 --- a/ldap/hooks/addldapapi.hook.php +++ b/ldap/hooks/addldapapi.hook.php @@ -19,7 +19,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddLDAPAPI extends Hook +class AddLDAPAPI extends \FOG\Base\Hook { /** * Add LDAP API diff --git a/ldap/hooks/addldapgrouptabs.hook.php b/ldap/hooks/addldapgrouptabs.hook.php index 2343e7e0..2b167c9b 100644 --- a/ldap/hooks/addldapgrouptabs.hook.php +++ b/ldap/hooks/addldapgrouptabs.hook.php @@ -37,7 +37,7 @@ * @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @link https://fogproject.org */ -class AddLDAPGroupTabs extends Hook +class AddLDAPGroupTabs extends \FOG\Base\Hook { /** * The name of this hook. @@ -118,7 +118,7 @@ public function injectTabData($arguments) // Without this, role.edit alone would be enough to rewrite what a // directory group grants -- a right the LDAP Group page itself // does not hand out. - if (!Authorization::can('ldapgroup.view')) { + if (!\FOG\Auth\Authorization::can('ldapgroup.view')) { return; } $obj = $arguments['obj']; @@ -154,15 +154,15 @@ public function renderTab($obj, $node) $isRole = ('role' === $node); $props = ' method="post" action="' - . FOGPage::makeTabUpdateURL($slug, $obj->get('id')) + . \FOG\Base\FOGPage::makeTabUpdateURL($slug, $obj->get('id')) . '" '; - $buttons = FOGPage::makeButton( + $buttons = \FOG\Base\FOGPage::makeButton( "$slug-send", _('Add selected'), 'btn btn-primary float-end', $props ); - $buttons .= FOGPage::makeButton( + $buttons .= \FOG\Base\FOGPage::makeButton( "$slug-remove", _('Remove selected'), 'btn btn-danger float-start', @@ -172,7 +172,7 @@ public function renderTab($obj, $node) // A directory group that has not been registered here yet is the // normal case when wiring up a new role, and sending the admin to // the LDAP Group page and back is the trip this removes. - $createModal = FOGPage::renderAssocCreate( + $createModal = \FOG\Base\FOGPage::renderAssocCreate( $slug, 'ldapgroup', $buttons, @@ -223,20 +223,20 @@ public function renderTab($obj, $node) echo ''; echo ''; echo '