Skip to content

Commit

Permalink
CONTENTBOX-1491 #resolve
Browse files Browse the repository at this point in the history
Migration to cfmigrations for full database and seeding creations instead of ORM
  • Loading branch information
lmajano committed Nov 8, 2023
1 parent 08a214d commit 8583f3c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 144 deletions.
2 changes: 2 additions & 0 deletions Application.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ component {
};
// cfformat-ignore-end

//applicationStop();abort;

/*****************************************************************************************************/
/************************************** CF APP LISTENERS *********************************************/
/*****************************************************************************************************/
Expand Down
143 changes: 3 additions & 140 deletions modules/contentbox-installer/models/InstallerService.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ component accessors="true" {
if ( arguments.setup.getFullRewrite() ) {
processRewrite( arguments.setup );
}
// create global roles
var adminRole = createRoles( arguments.setup );
// create the admin author
var author = createAuthor( arguments.setup, adminRole );
var author = createAuthor( arguments.setup );
// Create the default site
var site = createSite( arguments.setup );
// Create global settings according to setup
Expand All @@ -64,9 +62,6 @@ component accessors="true" {
}
}

// Remove ORM update from Application.cfc
// Commented out for better update procedures.
processORMUpdate( arguments.setup );
// Process reinit and debug password security
processColdBoxPasswords( arguments.setup );
// ContentBox is now online, mark it:
Expand Down Expand Up @@ -176,20 +171,6 @@ component accessors="true" {
securityRuleService.resetRules();
}

/**
* Process ORM Update
*
* @setup The setup object
*/
function processORMUpdate( required setup ){
var appCFCPath = appPath & "Application.cfc";
var c = fileRead( appCFCPath );

fileWrite( appCFCPath, replaceNoCase( c, """dropcreate""", """update""" ) );

return this;
}

/**
* Process ColdBox Passwords
*
Expand Down Expand Up @@ -245,134 +226,16 @@ component accessors="true" {
return this;
}

/**
* Create permissions
*
* @setup The setup object
*/
function createPermissions( required setup ){
var perms = {
"AUTHOR_ADMIN" : "Ability to manage authors, default is view only",
"CATEGORIES_ADMIN" : "Ability to manage categories, default is view only",
"COMMENTS_ADMIN" : "Ability to manage comments, default is view only",
"CONTENTBOX_ADMIN" : "Access to the enter the ContentBox administrator console",
"CONTENTSTORE_ADMIN" : "Ability to manage the content store, default is view only",
"CONTENTSTORE_EDITOR" : "Ability to create, edit and publish content store elements",
"EDITORS_CACHING" : "Ability to view the content caching panel",
"EDITORS_CATEGORIES" : "Ability to view the content categories panel",
"EDITORS_CUSTOM_FIELDS" : "Ability to manage custom fields in any content editors",
"EDITORS_DISPLAY_OPTIONS" : "Ability to view the content display options panel",
"EDITORS_EDITOR_SELECTOR" : "Ability to change the editor to another registered online editor",
"EDITORS_FEATURED_IMAGE" : "Ability to view the featured image panel",
"EDITORS_HTML_ATTRIBUTES" : "Ability to view the content HTML attributes panel",
"EDITORS_LINKED_CONTENT" : "Ability to view the linked content panel",
"EDITORS_MODIFIERS" : "Ability to view the content modifiers panel",
"EDITORS_RELATED_CONTENT" : "Ability to view the related content panel",
"EMAIL_TEMPLATE_ADMIN" : "Ability to admin and preview email templates",
"ENTRIES_ADMIN" : "Ability to manage blog entries, default is view only",
"ENTRIES_EDITOR" : "Ability to create, edit and publish blog entries",
"FORGEBOX_ADMIN" : "Ability to manage ForgeBox installations and connectivity.",
"GLOBAL_SEARCH" : "Ability to do global searches in the ContentBox Admin",
"GLOBALHTML_ADMIN" : "Ability to manage the system's global HTML content used on layouts",
"MEDIAMANAGER_ADMIN" : "Ability to manage the system's media manager",
"MEDIAMANAGER_LIBRARY_SWITCHER" : "Ability to switch media manager libraries for management",
"MENUS_ADMIN" : "Ability to manage the menu builder",
"MODULES_ADMIN" : "Ability to manage ContentBox Modules",
"PAGES_ADMIN" : "Ability to manage content pages, default is view only",
"PAGES_EDITOR" : "Ability to create, edit and publish pages",
"PERMISSIONS_ADMIN" : "Ability to manage permissions, default is view only",
"RELOAD_MODULES" : "Ability to reload modules",
"ROLES_ADMIN" : "Ability to manage roles, default is view only",
"SECURITYRULES_ADMIN" : "Ability to manage the system's security rules, default is view only",
"SITES_ADMIN" : "Ability to manage sites",
"SYSTEM_AUTH_LOGS" : "Access to the system auth logs",
"SYSTEM_RAW_SETTINGS" : "Access to the ContentBox raw geek settings panel",
"SYSTEM_SAVE_CONFIGURATION" : "Ability to update global configuration data",
"SYSTEM_TAB" : "Access to the ContentBox System tools",
"SYSTEM_UPDATES" : "Ability to view and apply ContentBox updates",
"THEME_ADMIN" : "Ability to manage layouts, default is view only",
"TOOLS_EXPORT" : "Ability to export data from ContentBox",
"TOOLS_IMPORT" : "Ability to import data into ContentBox",
"VERSIONS_DELETE" : "Ability to delete past content versions",
"VERSIONS_ROLLBACK" : "Ability to rollback content versions",
"WIDGET_ADMIN" : "Ability to manage widgets, default is view only"
};

var allperms = [];
for ( var key in perms ) {
var props = { permission : key, description : perms[ key ] };
permissions[ key ] = permissionService.new( properties = props );
arrayAppend( allPerms, permissions[ key ] );
}
permissionService.saveAll( entities = allPerms, transactional = false );

return this;
}

/**
* Create roles and return the admin
*
* @setup The setup object
*/
function createRoles( required setup ){
// Create Permissions
createPermissions( arguments.setup );

// Create Editor
var oRole = roleService.new( properties = { role : "Editor", description : "A ContentBox editor" } );
// Add Editor Permissions
oRole.addPermissions( permissions[ "COMMENTS_ADMIN" ] );
oRole.addPermissions( permissions[ "CONTENTSTORE_EDITOR" ] );
oRole.addPermissions( permissions[ "PAGES_EDITOR" ] );
oRole.addPermissions( permissions[ "CATEGORIES_ADMIN" ] );
oRole.addPermissions( permissions[ "ENTRIES_EDITOR" ] );
oRole.addPermissions( permissions[ "THEME_ADMIN" ] );
oRole.addPermissions( permissions[ "GLOBALHTML_ADMIN" ] );
oRole.addPermissions( permissions[ "MEDIAMANAGER_ADMIN" ] );
oRole.addPermissions( permissions[ "VERSIONS_ROLLBACK" ] );
oRole.addPermissions( permissions[ "CONTENTBOX_ADMIN" ] );
oRole.addPermissions( permissions[ "EDITORS_LINKED_CONTENT" ] );
oRole.addPermissions( permissions[ "EDITORS_DISPLAY_OPTIONS" ] );
oRole.addPermissions( permissions[ "EDITORS_RELATED_CONTENT" ] );
oRole.addPermissions( permissions[ "EDITORS_MODIFIERS" ] );
oRole.addPermissions( permissions[ "EDITORS_CACHING" ] );
oRole.addPermissions( permissions[ "EDITORS_CATEGORIES" ] );
oRole.addPermissions( permissions[ "EDITORS_HTML_ATTRIBUTES" ] );
oRole.addPermissions( permissions[ "EDITORS_EDITOR_SELECTOR" ] );
oRole.addPermissions( permissions[ "EDITORS_CUSTOM_FIELDS" ] );
oRole.addPermissions( permissions[ "GLOBAL_SEARCH" ] );
oRole.addPermissions( permissions[ "MENUS_ADMIN" ] );
oRole.addPermissions( permissions[ "EDITORS_FEATURED_IMAGE" ] );
oRole.addPermissions( permissions[ "EMAIL_TEMPLATE_ADMIN" ] );
roleService.save( entity = oRole, transactional = false );

// Create Admin
var oRole = roleService.new(
properties = {
role : "Administrator",
description : "A ContentBox Administrator"
}
);
// Add All Permissions To Admin
for ( var key in permissions ) {
oRole.addPermissions( permissions[ key ] );
}
roleService.save( entity = oRole, transactional = false );

return oRole;
}

/**
* Create author
*
* @setup The setup object
* @adminRole The role of the admin string
*/
function createAuthor( required setup, required adminRole ){
function createAuthor( required setup ){
var oAuthor = variables.authorService
.new( properties = arguments.setup.getUserData() )
.setIsActive( true )
.setRole( arguments.adminRole );
.setRole( roleService.findByRole( "Administrator" ) );

return variables.authorService.save( oAuthor );
}
Expand Down
2 changes: 1 addition & 1 deletion modules/contentbox-installer/views/home/index.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!--- Tabs --->
<ul class="nav nav-tabs" id="tabs" role="tablist">
<li class="nav-item active">
<a href="##introduction" class="current" data-toggle="tab">
<a href="##introduction" class="nav-link" data-toggle="tab">
#cb.r( "tab.intro@installer" )#
</a>
</li>
Expand Down
4 changes: 2 additions & 2 deletions modules/contentbox/migrations/init/create_category.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ component {
table.datetime( "modifiedDate" ).withCurrent();
table.boolean( "isDeleted" ).default( false );

table.string( "slug" ).unique();
table.string( "category" ).unique();
table.string( "slug" );
table.string( "category" );
table.boolean( "isPublic" ).default( true );

// Relationships
Expand Down
2 changes: 1 addition & 1 deletion modules/contentbox/migrations/init/create_entry.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ component {
schema.create( "cb_entry", function(table) {

table.string( "contentID", 36 ).primaryKey();
table.longtext( "description" ).nullable();
table.longtext( "excerpt" ).nullable();

// Relationships
table.foreignKey( "contentID" ).references( "contentID" ).onTable( "cb_content" );
Expand Down

0 comments on commit 8583f3c

Please sign in to comment.