diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-15 15:42:17 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-15 15:42:17 +0100 |
| commit | 152721111e2bdc5686f2f6b92c0181a1fbbe333a (patch) | |
| tree | 62183dfe0d1f2bd011760654cb9c36cbbddb8dcb | |
| parent | 2613056108575dda3f23a1d690c59aa79777d591 (diff) | |
| download | themes-152721111e2bdc5686f2f6b92c0181a1fbbe333a.tar.gz themes-152721111e2bdc5686f2f6b92c0181a1fbbe333a.tar.bz2 themes-152721111e2bdc5686f2f6b92c0181a1fbbe333a.zip | |
To simplyfy maintenence BitUser classes have been retired and active code base defaulted to ROLE_MODEL
| -rwxr-xr-x | admin/admin_layout_inc.php | 29 | ||||
| -rwxr-xr-x | admin/admin_layout_overview_inc.php | 9 | ||||
| -rwxr-xr-x | admin/admin_themes_inc.php | 2 | ||||
| -rwxr-xr-x | includes/classes/BitThemes.php | 83 |
4 files changed, 28 insertions, 95 deletions
diff --git a/admin/admin_layout_inc.php b/admin/admin_layout_inc.php index 6e938c8..1346010 100755 --- a/admin/admin_layout_inc.php +++ b/admin/admin_layout_inc.php @@ -4,14 +4,8 @@ // Initialization require_once '../../kernel/includes/setup_inc.php'; -if( defined( 'ROLE_MODEL' )) { - if( !isset($_REQUEST["roles"] ) ) { - $_REQUEST["roles"] = []; - } -} else { - if( !isset($_REQUEST["groups"] ) ) { - $_REQUEST["groups"] = []; - } +if( !isset($_REQUEST["roles"] ) ) { + $_REQUEST["roles"] = []; } if( empty( $_REQUEST['module_package'] ) ) { @@ -68,14 +62,8 @@ if( isset( $_REQUEST['module_id'] ) && !empty( $_REQUEST['move_module'] )) { } elseif( $processForm == 'Center' || $processForm == 'Column' ) { $fAssign = &$_REQUEST['fAssign']; - if( defined( 'ROLE_MODEL' )) { - if( !empty( $_REQUEST['roles'] ) ) { - $fAssign['roles'] = $_REQUEST['roles']; - } - } else { - if( !empty( $_REQUEST['groups'] ) ) { - $fAssign['groups'] = $_REQUEST['groups']; - } + if( !empty( $_REQUEST['roles'] ) ) { + $fAssign['roles'] = $_REQUEST['roles']; } // either add the module to all available layouts or just the active one @@ -150,13 +138,8 @@ for( $i = 1; $i < 50; $i++ ) { $gBitSmarty->assign( 'orders', $orders ); -if( defined( 'ROLE_MODEL' )) { - $roles = $gBitUser->getAllUserRoles( ROOT_USER_ID ); - $gBitSmarty->assign( "roles", $roles ); -} else { - $groups = $gBitUser->getAllUserGroups( ROOT_USER_ID ); - $gBitSmarty->assign( "groups", $groups ); -} +$roles = $gBitUser->getAllUserRoles( ROOT_USER_ID ); +$gBitSmarty->assign( "roles", $roles ); // we need gBitThemes as well $gBitSmarty->assign( "gBitThemes", $gBitThemes ); diff --git a/admin/admin_layout_overview_inc.php b/admin/admin_layout_overview_inc.php index bc21be0..3565796 100755 --- a/admin/admin_layout_overview_inc.php +++ b/admin/admin_layout_overview_inc.php @@ -59,11 +59,6 @@ ksort( $allModulesHelp ); $gBitSmarty->assign( 'allModulesHelp', $allModulesHelp ); $gBitSmarty->assign( 'pageName', 'Layout Options' ); -if( defined( 'ROLE_MODEL' )) { - $roles = $gBitUser->getAllUserRoles( ROOT_USER_ID ); - $gBitSmarty->assign( "roles", $roles ); -} else { - $groups = $gBitUser->getAllUserGroups( ROOT_USER_ID ); - $gBitSmarty->assign( "groups", $groups ); -} +$roles = $gBitUser->getAllUserRoles( ROOT_USER_ID ); +$gBitSmarty->assign( "roles", $roles ); ?> diff --git a/admin/admin_themes_inc.php b/admin/admin_themes_inc.php index d8b4c6c..ff68a38 100755 --- a/admin/admin_themes_inc.php +++ b/admin/admin_themes_inc.php @@ -28,7 +28,7 @@ $themeSettings = [ ], 'site_fancy_zoom' => [ 'label' => "Enable Fancy Zoom for images", - 'note' => "If checked, a Javascript zooms images when clicking on them. This will modify the behaviour when viewing most images. If you are running a commercial site, please read the license notice in /util/javascript/fancyzoom/js-global/FancyZoom.js.", + 'note' => "If checked, a Javascript zooms images when clicking on them. This will modify the behaviour when viewing most images. If you are running a commercial site, please read the license notice in /themes/js/fancyzoom/js-global/FancyZoom.js.", ], 'site_mods_req_admn_grp' => [ 'label' => 'Modules require membership', diff --git a/includes/classes/BitThemes.php b/includes/classes/BitThemes.php index 46ae193..5bb11bc 100755 --- a/includes/classes/BitThemes.php +++ b/includes/classes/BitThemes.php @@ -10,6 +10,7 @@ namespace Bitweaver\Themes; use Bitweaver\BitCache; use Bitweaver\BitSingleton; +use Bitweaver\Users\RolePermUser; use Bitweaver\Users\RoleUser; use Bitweaver\KernelTools; @@ -600,58 +601,24 @@ class BitThemes extends BitSingleton { break; } - if ( defined ('ROLE_MODEL') ) { - // transform roles to managable array - if( empty( $row["roles"] )) { - // default is that module is visible at all times - $row["visible"] = true; - $row["module_roles"] = []; - } else { - $row['module_roles'] = $this->parseRoles( $row['roles'] ); - - if( $gBitUser->isAdmin() ) { - if ( $gBitSystem->isFeatureActive('site_mods_req_admn_grp') ) { - if( \in_array(1, $row['module_roles']) ) { - $row['visible'] = true; - } - } - else { - $row["visible"] = true; + if( empty( $row["roles"] )) { + $row["visible"] = true; + $row["module_roles"] = []; + } else { + $row['module_roles'] = $this->parseRoles( $row['roles'] ); + if( $gBitUser->isAdmin() ) { + if ( $gBitSystem->isFeatureActive('site_mods_req_admn_grp') ) { + if( \in_array(1, $row['module_roles']) ) { + $row['visible'] = true; } } else { - // Check for the right roles - foreach( $row["module_roles"] as $modRoleId ) { - if( $gBitUser->isInRole( $modRoleId )) { - $row["visible"] = true; - break; // no need to continue looping - } - } + $row["visible"] = true; } - } - } else { - // transform groups to managable array - if( empty( $row["groups"] )) { - // default is that module is visible at all times - $row["visible"] = true; - $row["module_groups"] = []; } else { - $row['module_groups'] = !empty($row['groups']) ? $this->parseGroups( $row['groups'] ) : null; - if( $gBitUser->isAdmin() ) { - if ( $gBitSystem->isFeatureActive('site_mods_req_admn_grp') ) { - if( \in_array(1, $row['module_groups']) ) { - $row['visible'] = true; - } - } - else { + foreach( $row["module_roles"] as $modRoleId ) { + if( $gBitUser->isInRole( $modRoleId )) { $row["visible"] = true; - } - } else { - // Check for the right groups - foreach( $row["module_groups"] as $modGroupId ) { - if( $gBitUser->isInGroup( $modGroupId )) { - $row["visible"] = true; - break; // no need to continue looping - } + break; } } } @@ -749,11 +716,7 @@ class BitThemes extends BitSingleton { $layouts = []; $modules = $this->mDb->getAll( "SELECT tl.* FROM `".BIT_DB_PREFIX."themes_layouts` tl ORDER BY ".$this->mDb->convertSortmode( "pos_asc" )); foreach( $modules as $module ) { - if( defined ( 'ROLE_MODEL') ) { - $module['module_roles'] = $this->parseRoles( $module['roles'] ?? '' ); - } else { - $module['module_groups'] = $this->parseGroups( $module['groups'] ?? '' ); - } + $module['module_roles'] = $this->parseRoles( $module['roles'] ?? '' ); $layouts[$module['layout']][$module['layout_area']][] = $module; } ksort( $layouts ); @@ -779,9 +742,8 @@ class BitThemes extends BitSingleton { // nuke existing layout $this->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."themes_layouts` WHERE `layout`=?", [$pToLayout]); // get requested layout - $team = defined('ROLE_MODEL') ? 'roles' : 'groups'; $layout = $this->mDb->getAll( " - SELECT `title`, `layout_area`, `module_rows`, `module_rsrc`, `params`, `cache_time`, `$team`, `pos` + SELECT `title`, `layout_area`, `module_rows`, `module_rsrc`, `params`, `cache_time`, `roles`, `pos` FROM `".BIT_DB_PREFIX."themes_layouts` WHERE `layout`=?", [$pFromLayout] ); foreach( $layout as $module ) { $module['layout'] = $pToLayout; @@ -899,12 +861,8 @@ class BitThemes extends BitSingleton { if( !empty( $pHash['roles'] ) && \is_array( $pHash['roles'] )) { $pHash['store']['roles'] = implode( ' ', $pHash['roles'] ); - } elseif( !empty( $pHash['groups'] ) && \is_array( $pHash['groups'] )) { - $pHash['store']['groups'] = implode( ' ', $pHash['groups'] ); - } elseif (defined('ROLE_MODEL') ) { - $pHash['store']['roles'] = null; } else { - $pHash['store']['groups'] = null; + $pHash['store']['roles'] = null; } if( !empty( $pHash['config'] ) ) { @@ -2271,9 +2229,7 @@ function themes_content_display( object $pContent ): void { if( !empty( $theme ) && $theme != DEFAULT_THEME ) { $gBitThemes->setStyle( $theme ); if( !is_object( $gQueryUser ) ) { - $userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' ); - require_once USERS_PKG_CLASS_PATH.$userClass.'.php'; - $gQueryUser = new $userClass( $pContent->getField( 'user_id' ) ); + $gQueryUser = new RolePermUser( $pContent->getField( 'user_id' ) ); $gQueryUser->load(); $gBitSmarty->assign( 'gQueryUser', $gQueryUser ); } @@ -2306,8 +2262,7 @@ function themes_content_list( $pContent, $pListHash ) { if( !empty( $theme ) && $theme != DEFAULT_THEME ) { $gBitThemes->setStyle( $theme ); if( !is_object( $gQueryUser ) ) { - $userClass = $gBitSystem->getConfig( 'user_class', 'BitPermUser' ); - $gQueryUser = new $userClass( $pListHash['user_id'] ); + $gQueryUser = new RolePermUser( $pListHash['user_id'] ); $gQueryUser->load(); $gBitSmarty->assign( 'gQueryUser', $gQueryUser ); } |
