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 '