Skip to content

Commit

Permalink
Update development db script to include new theme group
Browse files Browse the repository at this point in the history
  • Loading branch information
eSilverStrike committed Nov 6, 2017
1 parent a845f0b commit b95d0e0
Showing 1 changed file with 44 additions and 4 deletions.
48 changes: 44 additions & 4 deletions public_html/admin/install/devel-db-update.php
Expand Up @@ -68,10 +68,50 @@ function update_DatabaseFor220()
// ***************************************
// Add database Geeklog Core updates here.
// NOTE: Cannot use ones found in normal upgrade script as no checks are performed to see if already done.





// Add theme admin
$result = DB_query("SELECT * FROM {$_TABLES['groups']} WHERE grp_name='Theme Admin'");
if ( DB_numRows($result) == 0 ) {
$sql1 = "INSERT INTO {$_TABLES['groups']} (grp_id, grp_name, grp_descr, grp_gl_core) "
. "VALUES (NULL, 'Theme Admin', 'Has full access to themes', 1)";
$sql2 = "INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_grp_id) VALUES (%d, %d)";
$sql3 = "INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) "
. "VALUES (NULL, 'theme.edit', 'Access to theme settings', 1)";
$sql4 = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (%d, %d)";

try {
DB_beginTransaction();

// Add Theme Admin to groups
if (!DB_query($sql1)) {
throw new \Exception(DB_error());
}

// Add Root group to Theme Admin group
$themeAdminGroupId = DB_insertId();
$rootGroupId = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
$sql2 = sprintf($sql2, $themeAdminGroupId, $rootGroupId);
if (!DB_query($sql2)) {
throw new \Exception(DB_error());
}

// Add theme.edit feature
if (!DB_query($sql3)) {
throw new \Exception(DB_error());
}

// Assign theme.edit feature to Theme Admin
$themeAdminFeatureId = DB_insertId();
$sql4 = sprintf($sql4, $themeAdminFeatureId, $themeAdminGroupId);
if (!DB_query($sql4)) {
throw new \Exception(DB_error());
}

DB_commit();
} catch (\Exception $e) {
DB_rollBack();
}
}

// ***************************************
// Core Plugin Updates Here
Expand Down

0 comments on commit b95d0e0

Please sign in to comment.